From 78289b4a58b58e9a8a76ef43ffbaf04a097e33c6 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Wed, 3 Jun 2020 14:40:18 +0300 Subject: iio: core: pass parent device as parameter during allocation The change passes the parent device to the iio_device_alloc() call. This also updates the devm_iio_device_alloc() call to consider the device object as the parent device by default. Having it passed like this, should ensure that any IIO device object already has a device object as parent, allowing for neater control, like passing the 'indio_dev' object for other stuff [like buffers/triggers/etc], and potentially creating iiom_xxx(indio_dev) functions. With this patch, only the 'drivers/platform/x86/toshiba_acpi.c' needs an update to pass the parent object as a parameter. In the next patch all devm_iio_device_alloc() calls will be handled. Acked-by: Andy Shevchenko Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/Documentation/device.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/iio/Documentation/device.txt b/drivers/staging/iio/Documentation/device.txt index ec42544a46aa..0d1275b1eb3f 100644 --- a/drivers/staging/iio/Documentation/device.txt +++ b/drivers/staging/iio/Documentation/device.txt @@ -8,7 +8,7 @@ The crucial structure for device drivers in iio is iio_dev. First allocate one using: -struct iio_dev *indio_dev = iio_device_alloc(sizeof(struct chip_state)); +struct iio_dev *indio_dev = iio_device_alloc(parent, sizeof(struct chip_state)); where chip_state is a structure of local state data for this instance of the chip. @@ -16,8 +16,6 @@ That data can be accessed using iio_priv(struct iio_dev *). Then fill in the following: -- indio_dev->dev.parent - Struct device associated with the underlying hardware. - indio_dev->name Name of the device being driven - made available as the name attribute in sysfs. -- cgit v1.2.3-58-ga151 From d3be83244c7dfe686d23f1c0bac75915587fc044 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 22 May 2020 11:22:05 +0300 Subject: iio: remove explicit IIO device parent assignment This patch applies the semantic patch: @@ expression I, P, SP; @@ I = devm_iio_device_alloc(P, SP); ... - I->dev.parent = P; It updates 302 files and does 307 deletions. This semantic patch also removes some comments like '/* Establish that the iio_dev is a child of the i2c device */' But this is is only done in case where the block is left empty. The patch does not seem to cover all cases. It looks like in some cases a different variable is used in some cases to assign the parent, but it points to the same reference. In other cases, the block covered by ... may be just too big to be covered by the semantic patch. However, this looks pretty good as well, as it does cover a big bulk of the drivers that should remove the parent assignment. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/counter/104-quad-8.c | 1 - drivers/counter/stm32-lptimer-cnt.c | 1 - drivers/iio/accel/adis16201.c | 1 - drivers/iio/accel/adis16209.c | 1 - drivers/iio/accel/adxl345_core.c | 1 - drivers/iio/accel/adxl372.c | 1 - drivers/iio/accel/bma180.c | 1 - drivers/iio/accel/bma220_spi.c | 1 - drivers/iio/accel/bma400_core.c | 1 - drivers/iio/accel/bmc150-accel-core.c | 1 - drivers/iio/accel/da280.c | 1 - drivers/iio/accel/da311.c | 1 - drivers/iio/accel/dmard06.c | 1 - drivers/iio/accel/dmard09.c | 1 - drivers/iio/accel/dmard10.c | 1 - drivers/iio/accel/hid-sensor-accel-3d.c | 1 - drivers/iio/accel/kxsd9.c | 1 - drivers/iio/accel/mc3230.c | 1 - drivers/iio/accel/mma7455_core.c | 1 - drivers/iio/accel/mma7660.c | 1 - drivers/iio/accel/mma9551.c | 1 - drivers/iio/accel/mxc4005.c | 1 - drivers/iio/accel/mxc6255.c | 1 - drivers/iio/accel/sca3000.c | 1 - drivers/iio/accel/ssp_accel_sensor.c | 1 - drivers/iio/accel/stk8312.c | 1 - drivers/iio/accel/stk8ba50.c | 1 - drivers/iio/adc/ab8500-gpadc.c | 1 - drivers/iio/adc/ad7091r-base.c | 1 - drivers/iio/adc/ad7124.c | 1 - drivers/iio/adc/ad7266.c | 1 - drivers/iio/adc/ad7291.c | 1 - drivers/iio/adc/ad7292.c | 1 - drivers/iio/adc/ad7298.c | 1 - drivers/iio/adc/ad7476.c | 1 - drivers/iio/adc/ad7606.c | 1 - drivers/iio/adc/ad7766.c | 1 - drivers/iio/adc/ad7768-1.c | 1 - drivers/iio/adc/ad7780.c | 1 - drivers/iio/adc/ad7791.c | 1 - drivers/iio/adc/ad7793.c | 1 - drivers/iio/adc/ad7887.c | 1 - drivers/iio/adc/ad7923.c | 1 - drivers/iio/adc/ad7949.c | 1 - drivers/iio/adc/ad799x.c | 1 - drivers/iio/adc/adi-axi-adc.c | 1 - drivers/iio/adc/aspeed_adc.c | 1 - drivers/iio/adc/at91-sama5d2_adc.c | 1 - drivers/iio/adc/at91_adc.c | 1 - drivers/iio/adc/axp20x_adc.c | 1 - drivers/iio/adc/axp288_adc.c | 1 - drivers/iio/adc/bcm_iproc_adc.c | 1 - drivers/iio/adc/berlin2-adc.c | 1 - drivers/iio/adc/cc10001_adc.c | 1 - drivers/iio/adc/cpcap-adc.c | 1 - drivers/iio/adc/da9150-gpadc.c | 1 - drivers/iio/adc/dln2-adc.c | 1 - drivers/iio/adc/envelope-detector.c | 1 - drivers/iio/adc/ep93xx_adc.c | 1 - drivers/iio/adc/exynos_adc.c | 1 - drivers/iio/adc/fsl-imx25-gcq.c | 1 - drivers/iio/adc/hi8435.c | 1 - drivers/iio/adc/imx7d_adc.c | 1 - drivers/iio/adc/ina2xx-adc.c | 1 - drivers/iio/adc/ingenic-adc.c | 1 - drivers/iio/adc/intel_mrfld_adc.c | 1 - drivers/iio/adc/lp8788_adc.c | 1 - drivers/iio/adc/lpc18xx_adc.c | 1 - drivers/iio/adc/lpc32xx_adc.c | 1 - drivers/iio/adc/ltc2471.c | 1 - drivers/iio/adc/ltc2485.c | 1 - drivers/iio/adc/max1027.c | 1 - drivers/iio/adc/max11100.c | 1 - drivers/iio/adc/max1118.c | 1 - drivers/iio/adc/max1241.c | 1 - drivers/iio/adc/max9611.c | 1 - drivers/iio/adc/mcp320x.c | 1 - drivers/iio/adc/mcp3422.c | 1 - drivers/iio/adc/men_z188_adc.c | 1 - drivers/iio/adc/meson_saradc.c | 1 - drivers/iio/adc/mt6577_auxadc.c | 1 - drivers/iio/adc/mxs-lradc-adc.c | 1 - drivers/iio/adc/nau7802.c | 1 - drivers/iio/adc/npcm_adc.c | 1 - drivers/iio/adc/palmas_gpadc.c | 1 - drivers/iio/adc/qcom-pm8xxx-xoadc.c | 1 - drivers/iio/adc/qcom-spmi-adc5.c | 1 - drivers/iio/adc/qcom-spmi-vadc.c | 1 - drivers/iio/adc/rcar-gyroadc.c | 1 - drivers/iio/adc/rn5t618-adc.c | 1 - drivers/iio/adc/rockchip_saradc.c | 1 - drivers/iio/adc/sc27xx_adc.c | 1 - drivers/iio/adc/sd_adc_modulator.c | 1 - drivers/iio/adc/spear_adc.c | 1 - drivers/iio/adc/stm32-adc.c | 1 - drivers/iio/adc/stm32-dfsdm-adc.c | 1 - drivers/iio/adc/stmpe-adc.c | 1 - drivers/iio/adc/stx104.c | 1 - drivers/iio/adc/sun4i-gpadc-iio.c | 1 - drivers/iio/adc/ti-adc081c.c | 1 - drivers/iio/adc/ti-adc0832.c | 1 - drivers/iio/adc/ti-adc084s021.c | 1 - drivers/iio/adc/ti-adc108s102.c | 1 - drivers/iio/adc/ti-adc12138.c | 1 - drivers/iio/adc/ti-adc128s052.c | 1 - drivers/iio/adc/ti-adc161s626.c | 1 - drivers/iio/adc/ti-ads1015.c | 1 - drivers/iio/adc/ti-ads124s08.c | 1 - drivers/iio/adc/ti-ads7950.c | 1 - drivers/iio/adc/ti-ads8344.c | 1 - drivers/iio/adc/ti-ads8688.c | 1 - drivers/iio/adc/ti-tlc4541.c | 1 - drivers/iio/adc/ti_am335x_adc.c | 1 - drivers/iio/adc/twl4030-madc.c | 1 - drivers/iio/adc/twl6030-gpadc.c | 1 - drivers/iio/adc/vf610_adc.c | 1 - drivers/iio/adc/viperboard_adc.c | 1 - drivers/iio/adc/xilinx-xadc-core.c | 1 - drivers/iio/afe/iio-rescale.c | 1 - drivers/iio/amplifiers/hmc425a.c | 1 - drivers/iio/chemical/ams-iaq-core.c | 1 - drivers/iio/chemical/atlas-sensor.c | 1 - drivers/iio/chemical/bme680_core.c | 1 - drivers/iio/chemical/ccs811.c | 1 - drivers/iio/chemical/pms7003.c | 1 - drivers/iio/chemical/sgp30.c | 1 - drivers/iio/chemical/sps30.c | 1 - drivers/iio/dac/ad5064.c | 1 - drivers/iio/dac/ad5360.c | 1 - drivers/iio/dac/ad5380.c | 1 - drivers/iio/dac/ad5421.c | 1 - drivers/iio/dac/ad5446.c | 1 - drivers/iio/dac/ad5449.c | 1 - drivers/iio/dac/ad5504.c | 1 - drivers/iio/dac/ad5592r-base.c | 1 - drivers/iio/dac/ad5624r_spi.c | 1 - drivers/iio/dac/ad5686.c | 1 - drivers/iio/dac/ad5755.c | 1 - drivers/iio/dac/ad5758.c | 1 - drivers/iio/dac/ad5761.c | 1 - drivers/iio/dac/ad5764.c | 1 - drivers/iio/dac/ad5791.c | 1 - drivers/iio/dac/ad7303.c | 1 - drivers/iio/dac/ad8801.c | 1 - drivers/iio/dac/cio-dac.c | 1 - drivers/iio/dac/dpot-dac.c | 1 - drivers/iio/dac/ds4424.c | 1 - drivers/iio/dac/lpc18xx_dac.c | 1 - drivers/iio/dac/ltc1660.c | 1 - drivers/iio/dac/ltc2632.c | 1 - drivers/iio/dac/m62332.c | 3 --- drivers/iio/dac/max517.c | 3 --- drivers/iio/dac/max5821.c | 1 - drivers/iio/dac/mcp4725.c | 1 - drivers/iio/dac/mcp4922.c | 1 - drivers/iio/dac/stm32-dac.c | 1 - drivers/iio/dac/ti-dac082s085.c | 1 - drivers/iio/dac/ti-dac5571.c | 1 - drivers/iio/dac/ti-dac7311.c | 1 - drivers/iio/dac/ti-dac7612.c | 1 - drivers/iio/dac/vf610_dac.c | 1 - drivers/iio/frequency/ad9523.c | 1 - drivers/iio/frequency/adf4350.c | 1 - drivers/iio/frequency/adf4371.c | 1 - drivers/iio/gyro/adis16080.c | 1 - drivers/iio/gyro/adis16130.c | 1 - drivers/iio/gyro/adis16136.c | 1 - drivers/iio/gyro/adis16260.c | 1 - drivers/iio/gyro/adxrs450.c | 1 - drivers/iio/gyro/bmg160_core.c | 1 - drivers/iio/gyro/fxas21002c_core.c | 1 - drivers/iio/gyro/hid-sensor-gyro-3d.c | 1 - drivers/iio/gyro/itg3200_core.c | 1 - drivers/iio/gyro/mpu3050-core.c | 1 - drivers/iio/gyro/ssp_gyro_sensor.c | 1 - drivers/iio/health/max30100.c | 1 - drivers/iio/health/max30102.c | 1 - drivers/iio/humidity/am2315.c | 1 - drivers/iio/humidity/hdc100x.c | 1 - drivers/iio/humidity/hid-sensor-humidity.c | 1 - drivers/iio/humidity/htu21.c | 1 - drivers/iio/humidity/si7005.c | 1 - drivers/iio/humidity/si7020.c | 1 - drivers/iio/imu/adis16400.c | 1 - drivers/iio/imu/adis16460.c | 1 - drivers/iio/imu/adis16475.c | 1 - drivers/iio/imu/adis16480.c | 1 - drivers/iio/imu/bmi160/bmi160_core.c | 1 - drivers/iio/imu/fxos8700_core.c | 1 - drivers/iio/imu/kmx61.c | 1 - drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 1 - drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 1 - drivers/iio/light/acpi-als.c | 1 - drivers/iio/light/adjd_s311.c | 1 - drivers/iio/light/adux1020.c | 1 - drivers/iio/light/al3010.c | 1 - drivers/iio/light/al3320a.c | 1 - drivers/iio/light/apds9300.c | 1 - drivers/iio/light/apds9960.c | 1 - drivers/iio/light/bh1750.c | 1 - drivers/iio/light/bh1780.c | 1 - drivers/iio/light/cm32181.c | 1 - drivers/iio/light/cm3232.c | 1 - drivers/iio/light/cm3323.c | 1 - drivers/iio/light/cm36651.c | 1 - drivers/iio/light/gp2ap002.c | 1 - drivers/iio/light/gp2ap020a00f.c | 1 - drivers/iio/light/hid-sensor-als.c | 1 - drivers/iio/light/hid-sensor-prox.c | 1 - drivers/iio/light/iqs621-als.c | 1 - drivers/iio/light/isl29018.c | 1 - drivers/iio/light/isl29028.c | 1 - drivers/iio/light/isl29125.c | 1 - drivers/iio/light/jsa1212.c | 1 - drivers/iio/light/lv0104cs.c | 1 - drivers/iio/light/max44000.c | 1 - drivers/iio/light/max44009.c | 1 - drivers/iio/light/noa1305.c | 1 - drivers/iio/light/opt3001.c | 1 - drivers/iio/light/pa12203001.c | 1 - drivers/iio/light/rpr0521.c | 1 - drivers/iio/light/si1133.c | 1 - drivers/iio/light/si1145.c | 1 - drivers/iio/light/st_uvis25_core.c | 1 - drivers/iio/light/stk3310.c | 1 - drivers/iio/light/tcs3414.c | 1 - drivers/iio/light/tcs3472.c | 1 - drivers/iio/light/tsl2563.c | 1 - drivers/iio/light/tsl2583.c | 1 - drivers/iio/light/tsl2772.c | 1 - drivers/iio/light/tsl4531.c | 1 - drivers/iio/light/us5182d.c | 1 - drivers/iio/light/vcnl4000.c | 1 - drivers/iio/light/vcnl4035.c | 1 - drivers/iio/light/veml6030.c | 1 - drivers/iio/light/veml6070.c | 1 - drivers/iio/light/vl6180.c | 1 - drivers/iio/light/zopt2201.c | 1 - drivers/iio/magnetometer/ak8974.c | 1 - drivers/iio/magnetometer/bmc150_magn.c | 1 - drivers/iio/magnetometer/hid-sensor-magn-3d.c | 1 - drivers/iio/magnetometer/hmc5843_core.c | 1 - drivers/iio/magnetometer/mag3110.c | 1 - drivers/iio/magnetometer/mmc35240.c | 1 - drivers/iio/magnetometer/rm3100-core.c | 1 - drivers/iio/multiplexer/iio-mux.c | 1 - drivers/iio/orientation/hid-sensor-incl-3d.c | 1 - drivers/iio/position/iqs624-pos.c | 1 - drivers/iio/potentiometer/ad5272.c | 1 - drivers/iio/potentiometer/ds1803.c | 1 - drivers/iio/potentiometer/max5432.c | 1 - drivers/iio/potentiometer/max5481.c | 1 - drivers/iio/potentiometer/max5487.c | 1 - drivers/iio/potentiometer/mcp4018.c | 1 - drivers/iio/potentiometer/mcp41010.c | 1 - drivers/iio/potentiometer/mcp4131.c | 1 - drivers/iio/potentiometer/mcp4531.c | 1 - drivers/iio/potentiometer/tpl0102.c | 1 - drivers/iio/pressure/abp060mg.c | 1 - drivers/iio/pressure/bmp280-core.c | 1 - drivers/iio/pressure/dlhl60d.c | 1 - drivers/iio/pressure/dps310.c | 1 - drivers/iio/pressure/hid-sensor-press.c | 1 - drivers/iio/pressure/hp03.c | 1 - drivers/iio/pressure/hp206c.c | 1 - drivers/iio/pressure/icp10100.c | 1 - drivers/iio/pressure/mpl115.c | 1 - drivers/iio/pressure/mpl3115.c | 1 - drivers/iio/pressure/ms5637.c | 1 - drivers/iio/pressure/t5403.c | 1 - drivers/iio/pressure/zpa2326.c | 1 - drivers/iio/proximity/as3935.c | 1 - drivers/iio/proximity/isl29501.c | 1 - drivers/iio/proximity/mb1232.c | 1 - drivers/iio/proximity/rfd77402.c | 1 - drivers/iio/proximity/sx9310.c | 1 - drivers/iio/proximity/sx9500.c | 1 - drivers/iio/proximity/vl53l0x-i2c.c | 1 - drivers/iio/resolver/ad2s1200.c | 1 - drivers/iio/resolver/ad2s90.c | 1 - drivers/iio/temperature/hid-sensor-temperature.c | 1 - drivers/iio/temperature/iqs620at-temp.c | 1 - drivers/iio/temperature/ltc2983.c | 1 - drivers/iio/temperature/max31856.c | 1 - drivers/iio/temperature/maxim_thermocouple.c | 1 - drivers/iio/temperature/mlx90614.c | 1 - drivers/iio/temperature/mlx90632.c | 1 - drivers/iio/temperature/tmp006.c | 1 - drivers/iio/temperature/tmp007.c | 1 - drivers/iio/temperature/tsys02d.c | 1 - drivers/iio/trigger/stm32-timer-trigger.c | 1 - drivers/input/touchscreen/tsc2007_iio.c | 1 - drivers/staging/iio/accel/adis16203.c | 1 - drivers/staging/iio/accel/adis16240.c | 1 - drivers/staging/iio/adc/ad7280a.c | 1 - drivers/staging/iio/adc/ad7816.c | 1 - drivers/staging/iio/cdc/ad7150.c | 2 -- drivers/staging/iio/cdc/ad7746.c | 1 - drivers/staging/iio/frequency/ad9832.c | 1 - drivers/staging/iio/frequency/ad9834.c | 1 - drivers/staging/iio/impedance-analyzer/ad5933.c | 1 - drivers/staging/iio/resolver/ad2s1210.c | 1 - 302 files changed, 307 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c index aa13708c2bc3..69fd34fe2749 100644 --- a/drivers/counter/104-quad-8.c +++ b/drivers/counter/104-quad-8.c @@ -1538,7 +1538,6 @@ static int quad8_probe(struct device *dev, unsigned int id) indio_dev->num_channels = ARRAY_SIZE(quad8_channels); indio_dev->channels = quad8_channels; indio_dev->name = dev_name(dev); - indio_dev->dev.parent = dev; /* Initialize Counter device and driver data */ quad8iio = iio_priv(indio_dev); diff --git a/drivers/counter/stm32-lptimer-cnt.c b/drivers/counter/stm32-lptimer-cnt.c index 8e276eb655f5..fd6828e2d34f 100644 --- a/drivers/counter/stm32-lptimer-cnt.c +++ b/drivers/counter/stm32-lptimer-cnt.c @@ -648,7 +648,6 @@ static int stm32_lptim_cnt_probe(struct platform_device *pdev) /* Initialize IIO device */ indio_dev->name = dev_name(&pdev->dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->info = &stm32_lptim_cnt_iio_info; if (ddata->has_encoder) diff --git a/drivers/iio/accel/adis16201.c b/drivers/iio/accel/adis16201.c index 4154e7396bbe..59a24c355a1a 100644 --- a/drivers/iio/accel/adis16201.c +++ b/drivers/iio/accel/adis16201.c @@ -271,7 +271,6 @@ static int adis16201_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); indio_dev->name = spi->dev.driver->name; - indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16201_info; indio_dev->channels = adis16201_channels; diff --git a/drivers/iio/accel/adis16209.c b/drivers/iio/accel/adis16209.c index 31d45e7c5485..3d5538e2f76e 100644 --- a/drivers/iio/accel/adis16209.c +++ b/drivers/iio/accel/adis16209.c @@ -282,7 +282,6 @@ static int adis16209_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); indio_dev->name = spi->dev.driver->name; - indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16209_info; indio_dev->channels = adis16209_channels; indio_dev->num_channels = ARRAY_SIZE(adis16209_channels); diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 9c269799e6c1..6d6468ef3dfd 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -246,7 +246,6 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap, return ret; } - indio_dev->dev.parent = dev; indio_dev->name = name; indio_dev->info = &adxl345_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c index 60daf04ce188..26ca45073a56 100644 --- a/drivers/iio/accel/adxl372.c +++ b/drivers/iio/accel/adxl372.c @@ -938,7 +938,6 @@ int adxl372_probe(struct device *dev, struct regmap *regmap, indio_dev->channels = adxl372_channels; indio_dev->num_channels = ARRAY_SIZE(adxl372_channels); indio_dev->available_scan_masks = adxl372_channel_masks; - indio_dev->dev.parent = dev; indio_dev->name = name; indio_dev->info = &adxl372_info; indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE; diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index 265722e4b13f..5b7a467c7b27 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -1038,7 +1038,6 @@ static int bma180_probe(struct i2c_client *client, goto err_chip_disable; mutex_init(&data->mutex); - indio_dev->dev.parent = dev; indio_dev->channels = data->part_info->channels; indio_dev->num_channels = data->part_info->num_channels; indio_dev->name = id->name; diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index cae905039cb6..cce8324394f5 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -237,7 +237,6 @@ static int bma220_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); mutex_init(&data->lock); - indio_dev->dev.parent = &spi->dev; indio_dev->info = &bma220_info; indio_dev->name = BMA220_DEVICE_NAME; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c index cc77f89c048b..7eeba80e32cb 100644 --- a/drivers/iio/accel/bma400_core.c +++ b/drivers/iio/accel/bma400_core.c @@ -816,7 +816,6 @@ int bma400_probe(struct device *dev, struct regmap *regmap, const char *name) return ret; mutex_init(&data->mutex); - indio_dev->dev.parent = dev; indio_dev->name = name; indio_dev->info = &bma400_info; indio_dev->channels = bma400_channels; diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 121b4e89f038..8f60d0727ee8 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -1574,7 +1574,6 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, mutex_init(&data->mutex); - indio_dev->dev.parent = dev; indio_dev->channels = data->chip_info->channels; indio_dev->num_channels = data->chip_info->num_channels; indio_dev->name = name ? name : data->chip_info->name; diff --git a/drivers/iio/accel/da280.c b/drivers/iio/accel/da280.c index 227bea2d738b..4472dde6899e 100644 --- a/drivers/iio/accel/da280.c +++ b/drivers/iio/accel/da280.c @@ -120,7 +120,6 @@ static int da280_probe(struct i2c_client *client, data->client = client; i2c_set_clientdata(client, indio_dev); - indio_dev->dev.parent = &client->dev; indio_dev->info = &da280_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = da280_channels; diff --git a/drivers/iio/accel/da311.c b/drivers/iio/accel/da311.c index c20979249a48..3b3df620ba27 100644 --- a/drivers/iio/accel/da311.c +++ b/drivers/iio/accel/da311.c @@ -231,7 +231,6 @@ static int da311_probe(struct i2c_client *client, data->client = client; i2c_set_clientdata(client, indio_dev); - indio_dev->dev.parent = &client->dev; indio_dev->info = &da311_info; indio_dev->name = "da311"; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/accel/dmard06.c b/drivers/iio/accel/dmard06.c index ef89bded7390..de2868c28d95 100644 --- a/drivers/iio/accel/dmard06.c +++ b/drivers/iio/accel/dmard06.c @@ -161,7 +161,6 @@ static int dmard06_probe(struct i2c_client *client, dmard06->chip_id = ret; i2c_set_clientdata(client, indio_dev); - indio_dev->dev.parent = &client->dev; indio_dev->name = DMARD06_DRV_NAME; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = dmard06_channels; diff --git a/drivers/iio/accel/dmard09.c b/drivers/iio/accel/dmard09.c index 2d666cd69b29..e6e28c964777 100644 --- a/drivers/iio/accel/dmard09.c +++ b/drivers/iio/accel/dmard09.c @@ -116,7 +116,6 @@ static int dmard09_probe(struct i2c_client *client, } i2c_set_clientdata(client, indio_dev); - indio_dev->dev.parent = &client->dev; indio_dev->name = DMARD09_DRV_NAME; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = dmard09_channels; diff --git a/drivers/iio/accel/dmard10.c b/drivers/iio/accel/dmard10.c index 71c852b8bb3e..90206f015857 100644 --- a/drivers/iio/accel/dmard10.c +++ b/drivers/iio/accel/dmard10.c @@ -196,7 +196,6 @@ static int dmard10_probe(struct i2c_client *client, data->client = client; i2c_set_clientdata(client, indio_dev); - indio_dev->dev.parent = &client->dev; indio_dev->info = &dmard10_info; indio_dev->name = "dmard10"; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index 0ec0533448bc..4c5e594024f8 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c @@ -384,7 +384,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev) goto error_free_dev_mem; } - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &accel_3d_info; indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index 0b876b2dc5bd..63b1d8ee6c6f 100644 --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c @@ -411,7 +411,6 @@ int kxsd9_common_probe(struct device *dev, indio_dev->channels = kxsd9_channels; indio_dev->num_channels = ARRAY_SIZE(kxsd9_channels); indio_dev->name = name; - indio_dev->dev.parent = dev; indio_dev->info = &kxsd9_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->available_scan_masks = kxsd9_scan_masks; diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c index 02b3d25b3d96..46e4283fc037 100644 --- a/drivers/iio/accel/mc3230.c +++ b/drivers/iio/accel/mc3230.c @@ -132,7 +132,6 @@ static int mc3230_probe(struct i2c_client *client, data->client = client; i2c_set_clientdata(client, indio_dev); - indio_dev->dev.parent = &client->dev; indio_dev->info = &mc3230_info; indio_dev->name = "mc3230"; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/accel/mma7455_core.c b/drivers/iio/accel/mma7455_core.c index 8b5a6aff9bf4..7e99bcb3398d 100644 --- a/drivers/iio/accel/mma7455_core.c +++ b/drivers/iio/accel/mma7455_core.c @@ -260,7 +260,6 @@ int mma7455_core_probe(struct device *dev, struct regmap *regmap, indio_dev->info = &mma7455_info; indio_dev->name = name; - indio_dev->dev.parent = dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = mma7455_channels; indio_dev->num_channels = ARRAY_SIZE(mma7455_channels); diff --git a/drivers/iio/accel/mma7660.c b/drivers/iio/accel/mma7660.c index 7faf6d8657ae..b3c9136d51ec 100644 --- a/drivers/iio/accel/mma7660.c +++ b/drivers/iio/accel/mma7660.c @@ -188,7 +188,6 @@ static int mma7660_probe(struct i2c_client *client, mutex_init(&data->lock); data->mode = MMA7660_MODE_STANDBY; - indio_dev->dev.parent = &client->dev; indio_dev->info = &mma7660_info; indio_dev->name = MMA7660_DRIVER_NAME; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c index 99e4a21ca942..08a2303cc9df 100644 --- a/drivers/iio/accel/mma9551.c +++ b/drivers/iio/accel/mma9551.c @@ -473,7 +473,6 @@ static int mma9551_probe(struct i2c_client *client, mutex_init(&data->mutex); - indio_dev->dev.parent = &client->dev; indio_dev->channels = mma9551_channels; indio_dev->num_channels = ARRAY_SIZE(mma9551_channels); indio_dev->name = name; diff --git a/drivers/iio/accel/mxc4005.c b/drivers/iio/accel/mxc4005.c index d2950831dd24..f877263dc6ef 100644 --- a/drivers/iio/accel/mxc4005.c +++ b/drivers/iio/accel/mxc4005.c @@ -416,7 +416,6 @@ static int mxc4005_probe(struct i2c_client *client, mutex_init(&data->mutex); - indio_dev->dev.parent = &client->dev; indio_dev->channels = mxc4005_channels; indio_dev->num_channels = ARRAY_SIZE(mxc4005_channels); indio_dev->available_scan_masks = mxc4005_scan_masks; diff --git a/drivers/iio/accel/mxc6255.c b/drivers/iio/accel/mxc6255.c index f532f8643aa4..9aeeadc420d3 100644 --- a/drivers/iio/accel/mxc6255.c +++ b/drivers/iio/accel/mxc6255.c @@ -138,7 +138,6 @@ static int mxc6255_probe(struct i2c_client *client, data->regmap = regmap; indio_dev->name = MXC6255_DRV_NAME; - indio_dev->dev.parent = &client->dev; indio_dev->channels = mxc6255_channels; indio_dev->num_channels = ARRAY_SIZE(mxc6255_channels); indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c index 6e429072e44a..6365be6a9237 100644 --- a/drivers/iio/accel/sca3000.c +++ b/drivers/iio/accel/sca3000.c @@ -1467,7 +1467,6 @@ static int sca3000_probe(struct spi_device *spi) st->info = &sca3000_spi_chip_info_tbl[spi_get_device_id(spi) ->driver_data]; - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &sca3000_info; if (st->info->temp_output) { diff --git a/drivers/iio/accel/ssp_accel_sensor.c b/drivers/iio/accel/ssp_accel_sensor.c index c32647abce20..3102b507e22a 100644 --- a/drivers/iio/accel/ssp_accel_sensor.c +++ b/drivers/iio/accel/ssp_accel_sensor.c @@ -108,7 +108,6 @@ static int ssp_accel_probe(struct platform_device *pdev) spd->type = SSP_ACCELEROMETER_SENSOR; indio_dev->name = ssp_accel_device_name; - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->info = &ssp_accel_iio_info; indio_dev->modes = INDIO_BUFFER_SOFTWARE; diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c index 58c160ccdee7..616d0b90dd92 100644 --- a/drivers/iio/accel/stk8312.c +++ b/drivers/iio/accel/stk8312.c @@ -515,7 +515,6 @@ static int stk8312_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &stk8312_info; indio_dev->name = STK8312_DRIVER_NAME; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c index c70ddec29eb4..98fad8cd6fe7 100644 --- a/drivers/iio/accel/stk8ba50.c +++ b/drivers/iio/accel/stk8ba50.c @@ -399,7 +399,6 @@ static int stk8ba50_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &stk8ba50_info; indio_dev->name = STK8BA50_DRIVER_NAME; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ab8500-gpadc.c b/drivers/iio/adc/ab8500-gpadc.c index fd5b18d7f0c2..b264f88cf9d9 100644 --- a/drivers/iio/adc/ab8500-gpadc.c +++ b/drivers/iio/adc/ab8500-gpadc.c @@ -1163,7 +1163,6 @@ static int ab8500_gpadc_probe(struct platform_device *pdev) pm_runtime_put(dev); - indio_dev->dev.parent = dev; indio_dev->dev.of_node = np; indio_dev->name = "ab8500-gpadc"; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c index 33c40357bd5e..63b4d6ea4566 100644 --- a/drivers/iio/adc/ad7091r-base.c +++ b/drivers/iio/adc/ad7091r-base.c @@ -224,7 +224,6 @@ int ad7091r_probe(struct device *dev, const char *name, st->chip_info = chip_info; st->map = map; - iio_dev->dev.parent = dev; iio_dev->name = name; iio_dev->info = &ad7091r_info; iio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index a3c0647a5391..bb53ab265b64 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -683,7 +683,6 @@ static int ad7124_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &ad7124_info; diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c index c8524f098883..715d39b200df 100644 --- a/drivers/iio/adc/ad7266.c +++ b/drivers/iio/adc/ad7266.c @@ -437,7 +437,6 @@ static int ad7266_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); st->spi = spi; - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ad7291.c b/drivers/iio/adc/ad7291.c index b2b137fed246..dbba62ad5e16 100644 --- a/drivers/iio/adc/ad7291.c +++ b/drivers/iio/adc/ad7291.c @@ -502,7 +502,6 @@ static int ad7291_probe(struct i2c_client *client, indio_dev->channels = ad7291_channels; indio_dev->num_channels = ARRAY_SIZE(ad7291_channels); - indio_dev->dev.parent = &client->dev; indio_dev->dev.of_node = client->dev.of_node; indio_dev->info = &ad7291_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ad7292.c b/drivers/iio/adc/ad7292.c index 6595fd196288..2eafbe7ac7c7 100644 --- a/drivers/iio/adc/ad7292.c +++ b/drivers/iio/adc/ad7292.c @@ -304,7 +304,6 @@ static int ad7292_probe(struct spi_device *spi) st->vref_mv = 1250; } - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &ad7292_info; diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index dc8d8c5f6ad3..26768b15c0de 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c @@ -312,7 +312,6 @@ static int ad7298_probe(struct spi_device *spi) st->spi = spi; indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ad7298_channels; diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c index 4e816d714ad2..e2a69dd6a47e 100644 --- a/drivers/iio/adc/ad7476.c +++ b/drivers/iio/adc/ad7476.c @@ -301,7 +301,6 @@ static int ad7476_probe(struct spi_device *spi) st->spi = spi; /* Establish that the iio_dev is a child of the spi device */ - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index e4683a68522a..23d8277086ee 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -614,7 +614,6 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address, if (ret) return ret; - indio_dev->dev.parent = dev; if (st->gpio_os) { if (st->gpio_range) indio_dev->info = &ad7606_info_os_and_range; diff --git a/drivers/iio/adc/ad7766.c b/drivers/iio/adc/ad7766.c index bc388ea41754..4bcf8a34bc46 100644 --- a/drivers/iio/adc/ad7766.c +++ b/drivers/iio/adc/ad7766.c @@ -242,7 +242,6 @@ static int ad7766_probe(struct spi_device *spi) if (IS_ERR(ad7766->pd_gpio)) return PTR_ERR(ad7766->pd_gpio); - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ad7766_channels; diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c index 0d132708c429..be2aed551324 100644 --- a/drivers/iio/adc/ad7768-1.c +++ b/drivers/iio/adc/ad7768-1.c @@ -584,7 +584,6 @@ static int ad7768_probe(struct spi_device *spi) indio_dev->channels = ad7768_channels; indio_dev->num_channels = ARRAY_SIZE(ad7768_channels); - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad7768_info; indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_TRIGGERED; diff --git a/drivers/iio/adc/ad7780.c b/drivers/iio/adc/ad7780.c index f47606ebbbbe..ecbbdfa1f88b 100644 --- a/drivers/iio/adc/ad7780.c +++ b/drivers/iio/adc/ad7780.c @@ -320,7 +320,6 @@ static int ad7780_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = &st->chip_info->channel; diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c index 48432b6f6002..b636cf0a8f19 100644 --- a/drivers/iio/adc/ad7791.c +++ b/drivers/iio/adc/ad7791.c @@ -425,7 +425,6 @@ static int ad7791_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c index 808485f42415..b858723c144b 100644 --- a/drivers/iio/adc/ad7793.c +++ b/drivers/iio/adc/ad7793.c @@ -818,7 +818,6 @@ static int ad7793_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c index c6a3428e950a..ca4c98401ebc 100644 --- a/drivers/iio/adc/ad7887.c +++ b/drivers/iio/adc/ad7887.c @@ -265,7 +265,6 @@ static int ad7887_probe(struct spi_device *spi) st->spi = spi; /* Estabilish that the iio_dev is a child of the spi device */ - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad7887_info; diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index 1d124c87c6ac..6f1996cfd1e5 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -315,7 +315,6 @@ static int ad7923_probe(struct spi_device *spi) info = &ad7923_chip_info[spi_get_device_id(spi)->driver_data]; indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = info->channels; diff --git a/drivers/iio/adc/ad7949.c b/drivers/iio/adc/ad7949.c index 2c6f60edb7ce..c6676d317356 100644 --- a/drivers/iio/adc/ad7949.c +++ b/drivers/iio/adc/ad7949.c @@ -243,7 +243,6 @@ static int ad7949_spi_probe(struct spi_device *spi) return -ENOMEM; } - indio_dev->dev.parent = dev; indio_dev->dev.of_node = dev->of_node; indio_dev->info = &ad7949_spi_info; indio_dev->name = spi_get_device_id(spi)->name; diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index ef013af1aec0..6a389bbbffaa 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -814,7 +814,6 @@ static int ad799x_probe(struct i2c_client *client, st->client = client; - indio_dev->dev.parent = &client->dev; indio_dev->dev.of_node = client->dev.of_node; indio_dev->name = id->name; indio_dev->info = st->chip_config->info; diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c index c24c8da99eb4..63d926e86798 100644 --- a/drivers/iio/adc/adi-axi-adc.c +++ b/drivers/iio/adc/adi-axi-adc.c @@ -435,7 +435,6 @@ static int adi_axi_adc_probe(struct platform_device *pdev) } indio_dev->info = &adi_axi_adc_info; - indio_dev->dev.parent = &pdev->dev; indio_dev->name = "adi-axi-adc"; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->num_channels = conv->chip_info->num_channels; diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c index 1e5375235cfe..19efaa41bc34 100644 --- a/drivers/iio/adc/aspeed_adc.c +++ b/drivers/iio/adc/aspeed_adc.c @@ -252,7 +252,6 @@ static int aspeed_adc_probe(struct platform_device *pdev) model_data = of_device_get_match_data(&pdev->dev); indio_dev->name = model_data->model_name; - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &aspeed_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = aspeed_adc_iio_channels; diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index 9abbbdcc7420..1b4340a6c6bb 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -1710,7 +1710,6 @@ static int at91_adc_probe(struct platform_device *pdev) if (!indio_dev) return -ENOMEM; - indio_dev->dev.parent = &pdev->dev; indio_dev->name = dev_name(&pdev->dev); indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE; indio_dev->info = &at91_adc_info; diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 0368b6dc6d60..8544f0b3b50f 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -1172,7 +1172,6 @@ static int at91_adc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, idev); - idev->dev.parent = &pdev->dev; idev->name = dev_name(&pdev->dev); idev->modes = INDIO_DIRECT_MODE; idev->info = &at91_adc_info; diff --git a/drivers/iio/adc/axp20x_adc.c b/drivers/iio/adc/axp20x_adc.c index 88059480da17..b138f1a1fb51 100644 --- a/drivers/iio/adc/axp20x_adc.c +++ b/drivers/iio/adc/axp20x_adc.c @@ -668,7 +668,6 @@ static int axp20x_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); info->regmap = axp20x_dev->regmap; - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c index 8ea2aed6d6f5..5f5e8b39e4d2 100644 --- a/drivers/iio/adc/axp288_adc.c +++ b/drivers/iio/adc/axp288_adc.c @@ -271,7 +271,6 @@ static int axp288_adc_probe(struct platform_device *pdev) return ret; } - indio_dev->dev.parent = &pdev->dev; indio_dev->name = pdev->name; indio_dev->channels = axp288_adc_channels; indio_dev->num_channels = ARRAY_SIZE(axp288_adc_channels); diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c index 5e396104ac86..9bf29c2384a4 100644 --- a/drivers/iio/adc/bcm_iproc_adc.c +++ b/drivers/iio/adc/bcm_iproc_adc.c @@ -573,7 +573,6 @@ static int iproc_adc_probe(struct platform_device *pdev) } indio_dev->name = "iproc-static-adc"; - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->info = &iproc_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/berlin2-adc.c b/drivers/iio/adc/berlin2-adc.c index 72d8fa94ab31..8b04b95b7b7a 100644 --- a/drivers/iio/adc/berlin2-adc.c +++ b/drivers/iio/adc/berlin2-adc.c @@ -321,7 +321,6 @@ static int berlin2_adc_probe(struct platform_device *pdev) init_waitqueue_head(&priv->wq); mutex_init(&priv->lock); - indio_dev->dev.parent = &pdev->dev; indio_dev->name = dev_name(&pdev->dev); indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &berlin2_adc_info; diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c index fe9257624f16..e16ac935693b 100644 --- a/drivers/iio/adc/cc10001_adc.c +++ b/drivers/iio/adc/cc10001_adc.c @@ -334,7 +334,6 @@ static int cc10001_adc_probe(struct platform_device *pdev) if (ret) return ret; - indio_dev->dev.parent = &pdev->dev; indio_dev->name = dev_name(&pdev->dev); indio_dev->info = &cc10001_adc_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c index 5086a337f4c9..9b0d6d7c90e9 100644 --- a/drivers/iio/adc/cpcap-adc.c +++ b/drivers/iio/adc/cpcap-adc.c @@ -985,7 +985,6 @@ static int cpcap_adc_probe(struct platform_device *pdev) init_waitqueue_head(&ddata->wq_data_avail); indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE; - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->channels = cpcap_adc_channels; indio_dev->num_channels = ARRAY_SIZE(cpcap_adc_channels); diff --git a/drivers/iio/adc/da9150-gpadc.c b/drivers/iio/adc/da9150-gpadc.c index ae8bcc32f63d..3461e26a89bd 100644 --- a/drivers/iio/adc/da9150-gpadc.c +++ b/drivers/iio/adc/da9150-gpadc.c @@ -354,7 +354,6 @@ static int da9150_gpadc_probe(struct platform_device *pdev) } indio_dev->name = dev_name(dev); - indio_dev->dev.parent = dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->info = &da9150_gpadc_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/dln2-adc.c b/drivers/iio/adc/dln2-adc.c index 65c7c9329b1c..6689cb93c6a2 100644 --- a/drivers/iio/adc/dln2-adc.c +++ b/drivers/iio/adc/dln2-adc.c @@ -652,7 +652,6 @@ static int dln2_adc_probe(struct platform_device *pdev) IIO_CHAN_SOFT_TIMESTAMP_ASSIGN(dln2->iio_channels[i], i); indio_dev->name = DLN2_ADC_MOD_NAME; - indio_dev->dev.parent = dev; indio_dev->info = &dln2_adc_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = dln2->iio_channels; diff --git a/drivers/iio/adc/envelope-detector.c b/drivers/iio/adc/envelope-detector.c index 28f3d6758eb5..77e60d160d02 100644 --- a/drivers/iio/adc/envelope-detector.c +++ b/drivers/iio/adc/envelope-detector.c @@ -343,7 +343,6 @@ static int envelope_detector_probe(struct platform_device *pdev) INIT_DELAYED_WORK(&env->comp_timeout, envelope_detector_timeout); indio_dev->name = dev_name(dev); - indio_dev->dev.parent = dev; indio_dev->dev.of_node = dev->of_node; indio_dev->info = &envelope_detector_info; indio_dev->channels = &envelope_detector_iio_channel; diff --git a/drivers/iio/adc/ep93xx_adc.c b/drivers/iio/adc/ep93xx_adc.c index 5c97e8a511f2..c08ab3c6dfaf 100644 --- a/drivers/iio/adc/ep93xx_adc.c +++ b/drivers/iio/adc/ep93xx_adc.c @@ -170,7 +170,6 @@ static int ep93xx_adc_probe(struct platform_device *pdev) return PTR_ERR(priv->base); } - iiodev->dev.parent = &pdev->dev; iiodev->name = dev_name(&pdev->dev); iiodev->modes = INDIO_DIRECT_MODE; iiodev->info = &ep93xx_adc_info; diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index 6bda4f4d89fe..27606fa7c7bb 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -867,7 +867,6 @@ static int exynos_adc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); indio_dev->name = dev_name(&pdev->dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->info = &exynos_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/fsl-imx25-gcq.c b/drivers/iio/adc/fsl-imx25-gcq.c index b0a4dc88ba9b..8cb51cf7a816 100644 --- a/drivers/iio/adc/fsl-imx25-gcq.c +++ b/drivers/iio/adc/fsl-imx25-gcq.c @@ -350,7 +350,6 @@ static int mx25_gcq_probe(struct platform_device *pdev) goto err_clk_unprepare; } - indio_dev->dev.parent = &pdev->dev; indio_dev->channels = mx25_gcq_channels; indio_dev->num_channels = ARRAY_SIZE(mx25_gcq_channels); indio_dev->info = &mx25_gcq_iio_info; diff --git a/drivers/iio/adc/hi8435.c b/drivers/iio/adc/hi8435.c index 8da45bf36d36..dd23b8593b7b 100644 --- a/drivers/iio/adc/hi8435.c +++ b/drivers/iio/adc/hi8435.c @@ -488,7 +488,6 @@ static int hi8435_probe(struct spi_device *spi) spi_set_drvdata(spi, idev); mutex_init(&priv->lock); - idev->dev.parent = &spi->dev; idev->dev.of_node = spi->dev.of_node; idev->name = spi_get_device_id(spi)->name; idev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c index 2a2fbf788e95..4969a5f941e3 100644 --- a/drivers/iio/adc/imx7d_adc.c +++ b/drivers/iio/adc/imx7d_adc.c @@ -515,7 +515,6 @@ static int imx7d_adc_probe(struct platform_device *pdev) init_completion(&info->completion); indio_dev->name = dev_name(dev); - indio_dev->dev.parent = dev; indio_dev->info = &imx7d_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = imx7d_adc_iio_channels; diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c index bdd7cba6f6b0..467f48b6f451 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -1015,7 +1015,6 @@ static int ina2xx_probe(struct i2c_client *client, } indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE; - indio_dev->dev.parent = &client->dev; indio_dev->dev.of_node = client->dev.of_node; if (id->driver_data == ina226) { indio_dev->channels = ina226_channels; diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c index 39c0a609fc94..3ea097c9650e 100644 --- a/drivers/iio/adc/ingenic-adc.c +++ b/drivers/iio/adc/ingenic-adc.c @@ -481,7 +481,6 @@ static int ingenic_adc_probe(struct platform_device *pdev) return ret; } - iio_dev->dev.parent = dev; iio_dev->name = "jz-adc"; iio_dev->modes = INDIO_DIRECT_MODE; iio_dev->channels = ingenic_channels; diff --git a/drivers/iio/adc/intel_mrfld_adc.c b/drivers/iio/adc/intel_mrfld_adc.c index a6d2e1f27e76..75394350eb4c 100644 --- a/drivers/iio/adc/intel_mrfld_adc.c +++ b/drivers/iio/adc/intel_mrfld_adc.c @@ -207,7 +207,6 @@ static int mrfld_adc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); - indio_dev->dev.parent = dev; indio_dev->name = pdev->name; indio_dev->channels = mrfld_adc_channels; diff --git a/drivers/iio/adc/lp8788_adc.c b/drivers/iio/adc/lp8788_adc.c index c1fc1b678e0f..6e32d2ac1ace 100644 --- a/drivers/iio/adc/lp8788_adc.c +++ b/drivers/iio/adc/lp8788_adc.c @@ -205,7 +205,6 @@ static int lp8788_adc_probe(struct platform_device *pdev) mutex_init(&adc->lock); - indio_dev->dev.parent = &pdev->dev; indio_dev->name = pdev->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &lp8788_adc_info; diff --git a/drivers/iio/adc/lpc18xx_adc.c b/drivers/iio/adc/lpc18xx_adc.c index 4c6ac6644dc0..3566990ae87d 100644 --- a/drivers/iio/adc/lpc18xx_adc.c +++ b/drivers/iio/adc/lpc18xx_adc.c @@ -152,7 +152,6 @@ static int lpc18xx_adc_probe(struct platform_device *pdev) } indio_dev->name = dev_name(&pdev->dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &lpc18xx_adc_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = lpc18xx_adc_iio_channels; diff --git a/drivers/iio/adc/lpc32xx_adc.c b/drivers/iio/adc/lpc32xx_adc.c index b896f7ff4572..bc2712a48844 100644 --- a/drivers/iio/adc/lpc32xx_adc.c +++ b/drivers/iio/adc/lpc32xx_adc.c @@ -196,7 +196,6 @@ static int lpc32xx_adc_probe(struct platform_device *pdev) init_completion(&st->completion); iodev->name = LPC32XXAD_NAME; - iodev->dev.parent = &pdev->dev; iodev->info = &lpc32xx_adc_iio_info; iodev->modes = INDIO_DIRECT_MODE; iodev->num_channels = ARRAY_SIZE(lpc32xx_adc_iio_channels); diff --git a/drivers/iio/adc/ltc2471.c b/drivers/iio/adc/ltc2471.c index 55fab612843a..0e0fe881a8e6 100644 --- a/drivers/iio/adc/ltc2471.c +++ b/drivers/iio/adc/ltc2471.c @@ -116,7 +116,6 @@ static int ltc2471_i2c_probe(struct i2c_client *client, data = iio_priv(indio_dev); data->client = client; - indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; indio_dev->info = <c2471_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ltc2485.c b/drivers/iio/adc/ltc2485.c index c418466d51fd..37c762f8218c 100644 --- a/drivers/iio/adc/ltc2485.c +++ b/drivers/iio/adc/ltc2485.c @@ -108,7 +108,6 @@ static int ltc2485_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); data->client = client; - indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; indio_dev->info = <c2485_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c index 02834ca3e1ce..b489cb14ea0d 100644 --- a/drivers/iio/adc/max1027.c +++ b/drivers/iio/adc/max1027.c @@ -440,7 +440,6 @@ static int max1027_probe(struct spi_device *spi) mutex_init(&st->lock); indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->info = &max1027_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/max11100.c b/drivers/iio/adc/max11100.c index b121ca78f851..a5a4e82b8bd2 100644 --- a/drivers/iio/adc/max11100.c +++ b/drivers/iio/adc/max11100.c @@ -115,7 +115,6 @@ static int max11100_probe(struct spi_device *spi) state = iio_priv(indio_dev); state->spi = spi; - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = "max11100"; indio_dev->info = &max11100_info; diff --git a/drivers/iio/adc/max1118.c b/drivers/iio/adc/max1118.c index 0c5d7aaf6826..273fbea2a515 100644 --- a/drivers/iio/adc/max1118.c +++ b/drivers/iio/adc/max1118.c @@ -225,7 +225,6 @@ static int max1118_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->dev.parent = &spi->dev; indio_dev->info = &max1118_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = max1118_channels; diff --git a/drivers/iio/adc/max1241.c b/drivers/iio/adc/max1241.c index 541939c7abca..0cbbb3c56d08 100644 --- a/drivers/iio/adc/max1241.c +++ b/drivers/iio/adc/max1241.c @@ -192,7 +192,6 @@ static int max1241_probe(struct spi_device *spi) dev_dbg(dev, "no shutdown pin passed, low-power mode disabled"); indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->dev.parent = dev; indio_dev->info = &max1241_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = max1241_channels; diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c index 04d5ff7d2c8e..f0fdd08cea91 100644 --- a/drivers/iio/adc/max9611.c +++ b/drivers/iio/adc/max9611.c @@ -545,7 +545,6 @@ static int max9611_probe(struct i2c_client *client, if (ret) return ret; - indio_dev->dev.parent = &client->dev; indio_dev->dev.of_node = client->dev.of_node; indio_dev->name = of_id->data; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c index 2c0eb5de110c..ee1f65f011a3 100644 --- a/drivers/iio/adc/mcp320x.c +++ b/drivers/iio/adc/mcp320x.c @@ -384,7 +384,6 @@ static int mcp320x_probe(struct spi_device *spi) adc = iio_priv(indio_dev); adc->spi = spi; - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c index d86c0b5d80a3..56a4768185ea 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -347,7 +347,6 @@ static int mcp3422_probe(struct i2c_client *client, mutex_init(&adc->lock); - indio_dev->dev.parent = &client->dev; indio_dev->dev.of_node = client->dev.of_node; indio_dev->name = dev_name(&client->dev); indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/men_z188_adc.c b/drivers/iio/adc/men_z188_adc.c index 196c8226381e..42ea8bc7e780 100644 --- a/drivers/iio/adc/men_z188_adc.c +++ b/drivers/iio/adc/men_z188_adc.c @@ -110,7 +110,6 @@ static int men_z188_probe(struct mcb_device *dev, adc = iio_priv(indio_dev); indio_dev->name = "z188-adc"; - indio_dev->dev.parent = &dev->dev; indio_dev->info = &z188_adc_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = z188_adc_iio_channels; diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 22a470db9ef8..1026cb199aa3 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -1208,7 +1208,6 @@ static int meson_sar_adc_probe(struct platform_device *pdev) priv->param = match_data->param; indio_dev->name = match_data->name; - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &meson_sar_adc_iio_info; diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c index a4776d924f3a..ac415cb089cd 100644 --- a/drivers/iio/adc/mt6577_auxadc.c +++ b/drivers/iio/adc/mt6577_auxadc.c @@ -245,7 +245,6 @@ static int mt6577_auxadc_probe(struct platform_device *pdev) return -ENOMEM; adc_dev = iio_priv(indio_dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->name = dev_name(&pdev->dev); indio_dev->info = &mt6577_auxadc_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c index 9d2f74c2489a..c371565374d1 100644 --- a/drivers/iio/adc/mxs-lradc-adc.c +++ b/drivers/iio/adc/mxs-lradc-adc.c @@ -722,7 +722,6 @@ static int mxs_lradc_adc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, iio); iio->name = pdev->name; - iio->dev.parent = dev; iio->dev.of_node = dev->parent->of_node; iio->info = &mxs_lradc_adc_iio_info; iio->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c index 572579139fba..e2ed9f575a46 100644 --- a/drivers/iio/adc/nau7802.c +++ b/drivers/iio/adc/nau7802.c @@ -430,7 +430,6 @@ static int nau7802_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); - indio_dev->dev.parent = &client->dev; indio_dev->dev.of_node = client->dev.of_node; indio_dev->name = dev_name(&client->dev); indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/npcm_adc.c b/drivers/iio/adc/npcm_adc.c index 83bad2d5575d..d9d105920001 100644 --- a/drivers/iio/adc/npcm_adc.c +++ b/drivers/iio/adc/npcm_adc.c @@ -261,7 +261,6 @@ static int npcm_adc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); indio_dev->name = dev_name(&pdev->dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &npcm_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = npcm_adc_iio_channels; diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c index 46e595eb889f..768453ca204b 100644 --- a/drivers/iio/adc/palmas_gpadc.c +++ b/drivers/iio/adc/palmas_gpadc.c @@ -593,7 +593,6 @@ static int palmas_gpadc_probe(struct platform_device *pdev) adc->extended_delay = gpadc_pdata->extended_delay; indio_dev->name = MOD_NAME; - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &palmas_gpadc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = palmas_gpadc_iio_channel; diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c index c599ffa45a04..d3225965a1af 100644 --- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c +++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c @@ -933,7 +933,6 @@ static int pm8xxx_xoadc_probe(struct platform_device *pdev) goto out_disable_vref; } - indio_dev->dev.parent = dev; indio_dev->dev.of_node = np; indio_dev->name = variant->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c index 0f9af6650772..2f8379a98ae5 100644 --- a/drivers/iio/adc/qcom-spmi-adc5.c +++ b/drivers/iio/adc/qcom-spmi-adc5.c @@ -982,7 +982,6 @@ static int adc5_probe(struct platform_device *pdev) return ret; } - indio_dev->dev.parent = dev; indio_dev->dev.of_node = node; indio_dev->name = pdev->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c index 203ad59da336..1f1bb747c8e1 100644 --- a/drivers/iio/adc/qcom-spmi-vadc.c +++ b/drivers/iio/adc/qcom-spmi-vadc.c @@ -907,7 +907,6 @@ static int vadc_probe(struct platform_device *pdev) if (ret) return ret; - indio_dev->dev.parent = dev; indio_dev->dev.of_node = node; indio_dev->name = pdev->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c index 63ce743ee7af..8591d3871791 100644 --- a/drivers/iio/adc/rcar-gyroadc.c +++ b/drivers/iio/adc/rcar-gyroadc.c @@ -516,7 +516,6 @@ static int rcar_gyroadc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); indio_dev->name = DRIVER_NAME; - indio_dev->dev.parent = dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->info = &rcar_gyroadc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/rn5t618-adc.c b/drivers/iio/adc/rn5t618-adc.c index f21027e4e26a..7010c4276947 100644 --- a/drivers/iio/adc/rn5t618-adc.c +++ b/drivers/iio/adc/rn5t618-adc.c @@ -218,7 +218,6 @@ static int rn5t618_adc_probe(struct platform_device *pdev) init_completion(&adc->conv_completion); iio_dev->name = dev_name(&pdev->dev); - iio_dev->dev.parent = &pdev->dev; iio_dev->info = &rn5t618_adc_iio_info; iio_dev->modes = INDIO_DIRECT_MODE; iio_dev->channels = rn5t618_adc_iio_channels; diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c index 582ba047c4a6..dabcd3e1365f 100644 --- a/drivers/iio/adc/rockchip_saradc.c +++ b/drivers/iio/adc/rockchip_saradc.c @@ -307,7 +307,6 @@ static int rockchip_saradc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); indio_dev->name = dev_name(&pdev->dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->info = &rockchip_saradc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c index 66b387f9b36d..aa32a1f385e2 100644 --- a/drivers/iio/adc/sc27xx_adc.c +++ b/drivers/iio/adc/sc27xx_adc.c @@ -533,7 +533,6 @@ static int sc27xx_adc_probe(struct platform_device *pdev) return ret; } - indio_dev->dev.parent = dev; indio_dev->name = dev_name(dev); indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &sc27xx_info; diff --git a/drivers/iio/adc/sd_adc_modulator.c b/drivers/iio/adc/sd_adc_modulator.c index 560d8c7d9d86..c32bb7bb5a96 100644 --- a/drivers/iio/adc/sd_adc_modulator.c +++ b/drivers/iio/adc/sd_adc_modulator.c @@ -32,7 +32,6 @@ static int iio_sd_mod_probe(struct platform_device *pdev) if (!iio) return -ENOMEM; - iio->dev.parent = dev; iio->dev.of_node = dev->of_node; iio->name = dev_name(dev); iio->info = &iio_sd_mod_iio_info; diff --git a/drivers/iio/adc/spear_adc.c b/drivers/iio/adc/spear_adc.c index 0ad536494e8f..1bc986a7009d 100644 --- a/drivers/iio/adc/spear_adc.c +++ b/drivers/iio/adc/spear_adc.c @@ -336,7 +336,6 @@ static int spear_adc_probe(struct platform_device *pdev) init_completion(&st->completion); indio_dev->name = SPEAR_ADC_MOD_NAME; - indio_dev->dev.parent = dev; indio_dev->info = &spear_adc_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = spear_adc_iio_channels; diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index 7dd865680e16..e5a2bfcb5681 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -1896,7 +1896,6 @@ static int stm32_adc_probe(struct platform_device *pdev) of_match_device(dev->driver->of_match_table, dev)->data; indio_dev->name = dev_name(&pdev->dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->info = &stm32_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE | INDIO_HARDWARE_TRIGGERED; diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 506bf519f64c..abe248bb1554 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -1571,7 +1571,6 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev) adc = iio_priv(iio); adc->dfsdm = dev_get_drvdata(dev->parent); - iio->dev.parent = dev; iio->dev.of_node = np; iio->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index 0f88048ea48f..fba659bfdb40 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -297,7 +297,6 @@ static int stmpe_adc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); indio_dev->name = dev_name(&pdev->dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &stmpe_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/stx104.c b/drivers/iio/adc/stx104.c index f87bbc711ccc..55bd2dc514e9 100644 --- a/drivers/iio/adc/stx104.c +++ b/drivers/iio/adc/stx104.c @@ -319,7 +319,6 @@ static int stx104_probe(struct device *dev, unsigned int id) } indio_dev->name = dev_name(dev); - indio_dev->dev.parent = dev; priv = iio_priv(indio_dev); priv->base = base[id]; diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 0f2c1738a90d..06b02f5b1721 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -619,7 +619,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev) info->indio_dev = indio_dev; init_completion(&info->completion); indio_dev->name = dev_name(&pdev->dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->info = &sun4i_gpadc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c index 0235863ff77b..e44e7a40a36b 100644 --- a/drivers/iio/adc/ti-adc081c.c +++ b/drivers/iio/adc/ti-adc081c.c @@ -181,7 +181,6 @@ static int adc081c_probe(struct i2c_client *client, if (err < 0) return err; - iio->dev.parent = &client->dev; iio->dev.of_node = client->dev.of_node; iio->name = dev_name(&client->dev); iio->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ti-adc0832.c b/drivers/iio/adc/ti-adc0832.c index 6ea39f4bbb37..054db3425afa 100644 --- a/drivers/iio/adc/ti-adc0832.c +++ b/drivers/iio/adc/ti-adc0832.c @@ -245,7 +245,6 @@ static int adc0832_probe(struct spi_device *spi) mutex_init(&adc->lock); indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->info = &adc0832_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ti-adc084s021.c b/drivers/iio/adc/ti-adc084s021.c index bdedf456ee05..376a0cf1f4ff 100644 --- a/drivers/iio/adc/ti-adc084s021.c +++ b/drivers/iio/adc/ti-adc084s021.c @@ -211,7 +211,6 @@ static int adc084s021_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); /* Initiate the Industrial I/O device */ - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ti-adc108s102.c b/drivers/iio/adc/ti-adc108s102.c index de9aaebff862..9b9b27415c93 100644 --- a/drivers/iio/adc/ti-adc108s102.c +++ b/drivers/iio/adc/ti-adc108s102.c @@ -252,7 +252,6 @@ static int adc108s102_probe(struct spi_device *spi) st->spi = spi; indio_dev->name = spi->modalias; - indio_dev->dev.parent = &spi->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = adc108s102_channels; indio_dev->num_channels = ARRAY_SIZE(adc108s102_channels); diff --git a/drivers/iio/adc/ti-adc12138.c b/drivers/iio/adc/ti-adc12138.c index 68a9dcb8faa2..e485719cd2c4 100644 --- a/drivers/iio/adc/ti-adc12138.c +++ b/drivers/iio/adc/ti-adc12138.c @@ -407,7 +407,6 @@ static int adc12138_probe(struct spi_device *spi) init_completion(&adc->complete); indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->dev.parent = &spi->dev; indio_dev->info = &adc12138_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index 1e5a936b5b6a..4eca6404661c 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -152,7 +152,6 @@ static int adc128_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ti-adc161s626.c b/drivers/iio/adc/ti-adc161s626.c index 3bbc9b9ddbfe..d6f28d478a73 100644 --- a/drivers/iio/adc/ti-adc161s626.c +++ b/drivers/iio/adc/ti-adc161s626.c @@ -179,7 +179,6 @@ static int ti_adc_probe(struct spi_device *spi) return -ENOMEM; indio_dev->info = &ti_adc_info; - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = TI_ADC_DRV_NAME; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index 5ea4f45d6bad..629c631e8f5c 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -939,7 +939,6 @@ static int ads1015_probe(struct i2c_client *client, mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->dev.of_node = client->dev.of_node; indio_dev->name = ADS1015_DRV_NAME; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c index f1ee3b1e2827..dacaa7255a3b 100644 --- a/drivers/iio/adc/ti-ads124s08.c +++ b/drivers/iio/adc/ti-ads124s08.c @@ -325,7 +325,6 @@ static int ads124s_probe(struct spi_device *spi) ads124s_priv->spi = spi; indio_dev->name = spi_id->name; - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ads124s_priv->chip_info->channels; diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c index f9edc1207f75..fa7e017f8202 100644 --- a/drivers/iio/adc/ti-ads7950.c +++ b/drivers/iio/adc/ti-ads7950.c @@ -557,7 +557,6 @@ static int ti_ads7950_probe(struct spi_device *spi) info = &ti_ads7950_chip_info[spi_get_device_id(spi)->driver_data]; indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->dev.parent = &spi->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = info->channels; indio_dev->num_channels = info->num_channels; diff --git a/drivers/iio/adc/ti-ads8344.c b/drivers/iio/adc/ti-ads8344.c index 8a8792010c20..f1fe98ce44e4 100644 --- a/drivers/iio/adc/ti-ads8344.c +++ b/drivers/iio/adc/ti-ads8344.c @@ -148,7 +148,6 @@ static int ads8344_probe(struct spi_device *spi) mutex_init(&adc->lock); indio_dev->name = dev_name(&spi->dev); - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->info = &ads8344_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ti-ads8688.c b/drivers/iio/adc/ti-ads8688.c index 14fe7c320b52..011e5c8b5afd 100644 --- a/drivers/iio/adc/ti-ads8688.c +++ b/drivers/iio/adc/ti-ads8688.c @@ -449,7 +449,6 @@ static int ads8688_probe(struct spi_device *spi) st->spi = spi; indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = st->chip_info->channels; diff --git a/drivers/iio/adc/ti-tlc4541.c b/drivers/iio/adc/ti-tlc4541.c index 77620359b54c..432238246519 100644 --- a/drivers/iio/adc/ti-tlc4541.c +++ b/drivers/iio/adc/ti-tlc4541.c @@ -177,7 +177,6 @@ static int tlc4541_probe(struct spi_device *spi) info = &tlc4541_chip_info[spi_get_device_id(spi)->driver_data]; indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->dev.parent = &spi->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = info->channels; indio_dev->num_channels = info->num_channels; diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 9d984f2a8ba7..55c583bf1664 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -626,7 +626,6 @@ static int tiadc_probe(struct platform_device *pdev) adc_dev->mfd_tscadc = ti_tscadc_dev_get(pdev); tiadc_parse_dt(pdev, adc_dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->name = dev_name(&pdev->dev); indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &tiadc_info; diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c index 472b08f37fea..e5602169e681 100644 --- a/drivers/iio/adc/twl4030-madc.c +++ b/drivers/iio/adc/twl4030-madc.c @@ -772,7 +772,6 @@ static int twl4030_madc_probe(struct platform_device *pdev) madc->dev = &pdev->dev; iio_dev->name = dev_name(&pdev->dev); - iio_dev->dev.parent = &pdev->dev; iio_dev->dev.of_node = pdev->dev.of_node; iio_dev->info = &twl4030_madc_iio_info; iio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c index f24148bd15de..bd501a09bc98 100644 --- a/drivers/iio/adc/twl6030-gpadc.c +++ b/drivers/iio/adc/twl6030-gpadc.c @@ -926,7 +926,6 @@ static int twl6030_gpadc_probe(struct platform_device *pdev) } indio_dev->name = DRIVER_NAME; - indio_dev->dev.parent = dev; indio_dev->info = &twl6030_gpadc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = pdata->iio_channels; diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index cb7380bf07ca..1e3ef5dd0bc6 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -860,7 +860,6 @@ static int vf610_adc_probe(struct platform_device *pdev) init_completion(&info->completion); indio_dev->name = dev_name(&pdev->dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->info = &vf610_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/viperboard_adc.c b/drivers/iio/adc/viperboard_adc.c index 1d2aeb04069b..1028b101cf56 100644 --- a/drivers/iio/adc/viperboard_adc.c +++ b/drivers/iio/adc/viperboard_adc.c @@ -121,7 +121,6 @@ static int vprbrd_adc_probe(struct platform_device *pdev) adc = iio_priv(indio_dev); adc->vb = vb; indio_dev->name = "viperboard adc"; - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &vprbrd_adc_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = vprbrd_adc_iio_channels; diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c index d7fecab9252e..aeefd9768203 100644 --- a/drivers/iio/adc/xilinx-xadc-core.c +++ b/drivers/iio/adc/xilinx-xadc-core.c @@ -1221,7 +1221,6 @@ static int xadc_probe(struct platform_device *pdev) if (IS_ERR(xadc->base)) return PTR_ERR(xadc->base); - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->name = "xadc"; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c index e9ceee66d1e7..69c0f277ada0 100644 --- a/drivers/iio/afe/iio-rescale.c +++ b/drivers/iio/afe/iio-rescale.c @@ -314,7 +314,6 @@ static int rescale_probe(struct platform_device *pdev) rescale->source = source; indio_dev->name = dev_name(dev); - indio_dev->dev.parent = dev; indio_dev->info = &rescale_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = &rescale->chan; diff --git a/drivers/iio/amplifiers/hmc425a.c b/drivers/iio/amplifiers/hmc425a.c index d9e6e9678ffc..582708924e4f 100644 --- a/drivers/iio/amplifiers/hmc425a.c +++ b/drivers/iio/amplifiers/hmc425a.c @@ -227,7 +227,6 @@ static int hmc425a_probe(struct platform_device *pdev) mutex_init(&st->lock); - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &hmc425a_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/chemical/ams-iaq-core.c b/drivers/iio/chemical/ams-iaq-core.c index a0646ba2ad88..8c1b64fd424a 100644 --- a/drivers/iio/chemical/ams-iaq-core.c +++ b/drivers/iio/chemical/ams-iaq-core.c @@ -152,7 +152,6 @@ static int ams_iaqcore_probe(struct i2c_client *client, data->last_update = jiffies - HZ; mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &ams_iaqcore_info; indio_dev->name = dev_name(&client->dev); indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c index 78a27e36bf32..047f4b3f5a0e 100644 --- a/drivers/iio/chemical/atlas-sensor.c +++ b/drivers/iio/chemical/atlas-sensor.c @@ -644,7 +644,6 @@ static int atlas_probe(struct i2c_client *client, indio_dev->channels = chip->channels; indio_dev->num_channels = chip->num_channels; indio_dev->modes = INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE; - indio_dev->dev.parent = &client->dev; trig = devm_iio_trigger_alloc(&client->dev, "%s-dev%d", indio_dev->name, indio_dev->id); diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c index 13773e01699b..6ea99e4cbf92 100644 --- a/drivers/iio/chemical/bme680_core.c +++ b/drivers/iio/chemical/bme680_core.c @@ -923,7 +923,6 @@ int bme680_core_probe(struct device *dev, struct regmap *regmap, data = iio_priv(indio_dev); dev_set_drvdata(dev, indio_dev); data->regmap = regmap; - indio_dev->dev.parent = dev; indio_dev->name = name; indio_dev->channels = bme680_channels; indio_dev->num_channels = ARRAY_SIZE(bme680_channels); diff --git a/drivers/iio/chemical/ccs811.c b/drivers/iio/chemical/ccs811.c index 3ecd633f9ed3..2b007e7568b2 100644 --- a/drivers/iio/chemical/ccs811.c +++ b/drivers/iio/chemical/ccs811.c @@ -464,7 +464,6 @@ static int ccs811_probe(struct i2c_client *client, mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; indio_dev->info = &ccs811_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/chemical/pms7003.c b/drivers/iio/chemical/pms7003.c index 07bb90d72434..e9d4405654bc 100644 --- a/drivers/iio/chemical/pms7003.c +++ b/drivers/iio/chemical/pms7003.c @@ -280,7 +280,6 @@ static int pms7003_probe(struct serdev_device *serdev) state = iio_priv(indio_dev); serdev_device_set_drvdata(serdev, indio_dev); state->serdev = serdev; - indio_dev->dev.parent = &serdev->dev; indio_dev->info = &pms7003_info; indio_dev->name = PMS7003_DRIVER_NAME; indio_dev->channels = pms7003_channels, diff --git a/drivers/iio/chemical/sgp30.c b/drivers/iio/chemical/sgp30.c index 403e8803471a..2c4086c48136 100644 --- a/drivers/iio/chemical/sgp30.c +++ b/drivers/iio/chemical/sgp30.c @@ -533,7 +533,6 @@ static int sgp_probe(struct i2c_client *client, if (ret) return ret; - indio_dev->dev.parent = &client->dev; indio_dev->info = &sgp_info; indio_dev->name = id->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/chemical/sps30.c b/drivers/iio/chemical/sps30.c index a88c1fb875a0..5a29e32c295f 100644 --- a/drivers/iio/chemical/sps30.c +++ b/drivers/iio/chemical/sps30.c @@ -487,7 +487,6 @@ static int sps30_probe(struct i2c_client *client) i2c_set_clientdata(client, indio_dev); state->client = client; state->state = RESET; - indio_dev->dev.parent = &client->dev; indio_dev->info = &sps30_info; indio_dev->name = client->name; indio_dev->channels = sps30_channels; diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c index d33642de9720..db36365dc04c 100644 --- a/drivers/iio/dac/ad5064.c +++ b/drivers/iio/dac/ad5064.c @@ -874,7 +874,6 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, return ret; } - indio_dev->dev.parent = dev; indio_dev->name = name; indio_dev->info = &ad5064_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ad5360.c b/drivers/iio/dac/ad5360.c index 3e0c9e84e8da..f5d19d158d1c 100644 --- a/drivers/iio/dac/ad5360.c +++ b/drivers/iio/dac/ad5360.c @@ -476,7 +476,6 @@ static int ad5360_probe(struct spi_device *spi) st->chip_info = &ad5360_chip_info_tbl[type]; st->spi = spi; - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad5360_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c index 04c74cc1a4ec..224ffc466ed1 100644 --- a/drivers/iio/dac/ad5380.c +++ b/drivers/iio/dac/ad5380.c @@ -386,7 +386,6 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap, st->chip_info = &ad5380_chip_info_tbl[type]; st->regmap = regmap; - indio_dev->dev.parent = dev; indio_dev->name = name; indio_dev->info = &ad5380_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c index fec27764cea8..4158c810de9b 100644 --- a/drivers/iio/dac/ad5421.c +++ b/drivers/iio/dac/ad5421.c @@ -487,7 +487,6 @@ static int ad5421_probe(struct spi_device *spi) st->spi = spi; - indio_dev->dev.parent = &spi->dev; indio_dev->name = "ad5421"; indio_dev->info = &ad5421_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c index 8f8afc8999bc..e01ba90dc106 100644 --- a/drivers/iio/dac/ad5446.c +++ b/drivers/iio/dac/ad5446.c @@ -251,7 +251,6 @@ static int ad5446_probe(struct device *dev, const char *name, st->dev = dev; /* Establish that the iio_dev is a child of the device */ - indio_dev->dev.parent = dev; indio_dev->name = name; indio_dev->info = &ad5446_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ad5449.c b/drivers/iio/dac/ad5449.c index d739b10e5236..447ba9f550d8 100644 --- a/drivers/iio/dac/ad5449.c +++ b/drivers/iio/dac/ad5449.c @@ -297,7 +297,6 @@ static int ad5449_spi_probe(struct spi_device *spi) if (ret) return ret; - indio_dev->dev.parent = &spi->dev; indio_dev->name = id->name; indio_dev->info = &ad5449_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c index c64e6898ff20..6f18ac2c20fa 100644 --- a/drivers/iio/dac/ad5504.c +++ b/drivers/iio/dac/ad5504.c @@ -304,7 +304,6 @@ static int ad5504_probe(struct spi_device *spi) st->reg = reg; st->spi = spi; - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(st->spi)->name; indio_dev->info = &ad5504_info; if (spi_get_device_id(st->spi)->driver_data == ID_AD5501) diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c index 49daf0eee4e4..5c4e5ff70380 100644 --- a/drivers/iio/dac/ad5592r-base.c +++ b/drivers/iio/dac/ad5592r-base.c @@ -618,7 +618,6 @@ int ad5592r_probe(struct device *dev, const char *name, return ret; } - iio_dev->dev.parent = dev; iio_dev->name = name; iio_dev->info = &ad5592r_info; iio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c index 2015a5df840c..2b2b8edfd258 100644 --- a/drivers/iio/dac/ad5624r_spi.c +++ b/drivers/iio/dac/ad5624r_spi.c @@ -253,7 +253,6 @@ static int ad5624r_probe(struct spi_device *spi) st->us = spi; - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad5624r_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 8dd67da0a7da..56cf9344d187 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -461,7 +461,6 @@ int ad5686_probe(struct device *dev, for (i = 0; i < st->chip_info->num_channels; i++) st->pwr_down_mode |= (0x01 << (i * 2)); - indio_dev->dev.parent = dev; indio_dev->name = name; indio_dev->info = &ad5686_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c index 7723bd313fc6..c8d9c698283d 100644 --- a/drivers/iio/dac/ad5755.c +++ b/drivers/iio/dac/ad5755.c @@ -744,7 +744,6 @@ static int ad5755_probe(struct spi_device *spi) st->spi = spi; st->pwr_down = 0xf; - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad5755_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ad5758.c b/drivers/iio/dac/ad5758.c index 475646c82b40..86649149a3b0 100644 --- a/drivers/iio/dac/ad5758.c +++ b/drivers/iio/dac/ad5758.c @@ -854,7 +854,6 @@ static int ad5758_probe(struct spi_device *spi) mutex_init(&st->lock); - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad5758_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ad5761.c b/drivers/iio/dac/ad5761.c index 67c4fa75c6f1..89fa5869b4bf 100644 --- a/drivers/iio/dac/ad5761.c +++ b/drivers/iio/dac/ad5761.c @@ -376,7 +376,6 @@ static int ad5761_probe(struct spi_device *spi) if (ret) goto disable_regulator_err; - iio_dev->dev.parent = &spi->dev; iio_dev->info = &ad5761_info; iio_dev->modes = INDIO_DIRECT_MODE; iio_dev->channels = &chip_info->channel; diff --git a/drivers/iio/dac/ad5764.c b/drivers/iio/dac/ad5764.c index 5b0f0fe354f6..53e756e59e60 100644 --- a/drivers/iio/dac/ad5764.c +++ b/drivers/iio/dac/ad5764.c @@ -290,7 +290,6 @@ static int ad5764_probe(struct spi_device *spi) st->spi = spi; st->chip_info = &ad5764_chip_infos[type]; - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad5764_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index 1d11f39ed047..60aa16128a8f 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -409,7 +409,6 @@ static int ad5791_probe(struct spi_device *spi) goto error_disable_reg_neg; spi_set_drvdata(spi, indio_dev); - indio_dev->dev.parent = &spi->dev; indio_dev->info = &ad5791_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c index 15af8a1cce3e..4460aa57a33f 100644 --- a/drivers/iio/dac/ad7303.c +++ b/drivers/iio/dac/ad7303.c @@ -238,7 +238,6 @@ static int ad7303_probe(struct spi_device *spi) st->config |= AD7303_CFG_EXTERNAL_VREF; } - indio_dev->dev.parent = &spi->dev; indio_dev->name = id->name; indio_dev->info = &ad7303_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ad8801.c b/drivers/iio/dac/ad8801.c index 0789c9100a8f..6354b7c8f052 100644 --- a/drivers/iio/dac/ad8801.c +++ b/drivers/iio/dac/ad8801.c @@ -171,7 +171,6 @@ static int ad8801_probe(struct spi_device *spi) } spi_set_drvdata(spi, indio_dev); - indio_dev->dev.parent = &spi->dev; indio_dev->info = &ad8801_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ad8801_channels; diff --git a/drivers/iio/dac/cio-dac.c b/drivers/iio/dac/cio-dac.c index 81677795e57a..95813569f394 100644 --- a/drivers/iio/dac/cio-dac.c +++ b/drivers/iio/dac/cio-dac.c @@ -110,7 +110,6 @@ static int cio_dac_probe(struct device *dev, unsigned int id) indio_dev->channels = cio_dac_channels; indio_dev->num_channels = CIO_DAC_NUM_CHAN; indio_dev->name = dev_name(dev); - indio_dev->dev.parent = dev; priv = iio_priv(indio_dev); priv->base = base[id]; diff --git a/drivers/iio/dac/dpot-dac.c b/drivers/iio/dac/dpot-dac.c index 4a6111b7e86c..b3835fb6b862 100644 --- a/drivers/iio/dac/dpot-dac.c +++ b/drivers/iio/dac/dpot-dac.c @@ -177,7 +177,6 @@ static int dpot_dac_probe(struct platform_device *pdev) dac = iio_priv(indio_dev); indio_dev->name = dev_name(dev); - indio_dev->dev.parent = dev; indio_dev->info = &dpot_dac_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = &dpot_dac_iio_channel; diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c index 26d206681472..86eec0df1174 100644 --- a/drivers/iio/dac/ds4424.c +++ b/drivers/iio/dac/ds4424.c @@ -231,7 +231,6 @@ static int ds4424_probe(struct i2c_client *client, data->client = client; indio_dev->name = id->name; indio_dev->dev.of_node = client->dev.of_node; - indio_dev->dev.parent = &client->dev; data->vcc_reg = devm_regulator_get(&client->dev, "vcc"); if (IS_ERR(data->vcc_reg)) { diff --git a/drivers/iio/dac/lpc18xx_dac.c b/drivers/iio/dac/lpc18xx_dac.c index 0ab357bd3633..9e38607a189e 100644 --- a/drivers/iio/dac/lpc18xx_dac.c +++ b/drivers/iio/dac/lpc18xx_dac.c @@ -133,7 +133,6 @@ static int lpc18xx_dac_probe(struct platform_device *pdev) } indio_dev->name = dev_name(&pdev->dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &lpc18xx_dac_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = lpc18xx_dac_iio_channels; diff --git a/drivers/iio/dac/ltc1660.c b/drivers/iio/dac/ltc1660.c index 10866838c72a..dc10188540ca 100644 --- a/drivers/iio/dac/ltc1660.c +++ b/drivers/iio/dac/ltc1660.c @@ -186,7 +186,6 @@ static int ltc1660_probe(struct spi_device *spi) priv->spi = spi; spi_set_drvdata(spi, indio_dev); - indio_dev->dev.parent = &spi->dev; indio_dev->info = <c1660_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ltc1660_channels[id->driver_data]; diff --git a/drivers/iio/dac/ltc2632.c b/drivers/iio/dac/ltc2632.c index f891311f05cf..06bfaaa00da6 100644 --- a/drivers/iio/dac/ltc2632.c +++ b/drivers/iio/dac/ltc2632.c @@ -362,7 +362,6 @@ static int ltc2632_probe(struct spi_device *spi) } } - indio_dev->dev.parent = &spi->dev; indio_dev->name = dev_of_node(&spi->dev) ? dev_of_node(&spi->dev)->name : spi_get_device_id(spi)->name; indio_dev->info = <c2632_info; diff --git a/drivers/iio/dac/m62332.c b/drivers/iio/dac/m62332.c index 3205ca98c32d..225b1a374dc1 100644 --- a/drivers/iio/dac/m62332.c +++ b/drivers/iio/dac/m62332.c @@ -204,9 +204,6 @@ static int m62332_probe(struct i2c_client *client, if (IS_ERR(data->vcc)) return PTR_ERR(data->vcc); - /* establish that the iio_dev is a child of the i2c device */ - indio_dev->dev.parent = &client->dev; - indio_dev->num_channels = ARRAY_SIZE(m62332_channels); indio_dev->channels = m62332_channels; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c index 7e01838ef4d0..daa60386bf0c 100644 --- a/drivers/iio/dac/max517.c +++ b/drivers/iio/dac/max517.c @@ -156,9 +156,6 @@ static int max517_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); data->client = client; - /* establish that the iio_dev is a child of the i2c device */ - indio_dev->dev.parent = &client->dev; - switch (id->driver_data) { case ID_MAX521: indio_dev->num_channels = 8; diff --git a/drivers/iio/dac/max5821.c b/drivers/iio/dac/max5821.c index 2da086e372af..d6bb24db49c4 100644 --- a/drivers/iio/dac/max5821.c +++ b/drivers/iio/dac/max5821.c @@ -341,7 +341,6 @@ static int max5821_probe(struct i2c_client *client, data->vref_mv = ret / 1000; indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; indio_dev->num_channels = ARRAY_SIZE(max5821_channels); indio_dev->channels = max5821_channels; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c index ed455e801e80..ee174d224110 100644 --- a/drivers/iio/dac/mcp4725.c +++ b/drivers/iio/dac/mcp4725.c @@ -453,7 +453,6 @@ static int mcp4725_probe(struct i2c_client *client, goto err_disable_vdd_reg; } - indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; indio_dev->info = &mcp4725_info; indio_dev->channels = &mcp472x_channel[id->driver_data]; diff --git a/drivers/iio/dac/mcp4922.c b/drivers/iio/dac/mcp4922.c index f9194b3ddc9c..c4e430b4050e 100644 --- a/drivers/iio/dac/mcp4922.c +++ b/drivers/iio/dac/mcp4922.c @@ -152,7 +152,6 @@ static int mcp4922_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); id = spi_get_device_id(spi); - indio_dev->dev.parent = &spi->dev; indio_dev->info = &mcp4922_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = mcp4922_channels[id->driver_data]; diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c index f22c1d9129b2..092c796fa3d9 100644 --- a/drivers/iio/dac/stm32-dac.c +++ b/drivers/iio/dac/stm32-dac.c @@ -323,7 +323,6 @@ static int stm32_dac_probe(struct platform_device *pdev) dac = iio_priv(indio_dev); dac->common = dev_get_drvdata(pdev->dev.parent); indio_dev->name = dev_name(&pdev->dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->info = &stm32_dac_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ti-dac082s085.c b/drivers/iio/dac/ti-dac082s085.c index 57b498d2a2a5..24e5833860f2 100644 --- a/drivers/iio/dac/ti-dac082s085.c +++ b/drivers/iio/dac/ti-dac082s085.c @@ -268,7 +268,6 @@ static int ti_dac_probe(struct spi_device *spi) if (!indio_dev) return -ENOMEM; - indio_dev->dev.parent = dev; indio_dev->info = &ti_dac_info; indio_dev->name = spi->modalias; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/dac/ti-dac5571.c b/drivers/iio/dac/ti-dac5571.c index 3a2bb0efe50d..502552716e1e 100644 --- a/drivers/iio/dac/ti-dac5571.c +++ b/drivers/iio/dac/ti-dac5571.c @@ -321,7 +321,6 @@ static int dac5571_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); data->client = client; - indio_dev->dev.parent = dev; indio_dev->dev.of_node = client->dev.of_node; indio_dev->info = &dac5571_info; indio_dev->name = id->name; diff --git a/drivers/iio/dac/ti-dac7311.c b/drivers/iio/dac/ti-dac7311.c index 6f5df1a30a1c..d20cee33daba 100644 --- a/drivers/iio/dac/ti-dac7311.c +++ b/drivers/iio/dac/ti-dac7311.c @@ -251,7 +251,6 @@ static int ti_dac_probe(struct spi_device *spi) spi->bits_per_word = 16; spi_setup(spi); - indio_dev->dev.parent = dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->info = &ti_dac_info; indio_dev->name = spi_get_device_id(spi)->name; diff --git a/drivers/iio/dac/ti-dac7612.c b/drivers/iio/dac/ti-dac7612.c index de0c6573cd97..07c9f39d54f1 100644 --- a/drivers/iio/dac/ti-dac7612.c +++ b/drivers/iio/dac/ti-dac7612.c @@ -139,7 +139,6 @@ static int dac7612_probe(struct spi_device *spi) return PTR_ERR(priv->loaddacs); priv->spi = spi; spi_set_drvdata(spi, iio_dev); - iio_dev->dev.parent = &spi->dev; iio_dev->info = &dac7612_info; iio_dev->modes = INDIO_DIRECT_MODE; iio_dev->channels = dac7612_channels; diff --git a/drivers/iio/dac/vf610_dac.c b/drivers/iio/dac/vf610_dac.c index 9417a4a3e22a..3787582d5340 100644 --- a/drivers/iio/dac/vf610_dac.c +++ b/drivers/iio/dac/vf610_dac.c @@ -199,7 +199,6 @@ static int vf610_dac_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); indio_dev->name = dev_name(&pdev->dev); - indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->info = &vf610_dac_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index a7322184cbdd..334e1d779d6d 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c @@ -1026,7 +1026,6 @@ static int ad9523_probe(struct spi_device *spi) st->spi = spi; st->pdata = pdata; - indio_dev->dev.parent = &spi->dev; indio_dev->name = (pdata->name[0] != 0) ? pdata->name : spi_get_device_id(spi)->name; indio_dev->info = &ad9523_info; diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c index 1c2dc9b00f31..409c9c47161e 100644 --- a/drivers/iio/frequency/adf4350.c +++ b/drivers/iio/frequency/adf4350.c @@ -531,7 +531,6 @@ static int adf4350_probe(struct spi_device *spi) st->spi = spi; st->pdata = pdata; - indio_dev->dev.parent = &spi->dev; indio_dev->name = (pdata->name[0] != 0) ? pdata->name : spi_get_device_id(spi)->name; diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c index ff82863cbf42..ecd5e18995ad 100644 --- a/drivers/iio/frequency/adf4371.c +++ b/drivers/iio/frequency/adf4371.c @@ -573,7 +573,6 @@ static int adf4371_probe(struct spi_device *spi) mutex_init(&st->lock); st->chip_info = &adf4371_chip_info[id->driver_data]; - indio_dev->dev.parent = &spi->dev; indio_dev->name = id->name; indio_dev->info = &adf4371_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/gyro/adis16080.c b/drivers/iio/gyro/adis16080.c index 1b84b8e112fe..6e5e2d98943c 100644 --- a/drivers/iio/gyro/adis16080.c +++ b/drivers/iio/gyro/adis16080.c @@ -207,7 +207,6 @@ static int adis16080_probe(struct spi_device *spi) indio_dev->name = spi->dev.driver->name; indio_dev->channels = adis16080_channels; indio_dev->num_channels = ARRAY_SIZE(adis16080_channels); - indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16080_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/gyro/adis16130.c b/drivers/iio/gyro/adis16130.c index 2a9ec08ec561..b9c952e65b55 100644 --- a/drivers/iio/gyro/adis16130.c +++ b/drivers/iio/gyro/adis16130.c @@ -155,7 +155,6 @@ static int adis16130_probe(struct spi_device *spi) indio_dev->name = spi->dev.driver->name; indio_dev->channels = adis16130_channels; indio_dev->num_channels = ARRAY_SIZE(adis16130_channels); - indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16130_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c index afdc57af475d..d8a96f6bbae2 100644 --- a/drivers/iio/gyro/adis16136.c +++ b/drivers/iio/gyro/adis16136.c @@ -540,7 +540,6 @@ static int adis16136_probe(struct spi_device *spi) adis16136 = iio_priv(indio_dev); adis16136->chip_info = &adis16136_chip_info[id->driver_data]; - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->channels = adis16136_channels; indio_dev->num_channels = ARRAY_SIZE(adis16136_channels); diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c index 9823573e811a..e638d56e1574 100644 --- a/drivers/iio/gyro/adis16260.c +++ b/drivers/iio/gyro/adis16260.c @@ -381,7 +381,6 @@ static int adis16260_probe(struct spi_device *spi) adis16260->info = &adis16260_chip_info_table[id->driver_data]; indio_dev->name = id->name; - indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16260_info; indio_dev->channels = adis16260->info->channels; indio_dev->num_channels = adis16260->info->num_channels; diff --git a/drivers/iio/gyro/adxrs450.c b/drivers/iio/gyro/adxrs450.c index b00c0eb44249..04f350025215 100644 --- a/drivers/iio/gyro/adxrs450.c +++ b/drivers/iio/gyro/adxrs450.c @@ -424,7 +424,6 @@ static int adxrs450_probe(struct spi_device *spi) /* This is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); - indio_dev->dev.parent = &spi->dev; indio_dev->info = &adxrs450_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index 428ddfc13acb..933492b33189 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c @@ -1097,7 +1097,6 @@ int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq, if (ACPI_HANDLE(dev)) name = bmg160_match_acpi_device(dev); - indio_dev->dev.parent = dev; indio_dev->channels = bmg160_channels; indio_dev->num_channels = ARRAY_SIZE(bmg160_channels); indio_dev->name = name; diff --git a/drivers/iio/gyro/fxas21002c_core.c b/drivers/iio/gyro/fxas21002c_core.c index 89d2bb2282ea..b5e0e96c5968 100644 --- a/drivers/iio/gyro/fxas21002c_core.c +++ b/drivers/iio/gyro/fxas21002c_core.c @@ -905,7 +905,6 @@ int fxas21002c_core_probe(struct device *dev, struct regmap *regmap, int irq, if (ret < 0) return ret; - indio_dev->dev.parent = dev; indio_dev->channels = fxas21002c_channels; indio_dev->num_channels = ARRAY_SIZE(fxas21002c_channels); indio_dev->name = name; diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index 7f382aae1dfd..6698f5f535f6 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c @@ -319,7 +319,6 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) } indio_dev->num_channels = ARRAY_SIZE(gyro_3d_channels); - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &gyro_3d_info; indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/gyro/itg3200_core.c b/drivers/iio/gyro/itg3200_core.c index b3afa556f973..e9804664db73 100644 --- a/drivers/iio/gyro/itg3200_core.c +++ b/drivers/iio/gyro/itg3200_core.c @@ -316,7 +316,6 @@ static int itg3200_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); st->i2c = client; - indio_dev->dev.parent = &client->dev; indio_dev->name = client->dev.driver->name; indio_dev->channels = itg3200_channels; indio_dev->num_channels = ARRAY_SIZE(itg3200_channels); diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c index 8e908a749f95..157330451e0a 100644 --- a/drivers/iio/gyro/mpu3050-core.c +++ b/drivers/iio/gyro/mpu3050-core.c @@ -1198,7 +1198,6 @@ int mpu3050_common_probe(struct device *dev, if (ret) goto err_power_down; - indio_dev->dev.parent = dev; indio_dev->channels = mpu3050_channels; indio_dev->num_channels = ARRAY_SIZE(mpu3050_channels); indio_dev->info = &mpu3050_info; diff --git a/drivers/iio/gyro/ssp_gyro_sensor.c b/drivers/iio/gyro/ssp_gyro_sensor.c index 4e4ee4167544..ac7c170a20de 100644 --- a/drivers/iio/gyro/ssp_gyro_sensor.c +++ b/drivers/iio/gyro/ssp_gyro_sensor.c @@ -108,7 +108,6 @@ static int ssp_gyro_probe(struct platform_device *pdev) spd->type = SSP_GYROSCOPE_SENSOR; indio_dev->name = ssp_gyro_name; - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &ssp_gyro_iio_info; indio_dev->modes = INDIO_BUFFER_SOFTWARE; indio_dev->channels = ssp_gyro_channels; diff --git a/drivers/iio/health/max30100.c b/drivers/iio/health/max30100.c index 546fc37ad75d..38aa2030f3c6 100644 --- a/drivers/iio/health/max30100.c +++ b/drivers/iio/health/max30100.c @@ -439,7 +439,6 @@ static int max30100_probe(struct i2c_client *client, indio_dev->available_scan_masks = max30100_scan_masks; indio_dev->modes = (INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE); indio_dev->setup_ops = &max30100_buffer_setup_ops; - indio_dev->dev.parent = &client->dev; data = iio_priv(indio_dev); data->indio_dev = indio_dev; diff --git a/drivers/iio/health/max30102.c b/drivers/iio/health/max30102.c index 74fc260b957e..9b47d9472a4f 100644 --- a/drivers/iio/health/max30102.c +++ b/drivers/iio/health/max30102.c @@ -526,7 +526,6 @@ static int max30102_probe(struct i2c_client *client, indio_dev->info = &max30102_info; indio_dev->modes = (INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE); indio_dev->setup_ops = &max30102_buffer_setup_ops; - indio_dev->dev.parent = &client->dev; data = iio_priv(indio_dev); data->indio_dev = indio_dev; diff --git a/drivers/iio/humidity/am2315.c b/drivers/iio/humidity/am2315.c index 3bac98e731d9..02ad1767c845 100644 --- a/drivers/iio/humidity/am2315.c +++ b/drivers/iio/humidity/am2315.c @@ -233,7 +233,6 @@ static int am2315_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &am2315_info; indio_dev->name = AM2315_DRIVER_NAME; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c index 7ecd2ffa3132..3331141734c8 100644 --- a/drivers/iio/humidity/hdc100x.c +++ b/drivers/iio/humidity/hdc100x.c @@ -374,7 +374,6 @@ static int hdc100x_probe(struct i2c_client *client, data->client = client; mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->name = dev_name(&client->dev); indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &hdc100x_info; diff --git a/drivers/iio/humidity/hid-sensor-humidity.c b/drivers/iio/humidity/hid-sensor-humidity.c index d2318c4aab0f..52f605114ef7 100644 --- a/drivers/iio/humidity/hid-sensor-humidity.c +++ b/drivers/iio/humidity/hid-sensor-humidity.c @@ -226,7 +226,6 @@ static int hid_humidity_probe(struct platform_device *pdev) indio_dev->channels = humid_chans; indio_dev->num_channels = ARRAY_SIZE(humidity_channels); - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &humidity_info; indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/humidity/htu21.c b/drivers/iio/humidity/htu21.c index d4c0589844dd..4f5d9d1c05ab 100644 --- a/drivers/iio/humidity/htu21.c +++ b/drivers/iio/humidity/htu21.c @@ -204,7 +204,6 @@ static int htu21_probe(struct i2c_client *client, indio_dev->info = &htu21_info; indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; if (id->driver_data == MS8607) { diff --git a/drivers/iio/humidity/si7005.c b/drivers/iio/humidity/si7005.c index d5aef0bfef01..160b3d92df61 100644 --- a/drivers/iio/humidity/si7005.c +++ b/drivers/iio/humidity/si7005.c @@ -142,7 +142,6 @@ static int si7005_probe(struct i2c_client *client, data->client = client; mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->name = dev_name(&client->dev); indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &si7005_info; diff --git a/drivers/iio/humidity/si7020.c b/drivers/iio/humidity/si7020.c index b938f07eed64..a09b5773d377 100644 --- a/drivers/iio/humidity/si7020.c +++ b/drivers/iio/humidity/si7020.c @@ -128,7 +128,6 @@ static int si7020_probe(struct i2c_client *client, data = iio_priv(indio_dev); *data = client; - indio_dev->dev.parent = &client->dev; indio_dev->name = dev_name(&client->dev); indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &si7020_info; diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c index 229f2ff98469..1ebe3e50d3e6 100644 --- a/drivers/iio/imu/adis16400.c +++ b/drivers/iio/imu/adis16400.c @@ -1181,7 +1181,6 @@ static int adis16400_probe(struct spi_device *spi) /* setup the industrialio driver allocated elements */ st->variant = &adis16400_chips[spi_get_device_id(spi)->driver_data]; - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->channels = st->variant->channels; indio_dev->num_channels = st->variant->num_channels; diff --git a/drivers/iio/imu/adis16460.c b/drivers/iio/imu/adis16460.c index ad20c488a3ba..b26a5f1bc51a 100644 --- a/drivers/iio/imu/adis16460.c +++ b/drivers/iio/imu/adis16460.c @@ -393,7 +393,6 @@ static int adis16460_probe(struct spi_device *spi) st = iio_priv(indio_dev); st->chip_info = &adis16460_chip_info; - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->channels = st->chip_info->channels; indio_dev->num_channels = st->chip_info->num_channels; diff --git a/drivers/iio/imu/adis16475.c b/drivers/iio/imu/adis16475.c index c6dac4fc67a1..35d10ccb66c2 100644 --- a/drivers/iio/imu/adis16475.c +++ b/drivers/iio/imu/adis16475.c @@ -1289,7 +1289,6 @@ static int adis16475_probe(struct spi_device *spi) if (ret) return ret; - indio_dev->dev.parent = &spi->dev; indio_dev->name = st->info->name; indio_dev->channels = st->info->channels; indio_dev->num_channels = st->info->num_channels; diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c index 6a471eee110e..5163749f568e 100644 --- a/drivers/iio/imu/adis16480.c +++ b/drivers/iio/imu/adis16480.c @@ -1229,7 +1229,6 @@ static int adis16480_probe(struct spi_device *spi) st = iio_priv(indio_dev); st->chip_info = &adis16480_chip_info[id->driver_data]; - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->channels = st->chip_info->channels; indio_dev->num_channels = st->chip_info->num_channels; diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c index 26d586daee26..222ebb26f013 100644 --- a/drivers/iio/imu/bmi160/bmi160_core.c +++ b/drivers/iio/imu/bmi160/bmi160_core.c @@ -870,7 +870,6 @@ int bmi160_core_probe(struct device *dev, struct regmap *regmap, if (!name && ACPI_HANDLE(dev)) name = bmi160_match_acpi_device(dev); - indio_dev->dev.parent = dev; indio_dev->channels = bmi160_channels; indio_dev->num_channels = ARRAY_SIZE(bmi160_channels); indio_dev->name = name; diff --git a/drivers/iio/imu/fxos8700_core.c b/drivers/iio/imu/fxos8700_core.c index 7b47be44ea59..ab288186f36e 100644 --- a/drivers/iio/imu/fxos8700_core.c +++ b/drivers/iio/imu/fxos8700_core.c @@ -633,7 +633,6 @@ int fxos8700_core_probe(struct device *dev, struct regmap *regmap, if (ret) return ret; - indio_dev->dev.parent = dev; indio_dev->channels = fxos8700_channels; indio_dev->num_channels = ARRAY_SIZE(fxos8700_channels); indio_dev->name = name ? name : "fxos8700"; diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c index e67466100aff..e37bf0cb1654 100644 --- a/drivers/iio/imu/kmx61.c +++ b/drivers/iio/imu/kmx61.c @@ -1248,7 +1248,6 @@ static struct iio_dev *kmx61_indiodev_setup(struct kmx61_data *data, kmx61_set_data(indio_dev, data); - indio_dev->dev.parent = &data->client->dev; indio_dev->channels = chan; indio_dev->num_channels = num_channels; indio_dev->name = name; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 0b776cb91928..c8ddeb3f48ff 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -2152,7 +2152,6 @@ static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw, return NULL; iio_dev->modes = INDIO_DIRECT_MODE; - iio_dev->dev.parent = hw->dev; iio_dev->available_scan_masks = st_lsm6dsx_available_scan_masks; iio_dev->channels = hw->settings->channels[id].chan; iio_dev->num_channels = hw->settings->channels[id].len; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c index c1f83fe0d8da..f0d615ce4f4b 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c @@ -735,7 +735,6 @@ st_lsm6dsx_shub_alloc_iiodev(struct st_lsm6dsx_hw *hw, return NULL; iio_dev->modes = INDIO_DIRECT_MODE; - iio_dev->dev.parent = hw->dev; iio_dev->info = &st_lsm6dsx_ext_info; sensor = iio_priv(iio_dev); diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c index 1eafd0b24e18..2be7180e2cbf 100644 --- a/drivers/iio/light/acpi-als.c +++ b/drivers/iio/light/acpi-als.c @@ -178,7 +178,6 @@ static int acpi_als_add(struct acpi_device *device) mutex_init(&als->lock); indio_dev->name = ACPI_ALS_DEVICE_NAME; - indio_dev->dev.parent = &device->dev; indio_dev->info = &acpi_als_info; indio_dev->modes = INDIO_BUFFER_SOFTWARE; indio_dev->channels = acpi_als_channels; diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c index d3269cd44fb5..17dac8d0e11d 100644 --- a/drivers/iio/light/adjd_s311.c +++ b/drivers/iio/light/adjd_s311.c @@ -259,7 +259,6 @@ static int adjd_s311_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); data->client = client; - indio_dev->dev.parent = &client->dev; indio_dev->info = &adjd_s311_info; indio_dev->name = ADJD_S311_DRV_NAME; indio_dev->channels = adjd_s311_channels; diff --git a/drivers/iio/light/adux1020.c b/drivers/iio/light/adux1020.c index b07797ac10d7..9aa28695e6f1 100644 --- a/drivers/iio/light/adux1020.c +++ b/drivers/iio/light/adux1020.c @@ -785,7 +785,6 @@ static int adux1020_probe(struct i2c_client *client, if (!indio_dev) return -ENOMEM; - indio_dev->dev.parent = &client->dev; indio_dev->info = &adux1020_info; indio_dev->name = ADUX1020_DRV_NAME; indio_dev->channels = adux1020_channels; diff --git a/drivers/iio/light/al3010.c b/drivers/iio/light/al3010.c index b1ed7658cc46..b4e9924094cd 100644 --- a/drivers/iio/light/al3010.c +++ b/drivers/iio/light/al3010.c @@ -179,7 +179,6 @@ static int al3010_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); data->client = client; - indio_dev->dev.parent = &client->dev; indio_dev->info = &al3010_info; indio_dev->name = AL3010_DRV_NAME; indio_dev->channels = al3010_channels; diff --git a/drivers/iio/light/al3320a.c b/drivers/iio/light/al3320a.c index 20ed0a73c390..cc1407ccc10a 100644 --- a/drivers/iio/light/al3320a.c +++ b/drivers/iio/light/al3320a.c @@ -202,7 +202,6 @@ static int al3320a_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); data->client = client; - indio_dev->dev.parent = &client->dev; indio_dev->info = &al3320a_info; indio_dev->name = AL3320A_DRV_NAME; indio_dev->channels = al3320a_channels; diff --git a/drivers/iio/light/apds9300.c b/drivers/iio/light/apds9300.c index 856b6c468dea..baaf202dce05 100644 --- a/drivers/iio/light/apds9300.c +++ b/drivers/iio/light/apds9300.c @@ -419,7 +419,6 @@ static int apds9300_probe(struct i2c_client *client, mutex_init(&data->mutex); - indio_dev->dev.parent = &client->dev; indio_dev->channels = apds9300_channels; indio_dev->num_channels = ARRAY_SIZE(apds9300_channels); indio_dev->name = APDS9300_DRV_NAME; diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c index 52f86bc777dd..9afb3fcc74e6 100644 --- a/drivers/iio/light/apds9960.c +++ b/drivers/iio/light/apds9960.c @@ -1001,7 +1001,6 @@ static int apds9960_probe(struct i2c_client *client, iio_device_attach_buffer(indio_dev, buffer); - indio_dev->dev.parent = &client->dev; indio_dev->info = &apds9960_info; indio_dev->name = APDS9960_DRV_NAME; indio_dev->channels = apds9960_channels; diff --git a/drivers/iio/light/bh1750.c b/drivers/iio/light/bh1750.c index adb5ab9e3439..48484b9401b9 100644 --- a/drivers/iio/light/bh1750.c +++ b/drivers/iio/light/bh1750.c @@ -254,7 +254,6 @@ static int bh1750_probe(struct i2c_client *client, return ret; mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &bh1750_info; indio_dev->name = id->name; indio_dev->channels = bh1750_channels; diff --git a/drivers/iio/light/bh1780.c b/drivers/iio/light/bh1780.c index 03f2d8d123c4..abbf2e662e7d 100644 --- a/drivers/iio/light/bh1780.c +++ b/drivers/iio/light/bh1780.c @@ -185,7 +185,6 @@ static int bh1780_probe(struct i2c_client *client, pm_runtime_use_autosuspend(&client->dev); pm_runtime_put(&client->dev); - indio_dev->dev.parent = &client->dev; indio_dev->info = &bh1780_info; indio_dev->name = "bh1780"; indio_dev->channels = bh1780_channels; diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c index 160eb3f99795..5d8333d63358 100644 --- a/drivers/iio/light/cm32181.c +++ b/drivers/iio/light/cm32181.c @@ -465,7 +465,6 @@ static int cm32181_probe(struct i2c_client *client) cm32181->dev = dev; mutex_init(&cm32181->lock); - indio_dev->dev.parent = dev; indio_dev->channels = cm32181_channels; indio_dev->num_channels = ARRAY_SIZE(cm32181_channels); indio_dev->info = &cm32181_info; diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c index 867200825686..18a410340dc5 100644 --- a/drivers/iio/light/cm3232.c +++ b/drivers/iio/light/cm3232.c @@ -340,7 +340,6 @@ static int cm3232_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); chip->client = client; - indio_dev->dev.parent = &client->dev; indio_dev->channels = cm3232_channels; indio_dev->num_channels = ARRAY_SIZE(cm3232_channels); indio_dev->info = &cm3232_info; diff --git a/drivers/iio/light/cm3323.c b/drivers/iio/light/cm3323.c index 0443861ba1ec..6d1b0ffd144b 100644 --- a/drivers/iio/light/cm3323.c +++ b/drivers/iio/light/cm3323.c @@ -231,7 +231,6 @@ static int cm3323_probe(struct i2c_client *client, mutex_init(&data->mutex); - indio_dev->dev.parent = &client->dev; indio_dev->info = &cm3323_info; indio_dev->name = CM3323_DRV_NAME; indio_dev->channels = cm3323_channels; diff --git a/drivers/iio/light/cm36651.c b/drivers/iio/light/cm36651.c index 90e38fcc974b..fd83a19929bc 100644 --- a/drivers/iio/light/cm36651.c +++ b/drivers/iio/light/cm36651.c @@ -662,7 +662,6 @@ static int cm36651_probe(struct i2c_client *client, } mutex_init(&cm36651->lock); - indio_dev->dev.parent = &client->dev; indio_dev->channels = cm36651_channels; indio_dev->num_channels = ARRAY_SIZE(cm36651_channels); indio_dev->info = &cm36651_info; diff --git a/drivers/iio/light/gp2ap002.c b/drivers/iio/light/gp2ap002.c index 7a2679bdc987..d5e1cd27eb46 100644 --- a/drivers/iio/light/gp2ap002.c +++ b/drivers/iio/light/gp2ap002.c @@ -596,7 +596,6 @@ static int gp2ap002_probe(struct i2c_client *client, pm_runtime_use_autosuspend(dev); pm_runtime_put(dev); - indio_dev->dev.parent = dev; indio_dev->info = &gp2ap002_info; indio_dev->name = "gp2ap002"; indio_dev->channels = gp2ap002_channels; diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c index 070d4cd0cf54..dd9ad880deca 100644 --- a/drivers/iio/light/gp2ap020a00f.c +++ b/drivers/iio/light/gp2ap020a00f.c @@ -1527,7 +1527,6 @@ static int gp2ap020a00f_probe(struct i2c_client *client, init_waitqueue_head(&data->data_ready_queue); mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->channels = gp2ap020a00f_channels; indio_dev->num_channels = ARRAY_SIZE(gp2ap020a00f_channels); indio_dev->info = &gp2ap020a00f_info; diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index 81fa2a422797..a21c827e4953 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -301,7 +301,6 @@ static int hid_als_probe(struct platform_device *pdev) indio_dev->num_channels = ARRAY_SIZE(als_channels); - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &als_info; indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c index e9c04df07344..330cf359e0b8 100644 --- a/drivers/iio/light/hid-sensor-prox.c +++ b/drivers/iio/light/hid-sensor-prox.c @@ -279,7 +279,6 @@ static int hid_prox_probe(struct platform_device *pdev) } indio_dev->num_channels = ARRAY_SIZE(prox_channels); - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &prox_info; indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/light/iqs621-als.c b/drivers/iio/light/iqs621-als.c index 1a056e2446ab..004ea890a4b2 100644 --- a/drivers/iio/light/iqs621-als.c +++ b/drivers/iio/light/iqs621-als.c @@ -582,7 +582,6 @@ static int iqs621_als_probe(struct platform_device *pdev) } indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->dev.parent = &pdev->dev; indio_dev->name = iqs62x->dev_desc->dev_name; indio_dev->info = &iqs621_als_info; diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c index 805a74f08ad1..ac8ad0f32689 100644 --- a/drivers/iio/light/isl29018.c +++ b/drivers/iio/light/isl29018.c @@ -782,7 +782,6 @@ static int isl29018_probe(struct i2c_client *client, indio_dev->channels = isl29018_chip_info_tbl[dev_id].channels; indio_dev->num_channels = isl29018_chip_info_tbl[dev_id].num_channels; indio_dev->name = name; - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; return devm_iio_device_register(&client->dev, indio_dev); diff --git a/drivers/iio/light/isl29028.c b/drivers/iio/light/isl29028.c index 4d220c835c75..2f8b494f3e08 100644 --- a/drivers/iio/light/isl29028.c +++ b/drivers/iio/light/isl29028.c @@ -620,7 +620,6 @@ static int isl29028_probe(struct i2c_client *client, indio_dev->channels = isl29028_channels; indio_dev->num_channels = ARRAY_SIZE(isl29028_channels); indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; pm_runtime_enable(&client->dev); diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c index 95611f5eff01..663c72610655 100644 --- a/drivers/iio/light/isl29125.c +++ b/drivers/iio/light/isl29125.c @@ -268,7 +268,6 @@ static int isl29125_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); data->client = client; - indio_dev->dev.parent = &client->dev; indio_dev->info = &isl29125_info; indio_dev->name = ISL29125_DRV_NAME; indio_dev->channels = isl29125_channels; diff --git a/drivers/iio/light/jsa1212.c b/drivers/iio/light/jsa1212.c index 13deeebe37eb..724a0ec9f35c 100644 --- a/drivers/iio/light/jsa1212.c +++ b/drivers/iio/light/jsa1212.c @@ -338,7 +338,6 @@ static int jsa1212_probe(struct i2c_client *client, if (ret < 0) return ret; - indio_dev->dev.parent = &client->dev; indio_dev->channels = jsa1212_channels; indio_dev->num_channels = ARRAY_SIZE(jsa1212_channels); indio_dev->name = JSA1212_DRIVER_NAME; diff --git a/drivers/iio/light/lv0104cs.c b/drivers/iio/light/lv0104cs.c index 55b8e2855647..c2a896bb0aac 100644 --- a/drivers/iio/light/lv0104cs.c +++ b/drivers/iio/light/lv0104cs.c @@ -502,7 +502,6 @@ static int lv0104cs_probe(struct i2c_client *client, return ret; indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->dev.parent = &client->dev; indio_dev->channels = lv0104cs_channels; indio_dev->num_channels = ARRAY_SIZE(lv0104cs_channels); indio_dev->name = client->name; diff --git a/drivers/iio/light/max44000.c b/drivers/iio/light/max44000.c index d6d8007ba430..aa8ed1e3e89a 100644 --- a/drivers/iio/light/max44000.c +++ b/drivers/iio/light/max44000.c @@ -538,7 +538,6 @@ static int max44000_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &max44000_info; indio_dev->name = MAX44000_DRV_NAME; indio_dev->channels = max44000_channels; diff --git a/drivers/iio/light/max44009.c b/drivers/iio/light/max44009.c index 00ba15499638..801e5a0ad496 100644 --- a/drivers/iio/light/max44009.c +++ b/drivers/iio/light/max44009.c @@ -501,7 +501,6 @@ static int max44009_probe(struct i2c_client *client, data = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); data->client = client; - indio_dev->dev.parent = &client->dev; indio_dev->info = &max44009_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->name = MAX44009_DRV_NAME; diff --git a/drivers/iio/light/noa1305.c b/drivers/iio/light/noa1305.c index 5ebfbc52f541..a308fbc2fc7b 100644 --- a/drivers/iio/light/noa1305.c +++ b/drivers/iio/light/noa1305.c @@ -270,7 +270,6 @@ static int noa1305_probe(struct i2c_client *client, return ret; } - indio_dev->dev.parent = &client->dev; indio_dev->info = &noa1305_info; indio_dev->channels = noa1305_channels; indio_dev->num_channels = ARRAY_SIZE(noa1305_channels); diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c index 82abfa57b59c..b02c497455f3 100644 --- a/drivers/iio/light/opt3001.c +++ b/drivers/iio/light/opt3001.c @@ -768,7 +768,6 @@ static int opt3001_probe(struct i2c_client *client, iio->name = client->name; iio->channels = opt3001_channels; iio->num_channels = ARRAY_SIZE(opt3001_channels); - iio->dev.parent = dev; iio->modes = INDIO_DIRECT_MODE; iio->info = &opt3001_info; diff --git a/drivers/iio/light/pa12203001.c b/drivers/iio/light/pa12203001.c index 0295783f036a..bfade6577a38 100644 --- a/drivers/iio/light/pa12203001.c +++ b/drivers/iio/light/pa12203001.c @@ -362,7 +362,6 @@ static int pa12203001_probe(struct i2c_client *client, mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &pa12203001_info; indio_dev->name = PA12203001_DRIVER_NAME; indio_dev->channels = pa12203001_channels; diff --git a/drivers/iio/light/rpr0521.c b/drivers/iio/light/rpr0521.c index a0a7aeae5a82..c20fbc730d65 100644 --- a/drivers/iio/light/rpr0521.c +++ b/drivers/iio/light/rpr0521.c @@ -948,7 +948,6 @@ static int rpr0521_probe(struct i2c_client *client, mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &rpr0521_info; indio_dev->name = RPR0521_DRV_NAME; indio_dev->channels = rpr0521_channels; diff --git a/drivers/iio/light/si1133.c b/drivers/iio/light/si1133.c index c1adab2a50fd..c280b4195003 100644 --- a/drivers/iio/light/si1133.c +++ b/drivers/iio/light/si1133.c @@ -1015,7 +1015,6 @@ static int si1133_probe(struct i2c_client *client, i2c_set_clientdata(client, iio_dev); data->client = client; - iio_dev->dev.parent = &client->dev; iio_dev->name = id->name; iio_dev->channels = si1133_channels; iio_dev->num_channels = ARRAY_SIZE(si1133_channels); diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c index 0476c2bc8138..e1f989dd3a3d 100644 --- a/drivers/iio/light/si1145.c +++ b/drivers/iio/light/si1145.c @@ -1307,7 +1307,6 @@ static int si1145_probe(struct i2c_client *client, return -ENODEV; } - indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; indio_dev->channels = data->part_info->channels; indio_dev->num_channels = data->part_info->num_channels; diff --git a/drivers/iio/light/st_uvis25_core.c b/drivers/iio/light/st_uvis25_core.c index d262c254b895..4d001d50e775 100644 --- a/drivers/iio/light/st_uvis25_core.c +++ b/drivers/iio/light/st_uvis25_core.c @@ -303,7 +303,6 @@ int st_uvis25_probe(struct device *dev, int irq, struct regmap *regmap) return err; iio_dev->modes = INDIO_DIRECT_MODE; - iio_dev->dev.parent = dev; iio_dev->channels = st_uvis25_channels; iio_dev->num_channels = ARRAY_SIZE(st_uvis25_channels); iio_dev->name = ST_UVIS25_DEV_NAME; diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index 9d1e503bc958..9e159393a38e 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -585,7 +585,6 @@ static int stk3310_probe(struct i2c_client *client, if (ret < 0) return ret; - indio_dev->dev.parent = &client->dev; indio_dev->info = &stk3310_info; indio_dev->name = STK3310_DRIVER_NAME; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/light/tcs3414.c b/drivers/iio/light/tcs3414.c index b542e5619ead..bd6d3e4a0c4d 100644 --- a/drivers/iio/light/tcs3414.c +++ b/drivers/iio/light/tcs3414.c @@ -294,7 +294,6 @@ static int tcs3414_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); data->client = client; - indio_dev->dev.parent = &client->dev; indio_dev->info = &tcs3414_info; indio_dev->name = TCS3414_DRV_NAME; indio_dev->channels = tcs3414_channels; diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c index 12ad34441010..a0dc447aeb68 100644 --- a/drivers/iio/light/tcs3472.c +++ b/drivers/iio/light/tcs3472.c @@ -454,7 +454,6 @@ static int tcs3472_probe(struct i2c_client *client, data->client = client; mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &tcs3472_info; indio_dev->name = TCS3472_DRV_NAME; indio_dev->channels = tcs3472_channels; diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c index 2987a7a79a97..abc8d7db8dc1 100644 --- a/drivers/iio/light/tsl2563.c +++ b/drivers/iio/light/tsl2563.c @@ -750,7 +750,6 @@ static int tsl2563_probe(struct i2c_client *client, indio_dev->name = client->name; indio_dev->channels = tsl2563_channels; indio_dev->num_channels = ARRAY_SIZE(tsl2563_channels); - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; if (client->irq) diff --git a/drivers/iio/light/tsl2583.c b/drivers/iio/light/tsl2583.c index a760d14e146a..9e5490b7473b 100644 --- a/drivers/iio/light/tsl2583.c +++ b/drivers/iio/light/tsl2583.c @@ -840,7 +840,6 @@ static int tsl2583_probe(struct i2c_client *clientp, indio_dev->info = &tsl2583_info; indio_dev->channels = tsl2583_channels; indio_dev->num_channels = ARRAY_SIZE(tsl2583_channels); - indio_dev->dev.parent = &clientp->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->name = chip->client->name; diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c index 9fbde9b71b63..735399405417 100644 --- a/drivers/iio/light/tsl2772.c +++ b/drivers/iio/light/tsl2772.c @@ -1833,7 +1833,6 @@ static int tsl2772_probe(struct i2c_client *clientp, &tsl2772_chip_info_tbl[device_channel_config[id->driver_data]]; indio_dev->info = chip->chip_info->info; - indio_dev->dev.parent = &clientp->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->name = chip->client->name; indio_dev->num_channels = chip->chip_info->chan_table_elements; diff --git a/drivers/iio/light/tsl4531.c b/drivers/iio/light/tsl4531.c index 0dfc664205c7..70505ba6d858 100644 --- a/drivers/iio/light/tsl4531.c +++ b/drivers/iio/light/tsl4531.c @@ -192,7 +192,6 @@ static int tsl4531_probe(struct i2c_client *client, if (ret < 0) return ret; - indio_dev->dev.parent = &client->dev; indio_dev->info = &tsl4531_info; indio_dev->channels = tsl4531_channels; indio_dev->num_channels = ARRAY_SIZE(tsl4531_channels); diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c index b995f21a3347..2f2e79f17f0e 100644 --- a/drivers/iio/light/us5182d.c +++ b/drivers/iio/light/us5182d.c @@ -851,7 +851,6 @@ static int us5182d_probe(struct i2c_client *client, mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &us5182d_info; indio_dev->name = US5182D_DRV_NAME; indio_dev->channels = us5182d_channels; diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 2a4b3d331055..ac1ab715d4dd 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -1058,7 +1058,6 @@ static int vcnl4000_probe(struct i2c_client *client, &data->near_level)) data->near_level = 0; - indio_dev->dev.parent = &client->dev; indio_dev->info = data->chip_spec->info; indio_dev->channels = data->chip_spec->channels; indio_dev->num_channels = data->chip_spec->num_channels; diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c index cca4db312bd3..765c44adac57 100644 --- a/drivers/iio/light/vcnl4035.c +++ b/drivers/iio/light/vcnl4035.c @@ -564,7 +564,6 @@ static int vcnl4035_probe(struct i2c_client *client, data->client = client; data->regmap = regmap; - indio_dev->dev.parent = &client->dev; indio_dev->info = &vcnl4035_info; indio_dev->name = VCNL4035_DRV_NAME; indio_dev->channels = vcnl4035_channels; diff --git a/drivers/iio/light/veml6030.c b/drivers/iio/light/veml6030.c index aa25b87fca8f..de85c9b30be1 100644 --- a/drivers/iio/light/veml6030.c +++ b/drivers/iio/light/veml6030.c @@ -814,7 +814,6 @@ static int veml6030_probe(struct i2c_client *client, data->client = client; data->regmap = regmap; - indio_dev->dev.parent = &client->dev; indio_dev->name = "veml6030"; indio_dev->channels = veml6030_channels; indio_dev->num_channels = ARRAY_SIZE(veml6030_channels); diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c index 0be553ad5989..1e55e09a8d16 100644 --- a/drivers/iio/light/veml6070.c +++ b/drivers/iio/light/veml6070.c @@ -151,7 +151,6 @@ static int veml6070_probe(struct i2c_client *client, data->client1 = client; mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &veml6070_info; indio_dev->channels = veml6070_channels; indio_dev->num_channels = ARRAY_SIZE(veml6070_channels); diff --git a/drivers/iio/light/vl6180.c b/drivers/iio/light/vl6180.c index ed7b02765b97..4775bd785e50 100644 --- a/drivers/iio/light/vl6180.c +++ b/drivers/iio/light/vl6180.c @@ -509,7 +509,6 @@ static int vl6180_probe(struct i2c_client *client, data->client = client; mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &vl6180_info; indio_dev->channels = vl6180_channels; indio_dev->num_channels = ARRAY_SIZE(vl6180_channels); diff --git a/drivers/iio/light/zopt2201.c b/drivers/iio/light/zopt2201.c index 80ae530720cd..e0bc9df9c88b 100644 --- a/drivers/iio/light/zopt2201.c +++ b/drivers/iio/light/zopt2201.c @@ -527,7 +527,6 @@ static int zopt2201_probe(struct i2c_client *client, data->client = client; mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &zopt2201_info; indio_dev->channels = zopt2201_channels; indio_dev->num_channels = ARRAY_SIZE(zopt2201_channels); diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c index 810fdfd37c88..c2260c84f7f1 100644 --- a/drivers/iio/magnetometer/ak8974.c +++ b/drivers/iio/magnetometer/ak8974.c @@ -892,7 +892,6 @@ static int ak8974_probe(struct i2c_client *i2c, pm_runtime_use_autosuspend(&i2c->dev); pm_runtime_put(&i2c->dev); - indio_dev->dev.parent = &i2c->dev; switch (ak8974->variant) { case AK8974_WHOAMI_VALUE_AMI306: case AK8974_WHOAMI_VALUE_AMI305: diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c index d4de16750b10..8fc52057837d 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -883,7 +883,6 @@ int bmc150_magn_probe(struct device *dev, struct regmap *regmap, if (ret < 0) return ret; - indio_dev->dev.parent = dev; indio_dev->channels = bmc150_magn_channels; indio_dev->num_channels = ARRAY_SIZE(bmc150_magn_channels); indio_dev->available_scan_masks = bmc150_magn_scan_masks; diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index 0c09daf87794..97642ebd9168 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c @@ -512,7 +512,6 @@ static int hid_magn_3d_probe(struct platform_device *pdev) indio_dev->channels = channels; indio_dev->num_channels = chan_count; - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &magn_3d_info; indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/magnetometer/hmc5843_core.c b/drivers/iio/magnetometer/hmc5843_core.c index c44a4292da92..1474ba63babe 100644 --- a/drivers/iio/magnetometer/hmc5843_core.c +++ b/drivers/iio/magnetometer/hmc5843_core.c @@ -642,7 +642,6 @@ int hmc5843_common_probe(struct device *dev, struct regmap *regmap, if (ret) return ret; - indio_dev->dev.parent = dev; indio_dev->name = name; indio_dev->info = &hmc5843_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c index fb16cfdd6fa6..4d305a21c379 100644 --- a/drivers/iio/magnetometer/mag3110.c +++ b/drivers/iio/magnetometer/mag3110.c @@ -519,7 +519,6 @@ static int mag3110_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); indio_dev->info = &mag3110_info; indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = mag3110_channels; indio_dev->num_channels = ARRAY_SIZE(mag3110_channels); diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c index f27586716b5c..29a08d72fa90 100644 --- a/drivers/iio/magnetometer/mmc35240.c +++ b/drivers/iio/magnetometer/mmc35240.c @@ -507,7 +507,6 @@ static int mmc35240_probe(struct i2c_client *client, mutex_init(&data->mutex); - indio_dev->dev.parent = &client->dev; indio_dev->info = &mmc35240_info; indio_dev->name = MMC35240_DRV_NAME; indio_dev->channels = mmc35240_channels; diff --git a/drivers/iio/magnetometer/rm3100-core.c b/drivers/iio/magnetometer/rm3100-core.c index 43a2e420c9c4..a3e754943456 100644 --- a/drivers/iio/magnetometer/rm3100-core.c +++ b/drivers/iio/magnetometer/rm3100-core.c @@ -549,7 +549,6 @@ int rm3100_common_probe(struct device *dev, struct regmap *regmap, int irq) mutex_init(&data->lock); - indio_dev->dev.parent = dev; indio_dev->name = "rm3100"; indio_dev->info = &rm3100_info; indio_dev->channels = rm3100_channels; diff --git a/drivers/iio/multiplexer/iio-mux.c b/drivers/iio/multiplexer/iio-mux.c index 0422ef57914c..6910218fdb00 100644 --- a/drivers/iio/multiplexer/iio-mux.c +++ b/drivers/iio/multiplexer/iio-mux.c @@ -395,7 +395,6 @@ static int mux_probe(struct platform_device *pdev) mux->cached_state = -1; indio_dev->name = dev_name(dev); - indio_dev->dev.parent = dev; indio_dev->info = &mux_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = mux->chan; diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c index 6aac8bea233a..ae132a93bcae 100644 --- a/drivers/iio/orientation/hid-sensor-incl-3d.c +++ b/drivers/iio/orientation/hid-sensor-incl-3d.c @@ -339,7 +339,6 @@ static int hid_incl_3d_probe(struct platform_device *pdev) } indio_dev->num_channels = ARRAY_SIZE(incl_3d_channels); - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &incl_3d_info; indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/position/iqs624-pos.c b/drivers/iio/position/iqs624-pos.c index 520dafbdc48f..4d7452314209 100644 --- a/drivers/iio/position/iqs624-pos.c +++ b/drivers/iio/position/iqs624-pos.c @@ -247,7 +247,6 @@ static int iqs624_pos_probe(struct platform_device *pdev) iqs624_pos->indio_dev = indio_dev; indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->dev.parent = &pdev->dev; indio_dev->channels = iqs624_pos_channels; indio_dev->num_channels = ARRAY_SIZE(iqs624_pos_channels); indio_dev->name = iqs62x->dev_desc->dev_name; diff --git a/drivers/iio/potentiometer/ad5272.c b/drivers/iio/potentiometer/ad5272.c index 154f9a5da8bc..08a15e505ed6 100644 --- a/drivers/iio/potentiometer/ad5272.c +++ b/drivers/iio/potentiometer/ad5272.c @@ -184,7 +184,6 @@ static int ad5272_probe(struct i2c_client *client, if (ret < 0) return -ENODEV; - indio_dev->dev.parent = dev; indio_dev->info = &ad5272_info; indio_dev->channels = &ad5272_channel; indio_dev->num_channels = 1; diff --git a/drivers/iio/potentiometer/ds1803.c b/drivers/iio/potentiometer/ds1803.c index d0de78232a93..5c061ab8f46c 100644 --- a/drivers/iio/potentiometer/ds1803.c +++ b/drivers/iio/potentiometer/ds1803.c @@ -126,7 +126,6 @@ static int ds1803_probe(struct i2c_client *client, data->client = client; data->cfg = &ds1803_cfg[id->driver_data]; - indio_dev->dev.parent = dev; indio_dev->info = &ds1803_info; indio_dev->channels = ds1803_channels; indio_dev->num_channels = ARRAY_SIZE(ds1803_channels); diff --git a/drivers/iio/potentiometer/max5432.c b/drivers/iio/potentiometer/max5432.c index 641b1821fdf6..280de9c54471 100644 --- a/drivers/iio/potentiometer/max5432.c +++ b/drivers/iio/potentiometer/max5432.c @@ -102,7 +102,6 @@ static int max5432_probe(struct i2c_client *client, data->client = client; data->ohm = (unsigned long)of_device_get_match_data(dev); - indio_dev->dev.parent = dev; indio_dev->info = &max5432_info; indio_dev->channels = max5432_channels; indio_dev->num_channels = ARRAY_SIZE(max5432_channels); diff --git a/drivers/iio/potentiometer/max5481.c b/drivers/iio/potentiometer/max5481.c index 732375b6d131..e4cb947c1c32 100644 --- a/drivers/iio/potentiometer/max5481.c +++ b/drivers/iio/potentiometer/max5481.c @@ -149,7 +149,6 @@ static int max5481_probe(struct spi_device *spi) data->cfg = &max5481_cfg[id->driver_data]; indio_dev->name = id->name; - indio_dev->dev.parent = &spi->dev; indio_dev->modes = INDIO_DIRECT_MODE; /* variant specific configuration */ diff --git a/drivers/iio/potentiometer/max5487.c b/drivers/iio/potentiometer/max5487.c index 68ff806d4668..7ec51976ec99 100644 --- a/drivers/iio/potentiometer/max5487.c +++ b/drivers/iio/potentiometer/max5487.c @@ -100,7 +100,6 @@ static int max5487_spi_probe(struct spi_device *spi) indio_dev->info = &max5487_info; indio_dev->name = id->name; - indio_dev->dev.parent = &spi->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = max5487_channels; indio_dev->num_channels = ARRAY_SIZE(max5487_channels); diff --git a/drivers/iio/potentiometer/mcp4018.c b/drivers/iio/potentiometer/mcp4018.c index 62151b2a2b12..fd0579ad3c83 100644 --- a/drivers/iio/potentiometer/mcp4018.c +++ b/drivers/iio/potentiometer/mcp4018.c @@ -165,7 +165,6 @@ static int mcp4018_probe(struct i2c_client *client) if (!data->cfg) data->cfg = &mcp4018_cfg[i2c_match_id(mcp4018_id, client)->driver_data]; - indio_dev->dev.parent = dev; indio_dev->info = &mcp4018_info; indio_dev->channels = &mcp4018_channel; indio_dev->num_channels = 1; diff --git a/drivers/iio/potentiometer/mcp41010.c b/drivers/iio/potentiometer/mcp41010.c index 2368b39debf5..3c46ce4bc627 100644 --- a/drivers/iio/potentiometer/mcp41010.c +++ b/drivers/iio/potentiometer/mcp41010.c @@ -152,7 +152,6 @@ static int mcp41010_probe(struct spi_device *spi) mutex_init(&data->lock); - indio_dev->dev.parent = dev; indio_dev->info = &mcp41010_info; indio_dev->channels = mcp41010_channels; indio_dev->num_channels = data->cfg->wipers; diff --git a/drivers/iio/potentiometer/mcp4131.c b/drivers/iio/potentiometer/mcp4131.c index 98df91e97f2f..103df5e100f3 100644 --- a/drivers/iio/potentiometer/mcp4131.c +++ b/drivers/iio/potentiometer/mcp4131.c @@ -260,7 +260,6 @@ static int mcp4131_probe(struct spi_device *spi) mutex_init(&data->lock); - indio_dev->dev.parent = dev; indio_dev->info = &mcp4131_info; indio_dev->channels = mcp4131_channels; indio_dev->num_channels = data->cfg->wipers; diff --git a/drivers/iio/potentiometer/mcp4531.c b/drivers/iio/potentiometer/mcp4531.c index d71a22d71a30..95efc4b40514 100644 --- a/drivers/iio/potentiometer/mcp4531.c +++ b/drivers/iio/potentiometer/mcp4531.c @@ -375,7 +375,6 @@ static int mcp4531_probe(struct i2c_client *client) if (!data->cfg) data->cfg = &mcp4531_cfg[i2c_match_id(mcp4531_id, client)->driver_data]; - indio_dev->dev.parent = dev; indio_dev->info = &mcp4531_info; indio_dev->channels = mcp4531_channels; indio_dev->num_channels = data->cfg->wipers; diff --git a/drivers/iio/potentiometer/tpl0102.c b/drivers/iio/potentiometer/tpl0102.c index a0a07e47f13f..d996dc367fb7 100644 --- a/drivers/iio/potentiometer/tpl0102.c +++ b/drivers/iio/potentiometer/tpl0102.c @@ -140,7 +140,6 @@ static int tpl0102_probe(struct i2c_client *client, return PTR_ERR(data->regmap); } - indio_dev->dev.parent = dev; indio_dev->info = &tpl0102_info; indio_dev->channels = tpl0102_channels; indio_dev->num_channels = data->cfg->wipers; diff --git a/drivers/iio/pressure/abp060mg.c b/drivers/iio/pressure/abp060mg.c index 267aad8af0a6..e1c3bdb371ee 100644 --- a/drivers/iio/pressure/abp060mg.c +++ b/drivers/iio/pressure/abp060mg.c @@ -194,7 +194,6 @@ static int abp060mg_probe(struct i2c_client *client, abp060mg_init_device(indio_dev, cfg_id); - indio_dev->dev.parent = &client->dev; indio_dev->name = dev_name(&client->dev); indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &abp060mg_info; diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index 126a56d31b6e..6b7da40f99c8 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -1004,7 +1004,6 @@ int bmp280_common_probe(struct device *dev, mutex_init(&data->lock); data->dev = dev; - indio_dev->dev.parent = dev; indio_dev->name = name; indio_dev->channels = bmp280_channels; indio_dev->info = &bmp280_info; diff --git a/drivers/iio/pressure/dlhl60d.c b/drivers/iio/pressure/dlhl60d.c index b8c99e7bd6cf..7afe37c97575 100644 --- a/drivers/iio/pressure/dlhl60d.c +++ b/drivers/iio/pressure/dlhl60d.c @@ -311,7 +311,6 @@ static int dlh_probe(struct i2c_client *client, st->use_interrupt = false; indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; indio_dev->dev.of_node = client->dev.of_node; indio_dev->info = &dlh_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c index 2c1943bbc433..0730380ceb69 100644 --- a/drivers/iio/pressure/dps310.c +++ b/drivers/iio/pressure/dps310.c @@ -732,7 +732,6 @@ static int dps310_probe(struct i2c_client *client, data->client = client; mutex_init(&data->lock); - iio->dev.parent = &client->dev; iio->name = id->name; iio->channels = dps310_channels; iio->num_channels = ARRAY_SIZE(dps310_channels); diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c index 5e6663f757ae..5c458788f346 100644 --- a/drivers/iio/pressure/hid-sensor-press.c +++ b/drivers/iio/pressure/hid-sensor-press.c @@ -283,7 +283,6 @@ static int hid_press_probe(struct platform_device *pdev) indio_dev->num_channels = ARRAY_SIZE(press_channels); - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &press_info; indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/pressure/hp03.c b/drivers/iio/pressure/hp03.c index 026ba15ef68f..e40b1d7dc129 100644 --- a/drivers/iio/pressure/hp03.c +++ b/drivers/iio/pressure/hp03.c @@ -224,7 +224,6 @@ static int hp03_probe(struct i2c_client *client, priv->client = client; mutex_init(&priv->lock); - indio_dev->dev.parent = dev; indio_dev->name = id->name; indio_dev->channels = hp03_channels; indio_dev->num_channels = ARRAY_SIZE(hp03_channels); diff --git a/drivers/iio/pressure/hp206c.c b/drivers/iio/pressure/hp206c.c index 1f931f5b7a65..986b7a59712e 100644 --- a/drivers/iio/pressure/hp206c.c +++ b/drivers/iio/pressure/hp206c.c @@ -378,7 +378,6 @@ static int hp206c_probe(struct i2c_client *client, indio_dev->info = &hp206c_info; indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = hp206c_channels; indio_dev->num_channels = ARRAY_SIZE(hp206c_channels); diff --git a/drivers/iio/pressure/icp10100.c b/drivers/iio/pressure/icp10100.c index 06cb5b63a189..90c0df068bbb 100644 --- a/drivers/iio/pressure/icp10100.c +++ b/drivers/iio/pressure/icp10100.c @@ -545,7 +545,6 @@ static int icp10100_probe(struct i2c_client *client, return -ENOMEM; i2c_set_clientdata(client, indio_dev); - indio_dev->dev.parent = &client->dev; indio_dev->name = client->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = icp10100_channels; diff --git a/drivers/iio/pressure/mpl115.c b/drivers/iio/pressure/mpl115.c index ca81a3dc5646..81f288312a28 100644 --- a/drivers/iio/pressure/mpl115.c +++ b/drivers/iio/pressure/mpl115.c @@ -160,7 +160,6 @@ int mpl115_probe(struct device *dev, const char *name, indio_dev->info = &mpl115_info; indio_dev->name = name; - indio_dev->dev.parent = dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = mpl115_channels; indio_dev->num_channels = ARRAY_SIZE(mpl115_channels); diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c index d066f3c5a8a6..ccdb0b70e48c 100644 --- a/drivers/iio/pressure/mpl3115.c +++ b/drivers/iio/pressure/mpl3115.c @@ -241,7 +241,6 @@ static int mpl3115_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); indio_dev->info = &mpl3115_info; indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = mpl3115_channels; indio_dev->num_channels = ARRAY_SIZE(mpl3115_channels); diff --git a/drivers/iio/pressure/ms5637.c b/drivers/iio/pressure/ms5637.c index f49c7003c72a..05e0ef7260d5 100644 --- a/drivers/iio/pressure/ms5637.c +++ b/drivers/iio/pressure/ms5637.c @@ -152,7 +152,6 @@ static int ms5637_probe(struct i2c_client *client, indio_dev->info = &ms5637_info; indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ms5637_channels; indio_dev->num_channels = ARRAY_SIZE(ms5637_channels); diff --git a/drivers/iio/pressure/t5403.c b/drivers/iio/pressure/t5403.c index 22abd28071b7..685fcf65334f 100644 --- a/drivers/iio/pressure/t5403.c +++ b/drivers/iio/pressure/t5403.c @@ -236,7 +236,6 @@ static int t5403_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); indio_dev->info = &t5403_info; indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = t5403_channels; indio_dev->num_channels = ARRAY_SIZE(t5403_channels); diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c index 37fe851f89af..ef818f2aebd6 100644 --- a/drivers/iio/pressure/zpa2326.c +++ b/drivers/iio/pressure/zpa2326.c @@ -1601,7 +1601,6 @@ static struct iio_dev *zpa2326_create_managed_iiodev(struct device *device, /* Setup for userspace synchronous on demand sampling. */ indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->dev.parent = device; indio_dev->channels = zpa2326_channels; indio_dev->num_channels = ARRAY_SIZE(zpa2326_channels); indio_dev->name = name; diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c index bac9a433dd19..c339e7339ec8 100644 --- a/drivers/iio/proximity/as3935.c +++ b/drivers/iio/proximity/as3935.c @@ -399,7 +399,6 @@ static int as3935_probe(struct spi_device *spi) return -EINVAL; } - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->channels = as3935_channels; indio_dev->num_channels = ARRAY_SIZE(as3935_channels); diff --git a/drivers/iio/proximity/isl29501.c b/drivers/iio/proximity/isl29501.c index 5ae549075b27..90e76451c972 100644 --- a/drivers/iio/proximity/isl29501.c +++ b/drivers/iio/proximity/isl29501.c @@ -972,7 +972,6 @@ static int isl29501_probe(struct i2c_client *client, return ret; indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->dev.parent = &client->dev; indio_dev->channels = isl29501_channels; indio_dev->num_channels = ARRAY_SIZE(isl29501_channels); indio_dev->name = client->name; diff --git a/drivers/iio/proximity/mb1232.c b/drivers/iio/proximity/mb1232.c index 166b3e6d7db8..654564c45248 100644 --- a/drivers/iio/proximity/mb1232.c +++ b/drivers/iio/proximity/mb1232.c @@ -200,7 +200,6 @@ static int mb1232_probe(struct i2c_client *client, indio_dev->info = &mb1232_info; indio_dev->name = id->name; - indio_dev->dev.parent = dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = mb1232_channels; indio_dev->num_channels = ARRAY_SIZE(mb1232_channels); diff --git a/drivers/iio/proximity/rfd77402.c b/drivers/iio/proximity/rfd77402.c index 36480c0100a7..7a0472323f17 100644 --- a/drivers/iio/proximity/rfd77402.c +++ b/drivers/iio/proximity/rfd77402.c @@ -274,7 +274,6 @@ static int rfd77402_probe(struct i2c_client *client, data->client = client; mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &rfd77402_info; indio_dev->channels = rfd77402_channels; indio_dev->num_channels = ARRAY_SIZE(rfd77402_channels); diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index d161f3061e35..08c6100e2c94 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -931,7 +931,6 @@ static int sx9310_probe(struct i2c_client *client, return ret; ACPI_COMPANION_SET(&indio_dev->dev, ACPI_COMPANION(&client->dev)); - indio_dev->dev.parent = &client->dev; indio_dev->channels = sx9310_channels; indio_dev->num_channels = ARRAY_SIZE(sx9310_channels); indio_dev->info = &sx9310_info; diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c index 287d288e40c2..f6eec54faef4 100644 --- a/drivers/iio/proximity/sx9500.c +++ b/drivers/iio/proximity/sx9500.c @@ -931,7 +931,6 @@ static int sx9500_probe(struct i2c_client *client, if (IS_ERR(data->regmap)) return PTR_ERR(data->regmap); - indio_dev->dev.parent = &client->dev; indio_dev->name = SX9500_DRIVER_NAME; indio_dev->channels = sx9500_channels; indio_dev->num_channels = ARRAY_SIZE(sx9500_channels); diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c index b48216cc1858..5fbda9475ba9 100644 --- a/drivers/iio/proximity/vl53l0x-i2c.c +++ b/drivers/iio/proximity/vl53l0x-i2c.c @@ -134,7 +134,6 @@ static int vl53l0x_probe(struct i2c_client *client) I2C_FUNC_SMBUS_BYTE_DATA)) return -EOPNOTSUPP; - indio_dev->dev.parent = &client->dev; indio_dev->name = "vl53l0x"; indio_dev->info = &vl53l0x_info; indio_dev->channels = vl53l0x_channels; diff --git a/drivers/iio/resolver/ad2s1200.c b/drivers/iio/resolver/ad2s1200.c index a391f46ee06b..6007abad116b 100644 --- a/drivers/iio/resolver/ad2s1200.c +++ b/drivers/iio/resolver/ad2s1200.c @@ -157,7 +157,6 @@ static int ad2s1200_probe(struct spi_device *spi) return PTR_ERR(st->rdvel); } - indio_dev->dev.parent = &spi->dev; indio_dev->info = &ad2s1200_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ad2s1200_channels; diff --git a/drivers/iio/resolver/ad2s90.c b/drivers/iio/resolver/ad2s90.c index a41f5cb10da5..d6a91f137e13 100644 --- a/drivers/iio/resolver/ad2s90.c +++ b/drivers/iio/resolver/ad2s90.c @@ -94,7 +94,6 @@ static int ad2s90_probe(struct spi_device *spi) mutex_init(&st->lock); st->sdev = spi; - indio_dev->dev.parent = &spi->dev; indio_dev->info = &ad2s90_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = &ad2s90_chan; diff --git a/drivers/iio/temperature/hid-sensor-temperature.c b/drivers/iio/temperature/hid-sensor-temperature.c index 8d1f434f109d..81688f1b932f 100644 --- a/drivers/iio/temperature/hid-sensor-temperature.c +++ b/drivers/iio/temperature/hid-sensor-temperature.c @@ -223,7 +223,6 @@ static int hid_temperature_probe(struct platform_device *pdev) indio_dev->channels = temp_chans; indio_dev->num_channels = ARRAY_SIZE(temperature_channels); - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &temperature_info; indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/temperature/iqs620at-temp.c b/drivers/iio/temperature/iqs620at-temp.c index 3fd52b3eb030..fe126e1fb783 100644 --- a/drivers/iio/temperature/iqs620at-temp.c +++ b/drivers/iio/temperature/iqs620at-temp.c @@ -74,7 +74,6 @@ static int iqs620_temp_probe(struct platform_device *pdev) iio_device_set_drvdata(indio_dev, iqs62x); indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->dev.parent = &pdev->dev; indio_dev->channels = iqs620_temp_channels; indio_dev->num_channels = ARRAY_SIZE(iqs620_temp_channels); indio_dev->name = iqs62x->dev_desc->dev_name; diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c index 8976e8d59826..55ff28a0f1c7 100644 --- a/drivers/iio/temperature/ltc2983.c +++ b/drivers/iio/temperature/ltc2983.c @@ -1500,7 +1500,6 @@ static int ltc2983_probe(struct spi_device *spi) if (ret) return ret; - indio_dev->dev.parent = &spi->dev; indio_dev->name = name; indio_dev->num_channels = st->iio_channels; indio_dev->channels = st->iio_chan; diff --git a/drivers/iio/temperature/max31856.c b/drivers/iio/temperature/max31856.c index b4c49a5d3685..ffc54289fca7 100644 --- a/drivers/iio/temperature/max31856.c +++ b/drivers/iio/temperature/max31856.c @@ -417,7 +417,6 @@ static int max31856_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); indio_dev->info = &max31856_info; - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = id->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c index 8d21116c7a22..0297e215b61a 100644 --- a/drivers/iio/temperature/maxim_thermocouple.c +++ b/drivers/iio/temperature/maxim_thermocouple.c @@ -244,7 +244,6 @@ static int maxim_thermocouple_probe(struct spi_device *spi) indio_dev->available_scan_masks = chip->scan_masks; indio_dev->num_channels = chip->num_channels; indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->dev.parent = &spi->dev; data = iio_priv(indio_dev); data->spi = spi; diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c index b7c56ddf884f..ef0fec94d269 100644 --- a/drivers/iio/temperature/mlx90614.c +++ b/drivers/iio/temperature/mlx90614.c @@ -525,7 +525,6 @@ static int mlx90614_probe(struct i2c_client *client, mlx90614_wakeup(data); - indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &mlx90614_info; diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c index eaca6ba06864..ef94ad86275c 100644 --- a/drivers/iio/temperature/mlx90632.c +++ b/drivers/iio/temperature/mlx90632.c @@ -645,7 +645,6 @@ static int mlx90632_probe(struct i2c_client *client, mlx90632->regmap = regmap; mutex_init(&mlx90632->lock); - indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &mlx90632_info; diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c index cc45d8345eb9..54976c7dad92 100644 --- a/drivers/iio/temperature/tmp006.c +++ b/drivers/iio/temperature/tmp006.c @@ -216,7 +216,6 @@ static int tmp006_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); data->client = client; - indio_dev->dev.parent = &client->dev; indio_dev->name = dev_name(&client->dev); indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &tmp006_info; diff --git a/drivers/iio/temperature/tmp007.c b/drivers/iio/temperature/tmp007.c index 7df234d96f94..f90fe9e5617b 100644 --- a/drivers/iio/temperature/tmp007.c +++ b/drivers/iio/temperature/tmp007.c @@ -463,7 +463,6 @@ static int tmp007_probe(struct i2c_client *client, data->client = client; mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->name = "tmp007"; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &tmp007_info; diff --git a/drivers/iio/temperature/tsys02d.c b/drivers/iio/temperature/tsys02d.c index 6735af400b22..fc96e5f9d3fc 100644 --- a/drivers/iio/temperature/tsys02d.c +++ b/drivers/iio/temperature/tsys02d.c @@ -149,7 +149,6 @@ static int tsys02d_probe(struct i2c_client *client, indio_dev->info = &tsys02d_info; indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = tsys02d_channels; indio_dev->num_channels = ARRAY_SIZE(tsys02d_channels); diff --git a/drivers/iio/trigger/stm32-timer-trigger.c b/drivers/iio/trigger/stm32-timer-trigger.c index 7d8962d6566a..e7459ad3d6cd 100644 --- a/drivers/iio/trigger/stm32-timer-trigger.c +++ b/drivers/iio/trigger/stm32-timer-trigger.c @@ -723,7 +723,6 @@ static struct stm32_timer_trigger *stm32_setup_counter_device(struct device *dev return NULL; indio_dev->name = dev_name(dev); - indio_dev->dev.parent = dev; indio_dev->info = &stm32_trigger_info; indio_dev->modes = INDIO_HARDWARE_TRIGGERED; indio_dev->num_channels = 1; diff --git a/drivers/input/touchscreen/tsc2007_iio.c b/drivers/input/touchscreen/tsc2007_iio.c index 3b0e3fa87d4c..752eb7fe5da3 100644 --- a/drivers/input/touchscreen/tsc2007_iio.c +++ b/drivers/input/touchscreen/tsc2007_iio.c @@ -119,7 +119,6 @@ int tsc2007_iio_configure(struct tsc2007 *ts) iio->ts = ts; indio_dev->name = "tsc2007"; - indio_dev->dev.parent = &ts->client->dev; indio_dev->info = &tsc2007_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = tsc2007_iio_channel; diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index fef52d9b5346..c7798908ef0e 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -277,7 +277,6 @@ static int adis16203_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); indio_dev->name = spi->dev.driver->name; - indio_dev->dev.parent = &spi->dev; indio_dev->channels = adis16203_channels; indio_dev->num_channels = ARRAY_SIZE(adis16203_channels); indio_dev->info = &adis16203_info; diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c index 8bd35c6c56a1..38ec40b458c9 100644 --- a/drivers/staging/iio/accel/adis16240.c +++ b/drivers/staging/iio/accel/adis16240.c @@ -400,7 +400,6 @@ static int adis16240_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); indio_dev->name = spi->dev.driver->name; - indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16240_info; indio_dev->channels = adis16240_channels; indio_dev->num_channels = ARRAY_SIZE(adis16240_channels); diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index bef6bd1295ea..fef0055b8990 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -978,7 +978,6 @@ static int ad7280_probe(struct spi_device *spi) st->readback_delay_us += 5; /* Add tWAIT */ indio_dev->name = spi_get_device_id(spi)->name; - indio_dev->dev.parent = &spi->dev; indio_dev->modes = INDIO_DIRECT_MODE; ret = ad7280_channel_init(st); diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index a9985a7f8199..6c14d7bcdd67 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -394,7 +394,6 @@ static int ad7816_probe(struct spi_device *spi_dev) } indio_dev->name = spi_get_device_id(spi_dev)->name; - indio_dev->dev.parent = &spi_dev->dev; indio_dev->info = &ad7816_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index f4954d85553e..48132ab157ef 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -590,8 +590,6 @@ static int ad7150_probe(struct i2c_client *client, indio_dev->name = id->name; indio_dev->channels = ad7150_channels; indio_dev->num_channels = ARRAY_SIZE(ad7150_channels); - /* Establish that the iio_dev is a child of the i2c device */ - indio_dev->dev.parent = &client->dev; indio_dev->info = &ad7150_info; diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index 21527d84f940..bd9803c7c5b6 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -695,7 +695,6 @@ static int ad7746_probe(struct i2c_client *client, /* Establish that the iio_dev is a child of the i2c device */ indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; indio_dev->info = &ad7746_info; indio_dev->channels = ad7746_channels; if (id->driver_data == 7746) diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c index 74308a2e72db..447937e04ebd 100644 --- a/drivers/staging/iio/frequency/ad9832.c +++ b/drivers/staging/iio/frequency/ad9832.c @@ -348,7 +348,6 @@ static int ad9832_probe(struct spi_device *spi) st->spi = spi; mutex_init(&st->lock); - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad9832_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c index 23026978a5a5..77f77a2b2e05 100644 --- a/drivers/staging/iio/frequency/ad9834.c +++ b/drivers/staging/iio/frequency/ad9834.c @@ -431,7 +431,6 @@ static int ad9834_probe(struct spi_device *spi) st->spi = spi; st->devid = spi_get_device_id(spi)->driver_data; st->reg = reg; - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; switch (st->devid) { case ID_AD9833: diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index c468355b0848..dba78896ea8f 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -759,7 +759,6 @@ static int ad5933_probe(struct i2c_client *client, INIT_DELAYED_WORK(&st->work, ad5933_work); st->poll_time_jiffies = msecs_to_jiffies(AD5933_POLL_TIME_ms); - indio_dev->dev.parent = &client->dev; indio_dev->info = &ad5933_info; indio_dev->name = id->name; indio_dev->modes = (INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE); diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index ed404355ea4c..74adb82f37c3 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -671,7 +671,6 @@ static int ad2s1210_probe(struct spi_device *spi) st->resolution = 12; st->fexcit = AD2S1210_DEF_EXCIT; - indio_dev->dev.parent = &spi->dev; indio_dev->info = &ad2s1210_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ad2s1210_channels; -- cgit v1.2.3-58-ga151 From 2cbd54129fddd6ce943d327eb22895d7ce93ce76 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Wed, 3 Jun 2020 14:40:21 +0300 Subject: iio: remove left-over comments about parent assignment These were obtained by doing a 'git diff | grep \/\*', in the previous diff to find comments. These needed a bit more manual review, as the semantic patch isn't great for catching these. The result is: /* Initialize Counter device and driver data */ /* Initialize IIO device */ /* Establish that the iio_dev is a child of the spi device */ /* Estabilish that the iio_dev is a child of the spi device */ /* Initiate the Industrial I/O device */ /* Establish that the iio_dev is a child of the device */ - /* establish that the iio_dev is a child of the i2c device */ - /* establish that the iio_dev is a child of the i2c device */ /* This is only used for removal purposes */ /* setup the industrialio driver allocated elements */ /* variant specific configuration */ /* Setup for userspace synchronous on demand sampling. */ st->readback_delay_us += 5; /* Add tWAIT */ - /* Establish that the iio_dev is a child of the i2c device */ /* Establish that the iio_dev is a child of the i2c device */ Out of which, 4 are really left-over comments about parent assignment. 3 of them are removed by the semantic patch, as the comment removed (by spatch) would be for an empty line. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7476.c | 1 - drivers/iio/adc/ad7887.c | 1 - drivers/iio/dac/ad5446.c | 1 - drivers/staging/iio/cdc/ad7746.c | 1 - 4 files changed, 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c index e2a69dd6a47e..6286e230f55b 100644 --- a/drivers/iio/adc/ad7476.c +++ b/drivers/iio/adc/ad7476.c @@ -300,7 +300,6 @@ static int ad7476_probe(struct spi_device *spi) st->spi = spi; - /* Establish that the iio_dev is a child of the spi device */ indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c index ca4c98401ebc..0f93f5c8965d 100644 --- a/drivers/iio/adc/ad7887.c +++ b/drivers/iio/adc/ad7887.c @@ -264,7 +264,6 @@ static int ad7887_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); st->spi = spi; - /* Estabilish that the iio_dev is a child of the spi device */ indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad7887_info; diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c index e01ba90dc106..5931bd630c4e 100644 --- a/drivers/iio/dac/ad5446.c +++ b/drivers/iio/dac/ad5446.c @@ -250,7 +250,6 @@ static int ad5446_probe(struct device *dev, const char *name, st->reg = reg; st->dev = dev; - /* Establish that the iio_dev is a child of the device */ indio_dev->name = name; indio_dev->info = &ad5446_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index bd9803c7c5b6..dfd71e99e872 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -693,7 +693,6 @@ static int ad7746_probe(struct i2c_client *client, chip->client = client; chip->capdac_set = -1; - /* Establish that the iio_dev is a child of the i2c device */ indio_dev->name = id->name; indio_dev->info = &ad7746_info; indio_dev->channels = ad7746_channels; -- cgit v1.2.3-58-ga151 From 8f73a13f74571941c2ad6d04c65b52d39cbdf90b Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Wed, 3 Jun 2020 14:40:23 +0300 Subject: iio: remove left-over parent assignments These were found by doing some shell magic: ------------ for file in $(git grep -w devm_iio_device_alloc | cut -d: -f1 | sort | uniq) ; do if grep 'parent =' $file | grep -v trig | grep -vq devm_; then echo "$file -> $(grep "parent =" $file)" fi done ----------- The output is bearable [after the semantic patch is applied]. There is a mix of trigger assignments with some iio device parent assignments that are removed via this patch. JC: A few more added via inspection of all parent = statements in drivers/iio. Some of these may just have crossed with this series, others were less obvious to scripting due to some cross file / module boundary calls. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/accel/kxcjk-1013.c | 1 - drivers/iio/accel/mma8452.c | 1 - drivers/iio/accel/mma9553.c | 1 - drivers/iio/adc/ad7192.c | 1 - drivers/iio/adc/hx711.c | 1 - drivers/iio/adc/ltc2497-core.c | 1 - drivers/iio/adc/max1363.c | 2 -- drivers/iio/adc/mcp3911.c | 1 - drivers/iio/adc/qcom-spmi-iadc.c | 1 - drivers/iio/amplifiers/ad8366.c | 1 - drivers/iio/chemical/atlas-ezo-sensor.c | 1 - drivers/iio/chemical/vz89x.c | 1 - drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c | 1 - drivers/iio/common/st_sensors/st_sensors_i2c.c | 1 - drivers/iio/common/st_sensors/st_sensors_spi.c | 1 - drivers/iio/dac/ad5770r.c | 1 - drivers/iio/health/afe4403.c | 1 - drivers/iio/health/afe4404.c | 1 - drivers/iio/humidity/dht11.c | 1 - drivers/iio/humidity/hts221_core.c | 1 - drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 1 - drivers/iio/light/cm3605.c | 1 - drivers/iio/light/ltr501.c | 1 - drivers/iio/magnetometer/ak8975.c | 1 - drivers/iio/orientation/hid-sensor-rotation.c | 1 - drivers/iio/potentiostat/lmp91000.c | 1 - drivers/iio/pressure/ms5611_core.c | 1 - drivers/iio/proximity/ping.c | 1 - drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 1 - drivers/iio/proximity/srf04.c | 1 - drivers/iio/proximity/srf08.c | 1 - drivers/iio/proximity/vcnl3020.c | 1 - drivers/iio/temperature/tsys01.c | 1 - drivers/staging/iio/addac/adt7316.c | 1 - 34 files changed, 35 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index c9924a65c32a..6b93521c0e17 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -1311,7 +1311,6 @@ static int kxcjk1013_probe(struct i2c_client *client, mutex_init(&data->mutex); - indio_dev->dev.parent = &client->dev; indio_dev->channels = kxcjk1013_channels; indio_dev->num_channels = ARRAY_SIZE(kxcjk1013_channels); indio_dev->available_scan_masks = kxcjk1013_scan_masks; diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 00e100fc845a..ef3df402fc3c 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -1592,7 +1592,6 @@ static int mma8452_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); indio_dev->info = &mma8452_info; indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = data->chip_info->channels; indio_dev->num_channels = data->chip_info->num_channels; diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c index 312070dcf035..c15908faa381 100644 --- a/drivers/iio/accel/mma9553.c +++ b/drivers/iio/accel/mma9553.c @@ -1103,7 +1103,6 @@ static int mma9553_probe(struct i2c_client *client, if (ret < 0) return ret; - indio_dev->dev.parent = &client->dev; indio_dev->channels = mma9553_channels; indio_dev->num_channels = ARRAY_SIZE(mma9553_channels); indio_dev->name = name; diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c index 08ba1a8f05eb..a0837d7e9176 100644 --- a/drivers/iio/adc/ad7192.c +++ b/drivers/iio/adc/ad7192.c @@ -970,7 +970,6 @@ static int ad7192_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); st->chip_info = of_device_get_match_data(&spi->dev); - indio_dev->dev.parent = &spi->dev; indio_dev->name = st->chip_info->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index c8686558429b..6a173531d355 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -551,7 +551,6 @@ static int hx711_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); indio_dev->name = "hx711"; - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &hx711_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = hx711_chan_spec; diff --git a/drivers/iio/adc/ltc2497-core.c b/drivers/iio/adc/ltc2497-core.c index f5f7039caacc..9b8fd9c32364 100644 --- a/drivers/iio/adc/ltc2497-core.c +++ b/drivers/iio/adc/ltc2497-core.c @@ -169,7 +169,6 @@ int ltc2497core_probe(struct device *dev, struct iio_dev *indio_dev) struct ltc2497core_driverdata *ddata = iio_priv(indio_dev); int ret; - indio_dev->dev.parent = dev; indio_dev->name = dev_name(dev); indio_dev->info = <c2497core_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index 9d92017c79b2..cc1ba7bfc8e6 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -1652,8 +1652,6 @@ static int max1363_probe(struct i2c_client *client, if (ret) goto error_disable_reg; - /* Establish that the iio_dev is a child of the i2c device */ - indio_dev->dev.parent = &client->dev; indio_dev->dev.of_node = client->dev.of_node; indio_dev->name = id->name; indio_dev->channels = st->chip_info->channels; diff --git a/drivers/iio/adc/mcp3911.c b/drivers/iio/adc/mcp3911.c index dd52f08ec82e..818b92518c66 100644 --- a/drivers/iio/adc/mcp3911.c +++ b/drivers/iio/adc/mcp3911.c @@ -293,7 +293,6 @@ static int mcp3911_probe(struct spi_device *spi) if (ret) goto clk_disable; - indio_dev->dev.parent = &spi->dev; indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/qcom-spmi-iadc.c b/drivers/iio/adc/qcom-spmi-iadc.c index 46858eddf1c3..1c90ad33a881 100644 --- a/drivers/iio/adc/qcom-spmi-iadc.c +++ b/drivers/iio/adc/qcom-spmi-iadc.c @@ -553,7 +553,6 @@ static int iadc_probe(struct platform_device *pdev) return ret; } - indio_dev->dev.parent = dev; indio_dev->dev.of_node = node; indio_dev->name = pdev->name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c index 8345ba65d41d..cfcf18a0bce8 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -277,7 +277,6 @@ static int ad8366_probe(struct spi_device *spi) } st->info = &ad8366_infos[st->type]; - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad8366_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/chemical/atlas-ezo-sensor.c b/drivers/iio/chemical/atlas-ezo-sensor.c index a94eb8a6bf32..8b72bb012363 100644 --- a/drivers/iio/chemical/atlas-ezo-sensor.c +++ b/drivers/iio/chemical/atlas-ezo-sensor.c @@ -152,7 +152,6 @@ static int atlas_ezo_probe(struct i2c_client *client, indio_dev->channels = chip->channels; indio_dev->num_channels = chip->num_channels; indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->dev.parent = &client->dev; data = iio_priv(indio_dev); data->client = client; diff --git a/drivers/iio/chemical/vz89x.c b/drivers/iio/chemical/vz89x.c index 415b39339d4e..5586eb8e12cd 100644 --- a/drivers/iio/chemical/vz89x.c +++ b/drivers/iio/chemical/vz89x.c @@ -382,7 +382,6 @@ static int vz89x_probe(struct i2c_client *client, data->last_update = jiffies - HZ; mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->info = &vz89x_info; indio_dev->name = dev_name(&client->dev); indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c index cda459b61206..ee309bbdf432 100644 --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c @@ -281,7 +281,6 @@ int cros_ec_sensors_core_init(struct platform_device *pdev, state->msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset; state->msg->outsize = sizeof(struct ec_params_motion_sense); - indio_dev->dev.parent = &pdev->dev; indio_dev->name = pdev->name; if (physical_device) { diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c index b400560bac93..b9e59ad32a02 100644 --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c @@ -56,7 +56,6 @@ int st_sensors_i2c_configure(struct iio_dev *indio_dev, i2c_set_clientdata(client, indio_dev); - indio_dev->dev.parent = &client->dev; indio_dev->name = client->name; sdata->dev = &client->dev; diff --git a/drivers/iio/common/st_sensors/st_sensors_spi.c b/drivers/iio/common/st_sensors/st_sensors_spi.c index ee70515bb89f..48fc41dc5633 100644 --- a/drivers/iio/common/st_sensors/st_sensors_spi.c +++ b/drivers/iio/common/st_sensors/st_sensors_spi.c @@ -108,7 +108,6 @@ int st_sensors_spi_configure(struct iio_dev *indio_dev, spi_set_drvdata(spi, indio_dev); - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi->modalias; sdata->dev = &spi->dev; diff --git a/drivers/iio/dac/ad5770r.c b/drivers/iio/dac/ad5770r.c index 2d7623b9b2c0..84dcf149261f 100644 --- a/drivers/iio/dac/ad5770r.c +++ b/drivers/iio/dac/ad5770r.c @@ -651,7 +651,6 @@ static int ad5770r_probe(struct spi_device *spi) } } - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad5770r_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index e9f87e42ff4f..ed230f12b2f8 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -509,7 +509,6 @@ static int afe4403_probe(struct spi_device *spi) } indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->dev.parent = afe->dev; indio_dev->channels = afe4403_channels; indio_dev->num_channels = ARRAY_SIZE(afe4403_channels); indio_dev->name = AFE4403_DRIVER_NAME; diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index e728bbb21ca8..3a3efae4695a 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -517,7 +517,6 @@ static int afe4404_probe(struct i2c_client *client, } indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->dev.parent = afe->dev; indio_dev->channels = afe4404_channels; indio_dev->num_channels = ARRAY_SIZE(afe4404_channels); indio_dev->name = AFE4404_DRIVER_NAME; diff --git a/drivers/iio/humidity/dht11.c b/drivers/iio/humidity/dht11.c index d05c6fdb758b..9a7819817488 100644 --- a/drivers/iio/humidity/dht11.c +++ b/drivers/iio/humidity/dht11.c @@ -321,7 +321,6 @@ static int dht11_probe(struct platform_device *pdev) init_completion(&dht11->completion); mutex_init(&dht11->lock); iio->name = pdev->name; - iio->dev.parent = &pdev->dev; iio->info = &dht11_iio_info; iio->modes = INDIO_DIRECT_MODE; iio->channels = dht11_chan_spec; diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c index 7ce1bd1defa0..16657789dc45 100644 --- a/drivers/iio/humidity/hts221_core.c +++ b/drivers/iio/humidity/hts221_core.c @@ -572,7 +572,6 @@ int hts221_probe(struct device *dev, int irq, const char *name, return err; iio_dev->modes = INDIO_DIRECT_MODE; - iio_dev->dev.parent = hw->dev; iio_dev->available_scan_masks = hts221_scan_masks; iio_dev->channels = hts221_channels; iio_dev->num_channels = ARRAY_SIZE(hts221_channels); diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 4d604fe842e5..153f855db8d6 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -1530,7 +1530,6 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name, } dev_set_drvdata(dev, indio_dev); - indio_dev->dev.parent = dev; /* name will be NULL when enumerated via ACPI */ if (name) indio_dev->name = name; diff --git a/drivers/iio/light/cm3605.c b/drivers/iio/light/cm3605.c index 964ede49f662..4c83953672be 100644 --- a/drivers/iio/light/cm3605.c +++ b/drivers/iio/light/cm3605.c @@ -239,7 +239,6 @@ static int cm3605_probe(struct platform_device *pdev) led_trigger_register_simple("cm3605", &cm3605->led); led_trigger_event(cm3605->led, LED_FULL); - indio_dev->dev.parent = dev; indio_dev->info = &cm3605_info; indio_dev->name = "cm3605"; indio_dev->channels = cm3605_channels; diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 5a3fcb127cd2..4bac0646398d 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -1480,7 +1480,6 @@ static int ltr501_probe(struct i2c_client *client, if ((partid >> 4) != data->chip_info->partid) return -ENODEV; - indio_dev->dev.parent = &client->dev; indio_dev->info = data->chip_info->info; indio_dev->channels = data->chip_info->channels; indio_dev->num_channels = data->chip_info->no_channels; diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index a23422aad97d..03d71f796177 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -940,7 +940,6 @@ static int ak8975_probe(struct i2c_client *client, } mutex_init(&data->lock); - indio_dev->dev.parent = &client->dev; indio_dev->channels = ak8975_channels; indio_dev->num_channels = ARRAY_SIZE(ak8975_channels); indio_dev->info = &ak8975_info; diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c index b99f41240e3e..23bc61a7f018 100644 --- a/drivers/iio/orientation/hid-sensor-rotation.c +++ b/drivers/iio/orientation/hid-sensor-rotation.c @@ -281,7 +281,6 @@ static int hid_dev_rot_probe(struct platform_device *pdev) } indio_dev->num_channels = ARRAY_SIZE(dev_rot_channels); - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &dev_rot_info; indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/potentiostat/lmp91000.c b/drivers/iio/potentiostat/lmp91000.c index 2cb11da18e0f..2d601889c8c0 100644 --- a/drivers/iio/potentiostat/lmp91000.c +++ b/drivers/iio/potentiostat/lmp91000.c @@ -321,7 +321,6 @@ static int lmp91000_probe(struct i2c_client *client, indio_dev->channels = lmp91000_channels; indio_dev->num_channels = ARRAY_SIZE(lmp91000_channels); indio_dev->name = LMP91000_DRV_NAME; - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; i2c_set_clientdata(client, indio_dev); diff --git a/drivers/iio/pressure/ms5611_core.c b/drivers/iio/pressure/ms5611_core.c index 2f598ad91621..d451bb9dffc8 100644 --- a/drivers/iio/pressure/ms5611_core.c +++ b/drivers/iio/pressure/ms5611_core.c @@ -435,7 +435,6 @@ int ms5611_probe(struct iio_dev *indio_dev, struct device *dev, st->pressure_osr = &ms5611_avail_pressure_osr[ARRAY_SIZE(ms5611_avail_pressure_osr) - 1]; - indio_dev->dev.parent = dev; indio_dev->name = name; indio_dev->info = &ms5611_info; indio_dev->channels = ms5611_channels; diff --git a/drivers/iio/proximity/ping.c b/drivers/iio/proximity/ping.c index 2e99eeb27f2e..1283ac1c2e03 100644 --- a/drivers/iio/proximity/ping.c +++ b/drivers/iio/proximity/ping.c @@ -309,7 +309,6 @@ static int ping_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); indio_dev->name = "ping"; - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &ping_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ping_chan_spec; diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c index 5b369645ef49..a8e716dbd24e 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -270,7 +270,6 @@ static int lidar_probe(struct i2c_client *client, indio_dev->name = LIDAR_DRV_NAME; indio_dev->channels = lidar_channels; indio_dev->num_channels = ARRAY_SIZE(lidar_channels); - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; i2c_set_clientdata(client, indio_dev); diff --git a/drivers/iio/proximity/srf04.c b/drivers/iio/proximity/srf04.c index 568b76e06385..2a3acff431d7 100644 --- a/drivers/iio/proximity/srf04.c +++ b/drivers/iio/proximity/srf04.c @@ -317,7 +317,6 @@ static int srf04_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); indio_dev->name = "srf04"; - indio_dev->dev.parent = &pdev->dev; indio_dev->info = &srf04_iio_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = srf04_chan_spec; diff --git a/drivers/iio/proximity/srf08.c b/drivers/iio/proximity/srf08.c index b23ce446b7be..6677221d5818 100644 --- a/drivers/iio/proximity/srf08.c +++ b/drivers/iio/proximity/srf08.c @@ -483,7 +483,6 @@ static int srf08_probe(struct i2c_client *client, } indio_dev->name = id->name; - indio_dev->dev.parent = &client->dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = srf08_channels; indio_dev->num_channels = ARRAY_SIZE(srf08_channels); diff --git a/drivers/iio/proximity/vcnl3020.c b/drivers/iio/proximity/vcnl3020.c index 9ff1a164c2e6..37264f801ad0 100644 --- a/drivers/iio/proximity/vcnl3020.c +++ b/drivers/iio/proximity/vcnl3020.c @@ -226,7 +226,6 @@ static int vcnl3020_probe(struct i2c_client *client) if (rc) return rc; - indio_dev->dev.parent = &client->dev; indio_dev->info = &vcnl3020_info; indio_dev->channels = vcnl3020_channels; indio_dev->num_channels = ARRAY_SIZE(vcnl3020_channels); diff --git a/drivers/iio/temperature/tsys01.c b/drivers/iio/temperature/tsys01.c index d41f050c2fea..2c631a1ca33b 100644 --- a/drivers/iio/temperature/tsys01.c +++ b/drivers/iio/temperature/tsys01.c @@ -160,7 +160,6 @@ static int tsys01_probe(struct iio_dev *indio_dev, struct device *dev) indio_dev->info = &tsys01_info; indio_dev->name = dev->driver->name; - indio_dev->dev.parent = dev; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = tsys01_channels; indio_dev->num_channels = ARRAY_SIZE(tsys01_channels); diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 9cb3d0e42c38..ccbafcaaf27e 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2171,7 +2171,6 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) chip->int_mask |= ADT7516_AIN_INT_MASK; - indio_dev->dev.parent = dev; if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) indio_dev->info = &adt7516_info; else -- cgit v1.2.3-58-ga151 From ce59858bbc104ab5afddbd3e00edcdaed134ac68 Mon Sep 17 00:00:00 2001 From: Julius Hemanth Pitti Date: Tue, 9 Jun 2020 14:24:14 -0700 Subject: staging: wfx: make methods 'wfx_get_ps_timeout' and 'wfx_update_pm' static Add "static" for local methods wfx_get_ps_timeout() and wfx_update_pm() to address following sparse warnings. wfx/sta.c:203:5: warning: symbol 'wfx_get_ps_timeout' was not declared. Should it be static? wfx/sta.c:233:5: warning: symbol 'wfx_update_pm' was not declared. Should it be static? Signed-off-by: Julius Hemanth Pitti Link: https://lore.kernel.org/r/1591737854-11855-1-git-send-email-juliushemanth@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/sta.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 12e8a5b638f1..d855d87c2102 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -200,7 +200,7 @@ void wfx_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, mutex_unlock(&wdev->conf_mutex); } -int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps) +static int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps) { struct ieee80211_channel *chan0 = NULL, *chan1 = NULL; struct ieee80211_conf *conf = &wvif->wdev->hw->conf; @@ -230,7 +230,7 @@ int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps) return -1; } -int wfx_update_pm(struct wfx_vif *wvif) +static int wfx_update_pm(struct wfx_vif *wvif) { int ps_timeout; bool ps; -- cgit v1.2.3-58-ga151 From 3ee97e220648257e8a89c98c2a5cd5f989956168 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Tue, 9 Jun 2020 20:48:48 +0100 Subject: staging: rtl8712: switch to common ieee80211 headers This patch switches to and and deletes a lot of duplicate definitions plus many unused ones. Non obvious changes: - struct ieee80211_ht_cap is different enough that I preferred to keep (and rename) it for now. - mcs_rate in translate_scan was not read after being set, so I deleted that part rather than using the renamed struct - WLAN_CAPABILITY_BSS is replaced with WLAN_CAPABILITY_ESS which is the corresponding one with same value Signed-off-by: Pascal Terjan Link: https://lore.kernel.org/r/20200609194848.166130-1-pterjan@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/Kconfig | 2 +- drivers/staging/rtl8712/ieee80211.h | 584 +------------------------- drivers/staging/rtl8712/rtl8712_recv.c | 7 +- drivers/staging/rtl8712/rtl871x_ht.h | 2 +- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 13 +- drivers/staging/rtl8712/rtl871x_mlme.c | 14 +- drivers/staging/rtl8712/rtl871x_recv.c | 7 +- drivers/staging/rtl8712/rtl871x_recv.h | 2 - drivers/staging/rtl8712/rtl871x_xmit.c | 2 +- drivers/staging/rtl8712/wifi.h | 21 +- 10 files changed, 21 insertions(+), 633 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/Kconfig b/drivers/staging/rtl8712/Kconfig index c62747c90968..8de26425225b 100644 --- a/drivers/staging/rtl8712/Kconfig +++ b/drivers/staging/rtl8712/Kconfig @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 config R8712U tristate "RealTek RTL8712U (RTL8192SU) Wireless LAN NIC driver" - depends on WLAN && USB + depends on WLAN && USB && CFG80211 select WIRELESS_EXT select WEXT_PRIV select FW_LOADER diff --git a/drivers/staging/rtl8712/ieee80211.h b/drivers/staging/rtl8712/ieee80211.h index dabaa8fd34fb..61eff7c5746b 100644 --- a/drivers/staging/rtl8712/ieee80211.h +++ b/drivers/staging/rtl8712/ieee80211.h @@ -14,14 +14,8 @@ #ifndef __IEEE80211_H #define __IEEE80211_H -#include "osdep_service.h" -#include "drv_types.h" -#include "wifi.h" -#include -#include +#include -#define MGMT_QUEUE_NUM 5 -#define ETH_ALEN 6 #define IEEE_CMD_SET_WPA_PARAM 1 #define IEEE_CMD_SET_WPA_IE 2 #define IEEE_CMD_SET_ENCRYPTION 3 @@ -102,162 +96,11 @@ struct ieee_param { } u; }; -#define IEEE80211_DATA_LEN 2304 -/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section - * 6.2.1.1.2. - * - * The figure in section 7.1.2 suggests a body size of up to 2312 - * bytes is allowed, which is a bit confusing, I suspect this - * represents the 2304 bytes of real data, plus a possible 8 bytes of - * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) - */ - -#define IEEE80211_HLEN 30 -#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) - -/* this is stolen from ipw2200 driver */ -#define IEEE_IBSS_MAC_HASH_SIZE 31 - -struct ieee_ibss_seq { - u8 mac[ETH_ALEN]; - u16 seq_num; - u16 frag_num; - unsigned long packet_time; - struct list_head list; -}; - -struct ieee80211_hdr { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 addr2[ETH_ALEN]; - u8 addr3[ETH_ALEN]; - __le16 seq_ctl; - u8 addr4[ETH_ALEN]; -} __packed __aligned(2); - -struct ieee80211_hdr_3addr { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 addr2[ETH_ALEN]; - u8 addr3[ETH_ALEN]; - __le16 seq_ctl; -} __packed __aligned(2); - -struct ieee80211_hdr_qos { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 addr2[ETH_ALEN]; - u8 addr3[ETH_ALEN]; - __le16 seq_ctl; - u8 addr4[ETH_ALEN]; - __le16 qc; -} __packed __aligned(2); - -struct ieee80211_hdr_3addr_qos { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[ETH_ALEN]; - u8 addr2[ETH_ALEN]; - u8 addr3[ETH_ALEN]; - __le16 seq_ctl; - __le16 qc; -} __packed; - -struct eapol { - u8 snap[6]; - __be16 ethertype; - u8 version; - u8 type; - __le16 length; -} __packed; - -enum eap_type { - EAP_PACKET = 0, - EAPOL_START, - EAPOL_LOGOFF, - EAPOL_KEY, - EAPOL_ENCAP_ASF_ALERT -}; - -#define IEEE80211_3ADDR_LEN 24 -#define IEEE80211_4ADDR_LEN 30 -#define IEEE80211_FCS_LEN 4 - #define MIN_FRAG_THRESHOLD 256U #define MAX_FRAG_THRESHOLD 2346U -/* Frame control field constants */ -#define IEEE80211_FCTL_VERS 0x0002 -#define IEEE80211_FCTL_FTYPE 0x000c -#define IEEE80211_FCTL_STYPE 0x00f0 -#define IEEE80211_FCTL_TODS 0x0100 -#define IEEE80211_FCTL_FROMDS 0x0200 -#define IEEE80211_FCTL_MOREFRAGS 0x0400 -#define IEEE80211_FCTL_RETRY 0x0800 -#define IEEE80211_FCTL_PM 0x1000 -#define IEEE80211_FCTL_MOREDATA 0x2000 -#define IEEE80211_FCTL_WEP 0x4000 -#define IEEE80211_FCTL_ORDER 0x8000 - -#define IEEE80211_FTYPE_MGMT 0x0000 -#define IEEE80211_FTYPE_CTL 0x0004 -#define IEEE80211_FTYPE_DATA 0x0008 - -/* management */ -#define IEEE80211_STYPE_ASSOC_REQ 0x0000 -#define IEEE80211_STYPE_ASSOC_RESP 0x0010 -#define IEEE80211_STYPE_REASSOC_REQ 0x0020 -#define IEEE80211_STYPE_REASSOC_RESP 0x0030 -#define IEEE80211_STYPE_PROBE_REQ 0x0040 -#define IEEE80211_STYPE_PROBE_RESP 0x0050 -#define IEEE80211_STYPE_BEACON 0x0080 -#define IEEE80211_STYPE_ATIM 0x0090 -#define IEEE80211_STYPE_DISASSOC 0x00A0 -#define IEEE80211_STYPE_AUTH 0x00B0 -#define IEEE80211_STYPE_DEAUTH 0x00C0 - -/* control */ -#define IEEE80211_STYPE_PSPOLL 0x00A0 -#define IEEE80211_STYPE_RTS 0x00B0 -#define IEEE80211_STYPE_CTS 0x00C0 -#define IEEE80211_STYPE_ACK 0x00D0 -#define IEEE80211_STYPE_CFEND 0x00E0 -#define IEEE80211_STYPE_CFENDACK 0x00F0 - -/* data */ -#define IEEE80211_STYPE_DATA 0x0000 -#define IEEE80211_STYPE_DATA_CFACK 0x0010 -#define IEEE80211_STYPE_DATA_CFPOLL 0x0020 -#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030 -#define IEEE80211_STYPE_NULLFUNC 0x0040 -#define IEEE80211_STYPE_CFACK 0x0050 -#define IEEE80211_STYPE_CFPOLL 0x0060 -#define IEEE80211_STYPE_CFACKPOLL 0x0070 -#define IEEE80211_QOS_DATAGRP 0x0080 - -#define IEEE80211_SCTL_FRAG 0x000F -#define IEEE80211_SCTL_SEQ 0xFFF0 - /* QoS,QOS */ #define NORMAL_ACK 0 -#define NO_ACK 1 -#define NON_EXPLICIT_ACK 2 -#define BLOCK_ACK 3 - -#ifndef ETH_P_PAE -#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ -#endif /* ETH_P_PAE */ - -#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ - -#define ETH_P_ECONET 0x0018 - -#ifndef ETH_P_80211_RAW -#define ETH_P_80211_RAW (ETH_P_ECONET + 1) -#endif /* IEEE 802.11 defines */ @@ -272,58 +115,6 @@ struct ieee80211_snap_hdr { #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) -#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE) -#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE) - -#define WLAN_QC_GET_TID(qc) ((qc) & 0x0f) - -#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG) -#define WLAN_GET_SEQ_SEQ(seq) ((seq) & IEEE80211_SCTL_SEQ) - -/* Authentication algorithms */ -#define WLAN_AUTH_OPEN 0 -#define WLAN_AUTH_SHARED_KEY 1 - -#define WLAN_AUTH_CHALLENGE_LEN 128 - -#define WLAN_CAPABILITY_BSS BIT(0) -#define WLAN_CAPABILITY_IBSS BIT(1) -#define WLAN_CAPABILITY_CF_POLLABLE BIT(2) -#define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3) -#define WLAN_CAPABILITY_PRIVACY BIT(4) -#define WLAN_CAPABILITY_SHORT_PREAMBLE BIT(5) -#define WLAN_CAPABILITY_PBCC BIT(6) -#define WLAN_CAPABILITY_CHANNEL_AGILITY BIT(7) -#define WLAN_CAPABILITY_SHORT_SLOT BIT(10) - -/* Information Element IDs */ -#define WLAN_EID_SSID 0 -#define WLAN_EID_SUPP_RATES 1 -#define WLAN_EID_FH_PARAMS 2 -#define WLAN_EID_DS_PARAMS 3 -#define WLAN_EID_CF_PARAMS 4 -#define WLAN_EID_TIM 5 -#define WLAN_EID_IBSS_PARAMS 6 -#define WLAN_EID_CHALLENGE 16 -#define WLAN_EID_RSN 48 -#define WLAN_EID_GENERIC 221 - -#define IEEE80211_MGMT_HDR_LEN 24 -#define IEEE80211_DATA_HDR3_LEN 24 -#define IEEE80211_DATA_HDR4_LEN 30 - -#define IEEE80211_STATMASK_SIGNAL BIT(0) -#define IEEE80211_STATMASK_RSSI BIT(1) -#define IEEE80211_STATMASK_NOISE BIT(2) -#define IEEE80211_STATMASK_RATE BIT(3) -#define IEEE80211_STATMASK_WEMASK 0x7 - -#define IEEE80211_CCK_MODULATION BIT(0) -#define IEEE80211_OFDM_MODULATION BIT(1) - -#define IEEE80211_24GHZ_BAND BIT(0) -#define IEEE80211_52GHZ_BAND BIT(1) - #define IEEE80211_CCK_RATE_LEN 4 #define IEEE80211_NUM_OFDM_RATESLEN 8 @@ -331,7 +122,6 @@ struct ieee80211_snap_hdr { #define IEEE80211_CCK_RATE_2MB 0x04 #define IEEE80211_CCK_RATE_5MB 0x0B #define IEEE80211_CCK_RATE_11MB 0x16 -#define IEEE80211_OFDM_RATE_LEN 8 #define IEEE80211_OFDM_RATE_6MB 0x0C #define IEEE80211_OFDM_RATE_9MB 0x12 #define IEEE80211_OFDM_RATE_12MB 0x18 @@ -342,388 +132,16 @@ struct ieee80211_snap_hdr { #define IEEE80211_OFDM_RATE_54MB 0x6C #define IEEE80211_BASIC_RATE_MASK 0x80 -#define IEEE80211_CCK_RATE_1MB_MASK BIT(0) -#define IEEE80211_CCK_RATE_2MB_MASK BIT(1) -#define IEEE80211_CCK_RATE_5MB_MASK BIT(2) -#define IEEE80211_CCK_RATE_11MB_MASK BIT(3) -#define IEEE80211_OFDM_RATE_6MB_MASK BIT(4) -#define IEEE80211_OFDM_RATE_9MB_MASK BIT(5) -#define IEEE80211_OFDM_RATE_12MB_MASK BIT(6) -#define IEEE80211_OFDM_RATE_18MB_MASK BIT(7) -#define IEEE80211_OFDM_RATE_24MB_MASK BIT(8) -#define IEEE80211_OFDM_RATE_36MB_MASK BIT(9) -#define IEEE80211_OFDM_RATE_48MB_MASK BIT(10) -#define IEEE80211_OFDM_RATE_54MB_MASK BIT(11) - -#define IEEE80211_CCK_RATES_MASK 0x0000000F -#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \ - IEEE80211_CCK_RATE_2MB_MASK) -#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \ - IEEE80211_CCK_RATE_5MB_MASK | \ - IEEE80211_CCK_RATE_11MB_MASK) - -#define IEEE80211_OFDM_RATES_MASK 0x00000FF0 -#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \ - IEEE80211_OFDM_RATE_12MB_MASK | \ - IEEE80211_OFDM_RATE_24MB_MASK) -#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \ - IEEE80211_OFDM_RATE_9MB_MASK | \ - IEEE80211_OFDM_RATE_18MB_MASK | \ - IEEE80211_OFDM_RATE_36MB_MASK | \ - IEEE80211_OFDM_RATE_48MB_MASK | \ - IEEE80211_OFDM_RATE_54MB_MASK) -#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \ - IEEE80211_CCK_DEFAULT_RATES_MASK) - -#define IEEE80211_NUM_OFDM_RATES 8 -#define IEEE80211_NUM_CCK_RATES 4 -#define IEEE80211_OFDM_SHIFT_MASK_A 4 - -/* NOTE: This data is for statistical purposes; not all hardware provides this - * information for frames received. Not setting these will not cause - * any adverse affects. - */ -struct ieee80211_rx_stats { - s8 rssi; - u8 signal; - u8 noise; - u8 received_channel; - u16 rate; /* in 100 kbps */ - u8 mask; - u8 freq; - u16 len; -}; - -/* IEEE 802.11 requires that STA supports concurrent reception of at least - * three fragmented frames. This define can be increased to support more - * concurrent frames, but it should be noted that each entry can consume about - * 2 kB of RAM and increasing cache size will slow down frame reassembly. - */ -#define IEEE80211_FRAG_CACHE_LEN 4 - -struct ieee80211_frag_entry { - u32 first_frag_time; - uint seq; - uint last_frag; - uint qos; /*jackson*/ - uint tid; /*jackson*/ - struct sk_buff *skb; - u8 src_addr[ETH_ALEN]; - u8 dst_addr[ETH_ALEN]; -}; - -struct ieee80211_stats { - uint tx_unicast_frames; - uint tx_multicast_frames; - uint tx_fragments; - uint tx_unicast_octets; - uint tx_multicast_octets; - uint tx_deferred_transmissions; - uint tx_single_retry_frames; - uint tx_multiple_retry_frames; - uint tx_retry_limit_exceeded; - uint tx_discards; - uint rx_unicast_frames; - uint rx_multicast_frames; - uint rx_fragments; - uint rx_unicast_octets; - uint rx_multicast_octets; - uint rx_fcs_errors; - uint rx_discards_no_buffer; - uint tx_discards_wrong_sa; - uint rx_discards_undecryptable; - uint rx_message_in_msg_fragments; - uint rx_message_in_bad_msg_fragments; -}; - -struct ieee80211_softmac_stats { - uint rx_ass_ok; - uint rx_ass_err; - uint rx_probe_rq; - uint tx_probe_rs; - uint tx_beacons; - uint rx_auth_rq; - uint rx_auth_rs_ok; - uint rx_auth_rs_err; - uint tx_auth_rq; - uint no_auth_rs; - uint no_ass_rs; - uint tx_ass_rq; - uint rx_ass_rq; - uint tx_probe_rq; - uint reassoc; - uint swtxstop; - uint swtxawake; -}; - -#define SEC_KEY_1 BIT(0) -#define SEC_KEY_2 BIT(1) -#define SEC_KEY_3 BIT(2) -#define SEC_KEY_4 BIT(3) -#define SEC_ACTIVE_KEY BIT(4) -#define SEC_AUTH_MODE BIT(5) -#define SEC_UNICAST_GROUP BIT(6) -#define SEC_LEVEL BIT(7) -#define SEC_ENABLED BIT(8) - -#define SEC_LEVEL_0 0 /* None */ -#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ -#define SEC_LEVEL_2 2 /* Level 1 + TKIP */ -#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ -#define SEC_LEVEL_3 4 /* Level 2 + CCMP */ - #define WEP_KEYS 4 -#define WEP_KEY_LEN 13 - -struct ieee80211_security { - u16 active_key:2, - enabled:1, - auth_mode:2, - auth_algo:4, - unicast_uses_group:1; - u8 key_sizes[WEP_KEYS]; - u8 keys[WEP_KEYS][WEP_KEY_LEN]; - u8 level; - u16 flags; -} __packed; - -/* - * - * 802.11 data frame from AP - * - * ,-------------------------------------------------------------------. - * Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | - * |------|------|---------|---------|---------|------|---------|------| - * Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | - * | | tion | (BSSID) | | | ence | data | | - * `-------------------------------------------------------------------' - * - * Total: 28-2340 bytes - * - */ - -struct ieee80211_header_data { - __le16 frame_ctl; - __le16 duration_id; - u8 addr1[6]; - u8 addr2[6]; - u8 addr3[6]; - __le16 seq_ctrl; -} __packed __aligned(2); -#define BEACON_PROBE_SSID_ID_POSITION 12 - -/* Management Frame Information Element Types */ -#define MFIE_TYPE_SSID 0 -#define MFIE_TYPE_RATES 1 -#define MFIE_TYPE_FH_SET 2 -#define MFIE_TYPE_DS_SET 3 -#define MFIE_TYPE_CF_SET 4 -#define MFIE_TYPE_TIM 5 -#define MFIE_TYPE_IBSS_SET 6 -#define MFIE_TYPE_CHALLENGE 16 -#define MFIE_TYPE_ERP 42 -#define MFIE_TYPE_RSN 48 -#define MFIE_TYPE_RATES_EX 50 -#define MFIE_TYPE_GENERIC 221 - -struct ieee80211_info_element_hdr { - u8 id; - u8 len; -} __packed; - -struct ieee80211_info_element { - u8 id; - u8 len; - u8 data[]; -} __packed; - -/* - * These are the data types that can make up management packets - * - __le16 auth_algorithm; - __le16 auth_sequence; - __le16 beacon_interval; - __le16 capability; - u8 current_ap[ETH_ALEN]; - __le16 listen_interval; - struct { - u16 association_id:14, reserved:2; - } __packed; - __le32 time_stamp[2]; - __le16 reason; - __le16 status; -*/ - -#define IEEE80211_DEFAULT_TX_ESSID "Penguin" -#define IEEE80211_DEFAULT_BASIC_RATE 10 - -struct ieee80211_authentication { - struct ieee80211_header_data header; - __le16 algorithm; - __le16 transaction; - __le16 status; -} __packed; - -struct ieee80211_probe_response { - struct ieee80211_header_data header; - __le32 time_stamp[2]; - __le16 beacon_interval; - __le16 capability; - struct ieee80211_info_element info_element; -} __packed; - -struct ieee80211_probe_request { - struct ieee80211_header_data header; -} __packed; - -struct ieee80211_assoc_request_frame { - struct ieee80211_hdr_3addr header; - __le16 capability; - __le16 listen_interval; - struct ieee80211_info_element_hdr info_element; -} __packed; - -struct ieee80211_assoc_response_frame { - struct ieee80211_hdr_3addr header; - __le16 capability; - __le16 status; - __le16 aid; -} __packed; - -struct ieee80211_txb { - u8 nr_frags; - u8 encrypted; - u16 reserved; - u16 frag_size; - u16 payload_size; - struct sk_buff *fragments[]; -}; - -/* SWEEP TABLE ENTRIES NUMBER*/ -#define MAX_SWEEP_TAB_ENTRIES 42 -#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs * only use 8, and then use extended rates for the remaining supported * rates. Other APs, however, stick all of their supported rates on the * main rates information element... */ #define MAX_RATES_LENGTH ((u8)12) -#define MAX_RATES_EX_LENGTH ((u8)16) -#define MAX_NETWORK_COUNT 128 -#define MAX_CHANNEL_NUMBER 161 -#define IEEE80211_SOFTMAC_SCAN_TIME 400 -/*(HZ / 2)*/ -#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) - -#define CRC_LENGTH 4U - #define MAX_WPA_IE_LEN 128 -#define NETWORK_EMPTY_ESSID BIT(0) -#define NETWORK_HAS_OFDM BIT(1) -#define NETWORK_HAS_CCK BIT(2) - -#define IEEE80211_DTIM_MBCAST 4 -#define IEEE80211_DTIM_UCAST 2 -#define IEEE80211_DTIM_VALID 1 -#define IEEE80211_DTIM_INVALID 0 - -#define IEEE80211_PS_DISABLED 0 -#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST -#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST -#define IW_ESSID_MAX_SIZE 32 -/* - * join_res: - * -1: authentication fail - * -2: association fail - * > 0: TID - */ - -enum ieee80211_state { - /* the card is not linked at all */ - IEEE80211_NOLINK = 0, - /* IEEE80211_ASSOCIATING* are for BSS client mode - * the driver shall not perform RX filtering unless - * the state is LINKED. - * The driver shall just check for the state LINKED and - * defaults to NOLINK for ALL the other states (including - * LINKED_SCANNING) - */ - /* the association procedure will start (wq scheduling)*/ - IEEE80211_ASSOCIATING, - IEEE80211_ASSOCIATING_RETRY, - /* the association procedure is sending AUTH request*/ - IEEE80211_ASSOCIATING_AUTHENTICATING, - /* the association procedure has successfully authenticated - * and is sending association request - */ - IEEE80211_ASSOCIATING_AUTHENTICATED, - /* the link is ok. the card associated to a BSS or linked - * to a ibss cell or acting as an AP and creating the bss - */ - IEEE80211_LINKED, - /* same as LINKED, but the driver shall apply RX filter - * rules as we are in NO_LINK mode. As the card is still - * logically linked, but it is doing a syncro site survey - * then it will be back to LINKED state. - */ - IEEE80211_LINKED_SCANNING, -}; - -#define DEFAULT_MAX_SCAN_AGE (15 * HZ) -#define DEFAULT_FTS 2346 - -#define CFG_IEEE80211_RESERVE_FCS BIT(0) -#define CFG_IEEE80211_COMPUTE_FCS BIT(1) - -#define MAXTID 16 - -#define IEEE_A BIT(0) -#define IEEE_B BIT(1) -#define IEEE_G BIT(2) -#define IEEE_MODE_MASK (IEEE_A | IEEE_B | IEEE_G) - -static inline int ieee80211_is_empty_essid(const char *essid, int essid_len) -{ - /* Single white space is for Linksys APs */ - if (essid_len == 1 && essid[0] == ' ') - return 1; - /* Otherwise, if the entire essid is 0, we assume it is hidden */ - while (essid_len) { - essid_len--; - if (essid[essid_len] != '\0') - return 0; - } - return 1; -} - -static inline int ieee80211_get_hdrlen(u16 fc) -{ - int hdrlen = 24; - - switch (WLAN_FC_GET_TYPE(fc)) { - case IEEE80211_FTYPE_DATA: - if (fc & IEEE80211_QOS_DATAGRP) - hdrlen += 2; - if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) - hdrlen += 6; /* Addr4 */ - break; - case IEEE80211_FTYPE_CTL: - switch (WLAN_FC_GET_STYPE(fc)) { - case IEEE80211_STYPE_CTS: - case IEEE80211_STYPE_ACK: - hdrlen = 10; - break; - default: - hdrlen = 16; - break; - } - break; - } - return hdrlen; -} - struct registry_priv; u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen); diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index 116773943a2e..fe6694f4d5e4 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -18,6 +18,7 @@ #include #include +#include #include "osdep_service.h" #include "drv_types.h" @@ -27,12 +28,6 @@ #include "usb_ops.h" #include "wifi.h" -/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ -static u8 bridge_tunnel_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8}; - -/* Ethernet-II snap header (RFC1042 for most EtherTypes) */ -static u8 rfc1042_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; - static void recv_tasklet(unsigned long priv); void r8712_init_recv_priv(struct recv_priv *precvpriv, diff --git a/drivers/staging/rtl8712/rtl871x_ht.h b/drivers/staging/rtl8712/rtl871x_ht.h index ebd78665775d..4bcf5591c44d 100644 --- a/drivers/staging/rtl8712/rtl871x_ht.h +++ b/drivers/staging/rtl8712/rtl871x_ht.h @@ -26,7 +26,7 @@ struct ht_priv { unsigned int rx_ampdu_maxlen; /* for rx reordering ctrl win_sz, * updated when join_callback. */ - struct ieee80211_ht_cap ht_cap; + struct rtl_ieee80211_ht_cap ht_cap; }; #endif /*_RTL871X_HT_H_ */ diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 363b82e3e7c6..36c89cde525d 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -211,11 +211,10 @@ static char *translate_scan(struct _adapter *padapter, char *start, char *stop) { struct iw_event iwe; - struct ieee80211_ht_cap *pht_capie; char *current_val; s8 *p; u32 i = 0, ht_ielen = 0; - u16 cap, ht_cap = false, mcs_rate; + u16 cap, ht_cap = false; u8 rssi; if ((pnetwork->network.Configuration.DSConfig < 1) || @@ -241,8 +240,6 @@ static char *translate_scan(struct _adapter *padapter, &ht_ielen, pnetwork->network.IELength - 12); if (p && ht_ielen > 0) { ht_cap = true; - pht_capie = (struct ieee80211_ht_cap *)(p + 2); - memcpy(&mcs_rate, pht_capie->supp_mcs_set, 2); } /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; @@ -268,8 +265,8 @@ static char *translate_scan(struct _adapter *padapter, memcpy((u8 *)&cap, r8712_get_capability_from_ie(pnetwork->network.IEs), 2); le16_to_cpus(&cap); - if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_BSS)) { - if (cap & WLAN_CAPABILITY_BSS) + if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_ESS)) { + if (cap & WLAN_CAPABILITY_ESS) iwe.u.mode = (u32)IW_MODE_MASTER; else iwe.u.mode = (u32)IW_MODE_ADHOC; @@ -1395,7 +1392,7 @@ static int r8711_wx_get_rate(struct net_device *dev, struct _adapter *padapter = netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - struct ieee80211_ht_cap *pht_capie; + struct rtl_ieee80211_ht_cap *pht_capie; unsigned char rf_type = padapter->registrypriv.rf_config; int i; u8 *p; @@ -1411,7 +1408,7 @@ static int r8711_wx_get_rate(struct net_device *dev, pcur_bss->IELength - 12); if (p && ht_ielen > 0) { ht_cap = true; - pht_capie = (struct ieee80211_ht_cap *)(p + 2); + pht_capie = (struct rtl_ieee80211_ht_cap *)(p + 2); memcpy(&mcs_rate, pht_capie->supp_mcs_set, 2); bw_40MHz = (le16_to_cpu(pht_capie->cap_info) & IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0; diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index cabdb3549a5a..efd75add8e35 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -249,8 +249,8 @@ static int is_same_network(struct wlan_bssid_ex *src, src->Ssid.SsidLength))) && ((s_cap & WLAN_CAPABILITY_IBSS) == (d_cap & WLAN_CAPABILITY_IBSS)) && - ((s_cap & WLAN_CAPABILITY_BSS) == - (d_cap & WLAN_CAPABILITY_BSS)); + ((s_cap & WLAN_CAPABILITY_ESS) == + (d_cap & WLAN_CAPABILITY_ESS)); } @@ -1643,7 +1643,7 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie, { u32 ielen, out_len; unsigned char *p; - struct ieee80211_ht_cap ht_capie; + struct rtl_ieee80211_ht_cap ht_capie; unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct qos_priv *pqospriv = &pmlmepriv->qospriv; @@ -1659,7 +1659,7 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie, pqospriv->qos_option = 1; } out_len = *pout_len; - memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap)); + memset(&ht_capie, 0, sizeof(struct rtl_ieee80211_ht_cap)); ht_capie.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | @@ -1669,7 +1669,7 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie, ht_capie.ampdu_params_info = (IEEE80211_HT_CAP_AMPDU_FACTOR & 0x03) | (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00); r8712_set_ie(out_ie + out_len, _HT_CAPABILITY_IE_, - sizeof(struct ieee80211_ht_cap), + sizeof(struct rtl_ieee80211_ht_cap), (unsigned char *)&ht_capie, pout_len); phtpriv->ht_option = 1; } @@ -1683,7 +1683,7 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len) int i; uint len; struct sta_info *bmc_sta, *psta; - struct ieee80211_ht_cap *pht_capie; + struct rtl_ieee80211_ht_cap *pht_capie; struct recv_reorder_ctrl *preorder_ctrl; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; @@ -1703,7 +1703,7 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len) &len, ie_len - sizeof(struct NDIS_802_11_FIXED_IEs)); if (p && len > 0) { - pht_capie = (struct ieee80211_ht_cap *)(p + 2); + pht_capie = (struct rtl_ieee80211_ht_cap *)(p + 2); max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_CAP_AMPDU_FACTOR); /* max_ampdu_sz (kbytes); */ diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c index e5092b6da4bd..c1bfd61824ef 100644 --- a/drivers/staging/rtl8712/rtl871x_recv.c +++ b/drivers/staging/rtl8712/rtl871x_recv.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "osdep_service.h" #include "drv_types.h" @@ -35,12 +36,6 @@ static const u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37}; /* Datagram Delivery Protocol */ static const u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3}; -/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ -static const u8 bridge_tunnel_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8}; - -/* Ethernet-II snap header (RFC1042 for most EtherTypes) */ -static const u8 rfc1042_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; - void _r8712_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) { memset((u8 *)psta_recvpriv, 0, sizeof(struct sta_recv_priv)); diff --git a/drivers/staging/rtl8712/rtl871x_recv.h b/drivers/staging/rtl8712/rtl871x_recv.h index e93f356ed2b0..e83c256e1474 100644 --- a/drivers/staging/rtl8712/rtl871x_recv.h +++ b/drivers/staging/rtl8712/rtl871x_recv.h @@ -12,8 +12,6 @@ #define MAX_SUBFRAME_COUNT 64 -#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) - /* for Rx reordering buffer control */ struct recv_reorder_ctrl { struct _adapter *padapter; diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c index 2f0d0ffa6fae..8b88fd5dc9a1 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.c +++ b/drivers/staging/rtl8712/rtl871x_xmit.c @@ -476,7 +476,7 @@ static int make_wlanhdr(struct _adapter *padapter, u8 *hdr, struct ieee80211_hdr *pwlanhdr = (struct ieee80211_hdr *)hdr; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct qos_priv *pqospriv = &pmlmepriv->qospriv; - __le16 *fctrl = &pwlanhdr->frame_ctl; + __le16 *fctrl = &pwlanhdr->frame_control; u8 *bssid; memset(hdr, 0, WLANHDR_OFFSET); diff --git a/drivers/staging/rtl8712/wifi.h b/drivers/staging/rtl8712/wifi.h index 91b65731fcaa..befb2f9b40ad 100644 --- a/drivers/staging/rtl8712/wifi.h +++ b/drivers/staging/rtl8712/wifi.h @@ -451,33 +451,18 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe) #define GetOrderBit(pbuf) (((*(__le16 *)(pbuf)) & \ le16_to_cpu(_ORDER_)) != 0) -/** - * struct ieee80211_bar - HT Block Ack Request - * - * This structure refers to "HT BlockAckReq" as - * described in 802.11n draft section 7.2.1.7.1 - */ -struct ieee80211_bar { - __le16 frame_control; - __le16 duration; - unsigned char ra[6]; - unsigned char ta[6]; - __le16 control; - __le16 start_seq_num; -} __packed; - /* 802.11 BAR control masks */ #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000 #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004 /* - * struct ieee80211_ht_cap - HT capabilities + * struct rtl_ieee80211_ht_cap - HT capabilities * * This structure refers to "HT capabilities element" as * described in 802.11n draft section 7.3.2.52 */ -struct ieee80211_ht_cap { +struct rtl_ieee80211_ht_cap { __le16 cap_info; unsigned char ampdu_params_info; unsigned char supp_mcs_set[16]; @@ -487,7 +472,7 @@ struct ieee80211_ht_cap { } __packed; /** - * struct ieee80211_ht_cap - HT additional information + * struct ieee80211_ht_addt_info - HT additional information * * This structure refers to "HT information element" as * described in 802.11n draft section 7.3.2.53 -- cgit v1.2.3-58-ga151 From 98fe05e21a6e0ca242e974650ed58b64813cb2dc Mon Sep 17 00:00:00 2001 From: Sebastian Arriola Date: Mon, 15 Jun 2020 09:51:31 -0600 Subject: staging: rtl8712: Remove unnecesary else after return statement. This patch fixes the checkpatch.pl warning: WARNING: else is not generally useful after a break or return 490: FILE: drivers/staging/rtl8712/rtl8712_recv.c:490: return false; else Signed-off-by: Sebastian Arriola Link: https://lore.kernel.org/r/20200615155131.GA4563@sevic69 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_recv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index fe6694f4d5e4..0bb49bcb9f1a 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -482,8 +482,7 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, plist = plist->next; else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) return false; - else - break; + break; } list_del_init(&(prframe->u.hdr.list)); list_add_tail(&(prframe->u.hdr.list), plist); -- cgit v1.2.3-58-ga151 From 5631feed3932b062bd8a576c8deff666ccf1fb74 Mon Sep 17 00:00:00 2001 From: Souptick Joarder Date: Wed, 17 Jun 2020 08:15:30 +0530 Subject: staging: gasket: Convert get_user_pages*() --> pin_user_pages*() In 2019, we introduced pin_user_pages*() and now we are converting get_user_pages*() to the new API as appropriate. [1] & [2] could be referred for more information. [1] Documentation/core-api/pin_user_pages.rst [2] "Explicit pinning of user-space pages": https://lwn.net/Articles/807108/ Signed-off-by: Souptick Joarder Acked-by: Dan Carpenter Cc: John Hubbard Cc: Dan Carpenter Link: https://lore.kernel.org/r/1592361930-3813-1-git-send-email-jrdr.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index f3dbe0fe2a67..6f6273c83822 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -449,7 +449,7 @@ static bool gasket_release_page(struct page *page) if (!PageReserved(page)) SetPageDirty(page); - put_page(page); + unpin_user_page(page); return true; } @@ -486,12 +486,12 @@ static int gasket_perform_mapping(struct gasket_page_table *pg_tbl, ptes[i].dma_addr = pg_tbl->coherent_pages[0].paddr + off + i * PAGE_SIZE; } else { - ret = get_user_pages_fast(page_addr - offset, 1, + ret = pin_user_pages_fast(page_addr - offset, 1, FOLL_WRITE, &page); if (ret <= 0) { dev_err(pg_tbl->device, - "get user pages failed for addr=0x%lx, offset=0x%lx [ret=%d]\n", + "pin user pages failed for addr=0x%lx, offset=0x%lx [ret=%d]\n", page_addr, offset, ret); return ret ? ret : -ENOMEM; } -- cgit v1.2.3-58-ga151 From 76cd0c7cc20f3ca71f1be38bfc0c9d3c0807e7ca Mon Sep 17 00:00:00 2001 From: Divyansh Kamboj Date: Fri, 5 Jun 2020 08:51:40 +0530 Subject: Staging: comedi: Added blank lines to fix coding style issue Fixed a coding style issue by adding a blank line after declarations Signed-off-by: Divyansh Kamboj Link: https://lore.kernel.org/r/20200605032140.31287-1-kambojdivyansh2000@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index e85a99b68f31..3f70e5dfac39 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2169,6 +2169,7 @@ static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, break; case COMEDI_CHANINFO: { struct comedi_chaninfo it; + if (copy_from_user(&it, (void __user *)arg, sizeof(it))) rc = -EFAULT; else @@ -2177,6 +2178,7 @@ static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, } case COMEDI_RANGEINFO: { struct comedi_rangeinfo it; + if (copy_from_user(&it, (void __user *)arg, sizeof(it))) rc = -EFAULT; else @@ -2249,6 +2251,7 @@ static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, } case COMEDI_INSN: { struct comedi_insn insn; + if (copy_from_user(&insn, (void __user *)arg, sizeof(insn))) rc = -EFAULT; else -- cgit v1.2.3-58-ga151 From 6655a352aca139778f507d50440b4ddcfe90555c Mon Sep 17 00:00:00 2001 From: Garrit Franke Date: Mon, 15 Jun 2020 15:55:41 +0200 Subject: staging: comedi: fix up missing whitespace in comment I noticed this missing whitespace in a comment inside ni_mio_common.c Signed-off-by: Garrit Franke Link: https://lore.kernel.org/r/20200615135541.46986-1-garritfranke@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index d99f4065b96d..9266e13f6271 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -2390,7 +2390,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) #endif break; case AIMODE_SAMPLE: - /*generate FIFO interrupts on non-empty */ + /* generate FIFO interrupts on non-empty */ ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_NE, NISTC_AI_MODE3_REG); break; -- cgit v1.2.3-58-ga151 From c5a3b1db6af24b9c9a3ea0b027a1d71c171b545d Mon Sep 17 00:00:00 2001 From: Jil Rouceau Date: Mon, 1 Jun 2020 12:44:16 +0200 Subject: staging: qlge: qlge_main.c: fixed spaces coding style issues Fixed the missing spaces before and after binary operators. Signed-off-by: Jil Rouceau Link: https://lore.kernel.org/r/20200601104416.102566-1-jilrouceau@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 402edaeffe12..1650de13842f 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -687,7 +687,7 @@ static int ql_get_8000_flash_params(struct ql_adapter *qdev) size = sizeof(struct flash_params_8000) / sizeof(u32); for (i = 0; i < size; i++, p++) { - status = ql_read_flash_word(qdev, i+offset, p); + status = ql_read_flash_word(qdev, i + offset, p); if (status) { netif_err(qdev, ifup, qdev->ndev, "Error reading flash.\n"); @@ -750,7 +750,7 @@ static int ql_get_8012_flash_params(struct ql_adapter *qdev) return -ETIMEDOUT; for (i = 0; i < size; i++, p++) { - status = ql_read_flash_word(qdev, i+offset, p); + status = ql_read_flash_word(qdev, i + offset, p); if (status) { netif_err(qdev, ifup, qdev->ndev, "Error reading flash.\n"); @@ -1528,7 +1528,7 @@ static void ql_process_mac_rx_page(struct ql_adapter *qdev, struct iphdr *iph = (struct iphdr *)((u8 *)addr + hlen); if (!(iph->frag_off & - htons(IP_MF|IP_OFFSET))) { + htons(IP_MF | IP_OFFSET))) { skb->ip_summed = CHECKSUM_UNNECESSARY; netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, @@ -1635,7 +1635,7 @@ static void ql_process_mac_rx_skb(struct ql_adapter *qdev, struct iphdr *iph = (struct iphdr *)skb->data; if (!(iph->frag_off & - htons(IP_MF|IP_OFFSET))) { + htons(IP_MF | IP_OFFSET))) { skb->ip_summed = CHECKSUM_UNNECESSARY; netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, @@ -1924,7 +1924,7 @@ static void ql_process_mac_split_rx_intr(struct ql_adapter *qdev, struct iphdr *iph = (struct iphdr *)skb->data; if (!(iph->frag_off & - htons(IP_MF|IP_OFFSET))) { + htons(IP_MF | IP_OFFSET))) { skb->ip_summed = CHECKSUM_UNNECESSARY; netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, "TCP checksum done!\n"); @@ -4547,7 +4547,7 @@ static void ql_timer(struct timer_list *t) return; } - mod_timer(&qdev->timer, jiffies + (5*HZ)); + mod_timer(&qdev->timer, jiffies + (5 * HZ)); } static int qlge_probe(struct pci_dev *pdev, @@ -4619,7 +4619,7 @@ static int qlge_probe(struct pci_dev *pdev, * the bus goes dead */ timer_setup(&qdev->timer, ql_timer, TIMER_DEFERRABLE); - mod_timer(&qdev->timer, jiffies + (5*HZ)); + mod_timer(&qdev->timer, jiffies + (5 * HZ)); ql_link_off(qdev); ql_display_dev_info(ndev); atomic_set(&qdev->lb_count, 0); @@ -4753,7 +4753,7 @@ static void qlge_io_resume(struct pci_dev *pdev) netif_err(qdev, ifup, qdev->ndev, "Device was not running prior to EEH.\n"); } - mod_timer(&qdev->timer, jiffies + (5*HZ)); + mod_timer(&qdev->timer, jiffies + (5 * HZ)); netif_device_attach(ndev); } @@ -4815,7 +4815,7 @@ static int qlge_resume(struct pci_dev *pdev) return err; } - mod_timer(&qdev->timer, jiffies + (5*HZ)); + mod_timer(&qdev->timer, jiffies + (5 * HZ)); netif_device_attach(ndev); return 0; -- cgit v1.2.3-58-ga151 From aeb4ac7916ce6120e764303b50917c7a2b8b0eba Mon Sep 17 00:00:00 2001 From: Souptick Joarder Date: Wed, 3 Jun 2020 00:24:17 +0530 Subject: staging: vc04_services: Convert get_user_pages*() --> pin_user_pages*() In 2019, we introduced pin_user_pages*() and now we are converting get_user_pages*() to the new API as appropriate. [1] & [2] could be referred for more information. [1] Documentation/core-api/pin_user_pages.rst [2] "Explicit pinning of user-space pages": https://lwn.net/Articles/807108/ Signed-off-by: Souptick Joarder Cc: John Hubbard Link: https://lore.kernel.org/r/1591124057-27696-1-git-send-email-jrdr.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 38a13e4618a8..46160139933e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -287,12 +287,8 @@ cleanup_pagelistinfo(struct vchiq_pagelist_info *pagelistinfo) pagelistinfo->num_pages, pagelistinfo->dma_dir); } - if (pagelistinfo->pages_need_release) { - unsigned int i; - - for (i = 0; i < pagelistinfo->num_pages; i++) - put_page(pagelistinfo->pages[i]); - } + if (pagelistinfo->pages_need_release) + unpin_user_pages(pagelistinfo->pages, pagelistinfo->num_pages); dma_free_coherent(g_dev, pagelistinfo->pagelist_buffer_size, pagelistinfo->pagelist, pagelistinfo->dma_addr); @@ -395,7 +391,7 @@ create_pagelist(char __user *buf, size_t count, unsigned short type) } /* do not try and release vmalloc pages */ } else { - actual_pages = get_user_pages_fast( + actual_pages = pin_user_pages_fast( (unsigned long)buf & PAGE_MASK, num_pages, type == PAGELIST_READ, @@ -407,10 +403,8 @@ create_pagelist(char __user *buf, size_t count, unsigned short type) __func__, actual_pages, num_pages); /* This is probably due to the process being killed */ - while (actual_pages > 0) { - actual_pages--; - put_page(pages[actual_pages]); - } + if (actual_pages > 0) + unpin_user_pages(pages, actual_pages); cleanup_pagelistinfo(pagelistinfo); return NULL; } -- cgit v1.2.3-58-ga151 From 21b1f2b3fb2e24cdfe8430acc8c8d2dc10f40225 Mon Sep 17 00:00:00 2001 From: Ivan Safonov Date: Sun, 31 May 2020 21:17:52 +0300 Subject: staging:r8723bs: remove wrappers around skb_clone() and remove unnecessary in_interrupt() call Wrappers around skb_clone() do not simplify the driver code. The skb_clone() is always called from an interrupt handler, so use GFP_ATOMIC allocation only. Signed-off-by: Ivan Safonov Link: https://lore.kernel.org/r/20200531181751.41830-1-insafonov@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/osdep_service.h | 3 --- drivers/staging/rtl8723bs/os_dep/osdep_service.c | 5 ----- drivers/staging/rtl8723bs/os_dep/recv_linux.c | 2 +- 3 files changed, 1 insertion(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h b/drivers/staging/rtl8723bs/include/osdep_service.h index 5f681899bbec..be34e279670b 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service.h +++ b/drivers/staging/rtl8723bs/include/osdep_service.h @@ -94,7 +94,6 @@ void _kfree(u8 *pbuf, u32 sz); struct sk_buff *_rtw_skb_alloc(u32 sz); struct sk_buff *_rtw_skb_copy(const struct sk_buff *skb); -struct sk_buff *_rtw_skb_clone(struct sk_buff *skb); int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb); #define rtw_malloc(sz) _rtw_malloc((sz)) @@ -103,9 +102,7 @@ int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb); #define rtw_skb_alloc(size) _rtw_skb_alloc((size)) #define rtw_skb_alloc_f(size, mstat_f) _rtw_skb_alloc((size)) #define rtw_skb_copy(skb) _rtw_skb_copy((skb)) -#define rtw_skb_clone(skb) _rtw_skb_clone((skb)) #define rtw_skb_copy_f(skb, mstat_f) _rtw_skb_copy((skb)) -#define rtw_skb_clone_f(skb, mstat_f) _rtw_skb_clone((skb)) #define rtw_netif_rx(ndev, skb) _rtw_netif_rx(ndev, skb) extern void _rtw_init_queue(struct __queue *pqueue); diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c index 4238209ec175..6d443197a0cf 100644 --- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c @@ -47,11 +47,6 @@ inline struct sk_buff *_rtw_skb_copy(const struct sk_buff *skb) return skb_copy(skb, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); } -inline struct sk_buff *_rtw_skb_clone(struct sk_buff *skb) -{ - return skb_clone(skb, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); -} - inline int _rtw_netif_rx(_nic_hdl ndev, struct sk_buff *skb) { skb->dev = ndev; diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c index eb4d1c3008fe..b2a1bbb30df6 100644 --- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c @@ -110,7 +110,7 @@ void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), ETH_ALEN)) { if (bmcast) { psta = rtw_get_bcmc_stainfo(padapter); - pskb2 = rtw_skb_clone(pkt); + pskb2 = skb_clone(pkt, GFP_ATOMIC); } else { psta = rtw_get_stainfo(pstapriv, pattrib->dst); } -- cgit v1.2.3-58-ga151 From 9e43eed45a48042573a5f3f27ccc15f8f9bb42e0 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 16 Jun 2020 12:55:43 -0500 Subject: staging: rts5208: Use array_size() helper in vmalloc() and memset() The vmalloc() function has no 2-factor argument form, so multiplication factors need to be wrapped in array_size(). Also, while there, use array_size() in memset(). This issue was found with the help of Coccinelle and, audited and fixed manually. Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83 Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200616175543.GA28687@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/ms.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rts5208/ms.c b/drivers/staging/rts5208/ms.c index d53dd138a356..9001570a8c94 100644 --- a/drivers/staging/rts5208/ms.c +++ b/drivers/staging/rts5208/ms.c @@ -2306,14 +2306,14 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no) if (!segment->l2p_table) goto BUILD_FAIL; } - memset((u8 *)(segment->l2p_table), 0xff, table_size * 2); + memset((u8 *)(segment->l2p_table), 0xff, array_size(table_size, 2)); if (!segment->free_table) { - segment->free_table = vmalloc(MS_FREE_TABLE_CNT * 2); + segment->free_table = vmalloc(array_size(MS_FREE_TABLE_CNT, 2)); if (!segment->free_table) goto BUILD_FAIL; } - memset((u8 *)(segment->free_table), 0xff, MS_FREE_TABLE_CNT * 2); + memset((u8 *)(segment->free_table), 0xff, array_size(MS_FREE_TABLE_CNT, 2)); start = (u16)seg_no << 9; end = (u16)(seg_no + 1) << 9; -- cgit v1.2.3-58-ga151 From 9bea6eb3f59cb2fad8b46d91c666a17d0aa53456 Mon Sep 17 00:00:00 2001 From: Ivan Safonov Date: Sun, 31 May 2020 14:05:47 +0300 Subject: staging:rtl8712: avoid skb_clone after skb allocation fail The skb allocated when out of memory is likely to be discarded during subsequent processing. Signed-off-by: Ivan Safonov Link: https://lore.kernel.org/r/20200531110548.9318-1-insafonov@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_recv.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index 0bb49bcb9f1a..c513cda2a49e 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -1031,24 +1031,17 @@ static void recvbuf2recvframe(struct _adapter *padapter, struct sk_buff *pskb) */ alloc_sz += 6; pkt_copy = netdev_alloc_skb(padapter->pnetdev, alloc_sz); - if (pkt_copy) { - precvframe->u.hdr.pkt = pkt_copy; - skb_reserve(pkt_copy, 4 - ((addr_t)(pkt_copy->data) - % 4)); - skb_reserve(pkt_copy, shift_sz); - memcpy(pkt_copy->data, pbuf, tmp_len); - precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_data = - precvframe->u.hdr.rx_tail = pkt_copy->data; - precvframe->u.hdr.rx_end = pkt_copy->data + alloc_sz; - } else { - precvframe->u.hdr.pkt = skb_clone(pskb, GFP_ATOMIC); - if (!precvframe->u.hdr.pkt) - return; - precvframe->u.hdr.rx_head = pbuf; - precvframe->u.hdr.rx_data = pbuf; - precvframe->u.hdr.rx_tail = pbuf; - precvframe->u.hdr.rx_end = pbuf + alloc_sz; - } + if (!pkt_copy) + return; + + precvframe->u.hdr.pkt = pkt_copy; + skb_reserve(pkt_copy, 4 - ((addr_t)(pkt_copy->data) % 4)); + skb_reserve(pkt_copy, shift_sz); + memcpy(pkt_copy->data, pbuf, tmp_len); + precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_data = + precvframe->u.hdr.rx_tail = pkt_copy->data; + precvframe->u.hdr.rx_end = pkt_copy->data + alloc_sz; + recvframe_put(precvframe, tmp_len); recvframe_pull(precvframe, drvinfo_sz + RXDESC_SIZE); /* because the endian issue, driver avoid reference to the -- cgit v1.2.3-58-ga151 From 4b95739222b85696e9cec98efff866ed876541f8 Mon Sep 17 00:00:00 2001 From: "Rodolfo C. Villordo" Date: Mon, 22 Jun 2020 07:36:12 +0000 Subject: staging: gasket: replace symbolic permissions WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. + .attr = __ATTR(_name, S_IRUGO, _show_function, NULL), \ warning detected by checkpatch.pl Unable to use __ATTR_RO(). Driver has multiple files using the same show function: $ grep GASKET_SYSFS_RO drivers/staging/gasket/* drivers/staging/gasket/apex_driver.c: GASKET_SYSFS_RO(node_0_page_table_entries, sysfs_show, drivers/staging/gasket/apex_driver.c: GASKET_SYSFS_RO(node_0_simple_page_table_entries, sysfs_show, drivers/staging/gasket/apex_driver.c: GASKET_SYSFS_RO(node_0_num_mapped_pages, sysfs_show, drivers/staging/gasket/gasket_core.c: GASKET_SYSFS_RO(bar_offsets, gasket_sysfs_data_show, ATTR_BAR_OFFSETS), drivers/staging/gasket/gasket_core.c: GASKET_SYSFS_RO(bar_sizes, gasket_sysfs_data_show, ATTR_BAR_SIZES), drivers/staging/gasket/gasket_core.c: GASKET_SYSFS_RO(driver_version, gasket_sysfs_data_show, drivers/staging/gasket/gasket_core.c: GASKET_SYSFS_RO(framework_version, gasket_sysfs_data_show, drivers/staging/gasket/gasket_core.c: GASKET_SYSFS_RO(device_type, gasket_sysfs_data_show, ATTR_DEVICE_TYPE), drivers/staging/gasket/gasket_core.c: GASKET_SYSFS_RO(revision, gasket_sysfs_data_show, drivers/staging/gasket/gasket_core.c: GASKET_SYSFS_RO(pci_address, gasket_sysfs_data_show, ATTR_PCI_ADDRESS), drivers/staging/gasket/gasket_core.c: GASKET_SYSFS_RO(status, gasket_sysfs_data_show, ATTR_STATUS), drivers/staging/gasket/gasket_core.c: GASKET_SYSFS_RO(is_device_owned, gasket_sysfs_data_show, drivers/staging/gasket/gasket_core.c: GASKET_SYSFS_RO(device_owner, gasket_sysfs_data_show, drivers/staging/gasket/gasket_core.c: GASKET_SYSFS_RO(write_open_count, gasket_sysfs_data_show, drivers/staging/gasket/gasket_core.c: GASKET_SYSFS_RO(reset_count, gasket_sysfs_data_show, ATTR_RESET_COUNT), drivers/staging/gasket/gasket_core.c: GASKET_SYSFS_RO(user_mem_ranges, gasket_sysfs_data_show, drivers/staging/gasket/gasket_interrupt.c: GASKET_SYSFS_RO(interrupt_counts, interrupt_sysfs_show, Signed-off-by: Rodolfo C. Villordo Link: https://lore.kernel.org/r/20200622073612.12282-1-rodolfovillordo@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_sysfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/gasket/gasket_sysfs.h b/drivers/staging/gasket/gasket_sysfs.h index ab5aa351d555..d5e167dfbe76 100644 --- a/drivers/staging/gasket/gasket_sysfs.h +++ b/drivers/staging/gasket/gasket_sysfs.h @@ -71,7 +71,7 @@ struct gasket_sysfs_attribute { #define GASKET_SYSFS_RO(_name, _show_function, _attr_type) \ { \ - .attr = __ATTR(_name, S_IRUGO, _show_function, NULL), \ + .attr = __ATTR(_name, 0444, _show_function, NULL), \ .data.attr_type = _attr_type \ } -- cgit v1.2.3-58-ga151 From c8a00029dc70d0c35e84d6f0ff99a534dfe636e6 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 19 Jun 2020 18:03:28 +0200 Subject: staging: rtl8188eu: use common packet header constants The driver replicates the definitions of rfc1042_header and bridge_tunnel_header available from cfg80211.h. Use the common ones from cfg80211.h. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200619160328.22776-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index a036ef104198..0257e56b551a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -15,6 +15,7 @@ #include #include #include +#include #define ETHERNET_HEADER_SIZE 14 /* Ethernet Header Length */ #define LLC_HEADER_SIZE 6 /* LLC Header Length */ @@ -22,15 +23,6 @@ static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37}; static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3}; -/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ -static u8 rtw_bridge_tunnel_header[] = { - 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 -}; - -static u8 rtw_rfc1042_header[] = { - 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 -}; - static void rtw_signal_stat_timer_hdl(struct timer_list *t); void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) @@ -1277,10 +1269,10 @@ static int wlanhdr_to_ethhdr(struct recv_frame *precvframe) psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen + pattrib->iv_len); psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE; /* convert hdr + possible LLC headers into Ethernet header */ - if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) && + if ((!memcmp(psnap, rfc1042_header, SNAP_SIZE) && memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) && memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2)) || - !memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) { + !memcmp(psnap, bridge_tunnel_header, SNAP_SIZE)) { /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */ bsnaphdr = true; } else { @@ -1560,9 +1552,9 @@ static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) /* convert hdr + possible LLC headers into Ethernet header */ eth_type = get_unaligned_be16(&sub_skb->data[6]); if (sub_skb->len >= 8 && - ((!memcmp(sub_skb->data, rtw_rfc1042_header, SNAP_SIZE) && + ((!memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) && eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || - !memcmp(sub_skb->data, rtw_bridge_tunnel_header, SNAP_SIZE))) { + !memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE))) { /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */ skb_pull(sub_skb, SNAP_SIZE); memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN); -- cgit v1.2.3-58-ga151 From 8ce8668bfb64f2973cc1276c54619aceede6498a Mon Sep 17 00:00:00 2001 From: Evgeny Novikov Date: Tue, 23 Jun 2020 11:29:59 +0300 Subject: staging: kpc2000: kpc_dma: set error code in probe If device_create() fails during probing the device, kpc_dma_probe() does not set the error code and returns 0. This can result in various bad issues later. The patch sets the error code on the corresponding error handling path. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Link: https://lore.kernel.org/r/20200623082959.14951-1-novikov@ispras.ru Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index c3b30551e0ca..624d47bae4d1 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -140,6 +140,7 @@ int kpc_dma_probe(struct platform_device *pldev) dev = MKDEV(assigned_major_num, pldev->id); ldev->kpc_dma_dev = device_create(kpc_dma_class, &pldev->dev, dev, ldev, "kpc_dma%d", pldev->id); if (IS_ERR(ldev->kpc_dma_dev)) { + rv = PTR_ERR(ldev->kpc_dma_dev); dev_err(&ldev->pldev->dev, "%s: device_create failed: %d\n", __func__, rv); goto err_kfree; } -- cgit v1.2.3-58-ga151 From 11507bf9a8832741db69efd32bf09a2ab26426bf Mon Sep 17 00:00:00 2001 From: Evgeny Novikov Date: Tue, 23 Jun 2020 17:12:30 +0300 Subject: staging: rts5208: fix memleaks on error handling paths in probe rtsx_probe() allocates host, but does not free it on error handling paths. The patch adds missed scsi_host_put(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Link: https://lore.kernel.org/r/20200623141230.7258-1-novikov@ispras.ru Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index be0053c795b7..937f4e732a75 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -972,6 +972,7 @@ ioremap_fail: kfree(dev->chip); chip_alloc_fail: dev_err(&pci->dev, "%s failed\n", __func__); + scsi_host_put(host); scsi_host_alloc_fail: pci_release_regions(pci); return err; -- cgit v1.2.3-58-ga151 From 79e88fd45bd26ea2770b79e70cfb824a4e2e7049 Mon Sep 17 00:00:00 2001 From: "Rodolfo C. Villordo" Date: Wed, 24 Jun 2020 10:02:56 +0000 Subject: drivers: staging: vt6655: replace CamelCase names on function s_uGetRTSCTSRsvTime Replace function and variables name from CamelCase style to snake_case style. Remove Hungarian notation. Signed-off-by: Rodolfo C. Villordo Link: https://lore.kernel.org/r/20200624100256.GA17118@ip-172-31-24-31.ec2.internal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rxtx.c | 80 ++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 42 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index cfab64d2b312..4778439e8757 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -21,7 +21,7 @@ * s_uGetDataDuration - get tx data required duration * s_uFillDataHead- fulfill tx data duration header * s_uGetRTSCTSDuration- get rtx/cts required duration - * s_uGetRTSCTSRsvTime- get rts/cts reserved time + * get_rtscts_time- get rts/cts reserved time * s_uGetTxRsvTime- get frame reserved time * s_vFillCTSHead- fulfill CTS ctl header * s_vFillFragParameter- Set fragment ctl parameter. @@ -190,45 +190,41 @@ static __le16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type, } /* byFreqType: 0=>5GHZ 1=>2.4GHZ */ -static -__le16 -s_uGetRTSCTSRsvTime( - struct vnt_private *pDevice, - unsigned char byRTSRsvType, - unsigned char byPktType, - unsigned int cbFrameLength, - unsigned short wCurrentRate -) +static __le16 get_rtscts_time(struct vnt_private *priv, + unsigned char rts_rsvtype, + unsigned char pkt_type, + unsigned int frame_length, + unsigned short current_rate) { - unsigned int uRrvTime = 0; - unsigned int uRTSTime = 0; - unsigned int uCTSTime = 0; - unsigned int uAckTime = 0; - unsigned int uDataTime = 0; - - uDataTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, cbFrameLength, wCurrentRate); - if (byRTSRsvType == 0) { /* RTSTxRrvTime_bb */ - uRTSTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate); - uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); - uCTSTime = uAckTime; - } else if (byRTSRsvType == 1) { /* RTSTxRrvTime_ba, only in 2.4GHZ */ - uRTSTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 20, pDevice->byTopCCKBasicRate); - uCTSTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); - uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); - } else if (byRTSRsvType == 2) { /* RTSTxRrvTime_aa */ - uRTSTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 20, pDevice->byTopOFDMBasicRate); - uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); - uCTSTime = uAckTime; - } else if (byRTSRsvType == 3) { /* CTSTxRrvTime_ba, only in 2.4GHZ */ - uCTSTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); - uAckTime = bb_get_frame_time(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); - uRrvTime = uCTSTime + uAckTime + uDataTime + 2 * pDevice->uSIFS; - return cpu_to_le16((u16)uRrvTime); + unsigned int rrv_time = 0; + unsigned int rts_time = 0; + unsigned int cts_time = 0; + unsigned int ack_time = 0; + unsigned int data_time = 0; + + data_time = bb_get_frame_time(priv->byPreambleType, pkt_type, frame_length, current_rate); + if (rts_rsvtype == 0) { /* RTSTxRrvTime_bb */ + rts_time = bb_get_frame_time(priv->byPreambleType, pkt_type, 20, priv->byTopCCKBasicRate); + ack_time = bb_get_frame_time(priv->byPreambleType, pkt_type, 14, priv->byTopCCKBasicRate); + cts_time = ack_time; + } else if (rts_rsvtype == 1) { /* RTSTxRrvTime_ba, only in 2.4GHZ */ + rts_time = bb_get_frame_time(priv->byPreambleType, pkt_type, 20, priv->byTopCCKBasicRate); + cts_time = bb_get_frame_time(priv->byPreambleType, pkt_type, 14, priv->byTopCCKBasicRate); + ack_time = bb_get_frame_time(priv->byPreambleType, pkt_type, 14, priv->byTopOFDMBasicRate); + } else if (rts_rsvtype == 2) { /* RTSTxRrvTime_aa */ + rts_time = bb_get_frame_time(priv->byPreambleType, pkt_type, 20, priv->byTopOFDMBasicRate); + ack_time = bb_get_frame_time(priv->byPreambleType, pkt_type, 14, priv->byTopOFDMBasicRate); + cts_time = ack_time; + } else if (rts_rsvtype == 3) { /* CTSTxRrvTime_ba, only in 2.4GHZ */ + cts_time = bb_get_frame_time(priv->byPreambleType, pkt_type, 14, priv->byTopCCKBasicRate); + ack_time = bb_get_frame_time(priv->byPreambleType, pkt_type, 14, priv->byTopOFDMBasicRate); + rrv_time = cts_time + ack_time + data_time + 2 * priv->uSIFS; + return cpu_to_le16((u16)rrv_time); } /* RTSRrvTime */ - uRrvTime = uRTSTime + uCTSTime + uAckTime + uDataTime + 3 * pDevice->uSIFS; - return cpu_to_le16((u16)uRrvTime); + rrv_time = rts_time + cts_time + ack_time + data_time + 3 * priv->uSIFS; + return cpu_to_le16((u16)rrv_time); } /* byFreqType 0: 5GHz, 1:2.4Ghz */ @@ -921,9 +917,9 @@ s_vGenerateTxParameter( /* Fill RsvTime */ struct vnt_rrv_time_rts *buf = pvRrvTime; - buf->rts_rrv_time_aa = s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate); - buf->rts_rrv_time_ba = s_uGetRTSCTSRsvTime(pDevice, 1, byPktType, cbFrameSize, wCurrentRate); - buf->rts_rrv_time_bb = s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate); + buf->rts_rrv_time_aa = get_rtscts_time(pDevice, 2, byPktType, cbFrameSize, wCurrentRate); + buf->rts_rrv_time_ba = get_rtscts_time(pDevice, 1, byPktType, cbFrameSize, wCurrentRate); + buf->rts_rrv_time_bb = get_rtscts_time(pDevice, 0, byPktType, cbFrameSize, wCurrentRate); buf->rrv_time_a = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK); buf->rrv_time_b = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK); @@ -933,7 +929,7 @@ s_vGenerateTxParameter( buf->rrv_time_a = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK); buf->rrv_time_b = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK); - buf->cts_rrv_time_ba = s_uGetRTSCTSRsvTime(pDevice, 3, byPktType, cbFrameSize, wCurrentRate); + buf->cts_rrv_time_ba = get_rtscts_time(pDevice, 3, byPktType, cbFrameSize, wCurrentRate); /* Fill CTS */ s_vFillCTSHead(pDevice, uDMAIdx, byPktType, pvCTS, cbFrameSize, bNeedACK, bDisCRC, wCurrentRate, byFBOption); @@ -942,7 +938,7 @@ s_vGenerateTxParameter( if (pvRTS) {/* RTS_need, non PCF mode */ struct vnt_rrv_time_ab *buf = pvRrvTime; - buf->rts_rrv_time = s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate); + buf->rts_rrv_time = get_rtscts_time(pDevice, 2, byPktType, cbFrameSize, wCurrentRate); buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK); /* Fill RTS */ @@ -956,7 +952,7 @@ s_vGenerateTxParameter( if (pvRTS) {/* RTS_need, non PCF mode */ struct vnt_rrv_time_ab *buf = pvRrvTime; - buf->rts_rrv_time = s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate); + buf->rts_rrv_time = get_rtscts_time(pDevice, 0, byPktType, cbFrameSize, wCurrentRate); buf->rrv_time = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK); /* Fill RTS */ -- cgit v1.2.3-58-ga151 From 8947979e8dbbc549a65355366b4cddc2c52bbb26 Mon Sep 17 00:00:00 2001 From: Peilin Ye Date: Wed, 24 Jun 2020 08:47:25 -0700 Subject: Staging: rtl8188eu: Fix alignment coding style issue Fix "Alignment should match open parenthesis" issues reported by checkpatch.pl for all files under drivers/staging/rtl8188eu/core. Line rtw_mlme_ext.c:373 is left overlength for readability. Signed-off-by: Peilin Ye Link: https://lore.kernel.org/r/1593013645-19130-1-git-send-email-yepeilin.cs@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 4 +-- drivers/staging/rtl8188eu/core/rtw_debug.c | 20 +++++------ drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 17 +++++----- drivers/staging/rtl8188eu/core/rtw_ioctl_set.c | 2 +- drivers/staging/rtl8188eu/core/rtw_mlme.c | 4 +-- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 46 ++++++++++++-------------- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 2 +- drivers/staging/rtl8188eu/core/rtw_recv.c | 8 ++--- 8 files changed, 50 insertions(+), 53 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index f69e9453ad45..a97d50081071 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -229,7 +229,7 @@ _next: * LOCKED pmlmepriv->lock */ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, int ssid_num, - struct rtw_ieee80211_channel *ch, int ch_num) + struct rtw_ieee80211_channel *ch, int ch_num) { u8 res = _FAIL; struct cmd_obj *ph2c; @@ -449,7 +449,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) (padapter->securitypriv.dot11PrivacyAlgrthm != _TKIP_)) { /* rtw_restructure_ht_ie */ rtw_restructure_ht_ie(padapter, &pnetwork->network.ies[0], &psecnetwork->ies[0], - pnetwork->network.ie_length, &psecnetwork->ie_length); + pnetwork->network.ie_length, &psecnetwork->ie_length); } } diff --git a/drivers/staging/rtl8188eu/core/rtw_debug.c b/drivers/staging/rtl8188eu/core/rtw_debug.c index d0e41f2ef1ce..fcc8bd1011e1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_debug.c +++ b/drivers/staging/rtl8188eu/core/rtw_debug.c @@ -10,8 +10,8 @@ #include int proc_get_drv_version(char *page, char **start, - off_t offset, int count, - int *eof, void *data) + off_t offset, int count, + int *eof, void *data) { int len = 0; @@ -22,15 +22,15 @@ int proc_get_drv_version(char *page, char **start, } int proc_get_write_reg(char *page, char **start, - off_t offset, int count, - int *eof, void *data) + off_t offset, int count, + int *eof, void *data) { *eof = 1; return 0; } int proc_set_write_reg(struct file *file, const char __user *buffer, - unsigned long count, void *data) + unsigned long count, void *data) { struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); @@ -71,8 +71,8 @@ static u32 proc_get_read_addr = 0xeeeeeeee; static u32 proc_get_read_len = 0x4; int proc_get_read_reg(char *page, char **start, - off_t offset, int count, - int *eof, void *data) + off_t offset, int count, + int *eof, void *data) { struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); @@ -104,7 +104,7 @@ int proc_get_read_reg(char *page, char **start, } int proc_set_read_reg(struct file *file, const char __user *buffer, - unsigned long count, void *data) + unsigned long count, void *data) { char tmp[16]; u32 addr, len; @@ -131,8 +131,8 @@ int proc_set_read_reg(struct file *file, const char __user *buffer, } int proc_get_adapter_state(char *page, char **start, - off_t offset, int count, - int *eof, void *data) + off_t offset, int count, + int *eof, void *data) { struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index caf600eba03b..5630d5d763db 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -675,8 +675,7 @@ u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 } static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, - struct rtw_ieee802_11_elems *elems, - int show_errors) + struct rtw_ieee802_11_elems *elems, int show_errors) { unsigned int oui; @@ -766,8 +765,8 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, * Returns: Parsing result */ enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len, - struct rtw_ieee802_11_elems *elems, - int show_errors) + struct rtw_ieee802_11_elems *elems, + int show_errors) { uint left = len; u8 *pos = start; @@ -921,8 +920,10 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; pnetwork->BcnInfo.group_cipher = group_cipher; pnetwork->BcnInfo.is_8021x = is8021x; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s: pnetwork->pairwise_cipher: %d, is_8021x is %d", - __func__, pnetwork->BcnInfo.pairwise_cipher, pnetwork->BcnInfo.is_8021x)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("%s: pnetwork->pairwise_cipher: %d, is_8021x is %d", + __func__, pnetwork->BcnInfo.pairwise_cipher, + pnetwork->BcnInfo.is_8021x)); ret = _SUCCESS; } } else { @@ -979,9 +980,9 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WEP; } RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: pnetwork->encryp_protocol is %x\n", - pnetwork->BcnInfo.encryp_protocol)); + pnetwork->BcnInfo.encryp_protocol)); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: pnetwork->encryp_protocol is %x\n", - pnetwork->BcnInfo.encryp_protocol)); + pnetwork->BcnInfo.encryp_protocol)); rtw_get_cipher_info(pnetwork); /* get bwmode and ch_offset */ diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index 7d56767cdff6..7bb26c362b10 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -306,7 +306,7 @@ exit: } u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, - enum ndis_802_11_network_infra networktype) + enum ndis_802_11_network_infra networktype) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 9de2d421f6b1..b291ee6ca8f4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -334,7 +334,7 @@ struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) } void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, - struct adapter *padapter, bool update_ie) + struct adapter *padapter, bool update_ie) { long rssi_ori = dst->Rssi; u8 sq_smp = src->PhyInfo.SignalQuality; @@ -646,7 +646,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) s_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv); if (s_ret == _SUCCESS) { mod_timer(&pmlmepriv->assoc_timer, - jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); + jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); } else if (s_ret == 2) { /* there is no need to wait for join */ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); rtw_indicate_connect(adapter); diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 8d035f67ef61..f6b9a39799ce 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -370,7 +370,7 @@ static void issue_beacon(struct adapter *padapter, int timeout_ms) pframe += (cur_network->ie_length + len_diff); pattrib->pktlen += (cur_network->ie_length + len_diff); wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr + TXDESC_OFFSET + sizeof(struct ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_, - pattrib->pktlen - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_, NULL, &wps_ielen); + pattrib->pktlen - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_, NULL, &wps_ielen); if (wps_ie && wps_ielen > 0) rtw_get_wps_attr_content(wps_ie, wps_ielen, WPS_ATTR_SELECTED_REGISTRAR, (u8 *)(&sr), NULL); if (sr != 0) @@ -1932,12 +1932,12 @@ static void site_survey(struct adapter *padapter) if (pmlmeext->sitesurvey_res.ssid[i].ssid_length) { /* todo: to issue two probe req??? */ issue_probereq(padapter, - &pmlmeext->sitesurvey_res.ssid[i], - NULL, false); + &pmlmeext->sitesurvey_res.ssid[i], + NULL, false); /* msleep(SURVEY_TO>>1); */ issue_probereq(padapter, - &pmlmeext->sitesurvey_res.ssid[i], - NULL, false); + &pmlmeext->sitesurvey_res.ssid[i], + NULL, false); } } @@ -2522,7 +2522,7 @@ static unsigned int OnProbeReq(struct adapter *padapter, return _SUCCESS; p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, &ielen, - len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); + len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); /* check (wildcard) SSID */ if (p) { @@ -2759,7 +2759,7 @@ static unsigned int OnAuth(struct adapter *padapter, DBG_88E("checking for challenging txt...\n"); p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, &ie_len, - len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4); + len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4); if (!p || ie_len <= 0) { DBG_88E("auth rejected because challenge failure!(1)\n"); @@ -2853,7 +2853,7 @@ static unsigned int OnAuthClient(struct adapter *padapter, if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { /* legendary shared system */ p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, &len, - pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_); + pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_); if (!p) goto authclnt_fail; @@ -2966,7 +2966,7 @@ static unsigned int OnAssocReq(struct adapter *padapter, /* now we should check all the fields... */ /* checking SSID */ p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SSID_IE_, &ie_len, - pkt_len - WLAN_HDR_A3_LEN - ie_offset); + pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (!p || ie_len == 0) { /* broadcast ssid, however it is not allowed in assocreq */ @@ -2999,7 +2999,7 @@ static unsigned int OnAssocReq(struct adapter *padapter, supportRateNum = ie_len; p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_, &ie_len, - pkt_len - WLAN_HDR_A3_LEN - ie_offset); + pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (p) { if (supportRateNum <= sizeof(supportRate)) { memcpy(supportRate + supportRateNum, @@ -3913,8 +3913,7 @@ static void init_mlme_ext_priv_value(struct adapter *padapter) } static int has_channel(struct rt_channel_info *channel_set, - u8 chanset_size, - u8 chan) + u8 chanset_size, u8 chan) { int i; @@ -4671,18 +4670,15 @@ void linked_status_chk(struct adapter *padapter) } else { if (rx_chk != _SUCCESS) { if (pmlmeext->retry == 0) { - issue_probereq(padapter, - &pmlmeinfo->network.ssid, - pmlmeinfo->network.MacAddress, - false); - issue_probereq(padapter, - &pmlmeinfo->network.ssid, - pmlmeinfo->network.MacAddress, - false); - issue_probereq(padapter, - &pmlmeinfo->network.ssid, - pmlmeinfo->network.MacAddress, - false); + issue_probereq(padapter, &pmlmeinfo->network.ssid, + pmlmeinfo->network.MacAddress, + false); + issue_probereq(padapter, &pmlmeinfo->network.ssid, + pmlmeinfo->network.MacAddress, + false); + issue_probereq(padapter, &pmlmeinfo->network.ssid, + pmlmeinfo->network.MacAddress, + false); } } @@ -5330,7 +5326,7 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) } ptxBeacon_parm = kmemdup(&pmlmeinfo->network, - sizeof(struct wlan_bssid_ex), GFP_ATOMIC); + sizeof(struct wlan_bssid_ex), GFP_ATOMIC); if (!ptxBeacon_parm) { kfree(ph2c); res = _FAIL; diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index c000382c96d9..e7777bf3bafb 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -264,7 +264,7 @@ static void pwr_state_check_handler(struct timer_list *t) { struct adapter *padapter = from_timer(padapter, t, - pwrctrlpriv.pwr_state_check_timer); + pwrctrlpriv.pwr_state_check_timer); rtw_ps_cmd(padapter); } diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 0257e56b551a..61ea8f38829c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -59,7 +59,7 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) INIT_LIST_HEAD(&precvframe->list); list_add_tail(&precvframe->list, - &precvpriv->free_recv_queue.queue); + &precvpriv->free_recv_queue.queue); precvframe->pkt = NULL; @@ -1184,21 +1184,21 @@ static int validate_recv_frame(struct adapter *adapter, if (_drv_err_ <= GlobalDebugLevel) { pr_info(DRIVER_PREFIX "#############################\n"); print_hex_dump(KERN_INFO, DRIVER_PREFIX, DUMP_PREFIX_NONE, - 16, 1, ptr, 64, false); + 16, 1, ptr, 64, false); pr_info(DRIVER_PREFIX "#############################\n"); } } else if (bDumpRxPkt == 2) { if ((_drv_err_ <= GlobalDebugLevel) && (type == WIFI_MGT_TYPE)) { pr_info(DRIVER_PREFIX "#############################\n"); print_hex_dump(KERN_INFO, DRIVER_PREFIX, DUMP_PREFIX_NONE, - 16, 1, ptr, 64, false); + 16, 1, ptr, 64, false); pr_info(DRIVER_PREFIX "#############################\n"); } } else if (bDumpRxPkt == 3) { if ((_drv_err_ <= GlobalDebugLevel) && (type == WIFI_DATA_TYPE)) { pr_info(DRIVER_PREFIX "#############################\n"); print_hex_dump(KERN_INFO, DRIVER_PREFIX, DUMP_PREFIX_NONE, - 16, 1, ptr, 64, false); + 16, 1, ptr, 64, false); pr_info(DRIVER_PREFIX "#############################\n"); } } -- cgit v1.2.3-58-ga151 From bcb24e6d32ee555b166db660fbdb5b536c4c9f58 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Fri, 19 Jun 2020 12:36:29 +0200 Subject: staging: ion: remove dead code ion_heap_pages_zero() function is not used at all, so remove it to simplify the ion_heap_sglist_zero() function later. Signed-off-by: Marek Szyprowski Link: https://lore.kernel.org/r/20200619103636.11974-30-m.szyprowski@samsung.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.h | 1 - drivers/staging/android/ion/ion_heap.c | 9 --------- 2 files changed, 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h index 74914a266e25..c199e88afc6c 100644 --- a/drivers/staging/android/ion/ion.h +++ b/drivers/staging/android/ion/ion.h @@ -177,7 +177,6 @@ void ion_heap_unmap_kernel(struct ion_heap *heap, struct ion_buffer *buffer); int ion_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer, struct vm_area_struct *vma); int ion_heap_buffer_zero(struct ion_buffer *buffer); -int ion_heap_pages_zero(struct page *page, size_t size, pgprot_t pgprot); /** * ion_heap_init_shrinker diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c index 0755b11348ed..9c23b2382a1e 100644 --- a/drivers/staging/android/ion/ion_heap.c +++ b/drivers/staging/android/ion/ion_heap.c @@ -145,15 +145,6 @@ int ion_heap_buffer_zero(struct ion_buffer *buffer) return ion_heap_sglist_zero(table->sgl, table->nents, pgprot); } -int ion_heap_pages_zero(struct page *page, size_t size, pgprot_t pgprot) -{ - struct scatterlist sg; - - sg_init_table(&sg, 1); - sg_set_page(&sg, page, size, 0); - return ion_heap_sglist_zero(&sg, 1, pgprot); -} - void ion_heap_freelist_add(struct ion_heap *heap, struct ion_buffer *buffer) { spin_lock(&heap->free_lock); -- cgit v1.2.3-58-ga151 From 61fd971eddecdc82586bbdcce26be01c984ae193 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Mon, 22 Jun 2020 10:48:10 +0200 Subject: staging: most: cdev: remove noisy log messages This patch removes unnecessary log messages to avoid noise in the kernel log. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1592815695-19305-2-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/cdev/cdev.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c index cc1e3dea196d..093b44d095a9 100644 --- a/drivers/staging/most/cdev/cdev.c +++ b/drivers/staging/most/cdev/cdev.c @@ -129,19 +129,16 @@ static int comp_open(struct inode *inode, struct file *filp) ((filp->f_flags & O_ACCMODE) != O_RDONLY)) || ((c->cfg->direction == MOST_CH_TX) && ((filp->f_flags & O_ACCMODE) != O_WRONLY))) { - pr_info("WARN: Access flags mismatch\n"); return -EACCES; } mutex_lock(&c->io_mutex); if (!c->dev) { - pr_info("WARN: Device is destroyed\n"); mutex_unlock(&c->io_mutex); return -ENODEV; } if (c->access_ref) { - pr_info("WARN: Device is busy\n"); mutex_unlock(&c->io_mutex); return -EBUSY; } @@ -328,10 +325,8 @@ static int comp_disconnect_channel(struct most_interface *iface, int channel_id) { struct comp_channel *c; - if (!iface) { - pr_info("Bad interface pointer\n"); + if (!iface) return -EINVAL; - } c = get_channel(iface, channel_id); if (!c) @@ -397,10 +392,9 @@ static int comp_tx_completion(struct most_interface *iface, int channel_id) { struct comp_channel *c; - if (!iface) { - pr_info("Bad interface pointer\n"); + if (!iface) return -EINVAL; - } + if ((channel_id < 0) || (channel_id >= iface->num_channels)) { pr_info("Channel ID out of range\n"); return -EINVAL; @@ -432,10 +426,9 @@ static int comp_probe(struct most_interface *iface, int channel_id, int retval; int current_minor; - if ((!iface) || (!cfg) || (!name)) { - pr_info("Probing component with bad arguments"); + if ((!iface) || (!cfg) || (!name)) return -EINVAL; - } + c = get_channel(iface, channel_id); if (c) return -EEXIST; @@ -474,7 +467,6 @@ static int comp_probe(struct most_interface *iface, int channel_id, if (IS_ERR(c->dev)) { retval = PTR_ERR(c->dev); - pr_info("failed to create new device node %s\n", name); goto err_free_kfifo_and_del_list; } kobject_uevent(&c->dev->kobj, KOBJ_ADD); @@ -507,13 +499,9 @@ static int __init mod_init(void) { int err; - pr_info("init()\n"); - comp.class = class_create(THIS_MODULE, "most_cdev"); - if (IS_ERR(comp.class)) { - pr_info("No udev support.\n"); + if (IS_ERR(comp.class)) return PTR_ERR(comp.class); - } INIT_LIST_HEAD(&channel_list); spin_lock_init(&ch_list_lock); @@ -545,8 +533,6 @@ static void __exit mod_exit(void) { struct comp_channel *c, *tmp; - pr_info("exit module\n"); - most_deregister_configfs_subsys(&comp.cc); most_deregister_component(&comp.cc); -- cgit v1.2.3-58-ga151 From 08839388d31ba85d550f60e8e4bc3956b0586e86 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Mon, 22 Jun 2020 10:48:11 +0200 Subject: staging: most: cdev: use dev_*() functions to print messages This patch removes the pr_*() functions and uses dev_*() instead. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1592815695-19305-3-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/cdev/cdev.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c index 093b44d095a9..394c7621cb51 100644 --- a/drivers/staging/most/cdev/cdev.c +++ b/drivers/staging/most/cdev/cdev.c @@ -5,7 +5,6 @@ * Copyright (C) 2013-2015 Microchip Technology Germany II GmbH & Co. KG */ -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include #include #include @@ -375,7 +374,7 @@ static int comp_rx_completion(struct mbo *mbo) spin_unlock(&c->unlink); #ifdef DEBUG_MESG if (kfifo_is_full(&c->fifo)) - pr_info("WARN: Fifo is full\n"); + dev_warn(c->dev, "Fifo is full\n"); #endif wake_up_interruptible(&c->wq); return 0; @@ -395,14 +394,15 @@ static int comp_tx_completion(struct most_interface *iface, int channel_id) if (!iface) return -EINVAL; + c = get_channel(iface, channel_id); + if (!c) + return -ENXIO; + if ((channel_id < 0) || (channel_id >= iface->num_channels)) { - pr_info("Channel ID out of range\n"); + dev_warn(c->dev, "Channel ID out of range\n"); return -EINVAL; } - c = get_channel(iface, channel_id); - if (!c) - return -ENXIO; wake_up_interruptible(&c->wq); return 0; } -- cgit v1.2.3-58-ga151 From 7aed13d1653678137ef291ced45158eaa8c39e96 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Mon, 22 Jun 2020 10:48:12 +0200 Subject: staging: most: cdev: remove overcautious parameter checking The interface pointer passed to a component API function cannot be NULL. This patch removes unnecessary sanity checks of the pointer. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1592815695-19305-4-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/cdev/cdev.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c index 394c7621cb51..9fc84fae21fd 100644 --- a/drivers/staging/most/cdev/cdev.c +++ b/drivers/staging/most/cdev/cdev.c @@ -324,9 +324,6 @@ static int comp_disconnect_channel(struct most_interface *iface, int channel_id) { struct comp_channel *c; - if (!iface) - return -EINVAL; - c = get_channel(iface, channel_id); if (!c) return -ENXIO; @@ -391,9 +388,6 @@ static int comp_tx_completion(struct most_interface *iface, int channel_id) { struct comp_channel *c; - if (!iface) - return -EINVAL; - c = get_channel(iface, channel_id); if (!c) return -ENXIO; @@ -426,7 +420,7 @@ static int comp_probe(struct most_interface *iface, int channel_id, int retval; int current_minor; - if ((!iface) || (!cfg) || (!name)) + if ((!cfg) || (!name)) return -EINVAL; c = get_channel(iface, channel_id); -- cgit v1.2.3-58-ga151 From e8e0f7fd7715de745ef522b5ed96e1f947e3fb91 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Mon, 22 Jun 2020 10:48:13 +0200 Subject: staging: most: cdev: fix up parenthesizing This patch removes unnecessary parnthesis. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1592815695-19305-5-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/cdev/cdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c index 9fc84fae21fd..d374cc05e447 100644 --- a/drivers/staging/most/cdev/cdev.c +++ b/drivers/staging/most/cdev/cdev.c @@ -420,7 +420,7 @@ static int comp_probe(struct most_interface *iface, int channel_id, int retval; int current_minor; - if ((!cfg) || (!name)) + if (!cfg || !name) return -EINVAL; c = get_channel(iface, channel_id); -- cgit v1.2.3-58-ga151 From 78aee6516670d1f8f4e74e5982ea8d557f114b2b Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Mon, 22 Jun 2020 10:48:14 +0200 Subject: staging: most: cdev: fix return values This patch makes use of the proper return values when reporting an error to the caller. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1592815695-19305-6-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/cdev/cdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c index d374cc05e447..aa7d7afd7d83 100644 --- a/drivers/staging/most/cdev/cdev.c +++ b/drivers/staging/most/cdev/cdev.c @@ -326,7 +326,7 @@ static int comp_disconnect_channel(struct most_interface *iface, int channel_id) c = get_channel(iface, channel_id); if (!c) - return -ENXIO; + return -EINVAL; mutex_lock(&c->io_mutex); spin_lock(&c->unlink); @@ -360,7 +360,7 @@ static int comp_rx_completion(struct mbo *mbo) c = get_channel(mbo->ifp, mbo->hdm_channel_id); if (!c) - return -ENXIO; + return -EINVAL; spin_lock(&c->unlink); if (!c->access_ref || !c->dev) { @@ -390,7 +390,7 @@ static int comp_tx_completion(struct most_interface *iface, int channel_id) c = get_channel(iface, channel_id); if (!c) - return -ENXIO; + return -EINVAL; if ((channel_id < 0) || (channel_id >= iface->num_channels)) { dev_warn(c->dev, "Channel ID out of range\n"); -- cgit v1.2.3-58-ga151 From 0ae9e4f22d1c046e53ad2eb0a8a8c3d9e441fd3d Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Mon, 22 Jun 2020 10:48:15 +0200 Subject: staging: most: cdev: simplify list iteration This patch uses a less confusing list traversing structure to either return an item of the list that meets the prerequisites or NULL otherwise. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1592815695-19305-7-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/cdev/cdev.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/cdev/cdev.c b/drivers/staging/most/cdev/cdev.c index aa7d7afd7d83..044880760b58 100644 --- a/drivers/staging/most/cdev/cdev.c +++ b/drivers/staging/most/cdev/cdev.c @@ -66,19 +66,16 @@ static struct comp_channel *get_channel(struct most_interface *iface, int id) { struct comp_channel *c, *tmp; unsigned long flags; - int found_channel = 0; spin_lock_irqsave(&ch_list_lock, flags); list_for_each_entry_safe(c, tmp, &channel_list, list) { if ((c->iface == iface) && (c->channel_id == id)) { - found_channel = 1; - break; + spin_unlock_irqrestore(&ch_list_lock, flags); + return c; } } spin_unlock_irqrestore(&ch_list_lock, flags); - if (!found_channel) - return NULL; - return c; + return NULL; } static void stop_channel(struct comp_channel *c) -- cgit v1.2.3-58-ga151 From c0b122a04e1274b6714a3a1176a89fb0c98b82e4 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Tue, 23 Jun 2020 17:07:31 +0200 Subject: staging: most: sound: remove noisy log messages This patch removes unnecessary log messages to avoid noise in the kernel log. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1592924855-25569-2-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/sound/sound.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 1527f410af2b..e6396d11cbb0 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -360,10 +360,8 @@ static int pcm_prepare(struct snd_pcm_substream *substream) channel->copy_fn = most_to_alsa_copy32; } - if (!channel->copy_fn) { - pr_err("unsupported format\n"); + if (!channel->copy_fn) return -EINVAL; - } channel->period_pos = 0; channel->buffer_pos = 0; @@ -396,7 +394,6 @@ static int pcm_trigger(struct snd_pcm_substream *substream, int cmd) return 0; default: - pr_info("%s(), invalid\n", __func__); return -EINVAL; } return 0; @@ -664,11 +661,8 @@ static int audio_disconnect_channel(struct most_interface *iface, struct sound_adapter *adpt = iface->priv; channel = get_channel(iface, channel_id); - if (!channel) { - pr_err("sound_disconnect_channel(), invalid channel %d\n", - channel_id); + if (!channel) return -EINVAL; - } list_del(&channel->list); @@ -692,11 +686,8 @@ static int audio_rx_completion(struct mbo *mbo) struct channel *channel = get_channel(mbo->ifp, mbo->hdm_channel_id); bool period_elapsed = false; - if (!channel) { - pr_err("sound_rx_completion(), invalid channel %d\n", - mbo->hdm_channel_id); + if (!channel) return -EINVAL; - } if (channel->is_stream_running) period_elapsed = copy_data(channel, mbo); @@ -724,14 +715,10 @@ static int audio_tx_completion(struct most_interface *iface, int channel_id) { struct channel *channel = get_channel(iface, channel_id); - if (!channel) { - pr_err("sound_tx_completion(), invalid channel %d\n", - channel_id); + if (!channel) return -EINVAL; - } wake_up_interruptible(&channel->playback_waitq); - return 0; } @@ -752,8 +739,6 @@ static int __init audio_init(void) { int ret; - pr_info("init()\n"); - INIT_LIST_HEAD(&adpt_list); ret = most_register_component(&comp); @@ -770,7 +755,6 @@ static int __init audio_init(void) static void __exit audio_exit(void) { - pr_info("exit()\n"); most_deregister_configfs_subsys(&comp); most_deregister_component(&comp); } -- cgit v1.2.3-58-ga151 From 36b67efe0cb3b33f6d58e1e86d5b2a02ff5ab387 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Tue, 23 Jun 2020 17:07:32 +0200 Subject: staging: most: sound: fix error path Return error and exit the function in case registering the component with the core is failing. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1592924855-25569-3-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/sound/sound.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index e6396d11cbb0..80a8feba1662 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -742,8 +742,10 @@ static int __init audio_init(void) INIT_LIST_HEAD(&adpt_list); ret = most_register_component(&comp); - if (ret) + if (ret) { pr_err("Failed to register %s\n", comp.name); + return ret; + } ret = most_register_configfs_subsys(&comp); if (ret) { pr_err("Failed to register %s configfs subsys\n", comp.name); -- cgit v1.2.3-58-ga151 From b1abd84d551b39c10ba86ffe8b27aaa659015e08 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Tue, 23 Jun 2020 17:07:33 +0200 Subject: staging: most: sound: fix return values This patch returns the proper values when reporting an error to the caller. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1592924855-25569-4-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/sound/sound.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 80a8feba1662..467faa1cb6b3 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -278,6 +278,7 @@ static int pcm_open(struct snd_pcm_substream *substream) struct channel *channel = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; struct most_channel_config *cfg = channel->cfg; + int ret; channel->substream = substream; @@ -290,11 +291,12 @@ static int pcm_open(struct snd_pcm_substream *substream) } } - if (most_start_channel(channel->iface, channel->id, &comp)) { + ret = most_start_channel(channel->iface, channel->id, &comp); + if (ret) { pr_err("most_start_channel() failed!\n"); if (cfg->direction == MOST_CH_TX) kthread_stop(channel->playback_task); - return -EBUSY; + return ret; } runtime->hw = channel->pcm_hardware; @@ -444,7 +446,7 @@ static int split_arg_list(char *buf, u16 *ch_num, char **sample_res) err: pr_err("Bad PCM format\n"); - return -EIO; + return -EINVAL; } static const struct sample_resolution_info { @@ -469,7 +471,7 @@ static int audio_set_hw_params(struct snd_pcm_hardware *pcm_hw, goto found; } pr_err("Unsupported PCM format\n"); - return -EIO; + return -EINVAL; found: if (!ch_num) { @@ -580,7 +582,7 @@ skip_adpt_alloc: if (get_channel(iface, channel_id)) { pr_err("channel (%s:%d) is already linked\n", iface->description, channel_id); - return -EINVAL; + return -EEXIST; } if (cfg->direction == MOST_CH_TX) { -- cgit v1.2.3-58-ga151 From 749a14343ecbbe1c8c5d8000301553aa815cce7d Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Tue, 23 Jun 2020 17:07:34 +0200 Subject: staging: most: sound: fix white spaces This patch removes unnecessary empty lines. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1592924855-25569-5-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/sound/sound.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 467faa1cb6b3..7c56cdb4d8ee 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -50,10 +50,8 @@ struct channel { unsigned int period_pos; unsigned int buffer_pos; bool is_stream_running; - struct task_struct *playback_task; wait_queue_head_t playback_waitq; - void (*copy_fn)(void *alsa, void *most, unsigned int bytes); }; @@ -176,7 +174,6 @@ static struct channel *get_channel(struct most_interface *iface, if ((channel->iface == iface) && (channel->id == channel_id)) return channel; } - return NULL; } @@ -220,7 +217,6 @@ static bool copy_data(struct channel *channel, struct mbo *mbo) channel->period_pos -= runtime->period_size; return true; } - return false; } @@ -260,7 +256,6 @@ static int playback_thread(void *data) if (period_elapsed) snd_pcm_period_elapsed(channel->substream); } - return 0; } @@ -320,7 +315,6 @@ static int pcm_close(struct snd_pcm_substream *substream) if (channel->cfg->direction == MOST_CH_TX) kthread_stop(channel->playback_task); most_stop_channel(channel->iface, channel->id, &comp); - return 0; } @@ -364,10 +358,8 @@ static int pcm_prepare(struct snd_pcm_substream *substream) if (!channel->copy_fn) return -EINVAL; - channel->period_pos = 0; channel->buffer_pos = 0; - return 0; } @@ -441,7 +433,6 @@ static int split_arg_list(char *buf, u16 *ch_num, char **sample_res) *sample_res = strsep(&buf, ".\n"); if (!*sample_res) goto err; - return 0; err: @@ -619,7 +610,6 @@ skip_adpt_alloc: strscpy(pcm->name, device_name, sizeof(pcm->name)); snd_pcm_set_ops(pcm, direction, &pcm_ops); snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0); - return 0; err_free_adpt: @@ -690,15 +680,11 @@ static int audio_rx_completion(struct mbo *mbo) if (!channel) return -EINVAL; - if (channel->is_stream_running) period_elapsed = copy_data(channel, mbo); - most_put_mbo(mbo); - if (period_elapsed) snd_pcm_period_elapsed(channel->substream); - return 0; } @@ -753,7 +739,6 @@ static int __init audio_init(void) pr_err("Failed to register %s configfs subsys\n", comp.name); most_deregister_component(&comp); } - return ret; } -- cgit v1.2.3-58-ga151 From 75d0bf8762640728316c3bbce1aba87b1cc3428f Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Tue, 23 Jun 2020 17:07:35 +0200 Subject: staging: most: sound: remove overcautious argument checking The interface pointer passed to a component API function cannot be NULL. This patch removes the unnecessary sanity check of this argument. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1592924855-25569-6-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/sound/sound.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 7c56cdb4d8ee..8a449ab9bdce 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -531,9 +531,6 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id, char *sample_res; char arg_list_cpy[STRING_SIZE]; - if (!iface) - return -EINVAL; - if (cfg->data_type != MOST_CH_SYNC) { pr_err("Incompatible channel type\n"); return -EINVAL; -- cgit v1.2.3-58-ga151 From 9666e8f83e527ded3e9ad4bd5a9dc14e21bdc7a9 Mon Sep 17 00:00:00 2001 From: Garrit Franke Date: Thu, 25 Jun 2020 11:32:37 +0200 Subject: trivial: staging: vc04_services: replace bitshift with BIT macro Cleans up some bitshifts by using the BIT macro. Signed-off-by: Garrit Franke Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/20200625093237.2640-1-garritfranke@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index ae9183db44ee..e0027148963e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -39,9 +39,9 @@ struct vchiq_openack_payload { }; enum { - QMFLAGS_IS_BLOCKING = (1 << 0), - QMFLAGS_NO_MUTEX_LOCK = (1 << 1), - QMFLAGS_NO_MUTEX_UNLOCK = (1 << 2) + QMFLAGS_IS_BLOCKING = BIT(0), + QMFLAGS_NO_MUTEX_LOCK = BIT(1), + QMFLAGS_NO_MUTEX_UNLOCK = BIT(2) }; /* we require this for consistency between endpoints */ @@ -526,14 +526,14 @@ request_poll(struct vchiq_state *state, struct vchiq_service *service, do { value = atomic_read(&service->poll_flags); } while (atomic_cmpxchg(&service->poll_flags, value, - value | (1 << poll_type)) != value); + value | BIT(poll_type)) != value); do { value = atomic_read(&state->poll_services[ service->localport>>5]); } while (atomic_cmpxchg( &state->poll_services[service->localport>>5], - value, value | (1 << (service->localport & 0x1f))) + value, value | BIT(service->localport & 0x1f)) != value); } @@ -1287,19 +1287,19 @@ poll_services(struct vchiq_state *state) flags = atomic_xchg(&state->poll_services[group], 0); for (i = 0; flags; i++) { - if (flags & (1 << i)) { + if (flags & BIT(i)) { struct vchiq_service *service = find_service_by_port(state, (group<<5) + i); u32 service_flags; - flags &= ~(1 << i); + flags &= ~BIT(i); if (!service) continue; service_flags = atomic_xchg(&service->poll_flags, 0); if (service_flags & - (1 << VCHIQ_POLL_REMOVE)) { + BIT(VCHIQ_POLL_REMOVE)) { vchiq_log_info(vchiq_core_log_level, "%d: ps - remove %d<->%d", state->id, service->localport, @@ -1317,7 +1317,7 @@ poll_services(struct vchiq_state *state) request_poll(state, service, VCHIQ_POLL_REMOVE); } else if (service_flags & - (1 << VCHIQ_POLL_TERMINATE)) { + BIT(VCHIQ_POLL_TERMINATE)) { vchiq_log_info(vchiq_core_log_level, "%d: ps - terminate %d<->%d", state->id, service->localport, @@ -1328,11 +1328,11 @@ poll_services(struct vchiq_state *state) request_poll(state, service, VCHIQ_POLL_TERMINATE); } - if (service_flags & (1 << VCHIQ_POLL_TXNOTIFY)) + if (service_flags & BIT(VCHIQ_POLL_TXNOTIFY)) notify_bulks(service, &service->bulk_tx, 1/*retry_poll*/); - if (service_flags & (1 << VCHIQ_POLL_RXNOTIFY)) + if (service_flags & BIT(VCHIQ_POLL_RXNOTIFY)) notify_bulks(service, &service->bulk_rx, 1/*retry_poll*/); -- cgit v1.2.3-58-ga151 From b18ee53ad297264a79cf4ea566663f20786b6455 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Tue, 23 Jun 2020 18:41:47 +0200 Subject: staging: bcm2835: Break MMAL support out from camera The BCM2835 camera host is currently the only component that uses the VCHIQ MMAL interface. This will soon change with the upporting of BCM2835 ISP, which make use of the same interface. Break VCHIQ MMAL interface support out from camera host directory to make it possible for the ISP driver to use it as well. The only modification to the existing mmal code is the introduction of EXPORT_SYMBOL() for symbols required by bcm2835-camera and the addition of the module author and licenses. Signed-off-by: Jacopo Mondi Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200623164235.29566-2-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/Kconfig | 2 + drivers/staging/vc04_services/Makefile | 5 +- .../staging/vc04_services/bcm2835-camera/Kconfig | 1 + .../staging/vc04_services/bcm2835-camera/Makefile | 4 +- .../vc04_services/bcm2835-camera/mmal-common.h | 60 - .../vc04_services/bcm2835-camera/mmal-encodings.h | 124 -- .../vc04_services/bcm2835-camera/mmal-msg-common.h | 48 - .../vc04_services/bcm2835-camera/mmal-msg-format.h | 106 -- .../vc04_services/bcm2835-camera/mmal-msg-port.h | 109 -- .../vc04_services/bcm2835-camera/mmal-msg.h | 406 ----- .../vc04_services/bcm2835-camera/mmal-parameters.h | 755 -------- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 1891 ------------------- .../vc04_services/bcm2835-camera/mmal-vchiq.h | 166 -- drivers/staging/vc04_services/vchiq-mmal/Kconfig | 7 + drivers/staging/vc04_services/vchiq-mmal/Makefile | 8 + .../staging/vc04_services/vchiq-mmal/mmal-common.h | 60 + .../vc04_services/vchiq-mmal/mmal-encodings.h | 124 ++ .../vc04_services/vchiq-mmal/mmal-msg-common.h | 48 + .../vc04_services/vchiq-mmal/mmal-msg-format.h | 106 ++ .../vc04_services/vchiq-mmal/mmal-msg-port.h | 109 ++ .../staging/vc04_services/vchiq-mmal/mmal-msg.h | 406 +++++ .../vc04_services/vchiq-mmal/mmal-parameters.h | 755 ++++++++ .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 1912 ++++++++++++++++++++ .../staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 166 ++ 24 files changed, 3709 insertions(+), 3669 deletions(-) delete mode 100644 drivers/staging/vc04_services/bcm2835-camera/mmal-common.h delete mode 100644 drivers/staging/vc04_services/bcm2835-camera/mmal-encodings.h delete mode 100644 drivers/staging/vc04_services/bcm2835-camera/mmal-msg-common.h delete mode 100644 drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h delete mode 100644 drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h delete mode 100644 drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h delete mode 100644 drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h delete mode 100644 drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c delete mode 100644 drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h create mode 100644 drivers/staging/vc04_services/vchiq-mmal/Kconfig create mode 100644 drivers/staging/vc04_services/vchiq-mmal/Makefile create mode 100644 drivers/staging/vc04_services/vchiq-mmal/mmal-common.h create mode 100644 drivers/staging/vc04_services/vchiq-mmal/mmal-encodings.h create mode 100644 drivers/staging/vc04_services/vchiq-mmal/mmal-msg-common.h create mode 100644 drivers/staging/vc04_services/vchiq-mmal/mmal-msg-format.h create mode 100644 drivers/staging/vc04_services/vchiq-mmal/mmal-msg-port.h create mode 100644 drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h create mode 100644 drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h create mode 100644 drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c create mode 100644 drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/Kconfig b/drivers/staging/vc04_services/Kconfig index 6baf9dd57f1f..4b886293f198 100644 --- a/drivers/staging/vc04_services/Kconfig +++ b/drivers/staging/vc04_services/Kconfig @@ -23,5 +23,7 @@ source "drivers/staging/vc04_services/bcm2835-audio/Kconfig" source "drivers/staging/vc04_services/bcm2835-camera/Kconfig" +source "drivers/staging/vc04_services/vchiq-mmal/Kconfig" + endif diff --git a/drivers/staging/vc04_services/Makefile b/drivers/staging/vc04_services/Makefile index 54d9e2f31916..d37f21d1a219 100644 --- a/drivers/staging/vc04_services/Makefile +++ b/drivers/staging/vc04_services/Makefile @@ -10,8 +10,9 @@ vchiq-objs := \ interface/vchiq_arm/vchiq_util.o \ interface/vchiq_arm/vchiq_connected.o \ -obj-$(CONFIG_SND_BCM2835) += bcm2835-audio/ -obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-camera/ +obj-$(CONFIG_SND_BCM2835) += bcm2835-audio/ +obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-camera/ +obj-$(CONFIG_BCM2835_VCHIQ_MMAL) += vchiq-mmal/ ccflags-y += -D__VCCOREVER__=0x04000000 diff --git a/drivers/staging/vc04_services/bcm2835-camera/Kconfig b/drivers/staging/vc04_services/bcm2835-camera/Kconfig index c81baf2c111e..d0653d1ed3c7 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/Kconfig +++ b/drivers/staging/vc04_services/bcm2835-camera/Kconfig @@ -4,6 +4,7 @@ config VIDEO_BCM2835 depends on MEDIA_SUPPORT depends on VIDEO_V4L2 && (ARCH_BCM2835 || COMPILE_TEST) select BCM2835_VCHIQ + select BCM2835_VCHIQ_MMAL select VIDEOBUF2_VMALLOC select BTREE help diff --git a/drivers/staging/vc04_services/bcm2835-camera/Makefile b/drivers/staging/vc04_services/bcm2835-camera/Makefile index 472f21e1f2a1..3a76d6ade428 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/Makefile +++ b/drivers/staging/vc04_services/bcm2835-camera/Makefile @@ -1,11 +1,11 @@ # SPDX-License-Identifier: GPL-2.0 bcm2835-v4l2-$(CONFIG_VIDEO_BCM2835) := \ bcm2835-camera.o \ - controls.o \ - mmal-vchiq.o + controls.o obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-v4l2.o ccflags-y += \ -I $(srctree)/$(src)/.. \ + -I $(srctree)/$(src)/../vchiq-mmal/ \ -D__VCCOREVER__=0x04000000 diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h deleted file mode 100644 index ce88fac7c24b..000000000000 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h +++ /dev/null @@ -1,60 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Broadcom BM2835 V4L2 driver - * - * Copyright © 2013 Raspberry Pi (Trading) Ltd. - * - * Authors: Vincent Sanders @ Collabora - * Dave Stevenson @ Broadcom - * (now dave.stevenson@raspberrypi.org) - * Simon Mellor @ Broadcom - * Luke Diamand @ Broadcom - * - * MMAL structures - * - */ -#ifndef MMAL_COMMON_H -#define MMAL_COMMON_H - -#define MMAL_FOURCC(a, b, c, d) ((a) | (b << 8) | (c << 16) | (d << 24)) -#define MMAL_MAGIC MMAL_FOURCC('m', 'm', 'a', 'l') - -/** Special value signalling that time is not known */ -#define MMAL_TIME_UNKNOWN BIT_ULL(63) - -struct mmal_msg_context; - -/* mapping between v4l and mmal video modes */ -struct mmal_fmt { - u32 fourcc; /* v4l2 format id */ - int flags; /* v4l2 flags field */ - u32 mmal; - int depth; - u32 mmal_component; /* MMAL component index to be used to encode */ - u32 ybbp; /* depth of first Y plane for planar formats */ - bool remove_padding; /* Does the GPU have to remove padding, - * or can we do hide padding via bytesperline. - */ -}; - -/* buffer for one video frame */ -struct mmal_buffer { - /* v4l buffer data -- must be first */ - struct vb2_v4l2_buffer vb; - - /* list of buffers available */ - struct list_head list; - - void *buffer; /* buffer pointer */ - unsigned long buffer_size; /* size of allocated buffer */ - - struct mmal_msg_context *msg_context; -}; - -/* */ -struct mmal_colourfx { - s32 enable; - u32 u; - u32 v; -}; -#endif diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-encodings.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-encodings.h deleted file mode 100644 index 2be9941a1f30..000000000000 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-encodings.h +++ /dev/null @@ -1,124 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Broadcom BM2835 V4L2 driver - * - * Copyright © 2013 Raspberry Pi (Trading) Ltd. - * - * Authors: Vincent Sanders @ Collabora - * Dave Stevenson @ Broadcom - * (now dave.stevenson@raspberrypi.org) - * Simon Mellor @ Broadcom - * Luke Diamand @ Broadcom - */ -#ifndef MMAL_ENCODINGS_H -#define MMAL_ENCODINGS_H - -#define MMAL_ENCODING_H264 MMAL_FOURCC('H', '2', '6', '4') -#define MMAL_ENCODING_H263 MMAL_FOURCC('H', '2', '6', '3') -#define MMAL_ENCODING_MP4V MMAL_FOURCC('M', 'P', '4', 'V') -#define MMAL_ENCODING_MP2V MMAL_FOURCC('M', 'P', '2', 'V') -#define MMAL_ENCODING_MP1V MMAL_FOURCC('M', 'P', '1', 'V') -#define MMAL_ENCODING_WMV3 MMAL_FOURCC('W', 'M', 'V', '3') -#define MMAL_ENCODING_WMV2 MMAL_FOURCC('W', 'M', 'V', '2') -#define MMAL_ENCODING_WMV1 MMAL_FOURCC('W', 'M', 'V', '1') -#define MMAL_ENCODING_WVC1 MMAL_FOURCC('W', 'V', 'C', '1') -#define MMAL_ENCODING_VP8 MMAL_FOURCC('V', 'P', '8', ' ') -#define MMAL_ENCODING_VP7 MMAL_FOURCC('V', 'P', '7', ' ') -#define MMAL_ENCODING_VP6 MMAL_FOURCC('V', 'P', '6', ' ') -#define MMAL_ENCODING_THEORA MMAL_FOURCC('T', 'H', 'E', 'O') -#define MMAL_ENCODING_SPARK MMAL_FOURCC('S', 'P', 'R', 'K') -#define MMAL_ENCODING_MJPEG MMAL_FOURCC('M', 'J', 'P', 'G') - -#define MMAL_ENCODING_JPEG MMAL_FOURCC('J', 'P', 'E', 'G') -#define MMAL_ENCODING_GIF MMAL_FOURCC('G', 'I', 'F', ' ') -#define MMAL_ENCODING_PNG MMAL_FOURCC('P', 'N', 'G', ' ') -#define MMAL_ENCODING_PPM MMAL_FOURCC('P', 'P', 'M', ' ') -#define MMAL_ENCODING_TGA MMAL_FOURCC('T', 'G', 'A', ' ') -#define MMAL_ENCODING_BMP MMAL_FOURCC('B', 'M', 'P', ' ') - -#define MMAL_ENCODING_I420 MMAL_FOURCC('I', '4', '2', '0') -#define MMAL_ENCODING_I420_SLICE MMAL_FOURCC('S', '4', '2', '0') -#define MMAL_ENCODING_YV12 MMAL_FOURCC('Y', 'V', '1', '2') -#define MMAL_ENCODING_I422 MMAL_FOURCC('I', '4', '2', '2') -#define MMAL_ENCODING_I422_SLICE MMAL_FOURCC('S', '4', '2', '2') -#define MMAL_ENCODING_YUYV MMAL_FOURCC('Y', 'U', 'Y', 'V') -#define MMAL_ENCODING_YVYU MMAL_FOURCC('Y', 'V', 'Y', 'U') -#define MMAL_ENCODING_UYVY MMAL_FOURCC('U', 'Y', 'V', 'Y') -#define MMAL_ENCODING_VYUY MMAL_FOURCC('V', 'Y', 'U', 'Y') -#define MMAL_ENCODING_NV12 MMAL_FOURCC('N', 'V', '1', '2') -#define MMAL_ENCODING_NV21 MMAL_FOURCC('N', 'V', '2', '1') -#define MMAL_ENCODING_ARGB MMAL_FOURCC('A', 'R', 'G', 'B') -#define MMAL_ENCODING_RGBA MMAL_FOURCC('R', 'G', 'B', 'A') -#define MMAL_ENCODING_ABGR MMAL_FOURCC('A', 'B', 'G', 'R') -#define MMAL_ENCODING_BGRA MMAL_FOURCC('B', 'G', 'R', 'A') -#define MMAL_ENCODING_RGB16 MMAL_FOURCC('R', 'G', 'B', '2') -#define MMAL_ENCODING_RGB24 MMAL_FOURCC('R', 'G', 'B', '3') -#define MMAL_ENCODING_RGB32 MMAL_FOURCC('R', 'G', 'B', '4') -#define MMAL_ENCODING_BGR16 MMAL_FOURCC('B', 'G', 'R', '2') -#define MMAL_ENCODING_BGR24 MMAL_FOURCC('B', 'G', 'R', '3') -#define MMAL_ENCODING_BGR32 MMAL_FOURCC('B', 'G', 'R', '4') - -/** SAND Video (YUVUV128) format, native format understood by VideoCore. - * This format is *not* opaque - if requested you will receive full frames - * of YUV_UV video. - */ -#define MMAL_ENCODING_YUVUV128 MMAL_FOURCC('S', 'A', 'N', 'D') - -/** VideoCore opaque image format, image handles are returned to - * the host but not the actual image data. - */ -#define MMAL_ENCODING_OPAQUE MMAL_FOURCC('O', 'P', 'Q', 'V') - -/** An EGL image handle - */ -#define MMAL_ENCODING_EGL_IMAGE MMAL_FOURCC('E', 'G', 'L', 'I') - -/* }@ */ - -/** \name Pre-defined audio encodings */ -/* @{ */ -#define MMAL_ENCODING_PCM_UNSIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'U') -#define MMAL_ENCODING_PCM_UNSIGNED_LE MMAL_FOURCC('p', 'c', 'm', 'u') -#define MMAL_ENCODING_PCM_SIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'S') -#define MMAL_ENCODING_PCM_SIGNED_LE MMAL_FOURCC('p', 'c', 'm', 's') -#define MMAL_ENCODING_PCM_FLOAT_BE MMAL_FOURCC('P', 'C', 'M', 'F') -#define MMAL_ENCODING_PCM_FLOAT_LE MMAL_FOURCC('p', 'c', 'm', 'f') - -/* Pre-defined H264 encoding variants */ - -/** ISO 14496-10 Annex B byte stream format */ -#define MMAL_ENCODING_VARIANT_H264_DEFAULT 0 -/** ISO 14496-15 AVC stream format */ -#define MMAL_ENCODING_VARIANT_H264_AVC1 MMAL_FOURCC('A', 'V', 'C', '1') -/** Implicitly delineated NAL units without emulation prevention */ -#define MMAL_ENCODING_VARIANT_H264_RAW MMAL_FOURCC('R', 'A', 'W', ' ') - -/** \defgroup MmalColorSpace List of pre-defined video color spaces - * This defines a list of common color spaces. This list isn't exhaustive and - * is only provided as a convenience to avoid clients having to use FourCC - * codes directly. However components are allowed to define and use their own - * FourCC codes. - */ -/* @{ */ - -/** Unknown color space */ -#define MMAL_COLOR_SPACE_UNKNOWN 0 -/** ITU-R BT.601-5 [SDTV] */ -#define MMAL_COLOR_SPACE_ITUR_BT601 MMAL_FOURCC('Y', '6', '0', '1') -/** ITU-R BT.709-3 [HDTV] */ -#define MMAL_COLOR_SPACE_ITUR_BT709 MMAL_FOURCC('Y', '7', '0', '9') -/** JPEG JFIF */ -#define MMAL_COLOR_SPACE_JPEG_JFIF MMAL_FOURCC('Y', 'J', 'F', 'I') -/** Title 47 Code of Federal Regulations (2003) 73.682 (a) (20) */ -#define MMAL_COLOR_SPACE_FCC MMAL_FOURCC('Y', 'F', 'C', 'C') -/** Society of Motion Picture and Television Engineers 240M (1999) */ -#define MMAL_COLOR_SPACE_SMPTE240M MMAL_FOURCC('Y', '2', '4', '0') -/** ITU-R BT.470-2 System M */ -#define MMAL_COLOR_SPACE_BT470_2_M MMAL_FOURCC('Y', '_', '_', 'M') -/** ITU-R BT.470-2 System BG */ -#define MMAL_COLOR_SPACE_BT470_2_BG MMAL_FOURCC('Y', '_', 'B', 'G') -/** JPEG JFIF, but with 16..255 luma */ -#define MMAL_COLOR_SPACE_JFIF_Y16_255 MMAL_FOURCC('Y', 'Y', '1', '6') -/* @} MmalColorSpace List */ - -#endif /* MMAL_ENCODINGS_H */ diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-common.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-common.h deleted file mode 100644 index 342c9b670f7e..000000000000 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-common.h +++ /dev/null @@ -1,48 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Broadcom BM2835 V4L2 driver - * - * Copyright © 2013 Raspberry Pi (Trading) Ltd. - * - * Authors: Vincent Sanders @ Collabora - * Dave Stevenson @ Broadcom - * (now dave.stevenson@raspberrypi.org) - * Simon Mellor @ Broadcom - * Luke Diamand @ Broadcom - */ - -#ifndef MMAL_MSG_COMMON_H -#define MMAL_MSG_COMMON_H - -enum mmal_msg_status { - MMAL_MSG_STATUS_SUCCESS = 0, /**< Success */ - MMAL_MSG_STATUS_ENOMEM, /**< Out of memory */ - MMAL_MSG_STATUS_ENOSPC, /**< Out of resources other than memory */ - MMAL_MSG_STATUS_EINVAL, /**< Argument is invalid */ - MMAL_MSG_STATUS_ENOSYS, /**< Function not implemented */ - MMAL_MSG_STATUS_ENOENT, /**< No such file or directory */ - MMAL_MSG_STATUS_ENXIO, /**< No such device or address */ - MMAL_MSG_STATUS_EIO, /**< I/O error */ - MMAL_MSG_STATUS_ESPIPE, /**< Illegal seek */ - MMAL_MSG_STATUS_ECORRUPT, /**< Data is corrupt \attention */ - MMAL_MSG_STATUS_ENOTREADY, /**< Component is not ready */ - MMAL_MSG_STATUS_ECONFIG, /**< Component is not configured */ - MMAL_MSG_STATUS_EISCONN, /**< Port is already connected */ - MMAL_MSG_STATUS_ENOTCONN, /**< Port is disconnected */ - MMAL_MSG_STATUS_EAGAIN, /**< Resource temporarily unavailable. */ - MMAL_MSG_STATUS_EFAULT, /**< Bad address */ -}; - -struct mmal_rect { - s32 x; /**< x coordinate (from left) */ - s32 y; /**< y coordinate (from top) */ - s32 width; /**< width */ - s32 height; /**< height */ -}; - -struct mmal_rational { - s32 num; /**< Numerator */ - s32 den; /**< Denominator */ -}; - -#endif /* MMAL_MSG_COMMON_H */ diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h deleted file mode 100644 index a118efd21d98..000000000000 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h +++ /dev/null @@ -1,106 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Broadcom BM2835 V4L2 driver - * - * Copyright © 2013 Raspberry Pi (Trading) Ltd. - * - * Authors: Vincent Sanders @ Collabora - * Dave Stevenson @ Broadcom - * (now dave.stevenson@raspberrypi.org) - * Simon Mellor @ Broadcom - * Luke Diamand @ Broadcom - */ - -#ifndef MMAL_MSG_FORMAT_H -#define MMAL_MSG_FORMAT_H - -#include "mmal-msg-common.h" - -/* MMAL_ES_FORMAT_T */ - -struct mmal_audio_format { - u32 channels; /* Number of audio channels */ - u32 sample_rate; /* Sample rate */ - - u32 bits_per_sample; /* Bits per sample */ - u32 block_align; /* Size of a block of data */ -}; - -struct mmal_video_format { - u32 width; /* Width of frame in pixels */ - u32 height; /* Height of frame in rows of pixels */ - struct mmal_rect crop; /* Visible region of the frame */ - struct mmal_rational frame_rate; /* Frame rate */ - struct mmal_rational par; /* Pixel aspect ratio */ - - /* - * FourCC specifying the color space of the video stream. See the - * MmalColorSpace "pre-defined color spaces" for some examples. - */ - u32 color_space; -}; - -struct mmal_subpicture_format { - u32 x_offset; - u32 y_offset; -}; - -union mmal_es_specific_format { - struct mmal_audio_format audio; - struct mmal_video_format video; - struct mmal_subpicture_format subpicture; -}; - -/* Definition of an elementary stream format (MMAL_ES_FORMAT_T) */ -struct mmal_es_format_local { - u32 type; /* enum mmal_es_type */ - - u32 encoding; /* FourCC specifying encoding of the elementary - * stream. - */ - u32 encoding_variant; /* FourCC specifying the specific - * encoding variant of the elementary - * stream. - */ - - union mmal_es_specific_format *es; /* Type specific - * information for the - * elementary stream - */ - - u32 bitrate; /* Bitrate in bits per second */ - u32 flags; /* Flags describing properties of the elementary - * stream. - */ - - u32 extradata_size; /* Size of the codec specific data */ - u8 *extradata; /* Codec specific data */ -}; - -/* Remote definition of an elementary stream format (MMAL_ES_FORMAT_T) */ -struct mmal_es_format { - u32 type; /* enum mmal_es_type */ - - u32 encoding; /* FourCC specifying encoding of the elementary - * stream. - */ - u32 encoding_variant; /* FourCC specifying the specific - * encoding variant of the elementary - * stream. - */ - - u32 es; /* Type specific - * information for the - * elementary stream - */ - - u32 bitrate; /* Bitrate in bits per second */ - u32 flags; /* Flags describing properties of the elementary - * stream. - */ - - u32 extradata_size; /* Size of the codec specific data */ - u32 extradata; /* Codec specific data */ -}; - -#endif /* MMAL_MSG_FORMAT_H */ diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h deleted file mode 100644 index 3fa3f2a578f0..000000000000 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h +++ /dev/null @@ -1,109 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Broadcom BM2835 V4L2 driver - * - * Copyright © 2013 Raspberry Pi (Trading) Ltd. - * - * Authors: Vincent Sanders @ Collabora - * Dave Stevenson @ Broadcom - * (now dave.stevenson@raspberrypi.org) - * Simon Mellor @ Broadcom - * Luke Diamand @ Broadcom - */ - -/* MMAL_PORT_TYPE_T */ -enum mmal_port_type { - MMAL_PORT_TYPE_UNKNOWN = 0, /* Unknown port type */ - MMAL_PORT_TYPE_CONTROL, /* Control port */ - MMAL_PORT_TYPE_INPUT, /* Input port */ - MMAL_PORT_TYPE_OUTPUT, /* Output port */ - MMAL_PORT_TYPE_CLOCK, /* Clock port */ -}; - -/* The port is pass-through and doesn't need buffer headers allocated */ -#define MMAL_PORT_CAPABILITY_PASSTHROUGH 0x01 -/* - *The port wants to allocate the buffer payloads. - * This signals a preference that payload allocation should be done - * on this port for efficiency reasons. - */ -#define MMAL_PORT_CAPABILITY_ALLOCATION 0x02 -/* - * The port supports format change events. - * This applies to input ports and is used to let the client know - * whether the port supports being reconfigured via a format - * change event (i.e. without having to disable the port). - */ -#define MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE 0x04 - -/* - * mmal port structure (MMAL_PORT_T) - * - * most elements are informational only, the pointer values for - * interogation messages are generally provided as additional - * structures within the message. When used to set values only the - * buffer_num, buffer_size and userdata parameters are writable. - */ -struct mmal_port { - u32 priv; /* Private member used by the framework */ - u32 name; /* Port name. Used for debugging purposes (RO) */ - - u32 type; /* Type of the port (RO) enum mmal_port_type */ - u16 index; /* Index of the port in its type list (RO) */ - u16 index_all; /* Index of the port in the list of all ports (RO) */ - - u32 is_enabled; /* Indicates whether the port is enabled or not (RO) */ - u32 format; /* Format of the elementary stream */ - - u32 buffer_num_min; /* Minimum number of buffers the port - * requires (RO). This is set by the - * component. - */ - - u32 buffer_size_min; /* Minimum size of buffers the port - * requires (RO). This is set by the - * component. - */ - - u32 buffer_alignment_min;/* Minimum alignment requirement for - * the buffers (RO). A value of - * zero means no special alignment - * requirements. This is set by the - * component. - */ - - u32 buffer_num_recommended; /* Number of buffers the port - * recommends for optimal - * performance (RO). A value of - * zero means no special - * recommendation. This is set - * by the component. - */ - - u32 buffer_size_recommended; /* Size of buffers the port - * recommends for optimal - * performance (RO). A value of - * zero means no special - * recommendation. This is set - * by the component. - */ - - u32 buffer_num; /* Actual number of buffers the port will use. - * This is set by the client. - */ - - u32 buffer_size; /* Actual maximum size of the buffers that - * will be sent to the port. This is set by - * the client. - */ - - u32 component; /* Component this port belongs to (Read Only) */ - - u32 userdata; /* Field reserved for use by the client */ - - u32 capabilities; /* Flags describing the capabilities of a - * port (RO). Bitwise combination of \ref - * portcapabilities "Port capabilities" - * values. - */ -}; diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h deleted file mode 100644 index 43cc59316f90..000000000000 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h +++ /dev/null @@ -1,406 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Broadcom BM2835 V4L2 driver - * - * Copyright © 2013 Raspberry Pi (Trading) Ltd. - * - * Authors: Vincent Sanders @ Collabora - * Dave Stevenson @ Broadcom - * (now dave.stevenson@raspberrypi.org) - * Simon Mellor @ Broadcom - * Luke Diamand @ Broadcom - */ - -/* - * all the data structures which serialise the MMAL protocol. note - * these are directly mapped onto the recived message data. - * - * BEWARE: They seem to *assume* pointers are u32 and that there is no - * structure padding! - * - * NOTE: this implementation uses kernel types to ensure sizes. Rather - * than assigning values to enums to force their size the - * implementation uses fixed size types and not the enums (though the - * comments have the actual enum type - */ -#ifndef MMAL_MSG_H -#define MMAL_MSG_H - -#define VC_MMAL_VER 15 -#define VC_MMAL_MIN_VER 10 -#define VC_MMAL_SERVER_NAME MAKE_FOURCC("mmal") - -/* max total message size is 512 bytes */ -#define MMAL_MSG_MAX_SIZE 512 -/* with six 32bit header elements max payload is therefore 488 bytes */ -#define MMAL_MSG_MAX_PAYLOAD 488 - -#include "mmal-msg-common.h" -#include "mmal-msg-format.h" -#include "mmal-msg-port.h" - -enum mmal_msg_type { - MMAL_MSG_TYPE_QUIT = 1, - MMAL_MSG_TYPE_SERVICE_CLOSED, - MMAL_MSG_TYPE_GET_VERSION, - MMAL_MSG_TYPE_COMPONENT_CREATE, - MMAL_MSG_TYPE_COMPONENT_DESTROY, /* 5 */ - MMAL_MSG_TYPE_COMPONENT_ENABLE, - MMAL_MSG_TYPE_COMPONENT_DISABLE, - MMAL_MSG_TYPE_PORT_INFO_GET, - MMAL_MSG_TYPE_PORT_INFO_SET, - MMAL_MSG_TYPE_PORT_ACTION, /* 10 */ - MMAL_MSG_TYPE_BUFFER_FROM_HOST, - MMAL_MSG_TYPE_BUFFER_TO_HOST, - MMAL_MSG_TYPE_GET_STATS, - MMAL_MSG_TYPE_PORT_PARAMETER_SET, - MMAL_MSG_TYPE_PORT_PARAMETER_GET, /* 15 */ - MMAL_MSG_TYPE_EVENT_TO_HOST, - MMAL_MSG_TYPE_GET_CORE_STATS_FOR_PORT, - MMAL_MSG_TYPE_OPAQUE_ALLOCATOR, - MMAL_MSG_TYPE_CONSUME_MEM, - MMAL_MSG_TYPE_LMK, /* 20 */ - MMAL_MSG_TYPE_OPAQUE_ALLOCATOR_DESC, - MMAL_MSG_TYPE_DRM_GET_LHS32, - MMAL_MSG_TYPE_DRM_GET_TIME, - MMAL_MSG_TYPE_BUFFER_FROM_HOST_ZEROLEN, - MMAL_MSG_TYPE_PORT_FLUSH, /* 25 */ - MMAL_MSG_TYPE_HOST_LOG, - MMAL_MSG_TYPE_MSG_LAST -}; - -/* port action request messages differ depending on the action type */ -enum mmal_msg_port_action_type { - MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unknown action */ - MMAL_MSG_PORT_ACTION_TYPE_ENABLE, /* Enable a port */ - MMAL_MSG_PORT_ACTION_TYPE_DISABLE, /* Disable a port */ - MMAL_MSG_PORT_ACTION_TYPE_FLUSH, /* Flush a port */ - MMAL_MSG_PORT_ACTION_TYPE_CONNECT, /* Connect ports */ - MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT, /* Disconnect ports */ - MMAL_MSG_PORT_ACTION_TYPE_SET_REQUIREMENTS, /* Set buffer requirements*/ -}; - -struct mmal_msg_header { - u32 magic; - u32 type; /* enum mmal_msg_type */ - - /* Opaque handle to the control service */ - u32 control_service; - - u32 context; /* a u32 per message context */ - u32 status; /* The status of the vchiq operation */ - u32 padding; -}; - -/* Send from VC to host to report version */ -struct mmal_msg_version { - u32 flags; - u32 major; - u32 minor; - u32 minimum; -}; - -/* request to VC to create component */ -struct mmal_msg_component_create { - u32 client_component; /* component context */ - char name[128]; - u32 pid; /* For debug */ -}; - -/* reply from VC to component creation request */ -struct mmal_msg_component_create_reply { - u32 status; /* enum mmal_msg_status - how does this differ to - * the one in the header? - */ - u32 component_handle; /* VideoCore handle for component */ - u32 input_num; /* Number of input ports */ - u32 output_num; /* Number of output ports */ - u32 clock_num; /* Number of clock ports */ -}; - -/* request to VC to destroy a component */ -struct mmal_msg_component_destroy { - u32 component_handle; -}; - -struct mmal_msg_component_destroy_reply { - u32 status; /* The component destruction status */ -}; - -/* request and reply to VC to enable a component */ -struct mmal_msg_component_enable { - u32 component_handle; -}; - -struct mmal_msg_component_enable_reply { - u32 status; /* The component enable status */ -}; - -/* request and reply to VC to disable a component */ -struct mmal_msg_component_disable { - u32 component_handle; -}; - -struct mmal_msg_component_disable_reply { - u32 status; /* The component disable status */ -}; - -/* request to VC to get port information */ -struct mmal_msg_port_info_get { - u32 component_handle; /* component handle port is associated with */ - u32 port_type; /* enum mmal_msg_port_type */ - u32 index; /* port index to query */ -}; - -/* reply from VC to get port info request */ -struct mmal_msg_port_info_get_reply { - u32 status; /* enum mmal_msg_status */ - u32 component_handle; /* component handle port is associated with */ - u32 port_type; /* enum mmal_msg_port_type */ - u32 port_index; /* port indexed in query */ - s32 found; /* unused */ - u32 port_handle; /* Handle to use for this port */ - struct mmal_port port; - struct mmal_es_format format; /* elementary stream format */ - union mmal_es_specific_format es; /* es type specific data */ - u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; /* es extra data */ -}; - -/* request to VC to set port information */ -struct mmal_msg_port_info_set { - u32 component_handle; - u32 port_type; /* enum mmal_msg_port_type */ - u32 port_index; /* port indexed in query */ - struct mmal_port port; - struct mmal_es_format format; - union mmal_es_specific_format es; - u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; -}; - -/* reply from VC to port info set request */ -struct mmal_msg_port_info_set_reply { - u32 status; - u32 component_handle; /* component handle port is associated with */ - u32 port_type; /* enum mmal_msg_port_type */ - u32 index; /* port indexed in query */ - s32 found; /* unused */ - u32 port_handle; /* Handle to use for this port */ - struct mmal_port port; - struct mmal_es_format format; - union mmal_es_specific_format es; - u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; -}; - -/* port action requests that take a mmal_port as a parameter */ -struct mmal_msg_port_action_port { - u32 component_handle; - u32 port_handle; - u32 action; /* enum mmal_msg_port_action_type */ - struct mmal_port port; -}; - -/* port action requests that take handles as a parameter */ -struct mmal_msg_port_action_handle { - u32 component_handle; - u32 port_handle; - u32 action; /* enum mmal_msg_port_action_type */ - u32 connect_component_handle; - u32 connect_port_handle; -}; - -struct mmal_msg_port_action_reply { - u32 status; /* The port action operation status */ -}; - -/* MMAL buffer transfer */ - -/* Size of space reserved in a buffer message for short messages. */ -#define MMAL_VC_SHORT_DATA 128 - -/* Signals that the current payload is the end of the stream of data */ -#define MMAL_BUFFER_HEADER_FLAG_EOS BIT(0) -/* Signals that the start of the current payload starts a frame */ -#define MMAL_BUFFER_HEADER_FLAG_FRAME_START BIT(1) -/* Signals that the end of the current payload ends a frame */ -#define MMAL_BUFFER_HEADER_FLAG_FRAME_END BIT(2) -/* Signals that the current payload contains only complete frames (>1) */ -#define MMAL_BUFFER_HEADER_FLAG_FRAME \ - (MMAL_BUFFER_HEADER_FLAG_FRAME_START | \ - MMAL_BUFFER_HEADER_FLAG_FRAME_END) -/* Signals that the current payload is a keyframe (i.e. self decodable) */ -#define MMAL_BUFFER_HEADER_FLAG_KEYFRAME BIT(3) -/* - * Signals a discontinuity in the stream of data (e.g. after a seek). - * Can be used for instance by a decoder to reset its state - */ -#define MMAL_BUFFER_HEADER_FLAG_DISCONTINUITY BIT(4) -/* - * Signals a buffer containing some kind of config data for the component - * (e.g. codec config data) - */ -#define MMAL_BUFFER_HEADER_FLAG_CONFIG BIT(5) -/* Signals an encrypted payload */ -#define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED BIT(6) -/* Signals a buffer containing side information */ -#define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO BIT(7) -/* - * Signals a buffer which is the snapshot/postview image from a stills - * capture - */ -#define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT BIT(8) -/* Signals a buffer which contains data known to be corrupted */ -#define MMAL_BUFFER_HEADER_FLAG_CORRUPTED BIT(9) -/* Signals that a buffer failed to be transmitted */ -#define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED BIT(10) - -struct mmal_driver_buffer { - u32 magic; - u32 component_handle; - u32 port_handle; - u32 client_context; -}; - -/* buffer header */ -struct mmal_buffer_header { - u32 next; /* next header */ - u32 priv; /* framework private data */ - u32 cmd; - u32 data; - u32 alloc_size; - u32 length; - u32 offset; - u32 flags; - s64 pts; - s64 dts; - u32 type; - u32 user_data; -}; - -struct mmal_buffer_header_type_specific { - union { - struct { - u32 planes; - u32 offset[4]; - u32 pitch[4]; - u32 flags; - } video; - } u; -}; - -struct mmal_msg_buffer_from_host { - /* - *The front 32 bytes of the buffer header are copied - * back to us in the reply to allow for context. This - * area is used to store two mmal_driver_buffer structures to - * allow for multiple concurrent service users. - */ - /* control data */ - struct mmal_driver_buffer drvbuf; - - /* referenced control data for passthrough buffer management */ - struct mmal_driver_buffer drvbuf_ref; - struct mmal_buffer_header buffer_header; /* buffer header itself */ - struct mmal_buffer_header_type_specific buffer_header_type_specific; - s32 is_zero_copy; - s32 has_reference; - - /* allows short data to be xfered in control message */ - u32 payload_in_message; - u8 short_data[MMAL_VC_SHORT_DATA]; -}; - -/* port parameter setting */ - -#define MMAL_WORKER_PORT_PARAMETER_SPACE 96 - -struct mmal_msg_port_parameter_set { - u32 component_handle; /* component */ - u32 port_handle; /* port */ - u32 id; /* Parameter ID */ - u32 size; /* Parameter size */ - u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE]; -}; - -struct mmal_msg_port_parameter_set_reply { - u32 status; /* enum mmal_msg_status todo: how does this - * differ to the one in the header? - */ -}; - -/* port parameter getting */ - -struct mmal_msg_port_parameter_get { - u32 component_handle; /* component */ - u32 port_handle; /* port */ - u32 id; /* Parameter ID */ - u32 size; /* Parameter size */ -}; - -struct mmal_msg_port_parameter_get_reply { - u32 status; /* Status of mmal_port_parameter_get call */ - u32 id; /* Parameter ID */ - u32 size; /* Parameter size */ - u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE]; -}; - -/* event messages */ -#define MMAL_WORKER_EVENT_SPACE 256 - -struct mmal_msg_event_to_host { - u32 client_component; /* component context */ - - u32 port_type; - u32 port_num; - - u32 cmd; - u32 length; - u8 data[MMAL_WORKER_EVENT_SPACE]; - u32 delayed_buffer; -}; - -/* all mmal messages are serialised through this structure */ -struct mmal_msg { - /* header */ - struct mmal_msg_header h; - /* payload */ - union { - struct mmal_msg_version version; - - struct mmal_msg_component_create component_create; - struct mmal_msg_component_create_reply component_create_reply; - - struct mmal_msg_component_destroy component_destroy; - struct mmal_msg_component_destroy_reply component_destroy_reply; - - struct mmal_msg_component_enable component_enable; - struct mmal_msg_component_enable_reply component_enable_reply; - - struct mmal_msg_component_disable component_disable; - struct mmal_msg_component_disable_reply component_disable_reply; - - struct mmal_msg_port_info_get port_info_get; - struct mmal_msg_port_info_get_reply port_info_get_reply; - - struct mmal_msg_port_info_set port_info_set; - struct mmal_msg_port_info_set_reply port_info_set_reply; - - struct mmal_msg_port_action_port port_action_port; - struct mmal_msg_port_action_handle port_action_handle; - struct mmal_msg_port_action_reply port_action_reply; - - struct mmal_msg_buffer_from_host buffer_from_host; - - struct mmal_msg_port_parameter_set port_parameter_set; - struct mmal_msg_port_parameter_set_reply - port_parameter_set_reply; - struct mmal_msg_port_parameter_get - port_parameter_get; - struct mmal_msg_port_parameter_get_reply - port_parameter_get_reply; - - struct mmal_msg_event_to_host event_to_host; - - u8 payload[MMAL_MSG_MAX_PAYLOAD]; - } u; -}; -#endif diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h deleted file mode 100644 index f4ac5a6149ea..000000000000 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h +++ /dev/null @@ -1,755 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Broadcom BM2835 V4L2 driver - * - * Copyright © 2013 Raspberry Pi (Trading) Ltd. - * - * Authors: Vincent Sanders @ Collabora - * Dave Stevenson @ Broadcom - * (now dave.stevenson@raspberrypi.org) - * Simon Mellor @ Broadcom - * Luke Diamand @ Broadcom - */ - -/* common parameters */ - -/** @name Parameter groups - * Parameters are divided into groups, and then allocated sequentially within - * a group using an enum. - * @{ - */ - -#ifndef MMAL_PARAMETERS_H -#define MMAL_PARAMETERS_H - -/** Common parameter ID group, used with many types of component. */ -#define MMAL_PARAMETER_GROUP_COMMON (0 << 16) -/** Camera-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_CAMERA (1 << 16) -/** Video-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_VIDEO (2 << 16) -/** Audio-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_AUDIO (3 << 16) -/** Clock-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_CLOCK (4 << 16) -/** Miracast-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_MIRACAST (5 << 16) - -/* Common parameters */ -enum mmal_parameter_common_type { - /**< Never a valid parameter ID */ - MMAL_PARAMETER_UNUSED = MMAL_PARAMETER_GROUP_COMMON, - - /**< MMAL_PARAMETER_ENCODING_T */ - MMAL_PARAMETER_SUPPORTED_ENCODINGS, - /**< MMAL_PARAMETER_URI_T */ - MMAL_PARAMETER_URI, - /** MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T */ - MMAL_PARAMETER_CHANGE_EVENT_REQUEST, - /** MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_ZERO_COPY, - /**< MMAL_PARAMETER_BUFFER_REQUIREMENTS_T */ - MMAL_PARAMETER_BUFFER_REQUIREMENTS, - /**< MMAL_PARAMETER_STATISTICS_T */ - MMAL_PARAMETER_STATISTICS, - /**< MMAL_PARAMETER_CORE_STATISTICS_T */ - MMAL_PARAMETER_CORE_STATISTICS, - /**< MMAL_PARAMETER_MEM_USAGE_T */ - MMAL_PARAMETER_MEM_USAGE, - /**< MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_BUFFER_FLAG_FILTER, - /**< MMAL_PARAMETER_SEEK_T */ - MMAL_PARAMETER_SEEK, - /**< MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_POWERMON_ENABLE, - /**< MMAL_PARAMETER_LOGGING_T */ - MMAL_PARAMETER_LOGGING, - /**< MMAL_PARAMETER_UINT64_T */ - MMAL_PARAMETER_SYSTEM_TIME, - /**< MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_NO_IMAGE_PADDING, -}; - -/* camera parameters */ - -enum mmal_parameter_camera_type { - /* 0 */ - /** @ref MMAL_PARAMETER_THUMBNAIL_CONFIG_T */ - MMAL_PARAMETER_THUMBNAIL_CONFIGURATION = - MMAL_PARAMETER_GROUP_CAMERA, - /**< Unused? */ - MMAL_PARAMETER_CAPTURE_QUALITY, - /**< @ref MMAL_PARAMETER_INT32_T */ - MMAL_PARAMETER_ROTATION, - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_EXIF_DISABLE, - /**< @ref MMAL_PARAMETER_EXIF_T */ - MMAL_PARAMETER_EXIF, - /**< @ref MMAL_PARAM_AWBMODE_T */ - MMAL_PARAMETER_AWB_MODE, - /**< @ref MMAL_PARAMETER_IMAGEFX_T */ - MMAL_PARAMETER_IMAGE_EFFECT, - /**< @ref MMAL_PARAMETER_COLOURFX_T */ - MMAL_PARAMETER_COLOUR_EFFECT, - /**< @ref MMAL_PARAMETER_FLICKERAVOID_T */ - MMAL_PARAMETER_FLICKER_AVOID, - /**< @ref MMAL_PARAMETER_FLASH_T */ - MMAL_PARAMETER_FLASH, - /**< @ref MMAL_PARAMETER_REDEYE_T */ - MMAL_PARAMETER_REDEYE, - /**< @ref MMAL_PARAMETER_FOCUS_T */ - MMAL_PARAMETER_FOCUS, - /**< Unused? */ - MMAL_PARAMETER_FOCAL_LENGTHS, - /**< @ref MMAL_PARAMETER_INT32_T */ - MMAL_PARAMETER_EXPOSURE_COMP, - /**< @ref MMAL_PARAMETER_SCALEFACTOR_T */ - MMAL_PARAMETER_ZOOM, - /**< @ref MMAL_PARAMETER_MIRROR_T */ - MMAL_PARAMETER_MIRROR, - - /* 0x10 */ - /**< @ref MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_CAMERA_NUM, - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_CAPTURE, - /**< @ref MMAL_PARAMETER_EXPOSUREMODE_T */ - MMAL_PARAMETER_EXPOSURE_MODE, - /**< @ref MMAL_PARAMETER_EXPOSUREMETERINGMODE_T */ - MMAL_PARAMETER_EXP_METERING_MODE, - /**< @ref MMAL_PARAMETER_FOCUS_STATUS_T */ - MMAL_PARAMETER_FOCUS_STATUS, - /**< @ref MMAL_PARAMETER_CAMERA_CONFIG_T */ - MMAL_PARAMETER_CAMERA_CONFIG, - /**< @ref MMAL_PARAMETER_CAPTURE_STATUS_T */ - MMAL_PARAMETER_CAPTURE_STATUS, - /**< @ref MMAL_PARAMETER_FACE_TRACK_T */ - MMAL_PARAMETER_FACE_TRACK, - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS, - /**< @ref MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_JPEG_Q_FACTOR, - /**< @ref MMAL_PARAMETER_FRAME_RATE_T */ - MMAL_PARAMETER_FRAME_RATE, - /**< @ref MMAL_PARAMETER_CAMERA_STC_MODE_T */ - MMAL_PARAMETER_USE_STC, - /**< @ref MMAL_PARAMETER_CAMERA_INFO_T */ - MMAL_PARAMETER_CAMERA_INFO, - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_VIDEO_STABILISATION, - /**< @ref MMAL_PARAMETER_FACE_TRACK_RESULTS_T */ - MMAL_PARAMETER_FACE_TRACK_RESULTS, - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_ENABLE_RAW_CAPTURE, - - /* 0x20 */ - /**< @ref MMAL_PARAMETER_URI_T */ - MMAL_PARAMETER_DPF_FILE, - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_ENABLE_DPF_FILE, - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_DPF_FAIL_IS_FATAL, - /**< @ref MMAL_PARAMETER_CAPTUREMODE_T */ - MMAL_PARAMETER_CAPTURE_MODE, - /**< @ref MMAL_PARAMETER_FOCUS_REGIONS_T */ - MMAL_PARAMETER_FOCUS_REGIONS, - /**< @ref MMAL_PARAMETER_INPUT_CROP_T */ - MMAL_PARAMETER_INPUT_CROP, - /**< @ref MMAL_PARAMETER_SENSOR_INFORMATION_T */ - MMAL_PARAMETER_SENSOR_INFORMATION, - /**< @ref MMAL_PARAMETER_FLASH_SELECT_T */ - MMAL_PARAMETER_FLASH_SELECT, - /**< @ref MMAL_PARAMETER_FIELD_OF_VIEW_T */ - MMAL_PARAMETER_FIELD_OF_VIEW, - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_HIGH_DYNAMIC_RANGE, - /**< @ref MMAL_PARAMETER_DRC_T */ - MMAL_PARAMETER_DYNAMIC_RANGE_COMPRESSION, - /**< @ref MMAL_PARAMETER_ALGORITHM_CONTROL_T */ - MMAL_PARAMETER_ALGORITHM_CONTROL, - /**< @ref MMAL_PARAMETER_RATIONAL_T */ - MMAL_PARAMETER_SHARPNESS, - /**< @ref MMAL_PARAMETER_RATIONAL_T */ - MMAL_PARAMETER_CONTRAST, - /**< @ref MMAL_PARAMETER_RATIONAL_T */ - MMAL_PARAMETER_BRIGHTNESS, - /**< @ref MMAL_PARAMETER_RATIONAL_T */ - MMAL_PARAMETER_SATURATION, - - /* 0x30 */ - /**< @ref MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_ISO, - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_ANTISHAKE, - /** @ref MMAL_PARAMETER_IMAGEFX_PARAMETERS_T */ - MMAL_PARAMETER_IMAGE_EFFECT_PARAMETERS, - /** @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_CAMERA_BURST_CAPTURE, - /** @ref MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_CAMERA_MIN_ISO, - /** @ref MMAL_PARAMETER_CAMERA_USE_CASE_T */ - MMAL_PARAMETER_CAMERA_USE_CASE, - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_CAPTURE_STATS_PASS, - /** @ref MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG, - /** @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_ENABLE_REGISTER_FILE, - /** @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_REGISTER_FAIL_IS_FATAL, - /** @ref MMAL_PARAMETER_CONFIGFILE_T */ - MMAL_PARAMETER_CONFIGFILE_REGISTERS, - /** @ref MMAL_PARAMETER_CONFIGFILE_CHUNK_T */ - MMAL_PARAMETER_CONFIGFILE_CHUNK_REGISTERS, - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_JPEG_ATTACH_LOG, - /**< @ref MMAL_PARAMETER_ZEROSHUTTERLAG_T */ - MMAL_PARAMETER_ZERO_SHUTTER_LAG, - /**< @ref MMAL_PARAMETER_FPS_RANGE_T */ - MMAL_PARAMETER_FPS_RANGE, - /**< @ref MMAL_PARAMETER_INT32_T */ - MMAL_PARAMETER_CAPTURE_EXPOSURE_COMP, - - /* 0x40 */ - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_SW_SHARPEN_DISABLE, - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_FLASH_REQUIRED, - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_SW_SATURATION_DISABLE, - /**< Takes a @ref MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_SHUTTER_SPEED, - /**< Takes a @ref MMAL_PARAMETER_AWB_GAINS_T */ - MMAL_PARAMETER_CUSTOM_AWB_GAINS, -}; - -struct mmal_parameter_rational { - s32 num; /**< Numerator */ - s32 den; /**< Denominator */ -}; - -enum mmal_parameter_camera_config_timestamp_mode { - MMAL_PARAM_TIMESTAMP_MODE_ZERO = 0, /* Always timestamp frames as 0 */ - MMAL_PARAM_TIMESTAMP_MODE_RAW_STC, /* Use the raw STC value - * for the frame timestamp - */ - MMAL_PARAM_TIMESTAMP_MODE_RESET_STC, /* Use the STC timestamp - * but subtract the - * timestamp of the first - * frame sent to give a - * zero based timestamp. - */ -}; - -struct mmal_parameter_fps_range { - /**< Low end of the permitted framerate range */ - struct mmal_parameter_rational fps_low; - /**< High end of the permitted framerate range */ - struct mmal_parameter_rational fps_high; -}; - -/* camera configuration parameter */ -struct mmal_parameter_camera_config { - /* Parameters for setting up the image pools */ - u32 max_stills_w; /* Max size of stills capture */ - u32 max_stills_h; - u32 stills_yuv422; /* Allow YUV422 stills capture */ - u32 one_shot_stills; /* Continuous or one shot stills captures. */ - - u32 max_preview_video_w; /* Max size of the preview or video - * capture frames - */ - u32 max_preview_video_h; - u32 num_preview_video_frames; - - /** Sets the height of the circular buffer for stills capture. */ - u32 stills_capture_circular_buffer_height; - - /** Allows preview/encode to resume as fast as possible after the stills - * input frame has been received, and then processes the still frame in - * the background whilst preview/encode has resumed. - * Actual mode is controlled by MMAL_PARAMETER_CAPTURE_MODE. - */ - u32 fast_preview_resume; - - /** Selects algorithm for timestamping frames if - * there is no clock component connected. - * enum mmal_parameter_camera_config_timestamp_mode - */ - s32 use_stc_timestamp; -}; - -enum mmal_parameter_exposuremode { - MMAL_PARAM_EXPOSUREMODE_OFF, - MMAL_PARAM_EXPOSUREMODE_AUTO, - MMAL_PARAM_EXPOSUREMODE_NIGHT, - MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW, - MMAL_PARAM_EXPOSUREMODE_BACKLIGHT, - MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT, - MMAL_PARAM_EXPOSUREMODE_SPORTS, - MMAL_PARAM_EXPOSUREMODE_SNOW, - MMAL_PARAM_EXPOSUREMODE_BEACH, - MMAL_PARAM_EXPOSUREMODE_VERYLONG, - MMAL_PARAM_EXPOSUREMODE_FIXEDFPS, - MMAL_PARAM_EXPOSUREMODE_ANTISHAKE, - MMAL_PARAM_EXPOSUREMODE_FIREWORKS, -}; - -enum mmal_parameter_exposuremeteringmode { - MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE, - MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT, - MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT, - MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX, -}; - -enum mmal_parameter_awbmode { - MMAL_PARAM_AWBMODE_OFF, - MMAL_PARAM_AWBMODE_AUTO, - MMAL_PARAM_AWBMODE_SUNLIGHT, - MMAL_PARAM_AWBMODE_CLOUDY, - MMAL_PARAM_AWBMODE_SHADE, - MMAL_PARAM_AWBMODE_TUNGSTEN, - MMAL_PARAM_AWBMODE_FLUORESCENT, - MMAL_PARAM_AWBMODE_INCANDESCENT, - MMAL_PARAM_AWBMODE_FLASH, - MMAL_PARAM_AWBMODE_HORIZON, -}; - -enum mmal_parameter_imagefx { - MMAL_PARAM_IMAGEFX_NONE, - MMAL_PARAM_IMAGEFX_NEGATIVE, - MMAL_PARAM_IMAGEFX_SOLARIZE, - MMAL_PARAM_IMAGEFX_POSTERIZE, - MMAL_PARAM_IMAGEFX_WHITEBOARD, - MMAL_PARAM_IMAGEFX_BLACKBOARD, - MMAL_PARAM_IMAGEFX_SKETCH, - MMAL_PARAM_IMAGEFX_DENOISE, - MMAL_PARAM_IMAGEFX_EMBOSS, - MMAL_PARAM_IMAGEFX_OILPAINT, - MMAL_PARAM_IMAGEFX_HATCH, - MMAL_PARAM_IMAGEFX_GPEN, - MMAL_PARAM_IMAGEFX_PASTEL, - MMAL_PARAM_IMAGEFX_WATERCOLOUR, - MMAL_PARAM_IMAGEFX_FILM, - MMAL_PARAM_IMAGEFX_BLUR, - MMAL_PARAM_IMAGEFX_SATURATION, - MMAL_PARAM_IMAGEFX_COLOURSWAP, - MMAL_PARAM_IMAGEFX_WASHEDOUT, - MMAL_PARAM_IMAGEFX_POSTERISE, - MMAL_PARAM_IMAGEFX_COLOURPOINT, - MMAL_PARAM_IMAGEFX_COLOURBALANCE, - MMAL_PARAM_IMAGEFX_CARTOON, -}; - -enum MMAL_PARAM_FLICKERAVOID_T { - MMAL_PARAM_FLICKERAVOID_OFF, - MMAL_PARAM_FLICKERAVOID_AUTO, - MMAL_PARAM_FLICKERAVOID_50HZ, - MMAL_PARAM_FLICKERAVOID_60HZ, - MMAL_PARAM_FLICKERAVOID_MAX = 0x7FFFFFFF -}; - -struct mmal_parameter_awbgains { - struct mmal_parameter_rational r_gain; /**< Red gain */ - struct mmal_parameter_rational b_gain; /**< Blue gain */ -}; - -/** Manner of video rate control */ -enum mmal_parameter_rate_control_mode { - MMAL_VIDEO_RATECONTROL_DEFAULT, - MMAL_VIDEO_RATECONTROL_VARIABLE, - MMAL_VIDEO_RATECONTROL_CONSTANT, - MMAL_VIDEO_RATECONTROL_VARIABLE_SKIP_FRAMES, - MMAL_VIDEO_RATECONTROL_CONSTANT_SKIP_FRAMES -}; - -enum mmal_video_profile { - MMAL_VIDEO_PROFILE_H263_BASELINE, - MMAL_VIDEO_PROFILE_H263_H320CODING, - MMAL_VIDEO_PROFILE_H263_BACKWARDCOMPATIBLE, - MMAL_VIDEO_PROFILE_H263_ISWV2, - MMAL_VIDEO_PROFILE_H263_ISWV3, - MMAL_VIDEO_PROFILE_H263_HIGHCOMPRESSION, - MMAL_VIDEO_PROFILE_H263_INTERNET, - MMAL_VIDEO_PROFILE_H263_INTERLACE, - MMAL_VIDEO_PROFILE_H263_HIGHLATENCY, - MMAL_VIDEO_PROFILE_MP4V_SIMPLE, - MMAL_VIDEO_PROFILE_MP4V_SIMPLESCALABLE, - MMAL_VIDEO_PROFILE_MP4V_CORE, - MMAL_VIDEO_PROFILE_MP4V_MAIN, - MMAL_VIDEO_PROFILE_MP4V_NBIT, - MMAL_VIDEO_PROFILE_MP4V_SCALABLETEXTURE, - MMAL_VIDEO_PROFILE_MP4V_SIMPLEFACE, - MMAL_VIDEO_PROFILE_MP4V_SIMPLEFBA, - MMAL_VIDEO_PROFILE_MP4V_BASICANIMATED, - MMAL_VIDEO_PROFILE_MP4V_HYBRID, - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDREALTIME, - MMAL_VIDEO_PROFILE_MP4V_CORESCALABLE, - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCODING, - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCORE, - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSCALABLE, - MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSIMPLE, - MMAL_VIDEO_PROFILE_H264_BASELINE, - MMAL_VIDEO_PROFILE_H264_MAIN, - MMAL_VIDEO_PROFILE_H264_EXTENDED, - MMAL_VIDEO_PROFILE_H264_HIGH, - MMAL_VIDEO_PROFILE_H264_HIGH10, - MMAL_VIDEO_PROFILE_H264_HIGH422, - MMAL_VIDEO_PROFILE_H264_HIGH444, - MMAL_VIDEO_PROFILE_H264_CONSTRAINED_BASELINE, - MMAL_VIDEO_PROFILE_DUMMY = 0x7FFFFFFF -}; - -enum mmal_video_level { - MMAL_VIDEO_LEVEL_H263_10, - MMAL_VIDEO_LEVEL_H263_20, - MMAL_VIDEO_LEVEL_H263_30, - MMAL_VIDEO_LEVEL_H263_40, - MMAL_VIDEO_LEVEL_H263_45, - MMAL_VIDEO_LEVEL_H263_50, - MMAL_VIDEO_LEVEL_H263_60, - MMAL_VIDEO_LEVEL_H263_70, - MMAL_VIDEO_LEVEL_MP4V_0, - MMAL_VIDEO_LEVEL_MP4V_0b, - MMAL_VIDEO_LEVEL_MP4V_1, - MMAL_VIDEO_LEVEL_MP4V_2, - MMAL_VIDEO_LEVEL_MP4V_3, - MMAL_VIDEO_LEVEL_MP4V_4, - MMAL_VIDEO_LEVEL_MP4V_4a, - MMAL_VIDEO_LEVEL_MP4V_5, - MMAL_VIDEO_LEVEL_MP4V_6, - MMAL_VIDEO_LEVEL_H264_1, - MMAL_VIDEO_LEVEL_H264_1b, - MMAL_VIDEO_LEVEL_H264_11, - MMAL_VIDEO_LEVEL_H264_12, - MMAL_VIDEO_LEVEL_H264_13, - MMAL_VIDEO_LEVEL_H264_2, - MMAL_VIDEO_LEVEL_H264_21, - MMAL_VIDEO_LEVEL_H264_22, - MMAL_VIDEO_LEVEL_H264_3, - MMAL_VIDEO_LEVEL_H264_31, - MMAL_VIDEO_LEVEL_H264_32, - MMAL_VIDEO_LEVEL_H264_4, - MMAL_VIDEO_LEVEL_H264_41, - MMAL_VIDEO_LEVEL_H264_42, - MMAL_VIDEO_LEVEL_H264_5, - MMAL_VIDEO_LEVEL_H264_51, - MMAL_VIDEO_LEVEL_DUMMY = 0x7FFFFFFF -}; - -struct mmal_parameter_video_profile { - enum mmal_video_profile profile; - enum mmal_video_level level; -}; - -/* video parameters */ - -enum mmal_parameter_video_type { - /** @ref MMAL_DISPLAYREGION_T */ - MMAL_PARAMETER_DISPLAYREGION = MMAL_PARAMETER_GROUP_VIDEO, - - /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */ - MMAL_PARAMETER_SUPPORTED_PROFILES, - - /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */ - MMAL_PARAMETER_PROFILE, - - /** @ref MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_INTRAPERIOD, - - /** @ref MMAL_PARAMETER_VIDEO_RATECONTROL_T */ - MMAL_PARAMETER_RATECONTROL, - - /** @ref MMAL_PARAMETER_VIDEO_NALUNITFORMAT_T */ - MMAL_PARAMETER_NALUNITFORMAT, - - /** @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_MINIMISE_FRAGMENTATION, - - /** @ref MMAL_PARAMETER_UINT32_T. - * Setting the value to zero resets to the default (one slice per - * frame). - */ - MMAL_PARAMETER_MB_ROWS_PER_SLICE, - - /** @ref MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION_T */ - MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION, - - /** @ref MMAL_PARAMETER_VIDEO_EEDE_ENABLE_T */ - MMAL_PARAMETER_VIDEO_EEDE_ENABLE, - - /** @ref MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE_T */ - MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE, - - /** @ref MMAL_PARAMETER_BOOLEAN_T. Request an I-frame. */ - MMAL_PARAMETER_VIDEO_REQUEST_I_FRAME, - /** @ref MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T */ - MMAL_PARAMETER_VIDEO_INTRA_REFRESH, - - /** @ref MMAL_PARAMETER_BOOLEAN_T. */ - MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT, - - /** @ref MMAL_PARAMETER_UINT32_T. Run-time bit rate control */ - MMAL_PARAMETER_VIDEO_BIT_RATE, - - /** @ref MMAL_PARAMETER_FRAME_RATE_T */ - MMAL_PARAMETER_VIDEO_FRAME_RATE, - - /** @ref MMAL_PARAMETER_UINT32_T. */ - MMAL_PARAMETER_VIDEO_ENCODE_MIN_QUANT, - - /** @ref MMAL_PARAMETER_UINT32_T. */ - MMAL_PARAMETER_VIDEO_ENCODE_MAX_QUANT, - - /** @ref MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL_T. */ - MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL, - - MMAL_PARAMETER_EXTRA_BUFFERS, /**< @ref MMAL_PARAMETER_UINT32_T. */ - /** @ref MMAL_PARAMETER_UINT32_T. - * Changing this parameter from the default can reduce frame rate - * because image buffers need to be re-pitched. - */ - MMAL_PARAMETER_VIDEO_ALIGN_HORIZ, - - /** @ref MMAL_PARAMETER_UINT32_T. - * Changing this parameter from the default can reduce frame rate - * because image buffers need to be re-pitched. - */ - MMAL_PARAMETER_VIDEO_ALIGN_VERT, - - /** @ref MMAL_PARAMETER_BOOLEAN_T. */ - MMAL_PARAMETER_VIDEO_DROPPABLE_PFRAMES, - - /** @ref MMAL_PARAMETER_UINT32_T. */ - MMAL_PARAMETER_VIDEO_ENCODE_INITIAL_QUANT, - - /**< @ref MMAL_PARAMETER_UINT32_T. */ - MMAL_PARAMETER_VIDEO_ENCODE_QP_P, - - /**< @ref MMAL_PARAMETER_UINT32_T. */ - MMAL_PARAMETER_VIDEO_ENCODE_RC_SLICE_DQUANT, - - /** @ref MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_VIDEO_ENCODE_FRAME_LIMIT_BITS, - - /** @ref MMAL_PARAMETER_UINT32_T. */ - MMAL_PARAMETER_VIDEO_ENCODE_PEAK_RATE, - - /* H264 specific parameters */ - - /** @ref MMAL_PARAMETER_BOOLEAN_T. */ - MMAL_PARAMETER_VIDEO_ENCODE_H264_DISABLE_CABAC, - - /** @ref MMAL_PARAMETER_BOOLEAN_T. */ - MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_LATENCY, - - /** @ref MMAL_PARAMETER_BOOLEAN_T. */ - MMAL_PARAMETER_VIDEO_ENCODE_H264_AU_DELIMITERS, - - /** @ref MMAL_PARAMETER_UINT32_T. */ - MMAL_PARAMETER_VIDEO_ENCODE_H264_DEBLOCK_IDC, - - /** @ref MMAL_PARAMETER_VIDEO_ENCODER_H264_MB_INTRA_MODES_T. */ - MMAL_PARAMETER_VIDEO_ENCODE_H264_MB_INTRA_MODE, - - /** @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_VIDEO_ENCODE_HEADER_ON_OPEN, - - /** @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_VIDEO_ENCODE_PRECODE_FOR_QP, - - /** @ref MMAL_PARAMETER_VIDEO_DRM_INIT_INFO_T. */ - MMAL_PARAMETER_VIDEO_DRM_INIT_INFO, - - /** @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_VIDEO_TIMESTAMP_FIFO, - - /** @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_VIDEO_DECODE_ERROR_CONCEALMENT, - - /** @ref MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER_T. */ - MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER, - - /** @ref MMAL_PARAMETER_BYTES_T */ - MMAL_PARAMETER_VIDEO_DECODE_CONFIG_VD3, - - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_VIDEO_ENCODE_H264_VCL_HRD_PARAMETERS, - - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_DELAY_HRD_FLAG, - - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER -}; - -/** Valid mirror modes */ -enum mmal_parameter_mirror { - MMAL_PARAM_MIRROR_NONE, - MMAL_PARAM_MIRROR_VERTICAL, - MMAL_PARAM_MIRROR_HORIZONTAL, - MMAL_PARAM_MIRROR_BOTH, -}; - -enum mmal_parameter_displaytransform { - MMAL_DISPLAY_ROT0 = 0, - MMAL_DISPLAY_MIRROR_ROT0 = 1, - MMAL_DISPLAY_MIRROR_ROT180 = 2, - MMAL_DISPLAY_ROT180 = 3, - MMAL_DISPLAY_MIRROR_ROT90 = 4, - MMAL_DISPLAY_ROT270 = 5, - MMAL_DISPLAY_ROT90 = 6, - MMAL_DISPLAY_MIRROR_ROT270 = 7, -}; - -enum mmal_parameter_displaymode { - MMAL_DISPLAY_MODE_FILL = 0, - MMAL_DISPLAY_MODE_LETTERBOX = 1, -}; - -enum mmal_parameter_displayset { - MMAL_DISPLAY_SET_NONE = 0, - MMAL_DISPLAY_SET_NUM = 1, - MMAL_DISPLAY_SET_FULLSCREEN = 2, - MMAL_DISPLAY_SET_TRANSFORM = 4, - MMAL_DISPLAY_SET_DEST_RECT = 8, - MMAL_DISPLAY_SET_SRC_RECT = 0x10, - MMAL_DISPLAY_SET_MODE = 0x20, - MMAL_DISPLAY_SET_PIXEL = 0x40, - MMAL_DISPLAY_SET_NOASPECT = 0x80, - MMAL_DISPLAY_SET_LAYER = 0x100, - MMAL_DISPLAY_SET_COPYPROTECT = 0x200, - MMAL_DISPLAY_SET_ALPHA = 0x400, -}; - -/* rectangle, used lots so it gets its own struct */ -struct vchiq_mmal_rect { - s32 x; - s32 y; - s32 width; - s32 height; -}; - -struct mmal_parameter_displayregion { - /** Bitfield that indicates which fields are set and should be - * used. All other fields will maintain their current value. - * \ref MMAL_DISPLAYSET_T defines the bits that can be - * combined. - */ - u32 set; - - /** Describes the display output device, with 0 typically - * being a directly connected LCD display. The actual values - * will depend on the hardware. Code using hard-wired numbers - * (e.g. 2) is certain to fail. - */ - - u32 display_num; - /** Indicates that we are using the full device screen area, - * rather than a window of the display. If zero, then - * dest_rect is used to specify a region of the display to - * use. - */ - - s32 fullscreen; - /** Indicates any rotation or flipping used to map frames onto - * the natural display orientation. - */ - u32 transform; /* enum mmal_parameter_displaytransform */ - - /** Where to display the frame within the screen, if - * fullscreen is zero. - */ - struct vchiq_mmal_rect dest_rect; - - /** Indicates which area of the frame to display. If all - * values are zero, the whole frame will be used. - */ - struct vchiq_mmal_rect src_rect; - - /** If set to non-zero, indicates that any display scaling - * should disregard the aspect ratio of the frame region being - * displayed. - */ - s32 noaspect; - - /** Indicates how the image should be scaled to fit the - * display. \code MMAL_DISPLAY_MODE_FILL \endcode indicates - * that the image should fill the screen by potentially - * cropping the frames. Setting \code mode \endcode to \code - * MMAL_DISPLAY_MODE_LETTERBOX \endcode indicates that all the - * source region should be displayed and black bars added if - * necessary. - */ - u32 mode; /* enum mmal_parameter_displaymode */ - - /** If non-zero, defines the width of a source pixel relative - * to \code pixel_y \endcode. If zero, then pixels default to - * being square. - */ - u32 pixel_x; - - /** If non-zero, defines the height of a source pixel relative - * to \code pixel_x \endcode. If zero, then pixels default to - * being square. - */ - u32 pixel_y; - - /** Sets the relative depth of the images, with greater values - * being in front of smaller values. - */ - u32 layer; - - /** Set to non-zero to ensure copy protection is used on - * output. - */ - s32 copyprotect_required; - - /** Level of opacity of the layer, where zero is fully - * transparent and 255 is fully opaque. - */ - u32 alpha; -}; - -#define MMAL_MAX_IMAGEFX_PARAMETERS 5 - -struct mmal_parameter_imagefx_parameters { - enum mmal_parameter_imagefx effect; - u32 num_effect_params; - u32 effect_parameter[MMAL_MAX_IMAGEFX_PARAMETERS]; -}; - -#define MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS 4 -#define MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES 2 -#define MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN 16 - -struct mmal_parameter_camera_info_camera_t { - u32 port_id; - u32 max_width; - u32 max_height; - u32 lens_present; - u8 camera_name[MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN]; -}; - -enum mmal_parameter_camera_info_flash_type_t { - /* Make values explicit to ensure they match values in config ini */ - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_XENON = 0, - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_LED = 1, - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_OTHER = 2, - MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_MAX = 0x7FFFFFFF -}; - -struct mmal_parameter_camera_info_flash_t { - enum mmal_parameter_camera_info_flash_type_t flash_type; -}; - -struct mmal_parameter_camera_info_t { - u32 num_cameras; - u32 num_flashes; - struct mmal_parameter_camera_info_camera_t - cameras[MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS]; - struct mmal_parameter_camera_info_flash_t - flashes[MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES]; -}; - -#endif diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c deleted file mode 100644 index de03b90021a8..000000000000 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ /dev/null @@ -1,1891 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Broadcom BM2835 V4L2 driver - * - * Copyright © 2013 Raspberry Pi (Trading) Ltd. - * - * Authors: Vincent Sanders @ Collabora - * Dave Stevenson @ Broadcom - * (now dave.stevenson@raspberrypi.org) - * Simon Mellor @ Broadcom - * Luke Diamand @ Broadcom - * - * V4L2 driver MMAL vchiq interface code - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mmal-common.h" -#include "mmal-vchiq.h" -#include "mmal-msg.h" - -#define USE_VCHIQ_ARM -#include "interface/vchi/vchi.h" - -/* maximum number of components supported */ -#define VCHIQ_MMAL_MAX_COMPONENTS 4 - -/*#define FULL_MSG_DUMP 1*/ - -#ifdef DEBUG -static const char *const msg_type_names[] = { - "UNKNOWN", - "QUIT", - "SERVICE_CLOSED", - "GET_VERSION", - "COMPONENT_CREATE", - "COMPONENT_DESTROY", - "COMPONENT_ENABLE", - "COMPONENT_DISABLE", - "PORT_INFO_GET", - "PORT_INFO_SET", - "PORT_ACTION", - "BUFFER_FROM_HOST", - "BUFFER_TO_HOST", - "GET_STATS", - "PORT_PARAMETER_SET", - "PORT_PARAMETER_GET", - "EVENT_TO_HOST", - "GET_CORE_STATS_FOR_PORT", - "OPAQUE_ALLOCATOR", - "CONSUME_MEM", - "LMK", - "OPAQUE_ALLOCATOR_DESC", - "DRM_GET_LHS32", - "DRM_GET_TIME", - "BUFFER_FROM_HOST_ZEROLEN", - "PORT_FLUSH", - "HOST_LOG", -}; -#endif - -static const char *const port_action_type_names[] = { - "UNKNOWN", - "ENABLE", - "DISABLE", - "FLUSH", - "CONNECT", - "DISCONNECT", - "SET_REQUIREMENTS", -}; - -#if defined(DEBUG) -#if defined(FULL_MSG_DUMP) -#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE) \ - do { \ - pr_debug(TITLE" type:%s(%d) length:%d\n", \ - msg_type_names[(MSG)->h.type], \ - (MSG)->h.type, (MSG_LEN)); \ - print_hex_dump(KERN_DEBUG, "<h.type], \ - (MSG)->h.type, (MSG_LEN)); \ - } -#endif -#else -#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE) -#endif - -struct vchiq_mmal_instance; - -/* normal message context */ -struct mmal_msg_context { - struct vchiq_mmal_instance *instance; - - /* Index in the context_map idr so that we can find the - * mmal_msg_context again when servicing the VCHI reply. - */ - int handle; - - union { - struct { - /* work struct for buffer_cb callback */ - struct work_struct work; - /* work struct for deferred callback */ - struct work_struct buffer_to_host_work; - /* mmal instance */ - struct vchiq_mmal_instance *instance; - /* mmal port */ - struct vchiq_mmal_port *port; - /* actual buffer used to store bulk reply */ - struct mmal_buffer *buffer; - /* amount of buffer used */ - unsigned long buffer_used; - /* MMAL buffer flags */ - u32 mmal_flags; - /* Presentation and Decode timestamps */ - s64 pts; - s64 dts; - - int status; /* context status */ - - } bulk; /* bulk data */ - - struct { - /* message handle to release */ - struct vchi_held_msg msg_handle; - /* pointer to received message */ - struct mmal_msg *msg; - /* received message length */ - u32 msg_len; - /* completion upon reply */ - struct completion cmplt; - } sync; /* synchronous response */ - } u; - -}; - -struct vchiq_mmal_instance { - struct vchi_service_handle *handle; - - /* ensure serialised access to service */ - struct mutex vchiq_mutex; - - /* vmalloc page to receive scratch bulk xfers into */ - void *bulk_scratch; - - struct idr context_map; - /* protect accesses to context_map */ - struct mutex context_map_lock; - - /* component to use next */ - int component_idx; - struct vchiq_mmal_component component[VCHIQ_MMAL_MAX_COMPONENTS]; - - /* ordered workqueue to process all bulk operations */ - struct workqueue_struct *bulk_wq; -}; - -static struct mmal_msg_context * -get_msg_context(struct vchiq_mmal_instance *instance) -{ - struct mmal_msg_context *msg_context; - int handle; - - /* todo: should this be allocated from a pool to avoid kzalloc */ - msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL); - - if (!msg_context) - return ERR_PTR(-ENOMEM); - - /* Create an ID that will be passed along with our message so - * that when we service the VCHI reply, we can look up what - * message is being replied to. - */ - mutex_lock(&instance->context_map_lock); - handle = idr_alloc(&instance->context_map, msg_context, - 0, 0, GFP_KERNEL); - mutex_unlock(&instance->context_map_lock); - - if (handle < 0) { - kfree(msg_context); - return ERR_PTR(handle); - } - - msg_context->instance = instance; - msg_context->handle = handle; - - return msg_context; -} - -static struct mmal_msg_context * -lookup_msg_context(struct vchiq_mmal_instance *instance, int handle) -{ - return idr_find(&instance->context_map, handle); -} - -static void -release_msg_context(struct mmal_msg_context *msg_context) -{ - struct vchiq_mmal_instance *instance = msg_context->instance; - - mutex_lock(&instance->context_map_lock); - idr_remove(&instance->context_map, msg_context->handle); - mutex_unlock(&instance->context_map_lock); - kfree(msg_context); -} - -/* deals with receipt of event to host message */ -static void event_to_host_cb(struct vchiq_mmal_instance *instance, - struct mmal_msg *msg, u32 msg_len) -{ - pr_debug("unhandled event\n"); - pr_debug("component:%u port type:%d num:%d cmd:0x%x length:%d\n", - msg->u.event_to_host.client_component, - msg->u.event_to_host.port_type, - msg->u.event_to_host.port_num, - msg->u.event_to_host.cmd, msg->u.event_to_host.length); -} - -/* workqueue scheduled callback - * - * we do this because it is important we do not call any other vchiq - * sync calls from witin the message delivery thread - */ -static void buffer_work_cb(struct work_struct *work) -{ - struct mmal_msg_context *msg_context = - container_of(work, struct mmal_msg_context, u.bulk.work); - - atomic_dec(&msg_context->u.bulk.port->buffers_with_vpu); - - msg_context->u.bulk.port->buffer_cb(msg_context->u.bulk.instance, - msg_context->u.bulk.port, - msg_context->u.bulk.status, - msg_context->u.bulk.buffer, - msg_context->u.bulk.buffer_used, - msg_context->u.bulk.mmal_flags, - msg_context->u.bulk.dts, - msg_context->u.bulk.pts); -} - -/* workqueue scheduled callback to handle receiving buffers - * - * VCHI will allow up to 4 bulk receives to be scheduled before blocking. - * If we block in the service_callback context then we can't process the - * VCHI_CALLBACK_BULK_RECEIVED message that would otherwise allow the blocked - * vchi_bulk_queue_receive() call to complete. - */ -static void buffer_to_host_work_cb(struct work_struct *work) -{ - struct mmal_msg_context *msg_context = - container_of(work, struct mmal_msg_context, - u.bulk.buffer_to_host_work); - struct vchiq_mmal_instance *instance = msg_context->instance; - unsigned long len = msg_context->u.bulk.buffer_used; - int ret; - - if (!len) - /* Dummy receive to ensure the buffers remain in order */ - len = 8; - /* queue the bulk submission */ - vchi_service_use(instance->handle); - ret = vchi_bulk_queue_receive(instance->handle, - msg_context->u.bulk.buffer->buffer, - /* Actual receive needs to be a multiple - * of 4 bytes - */ - (len + 3) & ~3, - VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE | - VCHI_FLAGS_BLOCK_UNTIL_QUEUED, - msg_context); - - vchi_service_release(instance->handle); - - if (ret != 0) - pr_err("%s: ctx: %p, vchi_bulk_queue_receive failed %d\n", - __func__, msg_context, ret); -} - -/* enqueue a bulk receive for a given message context */ -static int bulk_receive(struct vchiq_mmal_instance *instance, - struct mmal_msg *msg, - struct mmal_msg_context *msg_context) -{ - unsigned long rd_len; - - rd_len = msg->u.buffer_from_host.buffer_header.length; - - if (!msg_context->u.bulk.buffer) { - pr_err("bulk.buffer not configured - error in buffer_from_host\n"); - - /* todo: this is a serious error, we should never have - * committed a buffer_to_host operation to the mmal - * port without the buffer to back it up (underflow - * handling) and there is no obvious way to deal with - * this - how is the mmal servie going to react when - * we fail to do the xfer and reschedule a buffer when - * it arrives? perhaps a starved flag to indicate a - * waiting bulk receive? - */ - - return -EINVAL; - } - - /* ensure we do not overrun the available buffer */ - if (rd_len > msg_context->u.bulk.buffer->buffer_size) { - rd_len = msg_context->u.bulk.buffer->buffer_size; - pr_warn("short read as not enough receive buffer space\n"); - /* todo: is this the correct response, what happens to - * the rest of the message data? - */ - } - - /* store length */ - msg_context->u.bulk.buffer_used = rd_len; - msg_context->u.bulk.dts = msg->u.buffer_from_host.buffer_header.dts; - msg_context->u.bulk.pts = msg->u.buffer_from_host.buffer_header.pts; - - queue_work(msg_context->instance->bulk_wq, - &msg_context->u.bulk.buffer_to_host_work); - - return 0; -} - -/* data in message, memcpy from packet into output buffer */ -static int inline_receive(struct vchiq_mmal_instance *instance, - struct mmal_msg *msg, - struct mmal_msg_context *msg_context) -{ - memcpy(msg_context->u.bulk.buffer->buffer, - msg->u.buffer_from_host.short_data, - msg->u.buffer_from_host.payload_in_message); - - msg_context->u.bulk.buffer_used = - msg->u.buffer_from_host.payload_in_message; - - return 0; -} - -/* queue the buffer availability with MMAL_MSG_TYPE_BUFFER_FROM_HOST */ -static int -buffer_from_host(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, struct mmal_buffer *buf) -{ - struct mmal_msg_context *msg_context; - struct mmal_msg m; - int ret; - - if (!port->enabled) - return -EINVAL; - - pr_debug("instance:%p buffer:%p\n", instance->handle, buf); - - /* get context */ - if (!buf->msg_context) { - pr_err("%s: msg_context not allocated, buf %p\n", __func__, - buf); - return -EINVAL; - } - msg_context = buf->msg_context; - - /* store bulk message context for when data arrives */ - msg_context->u.bulk.instance = instance; - msg_context->u.bulk.port = port; - msg_context->u.bulk.buffer = buf; - msg_context->u.bulk.buffer_used = 0; - - /* initialise work structure ready to schedule callback */ - INIT_WORK(&msg_context->u.bulk.work, buffer_work_cb); - INIT_WORK(&msg_context->u.bulk.buffer_to_host_work, - buffer_to_host_work_cb); - - atomic_inc(&port->buffers_with_vpu); - - /* prep the buffer from host message */ - memset(&m, 0xbc, sizeof(m)); /* just to make debug clearer */ - - m.h.type = MMAL_MSG_TYPE_BUFFER_FROM_HOST; - m.h.magic = MMAL_MAGIC; - m.h.context = msg_context->handle; - m.h.status = 0; - - /* drvbuf is our private data passed back */ - m.u.buffer_from_host.drvbuf.magic = MMAL_MAGIC; - m.u.buffer_from_host.drvbuf.component_handle = port->component->handle; - m.u.buffer_from_host.drvbuf.port_handle = port->handle; - m.u.buffer_from_host.drvbuf.client_context = msg_context->handle; - - /* buffer header */ - m.u.buffer_from_host.buffer_header.cmd = 0; - m.u.buffer_from_host.buffer_header.data = - (u32)(unsigned long)buf->buffer; - m.u.buffer_from_host.buffer_header.alloc_size = buf->buffer_size; - m.u.buffer_from_host.buffer_header.length = 0; /* nothing used yet */ - m.u.buffer_from_host.buffer_header.offset = 0; /* no offset */ - m.u.buffer_from_host.buffer_header.flags = 0; /* no flags */ - m.u.buffer_from_host.buffer_header.pts = MMAL_TIME_UNKNOWN; - m.u.buffer_from_host.buffer_header.dts = MMAL_TIME_UNKNOWN; - - /* clear buffer type sepecific data */ - memset(&m.u.buffer_from_host.buffer_header_type_specific, 0, - sizeof(m.u.buffer_from_host.buffer_header_type_specific)); - - /* no payload in message */ - m.u.buffer_from_host.payload_in_message = 0; - - vchi_service_use(instance->handle); - - ret = vchi_queue_kernel_message(instance->handle, - &m, - sizeof(struct mmal_msg_header) + - sizeof(m.u.buffer_from_host)); - - vchi_service_release(instance->handle); - - return ret; -} - -/* deals with receipt of buffer to host message */ -static void buffer_to_host_cb(struct vchiq_mmal_instance *instance, - struct mmal_msg *msg, u32 msg_len) -{ - struct mmal_msg_context *msg_context; - u32 handle; - - pr_debug("%s: instance:%p msg:%p msg_len:%d\n", - __func__, instance, msg, msg_len); - - if (msg->u.buffer_from_host.drvbuf.magic == MMAL_MAGIC) { - handle = msg->u.buffer_from_host.drvbuf.client_context; - msg_context = lookup_msg_context(instance, handle); - - if (!msg_context) { - pr_err("drvbuf.client_context(%u) is invalid\n", - handle); - return; - } - } else { - pr_err("MMAL_MSG_TYPE_BUFFER_TO_HOST with bad magic\n"); - return; - } - - msg_context->u.bulk.mmal_flags = - msg->u.buffer_from_host.buffer_header.flags; - - if (msg->h.status != MMAL_MSG_STATUS_SUCCESS) { - /* message reception had an error */ - pr_warn("error %d in reply\n", msg->h.status); - - msg_context->u.bulk.status = msg->h.status; - - } else if (msg->u.buffer_from_host.buffer_header.length == 0) { - /* empty buffer */ - if (msg->u.buffer_from_host.buffer_header.flags & - MMAL_BUFFER_HEADER_FLAG_EOS) { - msg_context->u.bulk.status = - bulk_receive(instance, msg, msg_context); - if (msg_context->u.bulk.status == 0) - return; /* successful bulk submission, bulk - * completion will trigger callback - */ - } else { - /* do callback with empty buffer - not EOS though */ - msg_context->u.bulk.status = 0; - msg_context->u.bulk.buffer_used = 0; - } - } else if (msg->u.buffer_from_host.payload_in_message == 0) { - /* data is not in message, queue a bulk receive */ - msg_context->u.bulk.status = - bulk_receive(instance, msg, msg_context); - if (msg_context->u.bulk.status == 0) - return; /* successful bulk submission, bulk - * completion will trigger callback - */ - - /* failed to submit buffer, this will end badly */ - pr_err("error %d on bulk submission\n", - msg_context->u.bulk.status); - - } else if (msg->u.buffer_from_host.payload_in_message <= - MMAL_VC_SHORT_DATA) { - /* data payload within message */ - msg_context->u.bulk.status = inline_receive(instance, msg, - msg_context); - } else { - pr_err("message with invalid short payload\n"); - - /* signal error */ - msg_context->u.bulk.status = -EINVAL; - msg_context->u.bulk.buffer_used = - msg->u.buffer_from_host.payload_in_message; - } - - /* schedule the port callback */ - schedule_work(&msg_context->u.bulk.work); -} - -static void bulk_receive_cb(struct vchiq_mmal_instance *instance, - struct mmal_msg_context *msg_context) -{ - msg_context->u.bulk.status = 0; - - /* schedule the port callback */ - schedule_work(&msg_context->u.bulk.work); -} - -static void bulk_abort_cb(struct vchiq_mmal_instance *instance, - struct mmal_msg_context *msg_context) -{ - pr_err("%s: bulk ABORTED msg_context:%p\n", __func__, msg_context); - - msg_context->u.bulk.status = -EINTR; - - schedule_work(&msg_context->u.bulk.work); -} - -/* incoming event service callback */ -static void service_callback(void *param, - const enum vchi_callback_reason reason, - void *bulk_ctx) -{ - struct vchiq_mmal_instance *instance = param; - int status; - u32 msg_len; - struct mmal_msg *msg; - struct vchi_held_msg msg_handle; - struct mmal_msg_context *msg_context; - - if (!instance) { - pr_err("Message callback passed NULL instance\n"); - return; - } - - switch (reason) { - case VCHI_CALLBACK_MSG_AVAILABLE: - status = vchi_msg_hold(instance->handle, (void **)&msg, - &msg_len, VCHI_FLAGS_NONE, &msg_handle); - if (status) { - pr_err("Unable to dequeue a message (%d)\n", status); - break; - } - - DBG_DUMP_MSG(msg, msg_len, "<<< reply message"); - - /* handling is different for buffer messages */ - switch (msg->h.type) { - case MMAL_MSG_TYPE_BUFFER_FROM_HOST: - vchi_held_msg_release(&msg_handle); - break; - - case MMAL_MSG_TYPE_EVENT_TO_HOST: - event_to_host_cb(instance, msg, msg_len); - vchi_held_msg_release(&msg_handle); - - break; - - case MMAL_MSG_TYPE_BUFFER_TO_HOST: - buffer_to_host_cb(instance, msg, msg_len); - vchi_held_msg_release(&msg_handle); - break; - - default: - /* messages dependent on header context to complete */ - if (!msg->h.context) { - pr_err("received message context was null!\n"); - vchi_held_msg_release(&msg_handle); - break; - } - - msg_context = lookup_msg_context(instance, - msg->h.context); - if (!msg_context) { - pr_err("received invalid message context %u!\n", - msg->h.context); - vchi_held_msg_release(&msg_handle); - break; - } - - /* fill in context values */ - msg_context->u.sync.msg_handle = msg_handle; - msg_context->u.sync.msg = msg; - msg_context->u.sync.msg_len = msg_len; - - /* todo: should this check (completion_done() - * == 1) for no one waiting? or do we need a - * flag to tell us the completion has been - * interrupted so we can free the message and - * its context. This probably also solves the - * message arriving after interruption todo - * below - */ - - /* complete message so caller knows it happened */ - complete(&msg_context->u.sync.cmplt); - break; - } - - break; - - case VCHI_CALLBACK_BULK_RECEIVED: - bulk_receive_cb(instance, bulk_ctx); - break; - - case VCHI_CALLBACK_BULK_RECEIVE_ABORTED: - bulk_abort_cb(instance, bulk_ctx); - break; - - case VCHI_CALLBACK_SERVICE_CLOSED: - /* TODO: consider if this requires action if received when - * driver is not explicitly closing the service - */ - break; - - default: - pr_err("Received unhandled message reason %d\n", reason); - break; - } -} - -static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, - struct mmal_msg *msg, - unsigned int payload_len, - struct mmal_msg **msg_out, - struct vchi_held_msg *msg_handle_out) -{ - struct mmal_msg_context *msg_context; - int ret; - unsigned long timeout; - - /* payload size must not cause message to exceed max size */ - if (payload_len > - (MMAL_MSG_MAX_SIZE - sizeof(struct mmal_msg_header))) { - pr_err("payload length %d exceeds max:%d\n", payload_len, - (int)(MMAL_MSG_MAX_SIZE - - sizeof(struct mmal_msg_header))); - return -EINVAL; - } - - msg_context = get_msg_context(instance); - if (IS_ERR(msg_context)) - return PTR_ERR(msg_context); - - init_completion(&msg_context->u.sync.cmplt); - - msg->h.magic = MMAL_MAGIC; - msg->h.context = msg_context->handle; - msg->h.status = 0; - - DBG_DUMP_MSG(msg, (sizeof(struct mmal_msg_header) + payload_len), - ">>> sync message"); - - vchi_service_use(instance->handle); - - ret = vchi_queue_kernel_message(instance->handle, - msg, - sizeof(struct mmal_msg_header) + - payload_len); - - vchi_service_release(instance->handle); - - if (ret) { - pr_err("error %d queuing message\n", ret); - release_msg_context(msg_context); - return ret; - } - - timeout = wait_for_completion_timeout(&msg_context->u.sync.cmplt, - 3 * HZ); - if (timeout == 0) { - pr_err("timed out waiting for sync completion\n"); - ret = -ETIME; - /* todo: what happens if the message arrives after aborting */ - release_msg_context(msg_context); - return ret; - } - - *msg_out = msg_context->u.sync.msg; - *msg_handle_out = msg_context->u.sync.msg_handle; - release_msg_context(msg_context); - - return 0; -} - -static void dump_port_info(struct vchiq_mmal_port *port) -{ - pr_debug("port handle:0x%x enabled:%d\n", port->handle, port->enabled); - - pr_debug("buffer minimum num:%d size:%d align:%d\n", - port->minimum_buffer.num, - port->minimum_buffer.size, port->minimum_buffer.alignment); - - pr_debug("buffer recommended num:%d size:%d align:%d\n", - port->recommended_buffer.num, - port->recommended_buffer.size, - port->recommended_buffer.alignment); - - pr_debug("buffer current values num:%d size:%d align:%d\n", - port->current_buffer.num, - port->current_buffer.size, port->current_buffer.alignment); - - pr_debug("elementary stream: type:%d encoding:0x%x variant:0x%x\n", - port->format.type, - port->format.encoding, port->format.encoding_variant); - - pr_debug(" bitrate:%d flags:0x%x\n", - port->format.bitrate, port->format.flags); - - if (port->format.type == MMAL_ES_TYPE_VIDEO) { - pr_debug - ("es video format: width:%d height:%d colourspace:0x%x\n", - port->es.video.width, port->es.video.height, - port->es.video.color_space); - - pr_debug(" : crop xywh %d,%d,%d,%d\n", - port->es.video.crop.x, - port->es.video.crop.y, - port->es.video.crop.width, port->es.video.crop.height); - pr_debug(" : framerate %d/%d aspect %d/%d\n", - port->es.video.frame_rate.num, - port->es.video.frame_rate.den, - port->es.video.par.num, port->es.video.par.den); - } -} - -static void port_to_mmal_msg(struct vchiq_mmal_port *port, struct mmal_port *p) -{ - /* todo do readonly fields need setting at all? */ - p->type = port->type; - p->index = port->index; - p->index_all = 0; - p->is_enabled = port->enabled; - p->buffer_num_min = port->minimum_buffer.num; - p->buffer_size_min = port->minimum_buffer.size; - p->buffer_alignment_min = port->minimum_buffer.alignment; - p->buffer_num_recommended = port->recommended_buffer.num; - p->buffer_size_recommended = port->recommended_buffer.size; - - /* only three writable fields in a port */ - p->buffer_num = port->current_buffer.num; - p->buffer_size = port->current_buffer.size; - p->userdata = (u32)(unsigned long)port; -} - -static int port_info_set(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port) -{ - int ret; - struct mmal_msg m; - struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; - - pr_debug("setting port info port %p\n", port); - if (!port) - return -1; - dump_port_info(port); - - m.h.type = MMAL_MSG_TYPE_PORT_INFO_SET; - - m.u.port_info_set.component_handle = port->component->handle; - m.u.port_info_set.port_type = port->type; - m.u.port_info_set.port_index = port->index; - - port_to_mmal_msg(port, &m.u.port_info_set.port); - - /* elementary stream format setup */ - m.u.port_info_set.format.type = port->format.type; - m.u.port_info_set.format.encoding = port->format.encoding; - m.u.port_info_set.format.encoding_variant = - port->format.encoding_variant; - m.u.port_info_set.format.bitrate = port->format.bitrate; - m.u.port_info_set.format.flags = port->format.flags; - - memcpy(&m.u.port_info_set.es, &port->es, - sizeof(union mmal_es_specific_format)); - - m.u.port_info_set.format.extradata_size = port->format.extradata_size; - memcpy(&m.u.port_info_set.extradata, port->format.extradata, - port->format.extradata_size); - - ret = send_synchronous_mmal_msg(instance, &m, - sizeof(m.u.port_info_set), - &rmsg, &rmsg_handle); - if (ret) - return ret; - - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_SET) { - /* got an unexpected message type in reply */ - ret = -EINVAL; - goto release_msg; - } - - /* return operation status */ - ret = -rmsg->u.port_info_get_reply.status; - - pr_debug("%s:result:%d component:0x%x port:%d\n", __func__, ret, - port->component->handle, port->handle); - -release_msg: - vchi_held_msg_release(&rmsg_handle); - - return ret; -} - -/* use port info get message to retrieve port information */ -static int port_info_get(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port) -{ - int ret; - struct mmal_msg m; - struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; - - /* port info time */ - m.h.type = MMAL_MSG_TYPE_PORT_INFO_GET; - m.u.port_info_get.component_handle = port->component->handle; - m.u.port_info_get.port_type = port->type; - m.u.port_info_get.index = port->index; - - ret = send_synchronous_mmal_msg(instance, &m, - sizeof(m.u.port_info_get), - &rmsg, &rmsg_handle); - if (ret) - return ret; - - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_GET) { - /* got an unexpected message type in reply */ - ret = -EINVAL; - goto release_msg; - } - - /* return operation status */ - ret = -rmsg->u.port_info_get_reply.status; - if (ret != MMAL_MSG_STATUS_SUCCESS) - goto release_msg; - - if (rmsg->u.port_info_get_reply.port.is_enabled == 0) - port->enabled = 0; - else - port->enabled = 1; - - /* copy the values out of the message */ - port->handle = rmsg->u.port_info_get_reply.port_handle; - - /* port type and index cached to use on port info set because - * it does not use a port handle - */ - port->type = rmsg->u.port_info_get_reply.port_type; - port->index = rmsg->u.port_info_get_reply.port_index; - - port->minimum_buffer.num = - rmsg->u.port_info_get_reply.port.buffer_num_min; - port->minimum_buffer.size = - rmsg->u.port_info_get_reply.port.buffer_size_min; - port->minimum_buffer.alignment = - rmsg->u.port_info_get_reply.port.buffer_alignment_min; - - port->recommended_buffer.alignment = - rmsg->u.port_info_get_reply.port.buffer_alignment_min; - port->recommended_buffer.num = - rmsg->u.port_info_get_reply.port.buffer_num_recommended; - - port->current_buffer.num = rmsg->u.port_info_get_reply.port.buffer_num; - port->current_buffer.size = - rmsg->u.port_info_get_reply.port.buffer_size; - - /* stream format */ - port->format.type = rmsg->u.port_info_get_reply.format.type; - port->format.encoding = rmsg->u.port_info_get_reply.format.encoding; - port->format.encoding_variant = - rmsg->u.port_info_get_reply.format.encoding_variant; - port->format.bitrate = rmsg->u.port_info_get_reply.format.bitrate; - port->format.flags = rmsg->u.port_info_get_reply.format.flags; - - /* elementary stream format */ - memcpy(&port->es, - &rmsg->u.port_info_get_reply.es, - sizeof(union mmal_es_specific_format)); - port->format.es = &port->es; - - port->format.extradata_size = - rmsg->u.port_info_get_reply.format.extradata_size; - memcpy(port->format.extradata, - rmsg->u.port_info_get_reply.extradata, - port->format.extradata_size); - - pr_debug("received port info\n"); - dump_port_info(port); - -release_msg: - - pr_debug("%s:result:%d component:0x%x port:%d\n", - __func__, ret, port->component->handle, port->handle); - - vchi_held_msg_release(&rmsg_handle); - - return ret; -} - -/* create comonent on vc */ -static int create_component(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_component *component, - const char *name) -{ - int ret; - struct mmal_msg m; - struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; - - /* build component create message */ - m.h.type = MMAL_MSG_TYPE_COMPONENT_CREATE; - m.u.component_create.client_component = (u32)(unsigned long)component; - strncpy(m.u.component_create.name, name, - sizeof(m.u.component_create.name)); - - ret = send_synchronous_mmal_msg(instance, &m, - sizeof(m.u.component_create), - &rmsg, &rmsg_handle); - if (ret) - return ret; - - if (rmsg->h.type != m.h.type) { - /* got an unexpected message type in reply */ - ret = -EINVAL; - goto release_msg; - } - - ret = -rmsg->u.component_create_reply.status; - if (ret != MMAL_MSG_STATUS_SUCCESS) - goto release_msg; - - /* a valid component response received */ - component->handle = rmsg->u.component_create_reply.component_handle; - component->inputs = rmsg->u.component_create_reply.input_num; - component->outputs = rmsg->u.component_create_reply.output_num; - component->clocks = rmsg->u.component_create_reply.clock_num; - - pr_debug("Component handle:0x%x in:%d out:%d clock:%d\n", - component->handle, - component->inputs, component->outputs, component->clocks); - -release_msg: - vchi_held_msg_release(&rmsg_handle); - - return ret; -} - -/* destroys a component on vc */ -static int destroy_component(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_component *component) -{ - int ret; - struct mmal_msg m; - struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; - - m.h.type = MMAL_MSG_TYPE_COMPONENT_DESTROY; - m.u.component_destroy.component_handle = component->handle; - - ret = send_synchronous_mmal_msg(instance, &m, - sizeof(m.u.component_destroy), - &rmsg, &rmsg_handle); - if (ret) - return ret; - - if (rmsg->h.type != m.h.type) { - /* got an unexpected message type in reply */ - ret = -EINVAL; - goto release_msg; - } - - ret = -rmsg->u.component_destroy_reply.status; - -release_msg: - - vchi_held_msg_release(&rmsg_handle); - - return ret; -} - -/* enable a component on vc */ -static int enable_component(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_component *component) -{ - int ret; - struct mmal_msg m; - struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; - - m.h.type = MMAL_MSG_TYPE_COMPONENT_ENABLE; - m.u.component_enable.component_handle = component->handle; - - ret = send_synchronous_mmal_msg(instance, &m, - sizeof(m.u.component_enable), - &rmsg, &rmsg_handle); - if (ret) - return ret; - - if (rmsg->h.type != m.h.type) { - /* got an unexpected message type in reply */ - ret = -EINVAL; - goto release_msg; - } - - ret = -rmsg->u.component_enable_reply.status; - -release_msg: - vchi_held_msg_release(&rmsg_handle); - - return ret; -} - -/* disable a component on vc */ -static int disable_component(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_component *component) -{ - int ret; - struct mmal_msg m; - struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; - - m.h.type = MMAL_MSG_TYPE_COMPONENT_DISABLE; - m.u.component_disable.component_handle = component->handle; - - ret = send_synchronous_mmal_msg(instance, &m, - sizeof(m.u.component_disable), - &rmsg, &rmsg_handle); - if (ret) - return ret; - - if (rmsg->h.type != m.h.type) { - /* got an unexpected message type in reply */ - ret = -EINVAL; - goto release_msg; - } - - ret = -rmsg->u.component_disable_reply.status; - -release_msg: - - vchi_held_msg_release(&rmsg_handle); - - return ret; -} - -/* get version of mmal implementation */ -static int get_version(struct vchiq_mmal_instance *instance, - u32 *major_out, u32 *minor_out) -{ - int ret; - struct mmal_msg m; - struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; - - m.h.type = MMAL_MSG_TYPE_GET_VERSION; - - ret = send_synchronous_mmal_msg(instance, &m, - sizeof(m.u.version), - &rmsg, &rmsg_handle); - if (ret) - return ret; - - if (rmsg->h.type != m.h.type) { - /* got an unexpected message type in reply */ - ret = -EINVAL; - goto release_msg; - } - - *major_out = rmsg->u.version.major; - *minor_out = rmsg->u.version.minor; - -release_msg: - vchi_held_msg_release(&rmsg_handle); - - return ret; -} - -/* do a port action with a port as a parameter */ -static int port_action_port(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, - enum mmal_msg_port_action_type action_type) -{ - int ret; - struct mmal_msg m; - struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; - - m.h.type = MMAL_MSG_TYPE_PORT_ACTION; - m.u.port_action_port.component_handle = port->component->handle; - m.u.port_action_port.port_handle = port->handle; - m.u.port_action_port.action = action_type; - - port_to_mmal_msg(port, &m.u.port_action_port.port); - - ret = send_synchronous_mmal_msg(instance, &m, - sizeof(m.u.port_action_port), - &rmsg, &rmsg_handle); - if (ret) - return ret; - - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) { - /* got an unexpected message type in reply */ - ret = -EINVAL; - goto release_msg; - } - - ret = -rmsg->u.port_action_reply.status; - - pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d)\n", - __func__, - ret, port->component->handle, port->handle, - port_action_type_names[action_type], action_type); - -release_msg: - vchi_held_msg_release(&rmsg_handle); - - return ret; -} - -/* do a port action with handles as parameters */ -static int port_action_handle(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, - enum mmal_msg_port_action_type action_type, - u32 connect_component_handle, - u32 connect_port_handle) -{ - int ret; - struct mmal_msg m; - struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; - - m.h.type = MMAL_MSG_TYPE_PORT_ACTION; - - m.u.port_action_handle.component_handle = port->component->handle; - m.u.port_action_handle.port_handle = port->handle; - m.u.port_action_handle.action = action_type; - - m.u.port_action_handle.connect_component_handle = - connect_component_handle; - m.u.port_action_handle.connect_port_handle = connect_port_handle; - - ret = send_synchronous_mmal_msg(instance, &m, - sizeof(m.u.port_action_handle), - &rmsg, &rmsg_handle); - if (ret) - return ret; - - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) { - /* got an unexpected message type in reply */ - ret = -EINVAL; - goto release_msg; - } - - ret = -rmsg->u.port_action_reply.status; - - pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d) connect component:0x%x connect port:%d\n", - __func__, - ret, port->component->handle, port->handle, - port_action_type_names[action_type], - action_type, connect_component_handle, connect_port_handle); - -release_msg: - vchi_held_msg_release(&rmsg_handle); - - return ret; -} - -static int port_parameter_set(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, - u32 parameter_id, void *value, u32 value_size) -{ - int ret; - struct mmal_msg m; - struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; - - m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_SET; - - m.u.port_parameter_set.component_handle = port->component->handle; - m.u.port_parameter_set.port_handle = port->handle; - m.u.port_parameter_set.id = parameter_id; - m.u.port_parameter_set.size = (2 * sizeof(u32)) + value_size; - memcpy(&m.u.port_parameter_set.value, value, value_size); - - ret = send_synchronous_mmal_msg(instance, &m, - (4 * sizeof(u32)) + value_size, - &rmsg, &rmsg_handle); - if (ret) - return ret; - - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_SET) { - /* got an unexpected message type in reply */ - ret = -EINVAL; - goto release_msg; - } - - ret = -rmsg->u.port_parameter_set_reply.status; - - pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n", - __func__, - ret, port->component->handle, port->handle, parameter_id); - -release_msg: - vchi_held_msg_release(&rmsg_handle); - - return ret; -} - -static int port_parameter_get(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, - u32 parameter_id, void *value, u32 *value_size) -{ - int ret; - struct mmal_msg m; - struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; - - m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_GET; - - m.u.port_parameter_get.component_handle = port->component->handle; - m.u.port_parameter_get.port_handle = port->handle; - m.u.port_parameter_get.id = parameter_id; - m.u.port_parameter_get.size = (2 * sizeof(u32)) + *value_size; - - ret = send_synchronous_mmal_msg(instance, &m, - sizeof(struct - mmal_msg_port_parameter_get), - &rmsg, &rmsg_handle); - if (ret) - return ret; - - if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_GET) { - /* got an unexpected message type in reply */ - pr_err("Incorrect reply type %d\n", rmsg->h.type); - ret = -EINVAL; - goto release_msg; - } - - ret = -rmsg->u.port_parameter_get_reply.status; - /* port_parameter_get_reply.size includes the header, - * whilst *value_size doesn't. - */ - rmsg->u.port_parameter_get_reply.size -= (2 * sizeof(u32)); - - if (ret || rmsg->u.port_parameter_get_reply.size > *value_size) { - /* Copy only as much as we have space for - * but report true size of parameter - */ - memcpy(value, &rmsg->u.port_parameter_get_reply.value, - *value_size); - *value_size = rmsg->u.port_parameter_get_reply.size; - } else { - memcpy(value, &rmsg->u.port_parameter_get_reply.value, - rmsg->u.port_parameter_get_reply.size); - } - - pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n", __func__, - ret, port->component->handle, port->handle, parameter_id); - -release_msg: - vchi_held_msg_release(&rmsg_handle); - - return ret; -} - -/* disables a port and drains buffers from it */ -static int port_disable(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port) -{ - int ret; - struct list_head *q, *buf_head; - unsigned long flags = 0; - - if (!port->enabled) - return 0; - - port->enabled = 0; - - ret = port_action_port(instance, port, - MMAL_MSG_PORT_ACTION_TYPE_DISABLE); - if (ret == 0) { - /* - * Drain all queued buffers on port. This should only - * apply to buffers that have been queued before the port - * has been enabled. If the port has been enabled and buffers - * passed, then the buffers should have been removed from this - * list, and we should get the relevant callbacks via VCHIQ - * to release the buffers. - */ - spin_lock_irqsave(&port->slock, flags); - - list_for_each_safe(buf_head, q, &port->buffers) { - struct mmal_buffer *mmalbuf; - - mmalbuf = list_entry(buf_head, struct mmal_buffer, - list); - list_del(buf_head); - if (port->buffer_cb) - port->buffer_cb(instance, - port, 0, mmalbuf, 0, 0, - MMAL_TIME_UNKNOWN, - MMAL_TIME_UNKNOWN); - } - - spin_unlock_irqrestore(&port->slock, flags); - - ret = port_info_get(instance, port); - } - - return ret; -} - -/* enable a port */ -static int port_enable(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port) -{ - unsigned int hdr_count; - struct list_head *q, *buf_head; - int ret; - - if (port->enabled) - return 0; - - ret = port_action_port(instance, port, - MMAL_MSG_PORT_ACTION_TYPE_ENABLE); - if (ret) - goto done; - - port->enabled = 1; - - if (port->buffer_cb) { - /* send buffer headers to videocore */ - hdr_count = 1; - list_for_each_safe(buf_head, q, &port->buffers) { - struct mmal_buffer *mmalbuf; - - mmalbuf = list_entry(buf_head, struct mmal_buffer, - list); - ret = buffer_from_host(instance, port, mmalbuf); - if (ret) - goto done; - - list_del(buf_head); - hdr_count++; - if (hdr_count > port->current_buffer.num) - break; - } - } - - ret = port_info_get(instance, port); - -done: - return ret; -} - -/* ------------------------------------------------------------------ - * Exported API - *------------------------------------------------------------------ - */ - -int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port) -{ - int ret; - - if (mutex_lock_interruptible(&instance->vchiq_mutex)) - return -EINTR; - - ret = port_info_set(instance, port); - if (ret) - goto release_unlock; - - /* read what has actually been set */ - ret = port_info_get(instance, port); - -release_unlock: - mutex_unlock(&instance->vchiq_mutex); - - return ret; -} - -int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, - u32 parameter, void *value, u32 value_size) -{ - int ret; - - if (mutex_lock_interruptible(&instance->vchiq_mutex)) - return -EINTR; - - ret = port_parameter_set(instance, port, parameter, value, value_size); - - mutex_unlock(&instance->vchiq_mutex); - - return ret; -} - -int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, - u32 parameter, void *value, u32 *value_size) -{ - int ret; - - if (mutex_lock_interruptible(&instance->vchiq_mutex)) - return -EINTR; - - ret = port_parameter_get(instance, port, parameter, value, value_size); - - mutex_unlock(&instance->vchiq_mutex); - - return ret; -} - -/* enable a port - * - * enables a port and queues buffers for satisfying callbacks if we - * provide a callback handler - */ -int vchiq_mmal_port_enable(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, - vchiq_mmal_buffer_cb buffer_cb) -{ - int ret; - - if (mutex_lock_interruptible(&instance->vchiq_mutex)) - return -EINTR; - - /* already enabled - noop */ - if (port->enabled) { - ret = 0; - goto unlock; - } - - port->buffer_cb = buffer_cb; - - ret = port_enable(instance, port); - -unlock: - mutex_unlock(&instance->vchiq_mutex); - - return ret; -} - -int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port) -{ - int ret; - - if (mutex_lock_interruptible(&instance->vchiq_mutex)) - return -EINTR; - - if (!port->enabled) { - mutex_unlock(&instance->vchiq_mutex); - return 0; - } - - ret = port_disable(instance, port); - - mutex_unlock(&instance->vchiq_mutex); - - return ret; -} - -/* ports will be connected in a tunneled manner so data buffers - * are not handled by client. - */ -int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *src, - struct vchiq_mmal_port *dst) -{ - int ret; - - if (mutex_lock_interruptible(&instance->vchiq_mutex)) - return -EINTR; - - /* disconnect ports if connected */ - if (src->connected) { - ret = port_disable(instance, src); - if (ret) { - pr_err("failed disabling src port(%d)\n", ret); - goto release_unlock; - } - - /* do not need to disable the destination port as they - * are connected and it is done automatically - */ - - ret = port_action_handle(instance, src, - MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT, - src->connected->component->handle, - src->connected->handle); - if (ret < 0) { - pr_err("failed disconnecting src port\n"); - goto release_unlock; - } - src->connected->enabled = 0; - src->connected = NULL; - } - - if (!dst) { - /* do not make new connection */ - ret = 0; - pr_debug("not making new connection\n"); - goto release_unlock; - } - - /* copy src port format to dst */ - dst->format.encoding = src->format.encoding; - dst->es.video.width = src->es.video.width; - dst->es.video.height = src->es.video.height; - dst->es.video.crop.x = src->es.video.crop.x; - dst->es.video.crop.y = src->es.video.crop.y; - dst->es.video.crop.width = src->es.video.crop.width; - dst->es.video.crop.height = src->es.video.crop.height; - dst->es.video.frame_rate.num = src->es.video.frame_rate.num; - dst->es.video.frame_rate.den = src->es.video.frame_rate.den; - - /* set new format */ - ret = port_info_set(instance, dst); - if (ret) { - pr_debug("setting port info failed\n"); - goto release_unlock; - } - - /* read what has actually been set */ - ret = port_info_get(instance, dst); - if (ret) { - pr_debug("read back port info failed\n"); - goto release_unlock; - } - - /* connect two ports together */ - ret = port_action_handle(instance, src, - MMAL_MSG_PORT_ACTION_TYPE_CONNECT, - dst->component->handle, dst->handle); - if (ret < 0) { - pr_debug("connecting port %d:%d to %d:%d failed\n", - src->component->handle, src->handle, - dst->component->handle, dst->handle); - goto release_unlock; - } - src->connected = dst; - -release_unlock: - - mutex_unlock(&instance->vchiq_mutex); - - return ret; -} - -int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, - struct mmal_buffer *buffer) -{ - unsigned long flags = 0; - int ret; - - ret = buffer_from_host(instance, port, buffer); - if (ret == -EINVAL) { - /* Port is disabled. Queue for when it is enabled. */ - spin_lock_irqsave(&port->slock, flags); - list_add_tail(&buffer->list, &port->buffers); - spin_unlock_irqrestore(&port->slock, flags); - } - - return 0; -} - -int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance, - struct mmal_buffer *buf) -{ - struct mmal_msg_context *msg_context = get_msg_context(instance); - - if (IS_ERR(msg_context)) - return (PTR_ERR(msg_context)); - - buf->msg_context = msg_context; - return 0; -} - -int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf) -{ - struct mmal_msg_context *msg_context = buf->msg_context; - - if (msg_context) - release_msg_context(msg_context); - buf->msg_context = NULL; - - return 0; -} - -/* Initialise a mmal component and its ports - * - */ -int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance, - const char *name, - struct vchiq_mmal_component **component_out) -{ - int ret; - int idx; /* port index */ - struct vchiq_mmal_component *component; - - if (mutex_lock_interruptible(&instance->vchiq_mutex)) - return -EINTR; - - if (instance->component_idx == VCHIQ_MMAL_MAX_COMPONENTS) { - ret = -EINVAL; /* todo is this correct error? */ - goto unlock; - } - - component = &instance->component[instance->component_idx]; - - ret = create_component(instance, component, name); - if (ret < 0) { - pr_err("%s: failed to create component %d (Not enough GPU mem?)\n", - __func__, ret); - goto unlock; - } - - /* ports info needs gathering */ - component->control.type = MMAL_PORT_TYPE_CONTROL; - component->control.index = 0; - component->control.component = component; - spin_lock_init(&component->control.slock); - INIT_LIST_HEAD(&component->control.buffers); - ret = port_info_get(instance, &component->control); - if (ret < 0) - goto release_component; - - for (idx = 0; idx < component->inputs; idx++) { - component->input[idx].type = MMAL_PORT_TYPE_INPUT; - component->input[idx].index = idx; - component->input[idx].component = component; - spin_lock_init(&component->input[idx].slock); - INIT_LIST_HEAD(&component->input[idx].buffers); - ret = port_info_get(instance, &component->input[idx]); - if (ret < 0) - goto release_component; - } - - for (idx = 0; idx < component->outputs; idx++) { - component->output[idx].type = MMAL_PORT_TYPE_OUTPUT; - component->output[idx].index = idx; - component->output[idx].component = component; - spin_lock_init(&component->output[idx].slock); - INIT_LIST_HEAD(&component->output[idx].buffers); - ret = port_info_get(instance, &component->output[idx]); - if (ret < 0) - goto release_component; - } - - for (idx = 0; idx < component->clocks; idx++) { - component->clock[idx].type = MMAL_PORT_TYPE_CLOCK; - component->clock[idx].index = idx; - component->clock[idx].component = component; - spin_lock_init(&component->clock[idx].slock); - INIT_LIST_HEAD(&component->clock[idx].buffers); - ret = port_info_get(instance, &component->clock[idx]); - if (ret < 0) - goto release_component; - } - - instance->component_idx++; - - *component_out = component; - - mutex_unlock(&instance->vchiq_mutex); - - return 0; - -release_component: - destroy_component(instance, component); -unlock: - mutex_unlock(&instance->vchiq_mutex); - - return ret; -} - -/* - * cause a mmal component to be destroyed - */ -int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_component *component) -{ - int ret; - - if (mutex_lock_interruptible(&instance->vchiq_mutex)) - return -EINTR; - - if (component->enabled) - ret = disable_component(instance, component); - - ret = destroy_component(instance, component); - - mutex_unlock(&instance->vchiq_mutex); - - return ret; -} - -/* - * cause a mmal component to be enabled - */ -int vchiq_mmal_component_enable(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_component *component) -{ - int ret; - - if (mutex_lock_interruptible(&instance->vchiq_mutex)) - return -EINTR; - - if (component->enabled) { - mutex_unlock(&instance->vchiq_mutex); - return 0; - } - - ret = enable_component(instance, component); - if (ret == 0) - component->enabled = true; - - mutex_unlock(&instance->vchiq_mutex); - - return ret; -} - -/* - * cause a mmal component to be enabled - */ -int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_component *component) -{ - int ret; - - if (mutex_lock_interruptible(&instance->vchiq_mutex)) - return -EINTR; - - if (!component->enabled) { - mutex_unlock(&instance->vchiq_mutex); - return 0; - } - - ret = disable_component(instance, component); - if (ret == 0) - component->enabled = 0; - - mutex_unlock(&instance->vchiq_mutex); - - return ret; -} - -int vchiq_mmal_version(struct vchiq_mmal_instance *instance, - u32 *major_out, u32 *minor_out) -{ - int ret; - - if (mutex_lock_interruptible(&instance->vchiq_mutex)) - return -EINTR; - - ret = get_version(instance, major_out, minor_out); - - mutex_unlock(&instance->vchiq_mutex); - - return ret; -} - -int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance) -{ - int status = 0; - - if (!instance) - return -EINVAL; - - if (mutex_lock_interruptible(&instance->vchiq_mutex)) - return -EINTR; - - vchi_service_use(instance->handle); - - status = vchi_service_close(instance->handle); - if (status != 0) - pr_err("mmal-vchiq: VCHIQ close failed\n"); - - mutex_unlock(&instance->vchiq_mutex); - - flush_workqueue(instance->bulk_wq); - destroy_workqueue(instance->bulk_wq); - - vfree(instance->bulk_scratch); - - idr_destroy(&instance->context_map); - - kfree(instance); - - return status; -} - -int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) -{ - int status; - struct vchiq_mmal_instance *instance; - static struct vchi_instance_handle *vchi_instance; - struct service_creation params = { - .version = VCHI_VERSION_EX(VC_MMAL_VER, VC_MMAL_MIN_VER), - .service_id = VC_MMAL_SERVER_NAME, - .callback = service_callback, - .callback_param = NULL, - }; - - /* compile time checks to ensure structure size as they are - * directly (de)serialised from memory. - */ - - /* ensure the header structure has packed to the correct size */ - BUILD_BUG_ON(sizeof(struct mmal_msg_header) != 24); - - /* ensure message structure does not exceed maximum length */ - BUILD_BUG_ON(sizeof(struct mmal_msg) > MMAL_MSG_MAX_SIZE); - - /* mmal port struct is correct size */ - BUILD_BUG_ON(sizeof(struct mmal_port) != 64); - - /* create a vchi instance */ - status = vchi_initialise(&vchi_instance); - if (status) { - pr_err("Failed to initialise VCHI instance (status=%d)\n", - status); - return -EIO; - } - - status = vchi_connect(vchi_instance); - if (status) { - pr_err("Failed to connect VCHI instance (status=%d)\n", status); - return -EIO; - } - - instance = kzalloc(sizeof(*instance), GFP_KERNEL); - - if (!instance) - return -ENOMEM; - - mutex_init(&instance->vchiq_mutex); - - instance->bulk_scratch = vmalloc(PAGE_SIZE); - - mutex_init(&instance->context_map_lock); - idr_init_base(&instance->context_map, 1); - - params.callback_param = instance; - - instance->bulk_wq = alloc_ordered_workqueue("mmal-vchiq", - WQ_MEM_RECLAIM); - if (!instance->bulk_wq) - goto err_free; - - status = vchi_service_open(vchi_instance, ¶ms, &instance->handle); - if (status) { - pr_err("Failed to open VCHI service connection (status=%d)\n", - status); - goto err_close_services; - } - - vchi_service_release(instance->handle); - - *out_instance = instance; - - return 0; - -err_close_services: - vchi_service_close(instance->handle); - destroy_workqueue(instance->bulk_wq); -err_free: - vfree(instance->bulk_scratch); - kfree(instance); - return -ENODEV; -} diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h deleted file mode 100644 index 47897e81ec58..000000000000 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h +++ /dev/null @@ -1,166 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Broadcom BM2835 V4L2 driver - * - * Copyright © 2013 Raspberry Pi (Trading) Ltd. - * - * Authors: Vincent Sanders @ Collabora - * Dave Stevenson @ Broadcom - * (now dave.stevenson@raspberrypi.org) - * Simon Mellor @ Broadcom - * Luke Diamand @ Broadcom - * - * MMAL interface to VCHIQ message passing - */ - -#ifndef MMAL_VCHIQ_H -#define MMAL_VCHIQ_H - -#include "mmal-msg-format.h" - -#define MAX_PORT_COUNT 4 - -/* Maximum size of the format extradata. */ -#define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128 - -struct vchiq_mmal_instance; - -enum vchiq_mmal_es_type { - MMAL_ES_TYPE_UNKNOWN, /**< Unknown elementary stream type */ - MMAL_ES_TYPE_CONTROL, /**< Elementary stream of control commands */ - MMAL_ES_TYPE_AUDIO, /**< Audio elementary stream */ - MMAL_ES_TYPE_VIDEO, /**< Video elementary stream */ - MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream */ -}; - -struct vchiq_mmal_port_buffer { - unsigned int num; /* number of buffers */ - u32 size; /* size of buffers */ - u32 alignment; /* alignment of buffers */ -}; - -struct vchiq_mmal_port; - -typedef void (*vchiq_mmal_buffer_cb)( - struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, - int status, struct mmal_buffer *buffer, - unsigned long length, u32 mmal_flags, s64 dts, s64 pts); - -struct vchiq_mmal_port { - u32 enabled:1; - u32 handle; - u32 type; /* port type, cached to use on port info set */ - u32 index; /* port index, cached to use on port info set */ - - /* component port belongs to, allows simple deref */ - struct vchiq_mmal_component *component; - - struct vchiq_mmal_port *connected; /* port connected to */ - - /* buffer info */ - struct vchiq_mmal_port_buffer minimum_buffer; - struct vchiq_mmal_port_buffer recommended_buffer; - struct vchiq_mmal_port_buffer current_buffer; - - /* stream format */ - struct mmal_es_format_local format; - /* elementary stream format */ - union mmal_es_specific_format es; - - /* data buffers to fill */ - struct list_head buffers; - /* lock to serialise adding and removing buffers from list */ - spinlock_t slock; - - /* Count of buffers the VPU has yet to return */ - atomic_t buffers_with_vpu; - /* callback on buffer completion */ - vchiq_mmal_buffer_cb buffer_cb; - /* callback context */ - void *cb_ctx; -}; - -struct vchiq_mmal_component { - u32 enabled:1; - u32 handle; /* VideoCore handle for component */ - u32 inputs; /* Number of input ports */ - u32 outputs; /* Number of output ports */ - u32 clocks; /* Number of clock ports */ - struct vchiq_mmal_port control; /* control port */ - struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */ - struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */ - struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */ -}; - -int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance); -int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance); - -/* Initialise a mmal component and its ports - * - */ -int vchiq_mmal_component_init( - struct vchiq_mmal_instance *instance, - const char *name, - struct vchiq_mmal_component **component_out); - -int vchiq_mmal_component_finalise( - struct vchiq_mmal_instance *instance, - struct vchiq_mmal_component *component); - -int vchiq_mmal_component_enable( - struct vchiq_mmal_instance *instance, - struct vchiq_mmal_component *component); - -int vchiq_mmal_component_disable( - struct vchiq_mmal_instance *instance, - struct vchiq_mmal_component *component); - -/* enable a mmal port - * - * enables a port and if a buffer callback provided enque buffer - * headers as appropriate for the port. - */ -int vchiq_mmal_port_enable( - struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, - vchiq_mmal_buffer_cb buffer_cb); - -/* disable a port - * - * disable a port will dequeue any pending buffers - */ -int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port); - -int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, - u32 parameter, - void *value, - u32 value_size); - -int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, - u32 parameter, - void *value, - u32 *value_size); - -int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port); - -int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *src, - struct vchiq_mmal_port *dst); - -int vchiq_mmal_version(struct vchiq_mmal_instance *instance, - u32 *major_out, - u32 *minor_out); - -int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port, - struct mmal_buffer *buf); - -int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance, - struct mmal_buffer *buf); -int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf); -#endif /* MMAL_VCHIQ_H */ diff --git a/drivers/staging/vc04_services/vchiq-mmal/Kconfig b/drivers/staging/vc04_services/vchiq-mmal/Kconfig new file mode 100644 index 000000000000..500c0d12e4ff --- /dev/null +++ b/drivers/staging/vc04_services/vchiq-mmal/Kconfig @@ -0,0 +1,7 @@ +config BCM2835_VCHIQ_MMAL + tristate "BCM2835 MMAL VCHIQ service" + depends on (ARCH_BCM2835 || COMPILE_TEST) + help + Enables the MMAL API over VCHIQ interface as used for the + majority of the multimedia services on VideoCore. + Defaults to Y when the Broadcomd BCM2835 camera host is selected. diff --git a/drivers/staging/vc04_services/vchiq-mmal/Makefile b/drivers/staging/vc04_services/vchiq-mmal/Makefile new file mode 100644 index 000000000000..f8164c33aec3 --- /dev/null +++ b/drivers/staging/vc04_services/vchiq-mmal/Makefile @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +bcm2835-mmal-vchiq-objs := mmal-vchiq.o + +obj-$(CONFIG_BCM2835_VCHIQ_MMAL) += bcm2835-mmal-vchiq.o + +ccflags-y += \ + -I$(srctree)/$(src)/.. \ + -D__VCCOREVER__=0x04000000 diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h new file mode 100644 index 000000000000..ce88fac7c24b --- /dev/null +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Broadcom BM2835 V4L2 driver + * + * Copyright © 2013 Raspberry Pi (Trading) Ltd. + * + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom + * + * MMAL structures + * + */ +#ifndef MMAL_COMMON_H +#define MMAL_COMMON_H + +#define MMAL_FOURCC(a, b, c, d) ((a) | (b << 8) | (c << 16) | (d << 24)) +#define MMAL_MAGIC MMAL_FOURCC('m', 'm', 'a', 'l') + +/** Special value signalling that time is not known */ +#define MMAL_TIME_UNKNOWN BIT_ULL(63) + +struct mmal_msg_context; + +/* mapping between v4l and mmal video modes */ +struct mmal_fmt { + u32 fourcc; /* v4l2 format id */ + int flags; /* v4l2 flags field */ + u32 mmal; + int depth; + u32 mmal_component; /* MMAL component index to be used to encode */ + u32 ybbp; /* depth of first Y plane for planar formats */ + bool remove_padding; /* Does the GPU have to remove padding, + * or can we do hide padding via bytesperline. + */ +}; + +/* buffer for one video frame */ +struct mmal_buffer { + /* v4l buffer data -- must be first */ + struct vb2_v4l2_buffer vb; + + /* list of buffers available */ + struct list_head list; + + void *buffer; /* buffer pointer */ + unsigned long buffer_size; /* size of allocated buffer */ + + struct mmal_msg_context *msg_context; +}; + +/* */ +struct mmal_colourfx { + s32 enable; + u32 u; + u32 v; +}; +#endif diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-encodings.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-encodings.h new file mode 100644 index 000000000000..2be9941a1f30 --- /dev/null +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-encodings.h @@ -0,0 +1,124 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Broadcom BM2835 V4L2 driver + * + * Copyright © 2013 Raspberry Pi (Trading) Ltd. + * + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom + */ +#ifndef MMAL_ENCODINGS_H +#define MMAL_ENCODINGS_H + +#define MMAL_ENCODING_H264 MMAL_FOURCC('H', '2', '6', '4') +#define MMAL_ENCODING_H263 MMAL_FOURCC('H', '2', '6', '3') +#define MMAL_ENCODING_MP4V MMAL_FOURCC('M', 'P', '4', 'V') +#define MMAL_ENCODING_MP2V MMAL_FOURCC('M', 'P', '2', 'V') +#define MMAL_ENCODING_MP1V MMAL_FOURCC('M', 'P', '1', 'V') +#define MMAL_ENCODING_WMV3 MMAL_FOURCC('W', 'M', 'V', '3') +#define MMAL_ENCODING_WMV2 MMAL_FOURCC('W', 'M', 'V', '2') +#define MMAL_ENCODING_WMV1 MMAL_FOURCC('W', 'M', 'V', '1') +#define MMAL_ENCODING_WVC1 MMAL_FOURCC('W', 'V', 'C', '1') +#define MMAL_ENCODING_VP8 MMAL_FOURCC('V', 'P', '8', ' ') +#define MMAL_ENCODING_VP7 MMAL_FOURCC('V', 'P', '7', ' ') +#define MMAL_ENCODING_VP6 MMAL_FOURCC('V', 'P', '6', ' ') +#define MMAL_ENCODING_THEORA MMAL_FOURCC('T', 'H', 'E', 'O') +#define MMAL_ENCODING_SPARK MMAL_FOURCC('S', 'P', 'R', 'K') +#define MMAL_ENCODING_MJPEG MMAL_FOURCC('M', 'J', 'P', 'G') + +#define MMAL_ENCODING_JPEG MMAL_FOURCC('J', 'P', 'E', 'G') +#define MMAL_ENCODING_GIF MMAL_FOURCC('G', 'I', 'F', ' ') +#define MMAL_ENCODING_PNG MMAL_FOURCC('P', 'N', 'G', ' ') +#define MMAL_ENCODING_PPM MMAL_FOURCC('P', 'P', 'M', ' ') +#define MMAL_ENCODING_TGA MMAL_FOURCC('T', 'G', 'A', ' ') +#define MMAL_ENCODING_BMP MMAL_FOURCC('B', 'M', 'P', ' ') + +#define MMAL_ENCODING_I420 MMAL_FOURCC('I', '4', '2', '0') +#define MMAL_ENCODING_I420_SLICE MMAL_FOURCC('S', '4', '2', '0') +#define MMAL_ENCODING_YV12 MMAL_FOURCC('Y', 'V', '1', '2') +#define MMAL_ENCODING_I422 MMAL_FOURCC('I', '4', '2', '2') +#define MMAL_ENCODING_I422_SLICE MMAL_FOURCC('S', '4', '2', '2') +#define MMAL_ENCODING_YUYV MMAL_FOURCC('Y', 'U', 'Y', 'V') +#define MMAL_ENCODING_YVYU MMAL_FOURCC('Y', 'V', 'Y', 'U') +#define MMAL_ENCODING_UYVY MMAL_FOURCC('U', 'Y', 'V', 'Y') +#define MMAL_ENCODING_VYUY MMAL_FOURCC('V', 'Y', 'U', 'Y') +#define MMAL_ENCODING_NV12 MMAL_FOURCC('N', 'V', '1', '2') +#define MMAL_ENCODING_NV21 MMAL_FOURCC('N', 'V', '2', '1') +#define MMAL_ENCODING_ARGB MMAL_FOURCC('A', 'R', 'G', 'B') +#define MMAL_ENCODING_RGBA MMAL_FOURCC('R', 'G', 'B', 'A') +#define MMAL_ENCODING_ABGR MMAL_FOURCC('A', 'B', 'G', 'R') +#define MMAL_ENCODING_BGRA MMAL_FOURCC('B', 'G', 'R', 'A') +#define MMAL_ENCODING_RGB16 MMAL_FOURCC('R', 'G', 'B', '2') +#define MMAL_ENCODING_RGB24 MMAL_FOURCC('R', 'G', 'B', '3') +#define MMAL_ENCODING_RGB32 MMAL_FOURCC('R', 'G', 'B', '4') +#define MMAL_ENCODING_BGR16 MMAL_FOURCC('B', 'G', 'R', '2') +#define MMAL_ENCODING_BGR24 MMAL_FOURCC('B', 'G', 'R', '3') +#define MMAL_ENCODING_BGR32 MMAL_FOURCC('B', 'G', 'R', '4') + +/** SAND Video (YUVUV128) format, native format understood by VideoCore. + * This format is *not* opaque - if requested you will receive full frames + * of YUV_UV video. + */ +#define MMAL_ENCODING_YUVUV128 MMAL_FOURCC('S', 'A', 'N', 'D') + +/** VideoCore opaque image format, image handles are returned to + * the host but not the actual image data. + */ +#define MMAL_ENCODING_OPAQUE MMAL_FOURCC('O', 'P', 'Q', 'V') + +/** An EGL image handle + */ +#define MMAL_ENCODING_EGL_IMAGE MMAL_FOURCC('E', 'G', 'L', 'I') + +/* }@ */ + +/** \name Pre-defined audio encodings */ +/* @{ */ +#define MMAL_ENCODING_PCM_UNSIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'U') +#define MMAL_ENCODING_PCM_UNSIGNED_LE MMAL_FOURCC('p', 'c', 'm', 'u') +#define MMAL_ENCODING_PCM_SIGNED_BE MMAL_FOURCC('P', 'C', 'M', 'S') +#define MMAL_ENCODING_PCM_SIGNED_LE MMAL_FOURCC('p', 'c', 'm', 's') +#define MMAL_ENCODING_PCM_FLOAT_BE MMAL_FOURCC('P', 'C', 'M', 'F') +#define MMAL_ENCODING_PCM_FLOAT_LE MMAL_FOURCC('p', 'c', 'm', 'f') + +/* Pre-defined H264 encoding variants */ + +/** ISO 14496-10 Annex B byte stream format */ +#define MMAL_ENCODING_VARIANT_H264_DEFAULT 0 +/** ISO 14496-15 AVC stream format */ +#define MMAL_ENCODING_VARIANT_H264_AVC1 MMAL_FOURCC('A', 'V', 'C', '1') +/** Implicitly delineated NAL units without emulation prevention */ +#define MMAL_ENCODING_VARIANT_H264_RAW MMAL_FOURCC('R', 'A', 'W', ' ') + +/** \defgroup MmalColorSpace List of pre-defined video color spaces + * This defines a list of common color spaces. This list isn't exhaustive and + * is only provided as a convenience to avoid clients having to use FourCC + * codes directly. However components are allowed to define and use their own + * FourCC codes. + */ +/* @{ */ + +/** Unknown color space */ +#define MMAL_COLOR_SPACE_UNKNOWN 0 +/** ITU-R BT.601-5 [SDTV] */ +#define MMAL_COLOR_SPACE_ITUR_BT601 MMAL_FOURCC('Y', '6', '0', '1') +/** ITU-R BT.709-3 [HDTV] */ +#define MMAL_COLOR_SPACE_ITUR_BT709 MMAL_FOURCC('Y', '7', '0', '9') +/** JPEG JFIF */ +#define MMAL_COLOR_SPACE_JPEG_JFIF MMAL_FOURCC('Y', 'J', 'F', 'I') +/** Title 47 Code of Federal Regulations (2003) 73.682 (a) (20) */ +#define MMAL_COLOR_SPACE_FCC MMAL_FOURCC('Y', 'F', 'C', 'C') +/** Society of Motion Picture and Television Engineers 240M (1999) */ +#define MMAL_COLOR_SPACE_SMPTE240M MMAL_FOURCC('Y', '2', '4', '0') +/** ITU-R BT.470-2 System M */ +#define MMAL_COLOR_SPACE_BT470_2_M MMAL_FOURCC('Y', '_', '_', 'M') +/** ITU-R BT.470-2 System BG */ +#define MMAL_COLOR_SPACE_BT470_2_BG MMAL_FOURCC('Y', '_', 'B', 'G') +/** JPEG JFIF, but with 16..255 luma */ +#define MMAL_COLOR_SPACE_JFIF_Y16_255 MMAL_FOURCC('Y', 'Y', '1', '6') +/* @} MmalColorSpace List */ + +#endif /* MMAL_ENCODINGS_H */ diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-common.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-common.h new file mode 100644 index 000000000000..342c9b670f7e --- /dev/null +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-common.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Broadcom BM2835 V4L2 driver + * + * Copyright © 2013 Raspberry Pi (Trading) Ltd. + * + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom + */ + +#ifndef MMAL_MSG_COMMON_H +#define MMAL_MSG_COMMON_H + +enum mmal_msg_status { + MMAL_MSG_STATUS_SUCCESS = 0, /**< Success */ + MMAL_MSG_STATUS_ENOMEM, /**< Out of memory */ + MMAL_MSG_STATUS_ENOSPC, /**< Out of resources other than memory */ + MMAL_MSG_STATUS_EINVAL, /**< Argument is invalid */ + MMAL_MSG_STATUS_ENOSYS, /**< Function not implemented */ + MMAL_MSG_STATUS_ENOENT, /**< No such file or directory */ + MMAL_MSG_STATUS_ENXIO, /**< No such device or address */ + MMAL_MSG_STATUS_EIO, /**< I/O error */ + MMAL_MSG_STATUS_ESPIPE, /**< Illegal seek */ + MMAL_MSG_STATUS_ECORRUPT, /**< Data is corrupt \attention */ + MMAL_MSG_STATUS_ENOTREADY, /**< Component is not ready */ + MMAL_MSG_STATUS_ECONFIG, /**< Component is not configured */ + MMAL_MSG_STATUS_EISCONN, /**< Port is already connected */ + MMAL_MSG_STATUS_ENOTCONN, /**< Port is disconnected */ + MMAL_MSG_STATUS_EAGAIN, /**< Resource temporarily unavailable. */ + MMAL_MSG_STATUS_EFAULT, /**< Bad address */ +}; + +struct mmal_rect { + s32 x; /**< x coordinate (from left) */ + s32 y; /**< y coordinate (from top) */ + s32 width; /**< width */ + s32 height; /**< height */ +}; + +struct mmal_rational { + s32 num; /**< Numerator */ + s32 den; /**< Denominator */ +}; + +#endif /* MMAL_MSG_COMMON_H */ diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-format.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-format.h new file mode 100644 index 000000000000..a118efd21d98 --- /dev/null +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-format.h @@ -0,0 +1,106 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Broadcom BM2835 V4L2 driver + * + * Copyright © 2013 Raspberry Pi (Trading) Ltd. + * + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom + */ + +#ifndef MMAL_MSG_FORMAT_H +#define MMAL_MSG_FORMAT_H + +#include "mmal-msg-common.h" + +/* MMAL_ES_FORMAT_T */ + +struct mmal_audio_format { + u32 channels; /* Number of audio channels */ + u32 sample_rate; /* Sample rate */ + + u32 bits_per_sample; /* Bits per sample */ + u32 block_align; /* Size of a block of data */ +}; + +struct mmal_video_format { + u32 width; /* Width of frame in pixels */ + u32 height; /* Height of frame in rows of pixels */ + struct mmal_rect crop; /* Visible region of the frame */ + struct mmal_rational frame_rate; /* Frame rate */ + struct mmal_rational par; /* Pixel aspect ratio */ + + /* + * FourCC specifying the color space of the video stream. See the + * MmalColorSpace "pre-defined color spaces" for some examples. + */ + u32 color_space; +}; + +struct mmal_subpicture_format { + u32 x_offset; + u32 y_offset; +}; + +union mmal_es_specific_format { + struct mmal_audio_format audio; + struct mmal_video_format video; + struct mmal_subpicture_format subpicture; +}; + +/* Definition of an elementary stream format (MMAL_ES_FORMAT_T) */ +struct mmal_es_format_local { + u32 type; /* enum mmal_es_type */ + + u32 encoding; /* FourCC specifying encoding of the elementary + * stream. + */ + u32 encoding_variant; /* FourCC specifying the specific + * encoding variant of the elementary + * stream. + */ + + union mmal_es_specific_format *es; /* Type specific + * information for the + * elementary stream + */ + + u32 bitrate; /* Bitrate in bits per second */ + u32 flags; /* Flags describing properties of the elementary + * stream. + */ + + u32 extradata_size; /* Size of the codec specific data */ + u8 *extradata; /* Codec specific data */ +}; + +/* Remote definition of an elementary stream format (MMAL_ES_FORMAT_T) */ +struct mmal_es_format { + u32 type; /* enum mmal_es_type */ + + u32 encoding; /* FourCC specifying encoding of the elementary + * stream. + */ + u32 encoding_variant; /* FourCC specifying the specific + * encoding variant of the elementary + * stream. + */ + + u32 es; /* Type specific + * information for the + * elementary stream + */ + + u32 bitrate; /* Bitrate in bits per second */ + u32 flags; /* Flags describing properties of the elementary + * stream. + */ + + u32 extradata_size; /* Size of the codec specific data */ + u32 extradata; /* Codec specific data */ +}; + +#endif /* MMAL_MSG_FORMAT_H */ diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-port.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-port.h new file mode 100644 index 000000000000..3fa3f2a578f0 --- /dev/null +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg-port.h @@ -0,0 +1,109 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Broadcom BM2835 V4L2 driver + * + * Copyright © 2013 Raspberry Pi (Trading) Ltd. + * + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom + */ + +/* MMAL_PORT_TYPE_T */ +enum mmal_port_type { + MMAL_PORT_TYPE_UNKNOWN = 0, /* Unknown port type */ + MMAL_PORT_TYPE_CONTROL, /* Control port */ + MMAL_PORT_TYPE_INPUT, /* Input port */ + MMAL_PORT_TYPE_OUTPUT, /* Output port */ + MMAL_PORT_TYPE_CLOCK, /* Clock port */ +}; + +/* The port is pass-through and doesn't need buffer headers allocated */ +#define MMAL_PORT_CAPABILITY_PASSTHROUGH 0x01 +/* + *The port wants to allocate the buffer payloads. + * This signals a preference that payload allocation should be done + * on this port for efficiency reasons. + */ +#define MMAL_PORT_CAPABILITY_ALLOCATION 0x02 +/* + * The port supports format change events. + * This applies to input ports and is used to let the client know + * whether the port supports being reconfigured via a format + * change event (i.e. without having to disable the port). + */ +#define MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE 0x04 + +/* + * mmal port structure (MMAL_PORT_T) + * + * most elements are informational only, the pointer values for + * interogation messages are generally provided as additional + * structures within the message. When used to set values only the + * buffer_num, buffer_size and userdata parameters are writable. + */ +struct mmal_port { + u32 priv; /* Private member used by the framework */ + u32 name; /* Port name. Used for debugging purposes (RO) */ + + u32 type; /* Type of the port (RO) enum mmal_port_type */ + u16 index; /* Index of the port in its type list (RO) */ + u16 index_all; /* Index of the port in the list of all ports (RO) */ + + u32 is_enabled; /* Indicates whether the port is enabled or not (RO) */ + u32 format; /* Format of the elementary stream */ + + u32 buffer_num_min; /* Minimum number of buffers the port + * requires (RO). This is set by the + * component. + */ + + u32 buffer_size_min; /* Minimum size of buffers the port + * requires (RO). This is set by the + * component. + */ + + u32 buffer_alignment_min;/* Minimum alignment requirement for + * the buffers (RO). A value of + * zero means no special alignment + * requirements. This is set by the + * component. + */ + + u32 buffer_num_recommended; /* Number of buffers the port + * recommends for optimal + * performance (RO). A value of + * zero means no special + * recommendation. This is set + * by the component. + */ + + u32 buffer_size_recommended; /* Size of buffers the port + * recommends for optimal + * performance (RO). A value of + * zero means no special + * recommendation. This is set + * by the component. + */ + + u32 buffer_num; /* Actual number of buffers the port will use. + * This is set by the client. + */ + + u32 buffer_size; /* Actual maximum size of the buffers that + * will be sent to the port. This is set by + * the client. + */ + + u32 component; /* Component this port belongs to (Read Only) */ + + u32 userdata; /* Field reserved for use by the client */ + + u32 capabilities; /* Flags describing the capabilities of a + * port (RO). Bitwise combination of \ref + * portcapabilities "Port capabilities" + * values. + */ +}; diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h new file mode 100644 index 000000000000..43cc59316f90 --- /dev/null +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h @@ -0,0 +1,406 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Broadcom BM2835 V4L2 driver + * + * Copyright © 2013 Raspberry Pi (Trading) Ltd. + * + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom + */ + +/* + * all the data structures which serialise the MMAL protocol. note + * these are directly mapped onto the recived message data. + * + * BEWARE: They seem to *assume* pointers are u32 and that there is no + * structure padding! + * + * NOTE: this implementation uses kernel types to ensure sizes. Rather + * than assigning values to enums to force their size the + * implementation uses fixed size types and not the enums (though the + * comments have the actual enum type + */ +#ifndef MMAL_MSG_H +#define MMAL_MSG_H + +#define VC_MMAL_VER 15 +#define VC_MMAL_MIN_VER 10 +#define VC_MMAL_SERVER_NAME MAKE_FOURCC("mmal") + +/* max total message size is 512 bytes */ +#define MMAL_MSG_MAX_SIZE 512 +/* with six 32bit header elements max payload is therefore 488 bytes */ +#define MMAL_MSG_MAX_PAYLOAD 488 + +#include "mmal-msg-common.h" +#include "mmal-msg-format.h" +#include "mmal-msg-port.h" + +enum mmal_msg_type { + MMAL_MSG_TYPE_QUIT = 1, + MMAL_MSG_TYPE_SERVICE_CLOSED, + MMAL_MSG_TYPE_GET_VERSION, + MMAL_MSG_TYPE_COMPONENT_CREATE, + MMAL_MSG_TYPE_COMPONENT_DESTROY, /* 5 */ + MMAL_MSG_TYPE_COMPONENT_ENABLE, + MMAL_MSG_TYPE_COMPONENT_DISABLE, + MMAL_MSG_TYPE_PORT_INFO_GET, + MMAL_MSG_TYPE_PORT_INFO_SET, + MMAL_MSG_TYPE_PORT_ACTION, /* 10 */ + MMAL_MSG_TYPE_BUFFER_FROM_HOST, + MMAL_MSG_TYPE_BUFFER_TO_HOST, + MMAL_MSG_TYPE_GET_STATS, + MMAL_MSG_TYPE_PORT_PARAMETER_SET, + MMAL_MSG_TYPE_PORT_PARAMETER_GET, /* 15 */ + MMAL_MSG_TYPE_EVENT_TO_HOST, + MMAL_MSG_TYPE_GET_CORE_STATS_FOR_PORT, + MMAL_MSG_TYPE_OPAQUE_ALLOCATOR, + MMAL_MSG_TYPE_CONSUME_MEM, + MMAL_MSG_TYPE_LMK, /* 20 */ + MMAL_MSG_TYPE_OPAQUE_ALLOCATOR_DESC, + MMAL_MSG_TYPE_DRM_GET_LHS32, + MMAL_MSG_TYPE_DRM_GET_TIME, + MMAL_MSG_TYPE_BUFFER_FROM_HOST_ZEROLEN, + MMAL_MSG_TYPE_PORT_FLUSH, /* 25 */ + MMAL_MSG_TYPE_HOST_LOG, + MMAL_MSG_TYPE_MSG_LAST +}; + +/* port action request messages differ depending on the action type */ +enum mmal_msg_port_action_type { + MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unknown action */ + MMAL_MSG_PORT_ACTION_TYPE_ENABLE, /* Enable a port */ + MMAL_MSG_PORT_ACTION_TYPE_DISABLE, /* Disable a port */ + MMAL_MSG_PORT_ACTION_TYPE_FLUSH, /* Flush a port */ + MMAL_MSG_PORT_ACTION_TYPE_CONNECT, /* Connect ports */ + MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT, /* Disconnect ports */ + MMAL_MSG_PORT_ACTION_TYPE_SET_REQUIREMENTS, /* Set buffer requirements*/ +}; + +struct mmal_msg_header { + u32 magic; + u32 type; /* enum mmal_msg_type */ + + /* Opaque handle to the control service */ + u32 control_service; + + u32 context; /* a u32 per message context */ + u32 status; /* The status of the vchiq operation */ + u32 padding; +}; + +/* Send from VC to host to report version */ +struct mmal_msg_version { + u32 flags; + u32 major; + u32 minor; + u32 minimum; +}; + +/* request to VC to create component */ +struct mmal_msg_component_create { + u32 client_component; /* component context */ + char name[128]; + u32 pid; /* For debug */ +}; + +/* reply from VC to component creation request */ +struct mmal_msg_component_create_reply { + u32 status; /* enum mmal_msg_status - how does this differ to + * the one in the header? + */ + u32 component_handle; /* VideoCore handle for component */ + u32 input_num; /* Number of input ports */ + u32 output_num; /* Number of output ports */ + u32 clock_num; /* Number of clock ports */ +}; + +/* request to VC to destroy a component */ +struct mmal_msg_component_destroy { + u32 component_handle; +}; + +struct mmal_msg_component_destroy_reply { + u32 status; /* The component destruction status */ +}; + +/* request and reply to VC to enable a component */ +struct mmal_msg_component_enable { + u32 component_handle; +}; + +struct mmal_msg_component_enable_reply { + u32 status; /* The component enable status */ +}; + +/* request and reply to VC to disable a component */ +struct mmal_msg_component_disable { + u32 component_handle; +}; + +struct mmal_msg_component_disable_reply { + u32 status; /* The component disable status */ +}; + +/* request to VC to get port information */ +struct mmal_msg_port_info_get { + u32 component_handle; /* component handle port is associated with */ + u32 port_type; /* enum mmal_msg_port_type */ + u32 index; /* port index to query */ +}; + +/* reply from VC to get port info request */ +struct mmal_msg_port_info_get_reply { + u32 status; /* enum mmal_msg_status */ + u32 component_handle; /* component handle port is associated with */ + u32 port_type; /* enum mmal_msg_port_type */ + u32 port_index; /* port indexed in query */ + s32 found; /* unused */ + u32 port_handle; /* Handle to use for this port */ + struct mmal_port port; + struct mmal_es_format format; /* elementary stream format */ + union mmal_es_specific_format es; /* es type specific data */ + u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; /* es extra data */ +}; + +/* request to VC to set port information */ +struct mmal_msg_port_info_set { + u32 component_handle; + u32 port_type; /* enum mmal_msg_port_type */ + u32 port_index; /* port indexed in query */ + struct mmal_port port; + struct mmal_es_format format; + union mmal_es_specific_format es; + u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; +}; + +/* reply from VC to port info set request */ +struct mmal_msg_port_info_set_reply { + u32 status; + u32 component_handle; /* component handle port is associated with */ + u32 port_type; /* enum mmal_msg_port_type */ + u32 index; /* port indexed in query */ + s32 found; /* unused */ + u32 port_handle; /* Handle to use for this port */ + struct mmal_port port; + struct mmal_es_format format; + union mmal_es_specific_format es; + u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; +}; + +/* port action requests that take a mmal_port as a parameter */ +struct mmal_msg_port_action_port { + u32 component_handle; + u32 port_handle; + u32 action; /* enum mmal_msg_port_action_type */ + struct mmal_port port; +}; + +/* port action requests that take handles as a parameter */ +struct mmal_msg_port_action_handle { + u32 component_handle; + u32 port_handle; + u32 action; /* enum mmal_msg_port_action_type */ + u32 connect_component_handle; + u32 connect_port_handle; +}; + +struct mmal_msg_port_action_reply { + u32 status; /* The port action operation status */ +}; + +/* MMAL buffer transfer */ + +/* Size of space reserved in a buffer message for short messages. */ +#define MMAL_VC_SHORT_DATA 128 + +/* Signals that the current payload is the end of the stream of data */ +#define MMAL_BUFFER_HEADER_FLAG_EOS BIT(0) +/* Signals that the start of the current payload starts a frame */ +#define MMAL_BUFFER_HEADER_FLAG_FRAME_START BIT(1) +/* Signals that the end of the current payload ends a frame */ +#define MMAL_BUFFER_HEADER_FLAG_FRAME_END BIT(2) +/* Signals that the current payload contains only complete frames (>1) */ +#define MMAL_BUFFER_HEADER_FLAG_FRAME \ + (MMAL_BUFFER_HEADER_FLAG_FRAME_START | \ + MMAL_BUFFER_HEADER_FLAG_FRAME_END) +/* Signals that the current payload is a keyframe (i.e. self decodable) */ +#define MMAL_BUFFER_HEADER_FLAG_KEYFRAME BIT(3) +/* + * Signals a discontinuity in the stream of data (e.g. after a seek). + * Can be used for instance by a decoder to reset its state + */ +#define MMAL_BUFFER_HEADER_FLAG_DISCONTINUITY BIT(4) +/* + * Signals a buffer containing some kind of config data for the component + * (e.g. codec config data) + */ +#define MMAL_BUFFER_HEADER_FLAG_CONFIG BIT(5) +/* Signals an encrypted payload */ +#define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED BIT(6) +/* Signals a buffer containing side information */ +#define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO BIT(7) +/* + * Signals a buffer which is the snapshot/postview image from a stills + * capture + */ +#define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT BIT(8) +/* Signals a buffer which contains data known to be corrupted */ +#define MMAL_BUFFER_HEADER_FLAG_CORRUPTED BIT(9) +/* Signals that a buffer failed to be transmitted */ +#define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED BIT(10) + +struct mmal_driver_buffer { + u32 magic; + u32 component_handle; + u32 port_handle; + u32 client_context; +}; + +/* buffer header */ +struct mmal_buffer_header { + u32 next; /* next header */ + u32 priv; /* framework private data */ + u32 cmd; + u32 data; + u32 alloc_size; + u32 length; + u32 offset; + u32 flags; + s64 pts; + s64 dts; + u32 type; + u32 user_data; +}; + +struct mmal_buffer_header_type_specific { + union { + struct { + u32 planes; + u32 offset[4]; + u32 pitch[4]; + u32 flags; + } video; + } u; +}; + +struct mmal_msg_buffer_from_host { + /* + *The front 32 bytes of the buffer header are copied + * back to us in the reply to allow for context. This + * area is used to store two mmal_driver_buffer structures to + * allow for multiple concurrent service users. + */ + /* control data */ + struct mmal_driver_buffer drvbuf; + + /* referenced control data for passthrough buffer management */ + struct mmal_driver_buffer drvbuf_ref; + struct mmal_buffer_header buffer_header; /* buffer header itself */ + struct mmal_buffer_header_type_specific buffer_header_type_specific; + s32 is_zero_copy; + s32 has_reference; + + /* allows short data to be xfered in control message */ + u32 payload_in_message; + u8 short_data[MMAL_VC_SHORT_DATA]; +}; + +/* port parameter setting */ + +#define MMAL_WORKER_PORT_PARAMETER_SPACE 96 + +struct mmal_msg_port_parameter_set { + u32 component_handle; /* component */ + u32 port_handle; /* port */ + u32 id; /* Parameter ID */ + u32 size; /* Parameter size */ + u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE]; +}; + +struct mmal_msg_port_parameter_set_reply { + u32 status; /* enum mmal_msg_status todo: how does this + * differ to the one in the header? + */ +}; + +/* port parameter getting */ + +struct mmal_msg_port_parameter_get { + u32 component_handle; /* component */ + u32 port_handle; /* port */ + u32 id; /* Parameter ID */ + u32 size; /* Parameter size */ +}; + +struct mmal_msg_port_parameter_get_reply { + u32 status; /* Status of mmal_port_parameter_get call */ + u32 id; /* Parameter ID */ + u32 size; /* Parameter size */ + u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE]; +}; + +/* event messages */ +#define MMAL_WORKER_EVENT_SPACE 256 + +struct mmal_msg_event_to_host { + u32 client_component; /* component context */ + + u32 port_type; + u32 port_num; + + u32 cmd; + u32 length; + u8 data[MMAL_WORKER_EVENT_SPACE]; + u32 delayed_buffer; +}; + +/* all mmal messages are serialised through this structure */ +struct mmal_msg { + /* header */ + struct mmal_msg_header h; + /* payload */ + union { + struct mmal_msg_version version; + + struct mmal_msg_component_create component_create; + struct mmal_msg_component_create_reply component_create_reply; + + struct mmal_msg_component_destroy component_destroy; + struct mmal_msg_component_destroy_reply component_destroy_reply; + + struct mmal_msg_component_enable component_enable; + struct mmal_msg_component_enable_reply component_enable_reply; + + struct mmal_msg_component_disable component_disable; + struct mmal_msg_component_disable_reply component_disable_reply; + + struct mmal_msg_port_info_get port_info_get; + struct mmal_msg_port_info_get_reply port_info_get_reply; + + struct mmal_msg_port_info_set port_info_set; + struct mmal_msg_port_info_set_reply port_info_set_reply; + + struct mmal_msg_port_action_port port_action_port; + struct mmal_msg_port_action_handle port_action_handle; + struct mmal_msg_port_action_reply port_action_reply; + + struct mmal_msg_buffer_from_host buffer_from_host; + + struct mmal_msg_port_parameter_set port_parameter_set; + struct mmal_msg_port_parameter_set_reply + port_parameter_set_reply; + struct mmal_msg_port_parameter_get + port_parameter_get; + struct mmal_msg_port_parameter_get_reply + port_parameter_get_reply; + + struct mmal_msg_event_to_host event_to_host; + + u8 payload[MMAL_MSG_MAX_PAYLOAD]; + } u; +}; +#endif diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h new file mode 100644 index 000000000000..f4ac5a6149ea --- /dev/null +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h @@ -0,0 +1,755 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Broadcom BM2835 V4L2 driver + * + * Copyright © 2013 Raspberry Pi (Trading) Ltd. + * + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom + */ + +/* common parameters */ + +/** @name Parameter groups + * Parameters are divided into groups, and then allocated sequentially within + * a group using an enum. + * @{ + */ + +#ifndef MMAL_PARAMETERS_H +#define MMAL_PARAMETERS_H + +/** Common parameter ID group, used with many types of component. */ +#define MMAL_PARAMETER_GROUP_COMMON (0 << 16) +/** Camera-specific parameter ID group. */ +#define MMAL_PARAMETER_GROUP_CAMERA (1 << 16) +/** Video-specific parameter ID group. */ +#define MMAL_PARAMETER_GROUP_VIDEO (2 << 16) +/** Audio-specific parameter ID group. */ +#define MMAL_PARAMETER_GROUP_AUDIO (3 << 16) +/** Clock-specific parameter ID group. */ +#define MMAL_PARAMETER_GROUP_CLOCK (4 << 16) +/** Miracast-specific parameter ID group. */ +#define MMAL_PARAMETER_GROUP_MIRACAST (5 << 16) + +/* Common parameters */ +enum mmal_parameter_common_type { + /**< Never a valid parameter ID */ + MMAL_PARAMETER_UNUSED = MMAL_PARAMETER_GROUP_COMMON, + + /**< MMAL_PARAMETER_ENCODING_T */ + MMAL_PARAMETER_SUPPORTED_ENCODINGS, + /**< MMAL_PARAMETER_URI_T */ + MMAL_PARAMETER_URI, + /** MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T */ + MMAL_PARAMETER_CHANGE_EVENT_REQUEST, + /** MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_ZERO_COPY, + /**< MMAL_PARAMETER_BUFFER_REQUIREMENTS_T */ + MMAL_PARAMETER_BUFFER_REQUIREMENTS, + /**< MMAL_PARAMETER_STATISTICS_T */ + MMAL_PARAMETER_STATISTICS, + /**< MMAL_PARAMETER_CORE_STATISTICS_T */ + MMAL_PARAMETER_CORE_STATISTICS, + /**< MMAL_PARAMETER_MEM_USAGE_T */ + MMAL_PARAMETER_MEM_USAGE, + /**< MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_BUFFER_FLAG_FILTER, + /**< MMAL_PARAMETER_SEEK_T */ + MMAL_PARAMETER_SEEK, + /**< MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_POWERMON_ENABLE, + /**< MMAL_PARAMETER_LOGGING_T */ + MMAL_PARAMETER_LOGGING, + /**< MMAL_PARAMETER_UINT64_T */ + MMAL_PARAMETER_SYSTEM_TIME, + /**< MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_NO_IMAGE_PADDING, +}; + +/* camera parameters */ + +enum mmal_parameter_camera_type { + /* 0 */ + /** @ref MMAL_PARAMETER_THUMBNAIL_CONFIG_T */ + MMAL_PARAMETER_THUMBNAIL_CONFIGURATION = + MMAL_PARAMETER_GROUP_CAMERA, + /**< Unused? */ + MMAL_PARAMETER_CAPTURE_QUALITY, + /**< @ref MMAL_PARAMETER_INT32_T */ + MMAL_PARAMETER_ROTATION, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_EXIF_DISABLE, + /**< @ref MMAL_PARAMETER_EXIF_T */ + MMAL_PARAMETER_EXIF, + /**< @ref MMAL_PARAM_AWBMODE_T */ + MMAL_PARAMETER_AWB_MODE, + /**< @ref MMAL_PARAMETER_IMAGEFX_T */ + MMAL_PARAMETER_IMAGE_EFFECT, + /**< @ref MMAL_PARAMETER_COLOURFX_T */ + MMAL_PARAMETER_COLOUR_EFFECT, + /**< @ref MMAL_PARAMETER_FLICKERAVOID_T */ + MMAL_PARAMETER_FLICKER_AVOID, + /**< @ref MMAL_PARAMETER_FLASH_T */ + MMAL_PARAMETER_FLASH, + /**< @ref MMAL_PARAMETER_REDEYE_T */ + MMAL_PARAMETER_REDEYE, + /**< @ref MMAL_PARAMETER_FOCUS_T */ + MMAL_PARAMETER_FOCUS, + /**< Unused? */ + MMAL_PARAMETER_FOCAL_LENGTHS, + /**< @ref MMAL_PARAMETER_INT32_T */ + MMAL_PARAMETER_EXPOSURE_COMP, + /**< @ref MMAL_PARAMETER_SCALEFACTOR_T */ + MMAL_PARAMETER_ZOOM, + /**< @ref MMAL_PARAMETER_MIRROR_T */ + MMAL_PARAMETER_MIRROR, + + /* 0x10 */ + /**< @ref MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_CAMERA_NUM, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_CAPTURE, + /**< @ref MMAL_PARAMETER_EXPOSUREMODE_T */ + MMAL_PARAMETER_EXPOSURE_MODE, + /**< @ref MMAL_PARAMETER_EXPOSUREMETERINGMODE_T */ + MMAL_PARAMETER_EXP_METERING_MODE, + /**< @ref MMAL_PARAMETER_FOCUS_STATUS_T */ + MMAL_PARAMETER_FOCUS_STATUS, + /**< @ref MMAL_PARAMETER_CAMERA_CONFIG_T */ + MMAL_PARAMETER_CAMERA_CONFIG, + /**< @ref MMAL_PARAMETER_CAPTURE_STATUS_T */ + MMAL_PARAMETER_CAPTURE_STATUS, + /**< @ref MMAL_PARAMETER_FACE_TRACK_T */ + MMAL_PARAMETER_FACE_TRACK, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS, + /**< @ref MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_JPEG_Q_FACTOR, + /**< @ref MMAL_PARAMETER_FRAME_RATE_T */ + MMAL_PARAMETER_FRAME_RATE, + /**< @ref MMAL_PARAMETER_CAMERA_STC_MODE_T */ + MMAL_PARAMETER_USE_STC, + /**< @ref MMAL_PARAMETER_CAMERA_INFO_T */ + MMAL_PARAMETER_CAMERA_INFO, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_VIDEO_STABILISATION, + /**< @ref MMAL_PARAMETER_FACE_TRACK_RESULTS_T */ + MMAL_PARAMETER_FACE_TRACK_RESULTS, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_ENABLE_RAW_CAPTURE, + + /* 0x20 */ + /**< @ref MMAL_PARAMETER_URI_T */ + MMAL_PARAMETER_DPF_FILE, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_ENABLE_DPF_FILE, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_DPF_FAIL_IS_FATAL, + /**< @ref MMAL_PARAMETER_CAPTUREMODE_T */ + MMAL_PARAMETER_CAPTURE_MODE, + /**< @ref MMAL_PARAMETER_FOCUS_REGIONS_T */ + MMAL_PARAMETER_FOCUS_REGIONS, + /**< @ref MMAL_PARAMETER_INPUT_CROP_T */ + MMAL_PARAMETER_INPUT_CROP, + /**< @ref MMAL_PARAMETER_SENSOR_INFORMATION_T */ + MMAL_PARAMETER_SENSOR_INFORMATION, + /**< @ref MMAL_PARAMETER_FLASH_SELECT_T */ + MMAL_PARAMETER_FLASH_SELECT, + /**< @ref MMAL_PARAMETER_FIELD_OF_VIEW_T */ + MMAL_PARAMETER_FIELD_OF_VIEW, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_HIGH_DYNAMIC_RANGE, + /**< @ref MMAL_PARAMETER_DRC_T */ + MMAL_PARAMETER_DYNAMIC_RANGE_COMPRESSION, + /**< @ref MMAL_PARAMETER_ALGORITHM_CONTROL_T */ + MMAL_PARAMETER_ALGORITHM_CONTROL, + /**< @ref MMAL_PARAMETER_RATIONAL_T */ + MMAL_PARAMETER_SHARPNESS, + /**< @ref MMAL_PARAMETER_RATIONAL_T */ + MMAL_PARAMETER_CONTRAST, + /**< @ref MMAL_PARAMETER_RATIONAL_T */ + MMAL_PARAMETER_BRIGHTNESS, + /**< @ref MMAL_PARAMETER_RATIONAL_T */ + MMAL_PARAMETER_SATURATION, + + /* 0x30 */ + /**< @ref MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_ISO, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_ANTISHAKE, + /** @ref MMAL_PARAMETER_IMAGEFX_PARAMETERS_T */ + MMAL_PARAMETER_IMAGE_EFFECT_PARAMETERS, + /** @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_CAMERA_BURST_CAPTURE, + /** @ref MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_CAMERA_MIN_ISO, + /** @ref MMAL_PARAMETER_CAMERA_USE_CASE_T */ + MMAL_PARAMETER_CAMERA_USE_CASE, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_CAPTURE_STATS_PASS, + /** @ref MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG, + /** @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_ENABLE_REGISTER_FILE, + /** @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_REGISTER_FAIL_IS_FATAL, + /** @ref MMAL_PARAMETER_CONFIGFILE_T */ + MMAL_PARAMETER_CONFIGFILE_REGISTERS, + /** @ref MMAL_PARAMETER_CONFIGFILE_CHUNK_T */ + MMAL_PARAMETER_CONFIGFILE_CHUNK_REGISTERS, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_JPEG_ATTACH_LOG, + /**< @ref MMAL_PARAMETER_ZEROSHUTTERLAG_T */ + MMAL_PARAMETER_ZERO_SHUTTER_LAG, + /**< @ref MMAL_PARAMETER_FPS_RANGE_T */ + MMAL_PARAMETER_FPS_RANGE, + /**< @ref MMAL_PARAMETER_INT32_T */ + MMAL_PARAMETER_CAPTURE_EXPOSURE_COMP, + + /* 0x40 */ + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_SW_SHARPEN_DISABLE, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_FLASH_REQUIRED, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_SW_SATURATION_DISABLE, + /**< Takes a @ref MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_SHUTTER_SPEED, + /**< Takes a @ref MMAL_PARAMETER_AWB_GAINS_T */ + MMAL_PARAMETER_CUSTOM_AWB_GAINS, +}; + +struct mmal_parameter_rational { + s32 num; /**< Numerator */ + s32 den; /**< Denominator */ +}; + +enum mmal_parameter_camera_config_timestamp_mode { + MMAL_PARAM_TIMESTAMP_MODE_ZERO = 0, /* Always timestamp frames as 0 */ + MMAL_PARAM_TIMESTAMP_MODE_RAW_STC, /* Use the raw STC value + * for the frame timestamp + */ + MMAL_PARAM_TIMESTAMP_MODE_RESET_STC, /* Use the STC timestamp + * but subtract the + * timestamp of the first + * frame sent to give a + * zero based timestamp. + */ +}; + +struct mmal_parameter_fps_range { + /**< Low end of the permitted framerate range */ + struct mmal_parameter_rational fps_low; + /**< High end of the permitted framerate range */ + struct mmal_parameter_rational fps_high; +}; + +/* camera configuration parameter */ +struct mmal_parameter_camera_config { + /* Parameters for setting up the image pools */ + u32 max_stills_w; /* Max size of stills capture */ + u32 max_stills_h; + u32 stills_yuv422; /* Allow YUV422 stills capture */ + u32 one_shot_stills; /* Continuous or one shot stills captures. */ + + u32 max_preview_video_w; /* Max size of the preview or video + * capture frames + */ + u32 max_preview_video_h; + u32 num_preview_video_frames; + + /** Sets the height of the circular buffer for stills capture. */ + u32 stills_capture_circular_buffer_height; + + /** Allows preview/encode to resume as fast as possible after the stills + * input frame has been received, and then processes the still frame in + * the background whilst preview/encode has resumed. + * Actual mode is controlled by MMAL_PARAMETER_CAPTURE_MODE. + */ + u32 fast_preview_resume; + + /** Selects algorithm for timestamping frames if + * there is no clock component connected. + * enum mmal_parameter_camera_config_timestamp_mode + */ + s32 use_stc_timestamp; +}; + +enum mmal_parameter_exposuremode { + MMAL_PARAM_EXPOSUREMODE_OFF, + MMAL_PARAM_EXPOSUREMODE_AUTO, + MMAL_PARAM_EXPOSUREMODE_NIGHT, + MMAL_PARAM_EXPOSUREMODE_NIGHTPREVIEW, + MMAL_PARAM_EXPOSUREMODE_BACKLIGHT, + MMAL_PARAM_EXPOSUREMODE_SPOTLIGHT, + MMAL_PARAM_EXPOSUREMODE_SPORTS, + MMAL_PARAM_EXPOSUREMODE_SNOW, + MMAL_PARAM_EXPOSUREMODE_BEACH, + MMAL_PARAM_EXPOSUREMODE_VERYLONG, + MMAL_PARAM_EXPOSUREMODE_FIXEDFPS, + MMAL_PARAM_EXPOSUREMODE_ANTISHAKE, + MMAL_PARAM_EXPOSUREMODE_FIREWORKS, +}; + +enum mmal_parameter_exposuremeteringmode { + MMAL_PARAM_EXPOSUREMETERINGMODE_AVERAGE, + MMAL_PARAM_EXPOSUREMETERINGMODE_SPOT, + MMAL_PARAM_EXPOSUREMETERINGMODE_BACKLIT, + MMAL_PARAM_EXPOSUREMETERINGMODE_MATRIX, +}; + +enum mmal_parameter_awbmode { + MMAL_PARAM_AWBMODE_OFF, + MMAL_PARAM_AWBMODE_AUTO, + MMAL_PARAM_AWBMODE_SUNLIGHT, + MMAL_PARAM_AWBMODE_CLOUDY, + MMAL_PARAM_AWBMODE_SHADE, + MMAL_PARAM_AWBMODE_TUNGSTEN, + MMAL_PARAM_AWBMODE_FLUORESCENT, + MMAL_PARAM_AWBMODE_INCANDESCENT, + MMAL_PARAM_AWBMODE_FLASH, + MMAL_PARAM_AWBMODE_HORIZON, +}; + +enum mmal_parameter_imagefx { + MMAL_PARAM_IMAGEFX_NONE, + MMAL_PARAM_IMAGEFX_NEGATIVE, + MMAL_PARAM_IMAGEFX_SOLARIZE, + MMAL_PARAM_IMAGEFX_POSTERIZE, + MMAL_PARAM_IMAGEFX_WHITEBOARD, + MMAL_PARAM_IMAGEFX_BLACKBOARD, + MMAL_PARAM_IMAGEFX_SKETCH, + MMAL_PARAM_IMAGEFX_DENOISE, + MMAL_PARAM_IMAGEFX_EMBOSS, + MMAL_PARAM_IMAGEFX_OILPAINT, + MMAL_PARAM_IMAGEFX_HATCH, + MMAL_PARAM_IMAGEFX_GPEN, + MMAL_PARAM_IMAGEFX_PASTEL, + MMAL_PARAM_IMAGEFX_WATERCOLOUR, + MMAL_PARAM_IMAGEFX_FILM, + MMAL_PARAM_IMAGEFX_BLUR, + MMAL_PARAM_IMAGEFX_SATURATION, + MMAL_PARAM_IMAGEFX_COLOURSWAP, + MMAL_PARAM_IMAGEFX_WASHEDOUT, + MMAL_PARAM_IMAGEFX_POSTERISE, + MMAL_PARAM_IMAGEFX_COLOURPOINT, + MMAL_PARAM_IMAGEFX_COLOURBALANCE, + MMAL_PARAM_IMAGEFX_CARTOON, +}; + +enum MMAL_PARAM_FLICKERAVOID_T { + MMAL_PARAM_FLICKERAVOID_OFF, + MMAL_PARAM_FLICKERAVOID_AUTO, + MMAL_PARAM_FLICKERAVOID_50HZ, + MMAL_PARAM_FLICKERAVOID_60HZ, + MMAL_PARAM_FLICKERAVOID_MAX = 0x7FFFFFFF +}; + +struct mmal_parameter_awbgains { + struct mmal_parameter_rational r_gain; /**< Red gain */ + struct mmal_parameter_rational b_gain; /**< Blue gain */ +}; + +/** Manner of video rate control */ +enum mmal_parameter_rate_control_mode { + MMAL_VIDEO_RATECONTROL_DEFAULT, + MMAL_VIDEO_RATECONTROL_VARIABLE, + MMAL_VIDEO_RATECONTROL_CONSTANT, + MMAL_VIDEO_RATECONTROL_VARIABLE_SKIP_FRAMES, + MMAL_VIDEO_RATECONTROL_CONSTANT_SKIP_FRAMES +}; + +enum mmal_video_profile { + MMAL_VIDEO_PROFILE_H263_BASELINE, + MMAL_VIDEO_PROFILE_H263_H320CODING, + MMAL_VIDEO_PROFILE_H263_BACKWARDCOMPATIBLE, + MMAL_VIDEO_PROFILE_H263_ISWV2, + MMAL_VIDEO_PROFILE_H263_ISWV3, + MMAL_VIDEO_PROFILE_H263_HIGHCOMPRESSION, + MMAL_VIDEO_PROFILE_H263_INTERNET, + MMAL_VIDEO_PROFILE_H263_INTERLACE, + MMAL_VIDEO_PROFILE_H263_HIGHLATENCY, + MMAL_VIDEO_PROFILE_MP4V_SIMPLE, + MMAL_VIDEO_PROFILE_MP4V_SIMPLESCALABLE, + MMAL_VIDEO_PROFILE_MP4V_CORE, + MMAL_VIDEO_PROFILE_MP4V_MAIN, + MMAL_VIDEO_PROFILE_MP4V_NBIT, + MMAL_VIDEO_PROFILE_MP4V_SCALABLETEXTURE, + MMAL_VIDEO_PROFILE_MP4V_SIMPLEFACE, + MMAL_VIDEO_PROFILE_MP4V_SIMPLEFBA, + MMAL_VIDEO_PROFILE_MP4V_BASICANIMATED, + MMAL_VIDEO_PROFILE_MP4V_HYBRID, + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDREALTIME, + MMAL_VIDEO_PROFILE_MP4V_CORESCALABLE, + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCODING, + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDCORE, + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSCALABLE, + MMAL_VIDEO_PROFILE_MP4V_ADVANCEDSIMPLE, + MMAL_VIDEO_PROFILE_H264_BASELINE, + MMAL_VIDEO_PROFILE_H264_MAIN, + MMAL_VIDEO_PROFILE_H264_EXTENDED, + MMAL_VIDEO_PROFILE_H264_HIGH, + MMAL_VIDEO_PROFILE_H264_HIGH10, + MMAL_VIDEO_PROFILE_H264_HIGH422, + MMAL_VIDEO_PROFILE_H264_HIGH444, + MMAL_VIDEO_PROFILE_H264_CONSTRAINED_BASELINE, + MMAL_VIDEO_PROFILE_DUMMY = 0x7FFFFFFF +}; + +enum mmal_video_level { + MMAL_VIDEO_LEVEL_H263_10, + MMAL_VIDEO_LEVEL_H263_20, + MMAL_VIDEO_LEVEL_H263_30, + MMAL_VIDEO_LEVEL_H263_40, + MMAL_VIDEO_LEVEL_H263_45, + MMAL_VIDEO_LEVEL_H263_50, + MMAL_VIDEO_LEVEL_H263_60, + MMAL_VIDEO_LEVEL_H263_70, + MMAL_VIDEO_LEVEL_MP4V_0, + MMAL_VIDEO_LEVEL_MP4V_0b, + MMAL_VIDEO_LEVEL_MP4V_1, + MMAL_VIDEO_LEVEL_MP4V_2, + MMAL_VIDEO_LEVEL_MP4V_3, + MMAL_VIDEO_LEVEL_MP4V_4, + MMAL_VIDEO_LEVEL_MP4V_4a, + MMAL_VIDEO_LEVEL_MP4V_5, + MMAL_VIDEO_LEVEL_MP4V_6, + MMAL_VIDEO_LEVEL_H264_1, + MMAL_VIDEO_LEVEL_H264_1b, + MMAL_VIDEO_LEVEL_H264_11, + MMAL_VIDEO_LEVEL_H264_12, + MMAL_VIDEO_LEVEL_H264_13, + MMAL_VIDEO_LEVEL_H264_2, + MMAL_VIDEO_LEVEL_H264_21, + MMAL_VIDEO_LEVEL_H264_22, + MMAL_VIDEO_LEVEL_H264_3, + MMAL_VIDEO_LEVEL_H264_31, + MMAL_VIDEO_LEVEL_H264_32, + MMAL_VIDEO_LEVEL_H264_4, + MMAL_VIDEO_LEVEL_H264_41, + MMAL_VIDEO_LEVEL_H264_42, + MMAL_VIDEO_LEVEL_H264_5, + MMAL_VIDEO_LEVEL_H264_51, + MMAL_VIDEO_LEVEL_DUMMY = 0x7FFFFFFF +}; + +struct mmal_parameter_video_profile { + enum mmal_video_profile profile; + enum mmal_video_level level; +}; + +/* video parameters */ + +enum mmal_parameter_video_type { + /** @ref MMAL_DISPLAYREGION_T */ + MMAL_PARAMETER_DISPLAYREGION = MMAL_PARAMETER_GROUP_VIDEO, + + /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */ + MMAL_PARAMETER_SUPPORTED_PROFILES, + + /** @ref MMAL_PARAMETER_VIDEO_PROFILE_T */ + MMAL_PARAMETER_PROFILE, + + /** @ref MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_INTRAPERIOD, + + /** @ref MMAL_PARAMETER_VIDEO_RATECONTROL_T */ + MMAL_PARAMETER_RATECONTROL, + + /** @ref MMAL_PARAMETER_VIDEO_NALUNITFORMAT_T */ + MMAL_PARAMETER_NALUNITFORMAT, + + /** @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_MINIMISE_FRAGMENTATION, + + /** @ref MMAL_PARAMETER_UINT32_T. + * Setting the value to zero resets to the default (one slice per + * frame). + */ + MMAL_PARAMETER_MB_ROWS_PER_SLICE, + + /** @ref MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION_T */ + MMAL_PARAMETER_VIDEO_LEVEL_EXTENSION, + + /** @ref MMAL_PARAMETER_VIDEO_EEDE_ENABLE_T */ + MMAL_PARAMETER_VIDEO_EEDE_ENABLE, + + /** @ref MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE_T */ + MMAL_PARAMETER_VIDEO_EEDE_LOSSRATE, + + /** @ref MMAL_PARAMETER_BOOLEAN_T. Request an I-frame. */ + MMAL_PARAMETER_VIDEO_REQUEST_I_FRAME, + /** @ref MMAL_PARAMETER_VIDEO_INTRA_REFRESH_T */ + MMAL_PARAMETER_VIDEO_INTRA_REFRESH, + + /** @ref MMAL_PARAMETER_BOOLEAN_T. */ + MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT, + + /** @ref MMAL_PARAMETER_UINT32_T. Run-time bit rate control */ + MMAL_PARAMETER_VIDEO_BIT_RATE, + + /** @ref MMAL_PARAMETER_FRAME_RATE_T */ + MMAL_PARAMETER_VIDEO_FRAME_RATE, + + /** @ref MMAL_PARAMETER_UINT32_T. */ + MMAL_PARAMETER_VIDEO_ENCODE_MIN_QUANT, + + /** @ref MMAL_PARAMETER_UINT32_T. */ + MMAL_PARAMETER_VIDEO_ENCODE_MAX_QUANT, + + /** @ref MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL_T. */ + MMAL_PARAMETER_VIDEO_ENCODE_RC_MODEL, + + MMAL_PARAMETER_EXTRA_BUFFERS, /**< @ref MMAL_PARAMETER_UINT32_T. */ + /** @ref MMAL_PARAMETER_UINT32_T. + * Changing this parameter from the default can reduce frame rate + * because image buffers need to be re-pitched. + */ + MMAL_PARAMETER_VIDEO_ALIGN_HORIZ, + + /** @ref MMAL_PARAMETER_UINT32_T. + * Changing this parameter from the default can reduce frame rate + * because image buffers need to be re-pitched. + */ + MMAL_PARAMETER_VIDEO_ALIGN_VERT, + + /** @ref MMAL_PARAMETER_BOOLEAN_T. */ + MMAL_PARAMETER_VIDEO_DROPPABLE_PFRAMES, + + /** @ref MMAL_PARAMETER_UINT32_T. */ + MMAL_PARAMETER_VIDEO_ENCODE_INITIAL_QUANT, + + /**< @ref MMAL_PARAMETER_UINT32_T. */ + MMAL_PARAMETER_VIDEO_ENCODE_QP_P, + + /**< @ref MMAL_PARAMETER_UINT32_T. */ + MMAL_PARAMETER_VIDEO_ENCODE_RC_SLICE_DQUANT, + + /** @ref MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_VIDEO_ENCODE_FRAME_LIMIT_BITS, + + /** @ref MMAL_PARAMETER_UINT32_T. */ + MMAL_PARAMETER_VIDEO_ENCODE_PEAK_RATE, + + /* H264 specific parameters */ + + /** @ref MMAL_PARAMETER_BOOLEAN_T. */ + MMAL_PARAMETER_VIDEO_ENCODE_H264_DISABLE_CABAC, + + /** @ref MMAL_PARAMETER_BOOLEAN_T. */ + MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_LATENCY, + + /** @ref MMAL_PARAMETER_BOOLEAN_T. */ + MMAL_PARAMETER_VIDEO_ENCODE_H264_AU_DELIMITERS, + + /** @ref MMAL_PARAMETER_UINT32_T. */ + MMAL_PARAMETER_VIDEO_ENCODE_H264_DEBLOCK_IDC, + + /** @ref MMAL_PARAMETER_VIDEO_ENCODER_H264_MB_INTRA_MODES_T. */ + MMAL_PARAMETER_VIDEO_ENCODE_H264_MB_INTRA_MODE, + + /** @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_VIDEO_ENCODE_HEADER_ON_OPEN, + + /** @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_VIDEO_ENCODE_PRECODE_FOR_QP, + + /** @ref MMAL_PARAMETER_VIDEO_DRM_INIT_INFO_T. */ + MMAL_PARAMETER_VIDEO_DRM_INIT_INFO, + + /** @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_VIDEO_TIMESTAMP_FIFO, + + /** @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_VIDEO_DECODE_ERROR_CONCEALMENT, + + /** @ref MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER_T. */ + MMAL_PARAMETER_VIDEO_DRM_PROTECT_BUFFER, + + /** @ref MMAL_PARAMETER_BYTES_T */ + MMAL_PARAMETER_VIDEO_DECODE_CONFIG_VD3, + + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_VIDEO_ENCODE_H264_VCL_HRD_PARAMETERS, + + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_VIDEO_ENCODE_H264_LOW_DELAY_HRD_FLAG, + + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER +}; + +/** Valid mirror modes */ +enum mmal_parameter_mirror { + MMAL_PARAM_MIRROR_NONE, + MMAL_PARAM_MIRROR_VERTICAL, + MMAL_PARAM_MIRROR_HORIZONTAL, + MMAL_PARAM_MIRROR_BOTH, +}; + +enum mmal_parameter_displaytransform { + MMAL_DISPLAY_ROT0 = 0, + MMAL_DISPLAY_MIRROR_ROT0 = 1, + MMAL_DISPLAY_MIRROR_ROT180 = 2, + MMAL_DISPLAY_ROT180 = 3, + MMAL_DISPLAY_MIRROR_ROT90 = 4, + MMAL_DISPLAY_ROT270 = 5, + MMAL_DISPLAY_ROT90 = 6, + MMAL_DISPLAY_MIRROR_ROT270 = 7, +}; + +enum mmal_parameter_displaymode { + MMAL_DISPLAY_MODE_FILL = 0, + MMAL_DISPLAY_MODE_LETTERBOX = 1, +}; + +enum mmal_parameter_displayset { + MMAL_DISPLAY_SET_NONE = 0, + MMAL_DISPLAY_SET_NUM = 1, + MMAL_DISPLAY_SET_FULLSCREEN = 2, + MMAL_DISPLAY_SET_TRANSFORM = 4, + MMAL_DISPLAY_SET_DEST_RECT = 8, + MMAL_DISPLAY_SET_SRC_RECT = 0x10, + MMAL_DISPLAY_SET_MODE = 0x20, + MMAL_DISPLAY_SET_PIXEL = 0x40, + MMAL_DISPLAY_SET_NOASPECT = 0x80, + MMAL_DISPLAY_SET_LAYER = 0x100, + MMAL_DISPLAY_SET_COPYPROTECT = 0x200, + MMAL_DISPLAY_SET_ALPHA = 0x400, +}; + +/* rectangle, used lots so it gets its own struct */ +struct vchiq_mmal_rect { + s32 x; + s32 y; + s32 width; + s32 height; +}; + +struct mmal_parameter_displayregion { + /** Bitfield that indicates which fields are set and should be + * used. All other fields will maintain their current value. + * \ref MMAL_DISPLAYSET_T defines the bits that can be + * combined. + */ + u32 set; + + /** Describes the display output device, with 0 typically + * being a directly connected LCD display. The actual values + * will depend on the hardware. Code using hard-wired numbers + * (e.g. 2) is certain to fail. + */ + + u32 display_num; + /** Indicates that we are using the full device screen area, + * rather than a window of the display. If zero, then + * dest_rect is used to specify a region of the display to + * use. + */ + + s32 fullscreen; + /** Indicates any rotation or flipping used to map frames onto + * the natural display orientation. + */ + u32 transform; /* enum mmal_parameter_displaytransform */ + + /** Where to display the frame within the screen, if + * fullscreen is zero. + */ + struct vchiq_mmal_rect dest_rect; + + /** Indicates which area of the frame to display. If all + * values are zero, the whole frame will be used. + */ + struct vchiq_mmal_rect src_rect; + + /** If set to non-zero, indicates that any display scaling + * should disregard the aspect ratio of the frame region being + * displayed. + */ + s32 noaspect; + + /** Indicates how the image should be scaled to fit the + * display. \code MMAL_DISPLAY_MODE_FILL \endcode indicates + * that the image should fill the screen by potentially + * cropping the frames. Setting \code mode \endcode to \code + * MMAL_DISPLAY_MODE_LETTERBOX \endcode indicates that all the + * source region should be displayed and black bars added if + * necessary. + */ + u32 mode; /* enum mmal_parameter_displaymode */ + + /** If non-zero, defines the width of a source pixel relative + * to \code pixel_y \endcode. If zero, then pixels default to + * being square. + */ + u32 pixel_x; + + /** If non-zero, defines the height of a source pixel relative + * to \code pixel_x \endcode. If zero, then pixels default to + * being square. + */ + u32 pixel_y; + + /** Sets the relative depth of the images, with greater values + * being in front of smaller values. + */ + u32 layer; + + /** Set to non-zero to ensure copy protection is used on + * output. + */ + s32 copyprotect_required; + + /** Level of opacity of the layer, where zero is fully + * transparent and 255 is fully opaque. + */ + u32 alpha; +}; + +#define MMAL_MAX_IMAGEFX_PARAMETERS 5 + +struct mmal_parameter_imagefx_parameters { + enum mmal_parameter_imagefx effect; + u32 num_effect_params; + u32 effect_parameter[MMAL_MAX_IMAGEFX_PARAMETERS]; +}; + +#define MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS 4 +#define MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES 2 +#define MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN 16 + +struct mmal_parameter_camera_info_camera_t { + u32 port_id; + u32 max_width; + u32 max_height; + u32 lens_present; + u8 camera_name[MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN]; +}; + +enum mmal_parameter_camera_info_flash_type_t { + /* Make values explicit to ensure they match values in config ini */ + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_XENON = 0, + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_LED = 1, + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_OTHER = 2, + MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_MAX = 0x7FFFFFFF +}; + +struct mmal_parameter_camera_info_flash_t { + enum mmal_parameter_camera_info_flash_type_t flash_type; +}; + +struct mmal_parameter_camera_info_t { + u32 num_cameras; + u32 num_flashes; + struct mmal_parameter_camera_info_camera_t + cameras[MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS]; + struct mmal_parameter_camera_info_flash_t + flashes[MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES]; +}; + +#endif diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c new file mode 100644 index 000000000000..daf21087f8f9 --- /dev/null +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -0,0 +1,1912 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Broadcom BM2835 V4L2 driver + * + * Copyright © 2013 Raspberry Pi (Trading) Ltd. + * + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom + * + * V4L2 driver MMAL vchiq interface code + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mmal-common.h" +#include "mmal-vchiq.h" +#include "mmal-msg.h" + +#define USE_VCHIQ_ARM +#include "interface/vchi/vchi.h" + +/* maximum number of components supported */ +#define VCHIQ_MMAL_MAX_COMPONENTS 4 + +/*#define FULL_MSG_DUMP 1*/ + +#ifdef DEBUG +static const char *const msg_type_names[] = { + "UNKNOWN", + "QUIT", + "SERVICE_CLOSED", + "GET_VERSION", + "COMPONENT_CREATE", + "COMPONENT_DESTROY", + "COMPONENT_ENABLE", + "COMPONENT_DISABLE", + "PORT_INFO_GET", + "PORT_INFO_SET", + "PORT_ACTION", + "BUFFER_FROM_HOST", + "BUFFER_TO_HOST", + "GET_STATS", + "PORT_PARAMETER_SET", + "PORT_PARAMETER_GET", + "EVENT_TO_HOST", + "GET_CORE_STATS_FOR_PORT", + "OPAQUE_ALLOCATOR", + "CONSUME_MEM", + "LMK", + "OPAQUE_ALLOCATOR_DESC", + "DRM_GET_LHS32", + "DRM_GET_TIME", + "BUFFER_FROM_HOST_ZEROLEN", + "PORT_FLUSH", + "HOST_LOG", +}; +#endif + +static const char *const port_action_type_names[] = { + "UNKNOWN", + "ENABLE", + "DISABLE", + "FLUSH", + "CONNECT", + "DISCONNECT", + "SET_REQUIREMENTS", +}; + +#if defined(DEBUG) +#if defined(FULL_MSG_DUMP) +#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE) \ + do { \ + pr_debug(TITLE" type:%s(%d) length:%d\n", \ + msg_type_names[(MSG)->h.type], \ + (MSG)->h.type, (MSG_LEN)); \ + print_hex_dump(KERN_DEBUG, "<h.type], \ + (MSG)->h.type, (MSG_LEN)); \ + } +#endif +#else +#define DBG_DUMP_MSG(MSG, MSG_LEN, TITLE) +#endif + +struct vchiq_mmal_instance; + +/* normal message context */ +struct mmal_msg_context { + struct vchiq_mmal_instance *instance; + + /* Index in the context_map idr so that we can find the + * mmal_msg_context again when servicing the VCHI reply. + */ + int handle; + + union { + struct { + /* work struct for buffer_cb callback */ + struct work_struct work; + /* work struct for deferred callback */ + struct work_struct buffer_to_host_work; + /* mmal instance */ + struct vchiq_mmal_instance *instance; + /* mmal port */ + struct vchiq_mmal_port *port; + /* actual buffer used to store bulk reply */ + struct mmal_buffer *buffer; + /* amount of buffer used */ + unsigned long buffer_used; + /* MMAL buffer flags */ + u32 mmal_flags; + /* Presentation and Decode timestamps */ + s64 pts; + s64 dts; + + int status; /* context status */ + + } bulk; /* bulk data */ + + struct { + /* message handle to release */ + struct vchi_held_msg msg_handle; + /* pointer to received message */ + struct mmal_msg *msg; + /* received message length */ + u32 msg_len; + /* completion upon reply */ + struct completion cmplt; + } sync; /* synchronous response */ + } u; + +}; + +struct vchiq_mmal_instance { + struct vchi_service_handle *handle; + + /* ensure serialised access to service */ + struct mutex vchiq_mutex; + + /* vmalloc page to receive scratch bulk xfers into */ + void *bulk_scratch; + + struct idr context_map; + /* protect accesses to context_map */ + struct mutex context_map_lock; + + /* component to use next */ + int component_idx; + struct vchiq_mmal_component component[VCHIQ_MMAL_MAX_COMPONENTS]; + + /* ordered workqueue to process all bulk operations */ + struct workqueue_struct *bulk_wq; +}; + +static struct mmal_msg_context * +get_msg_context(struct vchiq_mmal_instance *instance) +{ + struct mmal_msg_context *msg_context; + int handle; + + /* todo: should this be allocated from a pool to avoid kzalloc */ + msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL); + + if (!msg_context) + return ERR_PTR(-ENOMEM); + + /* Create an ID that will be passed along with our message so + * that when we service the VCHI reply, we can look up what + * message is being replied to. + */ + mutex_lock(&instance->context_map_lock); + handle = idr_alloc(&instance->context_map, msg_context, + 0, 0, GFP_KERNEL); + mutex_unlock(&instance->context_map_lock); + + if (handle < 0) { + kfree(msg_context); + return ERR_PTR(handle); + } + + msg_context->instance = instance; + msg_context->handle = handle; + + return msg_context; +} + +static struct mmal_msg_context * +lookup_msg_context(struct vchiq_mmal_instance *instance, int handle) +{ + return idr_find(&instance->context_map, handle); +} + +static void +release_msg_context(struct mmal_msg_context *msg_context) +{ + struct vchiq_mmal_instance *instance = msg_context->instance; + + mutex_lock(&instance->context_map_lock); + idr_remove(&instance->context_map, msg_context->handle); + mutex_unlock(&instance->context_map_lock); + kfree(msg_context); +} + +/* deals with receipt of event to host message */ +static void event_to_host_cb(struct vchiq_mmal_instance *instance, + struct mmal_msg *msg, u32 msg_len) +{ + pr_debug("unhandled event\n"); + pr_debug("component:%u port type:%d num:%d cmd:0x%x length:%d\n", + msg->u.event_to_host.client_component, + msg->u.event_to_host.port_type, + msg->u.event_to_host.port_num, + msg->u.event_to_host.cmd, msg->u.event_to_host.length); +} + +/* workqueue scheduled callback + * + * we do this because it is important we do not call any other vchiq + * sync calls from witin the message delivery thread + */ +static void buffer_work_cb(struct work_struct *work) +{ + struct mmal_msg_context *msg_context = + container_of(work, struct mmal_msg_context, u.bulk.work); + + atomic_dec(&msg_context->u.bulk.port->buffers_with_vpu); + + msg_context->u.bulk.port->buffer_cb(msg_context->u.bulk.instance, + msg_context->u.bulk.port, + msg_context->u.bulk.status, + msg_context->u.bulk.buffer, + msg_context->u.bulk.buffer_used, + msg_context->u.bulk.mmal_flags, + msg_context->u.bulk.dts, + msg_context->u.bulk.pts); +} + +/* workqueue scheduled callback to handle receiving buffers + * + * VCHI will allow up to 4 bulk receives to be scheduled before blocking. + * If we block in the service_callback context then we can't process the + * VCHI_CALLBACK_BULK_RECEIVED message that would otherwise allow the blocked + * vchi_bulk_queue_receive() call to complete. + */ +static void buffer_to_host_work_cb(struct work_struct *work) +{ + struct mmal_msg_context *msg_context = + container_of(work, struct mmal_msg_context, + u.bulk.buffer_to_host_work); + struct vchiq_mmal_instance *instance = msg_context->instance; + unsigned long len = msg_context->u.bulk.buffer_used; + int ret; + + if (!len) + /* Dummy receive to ensure the buffers remain in order */ + len = 8; + /* queue the bulk submission */ + vchi_service_use(instance->handle); + ret = vchi_bulk_queue_receive(instance->handle, + msg_context->u.bulk.buffer->buffer, + /* Actual receive needs to be a multiple + * of 4 bytes + */ + (len + 3) & ~3, + VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE | + VCHI_FLAGS_BLOCK_UNTIL_QUEUED, + msg_context); + + vchi_service_release(instance->handle); + + if (ret != 0) + pr_err("%s: ctx: %p, vchi_bulk_queue_receive failed %d\n", + __func__, msg_context, ret); +} + +/* enqueue a bulk receive for a given message context */ +static int bulk_receive(struct vchiq_mmal_instance *instance, + struct mmal_msg *msg, + struct mmal_msg_context *msg_context) +{ + unsigned long rd_len; + + rd_len = msg->u.buffer_from_host.buffer_header.length; + + if (!msg_context->u.bulk.buffer) { + pr_err("bulk.buffer not configured - error in buffer_from_host\n"); + + /* todo: this is a serious error, we should never have + * committed a buffer_to_host operation to the mmal + * port without the buffer to back it up (underflow + * handling) and there is no obvious way to deal with + * this - how is the mmal servie going to react when + * we fail to do the xfer and reschedule a buffer when + * it arrives? perhaps a starved flag to indicate a + * waiting bulk receive? + */ + + return -EINVAL; + } + + /* ensure we do not overrun the available buffer */ + if (rd_len > msg_context->u.bulk.buffer->buffer_size) { + rd_len = msg_context->u.bulk.buffer->buffer_size; + pr_warn("short read as not enough receive buffer space\n"); + /* todo: is this the correct response, what happens to + * the rest of the message data? + */ + } + + /* store length */ + msg_context->u.bulk.buffer_used = rd_len; + msg_context->u.bulk.dts = msg->u.buffer_from_host.buffer_header.dts; + msg_context->u.bulk.pts = msg->u.buffer_from_host.buffer_header.pts; + + queue_work(msg_context->instance->bulk_wq, + &msg_context->u.bulk.buffer_to_host_work); + + return 0; +} + +/* data in message, memcpy from packet into output buffer */ +static int inline_receive(struct vchiq_mmal_instance *instance, + struct mmal_msg *msg, + struct mmal_msg_context *msg_context) +{ + memcpy(msg_context->u.bulk.buffer->buffer, + msg->u.buffer_from_host.short_data, + msg->u.buffer_from_host.payload_in_message); + + msg_context->u.bulk.buffer_used = + msg->u.buffer_from_host.payload_in_message; + + return 0; +} + +/* queue the buffer availability with MMAL_MSG_TYPE_BUFFER_FROM_HOST */ +static int +buffer_from_host(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, struct mmal_buffer *buf) +{ + struct mmal_msg_context *msg_context; + struct mmal_msg m; + int ret; + + if (!port->enabled) + return -EINVAL; + + pr_debug("instance:%p buffer:%p\n", instance->handle, buf); + + /* get context */ + if (!buf->msg_context) { + pr_err("%s: msg_context not allocated, buf %p\n", __func__, + buf); + return -EINVAL; + } + msg_context = buf->msg_context; + + /* store bulk message context for when data arrives */ + msg_context->u.bulk.instance = instance; + msg_context->u.bulk.port = port; + msg_context->u.bulk.buffer = buf; + msg_context->u.bulk.buffer_used = 0; + + /* initialise work structure ready to schedule callback */ + INIT_WORK(&msg_context->u.bulk.work, buffer_work_cb); + INIT_WORK(&msg_context->u.bulk.buffer_to_host_work, + buffer_to_host_work_cb); + + atomic_inc(&port->buffers_with_vpu); + + /* prep the buffer from host message */ + memset(&m, 0xbc, sizeof(m)); /* just to make debug clearer */ + + m.h.type = MMAL_MSG_TYPE_BUFFER_FROM_HOST; + m.h.magic = MMAL_MAGIC; + m.h.context = msg_context->handle; + m.h.status = 0; + + /* drvbuf is our private data passed back */ + m.u.buffer_from_host.drvbuf.magic = MMAL_MAGIC; + m.u.buffer_from_host.drvbuf.component_handle = port->component->handle; + m.u.buffer_from_host.drvbuf.port_handle = port->handle; + m.u.buffer_from_host.drvbuf.client_context = msg_context->handle; + + /* buffer header */ + m.u.buffer_from_host.buffer_header.cmd = 0; + m.u.buffer_from_host.buffer_header.data = + (u32)(unsigned long)buf->buffer; + m.u.buffer_from_host.buffer_header.alloc_size = buf->buffer_size; + m.u.buffer_from_host.buffer_header.length = 0; /* nothing used yet */ + m.u.buffer_from_host.buffer_header.offset = 0; /* no offset */ + m.u.buffer_from_host.buffer_header.flags = 0; /* no flags */ + m.u.buffer_from_host.buffer_header.pts = MMAL_TIME_UNKNOWN; + m.u.buffer_from_host.buffer_header.dts = MMAL_TIME_UNKNOWN; + + /* clear buffer type sepecific data */ + memset(&m.u.buffer_from_host.buffer_header_type_specific, 0, + sizeof(m.u.buffer_from_host.buffer_header_type_specific)); + + /* no payload in message */ + m.u.buffer_from_host.payload_in_message = 0; + + vchi_service_use(instance->handle); + + ret = vchi_queue_kernel_message(instance->handle, + &m, + sizeof(struct mmal_msg_header) + + sizeof(m.u.buffer_from_host)); + + vchi_service_release(instance->handle); + + return ret; +} + +/* deals with receipt of buffer to host message */ +static void buffer_to_host_cb(struct vchiq_mmal_instance *instance, + struct mmal_msg *msg, u32 msg_len) +{ + struct mmal_msg_context *msg_context; + u32 handle; + + pr_debug("%s: instance:%p msg:%p msg_len:%d\n", + __func__, instance, msg, msg_len); + + if (msg->u.buffer_from_host.drvbuf.magic == MMAL_MAGIC) { + handle = msg->u.buffer_from_host.drvbuf.client_context; + msg_context = lookup_msg_context(instance, handle); + + if (!msg_context) { + pr_err("drvbuf.client_context(%u) is invalid\n", + handle); + return; + } + } else { + pr_err("MMAL_MSG_TYPE_BUFFER_TO_HOST with bad magic\n"); + return; + } + + msg_context->u.bulk.mmal_flags = + msg->u.buffer_from_host.buffer_header.flags; + + if (msg->h.status != MMAL_MSG_STATUS_SUCCESS) { + /* message reception had an error */ + pr_warn("error %d in reply\n", msg->h.status); + + msg_context->u.bulk.status = msg->h.status; + + } else if (msg->u.buffer_from_host.buffer_header.length == 0) { + /* empty buffer */ + if (msg->u.buffer_from_host.buffer_header.flags & + MMAL_BUFFER_HEADER_FLAG_EOS) { + msg_context->u.bulk.status = + bulk_receive(instance, msg, msg_context); + if (msg_context->u.bulk.status == 0) + return; /* successful bulk submission, bulk + * completion will trigger callback + */ + } else { + /* do callback with empty buffer - not EOS though */ + msg_context->u.bulk.status = 0; + msg_context->u.bulk.buffer_used = 0; + } + } else if (msg->u.buffer_from_host.payload_in_message == 0) { + /* data is not in message, queue a bulk receive */ + msg_context->u.bulk.status = + bulk_receive(instance, msg, msg_context); + if (msg_context->u.bulk.status == 0) + return; /* successful bulk submission, bulk + * completion will trigger callback + */ + + /* failed to submit buffer, this will end badly */ + pr_err("error %d on bulk submission\n", + msg_context->u.bulk.status); + + } else if (msg->u.buffer_from_host.payload_in_message <= + MMAL_VC_SHORT_DATA) { + /* data payload within message */ + msg_context->u.bulk.status = inline_receive(instance, msg, + msg_context); + } else { + pr_err("message with invalid short payload\n"); + + /* signal error */ + msg_context->u.bulk.status = -EINVAL; + msg_context->u.bulk.buffer_used = + msg->u.buffer_from_host.payload_in_message; + } + + /* schedule the port callback */ + schedule_work(&msg_context->u.bulk.work); +} + +static void bulk_receive_cb(struct vchiq_mmal_instance *instance, + struct mmal_msg_context *msg_context) +{ + msg_context->u.bulk.status = 0; + + /* schedule the port callback */ + schedule_work(&msg_context->u.bulk.work); +} + +static void bulk_abort_cb(struct vchiq_mmal_instance *instance, + struct mmal_msg_context *msg_context) +{ + pr_err("%s: bulk ABORTED msg_context:%p\n", __func__, msg_context); + + msg_context->u.bulk.status = -EINTR; + + schedule_work(&msg_context->u.bulk.work); +} + +/* incoming event service callback */ +static void service_callback(void *param, + const enum vchi_callback_reason reason, + void *bulk_ctx) +{ + struct vchiq_mmal_instance *instance = param; + int status; + u32 msg_len; + struct mmal_msg *msg; + struct vchi_held_msg msg_handle; + struct mmal_msg_context *msg_context; + + if (!instance) { + pr_err("Message callback passed NULL instance\n"); + return; + } + + switch (reason) { + case VCHI_CALLBACK_MSG_AVAILABLE: + status = vchi_msg_hold(instance->handle, (void **)&msg, + &msg_len, VCHI_FLAGS_NONE, &msg_handle); + if (status) { + pr_err("Unable to dequeue a message (%d)\n", status); + break; + } + + DBG_DUMP_MSG(msg, msg_len, "<<< reply message"); + + /* handling is different for buffer messages */ + switch (msg->h.type) { + case MMAL_MSG_TYPE_BUFFER_FROM_HOST: + vchi_held_msg_release(&msg_handle); + break; + + case MMAL_MSG_TYPE_EVENT_TO_HOST: + event_to_host_cb(instance, msg, msg_len); + vchi_held_msg_release(&msg_handle); + + break; + + case MMAL_MSG_TYPE_BUFFER_TO_HOST: + buffer_to_host_cb(instance, msg, msg_len); + vchi_held_msg_release(&msg_handle); + break; + + default: + /* messages dependent on header context to complete */ + if (!msg->h.context) { + pr_err("received message context was null!\n"); + vchi_held_msg_release(&msg_handle); + break; + } + + msg_context = lookup_msg_context(instance, + msg->h.context); + if (!msg_context) { + pr_err("received invalid message context %u!\n", + msg->h.context); + vchi_held_msg_release(&msg_handle); + break; + } + + /* fill in context values */ + msg_context->u.sync.msg_handle = msg_handle; + msg_context->u.sync.msg = msg; + msg_context->u.sync.msg_len = msg_len; + + /* todo: should this check (completion_done() + * == 1) for no one waiting? or do we need a + * flag to tell us the completion has been + * interrupted so we can free the message and + * its context. This probably also solves the + * message arriving after interruption todo + * below + */ + + /* complete message so caller knows it happened */ + complete(&msg_context->u.sync.cmplt); + break; + } + + break; + + case VCHI_CALLBACK_BULK_RECEIVED: + bulk_receive_cb(instance, bulk_ctx); + break; + + case VCHI_CALLBACK_BULK_RECEIVE_ABORTED: + bulk_abort_cb(instance, bulk_ctx); + break; + + case VCHI_CALLBACK_SERVICE_CLOSED: + /* TODO: consider if this requires action if received when + * driver is not explicitly closing the service + */ + break; + + default: + pr_err("Received unhandled message reason %d\n", reason); + break; + } +} + +static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, + struct mmal_msg *msg, + unsigned int payload_len, + struct mmal_msg **msg_out, + struct vchi_held_msg *msg_handle_out) +{ + struct mmal_msg_context *msg_context; + int ret; + unsigned long timeout; + + /* payload size must not cause message to exceed max size */ + if (payload_len > + (MMAL_MSG_MAX_SIZE - sizeof(struct mmal_msg_header))) { + pr_err("payload length %d exceeds max:%d\n", payload_len, + (int)(MMAL_MSG_MAX_SIZE - + sizeof(struct mmal_msg_header))); + return -EINVAL; + } + + msg_context = get_msg_context(instance); + if (IS_ERR(msg_context)) + return PTR_ERR(msg_context); + + init_completion(&msg_context->u.sync.cmplt); + + msg->h.magic = MMAL_MAGIC; + msg->h.context = msg_context->handle; + msg->h.status = 0; + + DBG_DUMP_MSG(msg, (sizeof(struct mmal_msg_header) + payload_len), + ">>> sync message"); + + vchi_service_use(instance->handle); + + ret = vchi_queue_kernel_message(instance->handle, + msg, + sizeof(struct mmal_msg_header) + + payload_len); + + vchi_service_release(instance->handle); + + if (ret) { + pr_err("error %d queuing message\n", ret); + release_msg_context(msg_context); + return ret; + } + + timeout = wait_for_completion_timeout(&msg_context->u.sync.cmplt, + 3 * HZ); + if (timeout == 0) { + pr_err("timed out waiting for sync completion\n"); + ret = -ETIME; + /* todo: what happens if the message arrives after aborting */ + release_msg_context(msg_context); + return ret; + } + + *msg_out = msg_context->u.sync.msg; + *msg_handle_out = msg_context->u.sync.msg_handle; + release_msg_context(msg_context); + + return 0; +} + +static void dump_port_info(struct vchiq_mmal_port *port) +{ + pr_debug("port handle:0x%x enabled:%d\n", port->handle, port->enabled); + + pr_debug("buffer minimum num:%d size:%d align:%d\n", + port->minimum_buffer.num, + port->minimum_buffer.size, port->minimum_buffer.alignment); + + pr_debug("buffer recommended num:%d size:%d align:%d\n", + port->recommended_buffer.num, + port->recommended_buffer.size, + port->recommended_buffer.alignment); + + pr_debug("buffer current values num:%d size:%d align:%d\n", + port->current_buffer.num, + port->current_buffer.size, port->current_buffer.alignment); + + pr_debug("elementary stream: type:%d encoding:0x%x variant:0x%x\n", + port->format.type, + port->format.encoding, port->format.encoding_variant); + + pr_debug(" bitrate:%d flags:0x%x\n", + port->format.bitrate, port->format.flags); + + if (port->format.type == MMAL_ES_TYPE_VIDEO) { + pr_debug + ("es video format: width:%d height:%d colourspace:0x%x\n", + port->es.video.width, port->es.video.height, + port->es.video.color_space); + + pr_debug(" : crop xywh %d,%d,%d,%d\n", + port->es.video.crop.x, + port->es.video.crop.y, + port->es.video.crop.width, port->es.video.crop.height); + pr_debug(" : framerate %d/%d aspect %d/%d\n", + port->es.video.frame_rate.num, + port->es.video.frame_rate.den, + port->es.video.par.num, port->es.video.par.den); + } +} + +static void port_to_mmal_msg(struct vchiq_mmal_port *port, struct mmal_port *p) +{ + /* todo do readonly fields need setting at all? */ + p->type = port->type; + p->index = port->index; + p->index_all = 0; + p->is_enabled = port->enabled; + p->buffer_num_min = port->minimum_buffer.num; + p->buffer_size_min = port->minimum_buffer.size; + p->buffer_alignment_min = port->minimum_buffer.alignment; + p->buffer_num_recommended = port->recommended_buffer.num; + p->buffer_size_recommended = port->recommended_buffer.size; + + /* only three writable fields in a port */ + p->buffer_num = port->current_buffer.num; + p->buffer_size = port->current_buffer.size; + p->userdata = (u32)(unsigned long)port; +} + +static int port_info_set(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port) +{ + int ret; + struct mmal_msg m; + struct mmal_msg *rmsg; + struct vchi_held_msg rmsg_handle; + + pr_debug("setting port info port %p\n", port); + if (!port) + return -1; + dump_port_info(port); + + m.h.type = MMAL_MSG_TYPE_PORT_INFO_SET; + + m.u.port_info_set.component_handle = port->component->handle; + m.u.port_info_set.port_type = port->type; + m.u.port_info_set.port_index = port->index; + + port_to_mmal_msg(port, &m.u.port_info_set.port); + + /* elementary stream format setup */ + m.u.port_info_set.format.type = port->format.type; + m.u.port_info_set.format.encoding = port->format.encoding; + m.u.port_info_set.format.encoding_variant = + port->format.encoding_variant; + m.u.port_info_set.format.bitrate = port->format.bitrate; + m.u.port_info_set.format.flags = port->format.flags; + + memcpy(&m.u.port_info_set.es, &port->es, + sizeof(union mmal_es_specific_format)); + + m.u.port_info_set.format.extradata_size = port->format.extradata_size; + memcpy(&m.u.port_info_set.extradata, port->format.extradata, + port->format.extradata_size); + + ret = send_synchronous_mmal_msg(instance, &m, + sizeof(m.u.port_info_set), + &rmsg, &rmsg_handle); + if (ret) + return ret; + + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_SET) { + /* got an unexpected message type in reply */ + ret = -EINVAL; + goto release_msg; + } + + /* return operation status */ + ret = -rmsg->u.port_info_get_reply.status; + + pr_debug("%s:result:%d component:0x%x port:%d\n", __func__, ret, + port->component->handle, port->handle); + +release_msg: + vchi_held_msg_release(&rmsg_handle); + + return ret; +} + +/* use port info get message to retrieve port information */ +static int port_info_get(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port) +{ + int ret; + struct mmal_msg m; + struct mmal_msg *rmsg; + struct vchi_held_msg rmsg_handle; + + /* port info time */ + m.h.type = MMAL_MSG_TYPE_PORT_INFO_GET; + m.u.port_info_get.component_handle = port->component->handle; + m.u.port_info_get.port_type = port->type; + m.u.port_info_get.index = port->index; + + ret = send_synchronous_mmal_msg(instance, &m, + sizeof(m.u.port_info_get), + &rmsg, &rmsg_handle); + if (ret) + return ret; + + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_INFO_GET) { + /* got an unexpected message type in reply */ + ret = -EINVAL; + goto release_msg; + } + + /* return operation status */ + ret = -rmsg->u.port_info_get_reply.status; + if (ret != MMAL_MSG_STATUS_SUCCESS) + goto release_msg; + + if (rmsg->u.port_info_get_reply.port.is_enabled == 0) + port->enabled = 0; + else + port->enabled = 1; + + /* copy the values out of the message */ + port->handle = rmsg->u.port_info_get_reply.port_handle; + + /* port type and index cached to use on port info set because + * it does not use a port handle + */ + port->type = rmsg->u.port_info_get_reply.port_type; + port->index = rmsg->u.port_info_get_reply.port_index; + + port->minimum_buffer.num = + rmsg->u.port_info_get_reply.port.buffer_num_min; + port->minimum_buffer.size = + rmsg->u.port_info_get_reply.port.buffer_size_min; + port->minimum_buffer.alignment = + rmsg->u.port_info_get_reply.port.buffer_alignment_min; + + port->recommended_buffer.alignment = + rmsg->u.port_info_get_reply.port.buffer_alignment_min; + port->recommended_buffer.num = + rmsg->u.port_info_get_reply.port.buffer_num_recommended; + + port->current_buffer.num = rmsg->u.port_info_get_reply.port.buffer_num; + port->current_buffer.size = + rmsg->u.port_info_get_reply.port.buffer_size; + + /* stream format */ + port->format.type = rmsg->u.port_info_get_reply.format.type; + port->format.encoding = rmsg->u.port_info_get_reply.format.encoding; + port->format.encoding_variant = + rmsg->u.port_info_get_reply.format.encoding_variant; + port->format.bitrate = rmsg->u.port_info_get_reply.format.bitrate; + port->format.flags = rmsg->u.port_info_get_reply.format.flags; + + /* elementary stream format */ + memcpy(&port->es, + &rmsg->u.port_info_get_reply.es, + sizeof(union mmal_es_specific_format)); + port->format.es = &port->es; + + port->format.extradata_size = + rmsg->u.port_info_get_reply.format.extradata_size; + memcpy(port->format.extradata, + rmsg->u.port_info_get_reply.extradata, + port->format.extradata_size); + + pr_debug("received port info\n"); + dump_port_info(port); + +release_msg: + + pr_debug("%s:result:%d component:0x%x port:%d\n", + __func__, ret, port->component->handle, port->handle); + + vchi_held_msg_release(&rmsg_handle); + + return ret; +} + +/* create comonent on vc */ +static int create_component(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_component *component, + const char *name) +{ + int ret; + struct mmal_msg m; + struct mmal_msg *rmsg; + struct vchi_held_msg rmsg_handle; + + /* build component create message */ + m.h.type = MMAL_MSG_TYPE_COMPONENT_CREATE; + m.u.component_create.client_component = (u32)(unsigned long)component; + strncpy(m.u.component_create.name, name, + sizeof(m.u.component_create.name)); + + ret = send_synchronous_mmal_msg(instance, &m, + sizeof(m.u.component_create), + &rmsg, &rmsg_handle); + if (ret) + return ret; + + if (rmsg->h.type != m.h.type) { + /* got an unexpected message type in reply */ + ret = -EINVAL; + goto release_msg; + } + + ret = -rmsg->u.component_create_reply.status; + if (ret != MMAL_MSG_STATUS_SUCCESS) + goto release_msg; + + /* a valid component response received */ + component->handle = rmsg->u.component_create_reply.component_handle; + component->inputs = rmsg->u.component_create_reply.input_num; + component->outputs = rmsg->u.component_create_reply.output_num; + component->clocks = rmsg->u.component_create_reply.clock_num; + + pr_debug("Component handle:0x%x in:%d out:%d clock:%d\n", + component->handle, + component->inputs, component->outputs, component->clocks); + +release_msg: + vchi_held_msg_release(&rmsg_handle); + + return ret; +} + +/* destroys a component on vc */ +static int destroy_component(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_component *component) +{ + int ret; + struct mmal_msg m; + struct mmal_msg *rmsg; + struct vchi_held_msg rmsg_handle; + + m.h.type = MMAL_MSG_TYPE_COMPONENT_DESTROY; + m.u.component_destroy.component_handle = component->handle; + + ret = send_synchronous_mmal_msg(instance, &m, + sizeof(m.u.component_destroy), + &rmsg, &rmsg_handle); + if (ret) + return ret; + + if (rmsg->h.type != m.h.type) { + /* got an unexpected message type in reply */ + ret = -EINVAL; + goto release_msg; + } + + ret = -rmsg->u.component_destroy_reply.status; + +release_msg: + + vchi_held_msg_release(&rmsg_handle); + + return ret; +} + +/* enable a component on vc */ +static int enable_component(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_component *component) +{ + int ret; + struct mmal_msg m; + struct mmal_msg *rmsg; + struct vchi_held_msg rmsg_handle; + + m.h.type = MMAL_MSG_TYPE_COMPONENT_ENABLE; + m.u.component_enable.component_handle = component->handle; + + ret = send_synchronous_mmal_msg(instance, &m, + sizeof(m.u.component_enable), + &rmsg, &rmsg_handle); + if (ret) + return ret; + + if (rmsg->h.type != m.h.type) { + /* got an unexpected message type in reply */ + ret = -EINVAL; + goto release_msg; + } + + ret = -rmsg->u.component_enable_reply.status; + +release_msg: + vchi_held_msg_release(&rmsg_handle); + + return ret; +} + +/* disable a component on vc */ +static int disable_component(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_component *component) +{ + int ret; + struct mmal_msg m; + struct mmal_msg *rmsg; + struct vchi_held_msg rmsg_handle; + + m.h.type = MMAL_MSG_TYPE_COMPONENT_DISABLE; + m.u.component_disable.component_handle = component->handle; + + ret = send_synchronous_mmal_msg(instance, &m, + sizeof(m.u.component_disable), + &rmsg, &rmsg_handle); + if (ret) + return ret; + + if (rmsg->h.type != m.h.type) { + /* got an unexpected message type in reply */ + ret = -EINVAL; + goto release_msg; + } + + ret = -rmsg->u.component_disable_reply.status; + +release_msg: + + vchi_held_msg_release(&rmsg_handle); + + return ret; +} + +/* get version of mmal implementation */ +static int get_version(struct vchiq_mmal_instance *instance, + u32 *major_out, u32 *minor_out) +{ + int ret; + struct mmal_msg m; + struct mmal_msg *rmsg; + struct vchi_held_msg rmsg_handle; + + m.h.type = MMAL_MSG_TYPE_GET_VERSION; + + ret = send_synchronous_mmal_msg(instance, &m, + sizeof(m.u.version), + &rmsg, &rmsg_handle); + if (ret) + return ret; + + if (rmsg->h.type != m.h.type) { + /* got an unexpected message type in reply */ + ret = -EINVAL; + goto release_msg; + } + + *major_out = rmsg->u.version.major; + *minor_out = rmsg->u.version.minor; + +release_msg: + vchi_held_msg_release(&rmsg_handle); + + return ret; +} + +/* do a port action with a port as a parameter */ +static int port_action_port(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, + enum mmal_msg_port_action_type action_type) +{ + int ret; + struct mmal_msg m; + struct mmal_msg *rmsg; + struct vchi_held_msg rmsg_handle; + + m.h.type = MMAL_MSG_TYPE_PORT_ACTION; + m.u.port_action_port.component_handle = port->component->handle; + m.u.port_action_port.port_handle = port->handle; + m.u.port_action_port.action = action_type; + + port_to_mmal_msg(port, &m.u.port_action_port.port); + + ret = send_synchronous_mmal_msg(instance, &m, + sizeof(m.u.port_action_port), + &rmsg, &rmsg_handle); + if (ret) + return ret; + + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) { + /* got an unexpected message type in reply */ + ret = -EINVAL; + goto release_msg; + } + + ret = -rmsg->u.port_action_reply.status; + + pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d)\n", + __func__, + ret, port->component->handle, port->handle, + port_action_type_names[action_type], action_type); + +release_msg: + vchi_held_msg_release(&rmsg_handle); + + return ret; +} + +/* do a port action with handles as parameters */ +static int port_action_handle(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, + enum mmal_msg_port_action_type action_type, + u32 connect_component_handle, + u32 connect_port_handle) +{ + int ret; + struct mmal_msg m; + struct mmal_msg *rmsg; + struct vchi_held_msg rmsg_handle; + + m.h.type = MMAL_MSG_TYPE_PORT_ACTION; + + m.u.port_action_handle.component_handle = port->component->handle; + m.u.port_action_handle.port_handle = port->handle; + m.u.port_action_handle.action = action_type; + + m.u.port_action_handle.connect_component_handle = + connect_component_handle; + m.u.port_action_handle.connect_port_handle = connect_port_handle; + + ret = send_synchronous_mmal_msg(instance, &m, + sizeof(m.u.port_action_handle), + &rmsg, &rmsg_handle); + if (ret) + return ret; + + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_ACTION) { + /* got an unexpected message type in reply */ + ret = -EINVAL; + goto release_msg; + } + + ret = -rmsg->u.port_action_reply.status; + + pr_debug("%s:result:%d component:0x%x port:%d action:%s(%d) connect component:0x%x connect port:%d\n", + __func__, + ret, port->component->handle, port->handle, + port_action_type_names[action_type], + action_type, connect_component_handle, connect_port_handle); + +release_msg: + vchi_held_msg_release(&rmsg_handle); + + return ret; +} + +static int port_parameter_set(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, + u32 parameter_id, void *value, u32 value_size) +{ + int ret; + struct mmal_msg m; + struct mmal_msg *rmsg; + struct vchi_held_msg rmsg_handle; + + m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_SET; + + m.u.port_parameter_set.component_handle = port->component->handle; + m.u.port_parameter_set.port_handle = port->handle; + m.u.port_parameter_set.id = parameter_id; + m.u.port_parameter_set.size = (2 * sizeof(u32)) + value_size; + memcpy(&m.u.port_parameter_set.value, value, value_size); + + ret = send_synchronous_mmal_msg(instance, &m, + (4 * sizeof(u32)) + value_size, + &rmsg, &rmsg_handle); + if (ret) + return ret; + + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_SET) { + /* got an unexpected message type in reply */ + ret = -EINVAL; + goto release_msg; + } + + ret = -rmsg->u.port_parameter_set_reply.status; + + pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n", + __func__, + ret, port->component->handle, port->handle, parameter_id); + +release_msg: + vchi_held_msg_release(&rmsg_handle); + + return ret; +} + +static int port_parameter_get(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, + u32 parameter_id, void *value, u32 *value_size) +{ + int ret; + struct mmal_msg m; + struct mmal_msg *rmsg; + struct vchi_held_msg rmsg_handle; + + m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_GET; + + m.u.port_parameter_get.component_handle = port->component->handle; + m.u.port_parameter_get.port_handle = port->handle; + m.u.port_parameter_get.id = parameter_id; + m.u.port_parameter_get.size = (2 * sizeof(u32)) + *value_size; + + ret = send_synchronous_mmal_msg(instance, &m, + sizeof(struct + mmal_msg_port_parameter_get), + &rmsg, &rmsg_handle); + if (ret) + return ret; + + if (rmsg->h.type != MMAL_MSG_TYPE_PORT_PARAMETER_GET) { + /* got an unexpected message type in reply */ + pr_err("Incorrect reply type %d\n", rmsg->h.type); + ret = -EINVAL; + goto release_msg; + } + + ret = -rmsg->u.port_parameter_get_reply.status; + /* port_parameter_get_reply.size includes the header, + * whilst *value_size doesn't. + */ + rmsg->u.port_parameter_get_reply.size -= (2 * sizeof(u32)); + + if (ret || rmsg->u.port_parameter_get_reply.size > *value_size) { + /* Copy only as much as we have space for + * but report true size of parameter + */ + memcpy(value, &rmsg->u.port_parameter_get_reply.value, + *value_size); + *value_size = rmsg->u.port_parameter_get_reply.size; + } else { + memcpy(value, &rmsg->u.port_parameter_get_reply.value, + rmsg->u.port_parameter_get_reply.size); + } + + pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n", __func__, + ret, port->component->handle, port->handle, parameter_id); + +release_msg: + vchi_held_msg_release(&rmsg_handle); + + return ret; +} + +/* disables a port and drains buffers from it */ +static int port_disable(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port) +{ + int ret; + struct list_head *q, *buf_head; + unsigned long flags = 0; + + if (!port->enabled) + return 0; + + port->enabled = 0; + + ret = port_action_port(instance, port, + MMAL_MSG_PORT_ACTION_TYPE_DISABLE); + if (ret == 0) { + /* + * Drain all queued buffers on port. This should only + * apply to buffers that have been queued before the port + * has been enabled. If the port has been enabled and buffers + * passed, then the buffers should have been removed from this + * list, and we should get the relevant callbacks via VCHIQ + * to release the buffers. + */ + spin_lock_irqsave(&port->slock, flags); + + list_for_each_safe(buf_head, q, &port->buffers) { + struct mmal_buffer *mmalbuf; + + mmalbuf = list_entry(buf_head, struct mmal_buffer, + list); + list_del(buf_head); + if (port->buffer_cb) + port->buffer_cb(instance, + port, 0, mmalbuf, 0, 0, + MMAL_TIME_UNKNOWN, + MMAL_TIME_UNKNOWN); + } + + spin_unlock_irqrestore(&port->slock, flags); + + ret = port_info_get(instance, port); + } + + return ret; +} + +/* enable a port */ +static int port_enable(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port) +{ + unsigned int hdr_count; + struct list_head *q, *buf_head; + int ret; + + if (port->enabled) + return 0; + + ret = port_action_port(instance, port, + MMAL_MSG_PORT_ACTION_TYPE_ENABLE); + if (ret) + goto done; + + port->enabled = 1; + + if (port->buffer_cb) { + /* send buffer headers to videocore */ + hdr_count = 1; + list_for_each_safe(buf_head, q, &port->buffers) { + struct mmal_buffer *mmalbuf; + + mmalbuf = list_entry(buf_head, struct mmal_buffer, + list); + ret = buffer_from_host(instance, port, mmalbuf); + if (ret) + goto done; + + list_del(buf_head); + hdr_count++; + if (hdr_count > port->current_buffer.num) + break; + } + } + + ret = port_info_get(instance, port); + +done: + return ret; +} + +/* ------------------------------------------------------------------ + * Exported API + *------------------------------------------------------------------ + */ + +int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port) +{ + int ret; + + if (mutex_lock_interruptible(&instance->vchiq_mutex)) + return -EINTR; + + ret = port_info_set(instance, port); + if (ret) + goto release_unlock; + + /* read what has actually been set */ + ret = port_info_get(instance, port); + +release_unlock: + mutex_unlock(&instance->vchiq_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_port_set_format); + +int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, + u32 parameter, void *value, u32 value_size) +{ + int ret; + + if (mutex_lock_interruptible(&instance->vchiq_mutex)) + return -EINTR; + + ret = port_parameter_set(instance, port, parameter, value, value_size); + + mutex_unlock(&instance->vchiq_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_port_parameter_set); + +int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, + u32 parameter, void *value, u32 *value_size) +{ + int ret; + + if (mutex_lock_interruptible(&instance->vchiq_mutex)) + return -EINTR; + + ret = port_parameter_get(instance, port, parameter, value, value_size); + + mutex_unlock(&instance->vchiq_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_port_parameter_get); + +/* enable a port + * + * enables a port and queues buffers for satisfying callbacks if we + * provide a callback handler + */ +int vchiq_mmal_port_enable(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, + vchiq_mmal_buffer_cb buffer_cb) +{ + int ret; + + if (mutex_lock_interruptible(&instance->vchiq_mutex)) + return -EINTR; + + /* already enabled - noop */ + if (port->enabled) { + ret = 0; + goto unlock; + } + + port->buffer_cb = buffer_cb; + + ret = port_enable(instance, port); + +unlock: + mutex_unlock(&instance->vchiq_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_port_enable); + +int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port) +{ + int ret; + + if (mutex_lock_interruptible(&instance->vchiq_mutex)) + return -EINTR; + + if (!port->enabled) { + mutex_unlock(&instance->vchiq_mutex); + return 0; + } + + ret = port_disable(instance, port); + + mutex_unlock(&instance->vchiq_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_port_disable); + +/* ports will be connected in a tunneled manner so data buffers + * are not handled by client. + */ +int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *src, + struct vchiq_mmal_port *dst) +{ + int ret; + + if (mutex_lock_interruptible(&instance->vchiq_mutex)) + return -EINTR; + + /* disconnect ports if connected */ + if (src->connected) { + ret = port_disable(instance, src); + if (ret) { + pr_err("failed disabling src port(%d)\n", ret); + goto release_unlock; + } + + /* do not need to disable the destination port as they + * are connected and it is done automatically + */ + + ret = port_action_handle(instance, src, + MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT, + src->connected->component->handle, + src->connected->handle); + if (ret < 0) { + pr_err("failed disconnecting src port\n"); + goto release_unlock; + } + src->connected->enabled = 0; + src->connected = NULL; + } + + if (!dst) { + /* do not make new connection */ + ret = 0; + pr_debug("not making new connection\n"); + goto release_unlock; + } + + /* copy src port format to dst */ + dst->format.encoding = src->format.encoding; + dst->es.video.width = src->es.video.width; + dst->es.video.height = src->es.video.height; + dst->es.video.crop.x = src->es.video.crop.x; + dst->es.video.crop.y = src->es.video.crop.y; + dst->es.video.crop.width = src->es.video.crop.width; + dst->es.video.crop.height = src->es.video.crop.height; + dst->es.video.frame_rate.num = src->es.video.frame_rate.num; + dst->es.video.frame_rate.den = src->es.video.frame_rate.den; + + /* set new format */ + ret = port_info_set(instance, dst); + if (ret) { + pr_debug("setting port info failed\n"); + goto release_unlock; + } + + /* read what has actually been set */ + ret = port_info_get(instance, dst); + if (ret) { + pr_debug("read back port info failed\n"); + goto release_unlock; + } + + /* connect two ports together */ + ret = port_action_handle(instance, src, + MMAL_MSG_PORT_ACTION_TYPE_CONNECT, + dst->component->handle, dst->handle); + if (ret < 0) { + pr_debug("connecting port %d:%d to %d:%d failed\n", + src->component->handle, src->handle, + dst->component->handle, dst->handle); + goto release_unlock; + } + src->connected = dst; + +release_unlock: + + mutex_unlock(&instance->vchiq_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_port_connect_tunnel); + +int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, + struct mmal_buffer *buffer) +{ + unsigned long flags = 0; + int ret; + + ret = buffer_from_host(instance, port, buffer); + if (ret == -EINVAL) { + /* Port is disabled. Queue for when it is enabled. */ + spin_lock_irqsave(&port->slock, flags); + list_add_tail(&buffer->list, &port->buffers); + spin_unlock_irqrestore(&port->slock, flags); + } + + return 0; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_submit_buffer); + +int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance, + struct mmal_buffer *buf) +{ + struct mmal_msg_context *msg_context = get_msg_context(instance); + + if (IS_ERR(msg_context)) + return (PTR_ERR(msg_context)); + + buf->msg_context = msg_context; + return 0; +} +EXPORT_SYMBOL_GPL(mmal_vchi_buffer_init); + +int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf) +{ + struct mmal_msg_context *msg_context = buf->msg_context; + + if (msg_context) + release_msg_context(msg_context); + buf->msg_context = NULL; + + return 0; +} +EXPORT_SYMBOL_GPL(mmal_vchi_buffer_cleanup); + +/* Initialise a mmal component and its ports + * + */ +int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance, + const char *name, + struct vchiq_mmal_component **component_out) +{ + int ret; + int idx; /* port index */ + struct vchiq_mmal_component *component; + + if (mutex_lock_interruptible(&instance->vchiq_mutex)) + return -EINTR; + + if (instance->component_idx == VCHIQ_MMAL_MAX_COMPONENTS) { + ret = -EINVAL; /* todo is this correct error? */ + goto unlock; + } + + component = &instance->component[instance->component_idx]; + + ret = create_component(instance, component, name); + if (ret < 0) { + pr_err("%s: failed to create component %d (Not enough GPU mem?)\n", + __func__, ret); + goto unlock; + } + + /* ports info needs gathering */ + component->control.type = MMAL_PORT_TYPE_CONTROL; + component->control.index = 0; + component->control.component = component; + spin_lock_init(&component->control.slock); + INIT_LIST_HEAD(&component->control.buffers); + ret = port_info_get(instance, &component->control); + if (ret < 0) + goto release_component; + + for (idx = 0; idx < component->inputs; idx++) { + component->input[idx].type = MMAL_PORT_TYPE_INPUT; + component->input[idx].index = idx; + component->input[idx].component = component; + spin_lock_init(&component->input[idx].slock); + INIT_LIST_HEAD(&component->input[idx].buffers); + ret = port_info_get(instance, &component->input[idx]); + if (ret < 0) + goto release_component; + } + + for (idx = 0; idx < component->outputs; idx++) { + component->output[idx].type = MMAL_PORT_TYPE_OUTPUT; + component->output[idx].index = idx; + component->output[idx].component = component; + spin_lock_init(&component->output[idx].slock); + INIT_LIST_HEAD(&component->output[idx].buffers); + ret = port_info_get(instance, &component->output[idx]); + if (ret < 0) + goto release_component; + } + + for (idx = 0; idx < component->clocks; idx++) { + component->clock[idx].type = MMAL_PORT_TYPE_CLOCK; + component->clock[idx].index = idx; + component->clock[idx].component = component; + spin_lock_init(&component->clock[idx].slock); + INIT_LIST_HEAD(&component->clock[idx].buffers); + ret = port_info_get(instance, &component->clock[idx]); + if (ret < 0) + goto release_component; + } + + instance->component_idx++; + + *component_out = component; + + mutex_unlock(&instance->vchiq_mutex); + + return 0; + +release_component: + destroy_component(instance, component); +unlock: + mutex_unlock(&instance->vchiq_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_component_init); + +/* + * cause a mmal component to be destroyed + */ +int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_component *component) +{ + int ret; + + if (mutex_lock_interruptible(&instance->vchiq_mutex)) + return -EINTR; + + if (component->enabled) + ret = disable_component(instance, component); + + ret = destroy_component(instance, component); + + mutex_unlock(&instance->vchiq_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_component_finalise); + +/* + * cause a mmal component to be enabled + */ +int vchiq_mmal_component_enable(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_component *component) +{ + int ret; + + if (mutex_lock_interruptible(&instance->vchiq_mutex)) + return -EINTR; + + if (component->enabled) { + mutex_unlock(&instance->vchiq_mutex); + return 0; + } + + ret = enable_component(instance, component); + if (ret == 0) + component->enabled = true; + + mutex_unlock(&instance->vchiq_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_component_enable); + +/* + * cause a mmal component to be enabled + */ +int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_component *component) +{ + int ret; + + if (mutex_lock_interruptible(&instance->vchiq_mutex)) + return -EINTR; + + if (!component->enabled) { + mutex_unlock(&instance->vchiq_mutex); + return 0; + } + + ret = disable_component(instance, component); + if (ret == 0) + component->enabled = 0; + + mutex_unlock(&instance->vchiq_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_component_disable); + +int vchiq_mmal_version(struct vchiq_mmal_instance *instance, + u32 *major_out, u32 *minor_out) +{ + int ret; + + if (mutex_lock_interruptible(&instance->vchiq_mutex)) + return -EINTR; + + ret = get_version(instance, major_out, minor_out); + + mutex_unlock(&instance->vchiq_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_version); + +int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance) +{ + int status = 0; + + if (!instance) + return -EINVAL; + + if (mutex_lock_interruptible(&instance->vchiq_mutex)) + return -EINTR; + + vchi_service_use(instance->handle); + + status = vchi_service_close(instance->handle); + if (status != 0) + pr_err("mmal-vchiq: VCHIQ close failed\n"); + + mutex_unlock(&instance->vchiq_mutex); + + flush_workqueue(instance->bulk_wq); + destroy_workqueue(instance->bulk_wq); + + vfree(instance->bulk_scratch); + + idr_destroy(&instance->context_map); + + kfree(instance); + + return status; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_finalise); + +int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) +{ + int status; + struct vchiq_mmal_instance *instance; + static struct vchi_instance_handle *vchi_instance; + struct service_creation params = { + .version = VCHI_VERSION_EX(VC_MMAL_VER, VC_MMAL_MIN_VER), + .service_id = VC_MMAL_SERVER_NAME, + .callback = service_callback, + .callback_param = NULL, + }; + + /* compile time checks to ensure structure size as they are + * directly (de)serialised from memory. + */ + + /* ensure the header structure has packed to the correct size */ + BUILD_BUG_ON(sizeof(struct mmal_msg_header) != 24); + + /* ensure message structure does not exceed maximum length */ + BUILD_BUG_ON(sizeof(struct mmal_msg) > MMAL_MSG_MAX_SIZE); + + /* mmal port struct is correct size */ + BUILD_BUG_ON(sizeof(struct mmal_port) != 64); + + /* create a vchi instance */ + status = vchi_initialise(&vchi_instance); + if (status) { + pr_err("Failed to initialise VCHI instance (status=%d)\n", + status); + return -EIO; + } + + status = vchi_connect(vchi_instance); + if (status) { + pr_err("Failed to connect VCHI instance (status=%d)\n", status); + return -EIO; + } + + instance = kzalloc(sizeof(*instance), GFP_KERNEL); + + if (!instance) + return -ENOMEM; + + mutex_init(&instance->vchiq_mutex); + + instance->bulk_scratch = vmalloc(PAGE_SIZE); + + mutex_init(&instance->context_map_lock); + idr_init_base(&instance->context_map, 1); + + params.callback_param = instance; + + instance->bulk_wq = alloc_ordered_workqueue("mmal-vchiq", + WQ_MEM_RECLAIM); + if (!instance->bulk_wq) + goto err_free; + + status = vchi_service_open(vchi_instance, ¶ms, &instance->handle); + if (status) { + pr_err("Failed to open VCHI service connection (status=%d)\n", + status); + goto err_close_services; + } + + vchi_service_release(instance->handle); + + *out_instance = instance; + + return 0; + +err_close_services: + vchi_service_close(instance->handle); + destroy_workqueue(instance->bulk_wq); +err_free: + vfree(instance->bulk_scratch); + kfree(instance); + return -ENODEV; +} +EXPORT_SYMBOL_GPL(vchiq_mmal_init); + +MODULE_DESCRIPTION("BCM2835 MMAL VCHIQ interface"); +MODULE_AUTHOR("Dave Stevenson, "); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h new file mode 100644 index 000000000000..47897e81ec58 --- /dev/null +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h @@ -0,0 +1,166 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Broadcom BM2835 V4L2 driver + * + * Copyright © 2013 Raspberry Pi (Trading) Ltd. + * + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom + * + * MMAL interface to VCHIQ message passing + */ + +#ifndef MMAL_VCHIQ_H +#define MMAL_VCHIQ_H + +#include "mmal-msg-format.h" + +#define MAX_PORT_COUNT 4 + +/* Maximum size of the format extradata. */ +#define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128 + +struct vchiq_mmal_instance; + +enum vchiq_mmal_es_type { + MMAL_ES_TYPE_UNKNOWN, /**< Unknown elementary stream type */ + MMAL_ES_TYPE_CONTROL, /**< Elementary stream of control commands */ + MMAL_ES_TYPE_AUDIO, /**< Audio elementary stream */ + MMAL_ES_TYPE_VIDEO, /**< Video elementary stream */ + MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream */ +}; + +struct vchiq_mmal_port_buffer { + unsigned int num; /* number of buffers */ + u32 size; /* size of buffers */ + u32 alignment; /* alignment of buffers */ +}; + +struct vchiq_mmal_port; + +typedef void (*vchiq_mmal_buffer_cb)( + struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, + int status, struct mmal_buffer *buffer, + unsigned long length, u32 mmal_flags, s64 dts, s64 pts); + +struct vchiq_mmal_port { + u32 enabled:1; + u32 handle; + u32 type; /* port type, cached to use on port info set */ + u32 index; /* port index, cached to use on port info set */ + + /* component port belongs to, allows simple deref */ + struct vchiq_mmal_component *component; + + struct vchiq_mmal_port *connected; /* port connected to */ + + /* buffer info */ + struct vchiq_mmal_port_buffer minimum_buffer; + struct vchiq_mmal_port_buffer recommended_buffer; + struct vchiq_mmal_port_buffer current_buffer; + + /* stream format */ + struct mmal_es_format_local format; + /* elementary stream format */ + union mmal_es_specific_format es; + + /* data buffers to fill */ + struct list_head buffers; + /* lock to serialise adding and removing buffers from list */ + spinlock_t slock; + + /* Count of buffers the VPU has yet to return */ + atomic_t buffers_with_vpu; + /* callback on buffer completion */ + vchiq_mmal_buffer_cb buffer_cb; + /* callback context */ + void *cb_ctx; +}; + +struct vchiq_mmal_component { + u32 enabled:1; + u32 handle; /* VideoCore handle for component */ + u32 inputs; /* Number of input ports */ + u32 outputs; /* Number of output ports */ + u32 clocks; /* Number of clock ports */ + struct vchiq_mmal_port control; /* control port */ + struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */ + struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */ + struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */ +}; + +int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance); +int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance); + +/* Initialise a mmal component and its ports + * + */ +int vchiq_mmal_component_init( + struct vchiq_mmal_instance *instance, + const char *name, + struct vchiq_mmal_component **component_out); + +int vchiq_mmal_component_finalise( + struct vchiq_mmal_instance *instance, + struct vchiq_mmal_component *component); + +int vchiq_mmal_component_enable( + struct vchiq_mmal_instance *instance, + struct vchiq_mmal_component *component); + +int vchiq_mmal_component_disable( + struct vchiq_mmal_instance *instance, + struct vchiq_mmal_component *component); + +/* enable a mmal port + * + * enables a port and if a buffer callback provided enque buffer + * headers as appropriate for the port. + */ +int vchiq_mmal_port_enable( + struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, + vchiq_mmal_buffer_cb buffer_cb); + +/* disable a port + * + * disable a port will dequeue any pending buffers + */ +int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port); + +int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, + u32 parameter, + void *value, + u32 value_size); + +int vchiq_mmal_port_parameter_get(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, + u32 parameter, + void *value, + u32 *value_size); + +int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port); + +int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *src, + struct vchiq_mmal_port *dst); + +int vchiq_mmal_version(struct vchiq_mmal_instance *instance, + u32 *major_out, + u32 *minor_out); + +int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance, + struct vchiq_mmal_port *port, + struct mmal_buffer *buf); + +int mmal_vchi_buffer_init(struct vchiq_mmal_instance *instance, + struct mmal_buffer *buf); +int mmal_vchi_buffer_cleanup(struct mmal_buffer *buf); +#endif /* MMAL_VCHIQ_H */ -- cgit v1.2.3-58-ga151 From 8c589e1794a31e9a381916b0280260ab601e4d6e Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Tue, 23 Jun 2020 18:41:48 +0200 Subject: staging: mmal-vchiq: Allocate and free components as required The existing code assumed that there would only ever be 4 components, and never freed the entries once used. Allow arbitrary creation and destruction of components. Signed-off-by: Dave Stevenson Signed-off-by: Jacopo Mondi Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200623164235.29566-3-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 29 ++++++++++++++-------- .../staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 1 + 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index daf21087f8f9..cbe262b111fe 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -32,8 +32,11 @@ #define USE_VCHIQ_ARM #include "interface/vchi/vchi.h" -/* maximum number of components supported */ -#define VCHIQ_MMAL_MAX_COMPONENTS 4 +/* + * maximum number of components supported. + * This matches the maximum permitted by default on the VPU + */ +#define VCHIQ_MMAL_MAX_COMPONENTS 64 /*#define FULL_MSG_DUMP 1*/ @@ -168,8 +171,6 @@ struct vchiq_mmal_instance { /* protect accesses to context_map */ struct mutex context_map_lock; - /* component to use next */ - int component_idx; struct vchiq_mmal_component component[VCHIQ_MMAL_MAX_COMPONENTS]; /* ordered workqueue to process all bulk operations */ @@ -1626,18 +1627,24 @@ int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance, { int ret; int idx; /* port index */ - struct vchiq_mmal_component *component; + struct vchiq_mmal_component *component = NULL; if (mutex_lock_interruptible(&instance->vchiq_mutex)) return -EINTR; - if (instance->component_idx == VCHIQ_MMAL_MAX_COMPONENTS) { + for (idx = 0; idx < VCHIQ_MMAL_MAX_COMPONENTS; idx++) { + if (!instance->component[idx].in_use) { + component = &instance->component[idx]; + component->in_use = 1; + break; + } + } + + if (!component) { ret = -EINVAL; /* todo is this correct error? */ goto unlock; } - component = &instance->component[instance->component_idx]; - ret = create_component(instance, component, name); if (ret < 0) { pr_err("%s: failed to create component %d (Not enough GPU mem?)\n", @@ -1688,8 +1695,6 @@ int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance, goto release_component; } - instance->component_idx++; - *component_out = component; mutex_unlock(&instance->vchiq_mutex); @@ -1699,6 +1704,8 @@ int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance, release_component: destroy_component(instance, component); unlock: + if (component) + component->in_use = 0; mutex_unlock(&instance->vchiq_mutex); return ret; @@ -1721,6 +1728,8 @@ int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance, ret = destroy_component(instance, component); + component->in_use = 0; + mutex_unlock(&instance->vchiq_mutex); return ret; diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h index 47897e81ec58..4e34728d87e5 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h @@ -82,6 +82,7 @@ struct vchiq_mmal_port { }; struct vchiq_mmal_component { + u32 in_use:1; u32 enabled:1; u32 handle; /* VideoCore handle for component */ u32 inputs; /* Number of input ports */ -- cgit v1.2.3-58-ga151 From 92cd1b5d65f5c67147c7da39a3c2ad7e6ff81027 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Fri, 19 Jun 2020 12:36:30 +0200 Subject: staging: ion: fix common struct sg_table related issues The Documentation/DMA-API-HOWTO.txt states that the dma_map_sg() function returns the number of the created entries in the DMA address space. However the subsequent calls to the dma_sync_sg_for_{device,cpu}() and dma_unmap_sg must be called with the original number of the entries passed to the dma_map_sg(). struct sg_table is a common structure used for describing a non-contiguous memory buffer, used commonly in the DRM and graphics subsystems. It consists of a scatterlist with memory pages and DMA addresses (sgl entry), as well as the number of scatterlist entries: CPU pages (orig_nents entry) and DMA mapped pages (nents entry). It turned out that it was a common mistake to misuse nents and orig_nents entries, calling DMA-mapping functions with a wrong number of entries or ignoring the number of mapped entries returned by the dma_map_sg() function. To avoid such issues, lets use a common dma-mapping wrappers operating directly on the struct sg_table objects and use scatterlist page iterators where possible. This, almost always, hides references to the nents and orig_nents entries, making the code robust, easier to follow and copy/paste safe. Signed-off-by: Marek Szyprowski Link: https://lore.kernel.org/r/20200619103636.11974-31-m.szyprowski@samsung.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 25 +++++++-------- drivers/staging/android/ion/ion_heap.c | 44 ++++++++------------------- drivers/staging/android/ion/ion_system_heap.c | 2 +- 3 files changed, 25 insertions(+), 46 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 38b51eace4f9..3c9f09506ffa 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -147,14 +147,14 @@ static struct sg_table *dup_sg_table(struct sg_table *table) if (!new_table) return ERR_PTR(-ENOMEM); - ret = sg_alloc_table(new_table, table->nents, GFP_KERNEL); + ret = sg_alloc_table(new_table, table->orig_nents, GFP_KERNEL); if (ret) { kfree(new_table); return ERR_PTR(-ENOMEM); } new_sg = new_table->sgl; - for_each_sg(table->sgl, sg, table->nents, i) { + for_each_sgtable_sg(table, sg, i) { memcpy(new_sg, sg, sizeof(*sg)); new_sg->dma_address = 0; new_sg = sg_next(new_sg); @@ -224,12 +224,13 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment, { struct ion_dma_buf_attachment *a = attachment->priv; struct sg_table *table; + int ret; table = a->table; - if (!dma_map_sg(attachment->dev, table->sgl, table->nents, - direction)) - return ERR_PTR(-ENOMEM); + ret = dma_map_sgtable(attachment->dev, table, direction, 0); + if (ret) + return ERR_PTR(ret); return table; } @@ -238,7 +239,7 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment, struct sg_table *table, enum dma_data_direction direction) { - dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction); + dma_unmap_sgtable(attachment->dev, table, direction, 0); } static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) @@ -296,10 +297,8 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf, } mutex_lock(&buffer->lock); - list_for_each_entry(a, &buffer->attachments, list) { - dma_sync_sg_for_cpu(a->dev, a->table->sgl, a->table->nents, - direction); - } + list_for_each_entry(a, &buffer->attachments, list) + dma_sync_sgtable_for_cpu(a->dev, a->table, direction); unlock: mutex_unlock(&buffer->lock); @@ -319,10 +318,8 @@ static int ion_dma_buf_end_cpu_access(struct dma_buf *dmabuf, } mutex_lock(&buffer->lock); - list_for_each_entry(a, &buffer->attachments, list) { - dma_sync_sg_for_device(a->dev, a->table->sgl, a->table->nents, - direction); - } + list_for_each_entry(a, &buffer->attachments, list) + dma_sync_sgtable_for_device(a->dev, a->table, direction); mutex_unlock(&buffer->lock); return 0; diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c index 9c23b2382a1e..79f27949edda 100644 --- a/drivers/staging/android/ion/ion_heap.c +++ b/drivers/staging/android/ion/ion_heap.c @@ -20,8 +20,7 @@ void *ion_heap_map_kernel(struct ion_heap *heap, struct ion_buffer *buffer) { - struct scatterlist *sg; - int i, j; + struct sg_page_iter piter; void *vaddr; pgprot_t pgprot; struct sg_table *table = buffer->sg_table; @@ -38,14 +37,11 @@ void *ion_heap_map_kernel(struct ion_heap *heap, else pgprot = pgprot_writecombine(PAGE_KERNEL); - for_each_sg(table->sgl, sg, table->nents, i) { - int npages_this_entry = PAGE_ALIGN(sg->length) / PAGE_SIZE; - struct page *page = sg_page(sg); - - BUG_ON(i >= npages); - for (j = 0; j < npages_this_entry; j++) - *(tmp++) = page++; + for_each_sgtable_page(table, &piter, 0) { + BUG_ON(tmp - pages >= npages); + *tmp++ = sg_page_iter_page(&piter); } + vaddr = vmap(pages, npages, VM_MAP, pgprot); vfree(pages); @@ -64,32 +60,19 @@ void ion_heap_unmap_kernel(struct ion_heap *heap, int ion_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer, struct vm_area_struct *vma) { + struct sg_page_iter piter; struct sg_table *table = buffer->sg_table; unsigned long addr = vma->vm_start; - unsigned long offset = vma->vm_pgoff * PAGE_SIZE; - struct scatterlist *sg; - int i; int ret; - for_each_sg(table->sgl, sg, table->nents, i) { - struct page *page = sg_page(sg); - unsigned long remainder = vma->vm_end - addr; - unsigned long len = sg->length; + for_each_sgtable_page(table, &piter, vma->vm_pgoff) { + struct page *page = sg_page_iter_page(&piter); - if (offset >= sg->length) { - offset -= sg->length; - continue; - } else if (offset) { - page += offset / PAGE_SIZE; - len = sg->length - offset; - offset = 0; - } - len = min(len, remainder); - ret = remap_pfn_range(vma, addr, page_to_pfn(page), len, + ret = remap_pfn_range(vma, addr, page_to_pfn(page), PAGE_SIZE, vma->vm_page_prot); if (ret) return ret; - addr += len; + addr += PAGE_SIZE; if (addr >= vma->vm_end) return 0; } @@ -109,15 +92,14 @@ static int ion_heap_clear_pages(struct page **pages, int num, pgprot_t pgprot) return 0; } -static int ion_heap_sglist_zero(struct scatterlist *sgl, unsigned int nents, - pgprot_t pgprot) +static int ion_heap_sglist_zero(struct sg_table *sgt, pgprot_t pgprot) { int p = 0; int ret = 0; struct sg_page_iter piter; struct page *pages[32]; - for_each_sg_page(sgl, &piter, nents, 0) { + for_each_sgtable_page(sgt, &piter, 0) { pages[p++] = sg_page_iter_page(&piter); if (p == ARRAY_SIZE(pages)) { ret = ion_heap_clear_pages(pages, p, pgprot); @@ -142,7 +124,7 @@ int ion_heap_buffer_zero(struct ion_buffer *buffer) else pgprot = pgprot_writecombine(PAGE_KERNEL); - return ion_heap_sglist_zero(table->sgl, table->nents, pgprot); + return ion_heap_sglist_zero(table, pgprot); } void ion_heap_freelist_add(struct ion_heap *heap, struct ion_buffer *buffer) diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index b83a1d16bd89..eac0632ab4e8 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -162,7 +162,7 @@ static void ion_system_heap_free(struct ion_buffer *buffer) if (!(buffer->private_flags & ION_PRIV_FLAG_SHRINKER_FREE)) ion_heap_buffer_zero(buffer); - for_each_sg(table->sgl, sg, table->nents, i) + for_each_sgtable_sg(table, sg, i) free_buffer_page(sys_heap, buffer, sg_page(sg)); sg_free_table(table); kfree(table); -- cgit v1.2.3-58-ga151 From f00b2a2fcb8c71f0c5f6b38f87370c3dfb7b9477 Mon Sep 17 00:00:00 2001 From: Brooke Basile Date: Fri, 26 Jun 2020 11:36:36 -0400 Subject: staging: rtl8188eu: Fix comment formatting Fix the following checkpatch warnings: WARNING: Block comments use * on subsequent lines WARNING: Block comments use a trailing */ on a separate line Signed-off-by: Brooke Basile Link: https://lore.kernel.org/r/20200626153639.8097-1-brookebasile@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index 5630d5d763db..2de78dc236de 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -139,9 +139,11 @@ u8 *rtw_set_ie return pbuf + len + 2; } -/*---------------------------------------------------------------------------- -index: the information element id index, limit is the limit for search ------------------------------------------------------------------------------*/ +/* + * ---------------------------------------------------------------------------- + * index: the information element id index, limit is the limit for search + * ---------------------------------------------------------------------------- + */ u8 *rtw_get_ie(u8 *pbuf, int index, uint *len, int limit) { int tmp, i; @@ -679,9 +681,11 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, { unsigned int oui; - /* first 3 bytes in vendor specific information element are the IEEE + /* + * first 3 bytes in vendor specific information element are the IEEE * OUI of the vendor. The following byte is used a vendor specific - * sub-type. */ + * sub-type. + */ if (elen < 4) { if (show_errors) { DBG_88E("short vendor specific information element ignored (len=%lu)\n", @@ -693,12 +697,16 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, oui = RTW_GET_BE24(pos); switch (oui) { case OUI_MICROSOFT: - /* Microsoft/Wi-Fi information elements are further typed and - * subtyped */ + /* + * Microsoft/Wi-Fi information elements are further typed and + * subtyped + */ switch (pos[3]) { case 1: - /* Microsoft OUI (00:50:F2) with OUI Type 1: - * real WPA information element */ + /* + * Microsoft OUI (00:50:F2) with OUI Type 1: + * real WPA information element + */ elems->wpa_ie = pos; elems->wpa_ie_len = elen; break; -- cgit v1.2.3-58-ga151 From cdc9750e1f6bc94686354dabd236cc590b6f99b1 Mon Sep 17 00:00:00 2001 From: Brooke Basile Date: Fri, 26 Jun 2020 11:36:38 -0400 Subject: staging: rtl8188eu: Fix strings split across lines Fix the following checkpatch warning: WARNING: quoted string split across lines Signed-off-by: Brooke Basile Link: https://lore.kernel.org/r/20200626153639.8097-2-brookebasile@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index 2de78dc236de..80ef90613503 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -381,8 +381,8 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis left -= 2; if (count == 0 || left < count * WPA_SELECTOR_LEN) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie count botch (pairwise), " - "count %u left %u", __func__, count, left)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie count botch (pairwise), count %u left %u", + __func__, count, left)); return _FAIL; } @@ -448,8 +448,8 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi left -= 2; if (count == 0 || left < count * RSN_SELECTOR_LEN) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie count botch (pairwise), " - "count %u left %u", __func__, count, left)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie count botch (pairwise), count %u left %u", + __func__, count, left)); return _FAIL; } @@ -944,8 +944,8 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; pnetwork->BcnInfo.group_cipher = group_cipher; pnetwork->BcnInfo.is_8021x = is8021x; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s: pnetwork->pairwise_cipher: %d," - "pnetwork->group_cipher is %d, is_8021x is %d", __func__, pnetwork->BcnInfo.pairwise_cipher, + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s: pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_8021x is %d", + __func__, pnetwork->BcnInfo.pairwise_cipher, pnetwork->BcnInfo.group_cipher, pnetwork->BcnInfo.is_8021x)); ret = _SUCCESS; } -- cgit v1.2.3-58-ga151 From a8e773132f131511357d9529c289ed52330e232a Mon Sep 17 00:00:00 2001 From: Brooke Basile Date: Fri, 26 Jun 2020 11:36:40 -0400 Subject: staging: rtl8188eu: Fix indentation Fix the following checkpatch warning: WARNING: suspect code indent for conditional statements (16, 32) Signed-off-by: Brooke Basile Link: https://lore.kernel.org/r/20200626153639.8097-3-brookebasile@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index 80ef90613503..3316059238e0 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -494,23 +494,23 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie authmode = in_ie[cnt]; if ((authmode == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4))) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", - sec_idx, in_ie[cnt + 1] + 2)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", + sec_idx, in_ie[cnt + 1] + 2)); - if (wpa_ie) { - memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); + if (wpa_ie) { + memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); - for (i = 0; i < (in_ie[cnt + 1] + 2); i += 8) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n", - wpa_ie[i], wpa_ie[i + 1], wpa_ie[i + 2], wpa_ie[i + 3], wpa_ie[i + 4], - wpa_ie[i + 5], wpa_ie[i + 6], wpa_ie[i + 7])); - } + for (i = 0; i < (in_ie[cnt + 1] + 2); i += 8) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n", + wpa_ie[i], wpa_ie[i + 1], wpa_ie[i + 2], wpa_ie[i + 3], wpa_ie[i + 4], + wpa_ie[i + 5], wpa_ie[i + 6], wpa_ie[i + 7])); } + } - *wpa_len = in_ie[cnt + 1] + 2; - cnt += in_ie[cnt + 1] + 2; /* get next */ + *wpa_len = in_ie[cnt + 1] + 2; + cnt += in_ie[cnt + 1] + 2; /* get next */ } else { if (authmode == _WPA2_IE_ID_) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, -- cgit v1.2.3-58-ga151 From 1113c90c48df9742bd4ac86ea4770b1fd2fb0adf Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 26 Jun 2020 05:57:54 +0800 Subject: staging: qlge: fix trailing */ in block comment Remove trailing "*/" in block comments. Signed-off-by: Coiby Xu Link: https://lore.kernel.org/r/20200625215755.70329-2-coiby.xu@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_main.c | 3 ++- drivers/staging/qlge/qlge_mpi.c | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 1650de13842f..aaecf2b0f9a1 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -3244,7 +3244,8 @@ static void ql_set_irq_mask(struct ql_adapter *qdev, struct intr_context *ctx) */ ctx->irq_mask = (1 << qdev->rx_ring[vect].cq_id); /* Add the TX ring(s) serviced by this vector - * to the mask. */ + * to the mask. + */ for (j = 0; j < tx_rings_per_vector; j++) { ctx->irq_mask |= (1 << qdev->rx_ring[qdev->rss_ring_count + diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c index 60c08d9cc034..3bb08d290525 100644 --- a/drivers/staging/qlge/qlge_mpi.c +++ b/drivers/staging/qlge/qlge_mpi.c @@ -389,7 +389,8 @@ static void ql_init_fw_done(struct ql_adapter *qdev, struct mbox_params *mbcp) * This can get called iteratively from the mpi_work thread * when events arrive via an interrupt. * It also gets called when a mailbox command is polling for - * it's completion. */ + * it's completion. + */ static int ql_mpi_handler(struct ql_adapter *qdev, struct mbox_params *mbcp) { int status; @@ -520,7 +521,7 @@ end: * changed when a mailbox command is waiting * for a response and an AEN arrives and * is handled. - * */ + */ mbcp->out_count = orig_count; return status; } @@ -555,7 +556,8 @@ static int ql_mailbox_command(struct ql_adapter *qdev, struct mbox_params *mbcp) * here because some AEN might arrive while * we're waiting for the mailbox command to * complete. If more than 5 seconds expire we can - * assume something is wrong. */ + * assume something is wrong. + */ count = jiffies + HZ * MAILBOX_TIMEOUT; do { /* Wait for the interrupt to come in. */ @@ -1178,7 +1180,7 @@ void ql_mpi_idc_work(struct work_struct *work) /* Signal the resulting link up AEN * that the frame routing and mac addr * needs to be set. - * */ + */ set_bit(QL_CAM_RT_SET, &qdev->flags); /* Do ACK if required */ if (timeout) { -- cgit v1.2.3-58-ga151 From e42f623c3ade190dee08790d9b91b2b0370cb3d9 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 26 Jun 2020 05:57:55 +0800 Subject: staging: qlge: fix else after return or break Remove unnecessary elses after return or break. Signed-off-by: Coiby Xu Link: https://lore.kernel.org/r/20200625215755.70329-3-coiby.xu@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_dbg.c | 23 ++++++++++------------- drivers/staging/qlge/qlge_main.c | 8 ++++---- drivers/staging/qlge/qlge_mpi.c | 4 ++-- 3 files changed, 16 insertions(+), 19 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 058889687907..87433510a224 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -1391,12 +1391,11 @@ static void ql_dump_cam_entries(struct ql_adapter *qdev) pr_err("%s: Failed read of mac index register\n", __func__); return; - } else { - if (value[0]) - pr_err("%s: CAM index %d CAM Lookup Lower = 0x%.08x:%.08x, Output = 0x%.08x\n", - qdev->ndev->name, i, value[1], value[0], - value[2]); } + if (value[0]) + pr_err("%s: CAM index %d CAM Lookup Lower = 0x%.08x:%.08x, Output = 0x%.08x\n", + qdev->ndev->name, i, value[1], value[0], + value[2]); } for (i = 0; i < 32; i++) { if (ql_get_mac_addr_reg @@ -1404,11 +1403,10 @@ static void ql_dump_cam_entries(struct ql_adapter *qdev) pr_err("%s: Failed read of mac index register\n", __func__); return; - } else { - if (value[0]) - pr_err("%s: MCAST index %d CAM Lookup Lower = 0x%.08x:%.08x\n", - qdev->ndev->name, i, value[1], value[0]); } + if (value[0]) + pr_err("%s: MCAST index %d CAM Lookup Lower = 0x%.08x:%.08x\n", + qdev->ndev->name, i, value[1], value[0]); } ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK); } @@ -1427,11 +1425,10 @@ void ql_dump_routing_entries(struct ql_adapter *qdev) pr_err("%s: Failed read of routing index register\n", __func__); return; - } else { - if (value) - pr_err("%s: Routing Mask %d = 0x%.08x\n", - qdev->ndev->name, i, value); } + if (value) + pr_err("%s: Routing Mask %d = 0x%.08x\n", + qdev->ndev->name, i, value); } ql_sem_unlock(qdev, SEM_RT_IDX_MASK); } diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index aaecf2b0f9a1..0054c454506b 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -3778,10 +3778,10 @@ static int ql_wol(struct ql_adapter *qdev) "Failed to set magic packet on %s.\n", qdev->ndev->name); return status; - } else - netif_info(qdev, drv, qdev->ndev, - "Enabled magic packet successfully on %s.\n", - qdev->ndev->name); + } + netif_info(qdev, drv, qdev->ndev, + "Enabled magic packet successfully on %s.\n", + qdev->ndev->name); wol |= MB_WOL_MAGIC_PKT; } diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c index 3bb08d290525..fa178fc642a6 100644 --- a/drivers/staging/qlge/qlge_mpi.c +++ b/drivers/staging/qlge/qlge_mpi.c @@ -276,8 +276,8 @@ static void ql_link_up(struct ql_adapter *qdev, struct mbox_params *mbcp) netif_err(qdev, ifup, qdev->ndev, "Failed to init CAM/Routing tables.\n"); return; - } else - clear_bit(QL_CAM_RT_SET, &qdev->flags); + } + clear_bit(QL_CAM_RT_SET, &qdev->flags); } /* Queue up a worker to check the frame -- cgit v1.2.3-58-ga151 From 5bfb7eadc5874a3a08dd173d66a16a1ed0548444 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 27 Jun 2020 11:06:00 +0200 Subject: staging: rtl8188eu: remove blank lines in header files Remove blank lines in header files to clear checkpatch issues. CHECK: Please don't use multiple blank lines Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200627090600.21354-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/drv_types.h | 1 - drivers/staging/rtl8188eu/include/hal_com.h | 1 - drivers/staging/rtl8188eu/include/ieee80211.h | 11 ----------- drivers/staging/rtl8188eu/include/odm.h | 4 ---- drivers/staging/rtl8188eu/include/odm_debug.h | 2 -- drivers/staging/rtl8188eu/include/pwrseq.h | 3 --- drivers/staging/rtl8188eu/include/pwrseqcmd.h | 1 - drivers/staging/rtl8188eu/include/recv_osdep.h | 2 -- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 5 ----- drivers/staging/rtl8188eu/include/rtl8188e_spec.h | 1 - drivers/staging/rtl8188eu/include/rtl8188e_xmit.h | 1 - drivers/staging/rtl8188eu/include/rtw_debug.h | 1 - drivers/staging/rtl8188eu/include/rtw_ioctl.h | 2 -- drivers/staging/rtl8188eu/include/rtw_ioctl_set.h | 1 - drivers/staging/rtl8188eu/include/rtw_mlme_ext.h | 3 --- drivers/staging/rtl8188eu/include/rtw_recv.h | 3 --- drivers/staging/rtl8188eu/include/rtw_rf.h | 1 - drivers/staging/rtl8188eu/include/rtw_security.h | 3 --- drivers/staging/rtl8188eu/include/rtw_xmit.h | 1 - drivers/staging/rtl8188eu/include/wifi.h | 5 ----- drivers/staging/rtl8188eu/include/wlan_bssdef.h | 3 --- 21 files changed, 55 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/drv_types.h b/drivers/staging/rtl8188eu/include/drv_types.h index 35c0946bc65d..0a3acb378d6d 100644 --- a/drivers/staging/rtl8188eu/include/drv_types.h +++ b/drivers/staging/rtl8188eu/include/drv_types.h @@ -10,7 +10,6 @@ ------------------------------------------------------------------------------*/ - #ifndef __DRV_TYPES_H__ #define __DRV_TYPES_H__ diff --git a/drivers/staging/rtl8188eu/include/hal_com.h b/drivers/staging/rtl8188eu/include/hal_com.h index 93cbbe7ba1fd..542e6e93ff8e 100644 --- a/drivers/staging/rtl8188eu/include/hal_com.h +++ b/drivers/staging/rtl8188eu/include/hal_com.h @@ -137,7 +137,6 @@ #include "HalVerDef.h" void dump_chip_info(struct HAL_VERSION ChipVersion); - /* return the final channel plan decision */ u8 hal_com_get_channel_plan(u8 hw_channel_plan, u8 sw_channel_plan, u8 def_channel_plan, bool load_fail); diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h b/drivers/staging/rtl8188eu/include/ieee80211.h index 75f0ebe0faf5..83218e7ec0a9 100644 --- a/drivers/staging/rtl8188eu/include/ieee80211.h +++ b/drivers/staging/rtl8188eu/include/ieee80211.h @@ -90,7 +90,6 @@ enum { #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7 - #define IEEE_CRYPT_ALG_NAME_LEN 16 #define WPA_CIPHER_NONE BIT(0) @@ -99,8 +98,6 @@ enum { #define WPA_CIPHER_TKIP BIT(3) #define WPA_CIPHER_CCMP BIT(4) - - #define WPA_SELECTOR_LEN 4 extern u8 RTW_WPA_OUI_TYPE[]; extern u8 WPA_AUTH_KEY_MGMT_NONE[]; @@ -113,7 +110,6 @@ extern u8 WPA_CIPHER_SUITE_WRAP[]; extern u8 WPA_CIPHER_SUITE_CCMP[]; extern u8 WPA_CIPHER_SUITE_WEP104[]; - #define RSN_HEADER_LEN 4 #define RSN_SELECTOR_LEN 4 @@ -192,7 +188,6 @@ enum NETWORK_TYPE { #define IsSupportedTxMCS(NetType) \ ((NetType) & (WIRELESS_11_24N | WIRELESS_11_5N) ? true : false) - struct ieee_param { u32 cmd; u8 sta_addr[ETH_ALEN]; @@ -270,11 +265,9 @@ struct sta_data { * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ - #define IEEE80211_HLEN 30 #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) - /* this is stolen from ipw2200 driver */ #define IEEE_IBSS_MAC_HASH_SIZE 31 @@ -297,7 +290,6 @@ enum eap_type { #define RTW_IEEE80211_SCTL_FRAG 0x000F #define RTW_IEEE80211_SCTL_SEQ 0xFFF0 - #define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0) #define RTW_ERP_INFO_USE_PROTECTION BIT(1) #define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2) @@ -354,7 +346,6 @@ struct ieee80211_snap_hdr { #define IEEE80211_CCK_RATE_LEN 4 #define IEEE80211_NUM_OFDM_RATESLEN 8 - #define IEEE80211_CCK_RATE_1MB 0x02 #define IEEE80211_CCK_RATE_2MB 0x04 #define IEEE80211_CCK_RATE_5MB 0x0B @@ -613,7 +604,6 @@ enum rtw_ieee80211_back_parties { #define WME_TSPEC_DIRECTION_DOWNLINK 1 #define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3 - #define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */ #define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */ @@ -758,7 +748,6 @@ uint rtw_get_rateset_len(u8 *rateset); struct registry_priv; int rtw_generate_ie(struct registry_priv *pregistrypriv); - int rtw_get_bit_value_from_ieee_value(u8 val); bool rtw_is_cckrates_included(u8 *rate); diff --git a/drivers/staging/rtl8188eu/include/odm.h b/drivers/staging/rtl8188eu/include/odm.h index 9d39fe13626a..c6b6ba191e1b 100644 --- a/drivers/staging/rtl8188eu/include/odm.h +++ b/drivers/staging/rtl8188eu/include/odm.h @@ -5,7 +5,6 @@ * ******************************************************************************/ - #ifndef __HALDMOUTSRC_H__ #define __HALDMOUTSRC_H__ @@ -41,7 +40,6 @@ #define DPK_DELTA_MAPPING_NUM 13 #define index_mapping_HP_NUM 15 - /* */ /* 3 PSD Handler */ /* 3============================================================ */ @@ -913,7 +911,6 @@ enum dm_dig_op { #define DM_SCAN_RSSI_TH 0x14 /* scan return issue for LC */ - #define DM_false_ALARM_THRESH_LOW 400 #define DM_false_ALARM_THRESH_HIGH 1000 @@ -991,7 +988,6 @@ enum dm_dig_op { /* 3 BB Power Save */ /* 3=========================================================== */ - enum dm_1r_cca { CCA_1R = 0, CCA_2R = 1, diff --git a/drivers/staging/rtl8188eu/include/odm_debug.h b/drivers/staging/rtl8188eu/include/odm_debug.h index 7ab2483bdacc..857c64b8d2f4 100644 --- a/drivers/staging/rtl8188eu/include/odm_debug.h +++ b/drivers/staging/rtl8188eu/include/odm_debug.h @@ -5,11 +5,9 @@ * ******************************************************************************/ - #ifndef __ODM_DBG_H__ #define __ODM_DBG_H__ - /* */ /* Define the debug levels */ /* */ diff --git a/drivers/staging/rtl8188eu/include/pwrseq.h b/drivers/staging/rtl8188eu/include/pwrseq.h index aa58db5fbd80..c4b76064476f 100644 --- a/drivers/staging/rtl8188eu/include/pwrseq.h +++ b/drivers/staging/rtl8188eu/include/pwrseq.h @@ -43,7 +43,6 @@ #define RTL8188E_TRANS_LPS_TO_ACT_STEPS 15 #define RTL8188E_TRANS_END_STEPS 1 - #define RTL8188E_TRANS_CARDEMU_TO_ACT \ /* format * { offset, cut_msk, cmd, msk, value @@ -179,7 +178,6 @@ {0x0553, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(5), BIT(5)}, \ /*Respond TxOK to scheduler*/ - #define RTL8188E_TRANS_LPS_TO_ACT \ /* format * { offset, cut_msk, cmd, msk, @@ -213,7 +211,6 @@ */ \ {0xFFFF, PWR_CUT_ALL_MSK, PWR_CMD_END, 0, 0}, - extern struct wl_pwr_cfg rtl8188E_power_on_flow [RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS + RTL8188E_TRANS_END_STEPS]; extern struct wl_pwr_cfg rtl8188E_radio_off_flow diff --git a/drivers/staging/rtl8188eu/include/pwrseqcmd.h b/drivers/staging/rtl8188eu/include/pwrseqcmd.h index 8c73322a0314..05f117e2a105 100644 --- a/drivers/staging/rtl8188eu/include/pwrseqcmd.h +++ b/drivers/staging/rtl8188eu/include/pwrseqcmd.h @@ -27,7 +27,6 @@ #define PWR_CUT_G_MSK BIT(7) #define PWR_CUT_ALL_MSK 0xFF - enum pwrseq_cmd_delat_unit { PWRSEQ_DELAY_US, PWRSEQ_DELAY_MS, diff --git a/drivers/staging/rtl8188eu/include/recv_osdep.h b/drivers/staging/rtl8188eu/include/recv_osdep.h index d2341521cc8e..3b771702810d 100644 --- a/drivers/staging/rtl8188eu/include/recv_osdep.h +++ b/drivers/staging/rtl8188eu/include/recv_osdep.h @@ -10,11 +10,9 @@ #include #include - int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); void _rtw_free_recv_priv(struct recv_priv *precvpriv); - s32 rtw_recv_entry(struct recv_frame *precv_frame); int rtw_recv_indicatepkt(struct adapter *adapter, struct recv_frame *recv_frame); diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index eb4655ecf6e0..ba7c98712934 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -7,7 +7,6 @@ #ifndef __RTL8188E_HAL_H__ #define __RTL8188E_HAL_H__ - /* include HAL Related header after HAL Related compiling flags */ #include "rtl8188e_spec.h" #include "hal8188e_phy_reg.h" @@ -78,7 +77,6 @@ enum usb_rx_agg_mode { #define MAX_TX_REPORT_BUFFER_SIZE 0x0400 /* 1k */ - /* BK, BE, VI, VO, HCCA, MANAGEMENT, COMMAND, HIGH, BEACON. */ #define MAX_TX_QUEUE 9 @@ -246,7 +244,6 @@ struct hal_data_8188e { u8 CurrentBW2024GTxPwrIdx; u8 CurrentBW4024GTxPwrIdx; - /* Read/write are allow for following hardware information variables */ u8 framesync; u32 framesyncC34; @@ -285,7 +282,6 @@ struct hal_data_8188e { u8 AntDivCfg; u8 TRxAntDivType; - u8 bDumpRxPkt;/* for debug */ u8 bDumpTxPkt;/* for debug */ u8 FwRsvdPageStartOffset; /* Reserve page start offset except @@ -335,7 +331,6 @@ void Hal_GetChnlGroup88E(u8 chnl, u8 *group); void _8051Reset88E(struct adapter *padapter); void rtl8188e_InitializeFirmwareVars(struct adapter *padapter); - s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy); /* EFuse */ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_spec.h b/drivers/staging/rtl8188eu/include/rtl8188e_spec.h index be30c9434a29..55cce1f6bd77 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_spec.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_spec.h @@ -18,7 +18,6 @@ #define RXPKT_BUF_SELECT 0xA5 #define DISABLE_TRXPKT_BUF_ACCESS 0x0 - /* 0x0000h ~ 0x00FFh System Configuration */ #define REG_SYS_ISO_CTRL 0x0000 #define REG_SYS_FUNC_EN 0x0002 diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h index c6c2ad20d9cf..49884cceb349 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h @@ -50,7 +50,6 @@ #define FSG BIT(27) #define OWN BIT(31) - /* OFFSET 4 */ #define PKT_OFFSET_SZ 0 #define QSEL_SHT 8 diff --git a/drivers/staging/rtl8188eu/include/rtw_debug.h b/drivers/staging/rtl8188eu/include/rtw_debug.h index 9840e596feaa..1fdf16124a0d 100644 --- a/drivers/staging/rtl8188eu/include/rtw_debug.h +++ b/drivers/staging/rtl8188eu/include/rtw_debug.h @@ -21,7 +21,6 @@ #define _drv_info_ 8 #define _drv_debug_ 9 - #define _module_rtl871x_xmit_c_ BIT(0) #define _module_xmit_osdep_c_ BIT(1) #define _module_rtl871x_recv_c_ BIT(2) diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl.h b/drivers/staging/rtl8188eu/include/rtw_ioctl.h index 5d773c84f11b..f681f9ebeafe 100644 --- a/drivers/staging/rtl8188eu/include/rtw_ioctl.h +++ b/drivers/staging/rtl8188eu/include/rtw_ioctl.h @@ -10,7 +10,6 @@ #include #include - #ifndef OID_802_11_CAPABILITY #define OID_802_11_CAPABILITY 0x0d010122 #endif @@ -19,7 +18,6 @@ #define OID_802_11_PMKID 0x0d010123 #endif - /* For DDK-defined OIDs */ #define OID_NDIS_SEG1 0x00010100 #define OID_NDIS_SEG2 0x00010200 diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h b/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h index 0be99f6d75ba..7078f8252fa0 100644 --- a/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h +++ b/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h @@ -9,7 +9,6 @@ #include - typedef u8 NDIS_802_11_PMKID_VALUE[16]; u8 rtw_set_802_11_authentication_mode(struct adapter *adapt, diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index d70780c8fd62..565bfe46256c 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -11,7 +11,6 @@ #include #include - /* Commented by Albert 20101105 */ /* Increase the SURVEY_TO value from 100 to 150 ( 100ms to 150ms ) */ /* The Realtek 8188CE SoftAP will spend around 100ms to send the probe response after receiving the probe request. */ @@ -66,7 +65,6 @@ #define _HW_STATE_STATION_ 0x02 #define _HW_STATE_AP_ 0x03 - #define _1M_RATE_ 0 #define _2M_RATE_ 1 #define _5M_RATE_ 2 @@ -681,7 +679,6 @@ enum rtw_c2h_event { MAX_C2HEVT }; - #ifdef _RTW_MLME_EXT_C_ static struct fwevent wlanevents[] = { diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 8fc500496f92..e383cb119e1b 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -10,7 +10,6 @@ #include #include - #define NR_RECVFRAME 256 #define RXFRAME_ALIGN 8 @@ -127,7 +126,6 @@ struct rx_pkt_attrib { struct phy_info phy_info; }; - /* These definition is used for Rx packet reordering. */ #define SN_LESS(a, b) (((a - b) & 0x800) != 0) #define SN_EQUAL(a, b) (a == b) @@ -254,7 +252,6 @@ static inline s32 translate_percentage_to_dbm(u32 sig_stren_index) return power; } - struct sta_info; void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv); diff --git a/drivers/staging/rtl8188eu/include/rtw_rf.h b/drivers/staging/rtl8188eu/include/rtw_rf.h index c3847cf16ec1..aabacb41bdde 100644 --- a/drivers/staging/rtl8188eu/include/rtw_rf.h +++ b/drivers/staging/rtl8188eu/include/rtw_rf.h @@ -114,5 +114,4 @@ enum rt_rf_type_def { u32 rtw_ch2freq(u32 ch); - #endif /* _RTL8711_RF_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_security.h b/drivers/staging/rtl8188eu/include/rtw_security.h index f8d9151fe6e3..b6f7f693d33a 100644 --- a/drivers/staging/rtl8188eu/include/rtw_security.h +++ b/drivers/staging/rtl8188eu/include/rtw_security.h @@ -37,7 +37,6 @@ enum { ENCRYP_PROTOCOL_MAX }; - #ifndef Ndis802_11AuthModeWPA2 #define Ndis802_11AuthModeWPA2 (Ndis802_11AuthModeWPANone + 1) #endif @@ -209,7 +208,6 @@ do { \ } \ } while (0) - #define GET_TKIP_PN(iv, dot11txpn) \ do { \ dot11txpn._byte_.TSC0 = iv[2]; \ @@ -220,7 +218,6 @@ do { \ dot11txpn._byte_.TSC5 = iv[7]; \ } while (0) - #define ROL32(A, n) (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1))) #define ROR32(A, n) ROL32((A), 32-(n)) diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h b/drivers/staging/rtl8188eu/include/rtw_xmit.h index b9f11ef327e7..12d16e98176a 100644 --- a/drivers/staging/rtl8188eu/include/rtw_xmit.h +++ b/drivers/staging/rtl8188eu/include/rtw_xmit.h @@ -46,7 +46,6 @@ do {\ dot11txpn.val = (dot11txpn.val == 0xffffff) ? 0 : (dot11txpn.val+1);\ } while (0) - #define TKIP_IV(pattrib_iv, dot11txpn, keyidx)\ do {\ pattrib_iv[0] = dot11txpn._byte_.TSC1;\ diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h index d059240b836f..667055796b66 100644 --- a/drivers/staging/rtl8188eu/include/wifi.h +++ b/drivers/staging/rtl8188eu/include/wifi.h @@ -160,7 +160,6 @@ enum WIFI_REG_DOMAIN { #define get_tofr_ds(pframe) ((GetToDs(pframe) << 1) | GetFrDs(pframe)) - #define SetMFrag(pbuf) \ *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_) @@ -231,7 +230,6 @@ enum WIFI_REG_DOMAIN { #define SetDuration(pbuf, dur) \ *(__le16 *)((size_t)(pbuf) + 2) = cpu_to_le16(0xffff & (dur)) - #define SetPriority(pbuf, tid) \ *(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf) @@ -384,7 +382,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _HT_ADD_INFO_IE_ 61 /* _HT_EXTRA_INFO_IE_ */ #define _WAPI_IE_ 68 - #define EID_BSSCoexistence 72 /* 20/40 BSS Coexistence */ #define EID_BSSIntolerantChlReport 73 #define _RIC_Descriptor_IE_ 75 @@ -452,7 +449,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _WMM_IE_Length_ 7 /* for WMM STA */ #define _WMM_Para_Element_Length_ 24 - /*----------------------------------------------------------------------------- Below is the definition for 802.11n ------------------------------------------------------------------------------*/ @@ -553,7 +549,6 @@ enum ht_cap_ampdu_factor { */ #define IEEE80211_MIN_AMPDU_BUF 0x8 - #define OP_MODE_PURE 0 #define OP_MODE_MAY_BE_LEGACY_STAS 1 #define OP_MODE_20MHZ_HT_STA_ASSOCED 2 diff --git a/drivers/staging/rtl8188eu/include/wlan_bssdef.h b/drivers/staging/rtl8188eu/include/wlan_bssdef.h index 8462c9c2fd39..1b6435cd5390 100644 --- a/drivers/staging/rtl8188eu/include/wlan_bssdef.h +++ b/drivers/staging/rtl8188eu/include/wlan_bssdef.h @@ -7,7 +7,6 @@ #ifndef __WLAN_BSSDEF_H__ #define __WLAN_BSSDEF_H__ - #define MAX_IE_SZ 768 #define NDIS_802_11_LENGTH_SSID 32 @@ -62,8 +61,6 @@ struct ndis_802_11_fixed_ie { u16 Capabilities; }; - - struct ndis_802_11_var_ie { u8 ElementID; u8 Length; -- cgit v1.2.3-58-ga151 From 6e8227155ece996e8887d3e4a0059b7fdcbcd1f0 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 28 Jun 2020 09:30:58 +0200 Subject: staging: rtl8188eu: remove unnecessary comments in hal8188e_phy_cfg.h Remove unnecessary comments in hal8188e_phy_cfg.h to improve readability and clear multiple blank lines checkpatch issues. CHECK: Please don't use multiple blank lines Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200628073058.11228-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/include/hal8188e_phy_cfg.h | 25 ---------------------- 1 file changed, 25 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/hal8188e_phy_cfg.h b/drivers/staging/rtl8188eu/include/hal8188e_phy_cfg.h index 0c5b2b0948f5..a1055ceb7206 100644 --- a/drivers/staging/rtl8188eu/include/hal8188e_phy_cfg.h +++ b/drivers/staging/rtl8188eu/include/hal8188e_phy_cfg.h @@ -7,8 +7,6 @@ #ifndef __INC_HAL8188EPHYCFG_H__ #define __INC_HAL8188EPHYCFG_H__ - -/*--------------------------Define Parameters-------------------------------*/ #define LOOP_LIMIT 5 #define MAX_STALL_TIME 50 /* us */ #define AntennaDiversityValue 0x80 @@ -17,11 +15,6 @@ #define MAX_AGGR_NUM 0x07 - -/*--------------------------Define Parameters-------------------------------*/ - - -/*------------------------------Define structure----------------------------*/ enum sw_chnl_cmd_id { CmdID_End, CmdID_SetTxPowerLevel, @@ -145,22 +138,6 @@ struct bb_reg_def { */ }; -/*------------------------------Define structure----------------------------*/ - - -/*------------------------Export global variable----------------------------*/ -/*------------------------Export global variable----------------------------*/ - - -/*------------------------Export Marco Definition---------------------------*/ -/*------------------------Export Marco Definition---------------------------*/ - - -/*--------------------------Exported Function prototype---------------------*/ -/* */ -/* BB and RF register read/write */ -/* */ - /* Read initi reg value for tx power setting. */ void rtl8192c_PHY_GetHWRegOriginalValue(struct adapter *adapter); @@ -181,8 +158,6 @@ void PHY_EnableHostClkReq(struct adapter *adapter); bool SetAntennaConfig92C(struct adapter *adapter, u8 defaultant); -/*--------------------------Exported Function prototype---------------------*/ - #define PHY_SetMacReg PHY_SetBBReg #define SIC_HW_SUPPORT 0 -- cgit v1.2.3-58-ga151 From ae7368f9a30b61db7caaf958bf7ff2e1f7e6f715 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sat, 27 Jun 2020 22:58:56 +0800 Subject: staging: qlge: fix ql_sem_unlock Some functions return without releasing the lock. Replace return with break. Suggested-by Dan Carpenter . Signed-off-by: Coiby Xu Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/20200627145857.15926-4-coiby.xu@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_dbg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 87433510a224..63e965966ced 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -1390,7 +1390,7 @@ static void ql_dump_cam_entries(struct ql_adapter *qdev) if (ql_get_mac_addr_reg(qdev, MAC_ADDR_TYPE_CAM_MAC, i, value)) { pr_err("%s: Failed read of mac index register\n", __func__); - return; + break; } if (value[0]) pr_err("%s: CAM index %d CAM Lookup Lower = 0x%.08x:%.08x, Output = 0x%.08x\n", @@ -1402,7 +1402,7 @@ static void ql_dump_cam_entries(struct ql_adapter *qdev) (qdev, MAC_ADDR_TYPE_MULTI_MAC, i, value)) { pr_err("%s: Failed read of mac index register\n", __func__); - return; + break; } if (value[0]) pr_err("%s: MCAST index %d CAM Lookup Lower = 0x%.08x:%.08x\n", @@ -1424,7 +1424,7 @@ void ql_dump_routing_entries(struct ql_adapter *qdev) if (ql_get_routing_reg(qdev, i, &value)) { pr_err("%s: Failed read of routing index register\n", __func__); - return; + break; } if (value) pr_err("%s: Routing Mask %d = 0x%.08x\n", -- cgit v1.2.3-58-ga151 From 0107635e15ac09f6549a3c5ea179b0a16eb2181f Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Sat, 27 Jun 2020 22:58:57 +0800 Subject: staging: qlge: replace pr_err with netdev_err Replace all pr_errs with netdev_err. Suggested-by: Joe Perches Signed-off-by: Coiby Xu Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/20200627145857.15926-5-coiby.xu@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_dbg.c | 568 ++++++++++++++++++++-------------------- 1 file changed, 289 insertions(+), 279 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 63e965966ced..32fbd30a6a2e 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -647,7 +647,7 @@ static void ql_get_mac_protocol_registers(struct ql_adapter *qdev, u32 *buf) max_offset = MAC_ADDR_MAX_MGMT_TU_DP_WCOUNT; break; default: - pr_err("Bad type!!! 0x%08x\n", type); + netdev_err(qdev->ndev, "Bad type!!! 0x%08x\n", type); max_index = 0; max_offset = 0; break; @@ -1335,9 +1335,8 @@ static void ql_dump_intr_states(struct ql_adapter *qdev) for (i = 0; i < qdev->intr_count; i++) { ql_write32(qdev, INTR_EN, qdev->intr_context[i].intr_read_mask); value = ql_read32(qdev, INTR_EN); - pr_err("%s: Interrupt %d is %s\n", - qdev->ndev->name, i, - (value & INTR_EN_EN ? "enabled" : "disabled")); + netdev_err(qdev->ndev, "Interrupt %d is %s\n", i, + (value & INTR_EN_EN ? "enabled" : "disabled")); } } @@ -1345,13 +1344,14 @@ static void ql_dump_intr_states(struct ql_adapter *qdev) do { \ u32 data; \ ql_read_xgmac_reg(qdev, reg, &data); \ - pr_err("%s: %s = 0x%.08x\n", qdev->ndev->name, #reg, data); \ + netdev_err(qdev->ndev, "%s = 0x%.08x\n", #reg, data); \ } while (0) void ql_dump_xgmac_control_regs(struct ql_adapter *qdev) { if (ql_sem_spinlock(qdev, qdev->xg_sem_mask)) { - pr_err("%s: Couldn't get xgmac sem\n", __func__); + netdev_err(qdev->ndev, "%s: Couldn't get xgmac sem\n", + __func__); return; } DUMP_XGMAC(qdev, PAUSE_SRC_LO); @@ -1388,25 +1388,28 @@ static void ql_dump_cam_entries(struct ql_adapter *qdev) return; for (i = 0; i < 4; i++) { if (ql_get_mac_addr_reg(qdev, MAC_ADDR_TYPE_CAM_MAC, i, value)) { - pr_err("%s: Failed read of mac index register\n", - __func__); + netdev_err(qdev->ndev, + "%s: Failed read of mac index register\n", + __func__); break; } if (value[0]) - pr_err("%s: CAM index %d CAM Lookup Lower = 0x%.08x:%.08x, Output = 0x%.08x\n", - qdev->ndev->name, i, value[1], value[0], - value[2]); + netdev_err(qdev->ndev, + "CAM index %d CAM Lookup Lower = 0x%.08x:%.08x, Output = 0x%.08x\n", + i, value[1], value[0], value[2]); } for (i = 0; i < 32; i++) { if (ql_get_mac_addr_reg (qdev, MAC_ADDR_TYPE_MULTI_MAC, i, value)) { - pr_err("%s: Failed read of mac index register\n", - __func__); + netdev_err(qdev->ndev, + "%s: Failed read of mac index register\n", + __func__); break; } if (value[0]) - pr_err("%s: MCAST index %d CAM Lookup Lower = 0x%.08x:%.08x\n", - qdev->ndev->name, i, value[1], value[0]); + netdev_err(qdev->ndev, + "MCAST index %d CAM Lookup Lower = 0x%.08x:%.08x\n", + i, value[1], value[0]); } ql_sem_unlock(qdev, SEM_MAC_ADDR_MASK); } @@ -1422,23 +1425,25 @@ void ql_dump_routing_entries(struct ql_adapter *qdev) for (i = 0; i < 16; i++) { value = 0; if (ql_get_routing_reg(qdev, i, &value)) { - pr_err("%s: Failed read of routing index register\n", - __func__); + netdev_err(qdev->ndev, + "%s: Failed read of routing index register\n", + __func__); break; } if (value) - pr_err("%s: Routing Mask %d = 0x%.08x\n", - qdev->ndev->name, i, value); + netdev_err(qdev->ndev, + "%s: Routing Mask %d = 0x%.08x\n", + i, value); } ql_sem_unlock(qdev, SEM_RT_IDX_MASK); } #define DUMP_REG(qdev, reg) \ - pr_err("%-32s= 0x%x\n", #reg, ql_read32(qdev, reg)) + netdev_err(qdev->ndev, "%-32s= 0x%x\n", #reg, ql_read32(qdev, reg)) void ql_dump_regs(struct ql_adapter *qdev) { - pr_err("reg dump for function #%d\n", qdev->func); + netdev_err(qdev->ndev, "reg dump for function #%d\n", qdev->func); DUMP_REG(qdev, SYS); DUMP_REG(qdev, RST_FO); DUMP_REG(qdev, FSC); @@ -1503,11 +1508,12 @@ void ql_dump_regs(struct ql_adapter *qdev) #ifdef QL_STAT_DUMP #define DUMP_STAT(qdev, stat) \ - pr_err("%s = %ld\n", #stat, (unsigned long)(qdev)->nic_stats.stat) + netdev_err(qdev->ndev, "%s = %ld\n", #stat, \ + (unsigned long)(qdev)->nic_stats.stat) void ql_dump_stat(struct ql_adapter *qdev) { - pr_err("%s: Enter\n", __func__); + netdev_err(qdev->ndev, "%s: Enter\n", __func__); DUMP_STAT(qdev, tx_pkts); DUMP_STAT(qdev, tx_bytes); DUMP_STAT(qdev, tx_mcast_pkts); @@ -1556,11 +1562,12 @@ void ql_dump_stat(struct ql_adapter *qdev) #ifdef QL_DEV_DUMP #define DUMP_QDEV_FIELD(qdev, type, field) \ - pr_err("qdev->%-24s = " type "\n", #field, (qdev)->field) + netdev_err(qdev->ndev, "qdev->%-24s = " type "\n", #field, (qdev)->field) #define DUMP_QDEV_DMA_FIELD(qdev, field) \ - pr_err("qdev->%-24s = %llx\n", #field, (unsigned long long)qdev->field) + netdev_err(qdev->ndev, "qdev->%-24s = %llx\n", #field, \ + (unsigned long long)qdev->field) #define DUMP_QDEV_ARRAY(qdev, type, array, index, field) \ - pr_err("%s[%d].%s = " type "\n", \ + netdev_err(qdev->ndev, "%s[%d].%s = " type "\n", \ #array, index, #field, (qdev)->array[index].field) void ql_dump_qdev(struct ql_adapter *qdev) { @@ -1611,99 +1618,100 @@ void ql_dump_qdev(struct ql_adapter *qdev) #ifdef QL_CB_DUMP void ql_dump_wqicb(struct wqicb *wqicb) { - pr_err("Dumping wqicb stuff...\n"); - pr_err("wqicb->len = 0x%x\n", le16_to_cpu(wqicb->len)); - pr_err("wqicb->flags = %x\n", le16_to_cpu(wqicb->flags)); - pr_err("wqicb->cq_id_rss = %d\n", - le16_to_cpu(wqicb->cq_id_rss)); - pr_err("wqicb->rid = 0x%x\n", le16_to_cpu(wqicb->rid)); - pr_err("wqicb->wq_addr = 0x%llx\n", - (unsigned long long)le64_to_cpu(wqicb->addr)); - pr_err("wqicb->wq_cnsmr_idx_addr = 0x%llx\n", - (unsigned long long)le64_to_cpu(wqicb->cnsmr_idx_addr)); + netdev_err(qdev->ndev, "Dumping wqicb stuff...\n"); + netdev_err(qdev->ndev, "wqicb->len = 0x%x\n", le16_to_cpu(wqicb->len)); + netdev_err(qdev->ndev, "wqicb->flags = %x\n", + le16_to_cpu(wqicb->flags)); + netdev_err(qdev->ndev, "wqicb->cq_id_rss = %d\n", + le16_to_cpu(wqicb->cq_id_rss)); + netdev_err(qdev->ndev, "wqicb->rid = 0x%x\n", le16_to_cpu(wqicb->rid)); + netdev_err(qdev->ndev, "wqicb->wq_addr = 0x%llx\n", + (unsigned long long)le64_to_cpu(wqicb->addr)); + netdev_err(qdev->ndev, "wqicb->wq_cnsmr_idx_addr = 0x%llx\n", + (unsigned long long)le64_to_cpu(wqicb->cnsmr_idx_addr)); } void ql_dump_tx_ring(struct tx_ring *tx_ring) { if (!tx_ring) return; - pr_err("===================== Dumping tx_ring %d ===============\n", - tx_ring->wq_id); - pr_err("tx_ring->base = %p\n", tx_ring->wq_base); - pr_err("tx_ring->base_dma = 0x%llx\n", - (unsigned long long)tx_ring->wq_base_dma); - pr_err("tx_ring->cnsmr_idx_sh_reg, addr = 0x%p, value = %d\n", - tx_ring->cnsmr_idx_sh_reg, - tx_ring->cnsmr_idx_sh_reg + netdev_err(qdev->ndev, "===================== Dumping tx_ring %d ===============\n", + tx_ring->wq_id); + netdev_err(qdev->ndev, "tx_ring->base = %p\n", tx_ring->wq_base); + netdev_err(qdev->ndev, "tx_ring->base_dma = 0x%llx\n", + (unsigned long long)tx_ring->wq_base_dma); + netdev_err(qdev->ndev, "tx_ring->cnsmr_idx_sh_reg, addr = 0x%p, value = %d\n", + tx_ring->cnsmr_idx_sh_reg, + tx_ring->cnsmr_idx_sh_reg ? ql_read_sh_reg(tx_ring->cnsmr_idx_sh_reg) : 0); - pr_err("tx_ring->size = %d\n", tx_ring->wq_size); - pr_err("tx_ring->len = %d\n", tx_ring->wq_len); - pr_err("tx_ring->prod_idx_db_reg = %p\n", tx_ring->prod_idx_db_reg); - pr_err("tx_ring->valid_db_reg = %p\n", tx_ring->valid_db_reg); - pr_err("tx_ring->prod_idx = %d\n", tx_ring->prod_idx); - pr_err("tx_ring->cq_id = %d\n", tx_ring->cq_id); - pr_err("tx_ring->wq_id = %d\n", tx_ring->wq_id); - pr_err("tx_ring->q = %p\n", tx_ring->q); - pr_err("tx_ring->tx_count = %d\n", atomic_read(&tx_ring->tx_count)); + netdev_err(qdev->ndev, "tx_ring->size = %d\n", tx_ring->wq_size); + netdev_err(qdev->ndev, "tx_ring->len = %d\n", tx_ring->wq_len); + netdev_err(qdev->ndev, "tx_ring->prod_idx_db_reg = %p\n", tx_ring->prod_idx_db_reg); + netdev_err(qdev->ndev, "tx_ring->valid_db_reg = %p\n", tx_ring->valid_db_reg); + netdev_err(qdev->ndev, "tx_ring->prod_idx = %d\n", tx_ring->prod_idx); + netdev_err(qdev->ndev, "tx_ring->cq_id = %d\n", tx_ring->cq_id); + netdev_err(qdev->ndev, "tx_ring->wq_id = %d\n", tx_ring->wq_id); + netdev_err(qdev->ndev, "tx_ring->q = %p\n", tx_ring->q); + netdev_err(qdev->ndev, "tx_ring->tx_count = %d\n", atomic_read(&tx_ring->tx_count)); } void ql_dump_ricb(struct ricb *ricb) { int i; - pr_err("===================== Dumping ricb ===============\n"); - pr_err("Dumping ricb stuff...\n"); - - pr_err("ricb->base_cq = %d\n", ricb->base_cq & 0x1f); - pr_err("ricb->flags = %s%s%s%s%s%s%s%s%s\n", - ricb->base_cq & RSS_L4K ? "RSS_L4K " : "", - ricb->flags & RSS_L6K ? "RSS_L6K " : "", - ricb->flags & RSS_LI ? "RSS_LI " : "", - ricb->flags & RSS_LB ? "RSS_LB " : "", - ricb->flags & RSS_LM ? "RSS_LM " : "", - ricb->flags & RSS_RI4 ? "RSS_RI4 " : "", - ricb->flags & RSS_RT4 ? "RSS_RT4 " : "", - ricb->flags & RSS_RI6 ? "RSS_RI6 " : "", - ricb->flags & RSS_RT6 ? "RSS_RT6 " : ""); - pr_err("ricb->mask = 0x%.04x\n", le16_to_cpu(ricb->mask)); + netdev_err(qdev->ndev, "===================== Dumping ricb ===============\n"); + netdev_err(qdev->ndev, "Dumping ricb stuff...\n"); + + netdev_err(qdev->ndev, "ricb->base_cq = %d\n", ricb->base_cq & 0x1f); + netdev_err(qdev->ndev, "ricb->flags = %s%s%s%s%s%s%s%s%s\n", + ricb->base_cq & RSS_L4K ? "RSS_L4K " : "", + ricb->flags & RSS_L6K ? "RSS_L6K " : "", + ricb->flags & RSS_LI ? "RSS_LI " : "", + ricb->flags & RSS_LB ? "RSS_LB " : "", + ricb->flags & RSS_LM ? "RSS_LM " : "", + ricb->flags & RSS_RI4 ? "RSS_RI4 " : "", + ricb->flags & RSS_RT4 ? "RSS_RT4 " : "", + ricb->flags & RSS_RI6 ? "RSS_RI6 " : "", + ricb->flags & RSS_RT6 ? "RSS_RT6 " : ""); + netdev_err(qdev->ndev, "ricb->mask = 0x%.04x\n", le16_to_cpu(ricb->mask)); for (i = 0; i < 16; i++) - pr_err("ricb->hash_cq_id[%d] = 0x%.08x\n", i, - le32_to_cpu(ricb->hash_cq_id[i])); + netdev_err(qdev->ndev, "ricb->hash_cq_id[%d] = 0x%.08x\n", i, + le32_to_cpu(ricb->hash_cq_id[i])); for (i = 0; i < 10; i++) - pr_err("ricb->ipv6_hash_key[%d] = 0x%.08x\n", i, - le32_to_cpu(ricb->ipv6_hash_key[i])); + netdev_err(qdev->ndev, "ricb->ipv6_hash_key[%d] = 0x%.08x\n", i, + le32_to_cpu(ricb->ipv6_hash_key[i])); for (i = 0; i < 4; i++) - pr_err("ricb->ipv4_hash_key[%d] = 0x%.08x\n", i, - le32_to_cpu(ricb->ipv4_hash_key[i])); + netdev_err(qdev->ndev, "ricb->ipv4_hash_key[%d] = 0x%.08x\n", i, + le32_to_cpu(ricb->ipv4_hash_key[i])); } void ql_dump_cqicb(struct cqicb *cqicb) { - pr_err("Dumping cqicb stuff...\n"); - - pr_err("cqicb->msix_vect = %d\n", cqicb->msix_vect); - pr_err("cqicb->flags = %x\n", cqicb->flags); - pr_err("cqicb->len = %d\n", le16_to_cpu(cqicb->len)); - pr_err("cqicb->addr = 0x%llx\n", - (unsigned long long)le64_to_cpu(cqicb->addr)); - pr_err("cqicb->prod_idx_addr = 0x%llx\n", - (unsigned long long)le64_to_cpu(cqicb->prod_idx_addr)); - pr_err("cqicb->pkt_delay = 0x%.04x\n", - le16_to_cpu(cqicb->pkt_delay)); - pr_err("cqicb->irq_delay = 0x%.04x\n", - le16_to_cpu(cqicb->irq_delay)); - pr_err("cqicb->lbq_addr = 0x%llx\n", - (unsigned long long)le64_to_cpu(cqicb->lbq_addr)); - pr_err("cqicb->lbq_buf_size = 0x%.04x\n", - le16_to_cpu(cqicb->lbq_buf_size)); - pr_err("cqicb->lbq_len = 0x%.04x\n", - le16_to_cpu(cqicb->lbq_len)); - pr_err("cqicb->sbq_addr = 0x%llx\n", - (unsigned long long)le64_to_cpu(cqicb->sbq_addr)); - pr_err("cqicb->sbq_buf_size = 0x%.04x\n", - le16_to_cpu(cqicb->sbq_buf_size)); - pr_err("cqicb->sbq_len = 0x%.04x\n", - le16_to_cpu(cqicb->sbq_len)); + netdev_err(qdev->ndev, "Dumping cqicb stuff...\n"); + + netdev_err(qdev->ndev, "cqicb->msix_vect = %d\n", cqicb->msix_vect); + netdev_err(qdev->ndev, "cqicb->flags = %x\n", cqicb->flags); + netdev_err(qdev->ndev, "cqicb->len = %d\n", le16_to_cpu(cqicb->len)); + netdev_err(qdev->ndev, "cqicb->addr = 0x%llx\n", + (unsigned long long)le64_to_cpu(cqicb->addr)); + netdev_err(qdev->ndev, "cqicb->prod_idx_addr = 0x%llx\n", + (unsigned long long)le64_to_cpu(cqicb->prod_idx_addr)); + netdev_err(qdev->ndev, "cqicb->pkt_delay = 0x%.04x\n", + le16_to_cpu(cqicb->pkt_delay)); + netdev_err(qdev->ndev, "cqicb->irq_delay = 0x%.04x\n", + le16_to_cpu(cqicb->irq_delay)); + netdev_err(qdev->ndev, "cqicb->lbq_addr = 0x%llx\n", + (unsigned long long)le64_to_cpu(cqicb->lbq_addr)); + netdev_err(qdev->ndev, "cqicb->lbq_buf_size = 0x%.04x\n", + le16_to_cpu(cqicb->lbq_buf_size)); + netdev_err(qdev->ndev, "cqicb->lbq_len = 0x%.04x\n", + le16_to_cpu(cqicb->lbq_len)); + netdev_err(qdev->ndev, "cqicb->sbq_addr = 0x%llx\n", + (unsigned long long)le64_to_cpu(cqicb->sbq_addr)); + netdev_err(qdev->ndev, "cqicb->sbq_buf_size = 0x%.04x\n", + le16_to_cpu(cqicb->sbq_buf_size)); + netdev_err(qdev->ndev, "cqicb->sbq_len = 0x%.04x\n", + le16_to_cpu(cqicb->sbq_len)); } static const char *qlge_rx_ring_type_name(struct rx_ring *rx_ring) @@ -1720,71 +1728,73 @@ void ql_dump_rx_ring(struct rx_ring *rx_ring) { if (!rx_ring) return; - pr_err("===================== Dumping rx_ring %d ===============\n", - rx_ring->cq_id); - pr_err("Dumping rx_ring %d, type = %s\n", rx_ring->cq_id, - qlge_rx_ring_type_name(rx_ring)); - pr_err("rx_ring->cqicb = %p\n", &rx_ring->cqicb); - pr_err("rx_ring->cq_base = %p\n", rx_ring->cq_base); - pr_err("rx_ring->cq_base_dma = %llx\n", - (unsigned long long)rx_ring->cq_base_dma); - pr_err("rx_ring->cq_size = %d\n", rx_ring->cq_size); - pr_err("rx_ring->cq_len = %d\n", rx_ring->cq_len); - pr_err("rx_ring->prod_idx_sh_reg, addr = 0x%p, value = %d\n", - rx_ring->prod_idx_sh_reg, - rx_ring->prod_idx_sh_reg - ? ql_read_sh_reg(rx_ring->prod_idx_sh_reg) : 0); - pr_err("rx_ring->prod_idx_sh_reg_dma = %llx\n", - (unsigned long long)rx_ring->prod_idx_sh_reg_dma); - pr_err("rx_ring->cnsmr_idx_db_reg = %p\n", - rx_ring->cnsmr_idx_db_reg); - pr_err("rx_ring->cnsmr_idx = %d\n", rx_ring->cnsmr_idx); - pr_err("rx_ring->curr_entry = %p\n", rx_ring->curr_entry); - pr_err("rx_ring->valid_db_reg = %p\n", rx_ring->valid_db_reg); - - pr_err("rx_ring->lbq.base = %p\n", rx_ring->lbq.base); - pr_err("rx_ring->lbq.base_dma = %llx\n", - (unsigned long long)rx_ring->lbq.base_dma); - pr_err("rx_ring->lbq.base_indirect = %p\n", - rx_ring->lbq.base_indirect); - pr_err("rx_ring->lbq.base_indirect_dma = %llx\n", - (unsigned long long)rx_ring->lbq.base_indirect_dma); - pr_err("rx_ring->lbq = %p\n", rx_ring->lbq.queue); - pr_err("rx_ring->lbq.prod_idx_db_reg = %p\n", - rx_ring->lbq.prod_idx_db_reg); - pr_err("rx_ring->lbq.next_to_use = %d\n", rx_ring->lbq.next_to_use); - pr_err("rx_ring->lbq.next_to_clean = %d\n", rx_ring->lbq.next_to_clean); - - pr_err("rx_ring->sbq.base = %p\n", rx_ring->sbq.base); - pr_err("rx_ring->sbq.base_dma = %llx\n", - (unsigned long long)rx_ring->sbq.base_dma); - pr_err("rx_ring->sbq.base_indirect = %p\n", - rx_ring->sbq.base_indirect); - pr_err("rx_ring->sbq.base_indirect_dma = %llx\n", - (unsigned long long)rx_ring->sbq.base_indirect_dma); - pr_err("rx_ring->sbq = %p\n", rx_ring->sbq.queue); - pr_err("rx_ring->sbq.prod_idx_db_reg addr = %p\n", - rx_ring->sbq.prod_idx_db_reg); - pr_err("rx_ring->sbq.next_to_use = %d\n", rx_ring->sbq.next_to_use); - pr_err("rx_ring->sbq.next_to_clean = %d\n", rx_ring->sbq.next_to_clean); - pr_err("rx_ring->cq_id = %d\n", rx_ring->cq_id); - pr_err("rx_ring->irq = %d\n", rx_ring->irq); - pr_err("rx_ring->cpu = %d\n", rx_ring->cpu); - pr_err("rx_ring->qdev = %p\n", rx_ring->qdev); + netdev_err(qdev->ndev, + "===================== Dumping rx_ring %d ===============\n", + rx_ring->cq_id); + netdev_err(qdev->ndev, + "Dumping rx_ring %d, type = %s\n", rx_ring->cq_id, + qlge_rx_ring_type_name(rx_ring)); + netdev_err(qdev->ndev, "rx_ring->cqicb = %p\n", &rx_ring->cqicb); + netdev_err(qdev->ndev, "rx_ring->cq_base = %p\n", rx_ring->cq_base); + netdev_err(qdev->ndev, "rx_ring->cq_base_dma = %llx\n", + (unsigned long long)rx_ring->cq_base_dma); + netdev_err(qdev->ndev, "rx_ring->cq_size = %d\n", rx_ring->cq_size); + netdev_err(qdev->ndev, "rx_ring->cq_len = %d\n", rx_ring->cq_len); + netdev_err(qdev->ndev, + "rx_ring->prod_idx_sh_reg, addr = 0x%p, value = %d\n", + rx_ring->prod_idx_sh_reg, + rx_ring->prod_idx_sh_reg ? ql_read_sh_reg(rx_ring->prod_idx_sh_reg) : 0); + netdev_err(qdev->ndev, "rx_ring->prod_idx_sh_reg_dma = %llx\n", + (unsigned long long)rx_ring->prod_idx_sh_reg_dma); + netdev_err(qdev->ndev, "rx_ring->cnsmr_idx_db_reg = %p\n", + rx_ring->cnsmr_idx_db_reg); + netdev_err(qdev->ndev, "rx_ring->cnsmr_idx = %d\n", rx_ring->cnsmr_idx); + netdev_err(qdev->ndev, "rx_ring->curr_entry = %p\n", rx_ring->curr_entry); + netdev_err(qdev->ndev, "rx_ring->valid_db_reg = %p\n", rx_ring->valid_db_reg); + + netdev_err(qdev->ndev, "rx_ring->lbq.base = %p\n", rx_ring->lbq.base); + netdev_err(qdev->ndev, "rx_ring->lbq.base_dma = %llx\n", + (unsigned long long)rx_ring->lbq.base_dma); + netdev_err(qdev->ndev, "rx_ring->lbq.base_indirect = %p\n", + rx_ring->lbq.base_indirect); + netdev_err(qdev->ndev, "rx_ring->lbq.base_indirect_dma = %llx\n", + (unsigned long long)rx_ring->lbq.base_indirect_dma); + netdev_err(qdev->ndev, "rx_ring->lbq = %p\n", rx_ring->lbq.queue); + netdev_err(qdev->ndev, "rx_ring->lbq.prod_idx_db_reg = %p\n", + rx_ring->lbq.prod_idx_db_reg); + netdev_err(qdev->ndev, "rx_ring->lbq.next_to_use = %d\n", rx_ring->lbq.next_to_use); + netdev_err(qdev->ndev, "rx_ring->lbq.next_to_clean = %d\n", rx_ring->lbq.next_to_clean); + + netdev_err(qdev->ndev, "rx_ring->sbq.base = %p\n", rx_ring->sbq.base); + netdev_err(qdev->ndev, "rx_ring->sbq.base_dma = %llx\n", + (unsigned long long)rx_ring->sbq.base_dma); + netdev_err(qdev->ndev, "rx_ring->sbq.base_indirect = %p\n", + rx_ring->sbq.base_indirect); + netdev_err(qdev->ndev, "rx_ring->sbq.base_indirect_dma = %llx\n", + (unsigned long long)rx_ring->sbq.base_indirect_dma); + netdev_err(qdev->ndev, "rx_ring->sbq = %p\n", rx_ring->sbq.queue); + netdev_err(qdev->ndev, "rx_ring->sbq.prod_idx_db_reg addr = %p\n", + rx_ring->sbq.prod_idx_db_reg); + netdev_err(qdev->ndev, "rx_ring->sbq.next_to_use = %d\n", rx_ring->sbq.next_to_use); + netdev_err(qdev->ndev, "rx_ring->sbq.next_to_clean = %d\n", rx_ring->sbq.next_to_clean); + netdev_err(qdev->ndev, "rx_ring->cq_id = %d\n", rx_ring->cq_id); + netdev_err(qdev->ndev, "rx_ring->irq = %d\n", rx_ring->irq); + netdev_err(qdev->ndev, "rx_ring->cpu = %d\n", rx_ring->cpu); + netdev_err(qdev->ndev, "rx_ring->qdev = %p\n", rx_ring->qdev); } void ql_dump_hw_cb(struct ql_adapter *qdev, int size, u32 bit, u16 q_id) { void *ptr; - pr_err("%s: Enter\n", __func__); + netdev_err(qdev->ndev, "%s: Enter\n", __func__); ptr = kmalloc(size, GFP_ATOMIC); if (!ptr) return; if (ql_write_cfg(qdev, ptr, size, bit, q_id)) { - pr_err("%s: Failed to upload control block!\n", __func__); + netdev_err(qdev->ndev, "%s: Failed to upload control block!\n", __func__); goto fail_it; } switch (bit) { @@ -1798,7 +1808,7 @@ void ql_dump_hw_cb(struct ql_adapter *qdev, int size, u32 bit, u16 q_id) ql_dump_ricb((struct ricb *)ptr); break; default: - pr_err("%s: Invalid bit value = %x\n", __func__, bit); + netdev_err(qdev->ndev, "%s: Invalid bit value = %x\n", __func__, bit); break; } fail_it: @@ -1809,29 +1819,29 @@ fail_it: #ifdef QL_OB_DUMP void ql_dump_tx_desc(struct tx_buf_desc *tbd) { - pr_err("tbd->addr = 0x%llx\n", - le64_to_cpu((u64) tbd->addr)); - pr_err("tbd->len = %d\n", - le32_to_cpu(tbd->len & TX_DESC_LEN_MASK)); - pr_err("tbd->flags = %s %s\n", - tbd->len & TX_DESC_C ? "C" : ".", - tbd->len & TX_DESC_E ? "E" : "."); + netdev_err(qdev->ndev, "tbd->addr = 0x%llx\n", + le64_to_cpu((u64)tbd->addr)); + netdev_err(qdev->ndev, "tbd->len = %d\n", + le32_to_cpu(tbd->len & TX_DESC_LEN_MASK)); + netdev_err(qdev->ndev, "tbd->flags = %s %s\n", + tbd->len & TX_DESC_C ? "C" : ".", + tbd->len & TX_DESC_E ? "E" : "."); tbd++; - pr_err("tbd->addr = 0x%llx\n", - le64_to_cpu((u64) tbd->addr)); - pr_err("tbd->len = %d\n", - le32_to_cpu(tbd->len & TX_DESC_LEN_MASK)); - pr_err("tbd->flags = %s %s\n", - tbd->len & TX_DESC_C ? "C" : ".", - tbd->len & TX_DESC_E ? "E" : "."); + netdev_err(qdev->ndev, "tbd->addr = 0x%llx\n", + le64_to_cpu((u64)tbd->addr)); + netdev_err(qdev->ndev, "tbd->len = %d\n", + le32_to_cpu(tbd->len & TX_DESC_LEN_MASK)); + netdev_err(qdev->ndev, "tbd->flags = %s %s\n", + tbd->len & TX_DESC_C ? "C" : ".", + tbd->len & TX_DESC_E ? "E" : "."); tbd++; - pr_err("tbd->addr = 0x%llx\n", - le64_to_cpu((u64) tbd->addr)); - pr_err("tbd->len = %d\n", - le32_to_cpu(tbd->len & TX_DESC_LEN_MASK)); - pr_err("tbd->flags = %s %s\n", - tbd->len & TX_DESC_C ? "C" : ".", - tbd->len & TX_DESC_E ? "E" : "."); + netdev_err(qdev->ndev, "tbd->addr = 0x%llx\n", + le64_to_cpu((u64)tbd->addr)); + netdev_err(qdev->ndev, "tbd->len = %d\n", + le32_to_cpu(tbd->len & TX_DESC_LEN_MASK)); + netdev_err(qdev->ndev, "tbd->flags = %s %s\n", + tbd->len & TX_DESC_C ? "C" : ".", + tbd->len & TX_DESC_E ? "E" : "."); } void ql_dump_ob_mac_iocb(struct ob_mac_iocb_req *ob_mac_iocb) @@ -1841,39 +1851,39 @@ void ql_dump_ob_mac_iocb(struct ob_mac_iocb_req *ob_mac_iocb) struct tx_buf_desc *tbd; u16 frame_len; - pr_err("%s\n", __func__); - pr_err("opcode = %s\n", - (ob_mac_iocb->opcode == OPCODE_OB_MAC_IOCB) ? "MAC" : "TSO"); - pr_err("flags1 = %s %s %s %s %s\n", - ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_OI ? "OI" : "", - ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_I ? "I" : "", - ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_D ? "D" : "", - ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_IP4 ? "IP4" : "", - ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_IP6 ? "IP6" : ""); - pr_err("flags2 = %s %s %s\n", - ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_LSO ? "LSO" : "", - ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_UC ? "UC" : "", - ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_TC ? "TC" : ""); - pr_err("flags3 = %s %s %s\n", - ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_IC ? "IC" : "", - ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_DFP ? "DFP" : "", - ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_V ? "V" : ""); - pr_err("tid = %x\n", ob_mac_iocb->tid); - pr_err("txq_idx = %d\n", ob_mac_iocb->txq_idx); - pr_err("vlan_tci = %x\n", ob_mac_tso_iocb->vlan_tci); + netdev_err(qdev->ndev, "%s\n", __func__); + netdev_err(qdev->ndev, "opcode = %s\n", + (ob_mac_iocb->opcode == OPCODE_OB_MAC_IOCB) ? "MAC" : "TSO"); + netdev_err(qdev->ndev, "flags1 = %s %s %s %s %s\n", + ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_OI ? "OI" : "", + ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_I ? "I" : "", + ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_D ? "D" : "", + ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_IP4 ? "IP4" : "", + ob_mac_tso_iocb->flags1 & OB_MAC_TSO_IOCB_IP6 ? "IP6" : ""); + netdev_err(qdev->ndev, "flags2 = %s %s %s\n", + ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_LSO ? "LSO" : "", + ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_UC ? "UC" : "", + ob_mac_tso_iocb->flags2 & OB_MAC_TSO_IOCB_TC ? "TC" : ""); + netdev_err(qdev->ndev, "flags3 = %s %s %s\n", + ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_IC ? "IC" : "", + ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_DFP ? "DFP" : "", + ob_mac_tso_iocb->flags3 & OB_MAC_TSO_IOCB_V ? "V" : ""); + netdev_err(qdev->ndev, "tid = %x\n", ob_mac_iocb->tid); + netdev_err(qdev->ndev, "txq_idx = %d\n", ob_mac_iocb->txq_idx); + netdev_err(qdev->ndev, "vlan_tci = %x\n", ob_mac_tso_iocb->vlan_tci); if (ob_mac_iocb->opcode == OPCODE_OB_MAC_TSO_IOCB) { - pr_err("frame_len = %d\n", - le32_to_cpu(ob_mac_tso_iocb->frame_len)); - pr_err("mss = %d\n", - le16_to_cpu(ob_mac_tso_iocb->mss)); - pr_err("prot_hdr_len = %d\n", - le16_to_cpu(ob_mac_tso_iocb->total_hdrs_len)); - pr_err("hdr_offset = 0x%.04x\n", - le16_to_cpu(ob_mac_tso_iocb->net_trans_offset)); + netdev_err(qdev->ndev, "frame_len = %d\n", + le32_to_cpu(ob_mac_tso_iocb->frame_len)); + netdev_err(qdev->ndev, "mss = %d\n", + le16_to_cpu(ob_mac_tso_iocb->mss)); + netdev_err(qdev->ndev, "prot_hdr_len = %d\n", + le16_to_cpu(ob_mac_tso_iocb->total_hdrs_len)); + netdev_err(qdev->ndev, "hdr_offset = 0x%.04x\n", + le16_to_cpu(ob_mac_tso_iocb->net_trans_offset)); frame_len = le32_to_cpu(ob_mac_tso_iocb->frame_len); } else { - pr_err("frame_len = %d\n", - le16_to_cpu(ob_mac_iocb->frame_len)); + netdev_err(qdev->ndev, "frame_len = %d\n", + le16_to_cpu(ob_mac_iocb->frame_len)); frame_len = le16_to_cpu(ob_mac_iocb->frame_len); } tbd = &ob_mac_iocb->tbd[0]; @@ -1882,98 +1892,98 @@ void ql_dump_ob_mac_iocb(struct ob_mac_iocb_req *ob_mac_iocb) void ql_dump_ob_mac_rsp(struct ob_mac_iocb_rsp *ob_mac_rsp) { - pr_err("%s\n", __func__); - pr_err("opcode = %d\n", ob_mac_rsp->opcode); - pr_err("flags = %s %s %s %s %s %s %s\n", - ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_OI ? "OI" : ".", - ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_I ? "I" : ".", - ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_E ? "E" : ".", - ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_S ? "S" : ".", - ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_L ? "L" : ".", - ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_P ? "P" : ".", - ob_mac_rsp->flags2 & OB_MAC_IOCB_RSP_B ? "B" : "."); - pr_err("tid = %x\n", ob_mac_rsp->tid); + netdev_err(qdev->ndev, "%s\n", __func__); + netdev_err(qdev->ndev, "opcode = %d\n", ob_mac_rsp->opcode); + netdev_err(qdev->ndev, "flags = %s %s %s %s %s %s %s\n", + ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_OI ? + "OI" : ".", ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_I ? "I" : ".", + ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_E ? "E" : ".", + ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_S ? "S" : ".", + ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_L ? "L" : ".", + ob_mac_rsp->flags1 & OB_MAC_IOCB_RSP_P ? "P" : ".", + ob_mac_rsp->flags2 & OB_MAC_IOCB_RSP_B ? "B" : "."); + netdev_err(qdev->ndev, "tid = %x\n", ob_mac_rsp->tid); } #endif #ifdef QL_IB_DUMP void ql_dump_ib_mac_rsp(struct ib_mac_iocb_rsp *ib_mac_rsp) { - pr_err("%s\n", __func__); - pr_err("opcode = 0x%x\n", ib_mac_rsp->opcode); - pr_err("flags1 = %s%s%s%s%s%s\n", - ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_OI ? "OI " : "", - ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_I ? "I " : "", - ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_TE ? "TE " : "", - ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_NU ? "NU " : "", - ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_IE ? "IE " : "", - ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_B ? "B " : ""); + netdev_err(qdev->ndev, "%s\n", __func__); + netdev_err(qdev->ndev, "opcode = 0x%x\n", ib_mac_rsp->opcode); + netdev_err(qdev->ndev, "flags1 = %s%s%s%s%s%s\n", + ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_OI ? "OI " : "", + ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_I ? "I " : "", + ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_TE ? "TE " : "", + ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_NU ? "NU " : "", + ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_IE ? "IE " : "", + ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_B ? "B " : ""); if (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) - pr_err("%s%s%s Multicast\n", - (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) == - IB_MAC_IOCB_RSP_M_HASH ? "Hash" : "", - (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) == - IB_MAC_IOCB_RSP_M_REG ? "Registered" : "", - (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) == - IB_MAC_IOCB_RSP_M_PROM ? "Promiscuous" : ""); - - pr_err("flags2 = %s%s%s%s%s\n", - (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_P) ? "P " : "", - (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_V) ? "V " : "", - (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_U) ? "U " : "", - (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_T) ? "T " : "", - (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_FO) ? "FO " : ""); + netdev_err(qdev->ndev, "%s%s%s Multicast\n", + (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) == + IB_MAC_IOCB_RSP_M_HASH ? "Hash" : "", + (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) == + IB_MAC_IOCB_RSP_M_REG ? "Registered" : "", + (ib_mac_rsp->flags1 & IB_MAC_IOCB_RSP_M_MASK) == + IB_MAC_IOCB_RSP_M_PROM ? "Promiscuous" : ""); + + netdev_err(qdev->ndev, "flags2 = %s%s%s%s%s\n", + (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_P) ? "P " : "", + (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_V) ? "V " : "", + (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_U) ? "U " : "", + (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_T) ? "T " : "", + (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_FO) ? "FO " : ""); if (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) - pr_err("%s%s%s%s%s error\n", - (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) == - IB_MAC_IOCB_RSP_ERR_OVERSIZE ? "oversize" : "", - (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) == - IB_MAC_IOCB_RSP_ERR_UNDERSIZE ? "undersize" : "", - (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) == - IB_MAC_IOCB_RSP_ERR_PREAMBLE ? "preamble" : "", - (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) == - IB_MAC_IOCB_RSP_ERR_FRAME_LEN ? "frame length" : "", - (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) == - IB_MAC_IOCB_RSP_ERR_CRC ? "CRC" : ""); - - pr_err("flags3 = %s%s\n", - ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DS ? "DS " : "", - ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL ? "DL " : ""); + netdev_err(qdev->ndev, "%s%s%s%s%s error\n", + (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) == + IB_MAC_IOCB_RSP_ERR_OVERSIZE ? "oversize" : "", + (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) == + IB_MAC_IOCB_RSP_ERR_UNDERSIZE ? "undersize" : "", + (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) == + IB_MAC_IOCB_RSP_ERR_PREAMBLE ? "preamble" : "", + (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) == + IB_MAC_IOCB_RSP_ERR_FRAME_LEN ? "frame length" : "", + (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_ERR_MASK) == + IB_MAC_IOCB_RSP_ERR_CRC ? "CRC" : ""); + + netdev_err(qdev->ndev, "flags3 = %s%s\n", + ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DS ? "DS " : "", + ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_DL ? "DL " : ""); if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) - pr_err("RSS flags = %s%s%s%s\n", - ((ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) == - IB_MAC_IOCB_RSP_M_IPV4) ? "IPv4 RSS" : "", - ((ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) == - IB_MAC_IOCB_RSP_M_IPV6) ? "IPv6 RSS " : "", - ((ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) == - IB_MAC_IOCB_RSP_M_TCP_V4) ? "TCP/IPv4 RSS" : "", - ((ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) == - IB_MAC_IOCB_RSP_M_TCP_V6) ? "TCP/IPv6 RSS" : ""); - - pr_err("data_len = %d\n", - le32_to_cpu(ib_mac_rsp->data_len)); - pr_err("data_addr = 0x%llx\n", - (unsigned long long)le64_to_cpu(ib_mac_rsp->data_addr)); + netdev_err(qdev->ndev, "RSS flags = %s%s%s%s\n", + ((ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) == + IB_MAC_IOCB_RSP_M_IPV4) ? "IPv4 RSS" : "", + ((ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) == + IB_MAC_IOCB_RSP_M_IPV6) ? "IPv6 RSS " : "", + ((ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) == + IB_MAC_IOCB_RSP_M_TCP_V4) ? "TCP/IPv4 RSS" : "", + ((ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) == + IB_MAC_IOCB_RSP_M_TCP_V6) ? "TCP/IPv6 RSS" : ""); + + netdev_err(qdev->ndev, "data_len = %d\n", + le32_to_cpu(ib_mac_rsp->data_len)); + netdev_err(qdev->ndev, "data_addr = 0x%llx\n", + (unsigned long long)le64_to_cpu(ib_mac_rsp->data_addr)); if (ib_mac_rsp->flags3 & IB_MAC_IOCB_RSP_RSS_MASK) - pr_err("rss = %x\n", - le32_to_cpu(ib_mac_rsp->rss)); + netdev_err(qdev->ndev, "rss = %x\n", + le32_to_cpu(ib_mac_rsp->rss)); if (ib_mac_rsp->flags2 & IB_MAC_IOCB_RSP_V) - pr_err("vlan_id = %x\n", - le16_to_cpu(ib_mac_rsp->vlan_id)); + netdev_err(qdev->ndev, "vlan_id = %x\n", + le16_to_cpu(ib_mac_rsp->vlan_id)); - pr_err("flags4 = %s%s%s\n", - ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV ? "HV " : "", - ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS ? "HS " : "", - ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HL ? "HL " : ""); + netdev_err(qdev->ndev, "flags4 = %s%s%s\n", + ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV ? "HV " : "", + ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HS ? "HS " : "", + ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HL ? "HL " : ""); if (ib_mac_rsp->flags4 & IB_MAC_IOCB_RSP_HV) { - pr_err("hdr length = %d\n", - le32_to_cpu(ib_mac_rsp->hdr_len)); - pr_err("hdr addr = 0x%llx\n", - (unsigned long long)le64_to_cpu(ib_mac_rsp->hdr_addr)); + netdev_err(qdev->ndev, "hdr length = %d\n", + le32_to_cpu(ib_mac_rsp->hdr_len)); + netdev_err(qdev->ndev, "hdr addr = 0x%llx\n", + (unsigned long long)le64_to_cpu(ib_mac_rsp->hdr_addr)); } } #endif -- cgit v1.2.3-58-ga151 From a45f04ba2422f6eab8226cd9ea05251e92b0914f Mon Sep 17 00:00:00 2001 From: B K Karthik Date: Mon, 29 Jun 2020 01:34:42 -0400 Subject: staging: rtl8188eu: include: hal8188e_rate_adaptive.h: fixed a blank space coding style issue added blank space around arithmetic operators to improve readability Signed-off-by: B K Karthik Link: https://lore.kernel.org/r/20200629053442.eob7oixlxbs5rh33@pesu-pes-edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h b/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h index 5b59c25e4c8a..79c0d2f9961e 100644 --- a/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h +++ b/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h @@ -35,17 +35,17 @@ #define GET_TX_REPORT_TYPE1_RERTY_0(__pAddr) \ LE_BITS_TO_4BYTE(__pAddr, 0, 16) #define GET_TX_REPORT_TYPE1_RERTY_1(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr+2, 0, 8) + LE_BITS_TO_1BYTE(__pAddr + 2, 0, 8) #define GET_TX_REPORT_TYPE1_RERTY_2(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr+3, 0, 8) + LE_BITS_TO_1BYTE(__pAddr + 3, 0, 8) #define GET_TX_REPORT_TYPE1_RERTY_3(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr+4, 0, 8) + LE_BITS_TO_1BYTE(__pAddr + 4, 0, 8) #define GET_TX_REPORT_TYPE1_RERTY_4(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr+4+1, 0, 8) + LE_BITS_TO_1BYTE(__pAddr + 4 + 1, 0, 8) #define GET_TX_REPORT_TYPE1_DROP_0(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr+4+2, 0, 8) + LE_BITS_TO_1BYTE(__pAddr + 4 + 2, 0, 8) #define GET_TX_REPORT_TYPE1_DROP_1(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr+4+3, 0, 8) + LE_BITS_TO_1BYTE(__pAddr + 4 + 3, 0, 8) /* End rate adaptive define */ -- cgit v1.2.3-58-ga151 From 41843ff0ece111515fc1913e4e5295fa398c5d00 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Sun, 28 Jun 2020 20:39:26 +0200 Subject: staging: ks7010: fix ks_wlan_start_xmit()'s return type The method ndo_start_xmit() is defined as returning an 'netdev_tx_t', which is a typedef for an enum type, but the implementation in this driver returns an 'int'. Fix this by returning 'netdev_tx_t' in this driver too and usind 'NETDEV_TX_OK' instead of 0 accordingly. Signed-off-by: Luc Van Oostenryck Link: https://lore.kernel.org/r/20200628183926.74908-1-luc.vanoostenryck@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 211dd4a11cac..334ae1ded684 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -46,7 +46,7 @@ struct wep_key { */ static int ks_wlan_open(struct net_device *dev); static void ks_wlan_tx_timeout(struct net_device *dev, unsigned int txqueue); -static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev); +static netdev_tx_t ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev); static int ks_wlan_close(struct net_device *dev); static void ks_wlan_set_rx_mode(struct net_device *dev); static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev); @@ -2511,7 +2511,7 @@ void ks_wlan_tx_timeout(struct net_device *dev, unsigned int txqueue) } static -int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev) +netdev_tx_t ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct ks_wlan_private *priv = netdev_priv(dev); int ret; -- cgit v1.2.3-58-ga151 From b98dabc11edd33592822d34e1fb3437a3f5d6814 Mon Sep 17 00:00:00 2001 From: B K Karthik Date: Mon, 29 Jun 2020 04:07:48 -0400 Subject: staging: rtl8188eu: include: odm.h: fixed a blank space coding style issue. added blank space and enclosed a complex valued macro within parentheses for improved code readability. Signed-off-by: B K Karthik Link: https://lore.kernel.org/r/20200629080748.l4ufcpuk4cg2m725@pesu-pes-edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/odm.h b/drivers/staging/rtl8188eu/include/odm.h index c6b6ba191e1b..d814ce492424 100644 --- a/drivers/staging/rtl8188eu/include/odm.h +++ b/drivers/staging/rtl8188eu/include/odm.h @@ -242,7 +242,7 @@ struct odm_rate_adapt { #define AVG_THERMAL_NUM 8 #define IQK_Matrix_REG_NUM 8 -#define IQK_Matrix_Settings_NUM 1+24+21 +#define IQK_Matrix_Settings_NUM (1 + 24 + 21) #define DM_Type_ByFWi 0 #define DM_Type_ByDriver 1 -- cgit v1.2.3-58-ga151 From 0c90789ad0377490a4e5937d96f364f055e1f3c7 Mon Sep 17 00:00:00 2001 From: Vaibhav Gupta Date: Mon, 29 Jun 2020 13:58:17 +0530 Subject: staging: rtl8192e: use generic power management The structure of working of PM hooks for source files is: drivers/staging/rtl8192e/rtl8192e/rtl_pm.h : callbacks declared drivers/staging/rtl8192e/rtl8192e/rtl_pm.c : callbacks defined drivers/staging/rtl8192e/rtl8192e/rtl_core.c : callbacks used Drivers should not use legacy power management as they have to manage power states and related operations, for the device, themselves. This driver was handling them with the help of PCI helper functions like pci_save/restore_state(), pci_enable/disable_device(), etc. With generic PM, all essentials will be handled by the PCI core. Driver needs to do only device-specific operations. The driver was also using pci_enable_wake(...,..., 0) to disable wake. Use device_wakeup_disable() instead. Use device_set_wakeup_enable() where WOL is decided by the value of a variable during runtime. Compile-tested only. Signed-off-by: Vaibhav Gupta Link: https://lore.kernel.org/r/20200629082819.216405-3-vaibhavgupta40@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 5 +++-- drivers/staging/rtl8192e/rtl8192e/rtl_pm.c | 26 +++++++------------------- drivers/staging/rtl8192e/rtl8192e/rtl_pm.h | 4 ++-- 3 files changed, 12 insertions(+), 23 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index a7cd4de65b28..dbcb8d0d9707 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -63,13 +63,14 @@ static int _rtl92e_pci_probe(struct pci_dev *pdev, static void _rtl92e_pci_disconnect(struct pci_dev *pdev); static irqreturn_t _rtl92e_irq(int irq, void *netdev); +static SIMPLE_DEV_PM_OPS(rtl92e_pm_ops, rtl92e_suspend, rtl92e_resume); + static struct pci_driver rtl8192_pci_driver = { .name = DRV_NAME, /* Driver name */ .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ .probe = _rtl92e_pci_probe, /* probe fn */ .remove = _rtl92e_pci_disconnect, /* remove fn */ - .suspend = rtl92e_suspend, /* PM suspend fn */ - .resume = rtl92e_resume, /* PM resume fn */ + .driver.pm = &rtl92e_pm_ops, }; static short _rtl92e_is_tx_queue_empty(struct net_device *dev); diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c index cd3e17b41d6f..5575186caebd 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c @@ -10,9 +10,9 @@ #include "rtl_pm.h" -int rtl92e_suspend(struct pci_dev *pdev, pm_message_t state) +int rtl92e_suspend(struct device *dev_d) { - struct net_device *dev = pci_get_drvdata(pdev); + struct net_device *dev = dev_get_drvdata(dev_d); struct r8192_priv *priv = rtllib_priv(dev); u32 ulRegRead; @@ -46,40 +46,28 @@ int rtl92e_suspend(struct pci_dev *pdev, pm_message_t state) out_pci_suspend: netdev_info(dev, "WOL is %s\n", priv->rtllib->bSupportRemoteWakeUp ? "Supported" : "Not supported"); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_enable_wake(pdev, pci_choose_state(pdev, state), - priv->rtllib->bSupportRemoteWakeUp ? 1 : 0); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); + device_set_wakeup_enable(dev_d, priv->rtllib->bSupportRemoteWakeUp); mdelay(20); return 0; } -int rtl92e_resume(struct pci_dev *pdev) +int rtl92e_resume(struct device *dev_d) { - struct net_device *dev = pci_get_drvdata(pdev); + struct pci_dev *pdev = to_pci_dev(dev_d); + struct net_device *dev = dev_get_drvdata(dev_d); struct r8192_priv *priv = rtllib_priv(dev); - int err; u32 val; netdev_info(dev, "================>r8192E resume call.\n"); - pci_set_power_state(pdev, PCI_D0); - - err = pci_enable_device(pdev); - if (err) { - netdev_err(dev, "pci_enable_device failed on resume\n"); - return err; - } - pci_restore_state(pdev); pci_read_config_dword(pdev, 0x40, &val); if ((val & 0x0000ff00) != 0) pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); - pci_enable_wake(pdev, PCI_D0, 0); + device_wakeup_disable(dev_d); if (priv->polling_timer_on == 0) rtl92e_check_rfctrl_gpio_timer(&priv->gpio_polling_timer); diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.h b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.h index e58f2bcdb1dd..fd8611495975 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.h @@ -10,7 +10,7 @@ #include #include -int rtl92e_suspend(struct pci_dev *dev, pm_message_t state); -int rtl92e_resume(struct pci_dev *dev); +int rtl92e_suspend(struct device *dev_d); +int rtl92e_resume(struct device *dev_d); #endif -- cgit v1.2.3-58-ga151 From b21204b60d0149859f2d285b8c2371f40e9bb0e7 Mon Sep 17 00:00:00 2001 From: Vaibhav Gupta Date: Mon, 29 Jun 2020 13:58:18 +0530 Subject: staging: rts5208/rtsx.c: use generic power management Drivers should not use legacy power management as they have to manage power states and related operations, for the device, themselves. This driver was handling them with the help of PCI helper functions like pci_save/restore_state(), pci_enable/disable_device(), etc. With generic PM, all essentials will be handled by the PCI core. Driver needs to do only device-specific operations. The driver was also using pci_enable_wake(...,..., 0) to disable wake. Use device_wakeup_disable() instead. Compile-tested only. Signed-off-by: Vaibhav Gupta Link: https://lore.kernel.org/r/20200629082819.216405-4-vaibhavgupta40@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index 937f4e732a75..e28e162d004e 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -258,12 +258,12 @@ static int rtsx_acquire_irq(struct rtsx_dev *dev) return 0; } -#ifdef CONFIG_PM /* * power management */ -static int rtsx_suspend(struct pci_dev *pci, pm_message_t state) +static int __maybe_unused rtsx_suspend(struct device *dev_d) { + struct pci_dev *pci = to_pci_dev(dev_d); struct rtsx_dev *dev = pci_get_drvdata(pci); struct rtsx_chip *chip; @@ -285,10 +285,7 @@ static int rtsx_suspend(struct pci_dev *pci, pm_message_t state) if (chip->msi_en) pci_disable_msi(pci); - pci_save_state(pci); - pci_enable_wake(pci, pci_choose_state(pci, state), 1); - pci_disable_device(pci); - pci_set_power_state(pci, pci_choose_state(pci, state)); + device_wakeup_enable(dev_d); /* unlock the device pointers */ mutex_unlock(&dev->dev_mutex); @@ -296,8 +293,9 @@ static int rtsx_suspend(struct pci_dev *pci, pm_message_t state) return 0; } -static int rtsx_resume(struct pci_dev *pci) +static int __maybe_unused rtsx_resume(struct device *dev_d) { + struct pci_dev *pci = to_pci_dev(dev_d); struct rtsx_dev *dev = pci_get_drvdata(pci); struct rtsx_chip *chip; @@ -309,16 +307,6 @@ static int rtsx_resume(struct pci_dev *pci) /* lock the device pointers */ mutex_lock(&dev->dev_mutex); - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - dev_err(&dev->pci->dev, - "%s: pci_enable_device failed, disabling device\n", - CR_DRIVER_NAME); - /* unlock the device pointers */ - mutex_unlock(&dev->dev_mutex); - return -EIO; - } pci_set_master(pci); if (chip->msi_en) { @@ -340,7 +328,6 @@ static int rtsx_resume(struct pci_dev *pci) return 0; } -#endif /* CONFIG_PM */ static void rtsx_shutdown(struct pci_dev *pci) { @@ -1000,16 +987,15 @@ static const struct pci_device_id rtsx_ids[] = { MODULE_DEVICE_TABLE(pci, rtsx_ids); +static SIMPLE_DEV_PM_OPS(rtsx_pm_ops, rtsx_suspend, rtsx_resume); + /* pci_driver definition */ static struct pci_driver rtsx_driver = { .name = CR_DRIVER_NAME, .id_table = rtsx_ids, .probe = rtsx_probe, .remove = rtsx_remove, -#ifdef CONFIG_PM - .suspend = rtsx_suspend, - .resume = rtsx_resume, -#endif + .driver.pm = &rtsx_pm_ops, .shutdown = rtsx_shutdown, }; -- cgit v1.2.3-58-ga151 From 7a46931ba9a25ce73761f4015f004229df44ef13 Mon Sep 17 00:00:00 2001 From: Vaibhav Gupta Date: Mon, 29 Jun 2020 13:58:19 +0530 Subject: staging: vt6655/device_main.c: use generic power management Drivers should not use legacy power management as they have to manage power states and related operations, for the device, themselves. This driver was handling them with the help of PCI helper functions like pci_save/restore_state(), pci_enable/disable_device(), etc. With generic PM, all essentials will be handled by the PCI core. Driver needs to do only device-specific operations. The driver was also using pci_enable_wake(...,..., 0) to disable wake. Use device_wakeup_disable() instead. Compile-tested only. Signed-off-by: Vaibhav Gupta Link: https://lore.kernel.org/r/20200629082819.216405-5-vaibhavgupta40@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 41cbec4134b0..76de1fd568eb 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1766,48 +1766,37 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) /*------------------------------------------------------------------*/ -#ifdef CONFIG_PM -static int vt6655_suspend(struct pci_dev *pcid, pm_message_t state) +static int __maybe_unused vt6655_suspend(struct device *dev_d) { - struct vnt_private *priv = pci_get_drvdata(pcid); + struct vnt_private *priv = dev_get_drvdata(dev_d); unsigned long flags; spin_lock_irqsave(&priv->lock, flags); - pci_save_state(pcid); - MACbShutdown(priv); - pci_disable_device(pcid); - spin_unlock_irqrestore(&priv->lock, flags); - pci_set_power_state(pcid, pci_choose_state(pcid, state)); - return 0; } -static int vt6655_resume(struct pci_dev *pcid) +static int __maybe_unused vt6655_resume(struct device *dev_d) { - pci_set_power_state(pcid, PCI_D0); - pci_enable_wake(pcid, PCI_D0, 0); - pci_restore_state(pcid); + device_wakeup_disable(dev_d); return 0; } -#endif MODULE_DEVICE_TABLE(pci, vt6655_pci_id_table); +static SIMPLE_DEV_PM_OPS(vt6655_pm_ops, vt6655_suspend, vt6655_resume); + static struct pci_driver device_driver = { .name = DEVICE_NAME, .id_table = vt6655_pci_id_table, .probe = vt6655_probe, .remove = vt6655_remove, -#ifdef CONFIG_PM - .suspend = vt6655_suspend, - .resume = vt6655_resume, -#endif + .driver.pm = &vt6655_pm_ops, }; module_pci_driver(device_driver); -- cgit v1.2.3-58-ga151 From be1247782e5ce606ad47220a87bd3d0fbabe3e4c Mon Sep 17 00:00:00 2001 From: Vaibhav Gupta Date: Mon, 29 Jun 2020 23:04:56 +0530 Subject: staging: qlge/qlge_main.c: use generic power management Drivers should not use legacy power management as they have to manage power states and related operations, for the device, themselves. This driver was handling them with the help of PCI helper functions like pci_save/restore_state(), pci_enable/disable_device(), etc. With generic PM, all essentials will be handled by the PCI core. Driver needs to do only device-specific operations. The driver was also using pci_enable_wake(...,..., 0) to disable wake. Use device_wakeup_disable() instead. Compile-tested only. Signed-off-by: Vaibhav Gupta Link: https://lore.kernel.org/r/20200629173459.262075-2-vaibhavgupta40@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_main.c | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 0054c454506b..f7e26defb844 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -4764,9 +4764,9 @@ static const struct pci_error_handlers qlge_err_handler = { .resume = qlge_io_resume, }; -static int qlge_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused qlge_suspend(struct device *dev_d) { - struct net_device *ndev = pci_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev_d); struct ql_adapter *qdev = netdev_priv(ndev); int err; @@ -4780,35 +4780,19 @@ static int qlge_suspend(struct pci_dev *pdev, pm_message_t state) } ql_wol(qdev); - err = pci_save_state(pdev); - if (err) - return err; - - pci_disable_device(pdev); - - pci_set_power_state(pdev, pci_choose_state(pdev, state)); return 0; } -#ifdef CONFIG_PM -static int qlge_resume(struct pci_dev *pdev) +static int __maybe_unused qlge_resume(struct device *dev_d) { - struct net_device *ndev = pci_get_drvdata(pdev); + struct net_device *ndev = dev_get_drvdata(dev_d); struct ql_adapter *qdev = netdev_priv(ndev); int err; - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - err = pci_enable_device(pdev); - if (err) { - netif_err(qdev, ifup, qdev->ndev, "Cannot enable PCI device from suspend\n"); - return err; - } - pci_set_master(pdev); + pci_set_master(to_pci_dev(dev_d)); - pci_enable_wake(pdev, PCI_D3hot, 0); - pci_enable_wake(pdev, PCI_D3cold, 0); + device_wakeup_disable(dev_d); if (netif_running(ndev)) { err = ql_adapter_up(qdev); @@ -4821,22 +4805,20 @@ static int qlge_resume(struct pci_dev *pdev) return 0; } -#endif /* CONFIG_PM */ static void qlge_shutdown(struct pci_dev *pdev) { - qlge_suspend(pdev, PMSG_SUSPEND); + qlge_suspend(&pdev->dev); } +static SIMPLE_DEV_PM_OPS(qlge_pm_ops, qlge_suspend, qlge_resume); + static struct pci_driver qlge_driver = { .name = DRV_NAME, .id_table = qlge_pci_tbl, .probe = qlge_probe, .remove = qlge_remove, -#ifdef CONFIG_PM - .suspend = qlge_suspend, - .resume = qlge_resume, -#endif + .driver.pm = &qlge_pm_ops, .shutdown = qlge_shutdown, .err_handler = &qlge_err_handler }; -- cgit v1.2.3-58-ga151 From 3a90d8186659b11dba0b19f60cfd866979f8b1be Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 29 Jun 2020 18:12:54 +0200 Subject: staging: rtl8188eu: use compound assignment operators Use compound assignment operators to simplify the code and clear missing spaces around operators checkpatch issues. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200629161255.28371-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index d5968ef9f43d..68196d8c05eb 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -211,7 +211,7 @@ static char *translate_scan(struct adapter *padapter, else/* default MCS7 */ max_rate = (bw_40MHz) ? ((short_GI) ? 150 : 135) : ((short_GI) ? 72 : 65); - max_rate = max_rate*2;/* Mbps/2; */ + max_rate *= 2; /* Mbps/2; */ } iwe.cmd = SIOCGIWRATE; @@ -1395,7 +1395,7 @@ static int rtw_wx_set_rate(struct net_device *dev, ratevalue = 11; goto set_rate; } - target_rate = target_rate/100000; + target_rate /= 100000; switch (target_rate) { case 10: -- cgit v1.2.3-58-ga151 From ca003698251c11be0384b34afb76516fb8a55808 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 29 Jun 2020 18:12:55 +0200 Subject: staging: rtl8188eu: add spaces around operators Add spaces around operators to improve readability and clear checkpatch issues. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200629161255.28371-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 8 +- drivers/staging/rtl8188eu/core/rtw_recv.c | 70 ++++++++--------- drivers/staging/rtl8188eu/core/rtw_security.c | 102 ++++++++++++------------- drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 2 +- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 50 ++++++------ 5 files changed, 116 insertions(+), 116 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index e7777bf3bafb..39ca97411fd5 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -205,10 +205,10 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter) if (time_after_eq(adapter->pwrctrlpriv.ips_deny_time, jiffies)) return false; - if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || - check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) || + if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE | WIFI_SITE_MONITOR) || + check_fwstate(pmlmepriv, WIFI_UNDER_LINKING | WIFI_UNDER_WPS) || check_fwstate(pmlmepriv, WIFI_AP_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE)) + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE)) return false; return true; @@ -249,7 +249,7 @@ void rtw_ps_processor(struct adapter *padapter) if (!rtw_pwr_unassociated_idle(padapter)) goto exit; - if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts%4) == 0)) { + if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts % 4) == 0)) { DBG_88E("==>%s .fw_state(%x)\n", __func__, get_fwstate(pmlmepriv)); pwrpriv->change_rfpwrstate = rf_off; diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 61ea8f38829c..44579f7cab87 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -244,10 +244,10 @@ static int recvframe_chkmic(struct adapter *adapter, } /* icv_len included the mic code */ - datalen = precvframe->pkt->len-prxattrib->hdrlen - - prxattrib->iv_len-prxattrib->icv_len-8; + datalen = precvframe->pkt->len - prxattrib->hdrlen - + prxattrib->iv_len - prxattrib->icv_len - 8; pframe = precvframe->pkt->data; - payload = pframe+prxattrib->hdrlen+prxattrib->iv_len; + payload = pframe + prxattrib->hdrlen + prxattrib->iv_len; RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n prxattrib->iv_len=%d prxattrib->icv_len=%d\n", prxattrib->iv_len, prxattrib->icv_len)); rtw_seccalctkipmic(mickey, pframe, payload, datalen, &miccode[0], @@ -258,7 +258,7 @@ static int recvframe_chkmic(struct adapter *adapter, bmic_err = false; for (i = 0; i < 8; i++) { - if (miccode[i] != *(pframemic+i)) { + if (miccode[i] != *(pframemic + i)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("%s: miccode[%d](%02x)!=*(pframemic+%d)(%02x) ", __func__, i, miccode[i], i, *(pframemic + i))); @@ -269,14 +269,14 @@ static int recvframe_chkmic(struct adapter *adapter, if (bmic_err) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n *(pframemic-8)-*(pframemic-1)=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - *(pframemic-8), *(pframemic-7), *(pframemic-6), - *(pframemic-5), *(pframemic-4), *(pframemic-3), - *(pframemic-2), *(pframemic-1))); + *(pframemic - 8), *(pframemic - 7), *(pframemic - 6), + *(pframemic - 5), *(pframemic - 4), *(pframemic - 3), + *(pframemic - 2), *(pframemic - 1))); RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n *(pframemic-16)-*(pframemic-9)=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - *(pframemic-16), *(pframemic-15), *(pframemic-14), - *(pframemic-13), *(pframemic-12), *(pframemic-11), - *(pframemic-10), *(pframemic-9))); + *(pframemic - 16), *(pframemic - 15), *(pframemic - 14), + *(pframemic - 13), *(pframemic - 12), *(pframemic - 11), + *(pframemic - 10), *(pframemic - 9))); { uint i; @@ -287,14 +287,14 @@ static int recvframe_chkmic(struct adapter *adapter, RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x", - *(precvframe->pkt->data+i), - *(precvframe->pkt->data+i+1), - *(precvframe->pkt->data+i+2), - *(precvframe->pkt->data+i+3), - *(precvframe->pkt->data+i+4), - *(precvframe->pkt->data+i+5), - *(precvframe->pkt->data+i+6), - *(precvframe->pkt->data+i+7))); + *(precvframe->pkt->data + i), + *(precvframe->pkt->data + i + 1), + *(precvframe->pkt->data + i + 2), + *(precvframe->pkt->data + i + 3), + *(precvframe->pkt->data + i + 4), + *(precvframe->pkt->data + i + 5), + *(precvframe->pkt->data + i + 6), + *(precvframe->pkt->data + i + 7))); } RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, @@ -488,7 +488,7 @@ static int recv_decache(struct recv_frame *precv_frame, u8 bretry, { int tid = precv_frame->attrib.priority; - u16 seq_ctrl = ((precv_frame->attrib.seq_num&0xffff) << 4) | + u16 seq_ctrl = ((precv_frame->attrib.seq_num & 0xffff) << 4) | (precv_frame->attrib.frag_num & 0xf); if (tid > 15) { @@ -553,29 +553,29 @@ static void process_wmmps_data(struct adapter *padapter, if (!psta->qos_option) return; - if (!(psta->qos_info&0xf)) + if (!(psta->qos_info & 0xf)) return; - if (psta->state&WIFI_SLEEP_STATE) { + if (psta->state & WIFI_SLEEP_STATE) { u8 wmmps_ac = 0; switch (pattrib->priority) { case 1: case 2: - wmmps_ac = psta->uapsd_bk&BIT(1); + wmmps_ac = psta->uapsd_bk & BIT(1); break; case 4: case 5: - wmmps_ac = psta->uapsd_vi&BIT(1); + wmmps_ac = psta->uapsd_vi & BIT(1); break; case 6: case 7: - wmmps_ac = psta->uapsd_vo&BIT(1); + wmmps_ac = psta->uapsd_vo & BIT(1); break; case 0: case 3: default: - wmmps_ac = psta->uapsd_be&BIT(1); + wmmps_ac = psta->uapsd_be & BIT(1); break; } @@ -884,20 +884,20 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, switch (pattrib->priority) { case 1: case 2: - wmmps_ac = psta->uapsd_bk&BIT(0); + wmmps_ac = psta->uapsd_bk & BIT(0); break; case 4: case 5: - wmmps_ac = psta->uapsd_vi&BIT(0); + wmmps_ac = psta->uapsd_vi & BIT(0); break; case 6: case 7: - wmmps_ac = psta->uapsd_vo&BIT(0); + wmmps_ac = psta->uapsd_vo & BIT(0); break; case 0: case 3: default: - wmmps_ac = psta->uapsd_be&BIT(0); + wmmps_ac = psta->uapsd_be & BIT(0); break; } @@ -910,7 +910,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, psta->state ^= WIFI_STA_ALIVE_CHK_STATE; } - if ((psta->state&WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap&BIT(psta->aid))) { + if ((psta->state & WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap & BIT(psta->aid))) { struct list_head *xmitframe_plist, *xmitframe_phead; struct xmit_frame *pxmitframe = NULL; @@ -948,7 +948,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, update_beacon(padapter, _TIM_IE_, NULL, false); } } else { - if (pstapriv->tim_bitmap&BIT(psta->aid)) { + if (pstapriv->tim_bitmap & BIT(psta->aid)) { if (psta->sleepq_len == 0) { DBG_88E("no buffered packets to xmit\n"); @@ -1266,8 +1266,8 @@ static int wlanhdr_to_ethhdr(struct recv_frame *precvframe) if (pattrib->encrypt) skb_trim(precvframe->pkt, precvframe->pkt->len - pattrib->icv_len); - psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen + pattrib->iv_len); - psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE; + psnap = (struct ieee80211_snap_hdr *)(ptr + pattrib->hdrlen + pattrib->iv_len); + psnap_type = ptr + pattrib->hdrlen + pattrib->iv_len + SNAP_SIZE; /* convert hdr + possible LLC headers into Ethernet header */ if ((!memcmp(psnap, rfc1042_header, SNAP_SIZE) && memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) && @@ -1286,7 +1286,7 @@ static int wlanhdr_to_ethhdr(struct recv_frame *precvframe) RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n===pattrib->hdrlen: %x, pattrib->iv_len:%x===\n\n", pattrib->hdrlen, pattrib->iv_len)); - memcpy(&be_tmp, ptr+rmv_len, 2); + memcpy(&be_tmp, ptr + rmv_len, 2); eth_type = ntohs(be_tmp); /* pattrib->ether_type */ pattrib->eth_type = eth_type; @@ -1535,7 +1535,7 @@ static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) pdata += nSubframe_Length; a_len -= nSubframe_Length; if (a_len != 0) { - padding_len = 4 - ((nSubframe_Length + ETH_HLEN) & (4-1)); + padding_len = 4 - ((nSubframe_Length + ETH_HLEN) & (4 - 1)); if (padding_len == 4) padding_len = 0; diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index 435c0fbec54a..f9139f72b3a7 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -80,9 +80,9 @@ static u32 crc32_table[256]; static u8 crc32_reverseBit(u8 data) { - return (u8)((data<<7)&0x80) | ((data<<5)&0x40) | ((data<<3)&0x20) | - ((data<<1)&0x10) | ((data>>1)&0x08) | ((data>>3)&0x04) | - ((data>>5)&0x02) | ((data>>7)&0x01); + return (u8)((data << 7) & 0x80) | ((data << 5) & 0x40) | ((data << 3) & 0x20) | + ((data << 1) & 0x10) | ((data >> 1) & 0x08) | ((data >> 3) & 0x04) | + ((data >> 5) & 0x02) | ((data >> 7) & 0x01); } static void crc32_init(void) @@ -260,7 +260,7 @@ static u32 secmicgetuint32(u8 *p) u32 res = 0; for (i = 0; i < 4; i++) - res |= ((u32)(*p++)) << (8*i); + res |= ((u32)(*p++)) << (8 * i); return res; } @@ -296,7 +296,7 @@ void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key) void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b) { /* Append the byte to our word-sized buffer */ - pmicdata->M |= ((unsigned long)b) << (8*pmicdata->nBytesInM); + pmicdata->M |= ((unsigned long)b) << (8 * pmicdata->nBytesInM); pmicdata->nBytesInM++; /* Process the word if it is full. */ if (pmicdata->nBytesInM >= 4) { @@ -337,7 +337,7 @@ void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst) rtw_secmicappendbyte(pmicdata, 0); /* The appendByte function has already computed the result. */ secmicputuint32(dst, pmicdata->L); - secmicputuint32(dst+4, pmicdata->R); + secmicputuint32(dst + 4, pmicdata->R); /* Reset to the empty message. */ secmicclear(pmicdata); } @@ -351,15 +351,15 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_cod priority[0] = pri; /* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */ - if (header[1]&1) { /* ToDS == 1 */ + if (header[1] & 1) { /* ToDS == 1 */ rtw_secmicappend(&micdata, &header[16], 6); /* DA */ - if (header[1]&2) /* From Ds == 1 */ + if (header[1] & 2) /* From Ds == 1 */ rtw_secmicappend(&micdata, &header[24], 6); else rtw_secmicappend(&micdata, &header[10], 6); } else { /* ToDS == 0 */ rtw_secmicappend(&micdata, &header[4], 6); /* DA */ - if (header[1]&2) /* From Ds == 1 */ + if (header[1] & 2) /* From Ds == 1 */ rtw_secmicappend(&micdata, &header[16], 6); else rtw_secmicappend(&micdata, &header[10], 6); @@ -382,7 +382,7 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_cod #define Mk16(hi, lo) ((lo) ^ (((u16)(hi)) << 8)) /* select the Nth 16-bit word of the temporal key unsigned char array TK[] */ -#define TK16(N) Mk16(tk[2*(N)+1], tk[2*(N)]) +#define TK16(N) Mk16(tk[2 * (N) + 1], tk[2 * (N)]) /* S-box lookup: 16 bits --> 16 bits */ #define _S_(v16) (Sbox1[0][Lo8(v16)] ^ Sbox1[1][Hi8(v16)]) @@ -497,11 +497,11 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32) /* Now compute an unbalanced Feistel cipher with 80-bit block */ /* size on the 80-bit block P1K[], using the 128-bit key TK[] */ for (i = 0; i < PHASE1_LOOP_CNT; i++) { /* Each add operation here is mod 2**16 */ - p1k[0] += _S_(p1k[4] ^ TK16((i&1)+0)); - p1k[1] += _S_(p1k[0] ^ TK16((i&1)+2)); - p1k[2] += _S_(p1k[1] ^ TK16((i&1)+4)); - p1k[3] += _S_(p1k[2] ^ TK16((i&1)+6)); - p1k[4] += _S_(p1k[3] ^ TK16((i&1)+0)); + p1k[0] += _S_(p1k[4] ^ TK16((i & 1) + 0)); + p1k[1] += _S_(p1k[0] ^ TK16((i & 1) + 2)); + p1k[2] += _S_(p1k[1] ^ TK16((i & 1) + 4)); + p1k[3] += _S_(p1k[2] ^ TK16((i & 1) + 6)); + p1k[4] += _S_(p1k[3] ^ TK16((i & 1) + 0)); p1k[4] += (unsigned short)i; /* avoid "slide attacks" */ } } @@ -566,8 +566,8 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15] (little-endian) */ for (i = 0; i < 6; i++) { - rc4key[4+2*i] = Lo8(PPK[i]); - rc4key[5+2*i] = Hi8(PPK[i]); + rc4key[4 + 2 * i] = Lo8(PPK[i]); + rc4key[5 + 2 * i] = Hi8(PPK[i]); } } @@ -613,18 +613,18 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) prwskey = &stainfo->dot118021x_UncstKey.skey[0]; for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - iv = pframe+pattrib->hdrlen; - payload = pframe+pattrib->iv_len+pattrib->hdrlen; + iv = pframe + pattrib->hdrlen; + payload = pframe + pattrib->iv_len + pattrib->hdrlen; GET_TKIP_PN(iv, dot11txpn); pnl = (u16)(dot11txpn.val); - pnh = (u32)(dot11txpn.val>>16); + pnh = (u32)(dot11txpn.val >> 16); phase1((u16 *)&ttkey[0], prwskey, &pattrib->ta[0], pnh); phase2(&rc4key[0], prwskey, (u16 *)&ttkey[0], pnl); - if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ - length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + if ((curfragnum + 1) == pattrib->nr_frags) { /* 4 the last fragment */ + length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; RT_TRACE(_module_rtl871x_security_c_, _drv_info_, ("pattrib->iv_len=%x, pattrib->icv_len=%x\n", pattrib->iv_len, pattrib->icv_len)); @@ -632,13 +632,13 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc, 4); + arcfour_encrypt(&mycontext, payload + length, crc, 4); } else { - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc, 4); + arcfour_encrypt(&mycontext, payload + length, crc, 4); pframe += pxmitpriv->frag_len; pframe = (u8 *)round_up((size_t)(pframe), 4); @@ -689,14 +689,14 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) prwskey = &stainfo->dot118021x_UncstKey.skey[0]; } - iv = pframe+prxattrib->hdrlen; - payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; - length = ((struct recv_frame *)precvframe)->pkt->len-prxattrib->hdrlen-prxattrib->iv_len; + iv = pframe + prxattrib->hdrlen; + payload = pframe + prxattrib->iv_len + prxattrib->hdrlen; + length = ((struct recv_frame *)precvframe)->pkt->len - prxattrib->hdrlen - prxattrib->iv_len; GET_TKIP_PN(iv, dot11txpn); pnl = (u16)(dot11txpn.val); - pnh = (u32)(dot11txpn.val>>16); + pnh = (u32)(dot11txpn.val >> 16); phase1((u16 *)&ttkey[0], prwskey, &prxattrib->ta[0], pnh); phase2(&rc4key[0], prwskey, (unsigned short *)&ttkey[0], pnl); @@ -706,15 +706,15 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); - *((__le32 *)crc) = getcrc32(payload, length-4); + *((__le32 *)crc) = getcrc32(payload, length - 4); - if (crc[3] != payload[length-1] || - crc[2] != payload[length-2] || - crc[1] != payload[length-3] || - crc[0] != payload[length-4]) { + if (crc[3] != payload[length - 1] || + crc[2] != payload[length - 2] || + crc[1] != payload[length - 3] || + crc[0] != payload[length - 4]) { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_wep_decrypt:icv error crc (%4ph)!=payload (%4ph)\n", - &crc, &payload[length-4])); + &crc, &payload[length - 4])); res = _FAIL; } } else { @@ -900,7 +900,7 @@ static void mix_column(u8 *in, u8 *out) for (i = 3; i > 0; i--) { /* logical shift left 1 bit */ andf7[i] = andf7[i] << 1; - if ((andf7[i-1] & 0x80) == 0x80) + if ((andf7[i - 1] & 0x80) == 0x80) andf7[i] = (andf7[i] | 0x01); } andf7[0] = andf7[0] << 1; @@ -1025,7 +1025,7 @@ static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int if (!qc_exists && a4_exists) { for (i = 0; i < 6; i++) - mic_header2[8+i] = mpdu[24+i]; /* A4 */ + mic_header2[8 + i] = mpdu[24 + i]; /* A4 */ } if (qc_exists && !a4_exists) { @@ -1035,7 +1035,7 @@ static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int if (qc_exists && a4_exists) { for (i = 0; i < 6; i++) - mic_header2[8+i] = mpdu[24+i]; /* A4 */ + mic_header2[8 + i] = mpdu[24 + i]; /* A4 */ mic_header2[14] = mpdu[30] & 0x0f; mic_header2[15] = mpdu[31] & 0x00; @@ -1128,11 +1128,11 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) } pn_vector[0] = pframe[hdrlen]; - pn_vector[1] = pframe[hdrlen+1]; - pn_vector[2] = pframe[hdrlen+4]; - pn_vector[3] = pframe[hdrlen+5]; - pn_vector[4] = pframe[hdrlen+6]; - pn_vector[5] = pframe[hdrlen+7]; + pn_vector[1] = pframe[hdrlen + 1]; + pn_vector[2] = pframe[hdrlen + 4]; + pn_vector[3] = pframe[hdrlen + 5]; + pn_vector[4] = pframe[hdrlen + 6]; + pn_vector[5] = pframe[hdrlen + 7]; construct_mic_iv(mic_iv, qc_exists, a4_exists, pframe, plen, pn_vector); @@ -1174,11 +1174,11 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) /* Insert MIC into payload */ for (j = 0; j < 8; j++) - pframe[payload_index+j] = mic[j]; + pframe[payload_index + j] = mic[j]; payload_index = hdrlen + 8; for (i = 0; i < num_blocks; i++) { - construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i+1); + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i + 1); aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); for (j = 0; j < 16; j++) @@ -1187,12 +1187,12 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ /* encrypt it and copy the unpadded part back */ - construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks+1); + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks + 1); for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; for (j = 0; j < payload_remainder; j++) - padded_buffer[j] = pframe[payload_index+j]; + padded_buffer[j] = pframe[payload_index + j]; aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); for (j = 0; j < payload_remainder; j++) @@ -1204,7 +1204,7 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; for (j = 0; j < 8; j++) - padded_buffer[j] = pframe[j+hdrlen+8+plen]; + padded_buffer[j] = pframe[j + hdrlen + 8 + plen]; aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); @@ -1254,12 +1254,12 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) else prwskey = &stainfo->dot118021x_UncstKey.skey[0]; for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ - length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + if ((curfragnum + 1) == pattrib->nr_frags) { /* 4 the last fragment */ + length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; aes_cipher(prwskey, pattrib->hdrlen, pframe, length); } else { - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; aes_cipher(prwskey, pattrib->hdrlen, pframe, length); pframe += pxmitpriv->frag_len; diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 73f2cb5ebaa6..3c03141e25b1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -112,7 +112,7 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) inline int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta) { - int offset = (((u8 *)sta) - stapriv->pstainfo_buf)/sizeof(struct sta_info); + int offset = (((u8 *)sta) - stapriv->pstainfo_buf) / sizeof(struct sta_info); if (!stainfo_offset_valid(offset)) DBG_88E("%s invalid offset(%d), out of range!!!", __func__, offset); diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 68196d8c05eb..38484dffe095 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -120,7 +120,7 @@ static char *translate_scan(struct adapter *padapter, start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.ssid.ssid); /* parsing HT_CAP_IE */ - p = rtw_get_ie(&pnetwork->network.ies[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.ie_length-12); + p = rtw_get_ie(&pnetwork->network.ies[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.ie_length - 12); if (p && ht_ielen > 0) { struct ieee80211_ht_cap *pht_capie; @@ -195,7 +195,7 @@ static char *translate_scan(struct adapter *padapter, p = custom; p += scnprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); while (pnetwork->network.SupportedRates[i] != 0) { - rate = pnetwork->network.SupportedRates[i]&0x7F; + rate = pnetwork->network.SupportedRates[i] & 0x7F; if (rate > max_rate) max_rate = rate; p += scnprintf(p, MAX_CUSTOM_LEN - (p - custom), @@ -204,9 +204,9 @@ static char *translate_scan(struct adapter *padapter, } if (ht_cap) { - if (mcs_rate&0x8000)/* MCS15 */ + if (mcs_rate & 0x8000)/* MCS15 */ max_rate = (bw_40MHz) ? ((short_GI) ? 300 : 270) : ((short_GI) ? 144 : 130); - else if (mcs_rate&0x0080)/* MCS7 */ + else if (mcs_rate & 0x0080)/* MCS7 */ ; else/* default MCS7 */ max_rate = (bw_40MHz) ? ((short_GI) ? 150 : 135) : ((short_GI) ? 72 : 65); @@ -284,7 +284,7 @@ static char *translate_scan(struct adapter *padapter, iwe.u.data.length = (u16)wps_ielen; start = iwe_stream_add_point(info, start, stop, &iwe, wpsie_ptr); } - cnt += ie_ptr[cnt+1]+2; /* goto next */ + cnt += ie_ptr[cnt + 1] + 2; /* goto next */ } } @@ -512,7 +512,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie DBG_88E("\n wpa_ie(length:%d):\n", ielen); for (i = 0; i < ielen; i += 8) - DBG_88E("0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", buf[i], buf[i+1], buf[i+2], buf[i+3], buf[i+4], buf[i+5], buf[i+6], buf[i+7]); + DBG_88E("0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", buf[i], buf[i + 1], buf[i + 2], buf[i + 3], buf[i + 4], buf[i + 5], buf[i + 6], buf[i + 7]); } if (ielen < RSN_HEADER_LEN) { @@ -586,7 +586,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie while (cnt < ielen) { eid = buf[cnt]; - if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt+2], wps_oui, 4))) { + if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt + 2], wps_oui, 4))) { DBG_88E("SET WPS_IE\n"); padapter->securitypriv.wps_ie_len = min(buf[cnt + 1] + 2, MAX_WPA_IE_LEN << 2); @@ -594,10 +594,10 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie memcpy(padapter->securitypriv.wps_ie, &buf[cnt], padapter->securitypriv.wps_ie_len); set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS); - cnt += buf[cnt+1]+2; + cnt += buf[cnt + 1] + 2; break; } - cnt += buf[cnt+1]+2; /* goto next */ + cnt += buf[cnt + 1] + 2; /* goto next */ } } } @@ -628,7 +628,7 @@ static int rtw_wx_get_name(struct net_device *dev, if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { /* parsing HT_CAP_IE */ - p = rtw_get_ie(&pcur_bss->ies[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->ie_length-12); + p = rtw_get_ie(&pcur_bss->ies[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->ie_length - 12); if (p && ht_ielen > 0) ht_cap = true; @@ -782,7 +782,7 @@ static int rtw_wx_set_pmkid(struct net_device *dev, DBG_88E("[rtw_wx_set_pmkid] BSSID exists in the PMKList.\n"); memcpy(psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN); psecuritypriv->PMKIDList[j].bUsed = true; - psecuritypriv->PMKIDIndex = j+1; + psecuritypriv->PMKIDIndex = j + 1; blInserted = true; break; } @@ -1093,7 +1093,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, goto exit; } - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) { indicate_wx_scan_complete_event(padapter); goto exit; } @@ -1102,7 +1102,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, /* the pmlmepriv->scan_interval is always equal to 3. */ /* So, the wpa_supplicant won't find out the WPS SoftAP. */ - memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT); + memset(ssid, 0, sizeof(struct ndis_802_11_ssid) * RTW_SSID_SCAN_AMOUNT); if (wrqu->data.length == sizeof(struct iw_scan_req)) { struct iw_scan_req *req = (struct iw_scan_req *)extra; @@ -1128,7 +1128,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, if (wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE && !memcmp(extra, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { int len = wrqu->data.length - WEXT_CSCAN_HEADER_SIZE; - char *pos = extra+WEXT_CSCAN_HEADER_SIZE; + char *pos = extra + WEXT_CSCAN_HEADER_SIZE; char section; char sec_len; int ssid_index = 0; @@ -1239,7 +1239,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - wrqu->data.length = ev-extra; + wrqu->data.length = ev - extra; wrqu->data.flags = 0; exit: @@ -1890,7 +1890,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)) param->u.crypt.set_tx = 0; - param->u.crypt.idx = (pencoding->flags&0x00FF) - 1; + param->u.crypt.idx = (pencoding->flags & 0x00FF) - 1; if (pext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) memcpy(param->u.crypt.seq, pext->rx_seq, 8); @@ -1935,7 +1935,7 @@ static int wpa_set_param(struct net_device *dev, u8 name, u32 value) switch (name) { case IEEE_PARAM_WPA_ENABLED: padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; /* 802.1x */ - switch ((value)&0xff) { + switch (value & 0xff) { case 1: /* WPA */ padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; /* WPA_PSK */ padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; @@ -2407,7 +2407,7 @@ static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int if ((pstapriv->max_num_sta > NUM_STA) || (pstapriv->max_num_sta <= 0)) pstapriv->max_num_sta = NUM_STA; - if (rtw_check_beacon_data(padapter, pbuf, (len-12-2)) == _SUCCESS)/* 12 = param header, 2:no packed */ + if (rtw_check_beacon_data(padapter, pbuf, len - 12 - 2) == _SUCCESS) /* 12 = param header, 2:no packed */ ret = 0; else ret = -EINVAL; @@ -2436,7 +2436,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) DBG_88E("rtw_add_sta(aid =%d) =%pM\n", param->u.add_sta.aid, (param->sta_addr)); - if (!check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE))) + if (!check_fwstate(pmlmepriv, (_FW_LINKED | WIFI_AP_STATE))) return -EINVAL; if (is_broadcast_ether_addr(param->sta_addr)) @@ -2451,7 +2451,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) memcpy(psta->bssrateset, param->u.add_sta.tx_supp_rates, 16); /* check wmm cap. */ - if (WLAN_STA_WME&flags) + if (WLAN_STA_WME & flags) psta->qos_option = 1; else psta->qos_option = 0; @@ -2460,7 +2460,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) psta->qos_option = 0; /* chec 802.11n ht cap. */ - if (WLAN_STA_HT&flags) { + if (WLAN_STA_HT & flags) { psta->htpriv.ht_option = true; psta->qos_option = 1; memcpy(&psta->htpriv.ht_cap, ¶m->u.add_sta.ht_cap, @@ -2620,7 +2620,7 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return -EINVAL; - ie_len = len-12-2;/* 12 = param header, 2:no packed */ + ie_len = len - 12 - 2; /* 12 = param header, 2:no packed */ kfree(pmlmepriv->wps_beacon_ie); pmlmepriv->wps_beacon_ie = NULL; @@ -2654,7 +2654,7 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return -EINVAL; - ie_len = len-12-2;/* 12 = param header, 2:no packed */ + ie_len = len - 12 - 2; /* 12 = param header, 2:no packed */ kfree(pmlmepriv->wps_probe_resp_ie); pmlmepriv->wps_probe_resp_ie = NULL; @@ -2683,7 +2683,7 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return -EINVAL; - ie_len = len-12-2;/* 12 = param header, 2:no packed */ + ie_len = len - 12 - 2; /* 12 = param header, 2:no packed */ kfree(pmlmepriv->wps_assoc_resp_ie); pmlmepriv->wps_assoc_resp_ie = NULL; @@ -3014,7 +3014,7 @@ int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ret = rtw_hostapd_ioctl(dev, &wrq->u.data); break; #endif /* CONFIG_88EU_AP_MODE */ - case (SIOCDEVPRIVATE+1): + case (SIOCDEVPRIVATE + 1): ret = rtw_android_priv_cmd(dev, rq, cmd); break; default: -- cgit v1.2.3-58-ga151 From 8c97f42ca2093e3b6bb50b572247cd299624ae1d Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 29 Jun 2020 19:14:03 +0200 Subject: staging: rtl8188eu: remove some ieee80211 constants from wifi.h The constants IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL and IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA are not used in the driver code and, if ever needed, available from 'include/linux/ieee80211.h'. Remove them from wifi.h. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200629171405.7711-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/wifi.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h index 667055796b66..e12e3d0a45e0 100644 --- a/drivers/staging/rtl8188eu/include/wifi.h +++ b/drivers/staging/rtl8188eu/include/wifi.h @@ -453,10 +453,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) Below is the definition for 802.11n ------------------------------------------------------------------------------*/ -/* 802.11 BAR control masks */ -#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000 -#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004 - /** * struct rtw_ieee80211_ht_cap - HT additional information * -- cgit v1.2.3-58-ga151 From 07795b9afd124b9075367f8cfb9fa581270ae5d5 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 29 Jun 2020 19:14:04 +0200 Subject: staging: rtl8723bs: remove some ieee80211 constants from wifi.h The constants IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL and IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA are not used in the driver code and, if ever needed, available from 'include/linux/ieee80211.h'. Remove them from wifi.h. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200629171405.7711-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/wifi.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 88a6e982ce01..f75df547a946 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -657,11 +657,6 @@ struct rtw_ieee80211_bar { __le16 start_seq_num; } __attribute__((packed)); -/* 802.11 BAR control masks */ -#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000 -#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004 - - /** * struct rtw_ieee80211_ht_cap - HT capabilities * -- cgit v1.2.3-58-ga151 From 24fe73106234903d70e7362f62fb6a5f737f3d81 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 29 Jun 2020 19:14:05 +0200 Subject: staging: rtl8712: remove some ieee80211 constants from wifi.h The constants IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL and IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA are not used in the driver code and, if ever needed, available from 'include/linux/ieee80211.h'. Remove them from wifi.h. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200629171405.7711-3-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/wifi.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/wifi.h b/drivers/staging/rtl8712/wifi.h index befb2f9b40ad..66e0634f07ba 100644 --- a/drivers/staging/rtl8712/wifi.h +++ b/drivers/staging/rtl8712/wifi.h @@ -451,10 +451,6 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe) #define GetOrderBit(pbuf) (((*(__le16 *)(pbuf)) & \ le16_to_cpu(_ORDER_)) != 0) -/* 802.11 BAR control masks */ -#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000 -#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004 - /* * struct rtl_ieee80211_ht_cap - HT capabilities * -- cgit v1.2.3-58-ga151 From c2532bebba0bb6106e7074f4b127c70d6305f710 Mon Sep 17 00:00:00 2001 From: Brooke Basile Date: Mon, 29 Jun 2020 13:37:11 -0400 Subject: staging: rtl8188eu: Replace function name with __func__ Fix the following checkpatch warning: WARNING: Prefer using '"%s...", __func__' to using 'rtw_get_bcn_info', this function's name, in a string Signed-off-by: Brooke Basile Link: https://lore.kernel.org/r/20200629173711.5158-1-brookebasile@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index 3316059238e0..b80273611fb8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -987,10 +987,10 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) if (bencrypt) pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WEP; } - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: pnetwork->encryp_protocol is %x\n", - pnetwork->BcnInfo.encryp_protocol)); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: pnetwork->encryp_protocol is %x\n", - pnetwork->BcnInfo.encryp_protocol)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s: pnetwork->encryp_protocol is %x\n", + __func__, pnetwork->BcnInfo.encryp_protocol)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s: pnetwork->encryp_protocol is %x\n", + __func__, pnetwork->BcnInfo.encryp_protocol)); rtw_get_cipher_info(pnetwork); /* get bwmode and ch_offset */ -- cgit v1.2.3-58-ga151 From 0a0a66c984b383af3d0943edd3887dd7634e208e Mon Sep 17 00:00:00 2001 From: David Gow Date: Mon, 29 Jun 2020 21:45:17 -0700 Subject: clk: staging: Specify IOMEM dependency for Xilinx Clocking Wizard driver The Xilinx Clocking Wizard driver uses the devm_ioremap_resource function, but does not specify a dependency on IOMEM in Kconfig. This causes a build failure on architectures without IOMEM, for example, UML (notably with make allyesconfig). Fix this by making CONFIG_COMMON_CLK_XLNX_CLKWZRD depend on CONFIG_IOMEM. Signed-off-by: David Gow Link: https://lore.kernel.org/r/20200630044518.1084468-1-davidgow@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/clocking-wizard/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/clocking-wizard/Kconfig b/drivers/staging/clocking-wizard/Kconfig index 04be22dca9b6..69cf51445f08 100644 --- a/drivers/staging/clocking-wizard/Kconfig +++ b/drivers/staging/clocking-wizard/Kconfig @@ -5,6 +5,6 @@ config COMMON_CLK_XLNX_CLKWZRD tristate "Xilinx Clocking Wizard" - depends on COMMON_CLK && OF + depends on COMMON_CLK && OF && IOMEM help Support for the Xilinx Clocking Wizard IP core clock generator. -- cgit v1.2.3-58-ga151 From f9b468a3bd173ad3627ed99c6ba01eae0046c9be Mon Sep 17 00:00:00 2001 From: Diego Bienz Date: Tue, 30 Jun 2020 13:33:24 +0200 Subject: staging: qlge: qlge.h: remove unnecessary spaces Spaces aren't necessary before function pointer arguments. Signed-off-by: Diego Bienz Link: https://lore.kernel.org/r/20200630113324.GA10534@diegob-nb Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index fc8c5ca8935d..05e4f47442a3 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -2057,8 +2057,8 @@ enum { }; struct nic_operations { - int (*get_flash) (struct ql_adapter *); - int (*port_initialize) (struct ql_adapter *); + int (*get_flash)(struct ql_adapter *); + int (*port_initialize)(struct ql_adapter *); }; /* -- cgit v1.2.3-58-ga151 From 63ed1e0287abcac9003e7b122badf546d66c9383 Mon Sep 17 00:00:00 2001 From: Souptick Joarder Date: Wed, 1 Jul 2020 11:47:41 +0530 Subject: staging: kpc2000: kpc_dma: Unpin partial pinned pages There is a bug, when get_user_pages() failed but partially pinned pages are not unpinned and positive numbers are returned instead of -ERRNO. Fixed it. Also, int is more appropriate type for rv. Changed it. Signed-off-by: Souptick Joarder Cc: John Hubbard Cc: Dan Carpenter Cc: Bharath Vedartham Link: https://lore.kernel.org/r/1593584264-16982-2-git-send-email-jrdr.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/fileops.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index 89753463e926..becdb41595ed 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -35,7 +35,7 @@ static int kpc_dma_transfer(struct dev_private_data *priv, unsigned long iov_base, size_t iov_len) { unsigned int i = 0; - long rv = 0; + int rv = 0; struct kpc_dma_device *ldev; struct aio_cb_data *acd; DECLARE_COMPLETION_ONSTACK(done); @@ -79,14 +79,14 @@ static int kpc_dma_transfer(struct dev_private_data *priv, rv = get_user_pages(iov_base, acd->page_count, FOLL_TOUCH | FOLL_WRITE | FOLL_GET, acd->user_pages, NULL); mmap_read_unlock(current->mm); /* release the semaphore */ if (rv != acd->page_count) { - dev_err(&priv->ldev->pldev->dev, "Couldn't get_user_pages (%ld)\n", rv); + dev_err(&priv->ldev->pldev->dev, "Couldn't get_user_pages (%d)\n", rv); goto err_get_user_pages; } // Allocate and setup the sg_table (scatterlist entries) rv = sg_alloc_table_from_pages(&acd->sgt, acd->user_pages, acd->page_count, iov_base & (PAGE_SIZE - 1), iov_len, GFP_KERNEL); if (rv) { - dev_err(&priv->ldev->pldev->dev, "Couldn't alloc sg_table (%ld)\n", rv); + dev_err(&priv->ldev->pldev->dev, "Couldn't alloc sg_table (%d)\n", rv); goto err_alloc_sg_table; } @@ -193,10 +193,15 @@ static int kpc_dma_transfer(struct dev_private_data *priv, put_page(acd->user_pages[i]); err_get_user_pages: + if (rv > 0) { + for (i = 0; i < rv; i++) + put_pages(acd->user_pages[i]); + rv = -EFAULT; + } kfree(acd->user_pages); err_alloc_userpages: kfree(acd); - dev_dbg(&priv->ldev->pldev->dev, "%s returning with error %ld\n", __func__, rv); + dev_dbg(&priv->ldev->pldev->dev, "%s returning with error %d\n", __func__, rv); return rv; } -- cgit v1.2.3-58-ga151 From b6d13bd9f2c189c7a18bb5c8233078149496837f Mon Sep 17 00:00:00 2001 From: Souptick Joarder Date: Wed, 1 Jul 2020 11:47:42 +0530 Subject: staging: kpc2000: kpc_dma: Convert set_page_dirty() --> set_page_dirty_lock() First, convert set_page_dirty() to set_page_dirty_lock() Second, there is an interval in there after set_page_dirty() and before put_page(), in which the device could be running and setting pages dirty. Moving set_page_dirty_lock() after dma_unmap_sg(). Signed-off-by: Souptick Joarder Suggested-by: John Hubbard Cc: John Hubbard Cc: Bharath Vedartham Cc: Dan Carpenter Link: https://lore.kernel.org/r/1593584264-16982-3-git-send-email-jrdr.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/fileops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index becdb41595ed..08d90a64f9c8 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -215,13 +215,13 @@ void transfer_complete_cb(struct aio_cb_data *acd, size_t xfr_count, u32 flags) BUG_ON(!acd->ldev); BUG_ON(!acd->ldev->pldev); + dma_unmap_sg(&acd->ldev->pldev->dev, acd->sgt.sgl, acd->sgt.nents, acd->ldev->dir); + for (i = 0 ; i < acd->page_count ; i++) { if (!PageReserved(acd->user_pages[i])) - set_page_dirty(acd->user_pages[i]); + set_page_dirty_lock(acd->user_pages[i]); } - dma_unmap_sg(&acd->ldev->pldev->dev, acd->sgt.sgl, acd->sgt.nents, acd->ldev->dir); - for (i = 0 ; i < acd->page_count ; i++) put_page(acd->user_pages[i]); -- cgit v1.2.3-58-ga151 From ab7abbcac07e8d040514e0bd93e9ead30ca3a114 Mon Sep 17 00:00:00 2001 From: Souptick Joarder Date: Wed, 1 Jul 2020 11:47:43 +0530 Subject: staging: kpc2000: kpc_dma: Convert get_user_pages() --> pin_user_pages() In 2019, we introduced pin_user_pages*() and now we are converting get_user_pages*() to the new API as appropriate. [1] & [2] could be referred for more information. This is case 2 as per document [1]. [1] Documentation/core-api/pin_user_pages.rst [2] "Explicit pinning of user-space pages": https://lwn.net/Articles/807108/ Signed-off-by: Souptick Joarder Cc: John Hubbard Cc: Bharath Vedartham Cc: Dan Carpenter Link: https://lore.kernel.org/r/1593584264-16982-4-git-send-email-jrdr.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/fileops.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index 08d90a64f9c8..8cd20adea91c 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -76,10 +76,10 @@ static int kpc_dma_transfer(struct dev_private_data *priv, // Lock the user buffer pages in memory, and hold on to the page pointers (for the sglist) mmap_read_lock(current->mm); /* get memory map semaphore */ - rv = get_user_pages(iov_base, acd->page_count, FOLL_TOUCH | FOLL_WRITE | FOLL_GET, acd->user_pages, NULL); + rv = pin_user_pages(iov_base, acd->page_count, FOLL_TOUCH | FOLL_WRITE, acd->user_pages, NULL); mmap_read_unlock(current->mm); /* release the semaphore */ if (rv != acd->page_count) { - dev_err(&priv->ldev->pldev->dev, "Couldn't get_user_pages (%d)\n", rv); + dev_err(&priv->ldev->pldev->dev, "Couldn't pin_user_pages (%d)\n", rv); goto err_get_user_pages; } @@ -189,13 +189,11 @@ static int kpc_dma_transfer(struct dev_private_data *priv, sg_free_table(&acd->sgt); err_dma_map_sg: err_alloc_sg_table: - for (i = 0 ; i < acd->page_count ; i++) - put_page(acd->user_pages[i]); + unpin_user_pages(acd->user_pages, acd->page_count); err_get_user_pages: if (rv > 0) { - for (i = 0; i < rv; i++) - put_pages(acd->user_pages[i]); + unpin_user_pages(acd->user_pages, rv); rv = -EFAULT; } kfree(acd->user_pages); @@ -222,8 +220,7 @@ void transfer_complete_cb(struct aio_cb_data *acd, size_t xfr_count, u32 flags) set_page_dirty_lock(acd->user_pages[i]); } - for (i = 0 ; i < acd->page_count ; i++) - put_page(acd->user_pages[i]); + unpin_user_pages(acd->user_pages, acd->page_count); sg_free_table(&acd->sgt); -- cgit v1.2.3-58-ga151 From 95154990a7ae05cef093459b0dd038f12dcd7034 Mon Sep 17 00:00:00 2001 From: Souptick Joarder Date: Wed, 1 Jul 2020 11:47:44 +0530 Subject: staging: kpc2000: kpc_dma: Remove additional goto statements As 3 goto level referring to same common code, those can be accomodated with a single goto level and renameing it to unpin_pages. Set the -ERRNO when returning partial mapped pages in more appropriate place. When dma_map_sg() failed, the previously allocated memory was not freed properly. This is corrected now. Signed-off-by: Souptick Joarder Cc: John Hubbard Cc: Bharath Vedartham Cc: Dan Carpenter Link: https://lore.kernel.org/r/1593584264-16982-5-git-send-email-jrdr.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/fileops.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index 8cd20adea91c..dd716edd9b1b 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -35,7 +35,7 @@ static int kpc_dma_transfer(struct dev_private_data *priv, unsigned long iov_base, size_t iov_len) { unsigned int i = 0; - int rv = 0; + int rv = 0, nr_pages = 0; struct kpc_dma_device *ldev; struct aio_cb_data *acd; DECLARE_COMPLETION_ONSTACK(done); @@ -79,22 +79,27 @@ static int kpc_dma_transfer(struct dev_private_data *priv, rv = pin_user_pages(iov_base, acd->page_count, FOLL_TOUCH | FOLL_WRITE, acd->user_pages, NULL); mmap_read_unlock(current->mm); /* release the semaphore */ if (rv != acd->page_count) { + nr_pages = rv; + if (rv > 0) + rv = -EFAULT; + dev_err(&priv->ldev->pldev->dev, "Couldn't pin_user_pages (%d)\n", rv); - goto err_get_user_pages; + goto unpin_pages; } + nr_pages = acd->page_count; // Allocate and setup the sg_table (scatterlist entries) rv = sg_alloc_table_from_pages(&acd->sgt, acd->user_pages, acd->page_count, iov_base & (PAGE_SIZE - 1), iov_len, GFP_KERNEL); if (rv) { dev_err(&priv->ldev->pldev->dev, "Couldn't alloc sg_table (%d)\n", rv); - goto err_alloc_sg_table; + goto unpin_pages; } // Setup the DMA mapping for all the sg entries acd->mapped_entry_count = dma_map_sg(&ldev->pldev->dev, acd->sgt.sgl, acd->sgt.nents, ldev->dir); if (acd->mapped_entry_count <= 0) { dev_err(&priv->ldev->pldev->dev, "Couldn't dma_map_sg (%d)\n", acd->mapped_entry_count); - goto err_dma_map_sg; + goto free_table; } // Calculate how many descriptors are actually needed for this transfer. @@ -186,16 +191,12 @@ static int kpc_dma_transfer(struct dev_private_data *priv, err_descr_too_many: unlock_engine(ldev); dma_unmap_sg(&ldev->pldev->dev, acd->sgt.sgl, acd->sgt.nents, ldev->dir); + free_table: sg_free_table(&acd->sgt); - err_dma_map_sg: - err_alloc_sg_table: - unpin_user_pages(acd->user_pages, acd->page_count); - err_get_user_pages: - if (rv > 0) { - unpin_user_pages(acd->user_pages, rv); - rv = -EFAULT; - } + unpin_pages: + if (nr_pages > 0) + unpin_user_pages(acd->user_pages, nr_pages); kfree(acd->user_pages); err_alloc_userpages: kfree(acd); -- cgit v1.2.3-58-ga151 From 481e5397f5e4b070b45e0b31e0c0cec96bf9bb87 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Mon, 29 Jun 2020 17:08:59 +0200 Subject: staging: mmal-vchiq: Make timeout a defined parameter The timeout period for VPU communications is a useful thing to extend when debugging. Set it via a define, rather than a magic number buried in the code. Signed-off-by: Dave Stevenson Signed-off-by: Jacopo Mondi Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-2-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index cbe262b111fe..ebe7fb078830 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -38,6 +38,12 @@ */ #define VCHIQ_MMAL_MAX_COMPONENTS 64 +/* + * Timeout for synchronous msg responses in seconds. + * Helpful to increase this if stopping in the VPU debugger. + */ +#define SYNC_MSG_TIMEOUT 3 + /*#define FULL_MSG_DUMP 1*/ #ifdef DEBUG @@ -686,7 +692,7 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, } timeout = wait_for_completion_timeout(&msg_context->u.sync.cmplt, - 3 * HZ); + SYNC_MSG_TIMEOUT * HZ); if (timeout == 0) { pr_err("timed out waiting for sync completion\n"); ret = -ETIME; -- cgit v1.2.3-58-ga151 From 959fc47c53a31409eccd6d28024567aa7931f6de Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Mon, 29 Jun 2020 17:09:00 +0200 Subject: staging: mmal-vchiq: Make a mmal_buf struct for passing parameters The callback from vchi_mmal to the client was growing lots of extra parameters. Consolidate them into a single struct instead of growing the list further. The struct is associated with the client buffer, therefore there are various changes to setup various containers for the struct, and pass the appropriate members. Signed-off-by: Dave Stevenson Signed-off-by: Jacopo Mondi Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-3-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/bcm2835-camera.c | 64 +++++++++++++--------- .../staging/vc04_services/vchiq-mmal/mmal-common.h | 5 ++ .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 29 +++++++--- .../staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 3 +- 4 files changed, 65 insertions(+), 36 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 4f1adddb804f..73b2354a6bb7 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -75,6 +75,12 @@ static const struct v4l2_fract tpf_max = {.numerator = 1, .denominator = FPS_MIN}, tpf_default = {.numerator = 1000, .denominator = 30000}; +/* Container for MMAL and VB2 buffers*/ +struct vb2_mmal_buffer { + struct vb2_v4l2_buffer vb; + struct mmal_buffer mmal; +}; + /* video formats */ static struct mmal_fmt formats[] = { { @@ -261,14 +267,15 @@ static int buffer_init(struct vb2_buffer *vb) { struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vb->vb2_queue); struct vb2_v4l2_buffer *vb2 = to_vb2_v4l2_buffer(vb); - struct mmal_buffer *buf = container_of(vb2, struct mmal_buffer, vb); + struct vb2_mmal_buffer *buf = + container_of(vb2, struct vb2_mmal_buffer, vb); v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p, vb %p\n", __func__, dev, vb); - buf->buffer = vb2_plane_vaddr(&buf->vb.vb2_buf, 0); - buf->buffer_size = vb2_plane_size(&buf->vb.vb2_buf, 0); + buf->mmal.buffer = vb2_plane_vaddr(&buf->vb.vb2_buf, 0); + buf->mmal.buffer_size = vb2_plane_size(&buf->vb.vb2_buf, 0); - return mmal_vchi_buffer_init(dev->instance, buf); + return mmal_vchi_buffer_init(dev->instance, &buf->mmal); } static int buffer_prepare(struct vb2_buffer *vb) @@ -297,11 +304,13 @@ static void buffer_cleanup(struct vb2_buffer *vb) { struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vb->vb2_queue); struct vb2_v4l2_buffer *vb2 = to_vb2_v4l2_buffer(vb); - struct mmal_buffer *buf = container_of(vb2, struct mmal_buffer, vb); + struct vb2_mmal_buffer *buf = + container_of(vb2, struct vb2_mmal_buffer, vb); v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p, vb %p\n", __func__, dev, vb); - mmal_vchi_buffer_cleanup(buf); + + mmal_vchi_buffer_cleanup(&buf->mmal); } static inline bool is_capturing(struct bm2835_mmal_dev *dev) @@ -313,14 +322,16 @@ static inline bool is_capturing(struct bm2835_mmal_dev *dev) static void buffer_cb(struct vchiq_mmal_instance *instance, struct vchiq_mmal_port *port, int status, - struct mmal_buffer *buf, - unsigned long length, u32 mmal_flags, s64 dts, s64 pts) + struct mmal_buffer *mmal_buf) { struct bm2835_mmal_dev *dev = port->cb_ctx; + struct vb2_mmal_buffer *buf = + container_of(mmal_buf, struct vb2_mmal_buffer, mmal); v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: status:%d, buf:%p, length:%lu, flags %u, pts %lld\n", - __func__, status, buf, length, mmal_flags, pts); + __func__, status, buf, mmal_buf->length, mmal_buf->mmal_flags, + mmal_buf->pts); if (status) { /* error in transfer */ @@ -331,7 +342,7 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, return; } - if (length == 0) { + if (mmal_buf->length == 0) { /* stream ended */ if (dev->capture.frame_count) { /* empty buffer whilst capturing - expected to be an @@ -347,7 +358,8 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, &dev->capture.frame_count, sizeof(dev->capture.frame_count)); } - if (vchiq_mmal_submit_buffer(instance, port, buf)) + if (vchiq_mmal_submit_buffer(instance, port, + &buf->mmal)) v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "Failed to return EOS buffer"); } else { @@ -367,16 +379,16 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, return; } - if (dev->capture.vc_start_timestamp != -1 && pts) { + if (dev->capture.vc_start_timestamp != -1 && mmal_buf->pts) { ktime_t timestamp; - s64 runtime_us = pts - dev->capture.vc_start_timestamp; - + s64 runtime_us = mmal_buf->pts - + dev->capture.vc_start_timestamp; timestamp = ktime_add_us(dev->capture.kernel_start_ts, runtime_us); v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "Convert start time %llu and %llu with offset %llu to %llu\n", ktime_to_ns(dev->capture.kernel_start_ts), - dev->capture.vc_start_timestamp, pts, + dev->capture.vc_start_timestamp, mmal_buf->pts, ktime_to_ns(timestamp)); buf->vb.vb2_buf.timestamp = ktime_to_ns(timestamp); } else { @@ -385,13 +397,13 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, buf->vb.sequence = dev->capture.sequence++; buf->vb.field = V4L2_FIELD_NONE; - vb2_set_plane_payload(&buf->vb.vb2_buf, 0, length); - if (mmal_flags & MMAL_BUFFER_HEADER_FLAG_KEYFRAME) + vb2_set_plane_payload(&buf->vb.vb2_buf, 0, mmal_buf->length); + if (mmal_buf->mmal_flags & MMAL_BUFFER_HEADER_FLAG_KEYFRAME) buf->vb.flags |= V4L2_BUF_FLAG_KEYFRAME; vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); - if (mmal_flags & MMAL_BUFFER_HEADER_FLAG_EOS && + if (mmal_buf->mmal_flags & MMAL_BUFFER_HEADER_FLAG_EOS && is_capturing(dev)) { v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "Grab another frame as buffer has EOS"); @@ -472,14 +484,16 @@ static void buffer_queue(struct vb2_buffer *vb) { struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vb->vb2_queue); struct vb2_v4l2_buffer *vb2 = to_vb2_v4l2_buffer(vb); - struct mmal_buffer *buf = container_of(vb2, struct mmal_buffer, vb); + struct vb2_mmal_buffer *buf = + container_of(vb2, struct vb2_mmal_buffer, vb); int ret; v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p buf:%p, idx %u\n", __func__, dev, buf, vb2->vb2_buf.index); - ret = vchiq_mmal_submit_buffer(dev->instance, dev->capture.port, buf); + ret = vchiq_mmal_submit_buffer(dev->instance, dev->capture.port, + &buf->mmal); if (ret < 0) v4l2_err(&dev->v4l2_dev, "%s: error submitting buffer\n", __func__); @@ -592,7 +606,7 @@ static void stop_streaming(struct vb2_queue *vq) dev->capture.frame_count = 0; /* ensure a format has actually been set */ - if (!dev->capture.port) { + if (!port) { v4l2_err(&dev->v4l2_dev, "no capture port - stream not started?\n"); return; @@ -612,11 +626,11 @@ static void stop_streaming(struct vb2_queue *vq) /* disable the connection from camera to encoder */ ret = vchiq_mmal_port_disable(dev->instance, dev->capture.camera_port); - if (!ret && dev->capture.camera_port != dev->capture.port) { + if (!ret && dev->capture.camera_port != port) { v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "disabling port\n"); - ret = vchiq_mmal_port_disable(dev->instance, dev->capture.port); - } else if (dev->capture.camera_port != dev->capture.port) { + ret = vchiq_mmal_port_disable(dev->instance, port); + } else if (dev->capture.camera_port != port) { v4l2_err(&dev->v4l2_dev, "port_disable failed, error %d\n", ret); } @@ -1916,7 +1930,7 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ; q->drv_priv = dev; - q->buf_struct_size = sizeof(struct mmal_buffer); + q->buf_struct_size = sizeof(struct vb2_mmal_buffer); q->ops = &bm2835_mmal_video_qops; q->mem_ops = &vb2_vmalloc_memops; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h index ce88fac7c24b..5bd7410a034a 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-common.h @@ -49,6 +49,11 @@ struct mmal_buffer { unsigned long buffer_size; /* size of allocated buffer */ struct mmal_msg_context *msg_context; + + unsigned long length; + u32 mmal_flags; + s64 dts; + s64 pts; }; /* */ diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index ebe7fb078830..6404d4e60350 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -253,17 +253,25 @@ static void buffer_work_cb(struct work_struct *work) { struct mmal_msg_context *msg_context = container_of(work, struct mmal_msg_context, u.bulk.work); + struct mmal_buffer *buffer = msg_context->u.bulk.buffer; + + if (!buffer) { + pr_err("%s: ctx: %p, No mmal buffer to pass details\n", + __func__, msg_context); + return; + } + + buffer->length = msg_context->u.bulk.buffer_used; + buffer->mmal_flags = msg_context->u.bulk.mmal_flags; + buffer->dts = msg_context->u.bulk.dts; + buffer->pts = msg_context->u.bulk.pts; atomic_dec(&msg_context->u.bulk.port->buffers_with_vpu); msg_context->u.bulk.port->buffer_cb(msg_context->u.bulk.instance, msg_context->u.bulk.port, msg_context->u.bulk.status, - msg_context->u.bulk.buffer, - msg_context->u.bulk.buffer_used, - msg_context->u.bulk.mmal_flags, - msg_context->u.bulk.dts, - msg_context->u.bulk.pts); + msg_context->u.bulk.buffer); } /* workqueue scheduled callback to handle receiving buffers @@ -1321,11 +1329,14 @@ static int port_disable(struct vchiq_mmal_instance *instance, mmalbuf = list_entry(buf_head, struct mmal_buffer, list); list_del(buf_head); - if (port->buffer_cb) + if (port->buffer_cb) { + mmalbuf->length = 0; + mmalbuf->mmal_flags = 0; + mmalbuf->dts = MMAL_TIME_UNKNOWN; + mmalbuf->pts = MMAL_TIME_UNKNOWN; port->buffer_cb(instance, - port, 0, mmalbuf, 0, 0, - MMAL_TIME_UNKNOWN, - MMAL_TIME_UNKNOWN); + port, 0, mmalbuf); + } } spin_unlock_irqrestore(&port->slock, flags); diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h index 4e34728d87e5..cca7289761c2 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h @@ -44,8 +44,7 @@ struct vchiq_mmal_port; typedef void (*vchiq_mmal_buffer_cb)( struct vchiq_mmal_instance *instance, struct vchiq_mmal_port *port, - int status, struct mmal_buffer *buffer, - unsigned long length, u32 mmal_flags, s64 dts, s64 pts); + int status, struct mmal_buffer *buffer); struct vchiq_mmal_port { u32 enabled:1; -- cgit v1.2.3-58-ga151 From 4a38e55089b918e5b60210b26e68841d91df46e9 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Mon, 29 Jun 2020 17:09:01 +0200 Subject: staging: mmal-vchiq: Fixup vchiq-mmal include ordering There were dependencies on including the headers in the correct order. Fix up the headers so that they include the other headers that they depend on themselves. Signed-off-by: Dave Stevenson Signed-off-by: Jacopo Mondi Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-4-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h | 1 + drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 1 + 2 files changed, 2 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h index 43cc59316f90..91f9b400d8dc 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h @@ -38,6 +38,7 @@ #include "mmal-msg-common.h" #include "mmal-msg-format.h" #include "mmal-msg-port.h" +#include "mmal-vchiq.h" enum mmal_msg_type { MMAL_MSG_TYPE_QUIT = 1, diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h index cca7289761c2..df608585063b 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h @@ -16,6 +16,7 @@ #ifndef MMAL_VCHIQ_H #define MMAL_VCHIQ_H +#include "mmal-common.h" #include "mmal-msg-format.h" #define MAX_PORT_COUNT 4 -- cgit v1.2.3-58-ga151 From 22e64b486adc4785542f8002c3af4c895490f841 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Mon, 29 Jun 2020 17:09:02 +0200 Subject: staging: mmal-vchiq: Fix client_component for 64 bit kernel The MMAL client_component field is used with the event mechanism to allow the client to identify the component for which the event is generated. The field is only 32bits in size, therefore we can't use a pointer to the component in a 64 bit kernel. Component handles are already held in an array per VCHI instance, so use the array index as the client_component handle to avoid having to create a new IDR for this purpose. Signed-off-by: Dave Stevenson Signed-off-by: Jacopo Mondi Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-5-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 8 +++++++- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 6404d4e60350..3bc04f2ea53a 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -943,7 +943,7 @@ static int create_component(struct vchiq_mmal_instance *instance, /* build component create message */ m.h.type = MMAL_MSG_TYPE_COMPONENT_CREATE; - m.u.component_create.client_component = (u32)(unsigned long)component; + m.u.component_create.client_component = component->client_component; strncpy(m.u.component_create.name, name, sizeof(m.u.component_create.name)); @@ -1662,6 +1662,12 @@ int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance, goto unlock; } + /* We need a handle to reference back to our component structure. + * Use the array index in instance->component rather than rolling + * another IDR. + */ + component->client_component = idx; + ret = create_component(instance, component, name); if (ret < 0) { pr_err("%s: failed to create component %d (Not enough GPU mem?)\n", diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h index df608585063b..1dc81ecf9268 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h @@ -92,6 +92,7 @@ struct vchiq_mmal_component { struct vchiq_mmal_port input[MAX_PORT_COUNT]; /* input ports */ struct vchiq_mmal_port output[MAX_PORT_COUNT]; /* output ports */ struct vchiq_mmal_port clock[MAX_PORT_COUNT]; /* clock ports */ + u32 client_component; /* Used to ref back to client struct */ }; int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance); -- cgit v1.2.3-58-ga151 From 20e006b89856b7e8c1f7c4083a9a5a1a73c78097 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Mon, 29 Jun 2020 17:09:03 +0200 Subject: staging: mmal-vchiq: Always return the param size from param_get mmal-vchiq is a reimplementation of the userland library for MMAL. When getting a parameter, the client provides the storage and the size of the storage. The VPU then returns the size of the parameter that it wished to return, and as much as possible of that parameter is returned to the client. The implementation previously only returned the size provided by the VPU should it exceed the buffer size. So for parameters such as the supported encodings list the client had no idea how much of the provided storage had been populated. Signed-off-by: Dave Stevenson Signed-off-by: Jacopo Mondi Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-6-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 3bc04f2ea53a..efdf30b9edf9 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -1282,11 +1282,12 @@ static int port_parameter_get(struct vchiq_mmal_instance *instance, */ memcpy(value, &rmsg->u.port_parameter_get_reply.value, *value_size); - *value_size = rmsg->u.port_parameter_get_reply.size; } else { memcpy(value, &rmsg->u.port_parameter_get_reply.value, rmsg->u.port_parameter_get_reply.size); } + /* Always report the size of the returned parameter to the caller */ + *value_size = rmsg->u.port_parameter_get_reply.size; pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n", __func__, ret, port->component->handle, port->handle, parameter_id); -- cgit v1.2.3-58-ga151 From 7c71d489bd70263a34db5c7006b46bebab11413d Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Mon, 29 Jun 2020 17:09:04 +0200 Subject: staging: mmal-vchiq: If the VPU returns an error, don't negate it There is an enum for the errors that the VPU can return. port_parameter_get was negating that value, but also using -EINVAL from the Linux error codes. Pass the VPU error code as positive values. Should the function need to pass a Linux failure, then return that as negative. Signed-off-by: Dave Stevenson Signed-off-by: Jacopo Mondi Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-7-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index efdf30b9edf9..7fb502f90a89 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -1270,7 +1270,8 @@ static int port_parameter_get(struct vchiq_mmal_instance *instance, goto release_msg; } - ret = -rmsg->u.port_parameter_get_reply.status; + ret = rmsg->u.port_parameter_get_reply.status; + /* port_parameter_get_reply.size includes the header, * whilst *value_size doesn't. */ -- cgit v1.2.3-58-ga151 From 3dad90c53215bb6f0ceeff9b244303067ad47e63 Mon Sep 17 00:00:00 2001 From: Naushir Patuck Date: Mon, 29 Jun 2020 17:09:05 +0200 Subject: staging: mmal-vchiq: Fix formatting errors in mmal_parameters.h No functional changes in this commit. - Remove erroneous whitespace. - Remove _t postfix label on structs and enums. Signed-off-by: Naushir Patuck Signed-off-by: Jacopo Mondi Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-8-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/bcm2835-camera.c | 2 +- .../vc04_services/vchiq-mmal/mmal-parameters.h | 32 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 73b2354a6bb7..df90c1f9d148 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -1497,7 +1497,7 @@ static int get_num_cameras(struct vchiq_mmal_instance *instance, { int ret; struct vchiq_mmal_component *cam_info_component; - struct mmal_parameter_camera_info_t cam_info = {0}; + struct mmal_parameter_camera_info cam_info = {0}; u32 param_size = sizeof(cam_info); int i; diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h index f4ac5a6149ea..a1e39b1b1701 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h @@ -23,21 +23,21 @@ #define MMAL_PARAMETERS_H /** Common parameter ID group, used with many types of component. */ -#define MMAL_PARAMETER_GROUP_COMMON (0 << 16) +#define MMAL_PARAMETER_GROUP_COMMON (0 << 16) /** Camera-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_CAMERA (1 << 16) +#define MMAL_PARAMETER_GROUP_CAMERA (1 << 16) /** Video-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_VIDEO (2 << 16) +#define MMAL_PARAMETER_GROUP_VIDEO (2 << 16) /** Audio-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_AUDIO (3 << 16) +#define MMAL_PARAMETER_GROUP_AUDIO (3 << 16) /** Clock-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_CLOCK (4 << 16) +#define MMAL_PARAMETER_GROUP_CLOCK (4 << 16) /** Miracast-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_MIRACAST (5 << 16) +#define MMAL_PARAMETER_GROUP_MIRACAST (5 << 16) /* Common parameters */ enum mmal_parameter_common_type { - /**< Never a valid parameter ID */ + /**< Never a valid parameter ID */ MMAL_PARAMETER_UNUSED = MMAL_PARAMETER_GROUP_COMMON, /**< MMAL_PARAMETER_ENCODING_T */ @@ -341,7 +341,7 @@ enum mmal_parameter_imagefx { MMAL_PARAM_IMAGEFX_CARTOON, }; -enum MMAL_PARAM_FLICKERAVOID_T { +enum MMAL_PARAM_FLICKERAVOID { MMAL_PARAM_FLICKERAVOID_OFF, MMAL_PARAM_FLICKERAVOID_AUTO, MMAL_PARAM_FLICKERAVOID_50HZ, @@ -723,7 +723,7 @@ struct mmal_parameter_imagefx_parameters { #define MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES 2 #define MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN 16 -struct mmal_parameter_camera_info_camera_t { +struct mmal_parameter_camera_info_camera { u32 port_id; u32 max_width; u32 max_height; @@ -731,7 +731,7 @@ struct mmal_parameter_camera_info_camera_t { u8 camera_name[MMAL_PARAMETER_CAMERA_INFO_MAX_STR_LEN]; }; -enum mmal_parameter_camera_info_flash_type_t { +enum mmal_parameter_camera_info_flash_type { /* Make values explicit to ensure they match values in config ini */ MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_XENON = 0, MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_LED = 1, @@ -739,16 +739,16 @@ enum mmal_parameter_camera_info_flash_type_t { MMAL_PARAMETER_CAMERA_INFO_FLASH_TYPE_MAX = 0x7FFFFFFF }; -struct mmal_parameter_camera_info_flash_t { - enum mmal_parameter_camera_info_flash_type_t flash_type; +struct mmal_parameter_camera_info_flash { + enum mmal_parameter_camera_info_flash_type flash_type; }; -struct mmal_parameter_camera_info_t { +struct mmal_parameter_camera_info { u32 num_cameras; u32 num_flashes; - struct mmal_parameter_camera_info_camera_t - cameras[MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS]; - struct mmal_parameter_camera_info_flash_t + struct mmal_parameter_camera_info_camera + cameras[MMAL_PARAMETER_CAMERA_INFO_MAX_CAMERAS]; + struct mmal_parameter_camera_info_flash flashes[MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES]; }; -- cgit v1.2.3-58-ga151 From 5d9272e28a9a6117fb63f5f930991304765caa32 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Mon, 29 Jun 2020 17:09:06 +0200 Subject: staging: vchiq_arm: Add a matching unregister call All the registered children of vchiq have a corresponding call to platform_device_unregister except bcm2835_audio. Fix that. Fixes: 25c7597af20d ("staging: vchiq_arm: Register a platform device for audio") Signed-off-by: Phil Elwell Signed-off-by: Jacopo Mondi Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-9-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 28ea8c3a4cba..355590f1e130 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -2805,6 +2805,7 @@ failed_platform_init: static int vchiq_remove(struct platform_device *pdev) { + platform_device_unregister(bcm2835_audio); platform_device_unregister(bcm2835_camera); vchiq_debugfs_deinit(); device_destroy(vchiq_class, vchiq_devid); -- cgit v1.2.3-58-ga151 From af22fd658ad5ab952e5ae7a49714456fc75f370c Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:07 +0200 Subject: staging: vchi: Get rid of all useless callback reasons They are neither produced nor expected, so just delete them. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-10-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchi/vchi_common.h | 40 ++-------------------- 1 file changed, 3 insertions(+), 37 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_common.h b/drivers/staging/vc04_services/interface/vchi/vchi_common.h index 7fc04e38936d..0f79bea4757d 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_common.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_common.h @@ -31,8 +31,6 @@ enum vchi_crc_control { //callback reasons when an event occurs on a service enum vchi_callback_reason { - VCHI_CALLBACK_REASON_MIN, - /* * This indicates that there is data available handle is the msg id that * was transmitted with the data @@ -41,44 +39,12 @@ enum vchi_callback_reason { * Tasks get kicked by the callback, reset their event and try and read * from the fifo until it fails */ + VCHI_CALLBACK_SERVICE_CLOSED, VCHI_CALLBACK_MSG_AVAILABLE, - VCHI_CALLBACK_MSG_SENT, - VCHI_CALLBACK_MSG_SPACE_AVAILABLE, // XXX not yet implemented - - // This indicates that a transfer from the other side has completed - VCHI_CALLBACK_BULK_RECEIVED, - //This indicates that data queued up to be sent has now gone - //handle is the msg id that was used when sending the data VCHI_CALLBACK_BULK_SENT, - VCHI_CALLBACK_BULK_RX_SPACE_AVAILABLE, // XXX not yet implemented - VCHI_CALLBACK_BULK_TX_SPACE_AVAILABLE, // XXX not yet implemented - - VCHI_CALLBACK_SERVICE_CLOSED, - - /* - * this side has sent XOFF to peer due to lack of data consumption by - * service (suggests the service may need to take some recovery action - * if it has been deliberately holding off consuming data) - */ - VCHI_CALLBACK_SENT_XOFF, - VCHI_CALLBACK_SENT_XON, - - // indicates that a bulk transfer has finished reading the source buffer - VCHI_CALLBACK_BULK_DATA_READ, - - // power notification events (currently host side only) - VCHI_CALLBACK_PEER_OFF, - VCHI_CALLBACK_PEER_SUSPENDED, - VCHI_CALLBACK_PEER_ON, - VCHI_CALLBACK_PEER_RESUMED, - VCHI_CALLBACK_FORCED_POWER_OFF, - - // some extra notifications provided by vchiq_arm - VCHI_CALLBACK_SERVICE_OPENED, - VCHI_CALLBACK_BULK_RECEIVE_ABORTED, + VCHI_CALLBACK_BULK_RECEIVED, VCHI_CALLBACK_BULK_TRANSMIT_ABORTED, - - VCHI_CALLBACK_REASON_MAX + VCHI_CALLBACK_BULK_RECEIVE_ABORTED, }; // service control options -- cgit v1.2.3-58-ga151 From b5f1547b6e3bddbbac263a1c7adfb51427a57a2c Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:08 +0200 Subject: staging: vchi: Get rid of vchi_msg_peek() There already is a function that covers most of the functionality vchi_msg_peek() provides: vchi_msg_hold(). The main difference being that the later removes the message from vchu's queue while the other does it later on, while releasing the message. There are no users of this function that can't be trivially converted to vchi_msg_hold(). So, for the sake of removing duplicate code, get rid of vchi_msg_peek(). Note that the opposite change could be performed as well. But vchi_msg_peek()'s implementation was deemed less robust as messages have to be released in order. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-11-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchi/vchi.h | 12 ---- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 64 ---------------------- .../vc04_services/interface/vchiq_arm/vchiq_util.c | 12 ---- .../vc04_services/interface/vchiq_arm/vchiq_util.h | 1 - 4 files changed, 89 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 1a981e98e82b..1daef5ad70f1 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -103,18 +103,6 @@ extern int32_t vchi_msg_dequeue(struct vchi_service_handle *handle, uint32_t *actual_msg_size, enum vchi_flags flags); -// Routine to look at a message in place. -// The message is not dequeued, so a subsequent call to peek or dequeue -// will return the same message. -extern int32_t vchi_msg_peek(struct vchi_service_handle *handle, - void **data, - uint32_t *msg_size, - enum vchi_flags flags); - -// Routine to remove a message after it has been read in place with peek -// The first message on the queue is dequeued. -extern int32_t vchi_msg_remove(struct vchi_service_handle *handle); - // Routine to look at a message in place. // The message is dequeued, so the caller is left holding it; the descriptor is // filled in and must be released when the user has finished with the message. diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 75d87b6992c4..54c2492b7c83 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -18,70 +18,6 @@ struct shim_service { void *callback_param; }; -/*********************************************************** - * Name: vchi_msg_peek - * - * Arguments: struct vchi_service_handle *handle, - * void **data, - * uint32_t *msg_size, - - * enum vchi_flags flags - * - * Description: Routine to return a pointer to the current message (to allow in - * place processing). The message can be removed using - * vchi_msg_remove when you're finished - * - * Returns: int32_t - success == 0 - * - ***********************************************************/ -int32_t vchi_msg_peek(struct vchi_service_handle *handle, - void **data, - uint32_t *msg_size, - enum vchi_flags flags) -{ - struct shim_service *service = (struct shim_service *)handle; - struct vchiq_header *header; - - WARN_ON((flags != VCHI_FLAGS_NONE) && - (flags != VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE)); - - if (flags == VCHI_FLAGS_NONE) - if (vchiu_queue_is_empty(&service->queue)) - return -1; - - header = vchiu_queue_peek(&service->queue); - - *data = header->data; - *msg_size = header->size; - - return 0; -} -EXPORT_SYMBOL(vchi_msg_peek); - -/*********************************************************** - * Name: vchi_msg_remove - * - * Arguments: struct vchi_service_handle *handle, - * - * Description: Routine to remove a message (after it has been read with - * vchi_msg_peek) - * - * Returns: int32_t - success == 0 - * - ***********************************************************/ -int32_t vchi_msg_remove(struct vchi_service_handle *handle) -{ - struct shim_service *service = (struct shim_service *)handle; - struct vchiq_header *header; - - header = vchiu_queue_pop(&service->queue); - - vchiq_release_message(service->handle, header); - - return 0; -} -EXPORT_SYMBOL(vchi_msg_remove); - int vchi_queue_kernel_message(struct vchi_service_handle *handle, void *data, unsigned int size) { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c index 644844d88fed..c1c81f9ab9e6 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c @@ -55,18 +55,6 @@ void vchiu_queue_push(struct vchiu_queue *queue, struct vchiq_header *header) complete(&queue->push); } -struct vchiq_header *vchiu_queue_peek(struct vchiu_queue *queue) -{ - while (queue->write == queue->read) { - if (wait_for_completion_interruptible(&queue->push)) - flush_signals(current); - } - - complete(&queue->push); // We haven't removed anything from the queue. - - return queue->storage[queue->read & (queue->size - 1)]; -} - struct vchiq_header *vchiu_queue_pop(struct vchiu_queue *queue) { struct vchiq_header *header; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h index f03a4250de0d..1c90a8da1a92 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h @@ -44,7 +44,6 @@ extern int vchiu_queue_is_empty(struct vchiu_queue *queue); extern void vchiu_queue_push(struct vchiu_queue *queue, struct vchiq_header *header); -extern struct vchiq_header *vchiu_queue_peek(struct vchiu_queue *queue); extern struct vchiq_header *vchiu_queue_pop(struct vchiu_queue *queue); #endif -- cgit v1.2.3-58-ga151 From a7983fd9462560884056a91a7ffa346eeb9eb421 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:09 +0200 Subject: staging: vchi: Get rid of struct vchi_instance_handle The idea behind this was to create an opaque handle to struct vchiq_instance. This can be achieved without creating a new type by means of a forward declaration of struct vchiq_instance. This saves us from a lot of useless casting and overall simplifies code. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-12-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 20 +++++++-------- .../staging/vc04_services/bcm2835-audio/bcm2835.h | 2 +- .../staging/vc04_services/interface/vchi/vchi.h | 12 ++++----- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 30 +++++++--------------- .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 8 +++--- 5 files changed, 30 insertions(+), 42 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 73144f1ce45e..8c9390153a26 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -122,7 +122,7 @@ static void audio_vchi_callback(void *param, } static int -vc_vchi_audio_init(struct vchi_instance_handle *vchi_instance, +vc_vchi_audio_init(struct vchiq_instance *vchiq_instance, struct bcm2835_audio_instance *instance) { struct service_creation params = { @@ -134,7 +134,7 @@ vc_vchi_audio_init(struct vchi_instance_handle *vchi_instance, int status; /* Open the VCHI service connections */ - status = vchi_service_open(vchi_instance, ¶ms, + status = vchi_service_open(vchiq_instance, ¶ms, &instance->vchi_handle); if (status) { @@ -173,20 +173,20 @@ int bcm2835_new_vchi_ctx(struct device *dev, struct bcm2835_vchi_ctx *vchi_ctx) int ret; /* Initialize and create a VCHI connection */ - ret = vchi_initialise(&vchi_ctx->vchi_instance); + ret = vchi_initialise(&vchi_ctx->instance); if (ret) { dev_err(dev, "failed to initialise VCHI instance (ret=%d)\n", ret); return -EIO; } - ret = vchi_connect(vchi_ctx->vchi_instance); + ret = vchi_connect(vchi_ctx->instance); if (ret) { dev_dbg(dev, "failed to connect VCHI instance (ret=%d)\n", ret); - kfree(vchi_ctx->vchi_instance); - vchi_ctx->vchi_instance = NULL; + kfree(vchi_ctx->instance); + vchi_ctx->instance = NULL; return -EIO; } @@ -196,10 +196,10 @@ int bcm2835_new_vchi_ctx(struct device *dev, struct bcm2835_vchi_ctx *vchi_ctx) void bcm2835_free_vchi_ctx(struct bcm2835_vchi_ctx *vchi_ctx) { - /* Close the VCHI connection - it will also free vchi_instance */ - WARN_ON(vchi_disconnect(vchi_ctx->vchi_instance)); + /* Close the VCHI connection - it will also free vchi_ctx->instance */ + WARN_ON(vchi_disconnect(vchi_ctx->instance)); - vchi_ctx->vchi_instance = NULL; + vchi_ctx->instance = NULL; } int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) @@ -217,7 +217,7 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) instance->alsa_stream = alsa_stream; alsa_stream->instance = instance; - err = vc_vchi_audio_init(vchi_ctx->vchi_instance, + err = vc_vchi_audio_init(vchi_ctx->instance, instance); if (err < 0) goto free_instance; diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h index d2fe8d36ab7d..2a94e825194f 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h @@ -44,7 +44,7 @@ enum snd_bcm2835_ctrl { }; struct bcm2835_vchi_ctx { - struct vchi_instance_handle *vchi_instance; + struct vchiq_instance *instance; }; /* definition of the chip-specific record */ diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 1daef5ad70f1..6b73d8fb394a 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -49,8 +49,8 @@ struct service_creation { void *callback_param; }; -// Opaque handle for a VCHI instance -struct vchi_instance_handle; +// Opaque handle for a VCHIQ instance +struct vchiq_instance; // Opaque handle for a server or client struct vchi_service_handle; @@ -61,19 +61,19 @@ struct vchi_service_handle; *****************************************************************************/ // Routine used to initialise the vchi on both local + remote connections -extern int32_t vchi_initialise(struct vchi_instance_handle **instance_handle); +extern int32_t vchi_initialise(struct vchiq_instance **instance); -extern int32_t vchi_connect(struct vchi_instance_handle *instance_handle); +extern int32_t vchi_connect(struct vchiq_instance *instance); //When this is called, ensure that all services have no data pending. //Bulk transfers can remain 'queued' -extern int32_t vchi_disconnect(struct vchi_instance_handle *instance_handle); +extern int32_t vchi_disconnect(struct vchiq_instance *instance); /****************************************************************************** * Global service API *****************************************************************************/ // Routine to open a named service -extern int32_t vchi_service_open(struct vchi_instance_handle *instance_handle, +extern int32_t vchi_service_open(struct vchiq_instance *instance, struct service_creation *setup, struct vchi_service_handle **handle); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 54c2492b7c83..8758704d61c9 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -287,7 +287,7 @@ EXPORT_SYMBOL(vchi_msg_hold); /*********************************************************** * Name: vchi_initialise * - * Arguments: struct vchi_instance_handle **instance_handle + * Arguments: struct vchiq_instance **instance * * Description: Initialises the hardware but does not transmit anything * When run as a Host App this will be called twice hence the need @@ -297,23 +297,16 @@ EXPORT_SYMBOL(vchi_msg_hold); * ***********************************************************/ -int32_t vchi_initialise(struct vchi_instance_handle **instance_handle) +int32_t vchi_initialise(struct vchiq_instance **instance) { - struct vchiq_instance *instance; - enum vchiq_status status; - - status = vchiq_initialise(&instance); - - *instance_handle = (struct vchi_instance_handle *)instance; - - return status; + return vchiq_initialise(instance); } EXPORT_SYMBOL(vchi_initialise); /*********************************************************** * Name: vchi_connect * - * Arguments: struct vchi_instance_handle *instance_handle + * Arguments: struct vchiq_instance *instance * * Description: Starts the command service on each connection, * causing INIT messages to be pinged back and forth @@ -321,10 +314,8 @@ EXPORT_SYMBOL(vchi_initialise); * Returns: 0 if successful, failure otherwise * ***********************************************************/ -int32_t vchi_connect(struct vchi_instance_handle *instance_handle) +int32_t vchi_connect(struct vchiq_instance *instance) { - struct vchiq_instance *instance = (struct vchiq_instance *)instance_handle; - return vchiq_connect(instance); } EXPORT_SYMBOL(vchi_connect); @@ -332,7 +323,7 @@ EXPORT_SYMBOL(vchi_connect); /*********************************************************** * Name: vchi_disconnect * - * Arguments: struct vchi_instance_handle *instance_handle + * Arguments: struct vchiq_instance *instance * * Description: Stops the command service on each connection, * causing DE-INIT messages to be pinged back and forth @@ -340,10 +331,8 @@ EXPORT_SYMBOL(vchi_connect); * Returns: 0 if successful, failure otherwise * ***********************************************************/ -int32_t vchi_disconnect(struct vchi_instance_handle *instance_handle) +int32_t vchi_disconnect(struct vchiq_instance *instance) { - struct vchiq_instance *instance = (struct vchiq_instance *)instance_handle; - return vchiq_shutdown(instance); } EXPORT_SYMBOL(vchi_disconnect); @@ -352,7 +341,7 @@ EXPORT_SYMBOL(vchi_disconnect); * Name: vchi_service_open * Name: vchi_service_create * - * Arguments: struct vchi_instance_handle *instance_handle + * Arguments: struct vchiq_instance *instance * struct service_creation *setup, * struct vchi_service_handle **handle * @@ -446,11 +435,10 @@ static void service_free(struct shim_service *service) } } -int32_t vchi_service_open(struct vchi_instance_handle *instance_handle, +int32_t vchi_service_open(struct vchiq_instance *instance, struct service_creation *setup, struct vchi_service_handle **handle) { - struct vchiq_instance *instance = (struct vchiq_instance *)instance_handle; struct shim_service *service = service_alloc(instance, setup); *handle = (struct vchi_service_handle *)service; diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 7fb502f90a89..30f97c4bb9fc 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -1864,7 +1864,7 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) { int status; struct vchiq_mmal_instance *instance; - static struct vchi_instance_handle *vchi_instance; + static struct vchiq_instance *vchiq_instance; struct service_creation params = { .version = VCHI_VERSION_EX(VC_MMAL_VER, VC_MMAL_MIN_VER), .service_id = VC_MMAL_SERVER_NAME, @@ -1886,14 +1886,14 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) BUILD_BUG_ON(sizeof(struct mmal_port) != 64); /* create a vchi instance */ - status = vchi_initialise(&vchi_instance); + status = vchi_initialise(&vchiq_instance); if (status) { pr_err("Failed to initialise VCHI instance (status=%d)\n", status); return -EIO; } - status = vchi_connect(vchi_instance); + status = vchi_connect(vchiq_instance); if (status) { pr_err("Failed to connect VCHI instance (status=%d)\n", status); return -EIO; @@ -1918,7 +1918,7 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) if (!instance->bulk_wq) goto err_free; - status = vchi_service_open(vchi_instance, ¶ms, &instance->handle); + status = vchi_service_open(vchiq_instance, ¶ms, &instance->handle); if (status) { pr_err("Failed to open VCHI service connection (status=%d)\n", status); -- cgit v1.2.3-58-ga151 From 5a8e22e3d319ddae77c9fcce31ebc40577a32c6a Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:10 +0200 Subject: staging: vchi: Unify struct shim_service and struct vchi_service_handle The idea behind struct vchi_service_handle is to create an opaque handle to struct shim_service. This can be achieved by doing a forward declaration of struct shim_service, which will avoid unwarranted casts and pointer play. Ultimately as a rename is due all over the vchi user space, rename struct shim_service into struvt vchi_service, which is more consistent with the rest of the exposed API. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-13-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 24 ++++---- .../staging/vc04_services/interface/vchi/vchi.h | 27 ++++----- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 70 +++++++++------------- .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 34 +++++------ 4 files changed, 70 insertions(+), 85 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 8c9390153a26..62eef233275f 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -9,7 +9,7 @@ struct bcm2835_audio_instance { struct device *dev; - struct vchi_service_handle *vchi_handle; + struct vchi_service *service; struct completion msg_avail_comp; struct mutex vchi_mutex; struct bcm2835_alsa_stream *alsa_stream; @@ -25,12 +25,12 @@ MODULE_PARM_DESC(force_bulk, "Force use of vchiq bulk for audio"); static void bcm2835_audio_lock(struct bcm2835_audio_instance *instance) { mutex_lock(&instance->vchi_mutex); - vchi_service_use(instance->vchi_handle); + vchi_service_use(instance->service); } static void bcm2835_audio_unlock(struct bcm2835_audio_instance *instance) { - vchi_service_release(instance->vchi_handle); + vchi_service_release(instance->service); mutex_unlock(&instance->vchi_mutex); } @@ -44,7 +44,7 @@ static int bcm2835_audio_send_msg_locked(struct bcm2835_audio_instance *instance init_completion(&instance->msg_avail_comp); } - status = vchi_queue_kernel_message(instance->vchi_handle, + status = vchi_queue_kernel_message(instance->service, m, sizeof(*m)); if (status) { dev_err(instance->dev, @@ -101,7 +101,7 @@ static void audio_vchi_callback(void *param, if (reason != VCHI_CALLBACK_MSG_AVAILABLE) return; - status = vchi_msg_dequeue(instance->vchi_handle, + status = vchi_msg_dequeue(instance->service, &m, sizeof(m), &msg_len, VCHI_FLAGS_NONE); if (status) return; @@ -135,7 +135,7 @@ vc_vchi_audio_init(struct vchiq_instance *vchiq_instance, /* Open the VCHI service connections */ status = vchi_service_open(vchiq_instance, ¶ms, - &instance->vchi_handle); + &instance->service); if (status) { dev_err(instance->dev, @@ -145,7 +145,7 @@ vc_vchi_audio_init(struct vchiq_instance *vchiq_instance, } /* Finished with the service for now */ - vchi_service_release(instance->vchi_handle); + vchi_service_release(instance->service); return 0; } @@ -155,10 +155,10 @@ static void vc_vchi_audio_deinit(struct bcm2835_audio_instance *instance) int status; mutex_lock(&instance->vchi_mutex); - vchi_service_use(instance->vchi_handle); + vchi_service_use(instance->service); /* Close all VCHI service connections */ - status = vchi_service_close(instance->vchi_handle); + status = vchi_service_close(instance->service); if (status) { dev_err(instance->dev, "failed to close VCHI service connection (status=%d)\n", @@ -228,7 +228,7 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) goto deinit; bcm2835_audio_lock(instance); - vchi_get_peer_version(instance->vchi_handle, &instance->peer_version); + vchi_get_peer_version(instance->service, &instance->peer_version); bcm2835_audio_unlock(instance); if (instance->peer_version < 2 || force_bulk) instance->max_packet = 0; /* bulk transfer */ @@ -344,7 +344,7 @@ int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, count = size; if (!instance->max_packet) { /* Send the message to the videocore */ - status = vchi_bulk_queue_transmit(instance->vchi_handle, + status = vchi_bulk_queue_transmit(instance->service, src, count, VCHI_FLAGS_BLOCK_UNTIL_DATA_READ, NULL); @@ -352,7 +352,7 @@ int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, while (count > 0) { int bytes = min(instance->max_packet, count); - status = vchi_queue_kernel_message(instance->vchi_handle, + status = vchi_queue_kernel_message(instance->service, src, bytes); src += bytes; count -= bytes; diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 6b73d8fb394a..ff302e6b8b1b 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -53,7 +53,7 @@ struct service_creation { struct vchiq_instance; // Opaque handle for a server or client -struct vchi_service_handle; +struct vchi_service; /****************************************************************************** * Global funcs - implementation is specific to which side you are on @@ -75,30 +75,27 @@ extern int32_t vchi_disconnect(struct vchiq_instance *instance); // Routine to open a named service extern int32_t vchi_service_open(struct vchiq_instance *instance, struct service_creation *setup, - struct vchi_service_handle **handle); + struct vchi_service **service); -extern int32_t vchi_get_peer_version(const struct vchi_service_handle *handle, +extern int32_t vchi_get_peer_version(struct vchi_service *service, short *peer_version); // Routine to close a named service -extern int32_t vchi_service_close(const struct vchi_service_handle *handle); +extern int32_t vchi_service_close(struct vchi_service *service); // Routine to increment ref count on a named service -extern int32_t vchi_service_use(const struct vchi_service_handle *handle); +extern int32_t vchi_service_use(struct vchi_service *service); // Routine to decrement ref count on a named service -extern int32_t vchi_service_release(const struct vchi_service_handle *handle); +extern int32_t vchi_service_release(struct vchi_service *service); /* Routine to send a message from kernel memory across a service */ -extern int -vchi_queue_kernel_message(struct vchi_service_handle *handle, - void *data, - unsigned int size); +extern int vchi_queue_kernel_message(struct vchi_service *service, void *data, + unsigned int size); // Routine to receive a msg from a service // Dequeue is equivalent to hold, copy into client buffer, release -extern int32_t vchi_msg_dequeue(struct vchi_service_handle *handle, - void *data, +extern int32_t vchi_msg_dequeue(struct vchi_service *service, void *data, uint32_t max_data_size_to_read, uint32_t *actual_msg_size, enum vchi_flags flags); @@ -106,7 +103,7 @@ extern int32_t vchi_msg_dequeue(struct vchi_service_handle *handle, // Routine to look at a message in place. // The message is dequeued, so the caller is left holding it; the descriptor is // filled in and must be released when the user has finished with the message. -extern int32_t vchi_msg_hold(struct vchi_service_handle *handle, +extern int32_t vchi_msg_hold(struct vchi_service *service, void **data, // } may be NULL, as info can be uint32_t *msg_size, // } obtained from HELD_MSG_T enum vchi_flags flags, @@ -125,14 +122,14 @@ extern int32_t vchi_held_msg_release(struct vchi_held_msg *message); *****************************************************************************/ // Routine to prepare interface for a transfer from the other side -extern int32_t vchi_bulk_queue_receive(struct vchi_service_handle *handle, +extern int32_t vchi_bulk_queue_receive(struct vchi_service *service, void *data_dst, uint32_t data_size, enum vchi_flags flags, void *transfer_handle); // Routine to queue up data ready for transfer to the other (once they have signalled they are ready) -extern int32_t vchi_bulk_queue_transmit(struct vchi_service_handle *handle, +extern int32_t vchi_bulk_queue_transmit(struct vchi_service *service, const void *data_src, uint32_t data_size, enum vchi_flags flags, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 8758704d61c9..39502786b41c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -9,7 +9,7 @@ #include "vchiq_util.h" -struct shim_service { +struct vchi_service { unsigned int handle; struct vchiu_queue queue; @@ -18,10 +18,9 @@ struct shim_service { void *callback_param; }; -int vchi_queue_kernel_message(struct vchi_service_handle *handle, void *data, - unsigned int size) +int vchi_queue_kernel_message(struct vchi_service *service, void *data, + unsigned int size) { - struct shim_service *service = (struct shim_service *)handle; enum vchiq_status status; while (1) { @@ -57,11 +56,10 @@ EXPORT_SYMBOL(vchi_queue_kernel_message); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_bulk_queue_receive(struct vchi_service_handle *handle, void *data_dst, +int32_t vchi_bulk_queue_receive(struct vchi_service *service, void *data_dst, uint32_t data_size, enum vchi_flags flags, void *bulk_handle) { - struct shim_service *service = (struct shim_service *)handle; enum vchiq_bulk_mode mode; enum vchiq_status status; @@ -115,13 +113,12 @@ EXPORT_SYMBOL(vchi_bulk_queue_receive); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_bulk_queue_transmit(struct vchi_service_handle *handle, +int32_t vchi_bulk_queue_transmit(struct vchi_service *service, const void *data_src, uint32_t data_size, enum vchi_flags flags, void *bulk_handle) { - struct shim_service *service = (struct shim_service *)handle; enum vchiq_bulk_mode mode; enum vchiq_status status; @@ -166,7 +163,7 @@ EXPORT_SYMBOL(vchi_bulk_queue_transmit); /*********************************************************** * Name: vchi_msg_dequeue * - * Arguments: struct vchi_service_handle *handle, + * Arguments: struct vchi_service *service, * void *data, * uint32_t max_data_size_to_read, * uint32_t *actual_msg_size @@ -177,11 +174,10 @@ EXPORT_SYMBOL(vchi_bulk_queue_transmit); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_msg_dequeue(struct vchi_service_handle *handle, void *data, +int32_t vchi_msg_dequeue(struct vchi_service *service, void *data, uint32_t max_data_size_to_read, uint32_t *actual_msg_size, enum vchi_flags flags) { - struct shim_service *service = (struct shim_service *)handle; struct vchiq_header *header; WARN_ON((flags != VCHI_FLAGS_NONE) && @@ -235,7 +231,7 @@ EXPORT_SYMBOL(vchi_held_msg_release); /*********************************************************** * Name: vchi_msg_hold * - * Arguments: struct vchi_service_handle *handle, + * Arguments: struct vchi_service *service, * void **data, * uint32_t *msg_size, * enum vchi_flags flags, @@ -249,11 +245,10 @@ EXPORT_SYMBOL(vchi_held_msg_release); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_msg_hold(struct vchi_service_handle *handle, void **data, +int32_t vchi_msg_hold(struct vchi_service *service, void **data, uint32_t *msg_size, enum vchi_flags flags, struct vchi_held_msg *message_handle) { - struct shim_service *service = (struct shim_service *)handle; struct vchiq_header *header; WARN_ON((flags != VCHI_FLAGS_NONE) && @@ -343,7 +338,7 @@ EXPORT_SYMBOL(vchi_disconnect); * * Arguments: struct vchiq_instance *instance * struct service_creation *setup, - * struct vchi_service_handle **handle + * struct vchi_service **service * * Description: Routine to open a service * @@ -356,8 +351,8 @@ static enum vchiq_status shim_callback(enum vchiq_reason reason, unsigned int handle, void *bulk_user) { - struct shim_service *service = - (struct shim_service *)VCHIQ_GET_SERVICE_USERDATA(handle); + struct vchi_service *service = + (struct vchi_service *)VCHIQ_GET_SERVICE_USERDATA(handle); if (!service->callback) goto release; @@ -407,10 +402,10 @@ release: return VCHIQ_SUCCESS; } -static struct shim_service *service_alloc(struct vchiq_instance *instance, +static struct vchi_service *service_alloc(struct vchiq_instance *instance, struct service_creation *setup) { - struct shim_service *service = kzalloc(sizeof(struct shim_service), GFP_KERNEL); + struct vchi_service *service = kzalloc(sizeof(struct vchi_service), GFP_KERNEL); (void)instance; @@ -427,7 +422,7 @@ static struct shim_service *service_alloc(struct vchiq_instance *instance, return service; } -static void service_free(struct shim_service *service) +static void service_free(struct vchi_service *service) { if (service) { vchiu_queue_delete(&service->queue); @@ -437,40 +432,36 @@ static void service_free(struct shim_service *service) int32_t vchi_service_open(struct vchiq_instance *instance, struct service_creation *setup, - struct vchi_service_handle **handle) + struct vchi_service **service) { - struct shim_service *service = service_alloc(instance, setup); - *handle = (struct vchi_service_handle *)service; - - if (service) { + *service = service_alloc(instance, setup); + if (*service) { struct vchiq_service_params params; enum vchiq_status status; memset(¶ms, 0, sizeof(params)); params.fourcc = setup->service_id; params.callback = shim_callback; - params.userdata = service; + params.userdata = *service; params.version = setup->version.version; params.version_min = setup->version.version_min; status = vchiq_open_service(instance, ¶ms, - &service->handle); + &((*service)->handle)); if (status != VCHIQ_SUCCESS) { - service_free(service); - service = NULL; - *handle = NULL; + service_free(*service); + *service = NULL; } } - return service ? 0 : -1; + return *service ? 0 : -1; } EXPORT_SYMBOL(vchi_service_open); -int32_t vchi_service_close(const struct vchi_service_handle *handle) +int32_t vchi_service_close(struct vchi_service *service) { int32_t ret = -1; - struct shim_service *service = (struct shim_service *)handle; if (service) { enum vchiq_status status = vchiq_close_service(service->handle); @@ -483,10 +474,9 @@ int32_t vchi_service_close(const struct vchi_service_handle *handle) } EXPORT_SYMBOL(vchi_service_close); -int32_t vchi_get_peer_version(const struct vchi_service_handle *handle, short *peer_version) +int32_t vchi_get_peer_version(struct vchi_service *service, short *peer_version) { int32_t ret = -1; - struct shim_service *service = (struct shim_service *)handle; if (service) { enum vchiq_status status; @@ -501,18 +491,17 @@ EXPORT_SYMBOL(vchi_get_peer_version); /*********************************************************** * Name: vchi_service_use * - * Arguments: const struct vchi_service_handle *handle + * Arguments: struct vchi_service *service * * Description: Routine to increment refcount on a service * * Returns: void * ***********************************************************/ -int32_t vchi_service_use(const struct vchi_service_handle *handle) +int32_t vchi_service_use(struct vchi_service *service) { int32_t ret = -1; - struct shim_service *service = (struct shim_service *)handle; if (service) ret = vchiq_use_service(service->handle); return ret; @@ -522,18 +511,17 @@ EXPORT_SYMBOL(vchi_service_use); /*********************************************************** * Name: vchi_service_release * - * Arguments: const struct vchi_service_handle *handle + * Arguments: struct vchi_service *service * * Description: Routine to decrement refcount on a service * * Returns: void * ***********************************************************/ -int32_t vchi_service_release(const struct vchi_service_handle *handle) +int32_t vchi_service_release(struct vchi_service *service) { int32_t ret = -1; - struct shim_service *service = (struct shim_service *)handle; if (service) ret = vchiq_release_service(service->handle); return ret; diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 30f97c4bb9fc..05ac1739db5f 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -165,7 +165,7 @@ struct mmal_msg_context { }; struct vchiq_mmal_instance { - struct vchi_service_handle *handle; + struct vchi_service *service; /* ensure serialised access to service */ struct mutex vchiq_mutex; @@ -294,8 +294,8 @@ static void buffer_to_host_work_cb(struct work_struct *work) /* Dummy receive to ensure the buffers remain in order */ len = 8; /* queue the bulk submission */ - vchi_service_use(instance->handle); - ret = vchi_bulk_queue_receive(instance->handle, + vchi_service_use(instance->service); + ret = vchi_bulk_queue_receive(instance->service, msg_context->u.bulk.buffer->buffer, /* Actual receive needs to be a multiple * of 4 bytes @@ -305,7 +305,7 @@ static void buffer_to_host_work_cb(struct work_struct *work) VCHI_FLAGS_BLOCK_UNTIL_QUEUED, msg_context); - vchi_service_release(instance->handle); + vchi_service_release(instance->service); if (ret != 0) pr_err("%s: ctx: %p, vchi_bulk_queue_receive failed %d\n", @@ -384,7 +384,7 @@ buffer_from_host(struct vchiq_mmal_instance *instance, if (!port->enabled) return -EINVAL; - pr_debug("instance:%p buffer:%p\n", instance->handle, buf); + pr_debug("instance:%p buffer:%p\n", instance->service, buf); /* get context */ if (!buf->msg_context) { @@ -439,14 +439,14 @@ buffer_from_host(struct vchiq_mmal_instance *instance, /* no payload in message */ m.u.buffer_from_host.payload_in_message = 0; - vchi_service_use(instance->handle); + vchi_service_use(instance->service); - ret = vchi_queue_kernel_message(instance->handle, + ret = vchi_queue_kernel_message(instance->service, &m, sizeof(struct mmal_msg_header) + sizeof(m.u.buffer_from_host)); - vchi_service_release(instance->handle); + vchi_service_release(instance->service); return ret; } @@ -568,7 +568,7 @@ static void service_callback(void *param, switch (reason) { case VCHI_CALLBACK_MSG_AVAILABLE: - status = vchi_msg_hold(instance->handle, (void **)&msg, + status = vchi_msg_hold(instance->service, (void **)&msg, &msg_len, VCHI_FLAGS_NONE, &msg_handle); if (status) { pr_err("Unable to dequeue a message (%d)\n", status); @@ -684,14 +684,14 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, DBG_DUMP_MSG(msg, (sizeof(struct mmal_msg_header) + payload_len), ">>> sync message"); - vchi_service_use(instance->handle); + vchi_service_use(instance->service); - ret = vchi_queue_kernel_message(instance->handle, + ret = vchi_queue_kernel_message(instance->service, msg, sizeof(struct mmal_msg_header) + payload_len); - vchi_service_release(instance->handle); + vchi_service_release(instance->service); if (ret) { pr_err("error %d queuing message\n", ret); @@ -1839,9 +1839,9 @@ int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance) if (mutex_lock_interruptible(&instance->vchiq_mutex)) return -EINTR; - vchi_service_use(instance->handle); + vchi_service_use(instance->service); - status = vchi_service_close(instance->handle); + status = vchi_service_close(instance->service); if (status != 0) pr_err("mmal-vchiq: VCHIQ close failed\n"); @@ -1918,21 +1918,21 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) if (!instance->bulk_wq) goto err_free; - status = vchi_service_open(vchiq_instance, ¶ms, &instance->handle); + status = vchi_service_open(vchiq_instance, ¶ms, &instance->service); if (status) { pr_err("Failed to open VCHI service connection (status=%d)\n", status); goto err_close_services; } - vchi_service_release(instance->handle); + vchi_service_release(instance->service); *out_instance = instance; return 0; err_close_services: - vchi_service_close(instance->handle); + vchi_service_close(instance->service); destroy_workqueue(instance->bulk_wq); err_free: vfree(instance->bulk_scratch); -- cgit v1.2.3-58-ga151 From b74a8932dff818f5ff83101c8088a307a8f2eeda Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:11 +0200 Subject: staging: vc04_services: bcm2835-audio: Use vchi_msg_hold() vchi_msg_dequeue() provides the same functionality as vchi_msg_hold() except it copies the message data as opposed to the later which provides the data in place. The copying is done on a local variable, so there is no need to keep the message out the function's bounds, so use vchi_msg_hold() instead. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-14-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 25 ++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 62eef233275f..5018b5baa009 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -94,31 +94,34 @@ static void audio_vchi_callback(void *param, void *msg_handle) { struct bcm2835_audio_instance *instance = param; - struct vc_audio_msg m; - int msg_len; + struct vchi_held_msg handle; + struct vc_audio_msg *m; + unsigned size; int status; if (reason != VCHI_CALLBACK_MSG_AVAILABLE) return; - status = vchi_msg_dequeue(instance->service, - &m, sizeof(m), &msg_len, VCHI_FLAGS_NONE); + status = vchi_msg_hold(instance->service, (void **)&m, &size, + VCHI_FLAGS_NONE, &handle); if (status) return; - if (m.type == VC_AUDIO_MSG_TYPE_RESULT) { - instance->result = m.result.success; + if (m->type == VC_AUDIO_MSG_TYPE_RESULT) { + instance->result = m->result.success; complete(&instance->msg_avail_comp); - } else if (m.type == VC_AUDIO_MSG_TYPE_COMPLETE) { - if (m.complete.cookie1 != VC_AUDIO_WRITE_COOKIE1 || - m.complete.cookie2 != VC_AUDIO_WRITE_COOKIE2) + } else if (m->type == VC_AUDIO_MSG_TYPE_COMPLETE) { + if (m->complete.cookie1 != VC_AUDIO_WRITE_COOKIE1 || + m->complete.cookie2 != VC_AUDIO_WRITE_COOKIE2) dev_err(instance->dev, "invalid cookie\n"); else bcm2835_playback_fifo(instance->alsa_stream, - m.complete.count); + m->complete.count); } else { - dev_err(instance->dev, "unexpected callback type=%d\n", m.type); + dev_err(instance->dev, "unexpected callback type=%d\n", m->type); } + + vchi_held_msg_release(&handle); } static int -- cgit v1.2.3-58-ga151 From 6cdd7b79539280ff5b45759291ec88d2eb44280a Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:12 +0200 Subject: staging: vchi: Get rid of vchi_msg_dequeue() Nobody uses it. Get rid of it. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-15-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchi/vchi.h | 7 ---- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 39 ---------------------- 2 files changed, 46 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index ff302e6b8b1b..a369feb3a448 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -93,13 +93,6 @@ extern int32_t vchi_service_release(struct vchi_service *service); extern int vchi_queue_kernel_message(struct vchi_service *service, void *data, unsigned int size); -// Routine to receive a msg from a service -// Dequeue is equivalent to hold, copy into client buffer, release -extern int32_t vchi_msg_dequeue(struct vchi_service *service, void *data, - uint32_t max_data_size_to_read, - uint32_t *actual_msg_size, - enum vchi_flags flags); - // Routine to look at a message in place. // The message is dequeued, so the caller is left holding it; the descriptor is // filled in and must be released when the user has finished with the message. diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 39502786b41c..53e0357d4aba 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -160,45 +160,6 @@ int32_t vchi_bulk_queue_transmit(struct vchi_service *service, } EXPORT_SYMBOL(vchi_bulk_queue_transmit); -/*********************************************************** - * Name: vchi_msg_dequeue - * - * Arguments: struct vchi_service *service, - * void *data, - * uint32_t max_data_size_to_read, - * uint32_t *actual_msg_size - * enum vchi_flags flags - * - * Description: Routine to dequeue a message into the supplied buffer - * - * Returns: int32_t - success == 0 - * - ***********************************************************/ -int32_t vchi_msg_dequeue(struct vchi_service *service, void *data, - uint32_t max_data_size_to_read, - uint32_t *actual_msg_size, enum vchi_flags flags) -{ - struct vchiq_header *header; - - WARN_ON((flags != VCHI_FLAGS_NONE) && - (flags != VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE)); - - if (flags == VCHI_FLAGS_NONE) - if (vchiu_queue_is_empty(&service->queue)) - return -1; - - header = vchiu_queue_pop(&service->queue); - - memcpy(data, header->data, header->size < max_data_size_to_read ? - header->size : max_data_size_to_read); - - *actual_msg_size = header->size; - - vchiq_release_message(service->handle, header); - - return 0; -} -EXPORT_SYMBOL(vchi_msg_dequeue); /*********************************************************** * Name: vchi_held_msg_release -- cgit v1.2.3-58-ga151 From 09c0f0fc3f69a91940a7598153bd45ff7d9a70e3 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:13 +0200 Subject: staging: vchi_common: Get rid of all unused definitions There is a series of structures and enums defined but never used. Get rid of them. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-16-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchi/vchi_common.h | 65 ---------------------- 1 file changed, 65 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_common.h b/drivers/staging/vc04_services/interface/vchi/vchi_common.h index 0f79bea4757d..e07376fe4dfd 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_common.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_common.h @@ -10,23 +10,7 @@ enum vchi_flags { VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE = 0x1, // waits for message to be received, or sent (NB. not the same as being seen on other side) VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE = 0x2, // run a callback when message sent VCHI_FLAGS_BLOCK_UNTIL_QUEUED = 0x4, // return once the transfer is in a queue ready to go - VCHI_FLAGS_ALLOW_PARTIAL = 0x8, VCHI_FLAGS_BLOCK_UNTIL_DATA_READ = 0x10, - VCHI_FLAGS_CALLBACK_WHEN_DATA_READ = 0x20, - - VCHI_FLAGS_ALIGN_SLOT = 0x000080, // internal use only - VCHI_FLAGS_BULK_AUX_QUEUED = 0x010000, // internal use only - VCHI_FLAGS_BULK_AUX_COMPLETE = 0x020000, // internal use only - VCHI_FLAGS_BULK_DATA_QUEUED = 0x040000, // internal use only - VCHI_FLAGS_BULK_DATA_COMPLETE = 0x080000, // internal use only - VCHI_FLAGS_INTERNAL = 0xFF0000 -}; - -// constants for vchi_crc_control() -enum vchi_crc_control { - VCHI_CRC_NOTHING = -1, - VCHI_CRC_PER_SERVICE = 0, - VCHI_CRC_EVERYTHING = 1, }; //callback reasons when an event occurs on a service @@ -47,58 +31,9 @@ enum vchi_callback_reason { VCHI_CALLBACK_BULK_RECEIVE_ABORTED, }; -// service control options -enum vchi_service_option { - VCHI_SERVICE_OPTION_MIN, - - VCHI_SERVICE_OPTION_TRACE, - VCHI_SERVICE_OPTION_SYNCHRONOUS, - - VCHI_SERVICE_OPTION_MAX -}; - //Callback used by all services / bulk transfers typedef void (*vchi_callback)(void *callback_param, //my service local param enum vchi_callback_reason reason, void *handle); //for transmitting msg's only -/* - * Define vector struct for scatter-gather (vector) operations - * Vectors can be nested - if a vector element has negative length, then - * the data pointer is treated as pointing to another vector array, with - * '-vec_len' elements. Thus to append a header onto an existing vector, - * you can do this: - * - * void foo(const struct vchi_msg_vector *v, int n) - * { - * struct vchi_msg_vector nv[2]; - * nv[0].vec_base = my_header; - * nv[0].vec_len = sizeof my_header; - * nv[1].vec_base = v; - * nv[1].vec_len = -n; - * ... - * - */ -struct vchi_msg_vector { - const void *vec_base; - int32_t vec_len; -}; - -/* - * Iterator structure for reading ahead through received message queue. - * Allocated by client, initialised by vchi_msg_look_ahead. Fields are for - * internal VCHI use only. - * Iterates over messages in queue at the instant of the call to - * vchi_msg_lookahead - will not proceed to messages received since. - * Behaviour is undefined if an iterator is used again after messages for that - * service are removed/dequeued by any means other than vchi_msg_iter_... - * calls on the iterator itself. - */ -struct vchi_msg_iter { - struct opaque_vchi_service_t *service; - void *last; - void *next; - void *remove; -}; - #endif // VCHI_COMMON_H_ -- cgit v1.2.3-58-ga151 From 7bfb15ccb3632122c7fbfd310bab0a6cfb1bafe4 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:14 +0200 Subject: staging: vchi: Get rid of unnecessary defines Those defines aren't used by anyone. Get rid of them. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-17-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchi/vchi.h | 11 ----------- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 1 - 2 files changed, 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index a369feb3a448..bf0c7a496f5a 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -11,21 +11,10 @@ * Global defs *****************************************************************************/ -#define VCHI_BULK_ROUND_UP(x) ((((unsigned long)(x)) + VCHI_BULK_ALIGN - 1) & ~(VCHI_BULK_ALIGN - 1)) -#define VCHI_BULK_ROUND_DOWN(x) (((unsigned long)(x)) & ~(VCHI_BULK_ALIGN - 1)) -#define VCHI_BULK_ALIGN_NBYTES(x) (VCHI_BULK_ALIGNED(x) ? 0 : (VCHI_BULK_ALIGN - ((unsigned long)(x) & (VCHI_BULK_ALIGN - 1)))) - -#ifdef USE_VCHIQ_ARM -#define VCHI_BULK_ALIGNED(x) 1 -#else -#define VCHI_BULK_ALIGNED(x) (((unsigned long)(x) & (VCHI_BULK_ALIGN - 1)) == 0) -#endif - struct vchi_version { uint32_t version; uint32_t version_min; }; -#define VCHI_VERSION(v_) { v_, v_ } #define VCHI_VERSION_EX(v_, m_) { v_, m_ } // Macros to manipulate 'FOURCC' values diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 05ac1739db5f..075dcf4d6b3e 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -29,7 +29,6 @@ #include "mmal-vchiq.h" #include "mmal-msg.h" -#define USE_VCHIQ_ARM #include "interface/vchi/vchi.h" /* -- cgit v1.2.3-58-ga151 From 115588bf775d740a48988c6d84e88d3f249179f9 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:15 +0200 Subject: staging: vc04_services: Get rid of vchi_cfg.h Nothing in it is being used. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-18-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchi/vchi.h | 1 - .../vc04_services/interface/vchi/vchi_cfg.h | 238 --------------------- 2 files changed, 239 deletions(-) delete mode 100644 drivers/staging/vc04_services/interface/vchi/vchi_cfg.h (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index bf0c7a496f5a..55e51e5a1fdc 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -4,7 +4,6 @@ #ifndef VCHI_H_ #define VCHI_H_ -#include "vchi_cfg.h" #include "vchi_common.h" /****************************************************************************** diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h b/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h deleted file mode 100644 index 138c36151a22..000000000000 --- a/drivers/staging/vc04_services/interface/vchi/vchi_cfg.h +++ /dev/null @@ -1,238 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ - -#ifndef VCHI_CFG_H_ -#define VCHI_CFG_H_ - -/******************************************************************************* - * Defines in this first section are part of the VCHI API and may be examined by - * VCHI services. - ******************************************************************************/ - -/* - * Required alignment of base addresses for bulk transfer, if unaligned - * transfers are not enabled - * Really determined by the message driver, and should be available from - * a run-time call. - */ -#ifndef VCHI_BULK_ALIGN -# if __VCCOREVER__ >= 0x04000000 -# define VCHI_BULK_ALIGN 32 // Allows for the need to do cache cleans -# else -# define VCHI_BULK_ALIGN 16 -# endif -#endif - -/* - * Required length multiple for bulk transfers, if unaligned transfers are - * not enabled - * May be less than or greater than VCHI_BULK_ALIGN - * Really determined by the message driver, and should be available from - * a run-time call. - */ -#ifndef VCHI_BULK_GRANULARITY -# if __VCCOREVER__ >= 0x04000000 -# define VCHI_BULK_GRANULARITY 32 // Allows for the need to do cache cleans -# else -# define VCHI_BULK_GRANULARITY 16 -# endif -#endif - -/* The largest possible message to be queued with vchi_msg_queue. */ -#ifndef VCHI_MAX_MSG_SIZE -# if defined VCHI_LOCAL_HOST_PORT -# define VCHI_MAX_MSG_SIZE 16384 // makes file transfers fast, but should they be using bulk? -# else -# define VCHI_MAX_MSG_SIZE 4096 // NOTE: THIS MUST BE LARGER THAN OR EQUAL TO THE SIZE OF THE KHRONOS MERGE BUFFER!! -# endif -#endif - -/****************************************************************************** - * Defines below are system configuration options, and should not be used by - * VCHI services. - ******************************************************************************/ - -/* - * How many connections can we support? A localhost implementation uses - * 2 connections, 1 for host-app, 1 for VMCS, and these are hooked together - * by a loopback MPHI VCFW driver. - */ -#ifndef VCHI_MAX_NUM_CONNECTIONS -# define VCHI_MAX_NUM_CONNECTIONS 3 -#endif - -/* - * How many services can we open per connection? Extending this doesn't cost - * processing time, just a small amount of static memory. - */ -#ifndef VCHI_MAX_SERVICES_PER_CONNECTION -# define VCHI_MAX_SERVICES_PER_CONNECTION 36 -#endif - -/* Adjust if using a message driver that supports more logical TX channels */ -#ifndef VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION -# define VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION 9 // 1 MPHI + 8 CCP2 logical channels -#endif - -/* Adjust if using a message driver that supports more logical RX channels */ -#ifndef VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION -# define VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION 1 // 1 MPHI -#endif - -/* - * How many receive slots do we use. This times VCHI_MAX_MSG_SIZE gives the - * effective receive queue space, less message headers. - */ -#ifndef VCHI_NUM_READ_SLOTS -# if defined(VCHI_LOCAL_HOST_PORT) -# define VCHI_NUM_READ_SLOTS 4 -# else -# define VCHI_NUM_READ_SLOTS 48 -# endif -#endif - -/* - * Do we utilise overrun facility for receive message slots? Can aid peer - * transmit performance. Only define on VideoCore end, talking to host. - */ -//#define VCHI_MSG_RX_OVERRUN - -/* - * How many transmit slots do we use. Generally don't need many, - * as the hardware driver underneath VCHI will usually have its own buffering. - */ -#ifndef VCHI_NUM_WRITE_SLOTS -# define VCHI_NUM_WRITE_SLOTS 4 -#endif - -/* - * If a service has held or queued received messages in VCHI_XOFF_THRESHOLD or - * more slots, then it's taking up too much buffer space, - * and the peer service will be told to stop transmitting with an XOFF message. - * For this to be effective, the VCHI_NUM_READ_SLOTS needs to be considerably - * bigger than VCHI_NUM_WRITE_SLOTS, or the transmit latency is too high. - */ -#ifndef VCHI_XOFF_THRESHOLD -# define VCHI_XOFF_THRESHOLD (VCHI_NUM_READ_SLOTS / 2) -#endif - -/* - * After we've sent an XOFF, the peer will be told to resume transmission - * once the local service has dequeued/released enough messages that it's now - * occupying VCHI_XON_THRESHOLD slots or fewer. - */ -#ifndef VCHI_XON_THRESHOLD -# define VCHI_XON_THRESHOLD (VCHI_NUM_READ_SLOTS / 4) -#endif - -/* - * A size below which a bulk transfer omits the handshake completely and always - * goes via the message channel, if bulk auxiliary is being sent on that - * service. (The user can guarantee this by enabling unaligned transmits). - * Not API. - */ -#ifndef VCHI_MIN_BULK_SIZE -# define VCHI_MIN_BULK_SIZE (VCHI_MAX_MSG_SIZE / 2 < 4096 ? VCHI_MAX_MSG_SIZE / 2 : 4096) -#endif - -/* - * Maximum size of bulk transmission chunks, for each interface type. - * A trade-off between speed and latency; the smaller the chunk size the better - * change of messages and other bulk transmissions getting in when big bulk - * transfers are happening. Set to 0 to not break transmissions into chunks. - */ -#ifndef VCHI_MAX_BULK_CHUNK_SIZE_MPHI -# define VCHI_MAX_BULK_CHUNK_SIZE_MPHI (16 * 1024) -#endif - -/* - * NB Chunked CCP2 transmissions violate the letter of the CCP2 spec - * by using "JPEG8" mode with multiple-line frames. Only use if the receiver - * can cope. - */ -#ifndef VCHI_MAX_BULK_CHUNK_SIZE_CCP2 -# define VCHI_MAX_BULK_CHUNK_SIZE_CCP2 0 -#endif - -/* - * How many TX messages can we have pending in our transmit slots. - * Once exhausted, vchi_msg_queue will be blocked. - */ -#ifndef VCHI_TX_MSG_QUEUE_SIZE -# define VCHI_TX_MSG_QUEUE_SIZE 256 -#endif - -/* - * How many RX messages can we have parsed in the receive slots. Once exhausted, - * parsing will be suspended until older messages are dequeued/released. - */ -#ifndef VCHI_RX_MSG_QUEUE_SIZE -# define VCHI_RX_MSG_QUEUE_SIZE 256 -#endif - -/* - * Really should be able to cope if we run out of received message descriptors, - * by suspending parsing as the comment above says, but we don't. - * This sweeps the issue under the carpet. - */ -#if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE / 16 + 1) * VCHI_NUM_READ_SLOTS -# undef VCHI_RX_MSG_QUEUE_SIZE -# define VCHI_RX_MSG_QUEUE_SIZE ((VCHI_MAX_MSG_SIZE / 16 + 1) * VCHI_NUM_READ_SLOTS) -#endif - -/* - * How many bulk transmits can we have pending. Once exhausted, - * vchi_bulk_queue_transmit will be blocked. - */ -#ifndef VCHI_TX_BULK_QUEUE_SIZE -# define VCHI_TX_BULK_QUEUE_SIZE 64 -#endif - -/* - * How many bulk receives can we have pending. Once exhausted, - *vchi_bulk_queue_receive will be blocked. - */ -#ifndef VCHI_RX_BULK_QUEUE_SIZE -# define VCHI_RX_BULK_QUEUE_SIZE 64 -#endif - -/* - * A limit on how many outstanding bulk requests we expect the peer to give us. - * If the peer asks for more than this, VCHI will fail and assert. - * The number is determined by the peer's hardware - * - it's the number of outstanding requests that can be queued - * on all bulk channels. VC3's MPHI peripheral allows 16. - */ -#ifndef VCHI_MAX_PEER_BULK_REQUESTS -# define VCHI_MAX_PEER_BULK_REQUESTS 32 -#endif - -/* - * Define VCHI_CCP2TX_MANUAL_POWER if the host tells us when to turn the CCP2 - * transmitter on and off. - */ -/*#define VCHI_CCP2TX_MANUAL_POWER*/ - -#ifndef VCHI_CCP2TX_MANUAL_POWER - -/* - * Timeout (in milliseconds) for putting the CCP2TX interface into IDLE state. - * Set negative for no IDLE. - */ -# ifndef VCHI_CCP2TX_IDLE_TIMEOUT -# define VCHI_CCP2TX_IDLE_TIMEOUT 5 -# endif - -/* - * Timeout (in milliseconds) for putting the CCP2TX interface into OFF state. - * Set negative for no OFF. - */ -# ifndef VCHI_CCP2TX_OFF_TIMEOUT -# define VCHI_CCP2TX_OFF_TIMEOUT 1000 -# endif - -#endif /* VCHI_CCP2TX_MANUAL_POWER */ - -#endif /* VCHI_CFG_H_ */ - -/****************************** End of file **********************************/ -- cgit v1.2.3-58-ga151 From a24ac57ef860045cb36db5f6f67aeac931a25e16 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:16 +0200 Subject: staging: vchi: Get rid of flags argument in vchi_msg_hold() All users are ignoring the flags argument. So for the sake of simplicity delete it. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-19-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 3 +-- drivers/staging/vc04_services/interface/vchi/vchi.h | 1 - .../staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 12 +++--------- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 2 +- 4 files changed, 5 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 5018b5baa009..68119246f10b 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -102,8 +102,7 @@ static void audio_vchi_callback(void *param, if (reason != VCHI_CALLBACK_MSG_AVAILABLE) return; - status = vchi_msg_hold(instance->service, (void **)&m, &size, - VCHI_FLAGS_NONE, &handle); + status = vchi_msg_hold(instance->service, (void **)&m, &size, &handle); if (status) return; diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 55e51e5a1fdc..92ce811fc28d 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -87,7 +87,6 @@ extern int vchi_queue_kernel_message(struct vchi_service *service, void *data, extern int32_t vchi_msg_hold(struct vchi_service *service, void **data, // } may be NULL, as info can be uint32_t *msg_size, // } obtained from HELD_MSG_T - enum vchi_flags flags, struct vchi_held_msg *message_descriptor); /******************************************************************************* diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 53e0357d4aba..6c48d9ef45cb 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -195,7 +195,6 @@ EXPORT_SYMBOL(vchi_held_msg_release); * Arguments: struct vchi_service *service, * void **data, * uint32_t *msg_size, - * enum vchi_flags flags, * struct vchi_held_msg *message_handle * * Description: Routine to return a pointer to the current message (to allow @@ -207,17 +206,12 @@ EXPORT_SYMBOL(vchi_held_msg_release); * ***********************************************************/ int32_t vchi_msg_hold(struct vchi_service *service, void **data, - uint32_t *msg_size, enum vchi_flags flags, - struct vchi_held_msg *message_handle) + uint32_t *msg_size, struct vchi_held_msg *message_handle) { struct vchiq_header *header; - WARN_ON((flags != VCHI_FLAGS_NONE) && - (flags != VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE)); - - if (flags == VCHI_FLAGS_NONE) - if (vchiu_queue_is_empty(&service->queue)) - return -1; + if (vchiu_queue_is_empty(&service->queue)) + return -1; header = vchiu_queue_pop(&service->queue); diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 075dcf4d6b3e..b63d4f5bda1c 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -568,7 +568,7 @@ static void service_callback(void *param, switch (reason) { case VCHI_CALLBACK_MSG_AVAILABLE: status = vchi_msg_hold(instance->service, (void **)&msg, - &msg_len, VCHI_FLAGS_NONE, &msg_handle); + &msg_len, &msg_handle); if (status) { pr_err("Unable to dequeue a message (%d)\n", status); break; -- cgit v1.2.3-58-ga151 From 0abd7412e97008689a8b40e418ad37ab07feee6d Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:17 +0200 Subject: staging: vchi: Use enum vchiq_bulk_mode instead of vchi's transmission flags vchi has a set of transfer flags which almost map 1:1 to vchiq's own transfer modes. For the sake of simplicity let's use the later and delete vchi's. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-20-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 2 +- .../staging/vc04_services/bcm2835-audio/bcm2835.h | 1 + .../staging/vc04_services/interface/vchi/vchi.h | 4 +- .../vc04_services/interface/vchi/vchi_common.h | 9 ----- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 44 ++-------------------- .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 4 +- 6 files changed, 9 insertions(+), 55 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 68119246f10b..565853ec1e7a 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -348,7 +348,7 @@ int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, /* Send the message to the videocore */ status = vchi_bulk_queue_transmit(instance->service, src, count, - VCHI_FLAGS_BLOCK_UNTIL_DATA_READ, + VCHIQ_BULK_MODE_BLOCKING, NULL); } else { while (count > 0) { diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h index 2a94e825194f..7a0e4ab50fc7 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h @@ -9,6 +9,7 @@ #include #include #include +#include "interface/vchiq_arm/vchiq_if.h" #include "interface/vchi/vchi.h" #define MAX_SUBSTREAMS (8) diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 92ce811fc28d..9a74ca4e1062 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -105,14 +105,14 @@ extern int32_t vchi_held_msg_release(struct vchi_held_msg *message); extern int32_t vchi_bulk_queue_receive(struct vchi_service *service, void *data_dst, uint32_t data_size, - enum vchi_flags flags, + enum vchiq_bulk_mode mode, void *transfer_handle); // Routine to queue up data ready for transfer to the other (once they have signalled they are ready) extern int32_t vchi_bulk_queue_transmit(struct vchi_service *service, const void *data_src, uint32_t data_size, - enum vchi_flags flags, + enum vchiq_bulk_mode mode, void *transfer_handle); /****************************************************************************** diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_common.h b/drivers/staging/vc04_services/interface/vchi/vchi_common.h index e07376fe4dfd..52b447c19445 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_common.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_common.h @@ -4,15 +4,6 @@ #ifndef VCHI_COMMON_H_ #define VCHI_COMMON_H_ -//flags used when sending messages (must be bitmapped) -enum vchi_flags { - VCHI_FLAGS_NONE = 0x0, - VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE = 0x1, // waits for message to be received, or sent (NB. not the same as being seen on other side) - VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE = 0x2, // run a callback when message sent - VCHI_FLAGS_BLOCK_UNTIL_QUEUED = 0x4, // return once the transfer is in a queue ready to go - VCHI_FLAGS_BLOCK_UNTIL_DATA_READ = 0x10, -}; - //callback reasons when an event occurs on a service enum vchi_callback_reason { /* diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 6c48d9ef45cb..c6b14d31492b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -3,6 +3,7 @@ #include #include +#include "vchiq_if.h" #include "../vchi/vchi.h" #include "vchiq.h" #include "vchiq_core.h" @@ -57,30 +58,11 @@ EXPORT_SYMBOL(vchi_queue_kernel_message); * ***********************************************************/ int32_t vchi_bulk_queue_receive(struct vchi_service *service, void *data_dst, - uint32_t data_size, enum vchi_flags flags, + uint32_t data_size, enum vchiq_bulk_mode mode, void *bulk_handle) { - enum vchiq_bulk_mode mode; enum vchiq_status status; - switch ((int)flags) { - case VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE - | VCHI_FLAGS_BLOCK_UNTIL_QUEUED: - WARN_ON(!service->callback); - mode = VCHIQ_BULK_MODE_CALLBACK; - break; - case VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE: - mode = VCHIQ_BULK_MODE_BLOCKING; - break; - case VCHI_FLAGS_BLOCK_UNTIL_QUEUED: - case VCHI_FLAGS_NONE: - mode = VCHIQ_BULK_MODE_NOCALLBACK; - break; - default: - WARN(1, "unsupported message\n"); - return VCHIQ_ERROR; - } - while (1) { status = vchiq_bulk_receive(service->handle, data_dst, data_size, bulk_handle, mode); @@ -116,31 +98,11 @@ EXPORT_SYMBOL(vchi_bulk_queue_receive); int32_t vchi_bulk_queue_transmit(struct vchi_service *service, const void *data_src, uint32_t data_size, - enum vchi_flags flags, + enum vchiq_bulk_mode mode, void *bulk_handle) { - enum vchiq_bulk_mode mode; enum vchiq_status status; - switch ((int)flags) { - case VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE - | VCHI_FLAGS_BLOCK_UNTIL_QUEUED: - WARN_ON(!service->callback); - mode = VCHIQ_BULK_MODE_CALLBACK; - break; - case VCHI_FLAGS_BLOCK_UNTIL_DATA_READ: - case VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE: - mode = VCHIQ_BULK_MODE_BLOCKING; - break; - case VCHI_FLAGS_BLOCK_UNTIL_QUEUED: - case VCHI_FLAGS_NONE: - mode = VCHIQ_BULK_MODE_NOCALLBACK; - break; - default: - WARN(1, "unsupported message\n"); - return VCHIQ_ERROR; - } - while (1) { status = vchiq_bulk_transmit(service->handle, data_src, data_size, bulk_handle, mode); diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index b63d4f5bda1c..5c9fd354a7fe 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -29,6 +29,7 @@ #include "mmal-vchiq.h" #include "mmal-msg.h" +#include "interface/vchiq_arm/vchiq_if.h" #include "interface/vchi/vchi.h" /* @@ -300,8 +301,7 @@ static void buffer_to_host_work_cb(struct work_struct *work) * of 4 bytes */ (len + 3) & ~3, - VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE | - VCHI_FLAGS_BLOCK_UNTIL_QUEUED, + VCHIQ_BULK_MODE_CALLBACK, msg_context); vchi_service_release(instance->service); -- cgit v1.2.3-58-ga151 From 469fbb24ced37fa48a25c82da7b9744404f1cf0e Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:18 +0200 Subject: staging: vchi: Use vchiq's enum vchiq_reason enum vchi_callback_reason maps 1:1 to enum vchiq_reason, in an effort to simplify things, let's use the later, and get rid of the extra indirection. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-21-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 5 ++- .../vc04_services/interface/vchi/vchi_common.h | 20 +---------- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 40 ++-------------------- .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 11 +++--- 4 files changed, 10 insertions(+), 66 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 565853ec1e7a..0f97eda4ec90 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -89,8 +89,7 @@ static int bcm2835_audio_send_simple(struct bcm2835_audio_instance *instance, return bcm2835_audio_send_msg(instance, &m, wait); } -static void audio_vchi_callback(void *param, - const enum vchi_callback_reason reason, +static void audio_vchi_callback(void *param, const enum vchiq_reason reason, void *msg_handle) { struct bcm2835_audio_instance *instance = param; @@ -99,7 +98,7 @@ static void audio_vchi_callback(void *param, unsigned size; int status; - if (reason != VCHI_CALLBACK_MSG_AVAILABLE) + if (reason != VCHIQ_MESSAGE_AVAILABLE) return; status = vchi_msg_hold(instance->service, (void **)&m, &size, &handle); diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_common.h b/drivers/staging/vc04_services/interface/vchi/vchi_common.h index 52b447c19445..24e8665e214a 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_common.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_common.h @@ -4,27 +4,9 @@ #ifndef VCHI_COMMON_H_ #define VCHI_COMMON_H_ -//callback reasons when an event occurs on a service -enum vchi_callback_reason { - /* - * This indicates that there is data available handle is the msg id that - * was transmitted with the data - * When a message is received and there was no FULL message available - * previously, send callback - * Tasks get kicked by the callback, reset their event and try and read - * from the fifo until it fails - */ - VCHI_CALLBACK_SERVICE_CLOSED, - VCHI_CALLBACK_MSG_AVAILABLE, - VCHI_CALLBACK_BULK_SENT, - VCHI_CALLBACK_BULK_RECEIVED, - VCHI_CALLBACK_BULK_TRANSMIT_ABORTED, - VCHI_CALLBACK_BULK_RECEIVE_ABORTED, -}; - //Callback used by all services / bulk transfers typedef void (*vchi_callback)(void *callback_param, //my service local param - enum vchi_callback_reason reason, + enum vchiq_reason reason, void *handle); //for transmitting msg's only #endif // VCHI_COMMON_H_ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index c6b14d31492b..f2998c0ca5b1 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -274,46 +274,10 @@ static enum vchiq_status shim_callback(enum vchiq_reason reason, if (!service->callback) goto release; - switch (reason) { - case VCHIQ_MESSAGE_AVAILABLE: + if (reason == VCHIQ_MESSAGE_AVAILABLE) vchiu_queue_push(&service->queue, header); - service->callback(service->callback_param, - VCHI_CALLBACK_MSG_AVAILABLE, NULL); - - break; - - case VCHIQ_BULK_TRANSMIT_DONE: - service->callback(service->callback_param, - VCHI_CALLBACK_BULK_SENT, bulk_user); - break; - - case VCHIQ_BULK_RECEIVE_DONE: - service->callback(service->callback_param, - VCHI_CALLBACK_BULK_RECEIVED, bulk_user); - break; - - case VCHIQ_SERVICE_CLOSED: - service->callback(service->callback_param, - VCHI_CALLBACK_SERVICE_CLOSED, NULL); - break; - - case VCHIQ_BULK_TRANSMIT_ABORTED: - service->callback(service->callback_param, - VCHI_CALLBACK_BULK_TRANSMIT_ABORTED, - bulk_user); - break; - - case VCHIQ_BULK_RECEIVE_ABORTED: - service->callback(service->callback_param, - VCHI_CALLBACK_BULK_RECEIVE_ABORTED, - bulk_user); - break; - - default: - WARN(1, "not supported\n"); - break; - } + service->callback(service->callback_param, reason, bulk_user); release: return VCHIQ_SUCCESS; diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 5c9fd354a7fe..f710ccccb14c 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -549,8 +549,7 @@ static void bulk_abort_cb(struct vchiq_mmal_instance *instance, } /* incoming event service callback */ -static void service_callback(void *param, - const enum vchi_callback_reason reason, +static void service_callback(void *param, const enum vchiq_reason reason, void *bulk_ctx) { struct vchiq_mmal_instance *instance = param; @@ -566,7 +565,7 @@ static void service_callback(void *param, } switch (reason) { - case VCHI_CALLBACK_MSG_AVAILABLE: + case VCHIQ_MESSAGE_AVAILABLE: status = vchi_msg_hold(instance->service, (void **)&msg, &msg_len, &msg_handle); if (status) { @@ -631,15 +630,15 @@ static void service_callback(void *param, break; - case VCHI_CALLBACK_BULK_RECEIVED: + case VCHIQ_BULK_RECEIVE_DONE: bulk_receive_cb(instance, bulk_ctx); break; - case VCHI_CALLBACK_BULK_RECEIVE_ABORTED: + case VCHIQ_BULK_RECEIVE_ABORTED: bulk_abort_cb(instance, bulk_ctx); break; - case VCHI_CALLBACK_SERVICE_CLOSED: + case VCHIQ_SERVICE_CLOSED: /* TODO: consider if this requires action if received when * driver is not explicitly closing the service */ -- cgit v1.2.3-58-ga151 From 6c53da0b2ff9df002ff8e8e65ddf9e011e5527a6 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:19 +0200 Subject: staging: vchi: Get rid of effect less expression It was probably there to trick compilers into ignoring unused variables, which isn't needed in Linux. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-22-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index f2998c0ca5b1..b4884d0b82cd 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -288,8 +288,6 @@ static struct vchi_service *service_alloc(struct vchiq_instance *instance, { struct vchi_service *service = kzalloc(sizeof(struct vchi_service), GFP_KERNEL); - (void)instance; - if (service) { if (!vchiu_queue_init(&service->queue, 64)) { service->callback = setup->callback; -- cgit v1.2.3-58-ga151 From a8f7116b79749ea7f273d7c7e4efcf301a7adfe3 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:20 +0200 Subject: staging: vchiq: Introduce vchiq_validate_params() When adding a new service validate the configuration parameters provided, and remove unnecessary checks in vchi, now that we have validated service's config. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-23-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 15 +++++++++++++++ .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 4 ---- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index e0027148963e..0a2419bd305b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2265,6 +2265,16 @@ fail_free_handler_thread: return VCHIQ_ERROR; } +static int vchiq_validate_params(const struct vchiq_service_params *params) +{ + if (!params->callback || !params->fourcc) { + vchiq_loud_error("Can't add service, invalid params\n"); + return -EINVAL; + } + + return 0; +} + /* Called from application thread when a client or server service is created. */ struct vchiq_service * vchiq_add_service_internal(struct vchiq_state *state, @@ -2275,8 +2285,13 @@ vchiq_add_service_internal(struct vchiq_state *state, struct vchiq_service *service; struct vchiq_service __rcu **pservice = NULL; struct vchiq_service_quota *service_quota; + int ret; int i; + ret = vchiq_validate_params(params); + if (ret) + return NULL; + service = kmalloc(sizeof(*service), GFP_KERNEL); if (!service) return service; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index b4884d0b82cd..3ce4b7b5d55e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -271,15 +271,11 @@ static enum vchiq_status shim_callback(enum vchiq_reason reason, struct vchi_service *service = (struct vchi_service *)VCHIQ_GET_SERVICE_USERDATA(handle); - if (!service->callback) - goto release; - if (reason == VCHIQ_MESSAGE_AVAILABLE) vchiu_queue_push(&service->queue, header); service->callback(service->callback_param, reason, bulk_user); -release: return VCHIQ_SUCCESS; } -- cgit v1.2.3-58-ga151 From 77b3f6c49105088f157672c6e16deb0154a1383b Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:21 +0200 Subject: staging: vchiq: Move message queue into struct vchiq_service This has historically been handled by vchi, but there is no reason why this couldn't be handled directly in vchiq. The patch tries to avoid altering any behavior, with the exception of the msg_queue size, which is now fixed to VCHIQ_MAX_SLOTS (it was set to VCHIQ_MAX_SLOTS / 2). This is done to match vchiq's user_service message queue, which could be merged with this one in the future. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-24-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/Makefile | 1 - .../vc04_services/interface/vchiq_arm/vchiq_core.c | 46 ++++++++++++++ .../vc04_services/interface/vchiq_arm/vchiq_core.h | 6 ++ .../vc04_services/interface/vchiq_arm/vchiq_if.h | 2 + .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 24 +++---- .../vc04_services/interface/vchiq_arm/vchiq_util.c | 73 ---------------------- .../vc04_services/interface/vchiq_arm/vchiq_util.h | 22 ------- 7 files changed, 61 insertions(+), 113 deletions(-) delete mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/Makefile b/drivers/staging/vc04_services/Makefile index d37f21d1a219..922990919c40 100644 --- a/drivers/staging/vc04_services/Makefile +++ b/drivers/staging/vc04_services/Makefile @@ -7,7 +7,6 @@ vchiq-objs := \ interface/vchiq_arm/vchiq_2835_arm.o \ interface/vchiq_arm/vchiq_debugfs.o \ interface/vchiq_arm/vchiq_shim.o \ - interface/vchiq_arm/vchiq_util.o \ interface/vchiq_arm/vchiq_connected.o \ obj-$(CONFIG_SND_BCM2835) += bcm2835-audio/ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 0a2419bd305b..fe8ce6880e49 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2265,6 +2265,47 @@ fail_free_handler_thread: return VCHIQ_ERROR; } +void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header) +{ + struct vchiq_service *service = find_service_by_handle(handle); + int pos; + + while (service->msg_queue_write == service->msg_queue_read + + VCHIQ_MAX_SLOTS) { + if (wait_for_completion_interruptible(&service->msg_queue_pop)) + flush_signals(current); + } + + pos = service->msg_queue_write++ & (VCHIQ_MAX_SLOTS - 1); + service->msg_queue[pos] = header; + + complete(&service->msg_queue_push); +} +EXPORT_SYMBOL(vchiq_msg_queue_push); + +struct vchiq_header *vchiq_msg_hold(unsigned handle) +{ + struct vchiq_service *service = find_service_by_handle(handle); + struct vchiq_header *header; + int pos; + + if (service->msg_queue_write == service->msg_queue_read) + return NULL; + + while (service->msg_queue_write == service->msg_queue_read) { + if (wait_for_completion_interruptible(&service->msg_queue_push)) + flush_signals(current); + } + + pos = service->msg_queue_read++ & (VCHIQ_MAX_SLOTS - 1); + header = service->msg_queue[pos]; + + complete(&service->msg_queue_pop); + + return header; +} +EXPORT_SYMBOL(vchiq_msg_hold); + static int vchiq_validate_params(const struct vchiq_service_params *params) { if (!params->callback || !params->fourcc) { @@ -2319,12 +2360,17 @@ vchiq_add_service_internal(struct vchiq_state *state, service->state = state; service->instance = instance; service->service_use_count = 0; + service->msg_queue_read = 0; + service->msg_queue_write = 0; init_bulk_queue(&service->bulk_tx); init_bulk_queue(&service->bulk_rx); init_completion(&service->remove_event); init_completion(&service->bulk_remove_event); + init_completion(&service->msg_queue_pop); + init_completion(&service->msg_queue_push); mutex_init(&service->bulk_mutex); memset(&service->stats, 0, sizeof(service->stats)); + memset(&service->msg_queue, 0, sizeof(service->msg_queue)); /* Although it is perfectly possible to use a spinlock ** to protect the creation of services, it is overkill as it diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 1fe6cd8b86c0..b97b661bea1c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -297,6 +297,12 @@ struct vchiq_service { uint64_t bulk_tx_bytes; uint64_t bulk_rx_bytes; } stats; + + int msg_queue_read; + int msg_queue_write; + struct completion msg_queue_pop; + struct completion msg_queue_push; + struct vchiq_header *msg_queue[VCHIQ_MAX_SLOTS]; }; /* The quota information is outside struct vchiq_service so that it can diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index b62fd6d6f1ac..8fd51d885a18 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -136,5 +136,7 @@ extern enum vchiq_status vchiq_dump_phys_mem(unsigned int service, extern enum vchiq_status vchiq_get_peer_version(unsigned int handle, short *peer_version); +extern void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header); +extern struct vchiq_header *vchiq_msg_hold(unsigned handle); #endif /* VCHIQ_IF_H */ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 3ce4b7b5d55e..fb6f3c052e11 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -13,8 +13,6 @@ struct vchi_service { unsigned int handle; - struct vchiu_queue queue; - vchi_callback callback; void *callback_param; }; @@ -172,10 +170,9 @@ int32_t vchi_msg_hold(struct vchi_service *service, void **data, { struct vchiq_header *header; - if (vchiu_queue_is_empty(&service->queue)) - return -1; - - header = vchiu_queue_pop(&service->queue); + header = vchiq_msg_hold(service->handle); + if (!header) + return -ENOENT; *data = header->data; *msg_size = header->size; @@ -272,7 +269,7 @@ static enum vchiq_status shim_callback(enum vchiq_reason reason, (struct vchi_service *)VCHIQ_GET_SERVICE_USERDATA(handle); if (reason == VCHIQ_MESSAGE_AVAILABLE) - vchiu_queue_push(&service->queue, header); + vchiq_msg_queue_push(service->handle, header); service->callback(service->callback_param, reason, bulk_user); @@ -285,13 +282,8 @@ static struct vchi_service *service_alloc(struct vchiq_instance *instance, struct vchi_service *service = kzalloc(sizeof(struct vchi_service), GFP_KERNEL); if (service) { - if (!vchiu_queue_init(&service->queue, 64)) { - service->callback = setup->callback; - service->callback_param = setup->callback_param; - } else { - kfree(service); - service = NULL; - } + service->callback = setup->callback; + service->callback_param = setup->callback_param; } return service; @@ -299,10 +291,8 @@ static struct vchi_service *service_alloc(struct vchiq_instance *instance, static void service_free(struct vchi_service *service) { - if (service) { - vchiu_queue_delete(&service->queue); + if (service) kfree(service); - } } int32_t vchi_service_open(struct vchiq_instance *instance, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c deleted file mode 100644 index c1c81f9ab9e6..000000000000 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c +++ /dev/null @@ -1,73 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause -/* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ - -#include "vchiq_util.h" - -static inline int is_pow2(int i) -{ - return i && !(i & (i - 1)); -} - -int vchiu_queue_init(struct vchiu_queue *queue, int size) -{ - WARN_ON(!is_pow2(size)); - - queue->size = size; - queue->read = 0; - queue->write = 0; - queue->initialized = 1; - - init_completion(&queue->pop); - init_completion(&queue->push); - - queue->storage = kcalloc(size, sizeof(struct vchiq_header *), - GFP_KERNEL); - if (!queue->storage) { - vchiu_queue_delete(queue); - return -ENOMEM; - } - return 0; -} - -void vchiu_queue_delete(struct vchiu_queue *queue) -{ - kfree(queue->storage); -} - -int vchiu_queue_is_empty(struct vchiu_queue *queue) -{ - return queue->read == queue->write; -} - -void vchiu_queue_push(struct vchiu_queue *queue, struct vchiq_header *header) -{ - if (!queue->initialized) - return; - - while (queue->write == queue->read + queue->size) { - if (wait_for_completion_interruptible(&queue->pop)) - flush_signals(current); - } - - queue->storage[queue->write & (queue->size - 1)] = header; - queue->write++; - - complete(&queue->push); -} - -struct vchiq_header *vchiu_queue_pop(struct vchiu_queue *queue) -{ - struct vchiq_header *header; - - while (queue->write == queue->read) { - if (wait_for_completion_interruptible(&queue->push)) - flush_signals(current); - } - - header = queue->storage[queue->read & (queue->size - 1)]; - queue->read++; - - complete(&queue->pop); - - return header; -} diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h index 1c90a8da1a92..dcf081079c39 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h @@ -24,26 +24,4 @@ #include "vchiq_if.h" -struct vchiu_queue { - int size; - int read; - int write; - int initialized; - - struct completion pop; - struct completion push; - - struct vchiq_header **storage; -}; - -extern int vchiu_queue_init(struct vchiu_queue *queue, int size); -extern void vchiu_queue_delete(struct vchiu_queue *queue); - -extern int vchiu_queue_is_empty(struct vchiu_queue *queue); - -extern void vchiu_queue_push(struct vchiu_queue *queue, - struct vchiq_header *header); - -extern struct vchiq_header *vchiu_queue_pop(struct vchiu_queue *queue); - #endif -- cgit v1.2.3-58-ga151 From 460165c677983ca86a805b2f8b85240f395879cc Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:22 +0200 Subject: staging: vchiq: Get rid of vchiq_util.h The header file only provides other includes. Move the relevant includes to their respective C files and delete it for good. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-25-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq.h | 1 - .../interface/vchiq_arm/vchiq_2835_arm.c | 1 + .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 ++ .../vc04_services/interface/vchiq_arm/vchiq_core.c | 9 ++++++++ .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 4 ++-- .../vc04_services/interface/vchiq_arm/vchiq_util.h | 27 ---------------------- 6 files changed, 14 insertions(+), 30 deletions(-) delete mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h index 25af99a0f394..211b20705e36 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h @@ -5,7 +5,6 @@ #define VCHIQ_VCHIQ_H #include "vchiq_if.h" -#include "vchiq_util.h" /* Do this so that we can test-build the code on non-rpi systems */ #if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 46160139933e..5ed36d557014 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #define TOTAL_SLOTS (VCHIQ_SLOT_ZERO_SLOTS + 2 * 32) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 355590f1e130..dddd5ea5d917 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include "vchiq_core.h" diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index fe8ce6880e49..2382dfb914ae 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1,8 +1,17 @@ // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include #include "vchiq_core.h" diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index fb6f3c052e11..d8329590b5b1 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -2,14 +2,14 @@ /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ #include #include +#include +#include #include "vchiq_if.h" #include "../vchi/vchi.h" #include "vchiq.h" #include "vchiq_core.h" -#include "vchiq_util.h" - struct vchi_service { unsigned int handle; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h deleted file mode 100644 index dcf081079c39..000000000000 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h +++ /dev/null @@ -1,27 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ - -#ifndef VCHIQ_UTIL_H -#define VCHIQ_UTIL_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* for time_t */ -#include - -#include "vchiq_if.h" - -#endif -- cgit v1.2.3-58-ga151 From 823568cf170477ce6f71379193fa95b339757759 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:23 +0200 Subject: staging: vchi: Expose struct vchi_service This will make further changes easier. The struct will ultimately disappear. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-26-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchi/vchi.h | 10 +++++++--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 7 ------- 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 9a74ca4e1062..789acb7999d1 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -29,6 +29,13 @@ struct vchi_held_msg { void *message; }; +struct vchi_service { + unsigned int handle; + + vchi_callback callback; + void *callback_param; +}; + // structure used to provide the information needed to open a server or a client struct service_creation { struct vchi_version version; @@ -40,9 +47,6 @@ struct service_creation { // Opaque handle for a VCHIQ instance struct vchiq_instance; -// Opaque handle for a server or client -struct vchi_service; - /****************************************************************************** * Global funcs - implementation is specific to which side you are on * (local / remote) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index d8329590b5b1..bec78f0ff44b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -10,13 +10,6 @@ #include "vchiq.h" #include "vchiq_core.h" -struct vchi_service { - unsigned int handle; - - vchi_callback callback; - void *callback_param; -}; - int vchi_queue_kernel_message(struct vchi_service *service, void *data, unsigned int size) { -- cgit v1.2.3-58-ga151 From 31eeca20b75bdc2a62f9b2410ca5cf6f173735f4 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:24 +0200 Subject: staging: vchiq: Export vchiq_get_service_userdata() This is for service's callbacks to get their private data. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-27-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 2382dfb914ae..bb69c91c44b0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -332,6 +332,7 @@ vchiq_get_service_userdata(unsigned int handle) rcu_read_unlock(); return userdata; } +EXPORT_SYMBOL(vchiq_get_service_userdata); static void mark_service_closing_internal(struct vchiq_service *service, int sh_thread) -- cgit v1.2.3-58-ga151 From b79134e9de28dd6ca7627a9bae2fa4bfb382ad64 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:25 +0200 Subject: staging: vchiq: Export vchiq_msg_queue_push vchiq consumer drivers may need to use this function in order to get the benefits of vchiq's per service message queueing mechanism. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-28-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index 8fd51d885a18..c99caa3add57 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -107,6 +107,7 @@ extern enum vchiq_status vchiq_use_service(unsigned int service); extern enum vchiq_status vchiq_release_service(unsigned int service); extern enum vchiq_status vchiq_queue_kernel_message(unsigned int handle, void *context, size_t size); +extern void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header); extern void vchiq_release_message(unsigned int service, struct vchiq_header *header); extern enum vchiq_status vchiq_bulk_transmit(unsigned int service, -- cgit v1.2.3-58-ga151 From 3c5da06f9969959f5cd85e8baaef9d96059b3924 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:26 +0200 Subject: staging: vchi: Get rid of vchiq_shim's message callback As vchiq_shim's callback does nothing aside from pushing messages into the service's queue, let's bypass it and jump directly to the service's callbacks, letting them choose whether to use the message queue. It turns out most services don't need to use the message queue, which makes for simpler code in the end. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-29-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 20 +++--- .../staging/vc04_services/interface/vchi/vchi.h | 9 +-- .../vc04_services/interface/vchi/vchi_common.h | 12 ---- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 42 +++-------- .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 83 +++++++++++----------- 5 files changed, 59 insertions(+), 107 deletions(-) delete mode 100644 drivers/staging/vc04_services/interface/vchi/vchi_common.h (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 0f97eda4ec90..71750ef891dd 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -89,22 +89,17 @@ static int bcm2835_audio_send_simple(struct bcm2835_audio_instance *instance, return bcm2835_audio_send_msg(instance, &m, wait); } -static void audio_vchi_callback(void *param, const enum vchiq_reason reason, - void *msg_handle) +static enum vchiq_status audio_vchi_callback(enum vchiq_reason reason, + struct vchiq_header *header, + unsigned handle, void *userdata) { - struct bcm2835_audio_instance *instance = param; - struct vchi_held_msg handle; + struct bcm2835_audio_instance *instance = vchiq_get_service_userdata(handle); struct vc_audio_msg *m; - unsigned size; - int status; if (reason != VCHIQ_MESSAGE_AVAILABLE) - return; - - status = vchi_msg_hold(instance->service, (void **)&m, &size, &handle); - if (status) - return; + return VCHIQ_SUCCESS; + m = (void *)header->data; if (m->type == VC_AUDIO_MSG_TYPE_RESULT) { instance->result = m->result.success; complete(&instance->msg_avail_comp); @@ -119,7 +114,8 @@ static void audio_vchi_callback(void *param, const enum vchiq_reason reason, dev_err(instance->dev, "unexpected callback type=%d\n", m->type); } - vchi_held_msg_release(&handle); + vchiq_release_message(handle, header); + return VCHIQ_SUCCESS; } static int diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 789acb7999d1..fdc243f3f60a 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -4,8 +4,6 @@ #ifndef VCHI_H_ #define VCHI_H_ -#include "vchi_common.h" - /****************************************************************************** * Global defs *****************************************************************************/ @@ -31,16 +29,13 @@ struct vchi_held_msg { struct vchi_service { unsigned int handle; - - vchi_callback callback; - void *callback_param; }; // structure used to provide the information needed to open a server or a client struct service_creation { struct vchi_version version; int32_t service_id; - vchi_callback callback; + vchiq_callback callback; void *callback_param; }; @@ -88,7 +83,7 @@ extern int vchi_queue_kernel_message(struct vchi_service *service, void *data, // Routine to look at a message in place. // The message is dequeued, so the caller is left holding it; the descriptor is // filled in and must be released when the user has finished with the message. -extern int32_t vchi_msg_hold(struct vchi_service *service, +extern int32_t vchi_msg_hold(unsigned handle, void **data, // } may be NULL, as info can be uint32_t *msg_size, // } obtained from HELD_MSG_T struct vchi_held_msg *message_descriptor); diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_common.h b/drivers/staging/vc04_services/interface/vchi/vchi_common.h deleted file mode 100644 index 24e8665e214a..000000000000 --- a/drivers/staging/vc04_services/interface/vchi/vchi_common.h +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ - -#ifndef VCHI_COMMON_H_ -#define VCHI_COMMON_H_ - -//Callback used by all services / bulk transfers -typedef void (*vchi_callback)(void *callback_param, //my service local param - enum vchiq_reason reason, - void *handle); //for transmitting msg's only - -#endif // VCHI_COMMON_H_ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index bec78f0ff44b..fb9fd5fec42c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -158,12 +158,12 @@ EXPORT_SYMBOL(vchi_held_msg_release); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_msg_hold(struct vchi_service *service, void **data, - uint32_t *msg_size, struct vchi_held_msg *message_handle) +int32_t vchi_msg_hold(unsigned handle, void **data, uint32_t *msg_size, + struct vchi_held_msg *message_handle) { struct vchiq_header *header; - header = vchiq_msg_hold(service->handle); + header = vchiq_msg_hold(handle); if (!header) return -ENOENT; @@ -179,7 +179,7 @@ int32_t vchi_msg_hold(struct vchi_service *service, void **data, */ message_handle->service = - (struct opaque_vchi_service_t *)(long)service->handle; + (struct opaque_vchi_service_t *)(long)handle; message_handle->message = header; return 0; @@ -253,33 +253,9 @@ EXPORT_SYMBOL(vchi_disconnect); * ***********************************************************/ -static enum vchiq_status shim_callback(enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, - void *bulk_user) +static struct vchi_service *service_alloc(void) { - struct vchi_service *service = - (struct vchi_service *)VCHIQ_GET_SERVICE_USERDATA(handle); - - if (reason == VCHIQ_MESSAGE_AVAILABLE) - vchiq_msg_queue_push(service->handle, header); - - service->callback(service->callback_param, reason, bulk_user); - - return VCHIQ_SUCCESS; -} - -static struct vchi_service *service_alloc(struct vchiq_instance *instance, - struct service_creation *setup) -{ - struct vchi_service *service = kzalloc(sizeof(struct vchi_service), GFP_KERNEL); - - if (service) { - service->callback = setup->callback; - service->callback_param = setup->callback_param; - } - - return service; + return kzalloc(sizeof(struct vchi_service), GFP_KERNEL); } static void service_free(struct vchi_service *service) @@ -293,15 +269,15 @@ int32_t vchi_service_open(struct vchiq_instance *instance, struct vchi_service **service) { - *service = service_alloc(instance, setup); + *service = service_alloc(); if (*service) { struct vchiq_service_params params; enum vchiq_status status; memset(¶ms, 0, sizeof(params)); params.fourcc = setup->service_id; - params.callback = shim_callback; - params.userdata = *service; + params.callback = setup->callback; + params.userdata = setup->callback_param; params.version = setup->version.version; params.version_min = setup->version.version_min; diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index f710ccccb14c..2abf0f6664f9 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -152,7 +152,7 @@ struct mmal_msg_context { struct { /* message handle to release */ - struct vchi_held_msg msg_handle; + struct vchiq_header *msg_handle; /* pointer to received message */ struct mmal_msg *msg; /* received message length */ @@ -549,54 +549,49 @@ static void bulk_abort_cb(struct vchiq_mmal_instance *instance, } /* incoming event service callback */ -static void service_callback(void *param, const enum vchiq_reason reason, - void *bulk_ctx) +static enum vchiq_status service_callback(enum vchiq_reason reason, + struct vchiq_header *header, + unsigned handle, void *bulk_ctx) { - struct vchiq_mmal_instance *instance = param; - int status; + struct vchiq_mmal_instance *instance = vchiq_get_service_userdata(handle); u32 msg_len; struct mmal_msg *msg; - struct vchi_held_msg msg_handle; struct mmal_msg_context *msg_context; if (!instance) { pr_err("Message callback passed NULL instance\n"); - return; + return VCHIQ_SUCCESS; } switch (reason) { case VCHIQ_MESSAGE_AVAILABLE: - status = vchi_msg_hold(instance->service, (void **)&msg, - &msg_len, &msg_handle); - if (status) { - pr_err("Unable to dequeue a message (%d)\n", status); - break; - } + msg = (void *)header->data; + msg_len = header->size; DBG_DUMP_MSG(msg, msg_len, "<<< reply message"); /* handling is different for buffer messages */ switch (msg->h.type) { case MMAL_MSG_TYPE_BUFFER_FROM_HOST: - vchi_held_msg_release(&msg_handle); + vchiq_release_message(handle, header); break; case MMAL_MSG_TYPE_EVENT_TO_HOST: event_to_host_cb(instance, msg, msg_len); - vchi_held_msg_release(&msg_handle); + vchiq_release_message(handle, header); break; case MMAL_MSG_TYPE_BUFFER_TO_HOST: buffer_to_host_cb(instance, msg, msg_len); - vchi_held_msg_release(&msg_handle); + vchiq_release_message(handle, header); break; default: /* messages dependent on header context to complete */ if (!msg->h.context) { pr_err("received message context was null!\n"); - vchi_held_msg_release(&msg_handle); + vchiq_release_message(handle, header); break; } @@ -605,12 +600,12 @@ static void service_callback(void *param, const enum vchiq_reason reason, if (!msg_context) { pr_err("received invalid message context %u!\n", msg->h.context); - vchi_held_msg_release(&msg_handle); + vchiq_release_message(handle, header); break; } /* fill in context values */ - msg_context->u.sync.msg_handle = msg_handle; + msg_context->u.sync.msg_handle = header; msg_context->u.sync.msg = msg; msg_context->u.sync.msg_len = msg_len; @@ -648,13 +643,15 @@ static void service_callback(void *param, const enum vchiq_reason reason, pr_err("Received unhandled message reason %d\n", reason); break; } + + return VCHIQ_SUCCESS; } static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, struct mmal_msg *msg, unsigned int payload_len, struct mmal_msg **msg_out, - struct vchi_held_msg *msg_handle_out) + struct vchiq_header **msg_handle) { struct mmal_msg_context *msg_context; int ret; @@ -708,7 +705,7 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, } *msg_out = msg_context->u.sync.msg; - *msg_handle_out = msg_context->u.sync.msg_handle; + *msg_handle = msg_context->u.sync.msg_handle; release_msg_context(msg_context); return 0; @@ -780,7 +777,7 @@ static int port_info_set(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; + struct vchiq_header *rmsg_handle; pr_debug("setting port info port %p\n", port); if (!port) @@ -829,7 +826,7 @@ static int port_info_set(struct vchiq_mmal_instance *instance, port->component->handle, port->handle); release_msg: - vchi_held_msg_release(&rmsg_handle); + vchiq_release_message(instance->service->handle, rmsg_handle); return ret; } @@ -841,7 +838,7 @@ static int port_info_get(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; + struct vchiq_header *rmsg_handle; /* port info time */ m.h.type = MMAL_MSG_TYPE_PORT_INFO_GET; @@ -924,7 +921,7 @@ release_msg: pr_debug("%s:result:%d component:0x%x port:%d\n", __func__, ret, port->component->handle, port->handle); - vchi_held_msg_release(&rmsg_handle); + vchiq_release_message(instance->service->handle, rmsg_handle); return ret; } @@ -937,7 +934,7 @@ static int create_component(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; + struct vchiq_header *rmsg_handle; /* build component create message */ m.h.type = MMAL_MSG_TYPE_COMPONENT_CREATE; @@ -972,7 +969,7 @@ static int create_component(struct vchiq_mmal_instance *instance, component->inputs, component->outputs, component->clocks); release_msg: - vchi_held_msg_release(&rmsg_handle); + vchiq_release_message(instance->service->handle, rmsg_handle); return ret; } @@ -984,7 +981,7 @@ static int destroy_component(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; + struct vchiq_header *rmsg_handle; m.h.type = MMAL_MSG_TYPE_COMPONENT_DESTROY; m.u.component_destroy.component_handle = component->handle; @@ -1005,7 +1002,7 @@ static int destroy_component(struct vchiq_mmal_instance *instance, release_msg: - vchi_held_msg_release(&rmsg_handle); + vchiq_release_message(instance->service->handle, rmsg_handle); return ret; } @@ -1017,7 +1014,7 @@ static int enable_component(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; + struct vchiq_header *rmsg_handle; m.h.type = MMAL_MSG_TYPE_COMPONENT_ENABLE; m.u.component_enable.component_handle = component->handle; @@ -1037,7 +1034,7 @@ static int enable_component(struct vchiq_mmal_instance *instance, ret = -rmsg->u.component_enable_reply.status; release_msg: - vchi_held_msg_release(&rmsg_handle); + vchiq_release_message(instance->service->handle, rmsg_handle); return ret; } @@ -1049,7 +1046,7 @@ static int disable_component(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; + struct vchiq_header *rmsg_handle; m.h.type = MMAL_MSG_TYPE_COMPONENT_DISABLE; m.u.component_disable.component_handle = component->handle; @@ -1070,7 +1067,7 @@ static int disable_component(struct vchiq_mmal_instance *instance, release_msg: - vchi_held_msg_release(&rmsg_handle); + vchiq_release_message(instance->service->handle, rmsg_handle); return ret; } @@ -1082,7 +1079,7 @@ static int get_version(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; + struct vchiq_header *rmsg_handle; m.h.type = MMAL_MSG_TYPE_GET_VERSION; @@ -1102,7 +1099,7 @@ static int get_version(struct vchiq_mmal_instance *instance, *minor_out = rmsg->u.version.minor; release_msg: - vchi_held_msg_release(&rmsg_handle); + vchiq_release_message(instance->service->handle, rmsg_handle); return ret; } @@ -1115,7 +1112,7 @@ static int port_action_port(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; + struct vchiq_header *rmsg_handle; m.h.type = MMAL_MSG_TYPE_PORT_ACTION; m.u.port_action_port.component_handle = port->component->handle; @@ -1144,7 +1141,7 @@ static int port_action_port(struct vchiq_mmal_instance *instance, port_action_type_names[action_type], action_type); release_msg: - vchi_held_msg_release(&rmsg_handle); + vchiq_release_message(instance->service->handle, rmsg_handle); return ret; } @@ -1159,7 +1156,7 @@ static int port_action_handle(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; + struct vchiq_header *rmsg_handle; m.h.type = MMAL_MSG_TYPE_PORT_ACTION; @@ -1192,7 +1189,7 @@ static int port_action_handle(struct vchiq_mmal_instance *instance, action_type, connect_component_handle, connect_port_handle); release_msg: - vchi_held_msg_release(&rmsg_handle); + vchiq_release_message(instance->service->handle, rmsg_handle); return ret; } @@ -1204,7 +1201,7 @@ static int port_parameter_set(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; + struct vchiq_header *rmsg_handle; m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_SET; @@ -1233,7 +1230,7 @@ static int port_parameter_set(struct vchiq_mmal_instance *instance, ret, port->component->handle, port->handle, parameter_id); release_msg: - vchi_held_msg_release(&rmsg_handle); + vchiq_release_message(instance->service->handle, rmsg_handle); return ret; } @@ -1245,7 +1242,7 @@ static int port_parameter_get(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - struct vchi_held_msg rmsg_handle; + struct vchiq_header *rmsg_handle; m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_GET; @@ -1292,7 +1289,7 @@ static int port_parameter_get(struct vchiq_mmal_instance *instance, ret, port->component->handle, port->handle, parameter_id); release_msg: - vchi_held_msg_release(&rmsg_handle); + vchiq_release_message(instance->service->handle, rmsg_handle); return ret; } -- cgit v1.2.3-58-ga151 From 47cc5b16b04f337e1b0378ec5c8c8fbf2dd92a6a Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:27 +0200 Subject: staging: vchiq: Don't use a typedef for vchiq_callback Linux coding style says to avoid typdefs. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-30-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchi/vchi.h | 5 ++++- .../staging/vc04_services/interface/vchiq_arm/vchiq_if.h | 14 ++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index fdc243f3f60a..cb66ea1ffad2 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -35,7 +35,10 @@ struct vchi_service { struct service_creation { struct vchi_version version; int32_t service_id; - vchiq_callback callback; + enum vchiq_status (*callback)(enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, + void *bulk_userdata); void *callback_param; }; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index c99caa3add57..b3d4c14536bd 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -60,19 +60,21 @@ struct vchiq_element { unsigned int size; }; -typedef enum vchiq_status (*vchiq_callback)(enum vchiq_reason, - struct vchiq_header *, - unsigned int, void *); - struct vchiq_service_base { int fourcc; - vchiq_callback callback; + enum vchiq_status (*callback)(enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, + void *bulk_userdata); void *userdata; }; struct vchiq_service_params { int fourcc; - vchiq_callback callback; + enum vchiq_status (*callback)(enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, + void *bulk_userdata); void *userdata; short version; /* Increment for non-trivial changes */ short version_min; /* Update for incompatible changes */ -- cgit v1.2.3-58-ga151 From 65c7536672b9ee82da399eed6f5f4f658012c758 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:28 +0200 Subject: staging: vchi: Use struct vchiq_service_params For initialization, vchi has its own params structure, which is then translated to vchiq's params structure. They are essentially the same, so lets directly use vchiq's. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-31-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 9 +++++---- drivers/staging/vc04_services/interface/vchi/vchi.h | 19 +------------------ .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 12 ++---------- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 11 ++++++----- 4 files changed, 14 insertions(+), 37 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 71750ef891dd..c1537a41a2fe 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -122,11 +122,12 @@ static int vc_vchi_audio_init(struct vchiq_instance *vchiq_instance, struct bcm2835_audio_instance *instance) { - struct service_creation params = { - .version = VCHI_VERSION_EX(VC_AUDIOSERV_VER, VC_AUDIOSERV_MIN_VER), - .service_id = VC_AUDIO_SERVER_NAME, + struct vchiq_service_params params = { + .version = VC_AUDIOSERV_VER, + .version_min = VC_AUDIOSERV_MIN_VER, + .fourcc = VC_AUDIO_SERVER_NAME, .callback = audio_vchi_callback, - .callback_param = instance, + .userdata = instance, }; int status; diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index cb66ea1ffad2..4afa6e9f57c4 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -8,12 +8,6 @@ * Global defs *****************************************************************************/ -struct vchi_version { - uint32_t version; - uint32_t version_min; -}; -#define VCHI_VERSION_EX(v_, m_) { v_, m_ } - // Macros to manipulate 'FOURCC' values #define MAKE_FOURCC(x) ((int32_t)((x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3])) @@ -31,17 +25,6 @@ struct vchi_service { unsigned int handle; }; -// structure used to provide the information needed to open a server or a client -struct service_creation { - struct vchi_version version; - int32_t service_id; - enum vchiq_status (*callback)(enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, - void *bulk_userdata); - void *callback_param; -}; - // Opaque handle for a VCHIQ instance struct vchiq_instance; @@ -64,7 +47,7 @@ extern int32_t vchi_disconnect(struct vchiq_instance *instance); *****************************************************************************/ // Routine to open a named service extern int32_t vchi_service_open(struct vchiq_instance *instance, - struct service_creation *setup, + struct vchiq_service_params *setup, struct vchi_service **service); extern int32_t vchi_get_peer_version(struct vchi_service *service, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index fb9fd5fec42c..30083927b33d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -265,23 +265,15 @@ static void service_free(struct vchi_service *service) } int32_t vchi_service_open(struct vchiq_instance *instance, - struct service_creation *setup, + struct vchiq_service_params *params, struct vchi_service **service) { *service = service_alloc(); if (*service) { - struct vchiq_service_params params; enum vchiq_status status; - memset(¶ms, 0, sizeof(params)); - params.fourcc = setup->service_id; - params.callback = setup->callback; - params.userdata = setup->callback_param; - params.version = setup->version.version; - params.version_min = setup->version.version_min; - - status = vchiq_open_service(instance, ¶ms, + status = vchiq_open_service(instance, params, &((*service)->handle)); if (status != VCHIQ_SUCCESS) { service_free(*service); diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 2abf0f6664f9..4788bb645dc5 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -1860,11 +1860,12 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) int status; struct vchiq_mmal_instance *instance; static struct vchiq_instance *vchiq_instance; - struct service_creation params = { - .version = VCHI_VERSION_EX(VC_MMAL_VER, VC_MMAL_MIN_VER), - .service_id = VC_MMAL_SERVER_NAME, + struct vchiq_service_params params = { + .version = VC_MMAL_VER, + .version_min = VC_MMAL_MIN_VER, + .fourcc = VC_MMAL_SERVER_NAME, .callback = service_callback, - .callback_param = NULL, + .userdata = NULL, }; /* compile time checks to ensure structure size as they are @@ -1906,7 +1907,7 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) mutex_init(&instance->context_map_lock); idr_init_base(&instance->context_map, 1); - params.callback_param = instance; + params.userdata = instance; instance->bulk_wq = alloc_ordered_workqueue("mmal-vchiq", WQ_MEM_RECLAIM); -- cgit v1.2.3-58-ga151 From 3a8895a9219f6b58d006546c40c1addb764a7c1d Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:29 +0200 Subject: staging: vchi: Get rid of struct vchi_service The structure only contains a single parameter, which is the underlying vchiq handle. Get rid of the struct and directly pass the handle around. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-32-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 23 ++--- .../staging/vc04_services/interface/vchi/vchi.h | 25 +++--- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 99 +++++----------------- .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 55 ++++++------ 4 files changed, 73 insertions(+), 129 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index c1537a41a2fe..18309578e9a2 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -9,7 +9,7 @@ struct bcm2835_audio_instance { struct device *dev; - struct vchi_service *service; + unsigned service_handle; struct completion msg_avail_comp; struct mutex vchi_mutex; struct bcm2835_alsa_stream *alsa_stream; @@ -25,12 +25,12 @@ MODULE_PARM_DESC(force_bulk, "Force use of vchiq bulk for audio"); static void bcm2835_audio_lock(struct bcm2835_audio_instance *instance) { mutex_lock(&instance->vchi_mutex); - vchi_service_use(instance->service); + vchi_service_use(instance->service_handle); } static void bcm2835_audio_unlock(struct bcm2835_audio_instance *instance) { - vchi_service_release(instance->service); + vchi_service_release(instance->service_handle); mutex_unlock(&instance->vchi_mutex); } @@ -44,7 +44,7 @@ static int bcm2835_audio_send_msg_locked(struct bcm2835_audio_instance *instance init_completion(&instance->msg_avail_comp); } - status = vchi_queue_kernel_message(instance->service, + status = vchi_queue_kernel_message(instance->service_handle, m, sizeof(*m)); if (status) { dev_err(instance->dev, @@ -133,7 +133,7 @@ vc_vchi_audio_init(struct vchiq_instance *vchiq_instance, /* Open the VCHI service connections */ status = vchi_service_open(vchiq_instance, ¶ms, - &instance->service); + &instance->service_handle); if (status) { dev_err(instance->dev, @@ -143,7 +143,7 @@ vc_vchi_audio_init(struct vchiq_instance *vchiq_instance, } /* Finished with the service for now */ - vchi_service_release(instance->service); + vchi_service_release(instance->service_handle); return 0; } @@ -153,10 +153,10 @@ static void vc_vchi_audio_deinit(struct bcm2835_audio_instance *instance) int status; mutex_lock(&instance->vchi_mutex); - vchi_service_use(instance->service); + vchi_service_use(instance->service_handle); /* Close all VCHI service connections */ - status = vchi_service_close(instance->service); + status = vchi_service_close(instance->service_handle); if (status) { dev_err(instance->dev, "failed to close VCHI service connection (status=%d)\n", @@ -226,7 +226,8 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) goto deinit; bcm2835_audio_lock(instance); - vchi_get_peer_version(instance->service, &instance->peer_version); + vchi_get_peer_version(instance->service_handle, + &instance->peer_version); bcm2835_audio_unlock(instance); if (instance->peer_version < 2 || force_bulk) instance->max_packet = 0; /* bulk transfer */ @@ -342,7 +343,7 @@ int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, count = size; if (!instance->max_packet) { /* Send the message to the videocore */ - status = vchi_bulk_queue_transmit(instance->service, + status = vchi_bulk_queue_transmit(instance->service_handle, src, count, VCHIQ_BULK_MODE_BLOCKING, NULL); @@ -350,7 +351,7 @@ int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, while (count > 0) { int bytes = min(instance->max_packet, count); - status = vchi_queue_kernel_message(instance->service, + status = vchi_queue_kernel_message(instance->service_handle, src, bytes); src += bytes; count -= bytes; diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 4afa6e9f57c4..74fd169e079a 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -21,10 +21,6 @@ struct vchi_held_msg { void *message; }; -struct vchi_service { - unsigned int handle; -}; - // Opaque handle for a VCHIQ instance struct vchiq_instance; @@ -46,24 +42,23 @@ extern int32_t vchi_disconnect(struct vchiq_instance *instance); * Global service API *****************************************************************************/ // Routine to open a named service -extern int32_t vchi_service_open(struct vchiq_instance *instance, - struct vchiq_service_params *setup, - struct vchi_service **service); +extern int vchi_service_open(struct vchiq_instance *instance, + struct vchiq_service_params *params, + unsigned *handle); -extern int32_t vchi_get_peer_version(struct vchi_service *service, - short *peer_version); +extern int32_t vchi_get_peer_version(unsigned handle, short *peer_version); // Routine to close a named service -extern int32_t vchi_service_close(struct vchi_service *service); +extern int32_t vchi_service_close(unsigned handle); // Routine to increment ref count on a named service -extern int32_t vchi_service_use(struct vchi_service *service); +extern int32_t vchi_service_use(unsigned handle); // Routine to decrement ref count on a named service -extern int32_t vchi_service_release(struct vchi_service *service); +extern int32_t vchi_service_release(unsigned handle); /* Routine to send a message from kernel memory across a service */ -extern int vchi_queue_kernel_message(struct vchi_service *service, void *data, +extern int vchi_queue_kernel_message(unsigned handle, void *data, unsigned int size); // Routine to look at a message in place. @@ -87,14 +82,14 @@ extern int32_t vchi_held_msg_release(struct vchi_held_msg *message); *****************************************************************************/ // Routine to prepare interface for a transfer from the other side -extern int32_t vchi_bulk_queue_receive(struct vchi_service *service, +extern int32_t vchi_bulk_queue_receive(unsigned handle, void *data_dst, uint32_t data_size, enum vchiq_bulk_mode mode, void *transfer_handle); // Routine to queue up data ready for transfer to the other (once they have signalled they are ready) -extern int32_t vchi_bulk_queue_transmit(struct vchi_service *service, +extern int32_t vchi_bulk_queue_transmit(unsigned handle, const void *data_src, uint32_t data_size, enum vchiq_bulk_mode mode, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 30083927b33d..578346965da6 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -10,14 +10,12 @@ #include "vchiq.h" #include "vchiq_core.h" -int vchi_queue_kernel_message(struct vchi_service *service, void *data, - unsigned int size) +int vchi_queue_kernel_message(unsigned handle, void *data, unsigned int size) { enum vchiq_status status; while (1) { - status = vchiq_queue_kernel_message(service->handle, data, - size); + status = vchiq_queue_kernel_message(handle, data, size); /* * vchiq_queue_message() may return VCHIQ_RETRY, so we need to @@ -48,15 +46,15 @@ EXPORT_SYMBOL(vchi_queue_kernel_message); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_bulk_queue_receive(struct vchi_service *service, void *data_dst, +int32_t vchi_bulk_queue_receive(unsigned handle, void *data_dst, uint32_t data_size, enum vchiq_bulk_mode mode, void *bulk_handle) { enum vchiq_status status; while (1) { - status = vchiq_bulk_receive(service->handle, data_dst, - data_size, bulk_handle, mode); + status = vchiq_bulk_receive(handle, data_dst, data_size, + bulk_handle, mode); /* * vchiq_bulk_receive() may return VCHIQ_RETRY, so we need to * implement a retry mechanism since this function is supposed @@ -86,17 +84,15 @@ EXPORT_SYMBOL(vchi_bulk_queue_receive); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_bulk_queue_transmit(struct vchi_service *service, - const void *data_src, - uint32_t data_size, - enum vchiq_bulk_mode mode, +int32_t vchi_bulk_queue_transmit(unsigned handle, const void *data_src, + uint32_t data_size, enum vchiq_bulk_mode mode, void *bulk_handle) { enum vchiq_status status; while (1) { - status = vchiq_bulk_transmit(service->handle, data_src, - data_size, bulk_handle, mode); + status = vchiq_bulk_transmit(handle, data_src, data_size, + bulk_handle, mode); /* * vchiq_bulk_transmit() may return VCHIQ_RETRY, so we need to @@ -245,7 +241,7 @@ EXPORT_SYMBOL(vchi_disconnect); * * Arguments: struct vchiq_instance *instance * struct service_creation *setup, - * struct vchi_service **service + * unsigned *handle * * Description: Routine to open a service * @@ -253,103 +249,54 @@ EXPORT_SYMBOL(vchi_disconnect); * ***********************************************************/ -static struct vchi_service *service_alloc(void) -{ - return kzalloc(sizeof(struct vchi_service), GFP_KERNEL); -} - -static void service_free(struct vchi_service *service) -{ - if (service) - kfree(service); -} - int32_t vchi_service_open(struct vchiq_instance *instance, - struct vchiq_service_params *params, - struct vchi_service **service) + struct vchiq_service_params *params, + unsigned *handle) { - - *service = service_alloc(); - if (*service) { - enum vchiq_status status; - - status = vchiq_open_service(instance, params, - &((*service)->handle)); - if (status != VCHIQ_SUCCESS) { - service_free(*service); - *service = NULL; - } - } - - return *service ? 0 : -1; + return vchiq_open_service(instance, params, handle); } EXPORT_SYMBOL(vchi_service_open); -int32_t vchi_service_close(struct vchi_service *service) +int32_t vchi_service_close(unsigned handle) { - int32_t ret = -1; - - if (service) { - enum vchiq_status status = vchiq_close_service(service->handle); - if (status == VCHIQ_SUCCESS) - service_free(service); - - ret = status; - } - return ret; + return vchiq_close_service(handle); } EXPORT_SYMBOL(vchi_service_close); -int32_t vchi_get_peer_version(struct vchi_service *service, short *peer_version) +int32_t vchi_get_peer_version(unsigned handle, short *peer_version) { - int32_t ret = -1; - - if (service) { - enum vchiq_status status; - - status = vchiq_get_peer_version(service->handle, peer_version); - ret = status; - } - return ret; + return vchiq_get_peer_version(handle, peer_version); } EXPORT_SYMBOL(vchi_get_peer_version); /*********************************************************** * Name: vchi_service_use * - * Arguments: struct vchi_service *service + * Arguments: unsigned handle * * Description: Routine to increment refcount on a service * * Returns: void * ***********************************************************/ -int32_t vchi_service_use(struct vchi_service *service) +int32_t vchi_service_use(unsigned handle) { - int32_t ret = -1; - - if (service) - ret = vchiq_use_service(service->handle); - return ret; + return vchiq_use_service(handle); } EXPORT_SYMBOL(vchi_service_use); /*********************************************************** * Name: vchi_service_release * - * Arguments: struct vchi_service *service + * Arguments: unsigned handle * * Description: Routine to decrement refcount on a service * * Returns: void * ***********************************************************/ -int32_t vchi_service_release(struct vchi_service *service) +int32_t vchi_service_release(unsigned handle) { - int32_t ret = -1; - - if (service) - ret = vchiq_release_service(service->handle); - return ret; + return vchiq_release_service(handle); } EXPORT_SYMBOL(vchi_service_release); diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 4788bb645dc5..c960fb7ec890 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -165,7 +165,7 @@ struct mmal_msg_context { }; struct vchiq_mmal_instance { - struct vchi_service *service; + unsigned service_handle; /* ensure serialised access to service */ struct mutex vchiq_mutex; @@ -294,8 +294,8 @@ static void buffer_to_host_work_cb(struct work_struct *work) /* Dummy receive to ensure the buffers remain in order */ len = 8; /* queue the bulk submission */ - vchi_service_use(instance->service); - ret = vchi_bulk_queue_receive(instance->service, + vchi_service_use(instance->service_handle); + ret = vchi_bulk_queue_receive(instance->service_handle, msg_context->u.bulk.buffer->buffer, /* Actual receive needs to be a multiple * of 4 bytes @@ -304,7 +304,7 @@ static void buffer_to_host_work_cb(struct work_struct *work) VCHIQ_BULK_MODE_CALLBACK, msg_context); - vchi_service_release(instance->service); + vchi_service_release(instance->service_handle); if (ret != 0) pr_err("%s: ctx: %p, vchi_bulk_queue_receive failed %d\n", @@ -383,7 +383,7 @@ buffer_from_host(struct vchiq_mmal_instance *instance, if (!port->enabled) return -EINVAL; - pr_debug("instance:%p buffer:%p\n", instance->service, buf); + pr_debug("instance:%u buffer:%p\n", instance->service_handle, buf); /* get context */ if (!buf->msg_context) { @@ -438,14 +438,14 @@ buffer_from_host(struct vchiq_mmal_instance *instance, /* no payload in message */ m.u.buffer_from_host.payload_in_message = 0; - vchi_service_use(instance->service); + vchi_service_use(instance->service_handle); - ret = vchi_queue_kernel_message(instance->service, + ret = vchi_queue_kernel_message(instance->service_handle, &m, sizeof(struct mmal_msg_header) + sizeof(m.u.buffer_from_host)); - vchi_service_release(instance->service); + vchi_service_release(instance->service_handle); return ret; } @@ -679,14 +679,14 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, DBG_DUMP_MSG(msg, (sizeof(struct mmal_msg_header) + payload_len), ">>> sync message"); - vchi_service_use(instance->service); + vchi_service_use(instance->service_handle); - ret = vchi_queue_kernel_message(instance->service, + ret = vchi_queue_kernel_message(instance->service_handle, msg, sizeof(struct mmal_msg_header) + payload_len); - vchi_service_release(instance->service); + vchi_service_release(instance->service_handle); if (ret) { pr_err("error %d queuing message\n", ret); @@ -826,7 +826,7 @@ static int port_info_set(struct vchiq_mmal_instance *instance, port->component->handle, port->handle); release_msg: - vchiq_release_message(instance->service->handle, rmsg_handle); + vchiq_release_message(instance->service_handle, rmsg_handle); return ret; } @@ -921,7 +921,7 @@ release_msg: pr_debug("%s:result:%d component:0x%x port:%d\n", __func__, ret, port->component->handle, port->handle); - vchiq_release_message(instance->service->handle, rmsg_handle); + vchiq_release_message(instance->service_handle, rmsg_handle); return ret; } @@ -969,7 +969,7 @@ static int create_component(struct vchiq_mmal_instance *instance, component->inputs, component->outputs, component->clocks); release_msg: - vchiq_release_message(instance->service->handle, rmsg_handle); + vchiq_release_message(instance->service_handle, rmsg_handle); return ret; } @@ -1002,7 +1002,7 @@ static int destroy_component(struct vchiq_mmal_instance *instance, release_msg: - vchiq_release_message(instance->service->handle, rmsg_handle); + vchiq_release_message(instance->service_handle, rmsg_handle); return ret; } @@ -1034,7 +1034,7 @@ static int enable_component(struct vchiq_mmal_instance *instance, ret = -rmsg->u.component_enable_reply.status; release_msg: - vchiq_release_message(instance->service->handle, rmsg_handle); + vchiq_release_message(instance->service_handle, rmsg_handle); return ret; } @@ -1067,7 +1067,7 @@ static int disable_component(struct vchiq_mmal_instance *instance, release_msg: - vchiq_release_message(instance->service->handle, rmsg_handle); + vchiq_release_message(instance->service_handle, rmsg_handle); return ret; } @@ -1099,7 +1099,7 @@ static int get_version(struct vchiq_mmal_instance *instance, *minor_out = rmsg->u.version.minor; release_msg: - vchiq_release_message(instance->service->handle, rmsg_handle); + vchiq_release_message(instance->service_handle, rmsg_handle); return ret; } @@ -1141,7 +1141,7 @@ static int port_action_port(struct vchiq_mmal_instance *instance, port_action_type_names[action_type], action_type); release_msg: - vchiq_release_message(instance->service->handle, rmsg_handle); + vchiq_release_message(instance->service_handle, rmsg_handle); return ret; } @@ -1189,7 +1189,7 @@ static int port_action_handle(struct vchiq_mmal_instance *instance, action_type, connect_component_handle, connect_port_handle); release_msg: - vchiq_release_message(instance->service->handle, rmsg_handle); + vchiq_release_message(instance->service_handle, rmsg_handle); return ret; } @@ -1230,7 +1230,7 @@ static int port_parameter_set(struct vchiq_mmal_instance *instance, ret, port->component->handle, port->handle, parameter_id); release_msg: - vchiq_release_message(instance->service->handle, rmsg_handle); + vchiq_release_message(instance->service_handle, rmsg_handle); return ret; } @@ -1289,7 +1289,7 @@ static int port_parameter_get(struct vchiq_mmal_instance *instance, ret, port->component->handle, port->handle, parameter_id); release_msg: - vchiq_release_message(instance->service->handle, rmsg_handle); + vchiq_release_message(instance->service_handle, rmsg_handle); return ret; } @@ -1834,9 +1834,9 @@ int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance) if (mutex_lock_interruptible(&instance->vchiq_mutex)) return -EINTR; - vchi_service_use(instance->service); + vchi_service_use(instance->service_handle); - status = vchi_service_close(instance->service); + status = vchi_service_close(instance->service_handle); if (status != 0) pr_err("mmal-vchiq: VCHIQ close failed\n"); @@ -1914,21 +1914,22 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) if (!instance->bulk_wq) goto err_free; - status = vchi_service_open(vchiq_instance, ¶ms, &instance->service); + status = vchi_service_open(vchiq_instance, ¶ms, + &instance->service_handle); if (status) { pr_err("Failed to open VCHI service connection (status=%d)\n", status); goto err_close_services; } - vchi_service_release(instance->service); + vchi_service_release(instance->service_handle); *out_instance = instance; return 0; err_close_services: - vchi_service_close(instance->service); + vchi_service_close(instance->service_handle); destroy_workqueue(instance->bulk_wq); err_free: vfree(instance->bulk_scratch); -- cgit v1.2.3-58-ga151 From 7c018ed10c07f5cd16e8ef661514232e111071cf Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:30 +0200 Subject: staging: vchiq: Pass vchiq's message when holding a message vchi created an opaque structure to be held by services while they process callback messages. The contents of this opaque structure are the service handle, which all services already maintain, and a pointer to vchiq's message structure, struct vchiq_header. Let's get rid of this opaque structure and directly pass struct vchiq_header, which is what ultimately vchiq consumes when handling callback messages. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-33-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchi/vchi.h | 14 ++---------- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 25 ++++++---------------- 2 files changed, 9 insertions(+), 30 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 74fd169e079a..72771fdee9d6 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -11,16 +11,6 @@ // Macros to manipulate 'FOURCC' values #define MAKE_FOURCC(x) ((int32_t)((x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3])) -// Opaque service information -struct opaque_vchi_service_t; - -// Descriptor for a held message. Allocated by client, initialised by vchi_msg_hold, -// vchi_msg_iter_hold or vchi_msg_iter_hold_next. Fields are for internal VCHI use only. -struct vchi_held_msg { - struct opaque_vchi_service_t *service; - void *message; -}; - // Opaque handle for a VCHIQ instance struct vchiq_instance; @@ -67,7 +57,7 @@ extern int vchi_queue_kernel_message(unsigned handle, void *data, extern int32_t vchi_msg_hold(unsigned handle, void **data, // } may be NULL, as info can be uint32_t *msg_size, // } obtained from HELD_MSG_T - struct vchi_held_msg *message_descriptor); + struct vchiq_header **message); /******************************************************************************* * Global service support API - operations on held messages @@ -75,7 +65,7 @@ extern int32_t vchi_msg_hold(unsigned handle, ******************************************************************************/ // Routine to release a held message after it has been processed -extern int32_t vchi_held_msg_release(struct vchi_held_msg *message); +extern int32_t vchi_held_msg_release(unsigned handle, struct vchiq_header *message); /****************************************************************************** * Global bulk API diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 578346965da6..6eb9a9878641 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -113,7 +113,8 @@ EXPORT_SYMBOL(vchi_bulk_queue_transmit); /*********************************************************** * Name: vchi_held_msg_release * - * Arguments: struct vchi_held_msg *message + * Arguments: unsgined handle + * struct vchiq_header *message * * Description: Routine to release a held message (after it has been read with * vchi_msg_hold) @@ -121,7 +122,7 @@ EXPORT_SYMBOL(vchi_bulk_queue_transmit); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_held_msg_release(struct vchi_held_msg *message) +int32_t vchi_held_msg_release(unsigned handle, struct vchiq_header *message) { /* * Convert the service field pointer back to an @@ -131,8 +132,7 @@ int32_t vchi_held_msg_release(struct vchi_held_msg *message) * to a pointer. */ - vchiq_release_message((unsigned int)(long)message->service, - (struct vchiq_header *)message->message); + vchiq_release_message(handle, message); return 0; } @@ -144,7 +144,7 @@ EXPORT_SYMBOL(vchi_held_msg_release); * Arguments: struct vchi_service *service, * void **data, * uint32_t *msg_size, - * struct vchi_held_msg *message_handle + * struct vchiq_header **message * * Description: Routine to return a pointer to the current message (to allow * in place processing). The message is dequeued - don't forget @@ -155,7 +155,7 @@ EXPORT_SYMBOL(vchi_held_msg_release); * ***********************************************************/ int32_t vchi_msg_hold(unsigned handle, void **data, uint32_t *msg_size, - struct vchi_held_msg *message_handle) + struct vchiq_header **message) { struct vchiq_header *header; @@ -165,18 +165,7 @@ int32_t vchi_msg_hold(unsigned handle, void **data, uint32_t *msg_size, *data = header->data; *msg_size = header->size; - - /* - * upcast the unsigned int which is an int - * to a pointer and stuff it in the held message. - * This pointer is opaque to everything except - * vchi_held_msg_release which simply downcasts it back - * to an int. - */ - - message_handle->service = - (struct opaque_vchi_service_t *)(long)handle; - message_handle->message = header; + *message = header; return 0; } -- cgit v1.2.3-58-ga151 From b1d362f408e28220f02d0d73351dc3fa94923c5d Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:31 +0200 Subject: staging: vchi: Rework vchi_msg_hold() to match vchiq_msg_hold() The services have access to struct vchiq_header's internals, so we can let them get the data pointer. This pretty much makes both functions exactly the same, which will allow us to make a switch to vchiq_msg_hold() further down the road. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-34-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchi/vchi.h | 5 +---- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 15 ++------------- 2 files changed, 3 insertions(+), 17 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 72771fdee9d6..59559d4cd5f1 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -54,10 +54,7 @@ extern int vchi_queue_kernel_message(unsigned handle, void *data, // Routine to look at a message in place. // The message is dequeued, so the caller is left holding it; the descriptor is // filled in and must be released when the user has finished with the message. -extern int32_t vchi_msg_hold(unsigned handle, - void **data, // } may be NULL, as info can be - uint32_t *msg_size, // } obtained from HELD_MSG_T - struct vchiq_header **message); +struct vchiq_header *vchi_msg_hold(unsigned handle); /******************************************************************************* * Global service support API - operations on held messages diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 6eb9a9878641..fc12b76617d1 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -154,20 +154,9 @@ EXPORT_SYMBOL(vchi_held_msg_release); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_msg_hold(unsigned handle, void **data, uint32_t *msg_size, - struct vchiq_header **message) +struct vchiq_header *vchi_msg_hold(unsigned handle) { - struct vchiq_header *header; - - header = vchiq_msg_hold(handle); - if (!header) - return -ENOENT; - - *data = header->data; - *msg_size = header->size; - *message = header; - - return 0; + return vchiq_msg_hold(handle); } EXPORT_SYMBOL(vchi_msg_hold); -- cgit v1.2.3-58-ga151 From b06eba5c525aede4ff14dbda1fededc0f71822d6 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:32 +0200 Subject: staging: vchiq: Unify fourcc definition mechanisms There is already enough duplication with regard to fourcc generation in the kernel. Let's at least use the same macro all over the vchiq ecosystem. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-35-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 2 +- drivers/staging/vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h | 5 ++--- drivers/staging/vc04_services/interface/vchi/vchi.h | 3 --- drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h | 1 - drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 2 +- 5 files changed, 4 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 18309578e9a2..55f1e684eef1 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -125,7 +125,7 @@ vc_vchi_audio_init(struct vchiq_instance *vchiq_instance, struct vchiq_service_params params = { .version = VC_AUDIOSERV_VER, .version_min = VC_AUDIOSERV_MIN_VER, - .fourcc = VC_AUDIO_SERVER_NAME, + .fourcc = VCHIQ_MAKE_FOURCC('A', 'U', 'D', 'S'), .callback = audio_vchi_callback, .userdata = instance, }; diff --git a/drivers/staging/vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h b/drivers/staging/vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h index d6401e914ac9..b4fa239c5ebe 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h +++ b/drivers/staging/vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h @@ -8,9 +8,8 @@ #define VC_AUDIOSERV_VER 2 /* FourCC codes used for VCHI communication */ -#define VC_AUDIO_SERVER_NAME MAKE_FOURCC("AUDS") -#define VC_AUDIO_WRITE_COOKIE1 MAKE_FOURCC("BCMA") -#define VC_AUDIO_WRITE_COOKIE2 MAKE_FOURCC("DATA") +#define VC_AUDIO_WRITE_COOKIE1 VCHIQ_MAKE_FOURCC('B', 'C', 'M', 'A') +#define VC_AUDIO_WRITE_COOKIE2 VCHIQ_MAKE_FOURCC('D', 'A', 'T', 'A') /* * List of screens that are currently supported diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 59559d4cd5f1..7108c254a38a 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -8,9 +8,6 @@ * Global defs *****************************************************************************/ -// Macros to manipulate 'FOURCC' values -#define MAKE_FOURCC(x) ((int32_t)((x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3])) - // Opaque handle for a VCHIQ instance struct vchiq_instance; diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h index 91f9b400d8dc..b636e889c8a1 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-msg.h @@ -28,7 +28,6 @@ #define VC_MMAL_VER 15 #define VC_MMAL_MIN_VER 10 -#define VC_MMAL_SERVER_NAME MAKE_FOURCC("mmal") /* max total message size is 512 bytes */ #define MMAL_MSG_MAX_SIZE 512 diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index c960fb7ec890..2c5027c1f0bb 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -1863,7 +1863,7 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) struct vchiq_service_params params = { .version = VC_MMAL_VER, .version_min = VC_MMAL_MIN_VER, - .fourcc = VC_MMAL_SERVER_NAME, + .fourcc = VCHIQ_MAKE_FOURCC('m', 'm', 'a', 'l'), .callback = service_callback, .userdata = NULL, }; -- cgit v1.2.3-58-ga151 From 1a883994efb2582481796fdc37879826f7b1bb75 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:33 +0200 Subject: staging: vchi: Get rid of struct vchiq_instance forward declaration It's already forward declared in vchiq_if.h. So no need to insist Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-36-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchi/vchi.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 7108c254a38a..d24e7027c08f 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -4,13 +4,6 @@ #ifndef VCHI_H_ #define VCHI_H_ -/****************************************************************************** - * Global defs - *****************************************************************************/ - -// Opaque handle for a VCHIQ instance -struct vchiq_instance; - /****************************************************************************** * Global funcs - implementation is specific to which side you are on * (local / remote) -- cgit v1.2.3-58-ga151 From 67a3f7df2195da289d28d2d3d937dce2602f6e47 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:34 +0200 Subject: staging: vchi: Don't include vchiq_core.h This file is internal to vchiq. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-37-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index fc12b76617d1..52654123463d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -8,7 +8,6 @@ #include "vchiq_if.h" #include "../vchi/vchi.h" #include "vchiq.h" -#include "vchiq_core.h" int vchi_queue_kernel_message(unsigned handle, void *data, unsigned int size) { -- cgit v1.2.3-58-ga151 From af948db0211dfb1658bd370dd02c4fbb0a627bba Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:35 +0200 Subject: staging: vchiq: Get rid of unnecessary definitions in vchiq_if.h Those functions don't actually exist, nor have any use, nor the macros. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-38-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_if.h | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index b3d4c14536bd..407e7dc31108 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -8,11 +8,9 @@ #define VCHIQ_SLOT_SIZE 4096 #define VCHIQ_MAX_MSG_SIZE (VCHIQ_SLOT_SIZE - sizeof(struct vchiq_header)) -#define VCHIQ_CHANNEL_SIZE VCHIQ_MAX_MSG_SIZE /* For backwards compatibility */ #define VCHIQ_MAKE_FOURCC(x0, x1, x2, x3) \ (((x0) << 24) | ((x1) << 16) | ((x2) << 8) | (x3)) -#define VCHIQ_GET_SERVICE_USERDATA(service) vchiq_get_service_userdata(service) enum vchiq_reason { VCHIQ_SERVICE_OPENED, /* service, -, - */ @@ -92,7 +90,6 @@ struct vchiq_config { }; struct vchiq_instance; -typedef void (*vchiq_remote_callback)(void *cb_arg); extern enum vchiq_status vchiq_initialise(struct vchiq_instance **pinstance); extern enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance); @@ -118,25 +115,11 @@ extern enum vchiq_status vchiq_bulk_transmit(unsigned int service, extern enum vchiq_status vchiq_bulk_receive(unsigned int service, void *data, unsigned int size, void *userdata, enum vchiq_bulk_mode mode); -extern enum vchiq_status vchiq_bulk_transmit_handle(unsigned int service, - const void *offset, unsigned int size, - void *userdata, enum vchiq_bulk_mode mode); -extern enum vchiq_status vchiq_bulk_receive_handle(unsigned int service, - void *offset, unsigned int size, void *userdata, - enum vchiq_bulk_mode mode); extern int vchiq_get_client_id(unsigned int service); extern void *vchiq_get_service_userdata(unsigned int service); extern void vchiq_get_config(struct vchiq_config *config); extern enum vchiq_status vchiq_set_service_option(unsigned int service, enum vchiq_service_option option, int value); - -extern enum vchiq_status vchiq_remote_use(struct vchiq_instance *instance, - vchiq_remote_callback callback, void *cb_arg); -extern enum vchiq_status vchiq_remote_release(struct vchiq_instance *instance); - -extern enum vchiq_status vchiq_dump_phys_mem(unsigned int service, - void *ptr, size_t num_bytes); - extern enum vchiq_status vchiq_get_peer_version(unsigned int handle, short *peer_version); extern void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header); -- cgit v1.2.3-58-ga151 From 9f10ddbd6fa41b3151a58eeb8702db8d07f6729e Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:36 +0200 Subject: staging: vchiq: Make vchiq_add_service() local The function is being exported although there is no use for it outside of vchiq's core code. Keep it local then. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-39-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 +-- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index dddd5ea5d917..1a050ac116fa 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -271,7 +271,7 @@ failed: } EXPORT_SYMBOL(vchiq_connect); -enum vchiq_status vchiq_add_service( +static enum vchiq_status vchiq_add_service( struct vchiq_instance *instance, const struct vchiq_service_params *params, unsigned int *phandle) @@ -308,7 +308,6 @@ enum vchiq_status vchiq_add_service( return status; } -EXPORT_SYMBOL(vchiq_add_service); enum vchiq_status vchiq_open_service( struct vchiq_instance *instance, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index 407e7dc31108..b852980447dc 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -94,9 +94,6 @@ struct vchiq_instance; extern enum vchiq_status vchiq_initialise(struct vchiq_instance **pinstance); extern enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance); extern enum vchiq_status vchiq_connect(struct vchiq_instance *instance); -extern enum vchiq_status vchiq_add_service(struct vchiq_instance *instance, - const struct vchiq_service_params *params, - unsigned int *pservice); extern enum vchiq_status vchiq_open_service(struct vchiq_instance *instance, const struct vchiq_service_params *params, unsigned int *pservice); -- cgit v1.2.3-58-ga151 From 76dbbe7706f4055ff95fe36901297a1acd7d04f1 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:37 +0200 Subject: staging: vchiq: Move definitions only used by core into core header vchiq_if.h is used by service consumers and only the exported API should be present. Move the rest of definitions, which were not exported by the way, to vchiq_core.h where they belong. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-40-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 22 ++++++++++++++++++++++ .../vc04_services/interface/vchiq_arm/vchiq_if.h | 16 ---------------- 2 files changed, 22 insertions(+), 16 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index b97b661bea1c..ff91c04ba6b9 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -486,6 +486,18 @@ struct bulk_waiter { int actual; }; +struct vchiq_config { + unsigned int max_msg_size; + unsigned int bulk_threshold; /* The message size above which it + is better to use a bulk transfer + (<= max_msg_size) */ + unsigned int max_outstanding_bulks; + unsigned int max_services; + short version; /* The version of VCHIQ */ + short version_min; /* The minimum compatible version of VCHIQ */ +}; + + extern spinlock_t bulk_waiter_spinlock; extern int vchiq_core_log_level; @@ -665,4 +677,14 @@ extern void vchiq_log_dump_mem(const char *label, uint32_t addr, const void *voidMem, size_t numBytes); +extern enum vchiq_status vchiq_remove_service(unsigned int service); + +extern int vchiq_get_client_id(unsigned int service); + +extern void vchiq_get_config(struct vchiq_config *config); + +extern enum vchiq_status +vchiq_set_service_option(unsigned int service, enum vchiq_service_option option, + int value); + #endif diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index b852980447dc..931debcd6492 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -78,17 +78,6 @@ struct vchiq_service_params { short version_min; /* Update for incompatible changes */ }; -struct vchiq_config { - unsigned int max_msg_size; - unsigned int bulk_threshold; /* The message size above which it - is better to use a bulk transfer - (<= max_msg_size) */ - unsigned int max_outstanding_bulks; - unsigned int max_services; - short version; /* The version of VCHIQ */ - short version_min; /* The minimum compatible version of VCHIQ */ -}; - struct vchiq_instance; extern enum vchiq_status vchiq_initialise(struct vchiq_instance **pinstance); @@ -98,7 +87,6 @@ extern enum vchiq_status vchiq_open_service(struct vchiq_instance *instance, const struct vchiq_service_params *params, unsigned int *pservice); extern enum vchiq_status vchiq_close_service(unsigned int service); -extern enum vchiq_status vchiq_remove_service(unsigned int service); extern enum vchiq_status vchiq_use_service(unsigned int service); extern enum vchiq_status vchiq_release_service(unsigned int service); extern enum vchiq_status vchiq_queue_kernel_message(unsigned int handle, @@ -112,11 +100,7 @@ extern enum vchiq_status vchiq_bulk_transmit(unsigned int service, extern enum vchiq_status vchiq_bulk_receive(unsigned int service, void *data, unsigned int size, void *userdata, enum vchiq_bulk_mode mode); -extern int vchiq_get_client_id(unsigned int service); extern void *vchiq_get_service_userdata(unsigned int service); -extern void vchiq_get_config(struct vchiq_config *config); -extern enum vchiq_status vchiq_set_service_option(unsigned int service, - enum vchiq_service_option option, int value); extern enum vchiq_status vchiq_get_peer_version(unsigned int handle, short *peer_version); extern void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header); -- cgit v1.2.3-58-ga151 From b2bbe3dc7667b20b5621211eb827f6b1afed76ca Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:38 +0200 Subject: staging: vchi: Get rid of vchi_bulk_queue_receive() Its vchiq counterpart, vchiq_bulk_receive() is only used by vchi. We can then merge both functions by moving vchi_bulk_queue_receive()'s retry mechanism into vchiq_bulk_receive() and let services call the later. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-41-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchi/vchi.h | 7 ---- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 42 ++++++++++++++-------- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 38 -------------------- .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 20 +++++------ 4 files changed, 37 insertions(+), 70 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index d24e7027c08f..ca20b99122f2 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -58,13 +58,6 @@ extern int32_t vchi_held_msg_release(unsigned handle, struct vchiq_header *messa * Global bulk API *****************************************************************************/ -// Routine to prepare interface for a transfer from the other side -extern int32_t vchi_bulk_queue_receive(unsigned handle, - void *data_dst, - uint32_t data_size, - enum vchiq_bulk_mode mode, - void *transfer_handle); - // Routine to queue up data ready for transfer to the other (once they have signalled they are ready) extern int32_t vchi_bulk_queue_transmit(unsigned handle, const void *data_src, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 1a050ac116fa..1165824711a5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -374,24 +374,36 @@ vchiq_bulk_transmit(unsigned int handle, const void *data, } EXPORT_SYMBOL(vchiq_bulk_transmit); -enum vchiq_status -vchiq_bulk_receive(unsigned int handle, void *data, - unsigned int size, void *userdata, enum vchiq_bulk_mode mode) +enum vchiq_status vchiq_bulk_receive(unsigned int handle, void *data, + unsigned int size, void *userdata, + enum vchiq_bulk_mode mode) { enum vchiq_status status; - switch (mode) { - case VCHIQ_BULK_MODE_NOCALLBACK: - case VCHIQ_BULK_MODE_CALLBACK: - status = vchiq_bulk_transfer(handle, data, size, userdata, - mode, VCHIQ_BULK_RECEIVE); - break; - case VCHIQ_BULK_MODE_BLOCKING: - status = vchiq_blocking_bulk_transfer(handle, - (void *)data, size, VCHIQ_BULK_RECEIVE); - break; - default: - return VCHIQ_ERROR; + while (1) { + switch (mode) { + case VCHIQ_BULK_MODE_NOCALLBACK: + case VCHIQ_BULK_MODE_CALLBACK: + status = vchiq_bulk_transfer(handle, data, size, userdata, + mode, VCHIQ_BULK_RECEIVE); + break; + case VCHIQ_BULK_MODE_BLOCKING: + status = vchiq_blocking_bulk_transfer(handle, + (void *)data, size, VCHIQ_BULK_RECEIVE); + break; + default: + return VCHIQ_ERROR; + } + + /* + * vchiq_*_bulk_transfer() may return VCHIQ_RETRY, so we need + * to implement a retry mechanism since this function is + * supposed to block until queued + */ + if (status != VCHIQ_RETRY) + break; + + msleep(1); } return status; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 52654123463d..f69936a9eb29 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -31,44 +31,6 @@ int vchi_queue_kernel_message(unsigned handle, void *data, unsigned int size) } EXPORT_SYMBOL(vchi_queue_kernel_message); -/*********************************************************** - * Name: vchi_bulk_queue_receive - * - * Arguments: VCHI_BULK_HANDLE_T handle, - * void *data_dst, - * const uint32_t data_size, - * enum vchi_flags flags - * void *bulk_handle - * - * Description: Routine to setup a rcv buffer - * - * Returns: int32_t - success == 0 - * - ***********************************************************/ -int32_t vchi_bulk_queue_receive(unsigned handle, void *data_dst, - uint32_t data_size, enum vchiq_bulk_mode mode, - void *bulk_handle) -{ - enum vchiq_status status; - - while (1) { - status = vchiq_bulk_receive(handle, data_dst, data_size, - bulk_handle, mode); - /* - * vchiq_bulk_receive() may return VCHIQ_RETRY, so we need to - * implement a retry mechanism since this function is supposed - * to block until queued - */ - if (status != VCHIQ_RETRY) - break; - - msleep(1); - } - - return status; -} -EXPORT_SYMBOL(vchi_bulk_queue_receive); - /*********************************************************** * Name: vchi_bulk_queue_transmit * diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 2c5027c1f0bb..4c6a6f4d89fc 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -279,7 +279,7 @@ static void buffer_work_cb(struct work_struct *work) * VCHI will allow up to 4 bulk receives to be scheduled before blocking. * If we block in the service_callback context then we can't process the * VCHI_CALLBACK_BULK_RECEIVED message that would otherwise allow the blocked - * vchi_bulk_queue_receive() call to complete. + * vchiq_bulk_receive() call to complete. */ static void buffer_to_host_work_cb(struct work_struct *work) { @@ -295,19 +295,19 @@ static void buffer_to_host_work_cb(struct work_struct *work) len = 8; /* queue the bulk submission */ vchi_service_use(instance->service_handle); - ret = vchi_bulk_queue_receive(instance->service_handle, - msg_context->u.bulk.buffer->buffer, - /* Actual receive needs to be a multiple - * of 4 bytes - */ - (len + 3) & ~3, - VCHIQ_BULK_MODE_CALLBACK, - msg_context); + ret = vchiq_bulk_receive(instance->service_handle, + msg_context->u.bulk.buffer->buffer, + /* Actual receive needs to be a multiple + * of 4 bytes + */ + (len + 3) & ~3, + msg_context, + VCHIQ_BULK_MODE_CALLBACK); vchi_service_release(instance->service_handle); if (ret != 0) - pr_err("%s: ctx: %p, vchi_bulk_queue_receive failed %d\n", + pr_err("%s: ctx: %p, vchiq_bulk_receive failed %d\n", __func__, msg_context, ret); } -- cgit v1.2.3-58-ga151 From 0bda14fd49a6d0fafa554c87b2167cdd8ee40b6c Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:39 +0200 Subject: staging: vchi: Get rid of vchi_bulk_queue_transmit() Its vchiq counterpart, vchiq_bulk_transmit() is only used by vchi. We can then merge both functions by moving vchi_bulk_queue_transmit()'s retry mechanism into vchiq_bulk_transmit() and let services call the later. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-42-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 7 +-- .../staging/vc04_services/interface/vchi/vchi.h | 11 ---- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 38 ++++++++----- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 66 +++++----------------- 4 files changed, 41 insertions(+), 81 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 55f1e684eef1..28d64bc895cd 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -343,10 +343,9 @@ int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, count = size; if (!instance->max_packet) { /* Send the message to the videocore */ - status = vchi_bulk_queue_transmit(instance->service_handle, - src, count, - VCHIQ_BULK_MODE_BLOCKING, - NULL); + status = vchiq_bulk_transmit(instance->service_handle, src, + count, NULL, + VCHIQ_BULK_MODE_BLOCKING); } else { while (count > 0) { int bytes = min(instance->max_packet, count); diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index ca20b99122f2..c800796f9986 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -54,17 +54,6 @@ struct vchiq_header *vchi_msg_hold(unsigned handle); // Routine to release a held message after it has been processed extern int32_t vchi_held_msg_release(unsigned handle, struct vchiq_header *message); -/****************************************************************************** - * Global bulk API - *****************************************************************************/ - -// Routine to queue up data ready for transfer to the other (once they have signalled they are ready) -extern int32_t vchi_bulk_queue_transmit(unsigned handle, - const void *data_src, - uint32_t data_size, - enum vchiq_bulk_mode mode, - void *transfer_handle); - /****************************************************************************** * Configuration plumbing *****************************************************************************/ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 1165824711a5..98d6fa84deab 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -355,19 +355,31 @@ vchiq_bulk_transmit(unsigned int handle, const void *data, { enum vchiq_status status; - switch (mode) { - case VCHIQ_BULK_MODE_NOCALLBACK: - case VCHIQ_BULK_MODE_CALLBACK: - status = vchiq_bulk_transfer(handle, (void *)data, size, - userdata, mode, - VCHIQ_BULK_TRANSMIT); - break; - case VCHIQ_BULK_MODE_BLOCKING: - status = vchiq_blocking_bulk_transfer(handle, - (void *)data, size, VCHIQ_BULK_TRANSMIT); - break; - default: - return VCHIQ_ERROR; + while (1) { + switch (mode) { + case VCHIQ_BULK_MODE_NOCALLBACK: + case VCHIQ_BULK_MODE_CALLBACK: + status = vchiq_bulk_transfer(handle, (void *)data, size, + userdata, mode, + VCHIQ_BULK_TRANSMIT); + break; + case VCHIQ_BULK_MODE_BLOCKING: + status = vchiq_blocking_bulk_transfer(handle, + (void *)data, size, VCHIQ_BULK_TRANSMIT); + break; + default: + return VCHIQ_ERROR; + } + + /* + * vchiq_*_bulk_transfer() may return VCHIQ_RETRY, so we need + * to implement a retry mechanism since this function is + * supposed to block until queued + */ + if (status != VCHIQ_RETRY) + break; + + msleep(1); } return status; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index f69936a9eb29..33493643b5f8 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -31,46 +31,6 @@ int vchi_queue_kernel_message(unsigned handle, void *data, unsigned int size) } EXPORT_SYMBOL(vchi_queue_kernel_message); -/*********************************************************** - * Name: vchi_bulk_queue_transmit - * - * Arguments: VCHI_BULK_HANDLE_T handle, - * const void *data_src, - * uint32_t data_size, - * enum vchi_flags flags, - * void *bulk_handle - * - * Description: Routine to transmit some data - * - * Returns: int32_t - success == 0 - * - ***********************************************************/ -int32_t vchi_bulk_queue_transmit(unsigned handle, const void *data_src, - uint32_t data_size, enum vchiq_bulk_mode mode, - void *bulk_handle) -{ - enum vchiq_status status; - - while (1) { - status = vchiq_bulk_transmit(handle, data_src, data_size, - bulk_handle, mode); - - /* - * vchiq_bulk_transmit() may return VCHIQ_RETRY, so we need to - * implement a retry mechanism since this function is supposed - * to block until queued - */ - if (status != VCHIQ_RETRY) - break; - - msleep(1); - } - - return status; -} -EXPORT_SYMBOL(vchi_bulk_queue_transmit); - - /*********************************************************** * Name: vchi_held_msg_release * @@ -80,10 +40,10 @@ EXPORT_SYMBOL(vchi_bulk_queue_transmit); * Description: Routine to release a held message (after it has been read with * vchi_msg_hold) * - * Returns: int32_t - success == 0 + * Returns: int - success == 0 * ***********************************************************/ -int32_t vchi_held_msg_release(unsigned handle, struct vchiq_header *message) +int vchi_held_msg_release(unsigned handle, struct vchiq_header *message) { /* * Convert the service field pointer back to an @@ -104,7 +64,7 @@ EXPORT_SYMBOL(vchi_held_msg_release); * * Arguments: struct vchi_service *service, * void **data, - * uint32_t *msg_size, + * unsigned *msg_size, * struct vchiq_header **message * * Description: Routine to return a pointer to the current message (to allow @@ -112,7 +72,7 @@ EXPORT_SYMBOL(vchi_held_msg_release); * to release the message using vchi_held_msg_release when you're * finished. * - * Returns: int32_t - success == 0 + * Returns: int - success == 0 * ***********************************************************/ struct vchiq_header *vchi_msg_hold(unsigned handle) @@ -134,7 +94,7 @@ EXPORT_SYMBOL(vchi_msg_hold); * ***********************************************************/ -int32_t vchi_initialise(struct vchiq_instance **instance) +int vchi_initialise(struct vchiq_instance **instance) { return vchiq_initialise(instance); } @@ -151,7 +111,7 @@ EXPORT_SYMBOL(vchi_initialise); * Returns: 0 if successful, failure otherwise * ***********************************************************/ -int32_t vchi_connect(struct vchiq_instance *instance) +int vchi_connect(struct vchiq_instance *instance) { return vchiq_connect(instance); } @@ -168,7 +128,7 @@ EXPORT_SYMBOL(vchi_connect); * Returns: 0 if successful, failure otherwise * ***********************************************************/ -int32_t vchi_disconnect(struct vchiq_instance *instance) +int vchi_disconnect(struct vchiq_instance *instance) { return vchiq_shutdown(instance); } @@ -184,11 +144,11 @@ EXPORT_SYMBOL(vchi_disconnect); * * Description: Routine to open a service * - * Returns: int32_t - success == 0 + * Returns: int - success == 0 * ***********************************************************/ -int32_t vchi_service_open(struct vchiq_instance *instance, +int vchi_service_open(struct vchiq_instance *instance, struct vchiq_service_params *params, unsigned *handle) { @@ -196,13 +156,13 @@ int32_t vchi_service_open(struct vchiq_instance *instance, } EXPORT_SYMBOL(vchi_service_open); -int32_t vchi_service_close(unsigned handle) +int vchi_service_close(unsigned handle) { return vchiq_close_service(handle); } EXPORT_SYMBOL(vchi_service_close); -int32_t vchi_get_peer_version(unsigned handle, short *peer_version) +int vchi_get_peer_version(unsigned handle, short *peer_version) { return vchiq_get_peer_version(handle, peer_version); } @@ -218,7 +178,7 @@ EXPORT_SYMBOL(vchi_get_peer_version); * Returns: void * ***********************************************************/ -int32_t vchi_service_use(unsigned handle) +int vchi_service_use(unsigned handle) { return vchiq_use_service(handle); } @@ -234,7 +194,7 @@ EXPORT_SYMBOL(vchi_service_use); * Returns: void * ***********************************************************/ -int32_t vchi_service_release(unsigned handle) +int vchi_service_release(unsigned handle) { return vchiq_release_service(handle); } -- cgit v1.2.3-58-ga151 From 5c01fc5c0084e1cb0742cb2a5b704f929733125a Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:40 +0200 Subject: staging: vchi: Move vchi_queue_kernel_message() into vchiq We can't really merge it with vchiq_queue_message() as it has internal users that will not benefit from the retry mechanism vchiq_queue_kernel_message() uses. So, for the sake of getting rid of vchi, move it into vchiq. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-43-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 8 ++++---- .../staging/vc04_services/interface/vchi/vchi.h | 4 ---- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 23 +++++++++++++++++++--- .../vc04_services/interface/vchiq_arm/vchiq_if.h | 4 ++-- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 22 --------------------- .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 14 ++++++------- 6 files changed, 32 insertions(+), 43 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 28d64bc895cd..efaa2ae11f52 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -44,8 +44,8 @@ static int bcm2835_audio_send_msg_locked(struct bcm2835_audio_instance *instance init_completion(&instance->msg_avail_comp); } - status = vchi_queue_kernel_message(instance->service_handle, - m, sizeof(*m)); + status = vchiq_queue_kernel_message(instance->service_handle, + m, sizeof(*m)); if (status) { dev_err(instance->dev, "vchi message queue failed: %d, msg=%d\n", @@ -350,8 +350,8 @@ int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, while (count > 0) { int bytes = min(instance->max_packet, count); - status = vchi_queue_kernel_message(instance->service_handle, - src, bytes); + status = vchiq_queue_kernel_message(instance->service_handle, + src, bytes); src += bytes; count -= bytes; } diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index c800796f9986..6de5df43cc29 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -37,10 +37,6 @@ extern int32_t vchi_service_use(unsigned handle); // Routine to decrement ref count on a named service extern int32_t vchi_service_release(unsigned handle); -/* Routine to send a message from kernel memory across a service */ -extern int vchi_queue_kernel_message(unsigned handle, void *data, - unsigned int size); - // Routine to look at a message in place. // The message is dequeued, so the caller is left holding it; the descriptor is // filled in and must be released when the user has finished with the message. diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index bb69c91c44b0..39d15f9f4a18 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3213,11 +3213,28 @@ error_exit: return status; } -enum vchiq_status vchiq_queue_kernel_message(unsigned int handle, void *context, - size_t size) +int vchiq_queue_kernel_message(unsigned handle, void *data, unsigned size) { - return vchiq_queue_message(handle, memcpy_copy_callback, context, size); + enum vchiq_status status; + + while (1) { + status = vchiq_queue_message(handle, memcpy_copy_callback, + data, size); + + /* + * vchiq_queue_message() may return VCHIQ_RETRY, so we need to + * implement a retry mechanism since this function is supposed + * to block until queued + */ + if (status != VCHIQ_RETRY) + break; + + msleep(1); + } + + return status; } +EXPORT_SYMBOL(vchiq_queue_kernel_message); void vchiq_release_message(unsigned int handle, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index 931debcd6492..6374eda4ea0c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -89,8 +89,8 @@ extern enum vchiq_status vchiq_open_service(struct vchiq_instance *instance, extern enum vchiq_status vchiq_close_service(unsigned int service); extern enum vchiq_status vchiq_use_service(unsigned int service); extern enum vchiq_status vchiq_release_service(unsigned int service); -extern enum vchiq_status vchiq_queue_kernel_message(unsigned int handle, - void *context, size_t size); +extern int vchiq_queue_kernel_message(unsigned handle, void *data, + unsigned size); extern void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header); extern void vchiq_release_message(unsigned int service, struct vchiq_header *header); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 33493643b5f8..57ac6a289a08 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -9,28 +9,6 @@ #include "../vchi/vchi.h" #include "vchiq.h" -int vchi_queue_kernel_message(unsigned handle, void *data, unsigned int size) -{ - enum vchiq_status status; - - while (1) { - status = vchiq_queue_kernel_message(handle, data, size); - - /* - * vchiq_queue_message() may return VCHIQ_RETRY, so we need to - * implement a retry mechanism since this function is supposed - * to block until queued - */ - if (status != VCHIQ_RETRY) - break; - - msleep(1); - } - - return status; -} -EXPORT_SYMBOL(vchi_queue_kernel_message); - /*********************************************************** * Name: vchi_held_msg_release * diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 4c6a6f4d89fc..c7a425db1d29 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -440,10 +440,9 @@ buffer_from_host(struct vchiq_mmal_instance *instance, vchi_service_use(instance->service_handle); - ret = vchi_queue_kernel_message(instance->service_handle, - &m, - sizeof(struct mmal_msg_header) + - sizeof(m.u.buffer_from_host)); + ret = vchiq_queue_kernel_message(instance->service_handle, &m, + sizeof(struct mmal_msg_header) + + sizeof(m.u.buffer_from_host)); vchi_service_release(instance->service_handle); @@ -681,10 +680,9 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, vchi_service_use(instance->service_handle); - ret = vchi_queue_kernel_message(instance->service_handle, - msg, - sizeof(struct mmal_msg_header) + - payload_len); + ret = vchiq_queue_kernel_message(instance->service_handle, msg, + sizeof(struct mmal_msg_header) + + payload_len); vchi_service_release(instance->service_handle); -- cgit v1.2.3-58-ga151 From 9d52311134e969c9cb7ef95c0a6a91b3199441b8 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:41 +0200 Subject: staging: vchiq: Get rid of vchi All the functions that vchi currently provides are a 1:1 mapping to its vchiq counterparts. Get rid of vchi altogether and use vchiq's on all services. In the process also get rid of the vchi directory, as the only remaining file was a TODO file, which now lives in the parent directory. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-44-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/Makefile | 1 - .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 24 +-- .../staging/vc04_services/bcm2835-audio/bcm2835.h | 1 - drivers/staging/vc04_services/interface/TODO | 93 +++++++++++ drivers/staging/vc04_services/interface/vchi/TODO | 93 ----------- .../staging/vc04_services/interface/vchi/vchi.h | 59 ------- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 + .../vc04_services/interface/vchiq_arm/vchiq_core.c | 3 + .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 179 --------------------- .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 29 ++-- 10 files changed, 124 insertions(+), 360 deletions(-) create mode 100644 drivers/staging/vc04_services/interface/TODO delete mode 100644 drivers/staging/vc04_services/interface/vchi/TODO delete mode 100644 drivers/staging/vc04_services/interface/vchi/vchi.h delete mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/Makefile b/drivers/staging/vc04_services/Makefile index 922990919c40..e02a9c2abf77 100644 --- a/drivers/staging/vc04_services/Makefile +++ b/drivers/staging/vc04_services/Makefile @@ -6,7 +6,6 @@ vchiq-objs := \ interface/vchiq_arm/vchiq_arm.o \ interface/vchiq_arm/vchiq_2835_arm.o \ interface/vchiq_arm/vchiq_debugfs.o \ - interface/vchiq_arm/vchiq_shim.o \ interface/vchiq_arm/vchiq_connected.o \ obj-$(CONFIG_SND_BCM2835) += bcm2835-audio/ diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index efaa2ae11f52..8c9ddd86fbbd 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -25,12 +25,12 @@ MODULE_PARM_DESC(force_bulk, "Force use of vchiq bulk for audio"); static void bcm2835_audio_lock(struct bcm2835_audio_instance *instance) { mutex_lock(&instance->vchi_mutex); - vchi_service_use(instance->service_handle); + vchiq_use_service(instance->service_handle); } static void bcm2835_audio_unlock(struct bcm2835_audio_instance *instance) { - vchi_service_release(instance->service_handle); + vchiq_release_service(instance->service_handle); mutex_unlock(&instance->vchi_mutex); } @@ -132,8 +132,8 @@ vc_vchi_audio_init(struct vchiq_instance *vchiq_instance, int status; /* Open the VCHI service connections */ - status = vchi_service_open(vchiq_instance, ¶ms, - &instance->service_handle); + status = vchiq_open_service(vchiq_instance, ¶ms, + &instance->service_handle); if (status) { dev_err(instance->dev, @@ -143,7 +143,7 @@ vc_vchi_audio_init(struct vchiq_instance *vchiq_instance, } /* Finished with the service for now */ - vchi_service_release(instance->service_handle); + vchiq_release_service(instance->service_handle); return 0; } @@ -153,10 +153,10 @@ static void vc_vchi_audio_deinit(struct bcm2835_audio_instance *instance) int status; mutex_lock(&instance->vchi_mutex); - vchi_service_use(instance->service_handle); + vchiq_use_service(instance->service_handle); /* Close all VCHI service connections */ - status = vchi_service_close(instance->service_handle); + status = vchiq_close_service(instance->service_handle); if (status) { dev_err(instance->dev, "failed to close VCHI service connection (status=%d)\n", @@ -171,14 +171,14 @@ int bcm2835_new_vchi_ctx(struct device *dev, struct bcm2835_vchi_ctx *vchi_ctx) int ret; /* Initialize and create a VCHI connection */ - ret = vchi_initialise(&vchi_ctx->instance); + ret = vchiq_initialise(&vchi_ctx->instance); if (ret) { dev_err(dev, "failed to initialise VCHI instance (ret=%d)\n", ret); return -EIO; } - ret = vchi_connect(vchi_ctx->instance); + ret = vchiq_connect(vchi_ctx->instance); if (ret) { dev_dbg(dev, "failed to connect VCHI instance (ret=%d)\n", ret); @@ -195,7 +195,7 @@ int bcm2835_new_vchi_ctx(struct device *dev, struct bcm2835_vchi_ctx *vchi_ctx) void bcm2835_free_vchi_ctx(struct bcm2835_vchi_ctx *vchi_ctx) { /* Close the VCHI connection - it will also free vchi_ctx->instance */ - WARN_ON(vchi_disconnect(vchi_ctx->instance)); + WARN_ON(vchiq_shutdown(vchi_ctx->instance)); vchi_ctx->instance = NULL; } @@ -226,8 +226,8 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) goto deinit; bcm2835_audio_lock(instance); - vchi_get_peer_version(instance->service_handle, - &instance->peer_version); + vchiq_get_peer_version(instance->service_handle, + &instance->peer_version); bcm2835_audio_unlock(instance); if (instance->peer_version < 2 || force_bulk) instance->max_packet = 0; /* bulk transfer */ diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h index 7a0e4ab50fc7..a15f251033ac 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h @@ -10,7 +10,6 @@ #include #include #include "interface/vchiq_arm/vchiq_if.h" -#include "interface/vchi/vchi.h" #define MAX_SUBSTREAMS (8) #define AVAIL_SUBSTREAMS_MASK (0xff) diff --git a/drivers/staging/vc04_services/interface/TODO b/drivers/staging/vc04_services/interface/TODO new file mode 100644 index 000000000000..fc2752bc95b2 --- /dev/null +++ b/drivers/staging/vc04_services/interface/TODO @@ -0,0 +1,93 @@ +1) Import drivers using VCHI. + +VCHI is just a tool to let drivers talk to the firmware. Here are +some of the ones we want: + + - vc_mem (https://github.com/raspberrypi/linux/blob/rpi-4.4.y/drivers/char/broadcom/vc_mem.c) + + This driver is what the vcdbg userspace program uses to set up its + requests to the firmware, which are transmitted across VCHIQ. vcdbg + is really useful for debugging firmware interactions. + + - VCSM (https://github.com/raspberrypi/linux/tree/rpi-4.4.y/drivers/char/broadcom/vc_sm) + + This driver is used for talking about regions of VC memory across + firmware protocols including VCHI. We'll want to extend this driver + to manage these buffers as dmabufs so that we can zero-copy import + camera images into vc4 for rendering/display. + +2) Garbage-collect unused code + +One of the reasons this driver wasn't upstreamed previously was that +there's a lot code that got built that's probably unnecessary these +days. Once we have the set of VCHI-using drivers we want in tree, we +should be able to do a sweep of the code to see what's left that's +unused. + +3) Make driver more portable + +Building this driver with arm/multi_v7_defconfig or arm64/defconfig +leads to data corruption during the following command: + + vchiq_test -f 1 + +This should be fixed. + +4) Fix kernel module support + +Even the VPU firmware doesn't support a VCHI re-connect, the driver +should properly handle a module unload. This also includes that all +resouces must be freed (kthreads, debugfs entries, ...) and global +variables avoided. + +5) Cleanup logging mechanism + +The driver should probably be using the standard kernel logging mechanisms +such as dev_info, dev_dbg, and friends. + +6) Documentation + +A short top-down description of this driver's architecture (function of +kthreads, userspace, limitations) could be very helpful for reviewers. + +7) Review and comment memory barriers + +There is a heavy use of memory barriers in this driver, it would be very +beneficial to go over all of them and, if correct, comment on their merits. +Extra points to whomever confidently reviews the remote_event_*() family of +functions. + +8) Get rid of custom function return values + +Most functions use a custom set of return values, we should force proper Linux +error numbers. Special care is needed for VCHIQ_RETRY. + +9) Reformat core code with more sane indentations + +The code follows the 80 characters limitation yet tends to go 3 or 4 levels of +indentation deep making it very unpleasant to read. This is specially relevant +in the character driver ioctl code and in the core thread functions. + +10) Reorganize file structure: Move char driver to it's own file and join both +platform files + +The cdev is defined alongside with the platform code in vchiq_arm.c. It would +be nice to completely decouple it from the actual core code. For instance to be +able to use bcm2835-audio without having /dev/vchiq created. One could argue +it's better for security reasons or general cleanliness. It could even be +interesting to create two different kernel modules, something the likes of +vchiq-core.ko and vchiq-dev.ko. This would also ease the upstreaming process. + +The code in vchiq_bcm2835_arm.c should fit in the generic platform file. + +12) Get rid of all the struct typedefs + +Most structs are typedefd, it's not encouraged in the kernel. + +13) Get rid of all non essential global structures and create a proper per +device structure + +The first thing one generally sees in a probe function is a memory allocation +for all the device specific data. This structure is then passed all over the +driver. This is good practice since it makes the driver work regardless of the +number of devices probed. diff --git a/drivers/staging/vc04_services/interface/vchi/TODO b/drivers/staging/vc04_services/interface/vchi/TODO deleted file mode 100644 index fc2752bc95b2..000000000000 --- a/drivers/staging/vc04_services/interface/vchi/TODO +++ /dev/null @@ -1,93 +0,0 @@ -1) Import drivers using VCHI. - -VCHI is just a tool to let drivers talk to the firmware. Here are -some of the ones we want: - - - vc_mem (https://github.com/raspberrypi/linux/blob/rpi-4.4.y/drivers/char/broadcom/vc_mem.c) - - This driver is what the vcdbg userspace program uses to set up its - requests to the firmware, which are transmitted across VCHIQ. vcdbg - is really useful for debugging firmware interactions. - - - VCSM (https://github.com/raspberrypi/linux/tree/rpi-4.4.y/drivers/char/broadcom/vc_sm) - - This driver is used for talking about regions of VC memory across - firmware protocols including VCHI. We'll want to extend this driver - to manage these buffers as dmabufs so that we can zero-copy import - camera images into vc4 for rendering/display. - -2) Garbage-collect unused code - -One of the reasons this driver wasn't upstreamed previously was that -there's a lot code that got built that's probably unnecessary these -days. Once we have the set of VCHI-using drivers we want in tree, we -should be able to do a sweep of the code to see what's left that's -unused. - -3) Make driver more portable - -Building this driver with arm/multi_v7_defconfig or arm64/defconfig -leads to data corruption during the following command: - - vchiq_test -f 1 - -This should be fixed. - -4) Fix kernel module support - -Even the VPU firmware doesn't support a VCHI re-connect, the driver -should properly handle a module unload. This also includes that all -resouces must be freed (kthreads, debugfs entries, ...) and global -variables avoided. - -5) Cleanup logging mechanism - -The driver should probably be using the standard kernel logging mechanisms -such as dev_info, dev_dbg, and friends. - -6) Documentation - -A short top-down description of this driver's architecture (function of -kthreads, userspace, limitations) could be very helpful for reviewers. - -7) Review and comment memory barriers - -There is a heavy use of memory barriers in this driver, it would be very -beneficial to go over all of them and, if correct, comment on their merits. -Extra points to whomever confidently reviews the remote_event_*() family of -functions. - -8) Get rid of custom function return values - -Most functions use a custom set of return values, we should force proper Linux -error numbers. Special care is needed for VCHIQ_RETRY. - -9) Reformat core code with more sane indentations - -The code follows the 80 characters limitation yet tends to go 3 or 4 levels of -indentation deep making it very unpleasant to read. This is specially relevant -in the character driver ioctl code and in the core thread functions. - -10) Reorganize file structure: Move char driver to it's own file and join both -platform files - -The cdev is defined alongside with the platform code in vchiq_arm.c. It would -be nice to completely decouple it from the actual core code. For instance to be -able to use bcm2835-audio without having /dev/vchiq created. One could argue -it's better for security reasons or general cleanliness. It could even be -interesting to create two different kernel modules, something the likes of -vchiq-core.ko and vchiq-dev.ko. This would also ease the upstreaming process. - -The code in vchiq_bcm2835_arm.c should fit in the generic platform file. - -12) Get rid of all the struct typedefs - -Most structs are typedefd, it's not encouraged in the kernel. - -13) Get rid of all non essential global structures and create a proper per -device structure - -The first thing one generally sees in a probe function is a memory allocation -for all the device specific data. This structure is then passed all over the -driver. This is good practice since it makes the driver work regardless of the -number of devices probed. diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h deleted file mode 100644 index 6de5df43cc29..000000000000 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ /dev/null @@ -1,59 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ - -#ifndef VCHI_H_ -#define VCHI_H_ - -/****************************************************************************** - * Global funcs - implementation is specific to which side you are on - * (local / remote) - *****************************************************************************/ - -// Routine used to initialise the vchi on both local + remote connections -extern int32_t vchi_initialise(struct vchiq_instance **instance); - -extern int32_t vchi_connect(struct vchiq_instance *instance); - -//When this is called, ensure that all services have no data pending. -//Bulk transfers can remain 'queued' -extern int32_t vchi_disconnect(struct vchiq_instance *instance); - -/****************************************************************************** - * Global service API - *****************************************************************************/ -// Routine to open a named service -extern int vchi_service_open(struct vchiq_instance *instance, - struct vchiq_service_params *params, - unsigned *handle); - -extern int32_t vchi_get_peer_version(unsigned handle, short *peer_version); - -// Routine to close a named service -extern int32_t vchi_service_close(unsigned handle); - -// Routine to increment ref count on a named service -extern int32_t vchi_service_use(unsigned handle); - -// Routine to decrement ref count on a named service -extern int32_t vchi_service_release(unsigned handle); - -// Routine to look at a message in place. -// The message is dequeued, so the caller is left holding it; the descriptor is -// filled in and must be released when the user has finished with the message. -struct vchiq_header *vchi_msg_hold(unsigned handle); - -/******************************************************************************* - * Global service support API - operations on held messages - * and message iterators - ******************************************************************************/ - -// Routine to release a held message after it has been processed -extern int32_t vchi_held_msg_release(unsigned handle, struct vchiq_header *message); - -/****************************************************************************** - * Configuration plumbing - *****************************************************************************/ - -#endif /* VCHI_H_ */ - -/****************************** End of file **********************************/ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 98d6fa84deab..d4d811884861 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -2572,6 +2572,7 @@ vchiq_use_service(unsigned int handle) } return ret; } +EXPORT_SYMBOL(vchiq_use_service); enum vchiq_status vchiq_release_service(unsigned int handle) @@ -2585,6 +2586,7 @@ vchiq_release_service(unsigned int handle) } return ret; } +EXPORT_SYMBOL(vchiq_release_service); struct service_data_struct { int fourcc; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 39d15f9f4a18..1bc4ce577614 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2946,6 +2946,7 @@ vchiq_close_service(unsigned int handle) return status; } +EXPORT_SYMBOL(vchiq_close_service); enum vchiq_status vchiq_remove_service(unsigned int handle) @@ -3268,6 +3269,7 @@ vchiq_release_message(unsigned int handle, unlock_service(service); } +EXPORT_SYMBOL(vchiq_release_message); static void release_message_sync(struct vchiq_state *state, struct vchiq_header *header) @@ -3294,6 +3296,7 @@ exit: unlock_service(service); return status; } +EXPORT_SYMBOL(vchiq_get_peer_version); void vchiq_get_config(struct vchiq_config *config) { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c deleted file mode 100644 index 57ac6a289a08..000000000000 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ /dev/null @@ -1,179 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause -/* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ -#include -#include -#include -#include - -#include "vchiq_if.h" -#include "../vchi/vchi.h" -#include "vchiq.h" - -/*********************************************************** - * Name: vchi_held_msg_release - * - * Arguments: unsgined handle - * struct vchiq_header *message - * - * Description: Routine to release a held message (after it has been read with - * vchi_msg_hold) - * - * Returns: int - success == 0 - * - ***********************************************************/ -int vchi_held_msg_release(unsigned handle, struct vchiq_header *message) -{ - /* - * Convert the service field pointer back to an - * unsigned int which is an int. - * This pointer is opaque to everything except - * vchi_msg_hold which simply upcasted the int - * to a pointer. - */ - - vchiq_release_message(handle, message); - - return 0; -} -EXPORT_SYMBOL(vchi_held_msg_release); - -/*********************************************************** - * Name: vchi_msg_hold - * - * Arguments: struct vchi_service *service, - * void **data, - * unsigned *msg_size, - * struct vchiq_header **message - * - * Description: Routine to return a pointer to the current message (to allow - * in place processing). The message is dequeued - don't forget - * to release the message using vchi_held_msg_release when you're - * finished. - * - * Returns: int - success == 0 - * - ***********************************************************/ -struct vchiq_header *vchi_msg_hold(unsigned handle) -{ - return vchiq_msg_hold(handle); -} -EXPORT_SYMBOL(vchi_msg_hold); - -/*********************************************************** - * Name: vchi_initialise - * - * Arguments: struct vchiq_instance **instance - * - * Description: Initialises the hardware but does not transmit anything - * When run as a Host App this will be called twice hence the need - * to malloc the state information - * - * Returns: 0 if successful, failure otherwise - * - ***********************************************************/ - -int vchi_initialise(struct vchiq_instance **instance) -{ - return vchiq_initialise(instance); -} -EXPORT_SYMBOL(vchi_initialise); - -/*********************************************************** - * Name: vchi_connect - * - * Arguments: struct vchiq_instance *instance - * - * Description: Starts the command service on each connection, - * causing INIT messages to be pinged back and forth - * - * Returns: 0 if successful, failure otherwise - * - ***********************************************************/ -int vchi_connect(struct vchiq_instance *instance) -{ - return vchiq_connect(instance); -} -EXPORT_SYMBOL(vchi_connect); - -/*********************************************************** - * Name: vchi_disconnect - * - * Arguments: struct vchiq_instance *instance - * - * Description: Stops the command service on each connection, - * causing DE-INIT messages to be pinged back and forth - * - * Returns: 0 if successful, failure otherwise - * - ***********************************************************/ -int vchi_disconnect(struct vchiq_instance *instance) -{ - return vchiq_shutdown(instance); -} -EXPORT_SYMBOL(vchi_disconnect); - -/*********************************************************** - * Name: vchi_service_open - * Name: vchi_service_create - * - * Arguments: struct vchiq_instance *instance - * struct service_creation *setup, - * unsigned *handle - * - * Description: Routine to open a service - * - * Returns: int - success == 0 - * - ***********************************************************/ - -int vchi_service_open(struct vchiq_instance *instance, - struct vchiq_service_params *params, - unsigned *handle) -{ - return vchiq_open_service(instance, params, handle); -} -EXPORT_SYMBOL(vchi_service_open); - -int vchi_service_close(unsigned handle) -{ - return vchiq_close_service(handle); -} -EXPORT_SYMBOL(vchi_service_close); - -int vchi_get_peer_version(unsigned handle, short *peer_version) -{ - return vchiq_get_peer_version(handle, peer_version); -} -EXPORT_SYMBOL(vchi_get_peer_version); - -/*********************************************************** - * Name: vchi_service_use - * - * Arguments: unsigned handle - * - * Description: Routine to increment refcount on a service - * - * Returns: void - * - ***********************************************************/ -int vchi_service_use(unsigned handle) -{ - return vchiq_use_service(handle); -} -EXPORT_SYMBOL(vchi_service_use); - -/*********************************************************** - * Name: vchi_service_release - * - * Arguments: unsigned handle - * - * Description: Routine to decrement refcount on a service - * - * Returns: void - * - ***********************************************************/ -int vchi_service_release(unsigned handle) -{ - return vchiq_release_service(handle); -} -EXPORT_SYMBOL(vchi_service_release); diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index c7a425db1d29..a18cc9c9811b 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -30,7 +30,6 @@ #include "mmal-msg.h" #include "interface/vchiq_arm/vchiq_if.h" -#include "interface/vchi/vchi.h" /* * maximum number of components supported. @@ -294,7 +293,7 @@ static void buffer_to_host_work_cb(struct work_struct *work) /* Dummy receive to ensure the buffers remain in order */ len = 8; /* queue the bulk submission */ - vchi_service_use(instance->service_handle); + vchiq_use_service(instance->service_handle); ret = vchiq_bulk_receive(instance->service_handle, msg_context->u.bulk.buffer->buffer, /* Actual receive needs to be a multiple @@ -304,7 +303,7 @@ static void buffer_to_host_work_cb(struct work_struct *work) msg_context, VCHIQ_BULK_MODE_CALLBACK); - vchi_service_release(instance->service_handle); + vchiq_release_service(instance->service_handle); if (ret != 0) pr_err("%s: ctx: %p, vchiq_bulk_receive failed %d\n", @@ -438,13 +437,13 @@ buffer_from_host(struct vchiq_mmal_instance *instance, /* no payload in message */ m.u.buffer_from_host.payload_in_message = 0; - vchi_service_use(instance->service_handle); + vchiq_use_service(instance->service_handle); ret = vchiq_queue_kernel_message(instance->service_handle, &m, sizeof(struct mmal_msg_header) + sizeof(m.u.buffer_from_host)); - vchi_service_release(instance->service_handle); + vchiq_release_service(instance->service_handle); return ret; } @@ -678,13 +677,13 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, DBG_DUMP_MSG(msg, (sizeof(struct mmal_msg_header) + payload_len), ">>> sync message"); - vchi_service_use(instance->service_handle); + vchiq_use_service(instance->service_handle); ret = vchiq_queue_kernel_message(instance->service_handle, msg, sizeof(struct mmal_msg_header) + payload_len); - vchi_service_release(instance->service_handle); + vchiq_release_service(instance->service_handle); if (ret) { pr_err("error %d queuing message\n", ret); @@ -1832,9 +1831,9 @@ int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance) if (mutex_lock_interruptible(&instance->vchiq_mutex)) return -EINTR; - vchi_service_use(instance->service_handle); + vchiq_use_service(instance->service_handle); - status = vchi_service_close(instance->service_handle); + status = vchiq_close_service(instance->service_handle); if (status != 0) pr_err("mmal-vchiq: VCHIQ close failed\n"); @@ -1880,14 +1879,14 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) BUILD_BUG_ON(sizeof(struct mmal_port) != 64); /* create a vchi instance */ - status = vchi_initialise(&vchiq_instance); + status = vchiq_initialise(&vchiq_instance); if (status) { pr_err("Failed to initialise VCHI instance (status=%d)\n", status); return -EIO; } - status = vchi_connect(vchiq_instance); + status = vchiq_connect(vchiq_instance); if (status) { pr_err("Failed to connect VCHI instance (status=%d)\n", status); return -EIO; @@ -1912,22 +1911,22 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) if (!instance->bulk_wq) goto err_free; - status = vchi_service_open(vchiq_instance, ¶ms, - &instance->service_handle); + status = vchiq_open_service(vchiq_instance, ¶ms, + &instance->service_handle); if (status) { pr_err("Failed to open VCHI service connection (status=%d)\n", status); goto err_close_services; } - vchi_service_release(instance->service_handle); + vchiq_release_service(instance->service_handle); *out_instance = instance; return 0; err_close_services: - vchi_service_close(instance->service_handle); + vchiq_close_service(instance->service_handle); destroy_workqueue(instance->bulk_wq); err_free: vfree(instance->bulk_scratch); -- cgit v1.2.3-58-ga151 From 3d212a835ccad24e88a76426f1bef8b1b1836b04 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:42 +0200 Subject: staging: vchiq: Move conditional barrier definition into vchiq_core.h The barrier is only used by core code. So keep the barrier definition in the core header. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-45-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h | 11 ----------- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 12 ++++++++++++ 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h index 211b20705e36..57fe7d5e9a85 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h @@ -6,15 +6,4 @@ #include "vchiq_if.h" -/* Do this so that we can test-build the code on non-rpi systems */ -#if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) - -#else - -#ifndef dsb -#define dsb(a) -#endif - -#endif /* IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) */ - #endif diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index ff91c04ba6b9..15e9867f78f4 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -15,6 +15,18 @@ #include "vchiq.h" +/* Do this so that we can test-build the code on non-rpi systems */ +#if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) + +#else + +#ifndef dsb +#define dsb(a) +#endif + +#endif /* IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) */ + + /* Run time control of log level, based on KERN_XXX level. */ #define VCHIQ_LOG_DEFAULT 4 #define VCHIQ_LOG_ERROR 3 -- cgit v1.2.3-58-ga151 From dcfbf457ae70e21bc2e332ee02943f87f79c4ad9 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:43 +0200 Subject: staging: vchiq: Use vchiq.h as the main header file for services This used to be vchiq_if.h but vchiq.h is more concise for an include file that will hopefully be in the future in the includes directory. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-46-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/bcm2835-audio/bcm2835.h | 2 +- .../vc04_services/interface/vchiq_arm/vchiq.h | 107 +++++++++++++++++++- .../vc04_services/interface/vchiq_arm/vchiq_if.h | 109 --------------------- .../interface/vchiq_arm/vchiq_ioctl.h | 2 +- .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 2 +- 5 files changed, 106 insertions(+), 116 deletions(-) delete mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h index a15f251033ac..ca220f5230ec 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h @@ -9,7 +9,7 @@ #include #include #include -#include "interface/vchiq_arm/vchiq_if.h" +#include "interface/vchiq_arm/vchiq.h" #define MAX_SUBSTREAMS (8) #define AVAIL_SUBSTREAMS_MASK (0xff) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h index 57fe7d5e9a85..04b7ff41a025 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h @@ -1,9 +1,108 @@ /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ -#ifndef VCHIQ_VCHIQ_H -#define VCHIQ_VCHIQ_H +#ifndef VCHIQ_H +#define VCHIQ_H -#include "vchiq_if.h" +#define VCHIQ_SERVICE_HANDLE_INVALID 0 -#endif +#define VCHIQ_SLOT_SIZE 4096 +#define VCHIQ_MAX_MSG_SIZE (VCHIQ_SLOT_SIZE - sizeof(struct vchiq_header)) + +#define VCHIQ_MAKE_FOURCC(x0, x1, x2, x3) \ + (((x0) << 24) | ((x1) << 16) | ((x2) << 8) | (x3)) + +enum vchiq_reason { + VCHIQ_SERVICE_OPENED, /* service, -, - */ + VCHIQ_SERVICE_CLOSED, /* service, -, - */ + VCHIQ_MESSAGE_AVAILABLE, /* service, header, - */ + VCHIQ_BULK_TRANSMIT_DONE, /* service, -, bulk_userdata */ + VCHIQ_BULK_RECEIVE_DONE, /* service, -, bulk_userdata */ + VCHIQ_BULK_TRANSMIT_ABORTED, /* service, -, bulk_userdata */ + VCHIQ_BULK_RECEIVE_ABORTED /* service, -, bulk_userdata */ +}; + +enum vchiq_status { + VCHIQ_ERROR = -1, + VCHIQ_SUCCESS = 0, + VCHIQ_RETRY = 1 +}; + +enum vchiq_bulk_mode { + VCHIQ_BULK_MODE_CALLBACK, + VCHIQ_BULK_MODE_BLOCKING, + VCHIQ_BULK_MODE_NOCALLBACK, + VCHIQ_BULK_MODE_WAITING /* Reserved for internal use */ +}; + +enum vchiq_service_option { + VCHIQ_SERVICE_OPTION_AUTOCLOSE, + VCHIQ_SERVICE_OPTION_SLOT_QUOTA, + VCHIQ_SERVICE_OPTION_MESSAGE_QUOTA, + VCHIQ_SERVICE_OPTION_SYNCHRONOUS, + VCHIQ_SERVICE_OPTION_TRACE +}; + +struct vchiq_header { + /* The message identifier - opaque to applications. */ + int msgid; + + /* Size of message data. */ + unsigned int size; + + char data[0]; /* message */ +}; + +struct vchiq_element { + const void __user *data; + unsigned int size; +}; + +struct vchiq_service_base { + int fourcc; + enum vchiq_status (*callback)(enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, + void *bulk_userdata); + void *userdata; +}; + +struct vchiq_service_params { + int fourcc; + enum vchiq_status (*callback)(enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, + void *bulk_userdata); + void *userdata; + short version; /* Increment for non-trivial changes */ + short version_min; /* Update for incompatible changes */ +}; + +struct vchiq_instance; + +extern enum vchiq_status vchiq_initialise(struct vchiq_instance **pinstance); +extern enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance); +extern enum vchiq_status vchiq_connect(struct vchiq_instance *instance); +extern enum vchiq_status vchiq_open_service(struct vchiq_instance *instance, + const struct vchiq_service_params *params, + unsigned int *pservice); +extern enum vchiq_status vchiq_close_service(unsigned int service); +extern enum vchiq_status vchiq_use_service(unsigned int service); +extern enum vchiq_status vchiq_release_service(unsigned int service); +extern void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header); +extern void vchiq_release_message(unsigned int service, + struct vchiq_header *header); +extern int vchiq_queue_kernel_message(unsigned handle, void *data, + unsigned size); +extern enum vchiq_status vchiq_bulk_transmit(unsigned int service, + const void *data, unsigned int size, void *userdata, + enum vchiq_bulk_mode mode); +extern enum vchiq_status vchiq_bulk_receive(unsigned int service, + void *data, unsigned int size, void *userdata, + enum vchiq_bulk_mode mode); +extern void *vchiq_get_service_userdata(unsigned int service); +extern enum vchiq_status vchiq_get_peer_version(unsigned int handle, + short *peer_version); +extern struct vchiq_header *vchiq_msg_hold(unsigned handle); + +#endif /* VCHIQ_H */ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h deleted file mode 100644 index 6374eda4ea0c..000000000000 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ /dev/null @@ -1,109 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ - -#ifndef VCHIQ_IF_H -#define VCHIQ_IF_H - -#define VCHIQ_SERVICE_HANDLE_INVALID 0 - -#define VCHIQ_SLOT_SIZE 4096 -#define VCHIQ_MAX_MSG_SIZE (VCHIQ_SLOT_SIZE - sizeof(struct vchiq_header)) - -#define VCHIQ_MAKE_FOURCC(x0, x1, x2, x3) \ - (((x0) << 24) | ((x1) << 16) | ((x2) << 8) | (x3)) - -enum vchiq_reason { - VCHIQ_SERVICE_OPENED, /* service, -, - */ - VCHIQ_SERVICE_CLOSED, /* service, -, - */ - VCHIQ_MESSAGE_AVAILABLE, /* service, header, - */ - VCHIQ_BULK_TRANSMIT_DONE, /* service, -, bulk_userdata */ - VCHIQ_BULK_RECEIVE_DONE, /* service, -, bulk_userdata */ - VCHIQ_BULK_TRANSMIT_ABORTED, /* service, -, bulk_userdata */ - VCHIQ_BULK_RECEIVE_ABORTED /* service, -, bulk_userdata */ -}; - -enum vchiq_status { - VCHIQ_ERROR = -1, - VCHIQ_SUCCESS = 0, - VCHIQ_RETRY = 1 -}; - -enum vchiq_bulk_mode { - VCHIQ_BULK_MODE_CALLBACK, - VCHIQ_BULK_MODE_BLOCKING, - VCHIQ_BULK_MODE_NOCALLBACK, - VCHIQ_BULK_MODE_WAITING /* Reserved for internal use */ -}; - -enum vchiq_service_option { - VCHIQ_SERVICE_OPTION_AUTOCLOSE, - VCHIQ_SERVICE_OPTION_SLOT_QUOTA, - VCHIQ_SERVICE_OPTION_MESSAGE_QUOTA, - VCHIQ_SERVICE_OPTION_SYNCHRONOUS, - VCHIQ_SERVICE_OPTION_TRACE -}; - -struct vchiq_header { - /* The message identifier - opaque to applications. */ - int msgid; - - /* Size of message data. */ - unsigned int size; - - char data[0]; /* message */ -}; - -struct vchiq_element { - const void __user *data; - unsigned int size; -}; - -struct vchiq_service_base { - int fourcc; - enum vchiq_status (*callback)(enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, - void *bulk_userdata); - void *userdata; -}; - -struct vchiq_service_params { - int fourcc; - enum vchiq_status (*callback)(enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, - void *bulk_userdata); - void *userdata; - short version; /* Increment for non-trivial changes */ - short version_min; /* Update for incompatible changes */ -}; - -struct vchiq_instance; - -extern enum vchiq_status vchiq_initialise(struct vchiq_instance **pinstance); -extern enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance); -extern enum vchiq_status vchiq_connect(struct vchiq_instance *instance); -extern enum vchiq_status vchiq_open_service(struct vchiq_instance *instance, - const struct vchiq_service_params *params, - unsigned int *pservice); -extern enum vchiq_status vchiq_close_service(unsigned int service); -extern enum vchiq_status vchiq_use_service(unsigned int service); -extern enum vchiq_status vchiq_release_service(unsigned int service); -extern int vchiq_queue_kernel_message(unsigned handle, void *data, - unsigned size); -extern void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header); -extern void vchiq_release_message(unsigned int service, - struct vchiq_header *header); -extern enum vchiq_status vchiq_bulk_transmit(unsigned int service, - const void *data, unsigned int size, void *userdata, - enum vchiq_bulk_mode mode); -extern enum vchiq_status vchiq_bulk_receive(unsigned int service, - void *data, unsigned int size, void *userdata, - enum vchiq_bulk_mode mode); -extern void *vchiq_get_service_userdata(unsigned int service); -extern enum vchiq_status vchiq_get_peer_version(unsigned int handle, - short *peer_version); -extern void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header); -extern struct vchiq_header *vchiq_msg_hold(unsigned handle); - -#endif /* VCHIQ_IF_H */ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 202889b3774f..f285d754ad28 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -5,7 +5,7 @@ #define VCHIQ_IOCTLS_H #include -#include "vchiq_if.h" +#include "vchiq.h" #define VCHIQ_IOC_MAGIC 0xc4 #define VCHIQ_INVALID_HANDLE (~0) diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index a18cc9c9811b..7da9a4c1ac03 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -29,7 +29,7 @@ #include "mmal-vchiq.h" #include "mmal-msg.h" -#include "interface/vchiq_arm/vchiq_if.h" +#include "interface/vchiq_arm/vchiq.h" /* * maximum number of components supported. -- cgit v1.2.3-58-ga151 From 5ada309f4a5f2b317192c469464931be43d10a99 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:44 +0200 Subject: staging: vchiq: Move defines into core header Those are only used in the core vchiq code, while present in vchiq's 'public' API header. Move them into the right place. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-47-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h | 5 ----- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h index 04b7ff41a025..cb9ef9a4150b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h @@ -4,11 +4,6 @@ #ifndef VCHIQ_H #define VCHIQ_H -#define VCHIQ_SERVICE_HANDLE_INVALID 0 - -#define VCHIQ_SLOT_SIZE 4096 -#define VCHIQ_MAX_MSG_SIZE (VCHIQ_SLOT_SIZE - sizeof(struct vchiq_header)) - #define VCHIQ_MAKE_FOURCC(x0, x1, x2, x3) \ (((x0) << 24) | ((x1) << 16) | ((x2) << 8) | (x3)) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 15e9867f78f4..8a27f3d7217e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -26,6 +26,10 @@ #endif /* IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) */ +#define VCHIQ_SERVICE_HANDLE_INVALID 0 + +#define VCHIQ_SLOT_SIZE 4096 +#define VCHIQ_MAX_MSG_SIZE (VCHIQ_SLOT_SIZE - sizeof(struct vchiq_header)) /* Run time control of log level, based on KERN_XXX level. */ #define VCHIQ_LOG_DEFAULT 4 -- cgit v1.2.3-58-ga151 From 2ad4ba07ef1d40a91490ec23c125edd63d68dfda Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Mon, 29 Jun 2020 17:09:45 +0200 Subject: staging: vchiq: Move vchiq.h into include directory To make the separation clear between vchiq's header files and vchiq.h, which is to be used by services and is the 'public' API, move it into a dedicated includes directory. Signed-off-by: Nicolas Saenz Julienne Link: https://lore.kernel.org/r/20200629150945.10720-48-nsaenzjulienne@suse.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/Makefile | 2 +- .../staging/vc04_services/bcm2835-audio/Makefile | 2 +- .../staging/vc04_services/bcm2835-audio/bcm2835.h | 2 +- .../include/linux/raspberrypi/vchiq.h | 103 +++++++++++++++++++++ .../vc04_services/interface/vchiq_arm/vchiq.h | 103 --------------------- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 2 +- .../interface/vchiq_arm/vchiq_ioctl.h | 2 +- drivers/staging/vc04_services/vchiq-mmal/Makefile | 1 + .../staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 3 +- 9 files changed, 110 insertions(+), 110 deletions(-) create mode 100644 drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h delete mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/Makefile b/drivers/staging/vc04_services/Makefile index e02a9c2abf77..7546d70116a0 100644 --- a/drivers/staging/vc04_services/Makefile +++ b/drivers/staging/vc04_services/Makefile @@ -12,5 +12,5 @@ obj-$(CONFIG_SND_BCM2835) += bcm2835-audio/ obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-camera/ obj-$(CONFIG_BCM2835_VCHIQ_MMAL) += vchiq-mmal/ -ccflags-y += -D__VCCOREVER__=0x04000000 +ccflags-y += -I $(srctree)/$(src)/include -D__VCCOREVER__=0x04000000 diff --git a/drivers/staging/vc04_services/bcm2835-audio/Makefile b/drivers/staging/vc04_services/bcm2835-audio/Makefile index 13fa6d7d9745..d59fe4dde615 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/Makefile +++ b/drivers/staging/vc04_services/bcm2835-audio/Makefile @@ -2,4 +2,4 @@ obj-$(CONFIG_SND_BCM2835) += snd-bcm2835.o snd-bcm2835-objs := bcm2835.o bcm2835-ctl.o bcm2835-pcm.o bcm2835-vchiq.o -ccflags-y += -I $(srctree)/$(src)/.. -D__VCCOREVER__=0x04000000 +ccflags-y += -I $(srctree)/$(src)/../include -D__VCCOREVER__=0x04000000 diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h index ca220f5230ec..1b36475872d6 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h @@ -6,10 +6,10 @@ #include #include +#include #include #include #include -#include "interface/vchiq_arm/vchiq.h" #define MAX_SUBSTREAMS (8) #define AVAIL_SUBSTREAMS_MASK (0xff) diff --git a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h new file mode 100644 index 000000000000..cb9ef9a4150b --- /dev/null +++ b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h @@ -0,0 +1,103 @@ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ + +#ifndef VCHIQ_H +#define VCHIQ_H + +#define VCHIQ_MAKE_FOURCC(x0, x1, x2, x3) \ + (((x0) << 24) | ((x1) << 16) | ((x2) << 8) | (x3)) + +enum vchiq_reason { + VCHIQ_SERVICE_OPENED, /* service, -, - */ + VCHIQ_SERVICE_CLOSED, /* service, -, - */ + VCHIQ_MESSAGE_AVAILABLE, /* service, header, - */ + VCHIQ_BULK_TRANSMIT_DONE, /* service, -, bulk_userdata */ + VCHIQ_BULK_RECEIVE_DONE, /* service, -, bulk_userdata */ + VCHIQ_BULK_TRANSMIT_ABORTED, /* service, -, bulk_userdata */ + VCHIQ_BULK_RECEIVE_ABORTED /* service, -, bulk_userdata */ +}; + +enum vchiq_status { + VCHIQ_ERROR = -1, + VCHIQ_SUCCESS = 0, + VCHIQ_RETRY = 1 +}; + +enum vchiq_bulk_mode { + VCHIQ_BULK_MODE_CALLBACK, + VCHIQ_BULK_MODE_BLOCKING, + VCHIQ_BULK_MODE_NOCALLBACK, + VCHIQ_BULK_MODE_WAITING /* Reserved for internal use */ +}; + +enum vchiq_service_option { + VCHIQ_SERVICE_OPTION_AUTOCLOSE, + VCHIQ_SERVICE_OPTION_SLOT_QUOTA, + VCHIQ_SERVICE_OPTION_MESSAGE_QUOTA, + VCHIQ_SERVICE_OPTION_SYNCHRONOUS, + VCHIQ_SERVICE_OPTION_TRACE +}; + +struct vchiq_header { + /* The message identifier - opaque to applications. */ + int msgid; + + /* Size of message data. */ + unsigned int size; + + char data[0]; /* message */ +}; + +struct vchiq_element { + const void __user *data; + unsigned int size; +}; + +struct vchiq_service_base { + int fourcc; + enum vchiq_status (*callback)(enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, + void *bulk_userdata); + void *userdata; +}; + +struct vchiq_service_params { + int fourcc; + enum vchiq_status (*callback)(enum vchiq_reason reason, + struct vchiq_header *header, + unsigned int handle, + void *bulk_userdata); + void *userdata; + short version; /* Increment for non-trivial changes */ + short version_min; /* Update for incompatible changes */ +}; + +struct vchiq_instance; + +extern enum vchiq_status vchiq_initialise(struct vchiq_instance **pinstance); +extern enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance); +extern enum vchiq_status vchiq_connect(struct vchiq_instance *instance); +extern enum vchiq_status vchiq_open_service(struct vchiq_instance *instance, + const struct vchiq_service_params *params, + unsigned int *pservice); +extern enum vchiq_status vchiq_close_service(unsigned int service); +extern enum vchiq_status vchiq_use_service(unsigned int service); +extern enum vchiq_status vchiq_release_service(unsigned int service); +extern void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header); +extern void vchiq_release_message(unsigned int service, + struct vchiq_header *header); +extern int vchiq_queue_kernel_message(unsigned handle, void *data, + unsigned size); +extern enum vchiq_status vchiq_bulk_transmit(unsigned int service, + const void *data, unsigned int size, void *userdata, + enum vchiq_bulk_mode mode); +extern enum vchiq_status vchiq_bulk_receive(unsigned int service, + void *data, unsigned int size, void *userdata, + enum vchiq_bulk_mode mode); +extern void *vchiq_get_service_userdata(unsigned int service); +extern enum vchiq_status vchiq_get_peer_version(unsigned int handle, + short *peer_version); +extern struct vchiq_header *vchiq_msg_hold(unsigned handle); + +#endif /* VCHIQ_H */ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h deleted file mode 100644 index cb9ef9a4150b..000000000000 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h +++ /dev/null @@ -1,103 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ - -#ifndef VCHIQ_H -#define VCHIQ_H - -#define VCHIQ_MAKE_FOURCC(x0, x1, x2, x3) \ - (((x0) << 24) | ((x1) << 16) | ((x2) << 8) | (x3)) - -enum vchiq_reason { - VCHIQ_SERVICE_OPENED, /* service, -, - */ - VCHIQ_SERVICE_CLOSED, /* service, -, - */ - VCHIQ_MESSAGE_AVAILABLE, /* service, header, - */ - VCHIQ_BULK_TRANSMIT_DONE, /* service, -, bulk_userdata */ - VCHIQ_BULK_RECEIVE_DONE, /* service, -, bulk_userdata */ - VCHIQ_BULK_TRANSMIT_ABORTED, /* service, -, bulk_userdata */ - VCHIQ_BULK_RECEIVE_ABORTED /* service, -, bulk_userdata */ -}; - -enum vchiq_status { - VCHIQ_ERROR = -1, - VCHIQ_SUCCESS = 0, - VCHIQ_RETRY = 1 -}; - -enum vchiq_bulk_mode { - VCHIQ_BULK_MODE_CALLBACK, - VCHIQ_BULK_MODE_BLOCKING, - VCHIQ_BULK_MODE_NOCALLBACK, - VCHIQ_BULK_MODE_WAITING /* Reserved for internal use */ -}; - -enum vchiq_service_option { - VCHIQ_SERVICE_OPTION_AUTOCLOSE, - VCHIQ_SERVICE_OPTION_SLOT_QUOTA, - VCHIQ_SERVICE_OPTION_MESSAGE_QUOTA, - VCHIQ_SERVICE_OPTION_SYNCHRONOUS, - VCHIQ_SERVICE_OPTION_TRACE -}; - -struct vchiq_header { - /* The message identifier - opaque to applications. */ - int msgid; - - /* Size of message data. */ - unsigned int size; - - char data[0]; /* message */ -}; - -struct vchiq_element { - const void __user *data; - unsigned int size; -}; - -struct vchiq_service_base { - int fourcc; - enum vchiq_status (*callback)(enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, - void *bulk_userdata); - void *userdata; -}; - -struct vchiq_service_params { - int fourcc; - enum vchiq_status (*callback)(enum vchiq_reason reason, - struct vchiq_header *header, - unsigned int handle, - void *bulk_userdata); - void *userdata; - short version; /* Increment for non-trivial changes */ - short version_min; /* Update for incompatible changes */ -}; - -struct vchiq_instance; - -extern enum vchiq_status vchiq_initialise(struct vchiq_instance **pinstance); -extern enum vchiq_status vchiq_shutdown(struct vchiq_instance *instance); -extern enum vchiq_status vchiq_connect(struct vchiq_instance *instance); -extern enum vchiq_status vchiq_open_service(struct vchiq_instance *instance, - const struct vchiq_service_params *params, - unsigned int *pservice); -extern enum vchiq_status vchiq_close_service(unsigned int service); -extern enum vchiq_status vchiq_use_service(unsigned int service); -extern enum vchiq_status vchiq_release_service(unsigned int service); -extern void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header); -extern void vchiq_release_message(unsigned int service, - struct vchiq_header *header); -extern int vchiq_queue_kernel_message(unsigned handle, void *data, - unsigned size); -extern enum vchiq_status vchiq_bulk_transmit(unsigned int service, - const void *data, unsigned int size, void *userdata, - enum vchiq_bulk_mode mode); -extern enum vchiq_status vchiq_bulk_receive(unsigned int service, - void *data, unsigned int size, void *userdata, - enum vchiq_bulk_mode mode); -extern void *vchiq_get_service_userdata(unsigned int service); -extern enum vchiq_status vchiq_get_peer_version(unsigned int handle, - short *peer_version); -extern struct vchiq_header *vchiq_msg_hold(unsigned handle); - -#endif /* VCHIQ_H */ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 8a27f3d7217e..e67692879249 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -10,10 +10,10 @@ #include #include #include +#include #include "vchiq_cfg.h" -#include "vchiq.h" /* Do this so that we can test-build the code on non-rpi systems */ #if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index f285d754ad28..3653fd99d8a1 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -5,7 +5,7 @@ #define VCHIQ_IOCTLS_H #include -#include "vchiq.h" +#include #define VCHIQ_IOC_MAGIC 0xc4 #define VCHIQ_INVALID_HANDLE (~0) diff --git a/drivers/staging/vc04_services/vchiq-mmal/Makefile b/drivers/staging/vc04_services/vchiq-mmal/Makefile index f8164c33aec3..b2a830f48acc 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/Makefile +++ b/drivers/staging/vc04_services/vchiq-mmal/Makefile @@ -5,4 +5,5 @@ obj-$(CONFIG_BCM2835_VCHIQ_MMAL) += bcm2835-mmal-vchiq.o ccflags-y += \ -I$(srctree)/$(src)/.. \ + -I$(srctree)/$(src)/../include \ -D__VCCOREVER__=0x04000000 diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 7da9a4c1ac03..a075cd63da7f 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -23,14 +23,13 @@ #include #include #include +#include #include #include "mmal-common.h" #include "mmal-vchiq.h" #include "mmal-msg.h" -#include "interface/vchiq_arm/vchiq.h" - /* * maximum number of components supported. * This matches the maximum permitted by default on the VPU -- cgit v1.2.3-58-ga151 From c4199169a510db57d0a1fd2c2c295b6b1dcfad84 Mon Sep 17 00:00:00 2001 From: Simon Fong Date: Tue, 30 Jun 2020 10:22:28 +0800 Subject: staging: rtl8188eu: core: Fix WARNING of Block comments Fixed a WARNING of Block comments use * on subsequent lines. Signed-off-by: Simon Fong Link: https://lore.kernel.org/r/20200630022228.GA580@simon-pc Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 44579f7cab87..282d0f869758 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -155,12 +155,12 @@ int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue) } /* -caller : defrag ; recvframe_chk_defrag in recv_thread (passive) -pframequeue: defrag_queue : will be accessed in recv_thread (passive) - -using spinlock to protect - -*/ + * caller : defrag ; recvframe_chk_defrag in recv_thread (passive) + * pframequeue: defrag_queue : will be accessed in recv_thread (passive) + * + * using spinlock to protect + * + */ void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue) { -- cgit v1.2.3-58-ga151 From efa30b82ac7553c25405ac56034aecf03c182033 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Wed, 1 Jul 2020 20:24:57 +0530 Subject: staging: rtl8188eu: core: Fix coding style issue Use %s and __func__ in place of function names. This solves following checkpatch.pl warning WARNING: Prefer using '"%s...", __func__' to using 'rtw_do_join', this function's name, in a string Signed-off-by: Puranjay Mohan Link: https://lore.kernel.org/r/20200701145457.9562-1-puranjay12@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ioctl_set.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index 7bb26c362b10..9cc77ab4fd6b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -25,7 +25,7 @@ u8 rtw_do_join(struct adapter *padapter) phead = get_list_head(queue); plist = phead->next; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("\n rtw_do_join: phead = %p; plist = %p\n\n\n", phead, plist)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("\n %s: phead = %p; plist = %p\n\n\n", __func__, phead, plist)); pmlmepriv->cur_network.join_res = -2; -- cgit v1.2.3-58-ga151 From 959cc33988436be6cadf86850dab0d8d125f7c43 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 2 Jul 2020 09:17:40 +0200 Subject: staging: wilc1000: remove obsolete TODO file The movement of wilc1000 out of staging left an obsolete TODO file. Remove that as it's no longer needed. Cc: Kalle Valo Cc: Cc: Cc: Cc: Cc: Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/TODO | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 drivers/staging/wilc1000/TODO (limited to 'drivers/staging') diff --git a/drivers/staging/wilc1000/TODO b/drivers/staging/wilc1000/TODO deleted file mode 100644 index 862e9eac9d60..000000000000 --- a/drivers/staging/wilc1000/TODO +++ /dev/null @@ -1,3 +0,0 @@ -TODO: -- support soft-ap and p2p mode -- support resume/suspend function -- cgit v1.2.3-58-ga151 From 69b2e08a8b0a332f0a257864acf52a9c9aebc3c4 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 1 Jul 2020 18:54:59 +0200 Subject: staging: rtl8188eu: remove unused parameter Remove unused parameter 'padapter' from rtw_os_xmit_resource_alloc(). Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200701165459.8904-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_xmit.c | 6 +++--- drivers/staging/rtl8188eu/include/xmit_osdep.h | 3 +-- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 258531bc1408..1b12afd33d95 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -124,10 +124,10 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitbuf->ext_tag = false; /* Tx buf allocation may fail sometimes, so sleep and retry. */ - res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); + res = rtw_os_xmit_resource_alloc(pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); if (res == _FAIL) { msleep(10); - res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); + res = rtw_os_xmit_resource_alloc(pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); if (res == _FAIL) goto exit; } @@ -162,7 +162,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitbuf->padapter = padapter; pxmitbuf->ext_tag = true; - res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ); + res = rtw_os_xmit_resource_alloc(pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ); if (res == _FAIL) { res = _FAIL; goto exit; diff --git a/drivers/staging/rtl8188eu/include/xmit_osdep.h b/drivers/staging/rtl8188eu/include/xmit_osdep.h index 5283a6d53700..5fd8ca51f156 100644 --- a/drivers/staging/rtl8188eu/include/xmit_osdep.h +++ b/drivers/staging/rtl8188eu/include/xmit_osdep.h @@ -22,8 +22,7 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev); void rtw_os_xmit_schedule(struct adapter *padapter); -int rtw_os_xmit_resource_alloc(struct adapter *padapter, - struct xmit_buf *pxmitbuf, u32 alloc_sz); +int rtw_os_xmit_resource_alloc(struct xmit_buf *pxmitbuf, u32 alloc_sz); void rtw_os_xmit_resource_free(struct xmit_buf *pxmitbuf); void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt); diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 017e1d628461..3ca1dc30efb7 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -14,8 +14,7 @@ #include #include -int rtw_os_xmit_resource_alloc(struct adapter *padapter, - struct xmit_buf *pxmitbuf, u32 alloc_sz) +int rtw_os_xmit_resource_alloc(struct xmit_buf *pxmitbuf, u32 alloc_sz) { int i; -- cgit v1.2.3-58-ga151 From 40c79667166b6eae6f9bcc6b576ca3f24d925b1b Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 1 Jul 2020 20:29:57 +0200 Subject: staging: rtl8188eu: use common ieee80211 constants Many defined constants in wifi.h are unused and/or available from , some with slightly different names. Use the common ones, rename where necessary and remove unused. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200701182957.7932-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 12 +++---- drivers/staging/rtl8188eu/core/rtw_mlme.c | 6 ++-- drivers/staging/rtl8188eu/include/wifi.h | 46 -------------------------- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 2 +- 4 files changed, 10 insertions(+), 56 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 817793b9aff2..41535441f82c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -535,7 +535,7 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) /* bwmode */ if (le16_to_cpu(phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & - IEEE80211_HT_CAP_SUP_WIDTH) { + IEEE80211_HT_CAP_SUP_WIDTH_20_40) { phtpriv_sta->bwmode = pmlmeext->cur_bwmode; phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; } @@ -925,12 +925,12 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) - pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY & (0x07 << 2)); + pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & (0x07 << 2)); else - pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00); + pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00); /* set Max Rx AMPDU size to 64K */ - pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_FACTOR & 0x03); + pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_FACTOR & 0x03); pht_cap->mcs.rx_mask[0] = 0xff; pht_cap->mcs.rx_mask[1] = 0x0; @@ -1307,7 +1307,7 @@ static int rtw_ht_operation_update(struct adapter *padapter) (pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)) new_op_mode = OP_MODE_MIXED; else if ((le16_to_cpu(phtpriv_ap->ht_cap.cap_info) & - IEEE80211_HT_CAP_SUP_WIDTH) && + IEEE80211_HT_CAP_SUP_WIDTH_20_40) && pmlmepriv->num_sta_ht_20mhz) new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED; else if (pmlmepriv->olbc_ht) @@ -1457,7 +1457,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) pmlmepriv->num_sta_ht_no_gf); } - if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH) == 0) { + if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH_20_40) == 0) { if (!psta->ht_20mhz_set) { psta->ht_20mhz_set = 1; pmlmepriv->num_sta_ht_20mhz++; diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index b291ee6ca8f4..5d7a749f1aac 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -1882,7 +1882,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ memset(&ht_cap, 0, sizeof(struct ieee80211_ht_cap)); - ht_cap.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH | + ht_cap.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_TX_STBC | @@ -1900,9 +1900,9 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ ht_cap.ampdu_params_info = max_rx_ampdu_factor & 0x03; if (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) - ht_cap.ampdu_params_info |= IEEE80211_HT_CAP_AMPDU_DENSITY & (0x07 << 2); + ht_cap.ampdu_params_info |= IEEE80211_HT_AMPDU_PARM_DENSITY & (0x07 << 2); else - ht_cap.ampdu_params_info |= IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00; + ht_cap.ampdu_params_info |= IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00; rtw_set_ie(out_ie + out_len, _HT_CAPABILITY_IE_, sizeof(struct ieee80211_ht_cap), diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h index e12e3d0a45e0..791f287a546d 100644 --- a/drivers/staging/rtl8188eu/include/wifi.h +++ b/drivers/staging/rtl8188eu/include/wifi.h @@ -499,52 +499,6 @@ enum ht_cap_ampdu_factor { MAX_AMPDU_FACTOR_64K = 3, }; -/* 802.11n HT capabilities masks */ -#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002 -#define IEEE80211_HT_CAP_SM_PS 0x000C -#define IEEE80211_HT_CAP_GRN_FLD 0x0010 -#define IEEE80211_HT_CAP_SGI_20 0x0020 -#define IEEE80211_HT_CAP_SGI_40 0x0040 -#define IEEE80211_HT_CAP_TX_STBC 0x0080 -#define IEEE80211_HT_CAP_RX_STBC 0x0300 -#define IEEE80211_HT_CAP_DELAY_BA 0x0400 -#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800 -#define IEEE80211_HT_CAP_DSSSCCK40 0x1000 -/* 802.11n HT capability AMPDU settings */ -#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03 -#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C -/* 802.11n HT capability MSC set */ -#define IEEE80211_SUPP_MCS_SET_UEQM 4 -#define IEEE80211_HT_CAP_MAX_STREAMS 4 -#define IEEE80211_SUPP_MCS_SET_LEN 10 -/* maximum streams the spec allows */ -#define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01 -#define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02 -#define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C -#define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10 -/* 802.11n HT IE masks */ -#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03 -#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00 -#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01 -#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03 -#define IEEE80211_HT_IE_CHA_WIDTH 0x04 -#define IEEE80211_HT_IE_HT_PROTECTION 0x0003 -#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004 -#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010 - -/* block-ack parameters */ -#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002 -#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C -#define RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0 -#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000 -#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800 - -/* - * A-PMDU buffer sizes - * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2) - */ -#define IEEE80211_MIN_AMPDU_BUF 0x8 - #define OP_MODE_PURE 0 #define OP_MODE_MAY_BE_LEGACY_STAS 1 #define OP_MODE_20MHZ_HT_STA_ASSOCED 2 diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 38484dffe095..5e6f7f0ed009 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -129,7 +129,7 @@ static char *translate_scan(struct adapter *padapter, pht_capie = (struct ieee80211_ht_cap *)(p + 2); memcpy(&mcs_rate, pht_capie->mcs.rx_mask, 2); bw_40MHz = !!(le16_to_cpu(pht_capie->cap_info) & - IEEE80211_HT_CAP_SUP_WIDTH); + IEEE80211_HT_CAP_SUP_WIDTH_20_40); short_GI = !!(le16_to_cpu(pht_capie->cap_info) & (IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40)); -- cgit v1.2.3-58-ga151 From d9ff039a29dd36e962c808cded1547ced3beafd6 Mon Sep 17 00:00:00 2001 From: Simon Fong Date: Thu, 2 Jul 2020 23:44:19 +0800 Subject: staging: rtl8188eu: Fix CHECK of coding style Fixed a CHECK of Lines should not end with a '('. Signed-off-by: Simon Fong Link: https://lore.kernel.org/r/9f1f9d7d4723aa8d9bc2d7149fd01aacc1191860.1593703689.git.simon.fodin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 282d0f869758..656fe70ae4fb 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -702,10 +702,9 @@ exit: return ret; } -static int ap2sta_data_frame( - struct adapter *adapter, - struct recv_frame *precv_frame, - struct sta_info **psta) +static int ap2sta_data_frame(struct adapter *adapter, + struct recv_frame *precv_frame, + struct sta_info **psta) { u8 *ptr = precv_frame->pkt->data; struct rx_pkt_attrib *pattrib = &precv_frame->attrib; -- cgit v1.2.3-58-ga151 From ee53f6dd709ed2c55c3603beeec494b02c5831c3 Mon Sep 17 00:00:00 2001 From: Simon Fong Date: Thu, 2 Jul 2020 23:44:20 +0800 Subject: staging: rtl8188eu: Fix WARNINGs of Block comments Fixed 5 WARNINGs of Block comments use * on subsequent lines. Signed-off-by: Simon Fong Link: https://lore.kernel.org/r/239f5c7f4761dd2ef0df8ee6966fca8ed2a13a9c.1593703689.git.simon.fodin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_xmit.c | 62 +++++++++++++++---------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 1b12afd33d95..d3b1b32bbf76 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -49,8 +49,8 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) spin_lock_init(&pxmitpriv->lock); /* - Please insert all the queue initializaiton using _rtw_init_queue below - */ + * Please insert all the queue initializaiton using _rtw_init_queue below + */ pxmitpriv->adapter = padapter; @@ -63,10 +63,10 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) _rtw_init_queue(&pxmitpriv->free_xmit_queue); /* - Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME, - and initialize free_xmit_frame below. - Please also apply free_txobj to link_up all the xmit_frames... - */ + * Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME, + * and initialize free_xmit_frame below. + * Please also apply free_txobj to link_up all the xmit_frames... + */ pxmitpriv->pallocated_frame_buf = vzalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); @@ -893,17 +893,17 @@ s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pat } /* - -This sub-routine will perform all the following: - -1. remove 802.3 header. -2. create wlan_header, based on the info in pxmitframe -3. append sta's iv/ext-iv -4. append LLC -5. move frag chunk from pframe to pxmitframe->mem -6. apply sw-encrypt, if necessary. - -*/ + * + * This sub-routine will perform all the following: + * + * 1. remove 802.3 header. + * 2. create wlan_header, based on the info in pxmitframe + * 3. append sta's iv/ext-iv + * 4. append LLC + * 5. move frag chunk from pframe to pxmitframe->mem + * 6. apply sw-encrypt, if necessary. + * + */ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe) { s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz; @@ -1233,25 +1233,25 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) } /* -Calling context: -1. OS_TXENTRY -2. RXENTRY (rx_thread or RX_ISR/RX_CallBack) - -If we turn on USE_RXTHREAD, then, no need for critical section. -Otherwise, we must use _enter/_exit critical to protect free_xmit_queue... - -Must be very very cautious... - -*/ + * Calling context: + * 1. OS_TXENTRY + * 2. RXENTRY (rx_thread or RX_ISR/RX_CallBack) + * + * If we turn on USE_RXTHREAD, then, no need for critical section. + * Otherwise, we must use _enter/_exit critical to protect free_xmit_queue... + * + * Must be very very cautious... + * + */ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv) /* _queue *pfree_xmit_queue) */ { /* - Please remember to use all the osdep_service api, - and lock/unlock or _enter/_exit critical to protect - pfree_xmit_queue - */ + * Please remember to use all the osdep_service api, + * and lock/unlock or _enter/_exit critical to protect + * pfree_xmit_queue + */ struct xmit_frame *pxframe; struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; -- cgit v1.2.3-58-ga151 From bd7a168a024dcfbc4db7fb79a51c8b574f55b527 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 1 Jul 2020 18:42:13 +0200 Subject: staging: rtl8712: use common ieee80211 constants Many defined constants in wifi.h are unused and/or available from , some with slightly different names. Use the common ones, rename where necessary and remove unused. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200701164213.4205-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 2 +- drivers/staging/rtl8712/rtl871x_mlme.c | 8 ++--- drivers/staging/rtl8712/wifi.h | 51 --------------------------- 3 files changed, 5 insertions(+), 56 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 36c89cde525d..81482d5ae1a3 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -1411,7 +1411,7 @@ static int r8711_wx_get_rate(struct net_device *dev, pht_capie = (struct rtl_ieee80211_ht_cap *)(p + 2); memcpy(&mcs_rate, pht_capie->supp_mcs_set, 2); bw_40MHz = (le16_to_cpu(pht_capie->cap_info) & - IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0; + IEEE80211_HT_CAP_SUP_WIDTH_20_40) ? 1 : 0; short_GI = (le16_to_cpu(pht_capie->cap_info) & (IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40)) ? 1 : 0; diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index efd75add8e35..9ee1bfac0763 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -1660,14 +1660,14 @@ unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie, } out_len = *pout_len; memset(&ht_capie, 0, sizeof(struct rtl_ieee80211_ht_cap)); - ht_capie.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH | + ht_capie.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_TX_STBC | IEEE80211_HT_CAP_MAX_AMSDU | IEEE80211_HT_CAP_DSSSCCK40); - ht_capie.ampdu_params_info = (IEEE80211_HT_CAP_AMPDU_FACTOR & - 0x03) | (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00); + ht_capie.ampdu_params_info = (IEEE80211_HT_AMPDU_PARM_FACTOR & + 0x03) | (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00); r8712_set_ie(out_ie + out_len, _HT_CAPABILITY_IE_, sizeof(struct rtl_ieee80211_ht_cap), (unsigned char *)&ht_capie, pout_len); @@ -1705,7 +1705,7 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len) if (p && len > 0) { pht_capie = (struct rtl_ieee80211_ht_cap *)(p + 2); max_ampdu_sz = (pht_capie->ampdu_params_info & - IEEE80211_HT_CAP_AMPDU_FACTOR); + IEEE80211_HT_AMPDU_PARM_FACTOR); /* max_ampdu_sz (kbytes); */ max_ampdu_sz = 1 << (max_ampdu_sz + 3); phtpriv->rx_ampdu_maxlen = max_ampdu_sz; diff --git a/drivers/staging/rtl8712/wifi.h b/drivers/staging/rtl8712/wifi.h index 66e0634f07ba..601d4ff607bc 100644 --- a/drivers/staging/rtl8712/wifi.h +++ b/drivers/staging/rtl8712/wifi.h @@ -437,13 +437,6 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe) *------------------------------------------------------------------------------ */ -/* block-ack parameters */ -#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002 -#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C -#define IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0 -#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000 -#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800 - #define SetOrderBit(pbuf) ({ \ *(__le16 *)(pbuf) |= cpu_to_le16(_ORDER_); \ }) @@ -481,49 +474,5 @@ struct ieee80211_ht_addt_info { unsigned char basic_set[16]; } __packed; -/* 802.11n HT capabilities masks */ -#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002 -#define IEEE80211_HT_CAP_SM_PS 0x000C -#define IEEE80211_HT_CAP_GRN_FLD 0x0010 -#define IEEE80211_HT_CAP_SGI_20 0x0020 -#define IEEE80211_HT_CAP_SGI_40 0x0040 -#define IEEE80211_HT_CAP_TX_STBC 0x0080 -#define IEEE80211_HT_CAP_DELAY_BA 0x0400 -#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800 -#define IEEE80211_HT_CAP_DSSSCCK40 0x1000 -/* 802.11n HT capability AMPDU settings */ -#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03 -#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C -/* 802.11n HT capability MSC set */ -#define IEEE80211_SUPP_MCS_SET_UEQM 4 -#define IEEE80211_HT_CAP_MAX_STREAMS 4 -#define IEEE80211_SUPP_MCS_SET_LEN 10 -/* maximum streams the spec allows */ -#define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01 -#define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02 -#define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C -#define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10 -/* 802.11n HT IE masks */ -#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03 -#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00 -#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01 -#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03 -#define IEEE80211_HT_IE_CHA_WIDTH 0x04 -#define IEEE80211_HT_IE_HT_PROTECTION 0x0003 -#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004 -#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010 - -/* - * A-PMDU buffer sizes - * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2) - */ -#define IEEE80211_MIN_AMPDU_BUF 0x8 - -/* Spatial Multiplexing Power Save Modes */ -#define WLAN_HT_CAP_SM_PS_STATIC 0 -#define WLAN_HT_CAP_SM_PS_DYNAMIC 1 -#define WLAN_HT_CAP_SM_PS_INVALID 2 -#define WLAN_HT_CAP_SM_PS_DISABLED 3 - #endif /* _WIFI_H_ */ -- cgit v1.2.3-58-ga151 From 2becc421c9f5d161a06869066336b02874533380 Mon Sep 17 00:00:00 2001 From: Mauro Dreissig Date: Wed, 1 Jul 2020 18:44:19 -0300 Subject: staging: rtl8712: Replace FIELD_OFFSET() with offsetof() Use the existing offsetof() macro instead of duplicating code. Signed-off-by: Mauro Dreissig Link: https://lore.kernel.org/r/20200701214420.5566-2-mukadr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/basic_types.h | 1 - drivers/staging/rtl8712/hal_init.c | 4 ++-- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/basic_types.h b/drivers/staging/rtl8712/basic_types.h index 4ad7f35b1644..b8ecd92ca9d4 100644 --- a/drivers/staging/rtl8712/basic_types.h +++ b/drivers/staging/rtl8712/basic_types.h @@ -21,7 +21,6 @@ #define SIZE_T __kernel_size_t #define sint signed int -#define FIELD_OFFSET(s, field) ((addr_t)&((s *)(0))->field) /* Should we extend this to be host_addr_t and target_addr_t for case: * host : x86_64 diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index 40145c0338e4..7293cdc3a43b 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -133,7 +133,7 @@ static u8 chk_fwhdr(struct fw_hdr *pfwhdr, u32 ulfilelength) if (pfwhdr->fw_priv_sz != sizeof(struct fw_priv)) return _FAIL; /* check fw_sz & image_fw_sz */ - fwhdrsz = FIELD_OFFSET(struct fw_hdr, fwpriv) + pfwhdr->fw_priv_sz; + fwhdrsz = offsetof(struct fw_hdr, fwpriv) + pfwhdr->fw_priv_sz; fw_sz = fwhdrsz + pfwhdr->img_IMEM_size + pfwhdr->img_SRAM_size + pfwhdr->dmem_size; if (fw_sz != ulfilelength) @@ -173,7 +173,7 @@ static u8 rtl8712_dl_fw(struct _adapter *adapter) txdesc = (struct tx_desc *)(tmpchar + FWBUFF_ALIGN_SZ - ((addr_t)(tmpchar) & (FWBUFF_ALIGN_SZ - 1))); payload = (u8 *)(txdesc) + txdscp_sz; - ptr = (u8 *)mappedfw + FIELD_OFFSET(struct fw_hdr, fwpriv) + + ptr = (u8 *)mappedfw + offsetof(struct fw_hdr, fwpriv) + fwhdr.fw_priv_sz; /* Download FirmWare */ /* 1. determine IMEM code size and Load IMEM Code Section */ diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 81482d5ae1a3..c6f6ccd060bb 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -407,7 +407,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, return -ENOMEM; pwep->KeyLength = wep_key_len; pwep->Length = wep_key_len + - FIELD_OFFSET(struct NDIS_802_11_WEP, KeyMaterial); + offsetof(struct NDIS_802_11_WEP, KeyMaterial); if (wep_key_len == 13) { padapter->securitypriv.PrivacyAlgrthm = _WEP104_; padapter->securitypriv.XGrpPrivacy = _WEP104_; @@ -1555,7 +1555,7 @@ static int r8711_wx_set_enc(struct net_device *dev, if (erq->length > 0) { wep.KeyLength = erq->length <= 5 ? 5 : 13; wep.Length = wep.KeyLength + - FIELD_OFFSET(struct NDIS_802_11_WEP, KeyMaterial); + offsetof(struct NDIS_802_11_WEP, KeyMaterial); } else { wep.KeyLength = 0; if (keyindex_provided == 1) { /* set key_id only, no given -- cgit v1.2.3-58-ga151 From 0f6ba599691fecf898daf445f49c932a1413bb73 Mon Sep 17 00:00:00 2001 From: Mauro Dreissig Date: Wed, 1 Jul 2020 18:44:20 -0300 Subject: staging: rtl8712: base_types: Remove unused macros Those #define's are not used anywhere, get rid of them. Signed-off-by: Mauro Dreissig Link: https://lore.kernel.org/r/20200701214420.5566-3-mukadr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/basic_types.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/basic_types.h b/drivers/staging/rtl8712/basic_types.h index b8ecd92ca9d4..aecded87dd4c 100644 --- a/drivers/staging/rtl8712/basic_types.h +++ b/drivers/staging/rtl8712/basic_types.h @@ -14,12 +14,8 @@ #ifndef __BASIC_TYPES_H__ #define __BASIC_TYPES_H__ -#define SUCCESS 0 -#define FAIL (-1) - #include -#define SIZE_T __kernel_size_t #define sint signed int /* Should we extend this to be host_addr_t and target_addr_t for case: @@ -28,8 +24,5 @@ */ #define addr_t unsigned long -#define MEM_ALIGNMENT_OFFSET (sizeof(SIZE_T)) -#define MEM_ALIGNMENT_PADDING (sizeof(SIZE_T) - 1) - #endif /*__BASIC_TYPES_H__*/ -- cgit v1.2.3-58-ga151 From 7566103ea5dd7a4062d604c70b5c180711e80219 Mon Sep 17 00:00:00 2001 From: Suraj Upadhyay Date: Thu, 2 Jul 2020 14:10:22 +0530 Subject: staging: qlge: qlge_ethtool.c: Proper indentation. Remove extra indentations from if-statement. Signed-off-by: Suraj Upadhyay Link: https://lore.kernel.org/r/20200702084022.GA1586@blackclown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_ethtool.c b/drivers/staging/qlge/qlge_ethtool.c index 949abd53a7a9..16fcdefa9687 100644 --- a/drivers/staging/qlge/qlge_ethtool.c +++ b/drivers/staging/qlge/qlge_ethtool.c @@ -528,8 +528,8 @@ void ql_check_lb_frame(struct ql_adapter *qdev, if ((*(skb->data + 3) == 0xFF) && (*(skb->data + frame_size / 2 + 10) == 0xBE) && (*(skb->data + frame_size / 2 + 12) == 0xAF)) { - atomic_dec(&qdev->lb_count); - return; + atomic_dec(&qdev->lb_count); + return; } } -- cgit v1.2.3-58-ga151 From 2a30cb163449b91eb65b7ad971198550c6a16f97 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Wed, 1 Jul 2020 17:06:55 +0200 Subject: staging: wfx: associate tx_queues to vifs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The device handles 4 queues (one per AC) for each virtual interface (and maximum 4 virtual interfaces). Until now the driver unified the queue of all interfaces and handled only 4 queues for whole device. This architecture did not allow to balance the traffic between the vif. So, this patch relocate the queues into the vif and change the API accordingly. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200701150707.222985-2-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_tx.c | 57 ++++++++++------- drivers/staging/wfx/main.c | 3 +- drivers/staging/wfx/queue.c | 143 +++++++++++++++++++----------------------- drivers/staging/wfx/queue.h | 15 +++-- drivers/staging/wfx/sta.c | 4 +- drivers/staging/wfx/wfx.h | 2 +- 6 files changed, 112 insertions(+), 112 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index f042ef36b408..ce3048c94961 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -408,7 +408,7 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, // Auxiliary operations wfx_tx_manage_pm(wvif, hdr, tx_priv, sta); - wfx_tx_queues_put(wvif->wdev, skb); + wfx_tx_queues_put(wvif, skb); if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) schedule_work(&wvif->update_tim_work); wfx_bh_request_tx(wvif->wdev); @@ -539,7 +539,7 @@ void wfx_tx_confirm_cb(struct wfx_vif *wvif, const struct hif_cnf_tx *arg) const struct wfx_tx_priv *tx_priv; struct sk_buff *skb; - skb = wfx_pending_get(wvif->wdev, arg->packet_id); + skb = wfx_pending_get(wvif, arg->packet_id); if (!skb) { dev_warn(wvif->wdev->dev, "received unknown packet_id (%#.8x) from chip\n", arg->packet_id); @@ -582,35 +582,51 @@ void wfx_tx_confirm_cb(struct wfx_vif *wvif, const struct hif_cnf_tx *arg) wfx_skb_dtor(wvif, skb); } -void wfx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, - u32 queues, bool drop) +static void wfx_flush_vif(struct wfx_vif *wvif, u32 queues, + struct sk_buff_head *dropped) { - struct wfx_dev *wdev = hw->priv; - struct sk_buff_head dropped; struct wfx_queue *queue; - struct wfx_vif *wvif; - struct hif_msg *hif; - struct sk_buff *skb; - int vif_id = -1; int i; - if (vif) - vif_id = ((struct wfx_vif *)vif->drv_priv)->id; - skb_queue_head_init(&dropped); for (i = 0; i < IEEE80211_NUM_ACS; i++) { if (!(BIT(i) & queues)) continue; - queue = &wdev->tx_queue[i]; - if (drop) - wfx_tx_queue_drop(wdev, queue, vif_id, &dropped); - if (wdev->chip_frozen) + queue = &wvif->tx_queue[i]; + if (dropped) + wfx_tx_queue_drop(wvif, queue, dropped); + } + if (wvif->wdev->chip_frozen) + return; + for (i = 0; i < IEEE80211_NUM_ACS; i++) { + if (!(BIT(i) & queues)) continue; - if (wait_event_timeout(wdev->tx_dequeue, - wfx_tx_queue_empty(wdev, queue, vif_id), + queue = &wvif->tx_queue[i]; + if (wait_event_timeout(wvif->wdev->tx_dequeue, + wfx_tx_queue_empty(wvif, queue), msecs_to_jiffies(1000)) <= 0) - dev_warn(wdev->dev, + dev_warn(wvif->wdev->dev, "frames queued while flushing tx queues?"); } +} + +void wfx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + u32 queues, bool drop) +{ + struct wfx_dev *wdev = hw->priv; + struct sk_buff_head dropped; + struct wfx_vif *wvif; + struct hif_msg *hif; + struct sk_buff *skb; + + skb_queue_head_init(&dropped); + if (vif) { + wvif = (struct wfx_vif *)vif->drv_priv; + wfx_flush_vif(wvif, queues, drop ? &dropped : NULL); + } else { + wvif = NULL; + while ((wvif = wvif_iterate(wdev, wvif)) != NULL) + wfx_flush_vif(wvif, queues, drop ? &dropped : NULL); + } wfx_tx_flush(wdev); if (wdev->chip_frozen) wfx_pending_drop(wdev, &dropped); @@ -623,4 +639,3 @@ void wfx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, wfx_skb_dtor(wvif, skb); } } - diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 6bd96f476388..80e4474cc331 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -349,8 +349,9 @@ struct wfx_dev *wfx_init_common(struct device *dev, init_completion(&wdev->firmware_ready); INIT_DELAYED_WORK(&wdev->cooling_timeout_work, wfx_cooling_timeout_work); + skb_queue_head_init(&wdev->tx_pending); + init_waitqueue_head(&wdev->tx_dequeue); wfx_init_hif_cmd(&wdev->hif_cmd); - wfx_tx_queues_init(wdev); if (devm_add_action_or_reset(dev, wfx_free_common, wdev)) return NULL; diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 93ea2b72febd..7ec36598d9a8 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -57,84 +57,57 @@ void wfx_tx_lock_flush(struct wfx_dev *wdev) wfx_tx_flush(wdev); } -void wfx_tx_queues_init(struct wfx_dev *wdev) +void wfx_tx_queues_init(struct wfx_vif *wvif) { int i; - skb_queue_head_init(&wdev->tx_pending); - init_waitqueue_head(&wdev->tx_dequeue); for (i = 0; i < IEEE80211_NUM_ACS; ++i) { - skb_queue_head_init(&wdev->tx_queue[i].normal); - skb_queue_head_init(&wdev->tx_queue[i].cab); + skb_queue_head_init(&wvif->tx_queue[i].normal); + skb_queue_head_init(&wvif->tx_queue[i].cab); } } -void wfx_tx_queues_check_empty(struct wfx_dev *wdev) +void wfx_tx_queues_check_empty(struct wfx_vif *wvif) { int i; - WARN_ON(!skb_queue_empty_lockless(&wdev->tx_pending)); for (i = 0; i < IEEE80211_NUM_ACS; ++i) { - WARN_ON(atomic_read(&wdev->tx_queue[i].pending_frames)); - WARN_ON(!skb_queue_empty_lockless(&wdev->tx_queue[i].normal)); - WARN_ON(!skb_queue_empty_lockless(&wdev->tx_queue[i].cab)); + WARN_ON(atomic_read(&wvif->tx_queue[i].pending_frames)); + WARN_ON(!skb_queue_empty_lockless(&wvif->tx_queue[i].normal)); + WARN_ON(!skb_queue_empty_lockless(&wvif->tx_queue[i].cab)); } } -static bool __wfx_tx_queue_empty(struct wfx_dev *wdev, - struct sk_buff_head *skb_queue, int vif_id) +bool wfx_tx_queue_empty(struct wfx_vif *wvif, struct wfx_queue *queue) { - struct hif_msg *hif_msg; - struct sk_buff *skb; - - spin_lock_bh(&skb_queue->lock); - skb_queue_walk(skb_queue, skb) { - hif_msg = (struct hif_msg *)skb->data; - if (vif_id < 0 || hif_msg->interface == vif_id) { - spin_unlock_bh(&skb_queue->lock); - return false; - } - } - spin_unlock_bh(&skb_queue->lock); - return true; + return skb_queue_empty(&queue->normal) && skb_queue_empty(&queue->cab); } -bool wfx_tx_queue_empty(struct wfx_dev *wdev, - struct wfx_queue *queue, int vif_id) -{ - return __wfx_tx_queue_empty(wdev, &queue->normal, vif_id) && - __wfx_tx_queue_empty(wdev, &queue->cab, vif_id); -} - -static void __wfx_tx_queue_drop(struct wfx_dev *wdev, - struct sk_buff_head *skb_queue, int vif_id, +static void __wfx_tx_queue_drop(struct wfx_vif *wvif, + struct sk_buff_head *skb_queue, struct sk_buff_head *dropped) { struct sk_buff *skb, *tmp; - struct hif_msg *hif_msg; spin_lock_bh(&skb_queue->lock); skb_queue_walk_safe(skb_queue, skb, tmp) { - hif_msg = (struct hif_msg *)skb->data; - if (vif_id < 0 || hif_msg->interface == vif_id) { - __skb_unlink(skb, skb_queue); - skb_queue_head(dropped, skb); - } + __skb_unlink(skb, skb_queue); + skb_queue_head(dropped, skb); } spin_unlock_bh(&skb_queue->lock); } -void wfx_tx_queue_drop(struct wfx_dev *wdev, struct wfx_queue *queue, - int vif_id, struct sk_buff_head *dropped) +void wfx_tx_queue_drop(struct wfx_vif *wvif, struct wfx_queue *queue, + struct sk_buff_head *dropped) { - __wfx_tx_queue_drop(wdev, &queue->cab, vif_id, dropped); - __wfx_tx_queue_drop(wdev, &queue->normal, vif_id, dropped); - wake_up(&wdev->tx_dequeue); + __wfx_tx_queue_drop(wvif, &queue->cab, dropped); + __wfx_tx_queue_drop(wvif, &queue->normal, dropped); + wake_up(&wvif->wdev->tx_dequeue); } -void wfx_tx_queues_put(struct wfx_dev *wdev, struct sk_buff *skb) +void wfx_tx_queues_put(struct wfx_vif *wvif, struct sk_buff *skb) { - struct wfx_queue *queue = &wdev->tx_queue[skb_get_queue_mapping(skb)]; + struct wfx_queue *queue = &wvif->tx_queue[skb_get_queue_mapping(skb)]; struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) @@ -146,39 +119,45 @@ void wfx_tx_queues_put(struct wfx_dev *wdev, struct sk_buff *skb) void wfx_pending_drop(struct wfx_dev *wdev, struct sk_buff_head *dropped) { struct wfx_queue *queue; + struct wfx_vif *wvif; + struct hif_msg *hif; struct sk_buff *skb; WARN(!wdev->chip_frozen, "%s should only be used to recover a frozen device", __func__); while ((skb = skb_dequeue(&wdev->tx_pending)) != NULL) { - queue = &wdev->tx_queue[skb_get_queue_mapping(skb)]; - WARN_ON(skb_get_queue_mapping(skb) > 3); - WARN_ON(!atomic_read(&queue->pending_frames)); - atomic_dec(&queue->pending_frames); + hif = (struct hif_msg *)skb->data; + wvif = wdev_to_wvif(wdev, hif->interface); + if (wvif) { + queue = &wvif->tx_queue[skb_get_queue_mapping(skb)]; + WARN_ON(skb_get_queue_mapping(skb) > 3); + WARN_ON(!atomic_read(&queue->pending_frames)); + atomic_dec(&queue->pending_frames); + } skb_queue_head(dropped, skb); } } -struct sk_buff *wfx_pending_get(struct wfx_dev *wdev, u32 packet_id) +struct sk_buff *wfx_pending_get(struct wfx_vif *wvif, u32 packet_id) { struct wfx_queue *queue; struct hif_req_tx *req; struct sk_buff *skb; - spin_lock_bh(&wdev->tx_pending.lock); - skb_queue_walk(&wdev->tx_pending, skb) { + spin_lock_bh(&wvif->wdev->tx_pending.lock); + skb_queue_walk(&wvif->wdev->tx_pending, skb) { req = wfx_skb_txreq(skb); if (req->packet_id == packet_id) { - spin_unlock_bh(&wdev->tx_pending.lock); - queue = &wdev->tx_queue[skb_get_queue_mapping(skb)]; + spin_unlock_bh(&wvif->wdev->tx_pending.lock); + queue = &wvif->tx_queue[skb_get_queue_mapping(skb)]; WARN_ON(skb_get_queue_mapping(skb) > 3); WARN_ON(!atomic_read(&queue->pending_frames)); atomic_dec(&queue->pending_frames); - skb_unlink(skb, &wdev->tx_pending); + skb_unlink(skb, &wvif->wdev->tx_pending); return skb; } } - spin_unlock_bh(&wdev->tx_pending.lock); + spin_unlock_bh(&wvif->wdev->tx_pending.lock); WARN(1, "cannot find packet in pending queue"); return NULL; } @@ -221,7 +200,6 @@ unsigned int wfx_pending_get_pkt_us_delay(struct wfx_dev *wdev, bool wfx_tx_queues_has_cab(struct wfx_vif *wvif) { - struct wfx_dev *wdev = wvif->wdev; int i; if (wvif->vif->type != NL80211_IFTYPE_AP) @@ -229,33 +207,39 @@ bool wfx_tx_queues_has_cab(struct wfx_vif *wvif) for (i = 0; i < IEEE80211_NUM_ACS; ++i) // Note: since only AP can have mcast frames in queue and only // one vif can be AP, all queued frames has same interface id - if (!skb_queue_empty_lockless(&wdev->tx_queue[i].cab)) + if (!skb_queue_empty_lockless(&wvif->tx_queue[i].cab)) return true; return false; } static struct sk_buff *wfx_tx_queues_get_skb(struct wfx_dev *wdev) { - struct wfx_queue *sorted_queues[IEEE80211_NUM_ACS]; + struct wfx_queue *queues[IEEE80211_NUM_ACS * ARRAY_SIZE(wdev->vif)]; + int i, j, num_queues = 0; struct wfx_vif *wvif; struct hif_msg *hif; struct sk_buff *skb; - int i, j; - - // bubble sort - for (i = 0; i < IEEE80211_NUM_ACS; i++) { - sorted_queues[i] = &wdev->tx_queue[i]; - for (j = i; j > 0; j--) - if (atomic_read(&sorted_queues[j]->pending_frames) < - atomic_read(&sorted_queues[j - 1]->pending_frames)) - swap(sorted_queues[j - 1], sorted_queues[j]); + + // sort the queues + wvif = NULL; + while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { + for (i = 0; i < IEEE80211_NUM_ACS; i++) { + WARN_ON(num_queues >= ARRAY_SIZE(queues)); + queues[num_queues] = &wvif->tx_queue[i]; + for (j = num_queues; j > 0; j--) + if (atomic_read(&queues[j]->pending_frames) < + atomic_read(&queues[j - 1]->pending_frames)) + swap(queues[j - 1], queues[j]); + num_queues++; + } } + wvif = NULL; while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { if (!wvif->after_dtim_tx_allowed) continue; - for (i = 0; i < IEEE80211_NUM_ACS; i++) { - skb = skb_dequeue(&sorted_queues[i]->cab); + for (i = 0; i < num_queues; i++) { + skb = skb_dequeue(&queues[i]->cab); if (!skb) continue; // Note: since only AP can have mcast frames in queue @@ -263,21 +247,20 @@ static struct sk_buff *wfx_tx_queues_get_skb(struct wfx_dev *wdev) // same interface id hif = (struct hif_msg *)skb->data; WARN_ON(hif->interface != wvif->id); - WARN_ON(sorted_queues[i] != - &wdev->tx_queue[skb_get_queue_mapping(skb)]); - atomic_inc(&sorted_queues[i]->pending_frames); + WARN_ON(queues[i] != + &wvif->tx_queue[skb_get_queue_mapping(skb)]); + atomic_inc(&queues[i]->pending_frames); return skb; } // No more multicast to sent wvif->after_dtim_tx_allowed = false; schedule_work(&wvif->update_tim_work); } - for (i = 0; i < IEEE80211_NUM_ACS; i++) { - skb = skb_dequeue(&sorted_queues[i]->normal); + + for (i = 0; i < num_queues; i++) { + skb = skb_dequeue(&queues[i]->normal); if (skb) { - WARN_ON(sorted_queues[i] != - &wdev->tx_queue[skb_get_queue_mapping(skb)]); - atomic_inc(&sorted_queues[i]->pending_frames); + atomic_inc(&queues[i]->pending_frames); return skb; } } diff --git a/drivers/staging/wfx/queue.h b/drivers/staging/wfx/queue.h index 0c3b7244498e..dfbbe4b11111 100644 --- a/drivers/staging/wfx/queue.h +++ b/drivers/staging/wfx/queue.h @@ -25,18 +25,17 @@ void wfx_tx_unlock(struct wfx_dev *wdev); void wfx_tx_flush(struct wfx_dev *wdev); void wfx_tx_lock_flush(struct wfx_dev *wdev); -void wfx_tx_queues_init(struct wfx_dev *wdev); -void wfx_tx_queues_check_empty(struct wfx_dev *wdev); +void wfx_tx_queues_init(struct wfx_vif *wvif); +void wfx_tx_queues_check_empty(struct wfx_vif *wvif); bool wfx_tx_queues_has_cab(struct wfx_vif *wvif); -void wfx_tx_queues_put(struct wfx_dev *wdev, struct sk_buff *skb); +void wfx_tx_queues_put(struct wfx_vif *wvif, struct sk_buff *skb); struct hif_msg *wfx_tx_queues_get(struct wfx_dev *wdev); -bool wfx_tx_queue_empty(struct wfx_dev *wdev, struct wfx_queue *queue, - int vif_id); -void wfx_tx_queue_drop(struct wfx_dev *wdev, struct wfx_queue *queue, - int vif_id, struct sk_buff_head *dropped); +bool wfx_tx_queue_empty(struct wfx_vif *wvif, struct wfx_queue *queue); +void wfx_tx_queue_drop(struct wfx_vif *wvif, struct wfx_queue *queue, + struct sk_buff_head *dropped); -struct sk_buff *wfx_pending_get(struct wfx_dev *wdev, u32 packet_id); +struct sk_buff *wfx_pending_get(struct wfx_vif *wvif, u32 packet_id); void wfx_pending_drop(struct wfx_dev *wdev, struct sk_buff_head *dropped); unsigned int wfx_pending_get_pkt_us_delay(struct wfx_dev *wdev, struct sk_buff *skb); diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index d855d87c2102..85d4bc294988 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -805,6 +805,7 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) hif_set_macaddr(wvif, vif->addr); + wfx_tx_queues_init(wvif); wfx_tx_policy_init(wvif); wvif = NULL; while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { @@ -823,6 +824,7 @@ void wfx_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv; wait_for_completion_timeout(&wvif->set_pm_mode_complete, msecs_to_jiffies(300)); + wfx_tx_queues_check_empty(wvif); mutex_lock(&wdev->conf_mutex); WARN(wvif->link_id_map != 1, "corrupted state"); @@ -855,5 +857,5 @@ void wfx_stop(struct ieee80211_hw *hw) { struct wfx_dev *wdev = hw->priv; - wfx_tx_queues_check_empty(wdev); + WARN_ON(!skb_queue_empty_lockless(&wdev->tx_pending)); } diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 73e216733ce4..0c44b733ef6f 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -48,7 +48,6 @@ struct wfx_dev { struct mutex conf_mutex; struct wfx_hif_cmd hif_cmd; - struct wfx_queue tx_queue[4]; struct sk_buff_head tx_pending; wait_queue_head_t tx_dequeue; atomic_t tx_lock; @@ -75,6 +74,7 @@ struct wfx_vif { struct delayed_work beacon_loss_work; + struct wfx_queue tx_queue[4]; struct tx_policy_cache tx_policy_cache; struct work_struct tx_policy_upload_work; -- cgit v1.2.3-58-ga151 From df6f08d3faec5ce603d531dbe9660f391a50af9d Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Wed, 1 Jul 2020 17:06:56 +0200 Subject: staging: wfx: check the vif ID of the Tx confirmations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the driver has sent a frame on a virtual interface (vif), it expects to receive the confirmation on the same vif. This patch add a check for that. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200701150707.222985-3-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/queue.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 7ec36598d9a8..6069143369f3 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -142,14 +142,18 @@ struct sk_buff *wfx_pending_get(struct wfx_vif *wvif, u32 packet_id) { struct wfx_queue *queue; struct hif_req_tx *req; + struct hif_msg *hif; struct sk_buff *skb; spin_lock_bh(&wvif->wdev->tx_pending.lock); skb_queue_walk(&wvif->wdev->tx_pending, skb) { - req = wfx_skb_txreq(skb); + hif = (struct hif_msg *)skb->data; + req = (struct hif_req_tx *)hif->body; if (req->packet_id == packet_id) { spin_unlock_bh(&wvif->wdev->tx_pending.lock); queue = &wvif->tx_queue[skb_get_queue_mapping(skb)]; + WARN(hif->interface != wvif->id, "sent frame %08x on vif %d, but get reply on vif %d", + req->packet_id, hif->interface, wvif->id); WARN_ON(skb_get_queue_mapping(skb) > 3); WARN_ON(!atomic_read(&queue->pending_frames)); atomic_dec(&queue->pending_frames); -- cgit v1.2.3-58-ga151 From 70a37a09db9c8187e94108d875513c18000bb8d9 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Wed, 1 Jul 2020 17:06:57 +0200 Subject: staging: wfx: correctly retrieve vif ID from Tx confirmation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The device is able to send multiple Tx confirmations in the one reply. In this case, there is only one vif identifier for all the confirmations. Unfortunately, to generate this kind of messages the device squashes all the confirmations whatever their vif ID and use the vif ID of the first confirmation. So, the driver cannot rely on the vif ID mentioned in the header. Fortunately, using the packet_id, the driver can retrieve the Tx request and the associated vif. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200701150707.222985-4-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_tx.c | 16 ++++++++++------ drivers/staging/wfx/data_tx.h | 2 +- drivers/staging/wfx/hif_rx.c | 14 ++------------ drivers/staging/wfx/queue.c | 22 ++++++++++++---------- drivers/staging/wfx/queue.h | 2 +- 5 files changed, 26 insertions(+), 30 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index ce3048c94961..dcec722afb17 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -533,25 +533,29 @@ static void wfx_tx_fill_rates(struct wfx_dev *wdev, dev_dbg(wdev->dev, "%d more retries than expected\n", tx_count); } -void wfx_tx_confirm_cb(struct wfx_vif *wvif, const struct hif_cnf_tx *arg) +void wfx_tx_confirm_cb(struct wfx_dev *wdev, const struct hif_cnf_tx *arg) { struct ieee80211_tx_info *tx_info; const struct wfx_tx_priv *tx_priv; + struct wfx_vif *wvif; struct sk_buff *skb; - skb = wfx_pending_get(wvif, arg->packet_id); + skb = wfx_pending_get(wdev, arg->packet_id); if (!skb) { - dev_warn(wvif->wdev->dev, "received unknown packet_id (%#.8x) from chip\n", + dev_warn(wdev->dev, "received unknown packet_id (%#.8x) from chip\n", arg->packet_id); return; } + wvif = wdev_to_wvif(wdev, ((struct hif_msg *)skb->data)->interface); + WARN_ON(!wvif); + if (!wvif) + return; tx_info = IEEE80211_SKB_CB(skb); tx_priv = wfx_skb_tx_priv(skb); - _trace_tx_stats(arg, skb, - wfx_pending_get_pkt_us_delay(wvif->wdev, skb)); + _trace_tx_stats(arg, skb, wfx_pending_get_pkt_us_delay(wdev, skb)); // You can touch to tx_priv, but don't touch to tx_info->status. - wfx_tx_fill_rates(wvif->wdev, tx_info, arg); + wfx_tx_fill_rates(wdev, tx_info, arg); if (tx_priv->has_sta) wfx_tx_update_sta(wvif, wfx_skb_hdr80211(skb)); skb_trim(skb, skb->len - wfx_tx_get_icv_len(tx_priv->hw_key)); diff --git a/drivers/staging/wfx/data_tx.h b/drivers/staging/wfx/data_tx.h index 54fff24508fb..b1727ddecd5e 100644 --- a/drivers/staging/wfx/data_tx.h +++ b/drivers/staging/wfx/data_tx.h @@ -44,7 +44,7 @@ void wfx_tx_policy_upload_work(struct work_struct *work); void wfx_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, struct sk_buff *skb); -void wfx_tx_confirm_cb(struct wfx_vif *wvif, const struct hif_cnf_tx *arg); +void wfx_tx_confirm_cb(struct wfx_dev *wdev, const struct hif_cnf_tx *arg); void wfx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u32 queues, bool drop); diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index bb156033d1e1..e3ebd910fabf 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -63,13 +63,8 @@ static int hif_tx_confirm(struct wfx_dev *wdev, const struct hif_msg *hif, const void *buf) { const struct hif_cnf_tx *body = buf; - struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); - - WARN_ON(!wvif); - if (!wvif) - return -EFAULT; - wfx_tx_confirm_cb(wvif, body); + wfx_tx_confirm_cb(wdev, body); return 0; } @@ -77,16 +72,11 @@ static int hif_multi_tx_confirm(struct wfx_dev *wdev, const struct hif_msg *hif, const void *buf) { const struct hif_cnf_multi_transmit *body = buf; - struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); int i; WARN(body->num_tx_confs <= 0, "corrupted message"); - WARN_ON(!wvif); - if (!wvif) - return -EFAULT; - for (i = 0; i < body->num_tx_confs; i++) - wfx_tx_confirm_cb(wvif, &body->tx_conf_payload[i]); + wfx_tx_confirm_cb(wdev, &body->tx_conf_payload[i]); return 0; } diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 6069143369f3..678f62263909 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -138,30 +138,32 @@ void wfx_pending_drop(struct wfx_dev *wdev, struct sk_buff_head *dropped) } } -struct sk_buff *wfx_pending_get(struct wfx_vif *wvif, u32 packet_id) +struct sk_buff *wfx_pending_get(struct wfx_dev *wdev, u32 packet_id) { struct wfx_queue *queue; struct hif_req_tx *req; + struct wfx_vif *wvif; struct hif_msg *hif; struct sk_buff *skb; - spin_lock_bh(&wvif->wdev->tx_pending.lock); - skb_queue_walk(&wvif->wdev->tx_pending, skb) { + spin_lock_bh(&wdev->tx_pending.lock); + skb_queue_walk(&wdev->tx_pending, skb) { hif = (struct hif_msg *)skb->data; req = (struct hif_req_tx *)hif->body; - if (req->packet_id == packet_id) { - spin_unlock_bh(&wvif->wdev->tx_pending.lock); + if (req->packet_id != packet_id) + continue; + spin_unlock_bh(&wdev->tx_pending.lock); + wvif = wdev_to_wvif(wdev, hif->interface); + if (wvif) { queue = &wvif->tx_queue[skb_get_queue_mapping(skb)]; - WARN(hif->interface != wvif->id, "sent frame %08x on vif %d, but get reply on vif %d", - req->packet_id, hif->interface, wvif->id); WARN_ON(skb_get_queue_mapping(skb) > 3); WARN_ON(!atomic_read(&queue->pending_frames)); atomic_dec(&queue->pending_frames); - skb_unlink(skb, &wvif->wdev->tx_pending); - return skb; } + skb_unlink(skb, &wdev->tx_pending); + return skb; } - spin_unlock_bh(&wvif->wdev->tx_pending.lock); + spin_unlock_bh(&wdev->tx_pending.lock); WARN(1, "cannot find packet in pending queue"); return NULL; } diff --git a/drivers/staging/wfx/queue.h b/drivers/staging/wfx/queue.h index dfbbe4b11111..22d7c936907f 100644 --- a/drivers/staging/wfx/queue.h +++ b/drivers/staging/wfx/queue.h @@ -35,7 +35,7 @@ bool wfx_tx_queue_empty(struct wfx_vif *wvif, struct wfx_queue *queue); void wfx_tx_queue_drop(struct wfx_vif *wvif, struct wfx_queue *queue, struct sk_buff_head *dropped); -struct sk_buff *wfx_pending_get(struct wfx_vif *wvif, u32 packet_id); +struct sk_buff *wfx_pending_get(struct wfx_dev *wdev, u32 packet_id); void wfx_pending_drop(struct wfx_dev *wdev, struct sk_buff_head *dropped); unsigned int wfx_pending_get_pkt_us_delay(struct wfx_dev *wdev, struct sk_buff *skb); -- cgit v1.2.3-58-ga151 From b64d1054bccbbcb435901e20f564292214373f87 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Wed, 1 Jul 2020 17:06:58 +0200 Subject: staging: wfx: add tracepoint "queues_stats" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is useful to check which queue the driver choose to send to the hardware. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200701150707.222985-5-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/queue.c | 3 +++ drivers/staging/wfx/traces.h | 51 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 678f62263909..6e3159165143 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -12,6 +12,7 @@ #include "wfx.h" #include "sta.h" #include "data_tx.h" +#include "traces.h" void wfx_tx_lock(struct wfx_dev *wdev) { @@ -256,6 +257,7 @@ static struct sk_buff *wfx_tx_queues_get_skb(struct wfx_dev *wdev) WARN_ON(queues[i] != &wvif->tx_queue[skb_get_queue_mapping(skb)]); atomic_inc(&queues[i]->pending_frames); + trace_queues_stats(wdev, queues[i]); return skb; } // No more multicast to sent @@ -267,6 +269,7 @@ static struct sk_buff *wfx_tx_queues_get_skb(struct wfx_dev *wdev) skb = skb_dequeue(&queues[i]->normal); if (skb) { atomic_inc(&queues[i]->pending_frames); + trace_queues_stats(wdev, queues[i]); return skb; } } diff --git a/drivers/staging/wfx/traces.h b/drivers/staging/wfx/traces.h index 0b6fbd518638..d376db2f1891 100644 --- a/drivers/staging/wfx/traces.h +++ b/drivers/staging/wfx/traces.h @@ -439,6 +439,57 @@ TRACE_EVENT(tx_stats, ); #define _trace_tx_stats(tx_cnf, skb, delay) trace_tx_stats(tx_cnf, skb, delay) +TRACE_EVENT(queues_stats, + TP_PROTO(struct wfx_dev *wdev, const struct wfx_queue *elected_queue), + TP_ARGS(wdev, elected_queue), + TP_STRUCT__entry( + __field(int, vif_id) + __field(int, queue_id) + __array(int, hw, IEEE80211_NUM_ACS * 2) + __array(int, drv, IEEE80211_NUM_ACS * 2) + __array(int, cab, IEEE80211_NUM_ACS * 2) + ), + TP_fast_assign( + const struct wfx_queue *queue; + struct wfx_vif *wvif; + int i, j; + + for (j = 0; j < IEEE80211_NUM_ACS * 2; j++) { + __entry->hw[j] = -1; + __entry->drv[j] = -1; + __entry->cab[j] = -1; + } + __entry->vif_id = -1; + __entry->queue_id = -1; + wvif = NULL; + while ((wvif = wvif_iterate(wdev, wvif)) != NULL) { + for (i = 0; i < IEEE80211_NUM_ACS; i++) { + j = wvif->id * IEEE80211_NUM_ACS + i; + WARN_ON(j >= IEEE80211_NUM_ACS * 2); + queue = &wvif->tx_queue[i]; + __entry->hw[j] = atomic_read(&queue->pending_frames); + __entry->drv[j] = skb_queue_len(&queue->normal); + __entry->cab[j] = skb_queue_len(&queue->cab); + if (queue == elected_queue) { + __entry->vif_id = wvif->id; + __entry->queue_id = i; + } + } + } + ), + TP_printk("got skb from %d/%d, pend. hw/norm/cab: [ %d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d ] [ %d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d ]", + __entry->vif_id, __entry->queue_id, + __entry->hw[0], __entry->drv[0], __entry->cab[0], + __entry->hw[1], __entry->drv[1], __entry->cab[1], + __entry->hw[2], __entry->drv[2], __entry->cab[2], + __entry->hw[3], __entry->drv[3], __entry->cab[3], + __entry->hw[4], __entry->drv[4], __entry->cab[4], + __entry->hw[5], __entry->drv[5], __entry->cab[5], + __entry->hw[6], __entry->drv[6], __entry->cab[6], + __entry->hw[7], __entry->drv[7], __entry->cab[7] + ) +); + #endif /* This part must be outside protection */ -- cgit v1.2.3-58-ga151 From a9408ad79ff3d77542a5cfdd76d21fd12bf8b46a Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Wed, 1 Jul 2020 17:06:59 +0200 Subject: staging: wfx: load the firmware faster MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During the loading of the firmware, the WFX_DCA_GET register provide the number available bytes in the receiving buffer. It is not necessary to access to the WFX_DCA_GET after sent of each firmware fragment. This patch allows to send the firmware: - in 64ms instead of 130ms using SDIO bus - in 78ms instead of 115ms using SPI bus Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200701150707.222985-6-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/fwio.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/fwio.c b/drivers/staging/wfx/fwio.c index 72bb3d2a9613..d9a886f3e64b 100644 --- a/drivers/staging/wfx/fwio.c +++ b/drivers/staging/wfx/fwio.c @@ -188,15 +188,14 @@ static int upload_firmware(struct wfx_dev *wdev, const u8 *data, size_t len) while (offs < len) { start = ktime_get(); for (;;) { - ret = sram_reg_read(wdev, WFX_DCA_GET, &bytes_done); - if (ret < 0) - return ret; now = ktime_get(); - if (offs + - DNLD_BLOCK_SIZE - bytes_done < DNLD_FIFO_SIZE) + if (offs + DNLD_BLOCK_SIZE - bytes_done < DNLD_FIFO_SIZE) break; if (ktime_after(now, ktime_add_ms(start, DCA_TIMEOUT))) return -ETIMEDOUT; + ret = sram_reg_read(wdev, WFX_DCA_GET, &bytes_done); + if (ret < 0) + return ret; } if (ktime_compare(now, start)) dev_dbg(wdev->dev, "answer after %lldus\n", -- cgit v1.2.3-58-ga151 From 9b8a9e6c2cb52374fed526e7db1961069fcd55ad Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Wed, 1 Jul 2020 17:07:00 +0200 Subject: staging: wfx: improve protection against malformed HIF messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As discussed here[1], if a message was smaller than the size of the message header, it could be incorrectly processed. [1] https://lore.kernel.org/driverdev-devel/2302785.6C7ODC2LYm@pc-42/ Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200701150707.222985-7-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/bh.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c index 1cbaf8bb4fa3..53ae0b5abcdd 100644 --- a/drivers/staging/wfx/bh.c +++ b/drivers/staging/wfx/bh.c @@ -57,7 +57,6 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) int release_count; int piggyback = 0; - WARN(read_len < 4, "corrupted read"); WARN(read_len > round_down(0xFFF, 2) * sizeof(u16), "%s: request exceed WFx capability", __func__); @@ -76,20 +75,17 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) hif = (struct hif_msg *)skb->data; WARN(hif->encrypted & 0x1, "unsupported encryption type"); if (hif->encrypted == 0x2) { - if (wfx_sl_decode(wdev, (void *)hif)) { - dev_kfree_skb(skb); - // If frame was a confirmation, expect trouble in next - // exchange. However, it is harmless to fail to decode - // an indication frame, so try to continue. Anyway, - // piggyback is probably correct. - return piggyback; - } - computed_len = - round_up(le16_to_cpu(hif->len) - sizeof(hif->len), 16) + - sizeof(struct hif_sl_msg) + - sizeof(struct hif_sl_tag); + if (WARN(read_len < sizeof(struct hif_sl_msg), "corrupted read")) + goto err; + computed_len = le16_to_cpu(((struct hif_sl_msg *)hif)->len); + computed_len = round_up(computed_len - sizeof(u16), 16); + computed_len += sizeof(struct hif_sl_msg); + computed_len += sizeof(struct hif_sl_tag); } else { - computed_len = round_up(le16_to_cpu(hif->len), 2); + if (WARN(read_len < sizeof(struct hif_msg), "corrupted read")) + goto err; + computed_len = le16_to_cpu(hif->len); + computed_len = round_up(computed_len, 2); } if (computed_len != read_len) { dev_err(wdev->dev, "inconsistent message length: %zu != %zu\n", @@ -98,6 +94,16 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf) hif, read_len, true); goto err; } + if (hif->encrypted == 0x2) { + if (wfx_sl_decode(wdev, (struct hif_sl_msg *)hif)) { + dev_kfree_skb(skb); + // If frame was a confirmation, expect trouble in next + // exchange. However, it is harmless to fail to decode + // an indication frame, so try to continue. Anyway, + // piggyback is probably correct. + return piggyback; + } + } if (!(hif->id & HIF_ID_IS_INDICATION)) { (*is_cnf)++; -- cgit v1.2.3-58-ga151 From da0ce565667a997c74240718c44de16257638b23 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Wed, 1 Jul 2020 17:07:01 +0200 Subject: staging: wfx: fix unexpected calls to ieee80211_sta_set_buffered() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a station go to sleep, the driver receive the status REQUEUE and forward this answer to mac80211. So, neither the driver, neither the hardware buffer the frames. So the call to ieee80211_sta_set_buffered is useless. In add, it seems that mac80211 does not expect to receive ieee80211_sta_set_buffered(false) after the station is asleep(). When the device send data to a station, the following sequence can be observed: - Mac80211 call wfx_sta_notify(awake). - The driver calls ieee80211_sta_set_buffered(true). Since the station is awake, its TIM is not set. - Mac80211 receive a power save notification from the station, so it calls wfx_sta_notify(asleep). - Then, since the driver has declared it has buffered some frames, the TIM of the station should be set. This action is delayed by mac80211. - The device also notice the station go to sleep. It replies the REQUEUE status for the buffered frames. The driver forward this status to mac80211. - There is no more frames in queues, so the driver call ieee80211_sta_set_buffered(false). - Mac80211 updates the TIM but since there is no frames buffered by the driver, it set the TIM for the station to 0. Anyway, correctly use the ieee80211_sta_set_buffered() API solves the problem. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200701150707.222985-8-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_tx.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index dcec722afb17..3244a768345c 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -225,7 +225,6 @@ static void wfx_tx_manage_pm(struct wfx_vif *wvif, struct ieee80211_hdr *hdr, sta_priv = (struct wfx_sta_priv *)&sta->drv_priv; spin_lock_bh(&sta_priv->lock); sta_priv->buffered[tid]++; - ieee80211_sta_set_buffered(sta, tid, true); spin_unlock_bh(&sta_priv->lock); } } @@ -471,8 +470,6 @@ static void wfx_tx_update_sta(struct wfx_vif *wvif, struct ieee80211_hdr *hdr) spin_lock_bh(&sta_priv->lock); WARN(!sta_priv->buffered[tid], "inconsistent notification"); sta_priv->buffered[tid]--; - if (!sta_priv->buffered[tid]) - ieee80211_sta_set_buffered(sta, tid, false); spin_unlock_bh(&sta_priv->lock); } else { dev_dbg(wvif->wdev->dev, "%s: sta does not exist anymore\n", -- cgit v1.2.3-58-ga151 From b9aa17505f3523b44c037eb44e01c78f277f5ef1 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Wed, 1 Jul 2020 17:07:02 +0200 Subject: staging: wfx: drop counter of buffered frames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the driver does not call ieee80211_sta_set_buffered() anymore, it is no more necessary to maintain a counter of buffered frames for each stations. This change allows to simplify the processing in multiple places in the driver. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200701150707.222985-9-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_tx.c | 50 ------------------------------------------- drivers/staging/wfx/data_tx.h | 1 - drivers/staging/wfx/sta.c | 8 ------- drivers/staging/wfx/sta.h | 3 --- 4 files changed, 62 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index 3244a768345c..5c744d9c8c11 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -213,22 +213,6 @@ static bool ieee80211_is_action_back(struct ieee80211_hdr *hdr) return true; } -static void wfx_tx_manage_pm(struct wfx_vif *wvif, struct ieee80211_hdr *hdr, - struct wfx_tx_priv *tx_priv, - struct ieee80211_sta *sta) -{ - struct wfx_sta_priv *sta_priv; - int tid = ieee80211_get_tid(hdr); - - if (sta) { - tx_priv->has_sta = true; - sta_priv = (struct wfx_sta_priv *)&sta->drv_priv; - spin_lock_bh(&sta_priv->lock); - sta_priv->buffered[tid]++; - spin_unlock_bh(&sta_priv->lock); - } -} - static u8 wfx_tx_get_link_id(struct wfx_vif *wvif, struct ieee80211_sta *sta, struct ieee80211_hdr *hdr) { @@ -406,7 +390,6 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta, req->tx_flags.retry_policy_index = wfx_tx_get_rate_id(wvif, tx_info); // Auxiliary operations - wfx_tx_manage_pm(wvif, hdr, tx_priv, sta); wfx_tx_queues_put(wvif, skb); if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) schedule_work(&wvif->update_tim_work); @@ -449,35 +432,6 @@ drop: ieee80211_tx_status_irqsafe(wdev->hw, skb); } -static struct ieee80211_hdr *wfx_skb_hdr80211(struct sk_buff *skb) -{ - struct hif_msg *hif = (struct hif_msg *)skb->data; - struct hif_req_tx *req = (struct hif_req_tx *)hif->body; - - return (struct ieee80211_hdr *)(req->frame + req->data_flags.fc_offset); -} - -static void wfx_tx_update_sta(struct wfx_vif *wvif, struct ieee80211_hdr *hdr) -{ - int tid = ieee80211_get_tid(hdr); - struct wfx_sta_priv *sta_priv; - struct ieee80211_sta *sta; - - rcu_read_lock(); // protect sta - sta = ieee80211_find_sta(wvif->vif, hdr->addr1); - if (sta) { - sta_priv = (struct wfx_sta_priv *)&sta->drv_priv; - spin_lock_bh(&sta_priv->lock); - WARN(!sta_priv->buffered[tid], "inconsistent notification"); - sta_priv->buffered[tid]--; - spin_unlock_bh(&sta_priv->lock); - } else { - dev_dbg(wvif->wdev->dev, "%s: sta does not exist anymore\n", - __func__); - } - rcu_read_unlock(); -} - static void wfx_skb_dtor(struct wfx_vif *wvif, struct sk_buff *skb) { struct hif_msg *hif = (struct hif_msg *)skb->data; @@ -553,8 +507,6 @@ void wfx_tx_confirm_cb(struct wfx_dev *wdev, const struct hif_cnf_tx *arg) // You can touch to tx_priv, but don't touch to tx_info->status. wfx_tx_fill_rates(wdev, tx_info, arg); - if (tx_priv->has_sta) - wfx_tx_update_sta(wvif, wfx_skb_hdr80211(skb)); skb_trim(skb, skb->len - wfx_tx_get_icv_len(tx_priv->hw_key)); // From now, you can touch to tx_info->status, but do not touch to @@ -634,8 +586,6 @@ void wfx_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif, while ((skb = skb_dequeue(&dropped)) != NULL) { hif = (struct hif_msg *)skb->data; wvif = wdev_to_wvif(wdev, hif->interface); - if (wfx_skb_tx_priv(skb)->has_sta) - wfx_tx_update_sta(wvif, wfx_skb_hdr80211(skb)); ieee80211_tx_info_clear_status(IEEE80211_SKB_CB(skb)); wfx_skb_dtor(wvif, skb); } diff --git a/drivers/staging/wfx/data_tx.h b/drivers/staging/wfx/data_tx.h index b1727ddecd5e..cff7b9ff99a9 100644 --- a/drivers/staging/wfx/data_tx.h +++ b/drivers/staging/wfx/data_tx.h @@ -36,7 +36,6 @@ struct tx_policy_cache { struct wfx_tx_priv { ktime_t xmit_timestamp; struct ieee80211_key_conf *hw_key; - bool has_sta; } __packed; void wfx_tx_policy_init(struct wfx_vif *wvif); diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 85d4bc294988..2c0ab51fc92d 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -430,7 +430,6 @@ int wfx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv; struct wfx_sta_priv *sta_priv = (struct wfx_sta_priv *)&sta->drv_priv; - spin_lock_init(&sta_priv->lock); sta_priv->vif_id = wvif->id; // In station mode, the firmware interprets new link-id as a TDLS peer. @@ -450,14 +449,7 @@ int wfx_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, { struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv; struct wfx_sta_priv *sta_priv = (struct wfx_sta_priv *)&sta->drv_priv; - int i; - for (i = 0; i < ARRAY_SIZE(sta_priv->buffered); i++) - if (sta_priv->buffered[i]) - // Not an error if paired with trace in - // wfx_tx_update_sta() - dev_dbg(wvif->wdev->dev, "release station while %d pending frame on queue %d", - sta_priv->buffered[i], i); // See note in wfx_sta_add() if (!sta_priv->link_id) return 0; diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h index 8a20ad9ae017..43808cef4785 100644 --- a/drivers/staging/wfx/sta.h +++ b/drivers/staging/wfx/sta.h @@ -16,9 +16,6 @@ struct wfx_vif; struct wfx_sta_priv { int link_id; int vif_id; - int buffered[IEEE80211_NUM_TIDS]; - // Ensure atomicity of "buffered" and calls to ieee80211_sta_set_buffered() - spinlock_t lock; }; // mac80211 interface -- cgit v1.2.3-58-ga151 From 6135ad0eeae9a3e9363fbb518c2815f0976fc20b Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Wed, 1 Jul 2020 17:07:03 +0200 Subject: staging: wfx: fix handling of frames without RSSI data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It seems that in the old days, the RSSI information could be missing. In this case, in order to not pollute the RSSI stats, the frame was dropped (!). It is far better to mark the frame with the flag RX_FLAG_NO_SIGNAL_VAL. In add, the problem seems now fixed in the firmware (at least, it has not been encountered with recent firmwares). Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200701150707.222985-10-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_rx.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_rx.c b/drivers/staging/wfx/data_rx.c index 0e959ebc38b5..316c2f1537fe 100644 --- a/drivers/staging/wfx/data_rx.c +++ b/drivers/staging/wfx/data_rx.c @@ -73,12 +73,6 @@ void wfx_rx_cb(struct wfx_vif *wvif, memset(hdr, 0, sizeof(*hdr)); - // FIXME: Why do we drop these frames? - if (!arg->rcpi_rssi && - (ieee80211_is_probe_resp(frame->frame_control) || - ieee80211_is_beacon(frame->frame_control))) - goto drop; - if (arg->status == HIF_STATUS_RX_FAIL_MIC) hdr->flag |= RX_FLAG_MMIC_ERROR; else if (arg->status) @@ -102,6 +96,10 @@ void wfx_rx_cb(struct wfx_vif *wvif, hdr->rate_idx = arg->rxed_rate; } + if (!arg->rcpi_rssi) { + hdr->flag |= RX_FLAG_NO_SIGNAL_VAL; + dev_info(wvif->wdev->dev, "received frame without RSSI data\n"); + } hdr->signal = arg->rcpi_rssi / 2 - 110; hdr->antenna = 0; -- cgit v1.2.3-58-ga151 From bbc409e276c948a7acda32cab5d8f26335c34ac0 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Wed, 1 Jul 2020 17:07:04 +0200 Subject: staging: wfx: simplify handling of encrypted frames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't want mac80211 try to check MMIC and other security mechanisms. So, the driver remove all the data related to the encryption (IV, ICV, MMIC). However, enabling RX_FLAG_PN_VALIDATED is sufficient for that. So, drop the useless function wfx_drop_encrypt_data() and enable RX_FLAG_PN_VALIDATED. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200701150707.222985-11-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_rx.c | 60 ++----------------------------------------- 1 file changed, 2 insertions(+), 58 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_rx.c b/drivers/staging/wfx/data_rx.c index 316c2f1537fe..60e2e5cb4656 100644 --- a/drivers/staging/wfx/data_rx.c +++ b/drivers/staging/wfx/data_rx.c @@ -13,57 +13,6 @@ #include "bh.h" #include "sta.h" -static int wfx_drop_encrypt_data(struct wfx_dev *wdev, - const struct hif_ind_rx *arg, - struct sk_buff *skb) -{ - struct ieee80211_hdr *frame = (struct ieee80211_hdr *)skb->data; - size_t hdrlen = ieee80211_hdrlen(frame->frame_control); - size_t iv_len, icv_len; - - /* Oops... There is no fast way to ask mac80211 about - * IV/ICV lengths. Even defineas are not exposed. - */ - switch (arg->rx_flags.encryp) { - case HIF_RI_FLAGS_WEP_ENCRYPTED: - iv_len = 4 /* WEP_IV_LEN */; - icv_len = 4 /* WEP_ICV_LEN */; - break; - case HIF_RI_FLAGS_TKIP_ENCRYPTED: - iv_len = 8 /* TKIP_IV_LEN */; - icv_len = 4 /* TKIP_ICV_LEN */ - + 8 /*MICHAEL_MIC_LEN*/; - break; - case HIF_RI_FLAGS_AES_ENCRYPTED: - iv_len = 8 /* CCMP_HDR_LEN */; - icv_len = 8 /* CCMP_MIC_LEN */; - break; - case HIF_RI_FLAGS_WAPI_ENCRYPTED: - iv_len = 18 /* WAPI_HDR_LEN */; - icv_len = 16 /* WAPI_MIC_LEN */; - break; - default: - dev_err(wdev->dev, "unknown encryption type %d\n", - arg->rx_flags.encryp); - return -EIO; - } - - /* Firmware strips ICV in case of MIC failure. */ - if (arg->status == HIF_STATUS_RX_FAIL_MIC) - icv_len = 0; - - if (skb->len < hdrlen + iv_len + icv_len) { - dev_warn(wdev->dev, "malformed SDU received\n"); - return -EIO; - } - - /* Remove IV, ICV and MIC */ - skb_trim(skb, skb->len - icv_len); - memmove(skb->data + iv_len, skb->data, hdrlen); - skb_pull(skb, iv_len); - return 0; -} - void wfx_rx_cb(struct wfx_vif *wvif, const struct hif_ind_rx *arg, struct sk_buff *skb) { @@ -103,13 +52,8 @@ void wfx_rx_cb(struct wfx_vif *wvif, hdr->signal = arg->rcpi_rssi / 2 - 110; hdr->antenna = 0; - if (arg->rx_flags.encryp) { - if (wfx_drop_encrypt_data(wvif->wdev, arg, skb)) - goto drop; - hdr->flag |= RX_FLAG_DECRYPTED | RX_FLAG_IV_STRIPPED; - if (arg->rx_flags.encryp == HIF_RI_FLAGS_TKIP_ENCRYPTED) - hdr->flag |= RX_FLAG_MMIC_STRIPPED; - } + if (arg->rx_flags.encryp) + hdr->flag |= RX_FLAG_DECRYPTED | RX_FLAG_PN_VALIDATED; /* Filter block ACK negotiation: fully controlled by firmware */ if (ieee80211_is_action(frame->frame_control) && -- cgit v1.2.3-58-ga151 From e5da5fbd7741162c51a70ffad4316be12e1bb010 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Wed, 1 Jul 2020 17:07:05 +0200 Subject: staging: wfx: fix CCMP/TKIP replay protection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To enable the TKIP/CCMP replay protection, the frames has to be processed in the right order. However, the device is not able to re-order the frames during BlockAck sessions. Mac80211 is able to reorder the frames, but it need the information about the BlockAck sessions start and stop. Unfortunately, since the BlockAck is fully handled by the hardware, these frames were not forwarded to the host. So, if the driver ask to mac80211 to apply the replay protection, it drop all misordered frames. So, until now, the driver explicitly asked to mac80211 to not apply the CCMP/TKIP replay protection. The situation has changed with the API 3.4 of the device firmware. The firmware forward the BlockAck information. Mac80211 is now able to correctly reorder the frames. There is no more reasons to drop cryptographic data. This patch also impact the older firmwares. There will be a performance impact on these firmware (since the misordered frames will dropped). However, we can't keep the replay protection disabled. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200701150707.222985-12-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/data_rx.c | 31 ++++++++++++++++++++++++++----- drivers/staging/wfx/data_tx.c | 3 ++- 2 files changed, 28 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/data_rx.c b/drivers/staging/wfx/data_rx.c index 60e2e5cb4656..6fb078880742 100644 --- a/drivers/staging/wfx/data_rx.c +++ b/drivers/staging/wfx/data_rx.c @@ -13,6 +13,24 @@ #include "bh.h" #include "sta.h" +static void wfx_rx_handle_ba(struct wfx_vif *wvif, struct ieee80211_mgmt *mgmt) +{ + int params, tid; + + switch (mgmt->u.action.u.addba_req.action_code) { + case WLAN_ACTION_ADDBA_REQ: + params = le16_to_cpu(mgmt->u.action.u.addba_req.capab); + tid = (params & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; + ieee80211_start_rx_ba_session_offl(wvif->vif, mgmt->sa, tid); + break; + case WLAN_ACTION_DELBA: + params = le16_to_cpu(mgmt->u.action.u.delba.params); + tid = (params & IEEE80211_DELBA_PARAM_TID_MASK) >> 12; + ieee80211_stop_rx_ba_session_offl(wvif->vif, mgmt->sa, tid); + break; + } +} + void wfx_rx_cb(struct wfx_vif *wvif, const struct hif_ind_rx *arg, struct sk_buff *skb) { @@ -53,15 +71,18 @@ void wfx_rx_cb(struct wfx_vif *wvif, hdr->antenna = 0; if (arg->rx_flags.encryp) - hdr->flag |= RX_FLAG_DECRYPTED | RX_FLAG_PN_VALIDATED; + hdr->flag |= RX_FLAG_DECRYPTED; - /* Filter block ACK negotiation: fully controlled by firmware */ + // Block ack negociation is offloaded by the firmware. However, + // re-ordering must be done by the mac80211. if (ieee80211_is_action(frame->frame_control) && - arg->rx_flags.match_uc_addr && - mgmt->u.action.category == WLAN_CATEGORY_BACK) + mgmt->u.action.category == WLAN_CATEGORY_BACK && + skb->len > IEEE80211_MIN_ACTION_SIZE) { + wfx_rx_handle_ba(wvif, mgmt); goto drop; - ieee80211_rx_irqsafe(wvif->wdev->hw, skb); + } + ieee80211_rx_irqsafe(wvif->wdev->hw, skb); return; drop: diff --git a/drivers/staging/wfx/data_tx.c b/drivers/staging/wfx/data_tx.c index 5c744d9c8c11..3acf4eb0214d 100644 --- a/drivers/staging/wfx/data_tx.c +++ b/drivers/staging/wfx/data_tx.c @@ -418,7 +418,8 @@ void wfx_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, wvif = wvif_iterate(wdev, NULL); if (WARN_ON(!wvif)) goto drop; - // FIXME: why? + // Because of TX_AMPDU_SETUP_IN_HW, mac80211 does not try to send any + // BlockAck session management frame. The check below exist just in case. if (ieee80211_is_action_back(hdr)) { dev_info(wdev->dev, "drop BA action\n"); goto drop; -- cgit v1.2.3-58-ga151 From 01d2ffa4d916d5884c89b1db0d79fd43c08bb708 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Wed, 1 Jul 2020 17:07:06 +0200 Subject: staging: wfx: add a debugfs entry to force ps_timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some advanced usage or debug scenarios, it could interesting to change the value of ps_timeout or eventually to force use of PS-Poll frames. The wext API (used by iwconfig) provide a way to change ps_timeout. However, this API is obsolete and it seems a little weird to use (it seems it does apply the change, so the user have to disable then re-enable de power save) On side of nl80211, there is no way to change the ps_timeout. This patch provides a file in debugfs to change the value of ps_timeout. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200701150707.222985-13-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/debug.c | 23 +++++++++++++++++++++++ drivers/staging/wfx/main.c | 1 + drivers/staging/wfx/sta.c | 10 +++++++--- drivers/staging/wfx/sta.h | 1 + drivers/staging/wfx/wfx.h | 1 + 5 files changed, 33 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index 10d649985696..3f1712b7c919 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -334,6 +334,28 @@ static const struct file_operations wfx_send_hif_msg_fops = { .read = wfx_send_hif_msg_read, }; +static int wfx_ps_timeout_set(void *data, u64 val) +{ + struct wfx_dev *wdev = (struct wfx_dev *)data; + struct wfx_vif *wvif; + + wdev->force_ps_timeout = val; + wvif = NULL; + while ((wvif = wvif_iterate(wdev, wvif)) != NULL) + wfx_update_pm(wvif); + return 0; +} + +static int wfx_ps_timeout_get(void *data, u64 *val) +{ + struct wfx_dev *wdev = (struct wfx_dev *)data; + + *val = wdev->force_ps_timeout; + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(wfx_ps_timeout_fops, wfx_ps_timeout_get, wfx_ps_timeout_set, "%lld\n"); + int wfx_debug_init(struct wfx_dev *wdev) { struct dentry *d; @@ -348,6 +370,7 @@ int wfx_debug_init(struct wfx_dev *wdev) &wfx_burn_slk_key_fops); debugfs_create_file("send_hif_msg", 0600, d, wdev, &wfx_send_hif_msg_fops); + debugfs_create_file("ps_timeout", 0600, d, wdev, &wfx_ps_timeout_fops); return 0; } diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 80e4474cc331..62e3634556ec 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -352,6 +352,7 @@ struct wfx_dev *wfx_init_common(struct device *dev, skb_queue_head_init(&wdev->tx_pending); init_waitqueue_head(&wdev->tx_dequeue); wfx_init_hif_cmd(&wdev->hif_cmd); + wdev->force_ps_timeout = -1; if (devm_add_action_or_reset(dev, wfx_free_common, wdev)) return NULL; diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 2c0ab51fc92d..fdf4f48ddc2c 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -217,20 +217,24 @@ static int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps) // are differents. if (enable_ps) *enable_ps = true; - if (wvif->bss_not_support_ps_poll) + if (wvif->wdev->force_ps_timeout > -1) + return wvif->wdev->force_ps_timeout; + else if (wvif->bss_not_support_ps_poll) return 30; else return 0; } if (enable_ps) *enable_ps = wvif->vif->bss_conf.ps; - if (wvif->vif->bss_conf.assoc && wvif->vif->bss_conf.ps) + if (wvif->wdev->force_ps_timeout > -1) + return wvif->wdev->force_ps_timeout; + else if (wvif->vif->bss_conf.assoc && wvif->vif->bss_conf.ps) return conf->dynamic_ps_timeout; else return -1; } -static int wfx_update_pm(struct wfx_vif *wvif) +int wfx_update_pm(struct wfx_vif *wvif) { int ps_timeout; bool ps; diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h index 43808cef4785..6b15a64ac9e2 100644 --- a/drivers/staging/wfx/sta.h +++ b/drivers/staging/wfx/sta.h @@ -66,6 +66,7 @@ void wfx_cooling_timeout_work(struct work_struct *work); void wfx_suspend_hot_dev(struct wfx_dev *wdev, enum sta_notify_cmd cmd); void wfx_suspend_resume_mc(struct wfx_vif *wvif, enum sta_notify_cmd cmd); void wfx_event_report_rssi(struct wfx_vif *wvif, u8 raw_rcpi_rssi); +int wfx_update_pm(struct wfx_vif *wvif); // Other Helpers void wfx_reset(struct wfx_vif *wvif); diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 0c44b733ef6f..477c08fc713f 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -59,6 +59,7 @@ struct wfx_dev { struct mutex rx_stats_lock; struct hif_tx_power_loop_info tx_power_loop_info; struct mutex tx_power_loop_info_lock; + int force_ps_timeout; }; struct wfx_vif { -- cgit v1.2.3-58-ga151 From 14442181d20490945f341644bb8257e334b01447 Mon Sep 17 00:00:00 2001 From: Jérôme Pouiller Date: Wed, 1 Jul 2020 17:07:07 +0200 Subject: staging: wfx: always enable FastPs in combo with new firmwares MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When multiple interface on different channels are in use. It is necessary to advertise the AP that the device is no more awake before to switch to the other channel. Until now, PS-Poll was the preferred mechanism for that. However. The new firmwares (>= 3.7) now nicely support FastPS. FastPS improves bandwidth and compatibility with AP. This patch drop the complex and rarely used mechanism introduced in the commit dd5eba1bb5b4f ("staging: wfx: fix support for AP that do not support PS-Poll") and use FastPS as soon as it is possible. Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200701150707.222985-14-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/hif_rx.c | 8 +------- drivers/staging/wfx/sta.c | 16 +++------------- drivers/staging/wfx/wfx.h | 2 -- 3 files changed, 4 insertions(+), 22 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index e3ebd910fabf..cc7c0cf226ba 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -149,7 +149,6 @@ static int hif_event_indication(struct wfx_dev *wdev, struct wfx_vif *wvif = wdev_to_wvif(wdev, hif->interface); const struct hif_ind_event *body = buf; int type = le32_to_cpu(body->event_id); - int cause; if (!wvif) { dev_warn(wdev->dev, "received event for non-existent vif\n"); @@ -168,13 +167,8 @@ static int hif_event_indication(struct wfx_dev *wdev, dev_dbg(wdev->dev, "ignore BSSREGAINED indication\n"); break; case HIF_EVENT_IND_PS_MODE_ERROR: - cause = le32_to_cpu(body->event_data.ps_mode_error); dev_warn(wdev->dev, "error while processing power save request: %d\n", - cause); - if (cause == HIF_PS_ERROR_AP_NOT_RESP_TO_POLL) { - wvif->bss_not_support_ps_poll = true; - schedule_work(&wvif->update_pm_work); - } + le32_to_cpu(body->event_data.ps_mode_error)); break; default: dev_warn(wdev->dev, "unhandled event indication: %.2x\n", diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index fdf4f48ddc2c..4e30ab17a93d 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -219,10 +219,10 @@ static int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps) *enable_ps = true; if (wvif->wdev->force_ps_timeout > -1) return wvif->wdev->force_ps_timeout; - else if (wvif->bss_not_support_ps_poll) - return 30; - else + else if (wfx_api_older_than(wvif->wdev, 3, 2)) return 0; + else + return 30; } if (enable_ps) *enable_ps = wvif->vif->bss_conf.ps; @@ -255,14 +255,6 @@ int wfx_update_pm(struct wfx_vif *wvif) return hif_set_pm(wvif, ps, ps_timeout); } -static void wfx_update_pm_work(struct work_struct *work) -{ - struct wfx_vif *wvif = container_of(work, struct wfx_vif, - update_pm_work); - - wfx_update_pm(wvif); -} - int wfx_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, const struct ieee80211_tx_queue_params *params) { @@ -372,7 +364,6 @@ void wfx_reset(struct wfx_vif *wvif) hif_set_block_ack_policy(wvif, 0xFF, 0xFF); wfx_tx_unlock(wdev); wvif->join_in_progress = false; - wvif->bss_not_support_ps_poll = false; cancel_delayed_work_sync(&wvif->beacon_loss_work); wvif = NULL; while ((wvif = wvif_iterate(wdev, wvif)) != NULL) @@ -790,7 +781,6 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) init_completion(&wvif->set_pm_mode_complete); complete(&wvif->set_pm_mode_complete); - INIT_WORK(&wvif->update_pm_work, wfx_update_pm_work); INIT_WORK(&wvif->tx_policy_upload_work, wfx_tx_policy_upload_work); mutex_init(&wvif->scan_lock); diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 477c08fc713f..38e24d7f72f2 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -93,8 +93,6 @@ struct wfx_vif { bool scan_abort; struct ieee80211_scan_request *scan_req; - bool bss_not_support_ps_poll; - struct work_struct update_pm_work; struct completion set_pm_mode_complete; }; -- cgit v1.2.3-58-ga151 From d4e03146b00395e82b8db22a0c2e867c7224b7c9 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 6 Jul 2020 14:20:17 +0100 Subject: staging: wfx: fix uninitialized variable bytes_done MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variable bytes_done is not initialized and hence the first FIFO size check on bytes_done may be breaking prematurely from the loop if bytes_done contains a large bogus uninitialized value. Fix this by initializing bytes_done to zero. Addresses-Coverity: ("Uninitialized scalar variable") Fixes: a9408ad79ff3 ("staging: wfx: load the firmware faster") Signed-off-by: Colin Ian King Reviewed-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20200706132017.487627-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/fwio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/fwio.c b/drivers/staging/wfx/fwio.c index d9a886f3e64b..206c6cf6511c 100644 --- a/drivers/staging/wfx/fwio.c +++ b/drivers/staging/wfx/fwio.c @@ -177,7 +177,7 @@ static int wait_ncp_status(struct wfx_dev *wdev, u32 status) static int upload_firmware(struct wfx_dev *wdev, const u8 *data, size_t len) { int ret; - u32 offs, bytes_done; + u32 offs, bytes_done = 0; ktime_t now, start; if (len % DNLD_BLOCK_SIZE) { -- cgit v1.2.3-58-ga151 From 354d6ca9d99790e037bf06f093634e851d1253ee Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 3 Jul 2020 15:07:56 +0200 Subject: staging: wfx: Get descriptors for GPIOs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code has the functionality to insert the GPIO lines using the global GPIO numbers through module parameters. As we are clearly deprecating the use of global GPIO numbers look up the GPIO descriptors from the device instead. This usually falls back to device hardware descriptions using e.g. device tree or ACPI. This device clearly supports device tree when used over SPI for example. For example, this can be supplied in the device tree like so: wfx@0x01 { compatible = "silabs,wf200"; reset-gpios = <&gpio0 1>; wakeup-gpios = <&gpio0 2>; }; Cc: Jérôme Pouiller Reviewed-by: Jérôme Pouiller Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20200703130756.514868-1-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/bus_spi.c | 14 ++++++------- drivers/staging/wfx/main.c | 47 +++++++------------------------------------ drivers/staging/wfx/main.h | 2 -- 3 files changed, 14 insertions(+), 49 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c index e8da61fb096b..d19c0478e8be 100644 --- a/drivers/staging/wfx/bus_spi.c +++ b/drivers/staging/wfx/bus_spi.c @@ -8,7 +8,6 @@ */ #include #include -#include #include #include #include @@ -21,10 +20,6 @@ #include "main.h" #include "bh.h" -static int gpio_reset = -2; -module_param(gpio_reset, int, 0644); -MODULE_PARM_DESC(gpio_reset, "gpio number for reset. -1 for none."); - #define SET_WRITE 0x7FFF /* usage: and operation */ #define SET_READ 0x8000 /* usage: or operation */ @@ -211,10 +206,15 @@ static int wfx_spi_probe(struct spi_device *func) bus->need_swab = true; spi_set_drvdata(func, bus); - bus->gpio_reset = wfx_get_gpio(&func->dev, gpio_reset, "reset"); + bus->gpio_reset = devm_gpiod_get_optional(&func->dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(bus->gpio_reset)) + return PTR_ERR(bus->gpio_reset); if (!bus->gpio_reset) { - dev_warn(&func->dev, "try to load firmware anyway\n"); + dev_warn(&func->dev, + "gpio reset is not defined, trying to load firmware anyway\n"); } else { + gpiod_set_consumer_name(bus->gpio_reset, "wfx reset"); if (spi_get_device_id(func)->driver_data & WFX_RESET_INVERTED) gpiod_toggle_active_low(bus->gpio_reset); gpiod_set_value_cansleep(bus->gpio_reset, 1); diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 62e3634556ec..11dfa088fc86 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -41,10 +40,6 @@ MODULE_DESCRIPTION("Silicon Labs 802.11 Wireless LAN driver for WFx"); MODULE_AUTHOR("Jérôme Pouiller "); MODULE_LICENSE("GPL"); -static int gpio_wakeup = -2; -module_param(gpio_wakeup, int, 0644); -MODULE_PARM_DESC(gpio_wakeup, "gpio number for wakeup. -1 for none."); - #define RATETAB_ENT(_rate, _rateid, _flags) { \ .bitrate = (_rate), \ .hw_value = (_rateid), \ @@ -170,38 +165,6 @@ bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor) return false; } -struct gpio_desc *wfx_get_gpio(struct device *dev, - int override, const char *label) -{ - struct gpio_desc *ret; - char label_buf[256]; - - if (override >= 0) { - snprintf(label_buf, sizeof(label_buf), "wfx_%s", label); - ret = ERR_PTR(devm_gpio_request_one(dev, override, - GPIOF_OUT_INIT_LOW, - label_buf)); - if (!ret) - ret = gpio_to_desc(override); - } else if (override == -1) { - ret = NULL; - } else { - ret = devm_gpiod_get(dev, label, GPIOD_OUT_LOW); - } - if (IS_ERR_OR_NULL(ret)) { - if (!ret || PTR_ERR(ret) == -ENOENT) - dev_warn(dev, "gpio %s is not defined\n", label); - else - dev_warn(dev, "error while requesting gpio %s\n", - label); - ret = NULL; - } else { - dev_dbg(dev, "using gpio %d for %s\n", - desc_to_gpio(ret), label); - } - return ret; -} - /* NOTE: wfx_send_pds() destroy buf */ int wfx_send_pds(struct wfx_dev *wdev, u8 *buf, size_t len) { @@ -340,7 +303,12 @@ struct wfx_dev *wfx_init_common(struct device *dev, memcpy(&wdev->pdata, pdata, sizeof(*pdata)); of_property_read_string(dev->of_node, "config-file", &wdev->pdata.file_pds); - wdev->pdata.gpio_wakeup = wfx_get_gpio(dev, gpio_wakeup, "wakeup"); + wdev->pdata.gpio_wakeup = devm_gpiod_get_optional(dev, "wakeup", + GPIOD_OUT_LOW); + if (IS_ERR(wdev->pdata.gpio_wakeup)) + return ERR_CAST(wdev->pdata.gpio_wakeup); + if (wdev->pdata.gpio_wakeup) + gpiod_set_consumer_name(wdev->pdata.gpio_wakeup, "wfx wakeup"); wfx_sl_fill_pdata(dev, &wdev->pdata); mutex_init(&wdev->conf_mutex); @@ -444,8 +412,7 @@ int wfx_probe(struct wfx_dev *wdev) wdev->pdata.gpio_wakeup = gpio_saved; if (wdev->pdata.gpio_wakeup) { dev_dbg(wdev->dev, - "enable 'quiescent' power mode with gpio %d and PDS file %s\n", - desc_to_gpio(wdev->pdata.gpio_wakeup), + "enable 'quiescent' power mode with wakeup GPIO and PDS file %s\n", wdev->pdata.file_pds); gpiod_set_value_cansleep(wdev->pdata.gpio_wakeup, 1); control_reg_write(wdev, 0); diff --git a/drivers/staging/wfx/main.h b/drivers/staging/wfx/main.h index f832ce409fda..c59d375dd3ad 100644 --- a/drivers/staging/wfx/main.h +++ b/drivers/staging/wfx/main.h @@ -38,8 +38,6 @@ struct wfx_dev *wfx_init_common(struct device *dev, int wfx_probe(struct wfx_dev *wdev); void wfx_release(struct wfx_dev *wdev); -struct gpio_desc *wfx_get_gpio(struct device *dev, int override, - const char *label); bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor); int wfx_send_pds(struct wfx_dev *wdev, u8 *buf, size_t len); -- cgit v1.2.3-58-ga151 From 056535320bc2d4d2d246df6369ff3d37a72f0148 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 3 Jul 2020 14:26:03 +0200 Subject: staging: rtl8192u: remove GPL boiler plate text The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. The file ieee80211_module.c has a proper SPDX line, so the GPL boiler plate text is not needed. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200703122604.12096-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_module.c | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c index a5a1b14f5a40..c52540b734fd 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c @@ -9,22 +9,6 @@ * * Copyright (c) 2002-2003, Jouni Malinen * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * * Contact Information: * James P. Ketrenos * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 -- cgit v1.2.3-58-ga151 From cecc7dca16bef2a4cb1f9d0baf853a6adcd19ade Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 3 Jul 2020 14:26:04 +0200 Subject: staging: rtl8192u: remove copying file All source and header files have a GPL-2.0 SPDX identifier. The 'copying' file with the whole GPL text is not needed, delete it. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200703122604.12096-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/copying | 340 --------------------------------------- 1 file changed, 340 deletions(-) delete mode 100644 drivers/staging/rtl8192u/copying (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/copying b/drivers/staging/rtl8192u/copying deleted file mode 100644 index e90dfed1a31e..000000000000 --- a/drivers/staging/rtl8192u/copying +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. -- cgit v1.2.3-58-ga151 From 12414fa87ba5cdc685bb56c10def39bdfe9d8a6e Mon Sep 17 00:00:00 2001 From: Mauro Dreissig Date: Sun, 5 Jul 2020 15:09:44 -0300 Subject: staging: rtl8712: Annotate r8712_sitesurvey_cmd() Add __must_hold() sparse annotation to r8712_sitesurvey_cmd(), replacing the comments on top of the function. Signed-off-by: Mauro Dreissig Link: https://lore.kernel.org/r/20200705180944.20958-1-mukadr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 26b618008fcf..c7523072a660 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -168,14 +168,9 @@ void r8712_free_cmd_obj(struct cmd_obj *pcmd) kfree(pcmd); } -/* - * r8712_sitesurvey_cmd(~) - * ### NOTE:#### (!!!!) - * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, - * YOU SHOULD HAVE LOCKED pmlmepriv->lock - */ u8 r8712_sitesurvey_cmd(struct _adapter *padapter, struct ndis_802_11_ssid *pssid) + __must_hold(&padapter->mlmepriv.lock) { struct cmd_obj *ph2c; struct sitesurvey_parm *psurveyPara; -- cgit v1.2.3-58-ga151 From eab439bee0ab0411a5768d1a0f31f8406d954726 Mon Sep 17 00:00:00 2001 From: John Oldman Date: Mon, 6 Jul 2020 17:22:40 +0100 Subject: staging: rtl8192u: Using comparison to true is error prone clear below issues reported by checkpatch.pl: CHECK: Using comparison to false is error prone Signed-off-by: John Oldman Link: https://lore.kernel.org/r/20200706162240.2770-1-john.oldman@polehill.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index c23e43b095d9..6b301acb584e 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2240,7 +2240,7 @@ static void dm_ctstoself(struct net_device *dev) unsigned long curTxOkCnt = 0; unsigned long curRxOkCnt = 0; - if (priv->ieee80211->bCTSToSelfEnable != true) { + if (!priv->ieee80211->bCTSToSelfEnable) { pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; return; } @@ -2944,7 +2944,7 @@ static void dm_dynamic_txpower(struct net_device *dev) unsigned int txhipower_threshold = 0; unsigned int txlowpower_threshold = 0; - if (priv->ieee80211->bdynamic_txpower_enable != true) { + if (!priv->ieee80211->bdynamic_txpower_enable) { priv->bDynamicTxHighPower = false; priv->bDynamicTxLowPower = false; return; -- cgit v1.2.3-58-ga151 From e49fa0b7394d5a273dbd7a3b8e3c9a103710c920 Mon Sep 17 00:00:00 2001 From: John Oldman Date: Tue, 7 Jul 2020 12:41:28 +0100 Subject: staging: rtl8723bs: Using comparison to true is error prone clear below issues reported by checkpatch.pl: CHECK: Using comparison to false is error prone CHECK: Using comparison to true is error pron Signed-off-by: John Oldman Link: https://lore.kernel.org/r/20200707114128.30312-1-john.oldman@polehill.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 70 +++++++++++++---------------- 1 file changed, 32 insertions(+), 38 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 50a3c2c3a8d2..27f990a01a23 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -313,7 +313,7 @@ static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); struct sockaddr *addr = p; - if (padapter->bup == false) { + if (!padapter->bup) { /* DBG_871X("r8711_net_set_mac_address(), MAC =%x:%x:%x:%x:%x:%x\n", addr->sa_data[0], addr->sa_data[1], addr->sa_data[2], addr->sa_data[3], */ /* addr->sa_data[4], addr->sa_data[5]); */ memcpy(padapter->eeprompriv.mac_addr, addr->sa_data, ETH_ALEN); @@ -897,12 +897,12 @@ int _netdev_open(struct net_device *pnetdev) padapter->netif_up = true; - if (pwrctrlpriv->ps_flag == true) { + if (pwrctrlpriv->ps_flag) { padapter->net_closed = false; goto netdev_open_normal_process; } - if (padapter->bup == false) { + if (!padapter->bup) { padapter->bDriverStopped = false; padapter->bSurpriseRemoved = false; padapter->bCardDisableWOHSM = false; @@ -964,7 +964,7 @@ int netdev_open(struct net_device *pnetdev) struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter); - if (pwrctrlpriv->bInSuspend == true) { + if (pwrctrlpriv->bInSuspend) { DBG_871X("+871x_drv - drv_open, bInSuspend =%d\n", pwrctrlpriv->bInSuspend); return 0; } @@ -1041,7 +1041,7 @@ void rtw_ips_dev_unload(struct adapter *padapter) DBG_871X("====> %s...\n", __func__); - if (padapter->bSurpriseRemoved == false) + if (!padapter->bSurpriseRemoved) rtw_hal_deinit(padapter); } @@ -1052,7 +1052,7 @@ static int pm_netdev_open(struct net_device *pnetdev, u8 bnormal) struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); - if (true == bnormal) { + if (bnormal) { if (mutex_lock_interruptible(&(adapter_to_dvobj(padapter)->hw_init_mutex)) == 0) { status = _netdev_open(pnetdev); mutex_unlock(&(adapter_to_dvobj(padapter)->hw_init_mutex)); @@ -1071,7 +1071,7 @@ static int netdev_close(struct net_device *pnetdev) RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+871x_drv - drv_close\n")); - if (pwrctl->bInternalAutoSuspend == true) { + if (pwrctl->bInternalAutoSuspend) { /* rtw_pwr_wakeup(padapter); */ if (pwrctl->rf_pwrstate == rf_off) pwrctl->ps_flag = true; @@ -1134,7 +1134,7 @@ void rtw_dev_unload(struct adapter *padapter) RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("+%s\n", __func__)); - if (padapter->bup == true) { + if (padapter->bup) { DBG_871X("===> %s\n", __func__); padapter->bDriverStopped = true; @@ -1149,7 +1149,7 @@ void rtw_dev_unload(struct adapter *padapter) if (!pwrctl->bInternalAutoSuspend) rtw_stop_drv_threads(padapter); - while (atomic_read(&(pcmdpriv->cmdthd_running)) == true) { + while (atomic_read(&pcmdpriv->cmdthd_running)) { if (cnt > 5) { DBG_871X("stop cmdthd timeout\n"); break; @@ -1163,7 +1163,8 @@ void rtw_dev_unload(struct adapter *padapter) RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("@ %s: stop thread complete!\n", __func__)); /* check the status of IPS */ - if (rtw_hal_check_ips_status(padapter) == true || pwrctl->rf_pwrstate == rf_off) { /* check HW status and SW state */ + if (rtw_hal_check_ips_status(padapter) || pwrctl->rf_pwrstate == rf_off) { + /* check HW status and SW state */ DBG_871X_LEVEL(_drv_always_, "%s: driver in IPS-FWLPS\n", __func__); pdbgpriv->dbg_dev_unload_inIPS_cnt++; LeaveAllPowerSaveMode(padapter); @@ -1171,11 +1172,10 @@ void rtw_dev_unload(struct adapter *padapter) DBG_871X_LEVEL(_drv_always_, "%s: driver not in IPS\n", __func__); } - if (padapter->bSurpriseRemoved == false) { + if (!padapter->bSurpriseRemoved) { hal_btcoex_IpsNotify(padapter, pwrctl->ips_mode_req); #ifdef CONFIG_WOWLAN - if (pwrctl->bSupportRemoteWakeup == true && - pwrctl->wowlan_mode == true) { + if (pwrctl->bSupportRemoteWakeup && pwrctl->wowlan_mode) { DBG_871X_LEVEL(_drv_always_, "%s bSupportRemoteWakeup ==true do not run rtw_hal_deinit()\n", __func__); } else @@ -1235,7 +1235,7 @@ static int rtw_suspend_free_assoc_resource(struct adapter *padapter) if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) rtw_indicate_scan_done(padapter, 1); - if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { DBG_871X_LEVEL(_drv_always_, "%s: fw_under_linking\n", __func__); rtw_indicate_disconnect(padapter); } @@ -1259,7 +1259,7 @@ void rtw_suspend_wow(struct adapter *padapter) DBG_871X("wowlan_mode: %d\n", pwrpriv->wowlan_mode); DBG_871X("wowlan_pno_enable: %d\n", pwrpriv->wowlan_pno_enable); - if (pwrpriv->wowlan_mode == true) { + if (pwrpriv->wowlan_mode) { if (pnetdev) rtw_netif_stop_queue(pnetdev); /* 1. stop thread */ @@ -1283,8 +1283,7 @@ void rtw_suspend_wow(struct adapter *padapter) poidparam.subcode = WOWLAN_ENABLE; padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_WOWLAN, (u8 *)&poidparam); if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) { - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) - && check_fwstate(pmlmepriv, _FW_LINKED)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED)) { DBG_871X("%s %s(" MAC_FMT "), length:%d assoc_ssid.length:%d\n", __func__, pmlmepriv->cur_network.network.Ssid.Ssid, MAC_ARG(pmlmepriv->cur_network.network.MacAddress), @@ -1297,7 +1296,7 @@ void rtw_suspend_wow(struct adapter *padapter) DBG_871X_LEVEL(_drv_always_, "%s: wowmode suspending\n", __func__); - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { DBG_871X_LEVEL(_drv_always_, "%s: fw_under_survey\n", __func__); rtw_indicate_scan_done(padapter, 1); clr_fwstate(pmlmepriv, _FW_UNDER_SURVEY); @@ -1313,8 +1312,7 @@ void rtw_suspend_wow(struct adapter *padapter) DBG_871X_LEVEL(_drv_always_, "%s: pno: %d\n", __func__, pwrpriv->wowlan_pno_enable); else rtw_set_ps_mode(padapter, PS_MODE_DTIM, 0, 0, "WOWLAN"); - } - else { + } else { DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR ### wowlan_mode =%d\n", __func__, pwrpriv->wowlan_mode); } DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter)); @@ -1385,10 +1383,8 @@ static void rtw_suspend_normal(struct adapter *padapter) rtw_suspend_free_assoc_resource(padapter); - if ((rtw_hal_check_ips_status(padapter) == true) - || (adapter_to_pwrctl(padapter)->rf_pwrstate == rf_off)) { + if ((rtw_hal_check_ips_status(padapter)) || (adapter_to_pwrctl(padapter)->rf_pwrstate == rf_off)) DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR #### driver in IPS ####ERROR###!!!\n", __func__); - } rtw_dev_unload(padapter); @@ -1415,7 +1411,7 @@ int rtw_suspend_common(struct adapter *padapter) pwrpriv->bInSuspend = true; - while (pwrpriv->bips_processing == true) + while (pwrpriv->bips_processing) msleep(1); if ((!padapter->bup) || (padapter->bDriverStopped) || (padapter->bSurpriseRemoved)) { @@ -1433,24 +1429,24 @@ int rtw_suspend_common(struct adapter *padapter) rtw_stop_cmd_thread(padapter); /* wait for the latest FW to remove this condition. */ - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { hal_btcoex_SuspendNotify(padapter, 0); DBG_871X("WIFI_AP_STATE\n"); - } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { hal_btcoex_SuspendNotify(padapter, 1); DBG_871X("STATION\n"); } rtw_ps_deny_cancel(padapter, PS_DENY_SUSPEND); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { #ifdef CONFIG_WOWLAN if (check_fwstate(pmlmepriv, _FW_LINKED)) pwrpriv->wowlan_mode = true; - else if (pwrpriv->wowlan_pno_enable == true) + else if (pwrpriv->wowlan_pno_enable) pwrpriv->wowlan_mode |= pwrpriv->wowlan_pno_enable; - if (pwrpriv->wowlan_mode == true) + if (pwrpriv->wowlan_mode) rtw_suspend_wow(padapter); else rtw_suspend_normal(padapter); @@ -1458,7 +1454,7 @@ int rtw_suspend_common(struct adapter *padapter) #else /* CONFIG_WOWLAN */ rtw_suspend_normal(padapter); #endif /* CONFIG_WOWLAN */ - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { #ifdef CONFIG_AP_WOWLAN rtw_suspend_ap_wow(padapter); #else @@ -1513,7 +1509,7 @@ int rtw_resume_process_wow(struct adapter *padapter) pwrpriv->pno_in_resume = true; #endif - if (pwrpriv->wowlan_mode == true) { + if (pwrpriv->wowlan_mode) { rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "WOWLAN"); pwrpriv->bFwCurrentInPSMode = false; @@ -1553,8 +1549,7 @@ int rtw_resume_process_wow(struct adapter *padapter) else rtw_netif_wake_queue(pnetdev); } - } - else { + } else { DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR ### wowlan_mode =%d\n", __func__, pwrpriv->wowlan_mode); } @@ -1584,7 +1579,7 @@ int rtw_resume_process_wow(struct adapter *padapter) } } - if (pwrpriv->wowlan_mode == true) { + if (pwrpriv->wowlan_mode) { pwrpriv->bips_processing = false; _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000); } else { @@ -1730,7 +1725,6 @@ static int rtw_resume_process_normal(struct adapter *padapter) rtw_signal_process(padapter->pid[1], SIGUSR2); } - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { DBG_871X(FUNC_ADPT_FMT " fwstate:0x%08x - WIFI_STATION_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv)); @@ -1762,9 +1756,9 @@ int rtw_resume_common(struct adapter *padapter) DBG_871X_LEVEL(_drv_always_, "resume start\n"); DBG_871X("==> %s (%s:%d)\n", __func__, current->comm, current->pid); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { #ifdef CONFIG_WOWLAN - if (pwrpriv->wowlan_mode == true) + if (pwrpriv->wowlan_mode) rtw_resume_process_wow(padapter); else rtw_resume_process_normal(padapter); @@ -1772,7 +1766,7 @@ int rtw_resume_common(struct adapter *padapter) rtw_resume_process_normal(padapter); #endif - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { #ifdef CONFIG_AP_WOWLAN rtw_resume_process_ap_wow(padapter); #else -- cgit v1.2.3-58-ga151 From deb34767b2b23d330aa226d5ef4209f52acfb127 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 7 Jul 2020 14:43:50 -0500 Subject: staging: vt6655: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200707194350.GA3255@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/channel.c | 2 +- drivers/staging/vt6655/key.c | 6 +++--- drivers/staging/vt6656/channel.c | 2 +- drivers/staging/vt6656/key.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index 62a85c1ca6c4..889fc22f19bd 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -133,7 +133,7 @@ void vnt_init_bands(struct vnt_private *priv) priv->hw->wiphy->bands[NL80211_BAND_5GHZ] = &vnt_supported_5ghz_band; - /* fallthrough */ + fallthrough; case RF_RFMD2959: case RF_AIROHA: case RF_AL2230S: diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index 4d6b48fd119d..94665ddc36a5 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -51,15 +51,15 @@ static int vnt_set_keymode(struct ieee80211_hw *hw, u8 *mac_addr, /* default key last entry */ entry = MAX_KEY_TABLE - 1; key->hw_key_idx = entry; - /* fall through */ + fallthrough; case VNT_KEY_ALLGROUP: key_mode |= VNT_KEY_ALLGROUP; if (onfly_latch) key_mode |= VNT_KEY_ONFLY_ALL; - /* fall through */ + fallthrough; case VNT_KEY_GROUP_ADDRESS: key_mode |= mode; - /* fall through */ + fallthrough; case VNT_KEY_GROUP: key_mode |= (mode << 4); key_mode |= VNT_KEY_GROUP; diff --git a/drivers/staging/vt6656/channel.c b/drivers/staging/vt6656/channel.c index 5d57d34577f5..7855689af7cb 100644 --- a/drivers/staging/vt6656/channel.c +++ b/drivers/staging/vt6656/channel.c @@ -145,7 +145,7 @@ void vnt_init_bands(struct vnt_private *priv) priv->hw->wiphy->bands[NL80211_BAND_5GHZ] = &vnt_supported_5ghz_band; - /* fallthrough */ + fallthrough; case RF_AL2230: case RF_AL2230S: case RF_VT3226: diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c index c66cb53cfc09..70f75c5760ce 100644 --- a/drivers/staging/vt6656/key.c +++ b/drivers/staging/vt6656/key.c @@ -67,7 +67,7 @@ static int vnt_set_keymode(struct ieee80211_hw *hw, u8 *mac_addr, /* default key last entry */ entry = MAX_KEY_TABLE - 1; key->hw_key_idx = entry; - /* fall through */ + fallthrough; case VNT_KEY_GROUP_ADDRESS: key_mode = mode | (mode << 4); break; -- cgit v1.2.3-58-ga151 From 50ce87829fc34a6ce1c67153a63b4007788f72f0 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Tue, 7 Jul 2020 13:20:08 -0500 Subject: staging: rtl8188eu: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200707182008.GA341@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8188eu/hal/usb_halinit.c | 2 +- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index f6b9a39799ce..46a0ac08e90a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -4132,7 +4132,7 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) ptable->func = &OnAuth; else ptable->func = &OnAuthClient; - /* fall through */ + fallthrough; case WIFI_ASSOCREQ: case WIFI_REASSOCREQ: case WIFI_PROBEREQ: diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 16a57b31a439..114638f6f719 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -1728,7 +1728,7 @@ void rtw_hal_get_hwreg(struct adapter *Adapter, u8 variable, u8 *val) switch (variable) { case HW_VAR_BASIC_RATE: *((u16 *)(val)) = Adapter->HalData->BasicRateSet; - /* fall through */ + fallthrough; case HW_VAR_TXPAUSE: val[0] = usb_read8(Adapter, REG_TXPAUSE); break; diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index 3cd6da1f843d..a80c7f3b86d1 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -400,7 +400,7 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) case -ENODEV: case -ESHUTDOWN: adapt->bSurpriseRemoved = true; - /* fall through */ + fallthrough; case -ENOENT: adapt->bDriverStopped = true; RT_TRACE(_module_hci_ops_os_c_, _drv_err_, -- cgit v1.2.3-58-ga151 From 2145021c44b4bc06419b3a45d814880ac8de7dde Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 8 Jul 2020 20:31:17 +0200 Subject: Staging: nvec: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200708183117.16563-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/nvec/README b/drivers/staging/nvec/README index 0e2d5c4c875f..510e6933f402 100644 --- a/drivers/staging/nvec/README +++ b/drivers/staging/nvec/README @@ -10,5 +10,5 @@ but the source code[1] of the published nvec reference drivers can be a guide. This driver is currently only used by the AC100 project[2], but it is likely, that other Tegra boards (not yet mainlined, if ever) also use it. -[1] e.g. http://nv-tegra.nvidia.com/gitweb/?p=linux-2.6.git;a=tree;f=arch/arm/mach-tegra/nvec;hb=android-tegra-2.6.32 +[1] e.g. https://nv-tegra.nvidia.com/gitweb/?p=linux-2.6.git;a=tree;f=arch/arm/mach-tegra/nvec;hb=android-tegra-2.6.32 [2] http://gitorious.org/ac100, http://launchpad.net/ac100 -- cgit v1.2.3-58-ga151 From 4911537c6b4115f4fd49e1190013555681735d74 Mon Sep 17 00:00:00 2001 From: Mauro Dreissig Date: Sun, 5 Jul 2020 11:35:48 -0300 Subject: staging: rtl8712: Replace constant 49152 with expression 48 * 1024 This way we don't need the comment stating that 49152 equals 48k. Signed-off-by: Mauro Dreissig Link: https://lore.kernel.org/r/20200705143552.9368-2-mukadr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index 7293cdc3a43b..1f5ba9cbe951 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -27,7 +27,7 @@ #include "usb_osintf.h" #define FWBUFF_ALIGN_SZ 512 -#define MAX_DUMP_FWSZ 49152 /*default = 49152 (48k)*/ +#define MAX_DUMP_FWSZ (48 * 1024) static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) { -- cgit v1.2.3-58-ga151 From 4e4a6b7c18ef21abe8771f131c1ef80655769adb Mon Sep 17 00:00:00 2001 From: Mauro Dreissig Date: Sun, 5 Jul 2020 11:35:49 -0300 Subject: staging: rtl8712: Simplify expressions with boolean logic Simplify some expressions by using boolean operations. Signed-off-by: Mauro Dreissig Link: https://lore.kernel.org/r/20200705143552.9368-3-mukadr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 4 ++-- drivers/staging/rtl8712/osdep_intf.h | 2 +- drivers/staging/rtl8712/rtl8712_recv.c | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index 1f5ba9cbe951..d3fc6fa9a715 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -99,12 +99,12 @@ static void fill_fwpriv(struct _adapter *adapter, struct fw_priv *fwpriv) default: fwpriv->rf_config = RTL8712_RFC_1T2R; } - fwpriv->mp_mode = (regpriv->mp_mode == 1) ? 1 : 0; + fwpriv->mp_mode = (regpriv->mp_mode == 1); /* 0:off 1:on 2:auto */ fwpriv->vcs_type = regpriv->vrtl_carrier_sense; fwpriv->vcs_mode = regpriv->vcs_type; /* 1:RTS/CTS 2:CTS to self */ /* default enable turbo_mode */ - fwpriv->turbo_mode = ((regpriv->wifi_test == 1) ? 0 : 1); + fwpriv->turbo_mode = (regpriv->wifi_test != 1); fwpriv->low_power_mode = regpriv->low_power; } diff --git a/drivers/staging/rtl8712/osdep_intf.h b/drivers/staging/rtl8712/osdep_intf.h index 2cc25db1a91d..9e75116c987e 100644 --- a/drivers/staging/rtl8712/osdep_intf.h +++ b/drivers/staging/rtl8712/osdep_intf.h @@ -17,7 +17,7 @@ #include "osdep_service.h" #include "drv_types.h" -#define RND4(x) (((x >> 2) + (((x & 3) == 0) ? 0 : 1)) << 2) +#define RND4(x) (((x >> 2) + ((x & 3) != 0)) << 2) struct intf_priv { u8 *intf_dev; diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index c513cda2a49e..d83f421acfc1 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -143,9 +143,8 @@ static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib, /*TODO: * Offset 0 */ - pattrib->bdecrypted = ((le32_to_cpu(prxstat->rxdw0) & BIT(27)) >> 27) - ? 0 : 1; - pattrib->crc_err = (le32_to_cpu(prxstat->rxdw0) & BIT(14)) >> 14; + pattrib->bdecrypted = (le32_to_cpu(prxstat->rxdw0) & BIT(27)) == 0; + pattrib->crc_err = (le32_to_cpu(prxstat->rxdw0) & BIT(14)) != 0; /*Offset 4*/ /*Offset 8*/ /*Offset 12*/ -- cgit v1.2.3-58-ga151 From f1c9ea1acf58f22f6e7c664f229e72d2a0c9bdea Mon Sep 17 00:00:00 2001 From: Mauro Dreissig Date: Sun, 5 Jul 2020 11:35:50 -0300 Subject: staging: rtl8712: Use ETH_ALEN instead of hardcoded value Use macro ETH_ALEN which defines the number of octets in an ethernet address. Signed-off-by: Mauro Dreissig Link: https://lore.kernel.org/r/20200705143552.9368-4-mukadr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index d3fc6fa9a715..d53efdfc9bf0 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -343,7 +343,7 @@ uint rtl8712_hal_init(struct _adapter *padapter) /* Fix the RX FIFO issue(USB error) */ r8712_write8(padapter, 0x1025fe5C, r8712_read8(padapter, 0x1025fe5C) | BIT(7)); - for (i = 0; i < 6; i++) + for (i = 0; i < ETH_ALEN; i++) padapter->eeprompriv.mac_addr[i] = r8712_read8(padapter, MACID + i); return _SUCCESS; -- cgit v1.2.3-58-ga151 From f1a4423ffa86643bad4ae1a8f9da3500d9f3cbd2 Mon Sep 17 00:00:00 2001 From: Mauro Dreissig Date: Sun, 5 Jul 2020 11:35:51 -0300 Subject: staging: rtl8712: Remove variable 'raw' from rtl871x_open_fw() Remove useless variable 'raw' from function rtl871x_open_fw() making the code a bit easier to understand. Signed-off-by: Mauro Dreissig Link: https://lore.kernel.org/r/20200705143552.9368-5-mukadr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index d53efdfc9bf0..d7b30152d409 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -67,15 +67,13 @@ MODULE_FIRMWARE("rtlwifi/rtl8712u.bin"); static u32 rtl871x_open_fw(struct _adapter *adapter, const u8 **mappedfw) { - const struct firmware **raw = &adapter->fw; - if (adapter->fw->size > 200000) { dev_err(&adapter->pnetdev->dev, "r8172u: Badfw->size of %d\n", (int)adapter->fw->size); return 0; } - *mappedfw = (*raw)->data; - return (*raw)->size; + *mappedfw = adapter->fw->data; + return adapter->fw->size; } static void fill_fwpriv(struct _adapter *adapter, struct fw_priv *fwpriv) -- cgit v1.2.3-58-ga151 From a3232e64b4be06460d02ded09c5bd347b0a3a2b8 Mon Sep 17 00:00:00 2001 From: Mauro Dreissig Date: Sun, 5 Jul 2020 11:35:52 -0300 Subject: staging: rtl8712: Use proper format in call to dev_err() In the call to dev_err(), remove the cast of size_t to int and change the format string accordingly. As reported by the kernel test robot, the correct format string for a size_t argument should be %zu. Reported-by: kernel test robot Signed-off-by: Mauro Dreissig Link: https://lore.kernel.org/r/20200705143552.9368-6-mukadr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index d7b30152d409..ed51023b85a0 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -68,8 +68,8 @@ MODULE_FIRMWARE("rtlwifi/rtl8712u.bin"); static u32 rtl871x_open_fw(struct _adapter *adapter, const u8 **mappedfw) { if (adapter->fw->size > 200000) { - dev_err(&adapter->pnetdev->dev, "r8172u: Badfw->size of %d\n", - (int)adapter->fw->size); + dev_err(&adapter->pnetdev->dev, "r8712u: Bad fw->size of %zu\n", + adapter->fw->size); return 0; } *mappedfw = adapter->fw->data; -- cgit v1.2.3-58-ga151 From cb22ab20c969615296475b7068c891ca3a849fa9 Mon Sep 17 00:00:00 2001 From: John Oldman Date: Fri, 10 Jul 2020 12:31:13 +0100 Subject: staging: rtl8712/: Using comparison to true is error prone clear below issues reported by checkpatch.pl: CHECK: Using comparison to true is error prone CHECK: Comparison to NULL should be written "!oldest" Signed-off-by: John Oldman Link: https://lore.kernel.org/r/20200710113113.1648-1-john.oldman@polehill.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_mlme.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index 9ee1bfac0763..2ccd49032206 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -264,13 +264,13 @@ struct wlan_network *r8712_get_oldest_wlan_network( phead = &scanned_queue->queue; plist = phead->next; while (1) { - if (end_of_queue_search(phead, plist) == true) + if (end_of_queue_search(phead, plist)) break; pwlan = container_of(plist, struct wlan_network, list); - if (pwlan->fixed != true) { - if (oldest == NULL || + if (!pwlan->fixed) { + if (!oldest || time_after((unsigned long)oldest->last_scanned, - (unsigned long)pwlan->last_scanned)) + (unsigned long)pwlan->last_scanned)) oldest = pwlan; } plist = plist->next; -- cgit v1.2.3-58-ga151 From 8ffe5f36d7329c1a251ebf80ff9b9111f8739246 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Fri, 10 Jul 2020 13:33:50 -0500 Subject: staging: rts5208: Assign array_size() to a variable Assign array_size() to variable _size_ and use it in multiple places. This issue was found with the help of Coccinelle and, audited and fixed manually. Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83 Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200710183350.GA8376@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index c6f9375468eb..ee9ddc4eb94d 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -1440,6 +1440,7 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, u16 aligned_addr = addr - offset; int dw_len, i, j; int retval; + size_t size; if (!buf) return STATUS_NOMEM; @@ -1451,11 +1452,12 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len); - data = vzalloc(array_size(dw_len, 4)); + size = array_size(dw_len, 4); + data = vzalloc(size); if (!data) return STATUS_NOMEM; - mask = vzalloc(array_size(dw_len, 4)); + mask = vzalloc(size); if (!mask) { vfree(data); return STATUS_NOMEM; @@ -1471,10 +1473,8 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, } } - print_hex_dump_bytes(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, mask, - dw_len * 4); - print_hex_dump_bytes(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, data, - dw_len * 4); + print_hex_dump_bytes(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, mask, size); + print_hex_dump_bytes(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, data, size); for (i = 0; i < dw_len; i++) { retval = rtsx_write_cfg_dw(chip, func, aligned_addr + i * 4, -- cgit v1.2.3-58-ga151 From e4c9b73babb6d7a9f2a68ab19b2d0f05a36d0b22 Mon Sep 17 00:00:00 2001 From: Suraj Upadhyay Date: Sat, 11 Jul 2020 18:46:24 +0530 Subject: staging: rtl8192e: rtl8192E_dev: Remove pci-dma-compat wrapper APIs. The legacy API wrappers in include/linux/pci-dma-compat.h should go away as it creates unnecessary midlayering for include/linux/dma-mapping.h APIs, instead use dma-mapping.h APIs directly. The patch has been generated with the coccinelle script below and compile-tested. @@@@ - PCI_DMA_BIDIRECTIONAL + DMA_BIDIRECTIONAL @@@@ - PCI_DMA_TODEVICE + DMA_TO_DEVICE @@@@ - PCI_DMA_FROMDEVICE + DMA_FROM_DEVICE @@@@ - PCI_DMA_NONE + DMA_NONE @@ expression E1, E2, E3; @@ - pci_alloc_consistent(E1, E2, E3) + dma_alloc_coherent(&E1->dev, E2, E3, GFP_ATOMIC) @@ expression E1, E2, E3; @@ - pci_zalloc_consistent(E1, E2, E3) + dma_alloc_coherent(&E1->dev, E2, E3, GFP_ATOMIC) @@ expression E1, E2, E3, E4; @@ - pci_free_consistent(E1, E2, E3, E4) + dma_free_coherent(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_map_single(E1, E2, E3, E4) + dma_map_single(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_unmap_single(E1, E2, E3, E4) + dma_unmap_single(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4, E5; @@ - pci_map_page(E1, E2, E3, E4, E5) + dma_map_page(&E1->dev, E2, E3, E4, (enum dma_data_direction)E5) @@ expression E1, E2, E3, E4; @@ - pci_unmap_page(E1, E2, E3, E4) + dma_unmap_page(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_map_sg(E1, E2, E3, E4) + dma_map_sg(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_unmap_sg(E1, E2, E3, E4) + dma_unmap_sg(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_single_for_cpu(E1, E2, E3, E4) + dma_sync_single_for_cpu(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_single_for_device(E1, E2, E3, E4) + dma_sync_single_for_device(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_sg_for_cpu(E1, E2, E3, E4) + dma_sync_sg_for_cpu(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_sg_for_device(E1, E2, E3, E4) + dma_sync_sg_for_device(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2; @@ - pci_dma_mapping_error(E1, E2) + dma_mapping_error(&E1->dev, E2) @@ expression E1, E2; @@ - pci_set_consistent_dma_mask(E1, E2) + dma_set_coherent_mask(&E1->dev, E2) @@ expression E1, E2; @@ - pci_set_dma_mask(E1, E2) + dma_set_mask(&E1->dev, E2) Signed-off-by: Suraj Upadhyay Link: https://lore.kernel.org/r/20200711131623.GA20537@blackclown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index ddcd7885d190..9f869fb3eaa8 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -1215,9 +1215,9 @@ void rtl92e_fill_tx_desc(struct net_device *dev, struct tx_desc *pdesc, memset((u8 *)pdesc, 0, 12); - mapping = pci_map_single(priv->pdev, skb->data, skb->len, - PCI_DMA_TODEVICE); - if (pci_dma_mapping_error(priv->pdev, mapping)) { + mapping = dma_map_single(&priv->pdev->dev, skb->data, skb->len, + DMA_TO_DEVICE); + if (dma_mapping_error(&priv->pdev->dev, mapping)) { netdev_err(dev, "%s(): DMA Mapping error\n", __func__); return; } @@ -1282,10 +1282,10 @@ void rtl92e_fill_tx_cmd_desc(struct net_device *dev, struct tx_desc_cmd *entry, struct cb_desc *cb_desc, struct sk_buff *skb) { struct r8192_priv *priv = rtllib_priv(dev); - dma_addr_t mapping = pci_map_single(priv->pdev, skb->data, skb->len, - PCI_DMA_TODEVICE); + dma_addr_t mapping = dma_map_single(&priv->pdev->dev, skb->data, + skb->len, DMA_TO_DEVICE); - if (pci_dma_mapping_error(priv->pdev, mapping)) + if (dma_mapping_error(&priv->pdev->dev, mapping)) netdev_err(dev, "%s(): DMA Mapping error\n", __func__); memset(entry, 0, 12); entry->LINIP = cb_desc->bLastIniPkt; -- cgit v1.2.3-58-ga151 From 8aaeac5beba087e089137c18bdfcc1b592209fab Mon Sep 17 00:00:00 2001 From: Suraj Upadhyay Date: Sat, 11 Jul 2020 18:53:49 +0530 Subject: staging: rtl8192e: rtl_core: Remove pci-dma-compat wrapper APIs. The legacy API wrappers in include/linux/pci-dma-compat.h should go away as it creates unnecessary midlayering for include/linux/dma-mapping.h APIs, instead use dma-mapping.h APIs directly. The patch has been generated with the coccinelle script below and compile-tested. @@@@ - PCI_DMA_BIDIRECTIONAL + DMA_BIDIRECTIONAL @@@@ - PCI_DMA_TODEVICE + DMA_TO_DEVICE @@@@ - PCI_DMA_FROMDEVICE + DMA_FROM_DEVICE @@@@ - PCI_DMA_NONE + DMA_NONE @@ expression E1, E2, E3; @@ - pci_alloc_consistent(E1, E2, E3) + dma_alloc_coherent(&E1->dev, E2, E3, GFP_ATOMIC) @@ expression E1, E2, E3; @@ - pci_zalloc_consistent(E1, E2, E3) + dma_alloc_coherent(&E1->dev, E2, E3, GFP_ATOMIC) @@ expression E1, E2, E3, E4; @@ - pci_free_consistent(E1, E2, E3, E4) + dma_free_coherent(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_map_single(E1, E2, E3, E4) + dma_map_single(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_unmap_single(E1, E2, E3, E4) + dma_unmap_single(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4, E5; @@ - pci_map_page(E1, E2, E3, E4, E5) + dma_map_page(&E1->dev, E2, E3, E4, E5) @@ expression E1, E2, E3, E4; @@ - pci_unmap_page(E1, E2, E3, E4) + dma_unmap_page(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_map_sg(E1, E2, E3, E4) + dma_map_sg(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_unmap_sg(E1, E2, E3, E4) + dma_unmap_sg(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_single_for_cpu(E1, E2, E3, E4) + dma_sync_single_for_cpu(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_single_for_device(E1, E2, E3, E4) + dma_sync_single_for_device(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_sg_for_cpu(E1, E2, E3, E4) + dma_sync_sg_for_cpu(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_sg_for_device(E1, E2, E3, E4) + dma_sync_sg_for_device(&E1->dev, E2, E3, E4) @@ expression E1, E2; @@ - pci_dma_mapping_error(E1, E2) + dma_mapping_error(&E1->dev, E2) @@ expression E1, E2; @@ - pci_set_consistent_dma_mask(E1, E2) + dma_set_coherent_mask(&E1->dev, E2) @@ expression E1, E2; @@ - pci_set_dma_mask(E1, E2) + dma_set_mask(&E1->dev, E2) Signed-off-by: Suraj Upadhyay Link: https://lore.kernel.org/r/20200711132349.GA21618@blackclown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 71 +++++++++++++--------------- 1 file changed, 34 insertions(+), 37 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index dbcb8d0d9707..fac58eebf263 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1558,17 +1558,16 @@ static void _rtl92e_free_rx_ring(struct net_device *dev) if (!skb) continue; - pci_unmap_single(priv->pdev, - *((dma_addr_t *)skb->cb), - priv->rxbuffersize, PCI_DMA_FROMDEVICE); + dma_unmap_single(&priv->pdev->dev, + *((dma_addr_t *)skb->cb), + priv->rxbuffersize, DMA_FROM_DEVICE); kfree_skb(skb); } - pci_free_consistent(priv->pdev, - sizeof(*priv->rx_ring[rx_queue_idx]) * - priv->rxringcount, - priv->rx_ring[rx_queue_idx], - priv->rx_ring_dma[rx_queue_idx]); + dma_free_coherent(&priv->pdev->dev, + sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, + priv->rx_ring[rx_queue_idx], + priv->rx_ring_dma[rx_queue_idx]); priv->rx_ring[rx_queue_idx] = NULL; } } @@ -1582,14 +1581,15 @@ static void _rtl92e_free_tx_ring(struct net_device *dev, unsigned int prio) struct tx_desc *entry = &ring->desc[ring->idx]; struct sk_buff *skb = __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, entry->TxBuffAddr, - skb->len, PCI_DMA_TODEVICE); + dma_unmap_single(&priv->pdev->dev, entry->TxBuffAddr, + skb->len, DMA_TO_DEVICE); kfree_skb(skb); ring->idx = (ring->idx + 1) % ring->entries; } - pci_free_consistent(priv->pdev, sizeof(*ring->desc) * ring->entries, - ring->desc, ring->dma); + dma_free_coherent(&priv->pdev->dev, + sizeof(*ring->desc) * ring->entries, ring->desc, + ring->dma); ring->desc = NULL; } @@ -1676,8 +1676,8 @@ static void _rtl92e_tx_isr(struct net_device *dev, int prio) } skb = __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, entry->TxBuffAddr, - skb->len, PCI_DMA_TODEVICE); + dma_unmap_single(&priv->pdev->dev, entry->TxBuffAddr, + skb->len, DMA_TO_DEVICE); kfree_skb(skb); } @@ -1782,9 +1782,10 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev) int i, rx_queue_idx; for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) { - priv->rx_ring[rx_queue_idx] = pci_zalloc_consistent(priv->pdev, - sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, - &priv->rx_ring_dma[rx_queue_idx]); + priv->rx_ring[rx_queue_idx] = dma_alloc_coherent(&priv->pdev->dev, + sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount, + &priv->rx_ring_dma[rx_queue_idx], + GFP_ATOMIC); if (!priv->rx_ring[rx_queue_idx] || (unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) { netdev_warn(dev, "Cannot allocate RX ring\n"); @@ -1803,11 +1804,10 @@ static short _rtl92e_alloc_rx_ring(struct net_device *dev) skb->dev = dev; priv->rx_buf[rx_queue_idx][i] = skb; mapping = (dma_addr_t *)skb->cb; - *mapping = pci_map_single(priv->pdev, + *mapping = dma_map_single(&priv->pdev->dev, skb_tail_pointer_rsl(skb), - priv->rxbuffersize, - PCI_DMA_FROMDEVICE); - if (pci_dma_mapping_error(priv->pdev, *mapping)) { + priv->rxbuffersize, DMA_FROM_DEVICE); + if (dma_mapping_error(&priv->pdev->dev, *mapping)) { dev_kfree_skb_any(skb); return -1; } @@ -1831,7 +1831,8 @@ static int _rtl92e_alloc_tx_ring(struct net_device *dev, unsigned int prio, dma_addr_t dma; int i; - ring = pci_zalloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); + ring = dma_alloc_coherent(&priv->pdev->dev, sizeof(*ring) * entries, + &dma, GFP_ATOMIC); if (!ring || (unsigned long)ring & 0xFF) { netdev_warn(dev, "Cannot allocate TX ring (prio = %d)\n", prio); return -ENOMEM; @@ -1905,9 +1906,9 @@ void rtl92e_reset_desc_ring(struct net_device *dev) struct sk_buff *skb = __skb_dequeue(&ring->queue); - pci_unmap_single(priv->pdev, - entry->TxBuffAddr, - skb->len, PCI_DMA_TODEVICE); + dma_unmap_single(&priv->pdev->dev, + entry->TxBuffAddr, skb->len, + DMA_TO_DEVICE); kfree_skb(skb); ring->idx = (ring->idx + 1) % ring->entries; } @@ -2028,10 +2029,8 @@ static void _rtl92e_rx_normal(struct net_device *dev) if (unlikely(!new_skb)) goto done; - pci_unmap_single(priv->pdev, - *((dma_addr_t *)skb->cb), - priv->rxbuffersize, - PCI_DMA_FROMDEVICE); + dma_unmap_single(&priv->pdev->dev, *((dma_addr_t *)skb->cb), + priv->rxbuffersize, DMA_FROM_DEVICE); skb_put(skb, pdesc->Length); skb_reserve(skb, stats.RxDrvInfoSize + @@ -2074,12 +2073,10 @@ static void _rtl92e_rx_normal(struct net_device *dev) priv->rx_buf[rx_queue_idx][priv->rx_idx[rx_queue_idx]] = skb; - *((dma_addr_t *)skb->cb) = pci_map_single(priv->pdev, - skb_tail_pointer_rsl(skb), - priv->rxbuffersize, - PCI_DMA_FROMDEVICE); - if (pci_dma_mapping_error(priv->pdev, - *((dma_addr_t *)skb->cb))) { + *((dma_addr_t *)skb->cb) = dma_map_single(&priv->pdev->dev, + skb_tail_pointer_rsl(skb), + priv->rxbuffersize, DMA_FROM_DEVICE); + if (dma_mapping_error(&priv->pdev->dev, *((dma_addr_t *)skb->cb))) { dev_kfree_skb_any(skb); return; } @@ -2417,8 +2414,8 @@ static int _rtl92e_pci_probe(struct pci_dev *pdev, pci_set_master(pdev); - if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { - if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) { + if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) { + if (dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32))) { dev_info(&pdev->dev, "Unable to obtain 32bit DMA for consistent allocations\n"); goto err_pci_disable; -- cgit v1.2.3-58-ga151 From 5723a0dd3ceb6f05f66b77e0a479ac9e98e7c6d9 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 13 Jul 2020 11:13:05 +0200 Subject: Staging: speakup: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200713091305.32708-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/spkguide.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/speakup/spkguide.txt b/drivers/staging/speakup/spkguide.txt index 1e622cd34363..3782f6a09e97 100644 --- a/drivers/staging/speakup/spkguide.txt +++ b/drivers/staging/speakup/spkguide.txt @@ -1531,7 +1531,7 @@ The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See -http://www.gnu.org/copyleft/. +https://www.gnu.org/copyleft/. Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this -- cgit v1.2.3-58-ga151 From ff98ca159b15f2dcc95c24d760df6628a4658e4e Mon Sep 17 00:00:00 2001 From: Suraj Upadhyay Date: Sat, 11 Jul 2020 18:16:33 +0530 Subject: staging: qlge: Remove pci-dma-compat wrapper APIs. The legacy API wrappers in include/linux/pci-dma-compat.h should go away as it creates unnecessary midlayering for include/linux/dma-mapping.h APIs, instead use dma-mapping.h APIs directly. The patch has been generated with the coccinelle script below and compile-tested. @@@@ - PCI_DMA_BIDIRECTIONAL + DMA_BIDIRECTIONAL @@@@ - PCI_DMA_TODEVICE + DMA_TO_DEVICE @@@@ - PCI_DMA_FROMDEVICE + DMA_FROM_DEVICE @@@@ - PCI_DMA_NONE + DMA_NONE @@ expression E1, E2, E3; @@ - pci_alloc_consistent(E1, E2, E3) + dma_alloc_coherent(&E1->dev, E2, E3, GFP_ATOMIC) @@ expression E1, E2, E3; @@ - pci_zalloc_consistent(E1, E2, E3) + dma_alloc_coherent(&E1->dev, E2, E3, GFP_ATOMIC) @@ expression E1, E2, E3, E4; @@ - pci_free_consistent(E1, E2, E3, E4) + dma_free_coherent(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_map_single(E1, E2, E3, E4) + dma_map_single(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_unmap_single(E1, E2, E3, E4) + dma_unmap_single(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4, E5; @@ - pci_map_page(E1, E2, E3, E4, E5) + dma_map_page(&E1->dev, E2, E3, E4, (enum dma_data_direction)E5) @@ expression E1, E2, E3, E4; @@ - pci_unmap_page(E1, E2, E3, E4) + dma_unmap_page(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_map_sg(E1, E2, E3, E4) + dma_map_sg(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_unmap_sg(E1, E2, E3, E4) + dma_unmap_sg(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_single_for_cpu(E1, E2, E3, E4) + dma_sync_single_for_cpu(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_single_for_device(E1, E2, E3, E4) + dma_sync_single_for_device(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_sg_for_cpu(E1, E2, E3, E4) + dma_sync_sg_for_cpu(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_sg_for_device(E1, E2, E3, E4) + dma_sync_sg_for_device(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2; @@ - pci_dma_mapping_error(E1, E2) + dma_mapping_error(&E1->dev, E2) @@ expression E1, E2; @@ - pci_set_consistent_dma_mask(E1, E2) + dma_set_coherent_mask(&E1->dev, E2) @@ expression E1, E2; @@ - pci_set_dma_mask(E1, E2) + dma_set_mask(&E1->dev, E2) Signed-off-by: Suraj Upadhyay Link: https://lore.kernel.org/r/20200711124633.GA16459@blackclown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_mpi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c index fa178fc642a6..16a9bf818346 100644 --- a/drivers/staging/qlge/qlge_mpi.c +++ b/drivers/staging/qlge/qlge_mpi.c @@ -788,8 +788,9 @@ int ql_dump_risc_ram_area(struct ql_adapter *qdev, void *buf, char *my_buf; dma_addr_t buf_dma; - my_buf = pci_alloc_consistent(qdev->pdev, word_count * sizeof(u32), - &buf_dma); + my_buf = dma_alloc_coherent(&qdev->pdev->dev, + word_count * sizeof(u32), &buf_dma, + GFP_ATOMIC); if (!my_buf) return -EIO; @@ -797,8 +798,8 @@ int ql_dump_risc_ram_area(struct ql_adapter *qdev, void *buf, if (!status) memcpy(buf, my_buf, word_count * sizeof(u32)); - pci_free_consistent(qdev->pdev, word_count * sizeof(u32), my_buf, - buf_dma); + dma_free_coherent(&qdev->pdev->dev, word_count * sizeof(u32), my_buf, + buf_dma); return status; } -- cgit v1.2.3-58-ga151 From d923bb6bf5083d85713c000e9b6be0e921ce98c6 Mon Sep 17 00:00:00 2001 From: Suraj Upadhyay Date: Mon, 13 Jul 2020 17:45:05 +0530 Subject: staging: qlge: qlge.h: Function definition arguments should have names. Issue found with checkpatch.pl Signed-off-by: Suraj Upadhyay Link: https://lore.kernel.org/r/2d788cffeec2dad9ce9562c15a69d8b63ed0b21f.1594642213.git.usuraj35@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index 05e4f47442a3..48bc494028ce 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -2057,8 +2057,8 @@ enum { }; struct nic_operations { - int (*get_flash)(struct ql_adapter *); - int (*port_initialize)(struct ql_adapter *); + int (*get_flash)(struct ql_adapter *qdev); + int (*port_initialize)(struct ql_adapter *qdev); }; /* @@ -2275,7 +2275,7 @@ int ql_mb_set_port_cfg(struct ql_adapter *qdev); int ql_wait_fifo_empty(struct ql_adapter *qdev); void ql_get_dump(struct ql_adapter *qdev, void *buff); netdev_tx_t ql_lb_send(struct sk_buff *skb, struct net_device *ndev); -void ql_check_lb_frame(struct ql_adapter *, struct sk_buff *); +void ql_check_lb_frame(struct ql_adapter *qdev, struct sk_buff *skb); int ql_own_firmware(struct ql_adapter *qdev); int ql_clean_lb_rx_ring(struct rx_ring *rx_ring, int budget); -- cgit v1.2.3-58-ga151 From dd7f1b6fc30bae4067300422d58eb6f4582d1c21 Mon Sep 17 00:00:00 2001 From: Suraj Upadhyay Date: Mon, 13 Jul 2020 17:45:45 +0530 Subject: staging: qlge: qlge.h: Insert line after declaration. Issue found by checkpatch.pl Signed-off-by: Suraj Upadhyay Link: https://lore.kernel.org/r/d14343ed4ea3d4428f93a63bf1f52804ed5938e9.1594642213.git.usuraj35@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index 48bc494028ce..483ce04789ed 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -2224,6 +2224,7 @@ static inline void ql_write_db_reg_relaxed(u32 val, void __iomem *addr) static inline u32 ql_read_sh_reg(__le32 *addr) { u32 reg; + reg = le32_to_cpu(*addr); rmb(); return reg; -- cgit v1.2.3-58-ga151 From 73b30441560654c75e09e48c93aa3df3ce76b5f0 Mon Sep 17 00:00:00 2001 From: Suraj Upadhyay Date: Mon, 13 Jul 2020 17:46:21 +0530 Subject: staging: qlge: qlge_dbg: Simplify while statements Simplify while loops into more readable and simple for loops. Signed-off-by: Suraj Upadhyay Link: https://lore.kernel.org/r/79e35c695a80168639c073137a80804da3362301.1594642213.git.usuraj35@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_dbg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 32fbd30a6a2e..985a6c341294 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -42,9 +42,9 @@ static int ql_wait_other_func_reg_rdy(struct ql_adapter *qdev, u32 reg, u32 bit, u32 err_bit) { u32 temp; - int count = 10; + int count; - while (count) { + for (count = 10; count; count--) { temp = ql_read_other_func_reg(qdev, reg); /* check for errors */ @@ -53,7 +53,6 @@ static int ql_wait_other_func_reg_rdy(struct ql_adapter *qdev, u32 reg, else if (temp & bit) return 0; mdelay(10); - count--; } return -1; } -- cgit v1.2.3-58-ga151 From 45170f100a8d2a96a3569519f5968144e6542940 Mon Sep 17 00:00:00 2001 From: Suraj Upadhyay Date: Mon, 13 Jul 2020 17:51:13 +0530 Subject: staging: qlge: qlge_mpi: Simplify while statements. Simplify while loops into more readable and simple for loops. Signed-off-by: Suraj Upadhyay Link: https://lore.kernel.org/r/6eb96e8c074bbdee3838b6421d25b50f1faffb3d.1594642213.git.usuraj35@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_mpi.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c index 16a9bf818346..94d504af84ff 100644 --- a/drivers/staging/qlge/qlge_mpi.c +++ b/drivers/staging/qlge/qlge_mpi.c @@ -17,36 +17,34 @@ int ql_unpause_mpi_risc(struct ql_adapter *qdev) int ql_pause_mpi_risc(struct ql_adapter *qdev) { u32 tmp; - int count = UDELAY_COUNT; + int count; /* Pause the RISC */ ql_write32(qdev, CSR, CSR_CMD_SET_PAUSE); - do { + for (count = UDELAY_COUNT; count; count--) { tmp = ql_read32(qdev, CSR); if (tmp & CSR_RP) break; mdelay(UDELAY_DELAY); - count--; - } while (count); + } return (count == 0) ? -ETIMEDOUT : 0; } int ql_hard_reset_mpi_risc(struct ql_adapter *qdev) { u32 tmp; - int count = UDELAY_COUNT; + int count; /* Reset the RISC */ ql_write32(qdev, CSR, CSR_CMD_SET_RST); - do { + for (count = UDELAY_COUNT; count; count--) { tmp = ql_read32(qdev, CSR); if (tmp & CSR_RR) { ql_write32(qdev, CSR, CSR_CMD_CLR_RST); break; } mdelay(UDELAY_DELAY); - count--; - } while (count); + } return (count == 0) ? -ETIMEDOUT : 0; } @@ -147,15 +145,15 @@ static int ql_get_mb_sts(struct ql_adapter *qdev, struct mbox_params *mbcp) */ static int ql_wait_mbx_cmd_cmplt(struct ql_adapter *qdev) { - int count = 100; + int count; u32 value; - do { + for (count = 100; count; count--) { value = ql_read32(qdev, STS); if (value & STS_PI) return 0; mdelay(UDELAY_DELAY); /* 100ms */ - } while (--count); + } return -ETIMEDOUT; } @@ -914,10 +912,10 @@ int ql_mb_wol_set_magic(struct ql_adapter *qdev, u32 enable_wol) static int ql_idc_wait(struct ql_adapter *qdev) { int status = -ETIMEDOUT; - long wait_time = 1 * HZ; struct mbox_params *mbcp = &qdev->idc_mbc; + long wait_time; - do { + for (wait_time = 1 * HZ; wait_time;) { /* Wait here for the command to complete * via the IDC process. */ @@ -947,7 +945,7 @@ static int ql_idc_wait(struct ql_adapter *qdev) status = -EIO; break; } - } while (wait_time); + } return status; } @@ -1080,18 +1078,18 @@ static int ql_mb_get_mgmnt_traffic_ctl(struct ql_adapter *qdev, u32 *control) int ql_wait_fifo_empty(struct ql_adapter *qdev) { - int count = 5; + int count; u32 mgmnt_fifo_empty; u32 nic_fifo_empty; - do { + for (count = 6; count; count--) { nic_fifo_empty = ql_read32(qdev, STS) & STS_NFE; ql_mb_get_mgmnt_traffic_ctl(qdev, &mgmnt_fifo_empty); mgmnt_fifo_empty &= MB_GET_MPI_TFK_FIFO_EMPTY; if (nic_fifo_empty && mgmnt_fifo_empty) return 0; msleep(100); - } while (count-- > 0); + } return -ETIMEDOUT; } -- cgit v1.2.3-58-ga151 From caaba08f8c0dbe5c8fcb497faa7e3b394c21ff39 Mon Sep 17 00:00:00 2001 From: Suraj Upadhyay Date: Mon, 13 Jul 2020 17:52:22 +0530 Subject: staging: qlge: qlge_ethtool: Remove one byte memset. Use direct assignment instead of using memset with just one byte as an argument. Issue found by checkpatch.pl. Signed-off-by: Suraj Upadhyay Link: https://lore.kernel.org/r/b5eb87576cef4bf1b968481d6341013e6c7e9650.1594642213.git.usuraj35@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_ethtool.c b/drivers/staging/qlge/qlge_ethtool.c index 16fcdefa9687..d44b2dae9213 100644 --- a/drivers/staging/qlge/qlge_ethtool.c +++ b/drivers/staging/qlge/qlge_ethtool.c @@ -516,8 +516,8 @@ static void ql_create_lb_frame(struct sk_buff *skb, memset(skb->data, 0xFF, frame_size); frame_size &= ~1; memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1); - memset(&skb->data[frame_size / 2 + 10], 0xBE, 1); - memset(&skb->data[frame_size / 2 + 12], 0xAF, 1); + skb->data[frame_size / 2 + 10] = (unsigned char)0xBE; + skb->data[frame_size / 2 + 12] = (unsigned char)0xAF; } void ql_check_lb_frame(struct ql_adapter *qdev, -- cgit v1.2.3-58-ga151 From 1e5f7325636abd6c650b956506eb1b7993bd688c Mon Sep 17 00:00:00 2001 From: Baidyanath Kundu Date: Mon, 13 Jul 2020 20:06:53 +0530 Subject: Staging: vc04_services: Fix unsigned int warnings This patch fixes the checkpatch.pl warning: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' Signed-off-by: Baidyanath Kundu Link: https://lore.kernel.org/r/20200713143653.32332-1-kundubaidya99@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 4 ++-- drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h | 8 ++++---- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 6 +++--- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 8c9ddd86fbbd..292fcee9d6f2 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -9,7 +9,7 @@ struct bcm2835_audio_instance { struct device *dev; - unsigned service_handle; + unsigned int service_handle; struct completion msg_avail_comp; struct mutex vchi_mutex; struct bcm2835_alsa_stream *alsa_stream; @@ -91,7 +91,7 @@ static int bcm2835_audio_send_simple(struct bcm2835_audio_instance *instance, static enum vchiq_status audio_vchi_callback(enum vchiq_reason reason, struct vchiq_header *header, - unsigned handle, void *userdata) + unsigned int handle, void *userdata) { struct bcm2835_audio_instance *instance = vchiq_get_service_userdata(handle); struct vc_audio_msg *m; diff --git a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h index cb9ef9a4150b..18d63df368c4 100644 --- a/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h +++ b/drivers/staging/vc04_services/include/linux/raspberrypi/vchiq.h @@ -84,11 +84,11 @@ extern enum vchiq_status vchiq_open_service(struct vchiq_instance *instance, extern enum vchiq_status vchiq_close_service(unsigned int service); extern enum vchiq_status vchiq_use_service(unsigned int service); extern enum vchiq_status vchiq_release_service(unsigned int service); -extern void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header); +extern void vchiq_msg_queue_push(unsigned int handle, struct vchiq_header *header); extern void vchiq_release_message(unsigned int service, struct vchiq_header *header); -extern int vchiq_queue_kernel_message(unsigned handle, void *data, - unsigned size); +extern int vchiq_queue_kernel_message(unsigned int handle, void *data, + unsigned int size); extern enum vchiq_status vchiq_bulk_transmit(unsigned int service, const void *data, unsigned int size, void *userdata, enum vchiq_bulk_mode mode); @@ -98,6 +98,6 @@ extern enum vchiq_status vchiq_bulk_receive(unsigned int service, extern void *vchiq_get_service_userdata(unsigned int service); extern enum vchiq_status vchiq_get_peer_version(unsigned int handle, short *peer_version); -extern struct vchiq_header *vchiq_msg_hold(unsigned handle); +extern struct vchiq_header *vchiq_msg_hold(unsigned int handle); #endif /* VCHIQ_H */ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 1bc4ce577614..af64cde82d36 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2275,7 +2275,7 @@ fail_free_handler_thread: return VCHIQ_ERROR; } -void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header) +void vchiq_msg_queue_push(unsigned int handle, struct vchiq_header *header) { struct vchiq_service *service = find_service_by_handle(handle); int pos; @@ -2293,7 +2293,7 @@ void vchiq_msg_queue_push(unsigned handle, struct vchiq_header *header) } EXPORT_SYMBOL(vchiq_msg_queue_push); -struct vchiq_header *vchiq_msg_hold(unsigned handle) +struct vchiq_header *vchiq_msg_hold(unsigned int handle) { struct vchiq_service *service = find_service_by_handle(handle); struct vchiq_header *header; @@ -3214,7 +3214,7 @@ error_exit: return status; } -int vchiq_queue_kernel_message(unsigned handle, void *data, unsigned size) +int vchiq_queue_kernel_message(unsigned int handle, void *data, unsigned int size) { enum vchiq_status status; diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index a075cd63da7f..dc767730db43 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -163,7 +163,7 @@ struct mmal_msg_context { }; struct vchiq_mmal_instance { - unsigned service_handle; + unsigned int service_handle; /* ensure serialised access to service */ struct mutex vchiq_mutex; @@ -548,7 +548,7 @@ static void bulk_abort_cb(struct vchiq_mmal_instance *instance, /* incoming event service callback */ static enum vchiq_status service_callback(enum vchiq_reason reason, struct vchiq_header *header, - unsigned handle, void *bulk_ctx) + unsigned int handle, void *bulk_ctx) { struct vchiq_mmal_instance *instance = vchiq_get_service_userdata(handle); u32 msg_len; -- cgit v1.2.3-58-ga151 From d1e8c52ab7ee7afbaa9d276d805525a64a01a07a Mon Sep 17 00:00:00 2001 From: Suraj Upadhyay Date: Mon, 13 Jul 2020 20:02:53 +0530 Subject: staging: comedi: s626: Remove pci-dma-compat wrapper APIs. The legacy API wrappers in include/linux/pci-dma-compat.h should go away as it creates unnecessary midlayering for include/linux/dma-mapping.h APIs, instead use dma-mapping.h APIs directly. The patch has been generated with the coccinelle script below and compile-tested. @@@@ - PCI_DMA_BIDIRECTIONAL + DMA_BIDIRECTIONAL @@@@ - PCI_DMA_TODEVICE + DMA_TO_DEVICE @@@@ - PCI_DMA_FROMDEVICE + DMA_FROM_DEVICE @@@@ - PCI_DMA_NONE + DMA_NONE @@ expression E1, E2, E3; @@ - pci_alloc_consistent(E1, E2, E3) + dma_alloc_coherent(&E1->dev, E2, E3, GFP_ATOMIC) @@ expression E1, E2, E3; @@ - pci_zalloc_consistent(E1, E2, E3) + dma_alloc_coherent(&E1->dev, E2, E3, GFP_ATOMIC) @@ expression E1, E2, E3, E4; @@ - pci_free_consistent(E1, E2, E3, E4) + dma_free_coherent(&E1->dev, E2, E3, E4) @@ expression E1, E2, E3, E4; @@ - pci_map_single(E1, E2, E3, E4) + dma_map_single(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_unmap_single(E1, E2, E3, E4) + dma_unmap_single(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4, E5; @@ - pci_map_page(E1, E2, E3, E4, E5) + dma_map_page(&E1->dev, E2, E3, E4, (enum dma_data_direction)E5) @@ expression E1, E2, E3, E4; @@ - pci_unmap_page(E1, E2, E3, E4) + dma_unmap_page(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_map_sg(E1, E2, E3, E4) + dma_map_sg(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_unmap_sg(E1, E2, E3, E4) + dma_unmap_sg(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_single_for_cpu(E1, E2, E3, E4) + dma_sync_single_for_cpu(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_single_for_device(E1, E2, E3, E4) + dma_sync_single_for_device(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_sg_for_cpu(E1, E2, E3, E4) + dma_sync_sg_for_cpu(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2, E3, E4; @@ - pci_dma_sync_sg_for_device(E1, E2, E3, E4) + dma_sync_sg_for_device(&E1->dev, E2, E3, (enum dma_data_direction)E4) @@ expression E1, E2; @@ - pci_dma_mapping_error(E1, E2) + dma_mapping_error(&E1->dev, E2) @@ expression E1, E2; @@ - pci_set_consistent_dma_mask(E1, E2) + dma_set_coherent_mask(&E1->dev, E2) @@ expression E1, E2; @@ - pci_set_dma_mask(E1, E2) + dma_set_mask(&E1->dev, E2) Signed-off-by: Suraj Upadhyay Reviewed-by: Ian Abbott Link: https://lore.kernel.org/r/20200713143253.GA14953@blackclown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s626.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 084a8e7b9fc2..e7aba937d896 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -2130,13 +2130,15 @@ static int s626_allocate_dma_buffers(struct comedi_device *dev) void *addr; dma_addr_t appdma; - addr = pci_alloc_consistent(pcidev, S626_DMABUF_SIZE, &appdma); + addr = dma_alloc_coherent(&pcidev->dev, S626_DMABUF_SIZE, &appdma, + GFP_KERNEL); if (!addr) return -ENOMEM; devpriv->ana_buf.logical_base = addr; devpriv->ana_buf.physical_base = appdma; - addr = pci_alloc_consistent(pcidev, S626_DMABUF_SIZE, &appdma); + addr = dma_alloc_coherent(&pcidev->dev, S626_DMABUF_SIZE, &appdma, + GFP_KERNEL); if (!addr) return -ENOMEM; devpriv->rps_buf.logical_base = addr; @@ -2154,13 +2156,13 @@ static void s626_free_dma_buffers(struct comedi_device *dev) return; if (devpriv->rps_buf.logical_base) - pci_free_consistent(pcidev, S626_DMABUF_SIZE, - devpriv->rps_buf.logical_base, - devpriv->rps_buf.physical_base); + dma_free_coherent(&pcidev->dev, S626_DMABUF_SIZE, + devpriv->rps_buf.logical_base, + devpriv->rps_buf.physical_base); if (devpriv->ana_buf.logical_base) - pci_free_consistent(pcidev, S626_DMABUF_SIZE, - devpriv->ana_buf.logical_base, - devpriv->ana_buf.physical_base); + dma_free_coherent(&pcidev->dev, S626_DMABUF_SIZE, + devpriv->ana_buf.logical_base, + devpriv->ana_buf.physical_base); } static int s626_initialize(struct comedi_device *dev) -- cgit v1.2.3-58-ga151 From a7a49357179ee71e1b969991474392e91295bff1 Mon Sep 17 00:00:00 2001 From: Zhixu Zhao Date: Wed, 15 Jul 2020 21:33:13 +0800 Subject: staging: gasket: core: Fix a coding style issue in gasket_core.c A coding alignment issue is found by checkpatch.pl. Fix it by using a temporary for gasket_dev->bar_data[bar_num]. Signed-off-by: Zhixu Zhao Link: https://lore.kernel.org/r/20200715133313.16327-1-zhixu001@126.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 67325fbaf760..28dab302183b 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -261,6 +261,7 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num) const struct gasket_driver_desc *driver_desc = internal_desc->driver_desc; ulong desc_bytes = driver_desc->bar_descriptions[bar_num].size; + struct gasket_bar_data *data; int ret; if (desc_bytes == 0) @@ -270,31 +271,32 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num) /* not PCI: skip this entry */ return 0; } + + data = &gasket_dev->bar_data[bar_num]; + /* * pci_resource_start and pci_resource_len return a "resource_size_t", * which is safely castable to ulong (which itself is the arg to * request_mem_region). */ - gasket_dev->bar_data[bar_num].phys_base = + data->phys_base = (ulong)pci_resource_start(gasket_dev->pci_dev, bar_num); - if (!gasket_dev->bar_data[bar_num].phys_base) { + if (!data->phys_base) { dev_err(gasket_dev->dev, "Cannot get BAR%u base address\n", bar_num); return -EINVAL; } - gasket_dev->bar_data[bar_num].length_bytes = + data->length_bytes = (ulong)pci_resource_len(gasket_dev->pci_dev, bar_num); - if (gasket_dev->bar_data[bar_num].length_bytes < desc_bytes) { + if (data->length_bytes < desc_bytes) { dev_err(gasket_dev->dev, "PCI BAR %u space is too small: %lu; expected >= %lu\n", - bar_num, gasket_dev->bar_data[bar_num].length_bytes, - desc_bytes); + bar_num, data->length_bytes, desc_bytes); return -ENOMEM; } - if (!request_mem_region(gasket_dev->bar_data[bar_num].phys_base, - gasket_dev->bar_data[bar_num].length_bytes, + if (!request_mem_region(data->phys_base, data->length_bytes, gasket_dev->dev_info.name)) { dev_err(gasket_dev->dev, "Cannot get BAR %d memory region %p\n", @@ -302,10 +304,8 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num) return -EINVAL; } - gasket_dev->bar_data[bar_num].virt_base = - ioremap(gasket_dev->bar_data[bar_num].phys_base, - gasket_dev->bar_data[bar_num].length_bytes); - if (!gasket_dev->bar_data[bar_num].virt_base) { + data->virt_base = ioremap(data->phys_base, data->length_bytes); + if (!data->virt_base) { dev_err(gasket_dev->dev, "Cannot remap BAR %d memory region %p\n", bar_num, &gasket_dev->pci_dev->resource[bar_num]); @@ -319,9 +319,8 @@ static int gasket_map_pci_bar(struct gasket_dev *gasket_dev, int bar_num) return 0; fail: - iounmap(gasket_dev->bar_data[bar_num].virt_base); - release_mem_region(gasket_dev->bar_data[bar_num].phys_base, - gasket_dev->bar_data[bar_num].length_bytes); + iounmap(data->virt_base); + release_mem_region(data->phys_base, data->length_bytes); return ret; } -- cgit v1.2.3-58-ga151 From 1843b3fef9aaa9f5098212019e927ffd2e8da7c1 Mon Sep 17 00:00:00 2001 From: Ivan Safonov Date: Sun, 12 Jul 2020 15:38:21 +0300 Subject: staging: r8188eu: remove unused members of struct xmit_buf Remove unused members of struct xmit_buf: alloc_sz, ff_hwaddr, dma_transfer_addr, bpending and last. Acked-by: Larry Finger Signed-off-by: Ivan Safonov Link: https://lore.kernel.org/r/20200712123821.553420-1-insafonov@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_xmit.h | 5 ----- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 1 - 2 files changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h b/drivers/staging/rtl8188eu/include/rtw_xmit.h index 12d16e98176a..3c03987c81a1 100644 --- a/drivers/staging/rtl8188eu/include/rtw_xmit.h +++ b/drivers/staging/rtl8188eu/include/rtw_xmit.h @@ -193,14 +193,9 @@ struct xmit_buf { void *priv_data; u16 ext_tag; /* 0: Normal xmitbuf, 1: extension xmitbuf. */ u16 flags; - u32 alloc_sz; u32 len; struct submit_ctx *sctx; - u32 ff_hwaddr; struct urb *pxmit_urb[8]; - dma_addr_t dma_transfer_addr; /* (in) dma addr for transfer_buffer */ - u8 bpending[8]; - int last[8]; }; struct xmit_frame { diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 3ca1dc30efb7..a73313cf6a75 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -23,7 +23,6 @@ int rtw_os_xmit_resource_alloc(struct xmit_buf *pxmitbuf, u32 alloc_sz) return _FAIL; pxmitbuf->pbuf = PTR_ALIGN(pxmitbuf->pallocated_buf, XMITBUF_ALIGN_SZ); - pxmitbuf->dma_transfer_addr = 0; for (i = 0; i < 8; i++) { pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL); -- cgit v1.2.3-58-ga151 From 06ddf551e4cb228155f8b086ac9113963817089c Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 14 Jul 2020 16:34:26 +0300 Subject: staging: dpaa2-ethsw: fix reported link state On the .ndo_open() callback set netif_carrier_off() until the link state interrupt is received so that the LOWER_UP flag does not show up incorrectly in the output of 'ip link show'. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20200714133431.17532-2-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 546ad376df99..46aa37093e86 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -473,6 +473,13 @@ static int port_open(struct net_device *netdev) /* No need to allow Tx as control interface is disabled */ netif_tx_stop_all_queues(netdev); + /* Explicitly set carrier off, otherwise + * netif_carrier_ok() will return true and cause 'ip link show' + * to report the LOWER_UP flag, even though the link + * notification wasn't even received. + */ + netif_carrier_off(netdev); + err = dpsw_if_enable(port_priv->ethsw_data->mc_io, 0, port_priv->ethsw_data->dpsw_handle, port_priv->idx); -- cgit v1.2.3-58-ga151 From 2cde6410c13d63cc306f395d9fa4b72605468061 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 14 Jul 2020 16:34:27 +0300 Subject: staging: dpaa2-ethsw: ignore state interrupts when the interface is not running Link state interrupts will be transmitted to the DPSW object even though the user has not yet issued a 'ifconfig up' on a switch interface. Don't act on those interrupts since there are of no interrest. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20200714133431.17532-3-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 46aa37093e86..b57bc705c2ee 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -445,6 +445,12 @@ static int port_carrier_state_sync(struct net_device *netdev) struct dpsw_link_state state; int err; + /* Interrupts are received even though no one issued an 'ifconfig up' + * on the switch interface. Ignore these link state update interrupts + */ + if (!netif_running(netdev)) + return 0; + err = dpsw_if_get_link_state(port_priv->ethsw_data->mc_io, 0, port_priv->ethsw_data->dpsw_handle, port_priv->idx, &state); -- cgit v1.2.3-58-ga151 From b53bb527d88ae963bdf9bd71f222cf459fc59d2b Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 14 Jul 2020 16:34:28 +0300 Subject: staging: dpaa2-ethsw: use netif_running when checking for port up There are some cases where the switch interface needs to be disabled so that changes in the configuration can be made. In such cases, we should check for a running interface (bit __LINK_STATE_START of the netdev) instead of netif_carrier_ok(). This is because on open() we enable the switch interface even though the link up has not come out yet. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20200714133431.17532-4-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index b57bc705c2ee..a1917842536e 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -48,7 +48,7 @@ static int ethsw_port_set_pvid(struct ethsw_port_priv *port_priv, u16 pvid) struct ethsw_core *ethsw = port_priv->ethsw_data; struct net_device *netdev = port_priv->netdev; struct dpsw_tci_cfg tci_cfg = { 0 }; - bool is_oper; + bool up; int err, ret; err = dpsw_if_get_tci(ethsw->mc_io, 0, ethsw->dpsw_handle, @@ -61,8 +61,8 @@ static int ethsw_port_set_pvid(struct ethsw_port_priv *port_priv, u16 pvid) tci_cfg.vlan_id = pvid; /* Interface needs to be down to change PVID */ - is_oper = netif_oper_up(netdev); - if (is_oper) { + up = netif_running(netdev); + if (up) { err = dpsw_if_disable(ethsw->mc_io, 0, ethsw->dpsw_handle, port_priv->idx); @@ -85,7 +85,7 @@ static int ethsw_port_set_pvid(struct ethsw_port_priv *port_priv, u16 pvid) port_priv->pvid = pvid; set_tci_error: - if (is_oper) { + if (up) { ret = dpsw_if_enable(ethsw->mc_io, 0, ethsw->dpsw_handle, port_priv->idx); @@ -188,7 +188,7 @@ static int ethsw_port_set_stp_state(struct ethsw_port_priv *port_priv, u8 state) }; int err; - if (!netif_oper_up(port_priv->netdev) || state == port_priv->stp_state) + if (!netif_running(port_priv->netdev) || state == port_priv->stp_state) return 0; /* Nothing to do */ err = dpsw_if_set_stp(port_priv->ethsw_data->mc_io, 0, -- cgit v1.2.3-58-ga151 From 03ad6de9bb3e6e48b2ab87226f545f8a301017fa Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 14 Jul 2020 16:34:29 +0300 Subject: staging: dpaa2-ethsw: disable switch ports are probe time The MC firmware will enable the switch interfaces at DPSW creation without waiting for an 'ifconfig up' on the switch interfaces. When this happens, the states held by the Linux software vs the firmware are not in sync. Make sure to disable the switch ports at probe time to not encounter this issue. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20200714133431.17532-5-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index a1917842536e..f283ce195c1e 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1672,6 +1672,10 @@ static int ethsw_probe(struct fsl_mc_device *sw_dev) goto err_free_ports; } + /* Make sure the switch ports are disabled at probe time */ + for (i = 0; i < ethsw->sw_attr.num_ifs; i++) + dpsw_if_disable(ethsw->mc_io, 0, ethsw->dpsw_handle, i); + /* Setup IRQs */ err = ethsw_setup_irqs(sw_dev); if (err) -- cgit v1.2.3-58-ga151 From 3b9c7029a7d6ee0876c5481db11947d57792cdd5 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 14 Jul 2020 16:34:30 +0300 Subject: staging: dpaa2-ethsw: store version information of the DPSW object Store the major and minor versions of the DPSW object in the ethsw structure. This will be used in a subsequent patch to make sure some commands are only called on the appropriate version of object. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20200714133431.17532-6-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 16 ++++++++-------- drivers/staging/fsl-dpaa2/ethsw/ethsw.h | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index f283ce195c1e..a8fc9bcf3b8a 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1368,9 +1368,9 @@ static int ethsw_init(struct fsl_mc_device *sw_dev) { struct device *dev = &sw_dev->dev; struct ethsw_core *ethsw = dev_get_drvdata(dev); - u16 version_major, version_minor, i; struct dpsw_stp_cfg stp_cfg; int err; + u16 i; ethsw->dev_id = sw_dev->obj_desc.id; @@ -1388,20 +1388,20 @@ static int ethsw_init(struct fsl_mc_device *sw_dev) } err = dpsw_get_api_version(ethsw->mc_io, 0, - &version_major, - &version_minor); + ðsw->major, + ðsw->minor); if (err) { dev_err(dev, "dpsw_get_api_version err %d\n", err); goto err_close; } /* Minimum supported DPSW version check */ - if (version_major < DPSW_MIN_VER_MAJOR || - (version_major == DPSW_MIN_VER_MAJOR && - version_minor < DPSW_MIN_VER_MINOR)) { + if (ethsw->major < DPSW_MIN_VER_MAJOR || + (ethsw->major == DPSW_MIN_VER_MAJOR && + ethsw->minor < DPSW_MIN_VER_MINOR)) { dev_err(dev, "DPSW version %d:%d not supported. Use %d.%d or greater.\n", - version_major, - version_minor, + ethsw->major, + ethsw->minor, DPSW_MIN_VER_MAJOR, DPSW_MIN_VER_MINOR); err = -ENOTSUPP; goto err_close; diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h index a0244f7d5003..0e520fd94dbc 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h @@ -61,6 +61,7 @@ struct ethsw_core { struct fsl_mc_io *mc_io; u16 dpsw_handle; struct dpsw_attr sw_attr; + u16 major, minor; int dev_id; struct ethsw_port_priv **ports; -- cgit v1.2.3-58-ga151 From 240cb8de112eb21543450b98dc88b7ec2e9869cb Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 14 Jul 2020 16:34:31 +0300 Subject: staging: dpaa2-ethsw: setup MAC address of switch netdevices At probe time, retrieve the MAC addresses of the switch ports using a firmware call and use that to setup the switch interface net_device instead of relying entirely on the user to configure a MAC address on the interface. In case a switch interface is not connected to a MAC, thus the dpsw_if_get_port_mac_addr() will return all zeroes, generate a random MAC address and use that. This new functionality is dependent on a firmware call which is available only on newer versions, so depending on the running DPSW object version skip this step. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20200714133431.17532-7-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h | 14 ++++ drivers/staging/fsl-dpaa2/ethsw/dpsw.c | 106 +++++++++++++++++++++++++++++ drivers/staging/fsl-dpaa2/ethsw/dpsw.h | 9 +++ drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 59 +++++++++++++++- drivers/staging/fsl-dpaa2/ethsw/ethsw.h | 3 + 5 files changed, 190 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h index 5e1339daa7c7..f100d503bd17 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h +++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h @@ -69,6 +69,10 @@ #define DPSW_CMDID_FDB_SET_LEARNING_MODE DPSW_CMD_ID(0x088) #define DPSW_CMDID_FDB_DUMP DPSW_CMD_ID(0x08A) +#define DPSW_CMDID_IF_GET_PORT_MAC_ADDR DPSW_CMD_ID(0x0A7) +#define DPSW_CMDID_IF_GET_PRIMARY_MAC_ADDR DPSW_CMD_ID(0x0A8) +#define DPSW_CMDID_IF_SET_PRIMARY_MAC_ADDR DPSW_CMD_ID(0x0A9) + /* Macros for accessing command fields smaller than 1byte */ #define DPSW_MASK(field) \ GENMASK(DPSW_##field##_SHIFT + DPSW_##field##_SIZE - 1, \ @@ -369,4 +373,14 @@ struct dpsw_rsp_get_api_version { __le16 version_minor; }; +struct dpsw_rsp_if_get_mac_addr { + __le16 pad; + u8 mac_addr[6]; +}; + +struct dpsw_cmd_if_set_mac_addr { + __le16 if_id; + u8 mac_addr[6]; +}; + #endif /* __FSL_DPSW_CMD_H */ diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c index 56b0fa789a67..f8bfe779bd30 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.c @@ -1214,3 +1214,109 @@ int dpsw_get_api_version(struct fsl_mc_io *mc_io, return 0; } + +/** + * dpsw_if_get_port_mac_addr() + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSW object + * @if_id: Interface Identifier + * @mac_addr: MAC address of the physical port, if any, otherwise 0 + * + * Return: Completion status. '0' on Success; Error code otherwise. + */ +int dpsw_if_get_port_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + u16 if_id, u8 mac_addr[6]) +{ + struct dpsw_rsp_if_get_mac_addr *rsp_params; + struct fsl_mc_command cmd = { 0 }; + struct dpsw_cmd_if *cmd_params; + int err, i; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_PORT_MAC_ADDR, + cmd_flags, + token); + cmd_params = (struct dpsw_cmd_if *)cmd.params; + cmd_params->if_id = cpu_to_le16(if_id); + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + rsp_params = (struct dpsw_rsp_if_get_mac_addr *)cmd.params; + for (i = 0; i < 6; i++) + mac_addr[5 - i] = rsp_params->mac_addr[i]; + + return 0; +} + +/** + * dpsw_if_get_primary_mac_addr() + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSW object + * @if_id: Interface Identifier + * @mac_addr: MAC address of the physical port, if any, otherwise 0 + * + * Return: Completion status. '0' on Success; Error code otherwise. + */ +int dpsw_if_get_primary_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 token, u16 if_id, u8 mac_addr[6]) +{ + struct dpsw_rsp_if_get_mac_addr *rsp_params; + struct fsl_mc_command cmd = { 0 }; + struct dpsw_cmd_if *cmd_params; + int err, i; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_PRIMARY_MAC_ADDR, + cmd_flags, + token); + cmd_params = (struct dpsw_cmd_if *)cmd.params; + cmd_params->if_id = cpu_to_le16(if_id); + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + rsp_params = (struct dpsw_rsp_if_get_mac_addr *)cmd.params; + for (i = 0; i < 6; i++) + mac_addr[5 - i] = rsp_params->mac_addr[i]; + + return 0; +} + +/** + * dpsw_if_set_primary_mac_addr() + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPSW object + * @if_id: Interface Identifier + * @mac_addr: MAC address of the physical port, if any, otherwise 0 + * + * Return: Completion status. '0' on Success; Error code otherwise. + */ +int dpsw_if_set_primary_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 token, u16 if_id, u8 mac_addr[6]) +{ + struct dpsw_cmd_if_set_mac_addr *cmd_params; + struct fsl_mc_command cmd = { 0 }; + int i; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_PRIMARY_MAC_ADDR, + cmd_flags, + token); + cmd_params = (struct dpsw_cmd_if_set_mac_addr *)cmd.params; + cmd_params->if_id = cpu_to_le16(if_id); + for (i = 0; i < 6; i++) + cmd_params->mac_addr[i] = mac_addr[5 - i]; + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h index 25b45850925c..ab63ee4f5cb7 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h +++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h @@ -580,4 +580,13 @@ int dpsw_get_api_version(struct fsl_mc_io *mc_io, u16 *major_ver, u16 *minor_ver); +int dpsw_if_get_port_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, + u16 if_id, u8 mac_addr[6]); + +int dpsw_if_get_primary_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 token, u16 if_id, u8 mac_addr[6]); + +int dpsw_if_set_primary_mac_addr(struct fsl_mc_io *mc_io, u32 cmd_flags, + u16 token, u16 if_id, u8 mac_addr[6]); + #endif /* __FSL_DPSW_H */ diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index a8fc9bcf3b8a..2fb75a7c9314 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -468,6 +468,7 @@ static int port_carrier_state_sync(struct net_device *netdev) netif_carrier_off(netdev); port_priv->link_state = state.up; } + return 0; } @@ -690,6 +691,46 @@ err_map: return err; } +static int ethsw_port_set_mac_addr(struct ethsw_port_priv *port_priv) +{ + struct ethsw_core *ethsw = port_priv->ethsw_data; + struct net_device *net_dev = port_priv->netdev; + struct device *dev = net_dev->dev.parent; + u8 mac_addr[ETH_ALEN]; + int err; + + if (!(ethsw->features & ETHSW_FEATURE_MAC_ADDR)) + return 0; + + /* Get firmware address, if any */ + err = dpsw_if_get_port_mac_addr(ethsw->mc_io, 0, ethsw->dpsw_handle, + port_priv->idx, mac_addr); + if (err) { + dev_err(dev, "dpsw_if_get_port_mac_addr() failed\n"); + return err; + } + + /* First check if firmware has any address configured by bootloader */ + if (!is_zero_ether_addr(mac_addr)) { + memcpy(net_dev->dev_addr, mac_addr, net_dev->addr_len); + } else { + /* No MAC address configured, fill in net_dev->dev_addr + * with a random one + */ + eth_hw_addr_random(net_dev); + dev_dbg_once(dev, "device(s) have all-zero hwaddr, replaced with random\n"); + + /* Override NET_ADDR_RANDOM set by eth_hw_addr_random(); for all + * practical purposes, this will be our "permanent" mac address, + * at least until the next reboot. This move will also permit + * register_netdevice() to properly fill up net_dev->perm_addr. + */ + net_dev->addr_assign_type = NET_ADDR_PERM; + } + + return 0; +} + static const struct net_device_ops ethsw_port_ops = { .ndo_open = port_open, .ndo_stop = port_stop, @@ -712,8 +753,10 @@ static void ethsw_links_state_update(struct ethsw_core *ethsw) { int i; - for (i = 0; i < ethsw->sw_attr.num_ifs; i++) + for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { port_carrier_state_sync(ethsw->ports[i]->netdev); + ethsw_port_set_mac_addr(ethsw->ports[i]); + } } static irqreturn_t ethsw_irq0_handler_thread(int irq_num, void *arg) @@ -1364,6 +1407,14 @@ err_switchdev_nb: return err; } +static void ethsw_detect_features(struct ethsw_core *ethsw) +{ + ethsw->features = 0; + + if (ethsw->major > 8 || (ethsw->major == 8 && ethsw->minor >= 6)) + ethsw->features |= ETHSW_FEATURE_MAC_ADDR; +} + static int ethsw_init(struct fsl_mc_device *sw_dev) { struct device *dev = &sw_dev->dev; @@ -1407,6 +1458,8 @@ static int ethsw_init(struct fsl_mc_device *sw_dev) goto err_close; } + ethsw_detect_features(ethsw); + err = dpsw_reset(ethsw->mc_io, 0, ethsw->dpsw_handle); if (err) { dev_err(dev, "dpsw_reset err %d\n", err); @@ -1602,6 +1655,10 @@ static int ethsw_probe_port(struct ethsw_core *ethsw, u16 port_idx) if (err) goto err_port_probe; + err = ethsw_port_set_mac_addr(port_priv); + if (err) + goto err_port_probe; + err = register_netdev(port_netdev); if (err < 0) { dev_err(dev, "register_netdev error %d\n", err); diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h index 0e520fd94dbc..d136dbdcaffa 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.h +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.h @@ -37,6 +37,8 @@ #define ETHSW_MAX_FRAME_LENGTH (DPAA2_MFL - VLAN_ETH_HLEN - ETH_FCS_LEN) #define ETHSW_L2_MAX_FRM(mtu) ((mtu) + VLAN_ETH_HLEN + ETH_FCS_LEN) +#define ETHSW_FEATURE_MAC_ADDR BIT(0) + extern const struct ethtool_ops ethsw_port_ethtool_ops; struct ethsw_core; @@ -62,6 +64,7 @@ struct ethsw_core { u16 dpsw_handle; struct dpsw_attr sw_attr; u16 major, minor; + unsigned long features; int dev_id; struct ethsw_port_priv **ports; -- cgit v1.2.3-58-ga151 From 419317021ccc8957d9cf11bf2500c2cff37ca6c7 Mon Sep 17 00:00:00 2001 From: Arpitha Raghunandan <98.arpi@gmail.com> Date: Wed, 15 Jul 2020 21:16:23 +0530 Subject: staging: rtl8188eu: core: fix coding style issues Fixing WARNING: Prefer using '"%s...", __func__' to using 'function_name' in a string in rtw_ioctl_set.c Signed-off-by: Arpitha Raghunandan <98.arpi@gmail.com> Link: https://lore.kernel.org/r/20200715154623.78315-1-98.arpi@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ioctl_set.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index 9cc77ab4fd6b..fa88e8b2852d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -44,12 +44,12 @@ u8 rtw_do_join(struct adapter *padapter) if (!pmlmepriv->LinkDetectInfo.bBusyTraffic || pmlmepriv->to_roaming > 0) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_do_join(): site survey if scanned_queue is empty\n.")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("%s: site survey if scanned_queue is empty\n.", __func__)); /* submit site_survey_cmd */ ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); if (ret != _SUCCESS) { pmlmepriv->to_join = false; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_do_join(): site survey return error\n.")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("%s: site survey return error\n.", __func__)); } } else { pmlmepriv->to_join = false; @@ -313,7 +313,7 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, enum ndis_802_11_network_infra *pold_state = &cur_network->network.InfrastructureMode; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, - ("+rtw_set_802_11_infrastructure_mode: old =%d new =%d fw_state = 0x%08x\n", + ("+%s: old =%d new =%d fw_state = 0x%08x\n", __func__, *pold_state, networktype, get_fwstate(pmlmepriv))); if (*pold_state != networktype) { @@ -496,7 +496,7 @@ u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) break; } RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_wep:before memcpy, wep->KeyLength = 0x%x wep->KeyIndex = 0x%x keyid =%x\n", + ("%s:before memcpy, wep->KeyLength = 0x%x wep->KeyIndex = 0x%x keyid =%x\n", __func__, wep->KeyLength, wep->KeyIndex, keyid)); memcpy(&psecuritypriv->dot11DefKey[keyid].skey[0], @@ -507,7 +507,7 @@ u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) psecuritypriv->dot11PrivacyKeyIndex = keyid; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_wep:security key material : %x %x %x %x %x %x %x %x %x %x %x %x %x\n", + ("%s:security key material : %x %x %x %x %x %x %x %x %x %x %x %x %x\n", __func__, psecuritypriv->dot11DefKey[keyid].skey[0], psecuritypriv->dot11DefKey[keyid].skey[1], psecuritypriv->dot11DefKey[keyid].skey[2], -- cgit v1.2.3-58-ga151 From c4283950a9a4d3bf4a3f362e406c80ab14f10714 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 16 Jul 2020 16:47:20 +0100 Subject: staging: rtl8192u: fix a dubious looking mask before a shift Currently the masking of ret with 0xff and followed by a right shift of 8 bits always leaves a zero result. It appears the mask of 0xff is incorrect and should be 0xff00, but I don't have the hardware to test this. Fix this to mask the upper 8 bits before shifting. [ Not tested ] Addresses-Coverity: ("Operands don't affect result") Fixes: 8fc8598e61f6 ("Staging: Added Realtek rtl8192u driver to staging") Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20200716154720.1710252-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index fcfb9024a83f..6ec65187bef9 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -2374,7 +2374,7 @@ static int rtl8192_read_eeprom_info(struct net_device *dev) ret = eprom_read(dev, (EEPROM_TX_PW_INDEX_CCK >> 1)); if (ret < 0) return ret; - priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff) >> 8; + priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff00) >> 8; } else priv->EEPROMTxPowerLevelCCK = 0x10; RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n", priv->EEPROMTxPowerLevelCCK); -- cgit v1.2.3-58-ga151 From b4383c971bc5263efe2b0915ba67ebf2bf3f1ee5 Mon Sep 17 00:00:00 2001 From: Rustam Kovhaev Date: Thu, 16 Jul 2020 08:13:26 -0700 Subject: staging: rtl8712: handle firmware load failure when firmware fails to load we should not call unregister_netdev() this patch fixes a race condition between rtl871x_load_fw_cb() and r871xu_dev_remove() and fixes the bug reported by syzbot Reported-by: syzbot+80899a8a8efe8968cde7@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=80899a8a8efe8968cde7 Signed-off-by: Rustam Kovhaev Cc: stable Link: https://lore.kernel.org/r/20200716151324.1036204-1-rkovhaev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 3 ++- drivers/staging/rtl8712/usb_intf.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index ed51023b85a0..715f1fe8b472 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -33,7 +33,6 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) { struct _adapter *adapter = context; - complete(&adapter->rtl8712_fw_ready); if (!firmware) { struct usb_device *udev = adapter->dvobjpriv.pusbdev; struct usb_interface *usb_intf = adapter->pusb_intf; @@ -41,11 +40,13 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) dev_err(&udev->dev, "r8712u: Firmware request failed\n"); usb_put_dev(udev); usb_set_intfdata(usb_intf, NULL); + complete(&adapter->rtl8712_fw_ready); return; } adapter->fw = firmware; /* firmware available - start netdev */ register_netdev(adapter->pnetdev); + complete(&adapter->rtl8712_fw_ready); } static const char firmware_file[] = "rtlwifi/rtl8712u.bin"; diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index a87562f632a7..2fcd65260f4c 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -595,13 +595,17 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf) if (pnetdev) { struct _adapter *padapter = netdev_priv(pnetdev); - usb_set_intfdata(pusb_intf, NULL); - release_firmware(padapter->fw); /* never exit with a firmware callback pending */ wait_for_completion(&padapter->rtl8712_fw_ready); + pnetdev = usb_get_intfdata(pusb_intf); + usb_set_intfdata(pusb_intf, NULL); + if (!pnetdev) + goto firmware_load_fail; + release_firmware(padapter->fw); if (drvpriv.drv_registered) padapter->surprise_removed = true; - unregister_netdev(pnetdev); /* will call netdev_close() */ + if (pnetdev->reg_state != NETREG_UNINITIALIZED) + unregister_netdev(pnetdev); /* will call netdev_close() */ flush_scheduled_work(); udelay(1); /* Stop driver mlme relation timer */ @@ -614,6 +618,7 @@ static void r871xu_dev_remove(struct usb_interface *pusb_intf) */ usb_put_dev(udev); } +firmware_load_fail: /* If we didn't unplug usb dongle and remove/insert module, driver * fails on sitesurvey for the first time when device is up. * Reset usb port for sitesurvey fail issue. -- cgit v1.2.3-58-ga151 From 4eab532dca768559a7af5c82f054558c36615baf Mon Sep 17 00:00:00 2001 From: Suraj Upadhyay Date: Thu, 16 Jul 2020 14:28:11 +0530 Subject: staging: qlge/qlge_main.c: Replace depracated MSI API. Replace the depracated MSI API pci_enable_msi() with pci_alloc_irq_vectors(). Signed-off-by: Suraj Upadhyay Link: https://lore.kernel.org/r/20200716085811.GA29239@blackclown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index f7e26defb844..44ef00f1f8ee 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -3181,7 +3181,7 @@ static void ql_enable_msix(struct ql_adapter *qdev) msi: qdev->intr_count = 1; if (qlge_irq_type == MSI_IRQ) { - if (!pci_enable_msi(qdev->pdev)) { + if (pci_alloc_irq_vectors(qdev->pdev, 1, 1, PCI_IRQ_MSI) >= 0) { set_bit(QL_MSI_ENABLED, &qdev->flags); netif_info(qdev, ifup, qdev->ndev, "Running with MSI interrupts.\n"); -- cgit v1.2.3-58-ga151 From 6cf2602159d2ac7e0494c1bbd164dd06bb2480ef Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 15 Jul 2020 10:29:37 -0700 Subject: staging: rtl*/security: Use static const in array declarations Use static const in declarations where appropriate. Signed-off-by: Joe Perches Link: https://lore.kernel.org/r/818bbd25924f0c733a4a39d426fd30392d4eae80.camel@perches.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 4 ++-- drivers/staging/rtl8712/rtl871x_security.c | 2 +- drivers/staging/rtl8723bs/core/rtw_security.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index f9139f72b3a7..3483c3d9cb56 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -734,7 +734,7 @@ exit: /******** SBOX Table *********/ /*****************************/ -static u8 sbox_table[256] = { +static const u8 sbox_table[256] = { 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, @@ -817,7 +817,7 @@ static void next_key(u8 *key, int round) { u8 rcon; u8 sbox_key[4]; - u8 rcon_table[12] = { + static const u8 rcon_table[12] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x36, 0x36 }; diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c index 73e3d5ef3af2..c05010d85212 100644 --- a/drivers/staging/rtl8712/rtl871x_security.c +++ b/drivers/staging/rtl8712/rtl871x_security.c @@ -762,7 +762,7 @@ static void next_key(u8 *key, sint round) { u8 rcon; u8 sbox_key[4]; - u8 rcon_table[12] = { + static const u8 rcon_table[12] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x36, 0x36 }; diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 0f95009a30b6..0f15c96183a0 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -10,7 +10,7 @@ #include #include -static const char *_security_type_str[] = { +static const char * const _security_type_str[] = { "N/A", "WEP40", "TKIP", @@ -842,7 +842,7 @@ exit: /******** SBOX Table *********/ /*****************************/ - static u8 sbox_table[256] = { + static const u8 sbox_table[256] = { 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, @@ -957,7 +957,7 @@ static void next_key(u8 *key, sint round) { u8 rcon; u8 sbox_key[4]; - u8 rcon_table[12] = { + static const u8 rcon_table[12] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x36, 0x36 -- cgit v1.2.3-58-ga151 From 891a8d77ff12d0f161909101df08d46cc7a237ba Mon Sep 17 00:00:00 2001 From: Rahul Gottipati Date: Wed, 15 Jul 2020 22:01:52 +0530 Subject: staging: rtl8188eu: add blank line after declarations Added a blank line after declarations in drivers/staging/rtl8188eu/core/rtw_security.c to fix a checkpatch.pl warning Signed-off-by: Rahul Gottipati Link: https://lore.kernel.org/r/20200715163152.GA10190@rahulg-ThinkPad-T450 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index 3483c3d9cb56..5511f16c8550 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -840,6 +840,7 @@ static void next_key(u8 *key, int round) static void byte_sub(u8 *in, u8 *out) { int i; + for (i = 0; i < 16; i++) out[i] = sbox(in[i]); } -- cgit v1.2.3-58-ga151 From 9d5d041eebe3dcf7591ff7004896c329eb841ca6 Mon Sep 17 00:00:00 2001 From: B K Karthik Date: Fri, 17 Jul 2020 06:30:31 -0400 Subject: staging: comedi: comedi_fops.c: added casts to get rid of sparse warnings fixed sparse warnings by adding a cast in assignment from void [noderef] __user * to unsigned int __force * and a reverse cast in argument from unsigned int * to unsigned int __user * . Signed-off-by: B K Karthik Reviewed-by: Ian Abbott Link: https://lore.kernel.org/r/20200717103031.3mfnlvqo3waolsee@pesu-pes-edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 3f70e5dfac39..9cdc1e8a022d 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2956,7 +2956,7 @@ static int get_compat_cmd(struct comedi_cmd *cmd, cmd->scan_end_arg = v32.scan_end_arg; cmd->stop_src = v32.stop_src; cmd->stop_arg = v32.stop_arg; - cmd->chanlist = compat_ptr(v32.chanlist); + cmd->chanlist = (unsigned int __force *)compat_ptr(v32.chanlist); cmd->chanlist_len = v32.chanlist_len; cmd->data = compat_ptr(v32.data); cmd->data_len = v32.data_len; @@ -2983,7 +2983,7 @@ static int put_compat_cmd(struct comedi32_cmd_struct __user *cmd32, v32.stop_src = cmd->stop_src; v32.stop_arg = cmd->stop_arg; /* Assume chanlist pointer is unchanged. */ - v32.chanlist = ptr_to_compat(cmd->chanlist); + v32.chanlist = ptr_to_compat((unsigned int __user *)cmd->chanlist); v32.chanlist_len = cmd->chanlist_len; v32.data = ptr_to_compat(cmd->data); v32.data_len = cmd->data_len; -- cgit v1.2.3-58-ga151 From e5debaec5fa65ef35e4266ed1bbd76921a7ff97a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 18 Jul 2020 08:55:14 +0200 Subject: staging: rtl8188eu: clear tabstop style issues Clear tabstop style issues reported by checkpatch. WARNING: Statements should start on a tabstop Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200718065514.16289-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ioctl_set.c | 2 +- drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 2 +- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index fa88e8b2852d..26e5193cfd6c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -343,7 +343,7 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, *pold_state == Ndis802_11IBSS) { if (check_fwstate(pmlmepriv, _FW_LINKED)) rtw_indicate_disconnect(padapter); /* will clr Linked_state; before this function, we must have checked whether issue dis-assoc_cmd or not */ - } + } *pold_state = networktype; diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 740004d71a15..2baef9a285c0 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -145,7 +145,7 @@ void rtw_hal_set_odm_var(struct adapter *Adapter, enum hal_odm_variable eVariabl } else { DBG_88E("### Clean STA_(%d) info\n", psta->mac_id); ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, NULL); - } + } } break; case HAL_ODM_P2P_STATE: diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 5e6f7f0ed009..2e83d24fcb09 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -811,7 +811,7 @@ static int rtw_wx_set_pmkid(struct net_device *dev, psecuritypriv->PMKIDList[j].bUsed = false; break; } - } + } } else if (pPMK->cmd == IW_PMKSA_FLUSH) { DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n"); memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); -- cgit v1.2.3-58-ga151 From 1f491421c4172ac6d97dcd762a07ae40f110cbac Mon Sep 17 00:00:00 2001 From: B K Karthik Date: Sat, 18 Jul 2020 05:14:42 -0400 Subject: staging: rtl8188eu: include: fixed multiple blank space coding style issues fixed multiple blank space coding style issues reported by checkpatch Signed-off-by: B K Karthik Link: https://lore.kernel.org/r/20200718091442.xamnoawpguo42k7v@pesu-pes-edu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/hal_com.h | 2 +- drivers/staging/rtl8188eu/include/osdep_service.h | 2 +- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 2 +- drivers/staging/rtl8188eu/include/rtl8188e_xmit.h | 12 ++++++------ drivers/staging/rtl8188eu/include/rtw_cmd.h | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/hal_com.h b/drivers/staging/rtl8188eu/include/hal_com.h index 542e6e93ff8e..c2019772bef0 100644 --- a/drivers/staging/rtl8188eu/include/hal_com.h +++ b/drivers/staging/rtl8188eu/include/hal_com.h @@ -81,7 +81,7 @@ #define RATE_ALL_OFDM_AG (RATR_6M | RATR_9M | RATR_12M | RATR_18M | \ RATR_24M | RATR_36M | RATR_48M | RATR_54M) #define RATE_ALL_OFDM_1SS (RATR_MCS0 | RATR_MCS1 | RATR_MCS2 | \ - RATR_MCS3 | RATR_MCS4 | RATR_MCS5|RATR_MCS6 | \ + RATR_MCS3 | RATR_MCS4 | RATR_MCS5 | RATR_MCS6 | \ RATR_MCS7) #define RATE_ALL_OFDM_2SS (RATR_MCS8 | RATR_MCS9 | RATR_MCS10 | \ RATR_MCS11 | RATR_MCS12 | RATR_MCS13 | \ diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 0d3e4a6e7e85..31d897f1d21f 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -82,7 +82,7 @@ void rtw_free_netdev(struct net_device *netdev); /* Macros for handling unaligned memory accesses */ -#define RTW_GET_BE24(a) ((((u32)(a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ +#define RTW_GET_BE24(a) ((((u32)(a)[0]) << 16) | (((u32)(a)[1]) << 8) | \ ((u32)(a)[2])) void rtw_buf_free(u8 **buf, u32 *buf_len); diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index ba7c98712934..b1e73503a2c2 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -104,7 +104,7 @@ enum usb_rx_agg_mode { (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER + 1) /* 0xA9 */ /* Chip specific */ -#define CHIP_BONDING_IDENTIFIER(_value) (((_value)>>22)&0x3) +#define CHIP_BONDING_IDENTIFIER(_value) (((_value) >> 22) & 0x3) #define CHIP_BONDING_92C_1T2R 0x1 #define CHIP_BONDING_88C_USB_MCARD 0x2 #define CHIP_BONDING_88C_USB_HP 0x1 diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h index 49884cceb349..85efa41c8350 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h @@ -30,11 +30,11 @@ #define SET_EARLYMODE_LEN2_1(__pAddr, __Value) \ SET_BITS_TO_LE_4BYTE(__pAddr, 28, 4, __Value) #define SET_EARLYMODE_LEN2_2(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr+4, 0, 8, __Value) + SET_BITS_TO_LE_4BYTE(__pAddr + 4, 0, 8, __Value) #define SET_EARLYMODE_LEN3(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr+4, 8, 12, __Value) + SET_BITS_TO_LE_4BYTE(__pAddr + 4, 8, 12, __Value) #define SET_EARLYMODE_LEN4(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr+4, 20, 12, __Value) + SET_BITS_TO_LE_4BYTE(__pAddr + 4, 20, 12, __Value) /* */ /* defined for TX DESC Operation */ @@ -100,7 +100,7 @@ enum TXDESC_SC { #define txdesc_set_ccx_sw_88e(txdesc, value) \ do { \ - ((struct txdesc_88e *)(txdesc))->sw1 = (((value)>>8) & 0x0f); \ + ((struct txdesc_88e *)(txdesc))->sw1 = (((value) >> 8) & 0x0f); \ ((struct txdesc_88e *)(txdesc))->sw0 = ((value) & 0xff); \ } while (0) @@ -138,9 +138,9 @@ struct txrpt_ccx_88e { u8 sw0; }; -#define txrpt_ccx_sw_88e(txrpt_ccx) ((txrpt_ccx)->sw0 + ((txrpt_ccx)->sw1<<8)) +#define txrpt_ccx_sw_88e(txrpt_ccx) ((txrpt_ccx)->sw0 + ((txrpt_ccx)->sw1 << 8)) #define txrpt_ccx_qtime_88e(txrpt_ccx) \ - ((txrpt_ccx)->ccx_qtime0+((txrpt_ccx)->ccx_qtime1<<8)) + ((txrpt_ccx)->ccx_qtime0 + ((txrpt_ccx)->ccx_qtime1 << 8)) void rtl8188e_fill_fake_txdesc(struct adapter *padapter, u8 *pDesc, u32 BufferLen, u8 IsPsPoll, u8 IsBTQosNull); diff --git a/drivers/staging/rtl8188eu/include/rtw_cmd.h b/drivers/staging/rtl8188eu/include/rtw_cmd.h index fa5e212fc9e0..002a797c6d0a 100644 --- a/drivers/staging/rtl8188eu/include/rtw_cmd.h +++ b/drivers/staging/rtl8188eu/include/rtw_cmd.h @@ -115,7 +115,7 @@ struct setopmode_parm { */ #define RTW_SSID_SCAN_AMOUNT 9 /* for WEXT_CSCAN_AMOUNT 9 */ -#define RTW_CHANNEL_SCAN_AMOUNT (14+37) +#define RTW_CHANNEL_SCAN_AMOUNT (14 + 37) struct sitesurvey_parm { int scan_mode; /* active: 1, passive: 0 */ u8 ssid_num; -- cgit v1.2.3-58-ga151 From 939032fb84eb67a88a0baafbd33f27940e307fbc Mon Sep 17 00:00:00 2001 From: Anoop S Date: Sat, 18 Jul 2020 16:01:25 +0530 Subject: Staging: rtl8188eu: core: Fix coding style issue This fixes the following checkpatch.pl warning WARNING: Prefer using '"%s...", __func__' to using 'rtw_tkip_decrypt', this function's name, in a string. Signed-off-by: Anoop S Link: https://lore.kernel.org/r/20200718103125.62528-1-anoop.skumar1507@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index 5511f16c8550..21f6652dd69f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -718,7 +718,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) res = _FAIL; } } else { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt: stainfo==NULL!!!\n")); + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo==NULL!!!\n",__func__)); res = _FAIL; } } -- cgit v1.2.3-58-ga151 From 315116579f79fafd7eea285e0c608682a649d786 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 19 Jul 2020 13:40:45 +0200 Subject: staging: rtl8188eu: add spaces around operators in header files Add spaces around operators in the header files to improve readability and clear checkpatch issues. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200719114045.13595-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h | 4 ++-- drivers/staging/rtl8188eu/include/odm_types.h | 6 +++--- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 12 ++++++------ drivers/staging/rtl8188eu/include/rtw_efuse.h | 2 +- drivers/staging/rtl8188eu/include/rtw_pwrctrl.h | 2 +- drivers/staging/rtl8188eu/include/rtw_recv.h | 2 +- drivers/staging/rtl8188eu/include/rtw_security.h | 10 +++++----- drivers/staging/rtl8188eu/include/rtw_xmit.h | 12 ++++++------ drivers/staging/rtl8188eu/include/wifi.h | 2 +- drivers/staging/rtl8188eu/include/wlan_bssdef.h | 2 +- 10 files changed, 27 insertions(+), 27 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h b/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h index 79c0d2f9961e..646647feae85 100644 --- a/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h +++ b/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h @@ -28,9 +28,9 @@ #define GET_TX_RPT2_DESC_PKT_LEN_88E(__pRxStatusDesc) \ LE_BITS_TO_4BYTE(__pRxStatusDesc, 0, 9) #define GET_TX_RPT2_DESC_MACID_VALID_1_88E(__pRxStatusDesc) \ - LE_BITS_TO_4BYTE(__pRxStatusDesc+16, 0, 32) + LE_BITS_TO_4BYTE(__pRxStatusDesc + 16, 0, 32) #define GET_TX_RPT2_DESC_MACID_VALID_2_88E(__pRxStatusDesc) \ - LE_BITS_TO_4BYTE(__pRxStatusDesc+20, 0, 32) + LE_BITS_TO_4BYTE(__pRxStatusDesc + 20, 0, 32) #define GET_TX_REPORT_TYPE1_RERTY_0(__pAddr) \ LE_BITS_TO_4BYTE(__pAddr, 0, 16) diff --git a/drivers/staging/rtl8188eu/include/odm_types.h b/drivers/staging/rtl8188eu/include/odm_types.h index 7255f7afff7a..2b207f09b56b 100644 --- a/drivers/staging/rtl8188eu/include/odm_types.h +++ b/drivers/staging/rtl8188eu/include/odm_types.h @@ -15,10 +15,10 @@ enum HAL_STATUS { }; #define SET_TX_DESC_ANTSEL_A_88E(__pTxDesc, __Value) \ - SET_BITS_TO_LE_4BYTE(__pTxDesc+8, 24, 1, __Value) + SET_BITS_TO_LE_4BYTE(__pTxDesc + 8, 24, 1, __Value) #define SET_TX_DESC_ANTSEL_B_88E(__pTxDesc, __Value) \ - SET_BITS_TO_LE_4BYTE(__pTxDesc+8, 25, 1, __Value) + SET_BITS_TO_LE_4BYTE(__pTxDesc + 8, 25, 1, __Value) #define SET_TX_DESC_ANTSEL_C_88E(__pTxDesc, __Value) \ - SET_BITS_TO_LE_4BYTE(__pTxDesc+28, 29, 1, __Value) + SET_BITS_TO_LE_4BYTE(__pTxDesc + 28, 29, 1, __Value) #endif /* __ODM_TYPES_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index b1e73503a2c2..6035c12ec578 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -45,7 +45,7 @@ #define Rtl8188E_NIC_LPS_LEAVE_FLOW rtl8188E_leave_lps_flow #define DRVINFO_SZ 4 /* unit is 8bytes */ -#define PageNum_128(_Len) (u32)(((_Len)>>7) + ((_Len) & 0x7F ? 1 : 0)) +#define PageNum_128(_Len) (u32)(((_Len) >> 7) + ((_Len) & 0x7F ? 1 : 0)) /* download firmware related data structure */ #define FW_8188E_SIZE 0x4000 /* 16384,16k */ @@ -54,11 +54,11 @@ #define MAX_PAGE_SIZE 4096 /* @ page : 4k bytes */ -#define IS_FW_HEADER_EXIST(_pFwHdr) \ - ((le16_to_cpu(_pFwHdr->signature)&0xFFF0) == 0x92C0 || \ - (le16_to_cpu(_pFwHdr->signature)&0xFFF0) == 0x88C0 || \ - (le16_to_cpu(_pFwHdr->signature)&0xFFF0) == 0x2300 || \ - (le16_to_cpu(_pFwHdr->signature)&0xFFF0) == 0x88E0) +#define IS_FW_HEADER_EXIST(_pFwHdr) \ + ((le16_to_cpu(_pFwHdr->signature) & 0xFFF0) == 0x92C0 || \ + (le16_to_cpu(_pFwHdr->signature) & 0xFFF0) == 0x88C0 || \ + (le16_to_cpu(_pFwHdr->signature) & 0xFFF0) == 0x2300 || \ + (le16_to_cpu(_pFwHdr->signature) & 0xFFF0) == 0x88E0) #define DRIVER_EARLY_INT_TIME 0x05 #define BCN_DMA_ATIME_INT_TIME 0x02 diff --git a/drivers/staging/rtl8188eu/include/rtw_efuse.h b/drivers/staging/rtl8188eu/include/rtw_efuse.h index 7a9c8ff0daa9..5926fc9b5e6b 100644 --- a/drivers/staging/rtl8188eu/include/rtw_efuse.h +++ b/drivers/staging/rtl8188eu/include/rtw_efuse.h @@ -44,7 +44,7 @@ /* The following is for BT Efuse definition */ #define EFUSE_BT_MAX_MAP_LEN 1024 #define EFUSE_MAX_BANK 4 -#define EFUSE_MAX_BT_BANK (EFUSE_MAX_BANK-1) +#define EFUSE_MAX_BT_BANK (EFUSE_MAX_BANK - 1) /*--------------------------Define Parameters-------------------------------*/ #define EFUSE_MAX_WORD_UNIT 4 diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h index 404634999e35..06062643c868 100644 --- a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h @@ -84,7 +84,7 @@ struct reportpwrstate_parm { unsigned short rsvd; }; -#define LPS_DELAY_TIME 1*HZ /* 1 sec */ +#define LPS_DELAY_TIME 1 * HZ /* 1 sec */ #define EXE_PWR_NONE 0x01 #define EXE_PWR_IPS 0x02 diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index e383cb119e1b..b281b9e7fcea 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -13,7 +13,7 @@ #define NR_RECVFRAME 256 #define RXFRAME_ALIGN 8 -#define RXFRAME_ALIGN_SZ (1<>(32-(n))) & ((1UL << (n)) - 1))) -#define ROR32(A, n) ROL32((A), 32-(n)) +#define ROL32(A, n) (((A) << (n)) | (((A) >> (32 - (n))) & ((1UL << (n)) - 1))) +#define ROR32(A, n) ROL32((A), 32 - (n)) struct mic_data { u32 K0, K1; /* Key */ @@ -275,12 +275,12 @@ static const unsigned long K[64] = { /* Various logical functions */ #define RORc(x, y) \ - (((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y)&31)) | \ - ((unsigned long)(x) << (unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) + (((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y) & 31)) | \ + ((unsigned long)(x) << (unsigned long)(32 - ((y) & 31)))) & 0xFFFFFFFFUL) #define Ch(x, y, z) (z ^ (x & (y ^ z))) #define Maj(x, y, z) (((x | y) & z) | (x & y)) #define S(x, n) RORc((x), (n)) -#define R(x, n) (((x)&0xFFFFFFFFUL)>>(n)) +#define R(x, n) (((x) & 0xFFFFFFFFUL) >> (n)) #define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22)) #define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25)) #define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3)) diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h b/drivers/staging/rtl8188eu/include/rtw_xmit.h index 3c03987c81a1..456fd52717f3 100644 --- a/drivers/staging/rtl8188eu/include/rtw_xmit.h +++ b/drivers/staging/rtl8188eu/include/rtw_xmit.h @@ -42,8 +42,8 @@ do {\ pattrib_iv[0] = dot11txpn._byte_.TSC0;\ pattrib_iv[1] = dot11txpn._byte_.TSC1;\ pattrib_iv[2] = dot11txpn._byte_.TSC2;\ - pattrib_iv[3] = ((keyidx & 0x3)<<6);\ - dot11txpn.val = (dot11txpn.val == 0xffffff) ? 0 : (dot11txpn.val+1);\ + pattrib_iv[3] = ((keyidx & 0x3) << 6);\ + dot11txpn.val = (dot11txpn.val == 0xffffff) ? 0 : (dot11txpn.val + 1);\ } while (0) #define TKIP_IV(pattrib_iv, dot11txpn, keyidx)\ @@ -51,12 +51,12 @@ do {\ pattrib_iv[0] = dot11txpn._byte_.TSC1;\ pattrib_iv[1] = (dot11txpn._byte_.TSC1 | 0x20) & 0x7f;\ pattrib_iv[2] = dot11txpn._byte_.TSC0;\ - pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\ + pattrib_iv[3] = BIT(5) | ((keyidx & 0x3) << 6);\ pattrib_iv[4] = dot11txpn._byte_.TSC2;\ pattrib_iv[5] = dot11txpn._byte_.TSC3;\ pattrib_iv[6] = dot11txpn._byte_.TSC4;\ pattrib_iv[7] = dot11txpn._byte_.TSC5;\ - dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val+1);\ + dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val + 1);\ } while (0) #define AES_IV(pattrib_iv, dot11txpn, keyidx)\ @@ -64,12 +64,12 @@ do { \ pattrib_iv[0] = dot11txpn._byte_.TSC0; \ pattrib_iv[1] = dot11txpn._byte_.TSC1; \ pattrib_iv[2] = 0; \ - pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6); \ + pattrib_iv[3] = BIT(5) | ((keyidx & 0x3) << 6); \ pattrib_iv[4] = dot11txpn._byte_.TSC2; \ pattrib_iv[5] = dot11txpn._byte_.TSC3; \ pattrib_iv[6] = dot11txpn._byte_.TSC4; \ pattrib_iv[7] = dot11txpn._byte_.TSC5; \ - dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val+1);\ + dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val + 1);\ } while (0) #define HWXMIT_ENTRY 4 diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h index 791f287a546d..217be809b937 100644 --- a/drivers/staging/rtl8188eu/include/wifi.h +++ b/drivers/staging/rtl8188eu/include/wifi.h @@ -35,7 +35,7 @@ enum WIFI_FRAME_TYPE { WIFI_MGT_TYPE = (0), WIFI_CTRL_TYPE = (BIT(2)), WIFI_DATA_TYPE = (BIT(3)), - WIFI_QOS_DATA_TYPE = (BIT(7)|BIT(3)), /* QoS Data */ + WIFI_QOS_DATA_TYPE = (BIT(7) | BIT(3)), /* QoS Data */ }; enum WIFI_FRAME_SUBTYPE { diff --git a/drivers/staging/rtl8188eu/include/wlan_bssdef.h b/drivers/staging/rtl8188eu/include/wlan_bssdef.h index 1b6435cd5390..2c184ce8746b 100644 --- a/drivers/staging/rtl8188eu/include/wlan_bssdef.h +++ b/drivers/staging/rtl8188eu/include/wlan_bssdef.h @@ -146,7 +146,7 @@ enum ndis_802_11_status_type { #define MIC_CHECK_TIME 60000000 #ifndef Ndis802_11APMode -#define Ndis802_11APMode (Ndis802_11InfrastructureMax+1) +#define Ndis802_11APMode (Ndis802_11InfrastructureMax + 1) #endif struct wlan_phy_info { -- cgit v1.2.3-58-ga151 From 809a9308646ac7d54b8e5d1a64edc63e1192ca67 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Sun, 19 Jul 2020 14:32:44 +0200 Subject: staging: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200719123244.58718-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/clocking-wizard/dt-binding.txt | 2 +- drivers/staging/gs_fpgaboot/README | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/clocking-wizard/dt-binding.txt b/drivers/staging/clocking-wizard/dt-binding.txt index 723271e93316..efb67ff9f76c 100644 --- a/drivers/staging/clocking-wizard/dt-binding.txt +++ b/drivers/staging/clocking-wizard/dt-binding.txt @@ -5,7 +5,7 @@ found in the product guide[2]. [1] Documentation/devicetree/bindings/clock/clock-bindings.txt [2] Clocking Wizard Product Guide -http://www.xilinx.com/support/documentation/ip_documentation/clk_wiz/v5_1/pg065-clk-wiz.pdf +https://www.xilinx.com/support/documentation/ip_documentation/clk_wiz/v5_1/pg065-clk-wiz.pdf Required properties: - compatible: Must be 'xlnx,clocking-wizard' diff --git a/drivers/staging/gs_fpgaboot/README b/drivers/staging/gs_fpgaboot/README index 8d793c1769b0..b85a76849fc4 100644 --- a/drivers/staging/gs_fpgaboot/README +++ b/drivers/staging/gs_fpgaboot/README @@ -65,6 +65,6 @@ TABLE OF CONTENTS. 6. REFERENCE 1. Xilinx APP NOTE XAPP583: - http://www.xilinx.com/support/documentation/application_notes/xapp583-fpga-configuration.pdf + https://www.xilinx.com/support/documentation/application_notes/xapp583-fpga-configuration.pdf 2. bitstream file info: http://home.earthlink.net/~davesullins/software/bitinfo.html -- cgit v1.2.3-58-ga151 From 15d25ed790504a5fb0bb3cea8088b3e087eba0e7 Mon Sep 17 00:00:00 2001 From: Sumera Priyadarsini Date: Mon, 20 Jul 2020 17:58:17 +0530 Subject: staging: wlan-ng: Fix alignment to match open parenthesis This patch fixes the file cfg80211.c to avoid the checkpatch.pl warning: CHECK: Alignment should match open parenthesis Signed-off-by: Sumera Priyadarsini Link: https://lore.kernel.org/r/20200720122817.31164-1-sylphrenadin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/cfg80211.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index fac38c842ac5..759e475e303c 100644 --- a/drivers/staging/wlan-ng/cfg80211.c +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -359,16 +359,15 @@ static int prism2_scan(struct wiphy *wiphy, freq = ieee80211_channel_to_frequency(msg2.dschannel.data, NL80211_BAND_2GHZ); bss = cfg80211_inform_bss(wiphy, - ieee80211_get_channel(wiphy, freq), - CFG80211_BSS_FTYPE_UNKNOWN, - (const u8 *)&msg2.bssid.data.data, - msg2.timestamp.data, msg2.capinfo.data, - msg2.beaconperiod.data, - ie_buf, - ie_len, - (msg2.signal.data - 65536) * 100, /* Conversion to signed type */ - GFP_KERNEL - ); + ieee80211_get_channel(wiphy, freq), + CFG80211_BSS_FTYPE_UNKNOWN, + (const u8 *)&msg2.bssid.data.data, + msg2.timestamp.data, msg2.capinfo.data, + msg2.beaconperiod.data, + ie_buf, + ie_len, + (msg2.signal.data - 65536) * 100, /* Conversion to signed type */ + GFP_KERNEL); if (!bss) { err = -ENOMEM; -- cgit v1.2.3-58-ga151 From 77cedcc0b31af6a6cb4ce64af2ee2a3ff2152944 Mon Sep 17 00:00:00 2001 From: Darshan D V Date: Mon, 20 Jul 2020 14:44:41 +0530 Subject: staging: rtl8192e: add space before open parenthesis Fix the coding style error by adding a space before open parenthesis '(' in a conditional statement. Signed-off-by: Darshan D V Link: https://lore.kernel.org/r/20200720091442.19532-1-darshandv10@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index 0cbf4a1a326b..b2af802b9451 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -278,7 +278,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) int aad_len, ret; req = aead_request_alloc(key->tfm, GFP_ATOMIC); - if(!req) + if (!req) return -ENOMEM; aad_len = ccmp_init_iv_and_aad(hdr, pn, iv, aad); -- cgit v1.2.3-58-ga151 From 846fbc621f24e2f00de3e27d6bbd0fe4638b7e01 Mon Sep 17 00:00:00 2001 From: Darshan D V Date: Mon, 20 Jul 2020 14:44:42 +0530 Subject: staging: rtl8192e: add proper code indent As the code indent for a conditional statement is not according to the preferred coding style for the linux kernel, add code indent as necessary after a conditional statement. Signed-off-by: Darshan D V Link: https://lore.kernel.org/r/20200720091442.19532-2-darshandv10@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index b2af802b9451..b60e2a109ce4 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -337,7 +337,7 @@ static int rtllib_ccmp_set_key(void *key, int len, u8 *seq, void *priv) } if (crypto_aead_setauthsize(data->tfm, CCMP_MIC_LEN) || crypto_aead_setkey(data->tfm, data->key, CCMP_TK_LEN)) - return -1; + return -1; } else if (len == 0) { data->key_set = 0; } else { -- cgit v1.2.3-58-ga151 From 2f248a80223257be094c694a75de73aeab0a6530 Mon Sep 17 00:00:00 2001 From: Marian Posteuca Date: Mon, 20 Jul 2020 09:42:05 +0300 Subject: staging: dpaa2-ethsw: fix switch/case fallthrough warning Fix the fallthrough warning that is reported by checkpatch. Signed-off-by: Marian Posteuca Link: https://lore.kernel.org/r/20200720064205.10323-1-posteuca@mutex.one Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 2fb75a7c9314..db10fd18914d 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1362,7 +1362,7 @@ static int port_switchdev_blocking_event(struct notifier_block *unused, return NOTIFY_DONE; switch (event) { - case SWITCHDEV_PORT_OBJ_ADD: /* fall through */ + case SWITCHDEV_PORT_OBJ_ADD: case SWITCHDEV_PORT_OBJ_DEL: return ethsw_switchdev_port_obj_event(event, dev, ptr); case SWITCHDEV_PORT_ATTR_SET: -- cgit v1.2.3-58-ga151 From 006266854705b308531c3a27c9e65d0eeadb5742 Mon Sep 17 00:00:00 2001 From: Suraj Upadhyay Date: Sun, 19 Jul 2020 20:04:04 +0530 Subject: staging: rts5208: rtsx: Replace depracated MSI API Replace depracated MSI IRQ enablers and disablers with pci_alloc_irq_vectors and pci_free_irq_vectors respectively. Compile tested. Signed-off-by: Suraj Upadhyay Link: https://lore.kernel.org/r/20200719143404.GA32519@blackclown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index e28e162d004e..898add4d1fc8 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -283,7 +283,7 @@ static int __maybe_unused rtsx_suspend(struct device *dev_d) } if (chip->msi_en) - pci_disable_msi(pci); + pci_free_irq_vectors(pci); device_wakeup_enable(dev_d); @@ -310,7 +310,7 @@ static int __maybe_unused rtsx_resume(struct device *dev_d) pci_set_master(pci); if (chip->msi_en) { - if (pci_enable_msi(pci) < 0) + if (pci_alloc_irq_vectors(pci, 1, 1, PCI_IRQ_MSI) < 0) chip->msi_en = 0; } @@ -347,7 +347,7 @@ static void rtsx_shutdown(struct pci_dev *pci) } if (chip->msi_en) - pci_disable_msi(pci); + pci_free_irq_vectors(pci); pci_disable_device(pci); } @@ -594,7 +594,7 @@ static void rtsx_release_resources(struct rtsx_dev *dev) if (dev->irq > 0) free_irq(dev->irq, (void *)dev); if (dev->chip->msi_en) - pci_disable_msi(dev->pci); + pci_free_irq_vectors(dev->pci); if (dev->remap_addr) iounmap(dev->remap_addr); @@ -881,7 +881,7 @@ static int rtsx_probe(struct pci_dev *pci, dev_info(&pci->dev, "pci->irq = %d\n", pci->irq); if (dev->chip->msi_en) { - if (pci_enable_msi(pci) < 0) + if (pci_alloc_irq_vectors(pci, 1, 1, PCI_IRQ_MSI) < 0) dev->chip->msi_en = 0; } @@ -952,7 +952,7 @@ irq_acquire_fail: dev->chip->host_cmds_ptr = NULL; dev->chip->host_sg_tbl_ptr = NULL; if (dev->chip->msi_en) - pci_disable_msi(dev->pci); + pci_free_irq_vectors(dev->pci); dma_alloc_fail: iounmap(dev->remap_addr); ioremap_fail: -- cgit v1.2.3-58-ga151 From b99a3f7093be7d7ff67491f75bf24fd60d8ba774 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 21 Jul 2020 12:19:14 +0300 Subject: staging: dpaa2-ethsw: verify the nofifier block Since now we have a notifier block for each DPSW instance probed, we have to also check that the netdev is indeed connected to the notifier received. Without this, we end up with the same switchdev callback being executed multiple times (because it would be received by all notifier blocks, not just the one intended to). Also, move the function higher in the source file because it will be used in later patches from multiple places. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20200721091919.20394-2-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index db10fd18914d..59ad7c75341a 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -749,6 +749,20 @@ static const struct net_device_ops ethsw_port_ops = { .ndo_get_phys_port_name = port_get_phys_name, }; +static bool ethsw_port_dev_check(const struct net_device *netdev, + struct notifier_block *nb) +{ + struct ethsw_port_priv *port_priv = netdev_priv(netdev); + + if (netdev->netdev_ops == ðsw_port_ops && + (!nb || &port_priv->ethsw_data->port_nb == nb || + &port_priv->ethsw_data->port_switchdev_nb == nb || + &port_priv->ethsw_data->port_switchdevb_nb == nb)) + return true; + + return false; +} + static void ethsw_links_state_update(struct ethsw_core *ethsw) { int i; @@ -1199,12 +1213,7 @@ static int port_bridge_leave(struct net_device *netdev) return err; } -static bool ethsw_port_dev_check(const struct net_device *netdev) -{ - return netdev->netdev_ops == ðsw_port_ops; -} - -static int port_netdevice_event(struct notifier_block *unused, +static int port_netdevice_event(struct notifier_block *nb, unsigned long event, void *ptr) { struct net_device *netdev = netdev_notifier_info_to_dev(ptr); @@ -1212,7 +1221,7 @@ static int port_netdevice_event(struct notifier_block *unused, struct net_device *upper_dev; int err = 0; - if (!ethsw_port_dev_check(netdev)) + if (!ethsw_port_dev_check(netdev, nb)) return NOTIFY_DONE; /* Handle just upper dev link/unlink for the moment */ @@ -1280,7 +1289,7 @@ static void ethsw_switchdev_event_work(struct work_struct *work) } /* Called under rcu_read_lock() */ -static int port_switchdev_event(struct notifier_block *unused, +static int port_switchdev_event(struct notifier_block *nb, unsigned long event, void *ptr) { struct net_device *dev = switchdev_notifier_info_to_dev(ptr); @@ -1289,7 +1298,7 @@ static int port_switchdev_event(struct notifier_block *unused, struct switchdev_notifier_fdb_info *fdb_info = ptr; struct ethsw_core *ethsw = port_priv->ethsw_data; - if (!ethsw_port_dev_check(dev)) + if (!ethsw_port_dev_check(dev, nb)) return NOTIFY_DONE; if (event == SWITCHDEV_PORT_ATTR_SET) @@ -1353,12 +1362,12 @@ ethsw_switchdev_port_obj_event(unsigned long event, struct net_device *netdev, return notifier_from_errno(err); } -static int port_switchdev_blocking_event(struct notifier_block *unused, +static int port_switchdev_blocking_event(struct notifier_block *nb, unsigned long event, void *ptr) { struct net_device *dev = switchdev_notifier_info_to_dev(ptr); - if (!ethsw_port_dev_check(dev)) + if (!ethsw_port_dev_check(dev, nb)) return NOTIFY_DONE; switch (event) { -- cgit v1.2.3-58-ga151 From af85d0e06c6ab1a2d9432cf5923a1a5de816ac22 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 21 Jul 2020 12:19:15 +0300 Subject: staging: dpaa2-ethsw: don't allow interfaces from different DPSWs to be bridged Error out when the user tries to bridge two switch interfaces that are from different DPSW instances. This is not supported by the hardware and we should reflect this into what the user is aware of. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20200721091919.20394-3-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 59ad7c75341a..f0d10afb1460 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1182,6 +1182,9 @@ static int port_bridge_join(struct net_device *netdev, { struct ethsw_port_priv *port_priv = netdev_priv(netdev); struct ethsw_core *ethsw = port_priv->ethsw_data; + struct ethsw_port_priv *other_port_priv; + struct net_device *other_dev; + struct list_head *iter; int i, err; for (i = 0; i < ethsw->sw_attr.num_ifs; i++) @@ -1192,6 +1195,18 @@ static int port_bridge_join(struct net_device *netdev, return -EINVAL; } + netdev_for_each_lower_dev(upper_dev, other_dev, iter) { + if (!ethsw_port_dev_check(other_dev, NULL)) + continue; + + other_port_priv = netdev_priv(other_dev); + if (other_port_priv->ethsw_data != port_priv->ethsw_data) { + netdev_err(netdev, + "Interface from a different DPSW is in the bridge already!\n"); + return -EINVAL; + } + } + /* Enable flooding */ err = ethsw_port_set_flood(port_priv, 1); if (!err) -- cgit v1.2.3-58-ga151 From 4acfc4393e90e4dfa6ebc6e43545296ca1d928fe Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 21 Jul 2020 12:19:16 +0300 Subject: staging: dpaa2-ethsw: setup the STP state for all installed VLANs Setup the STP state for all VLANs installed on the port. This is also avoiding the error situation when the DEFAULT_VLAN_ID is not installed on the port (thus the firmware complains that it cannot setup the required STP state). Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20200721091919.20394-4-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index f0d10afb1460..c620ee23227b 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -183,21 +183,26 @@ static int ethsw_port_set_flood(struct ethsw_port_priv *port_priv, bool enable) static int ethsw_port_set_stp_state(struct ethsw_port_priv *port_priv, u8 state) { struct dpsw_stp_cfg stp_cfg = { - .vlan_id = DEFAULT_VLAN_ID, .state = state, }; int err; + u16 vid; if (!netif_running(port_priv->netdev) || state == port_priv->stp_state) return 0; /* Nothing to do */ - err = dpsw_if_set_stp(port_priv->ethsw_data->mc_io, 0, - port_priv->ethsw_data->dpsw_handle, - port_priv->idx, &stp_cfg); - if (err) { - netdev_err(port_priv->netdev, - "dpsw_if_set_stp err %d\n", err); - return err; + for (vid = 0; vid <= VLAN_VID_MASK; vid++) { + if (port_priv->vlans[vid] & ETHSW_VLAN_MEMBER) { + stp_cfg.vlan_id = vid; + err = dpsw_if_set_stp(port_priv->ethsw_data->mc_io, 0, + port_priv->ethsw_data->dpsw_handle, + port_priv->idx, &stp_cfg); + if (err) { + netdev_err(port_priv->netdev, + "dpsw_if_set_stp err %d\n", err); + return err; + } + } } port_priv->stp_state = state; -- cgit v1.2.3-58-ga151 From adcdd57d5feab928d58959956844a6b755a41650 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 21 Jul 2020 12:19:17 +0300 Subject: staging: dpaa2-ethsw: destroy workqueue after deregistering the notifiers We should destroy the switch workqueue only after deregistering the switchdev notifiers. Without this fix, we could end up with switchdev notifications on a draining workqueue and also with a lock up since the netdevice reference count is increased (in port_switchdev_event) and not decreased ever (since the workqueue did not run). Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20200721091919.20394-5-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index c620ee23227b..c4267ef44597 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1628,8 +1628,6 @@ static int ethsw_remove(struct fsl_mc_device *sw_dev) ethsw_teardown_irqs(sw_dev); - destroy_workqueue(ethsw->workqueue); - dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle); for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { @@ -1640,6 +1638,9 @@ static int ethsw_remove(struct fsl_mc_device *sw_dev) kfree(ethsw->ports); ethsw_takedown(sw_dev); + + destroy_workqueue(ethsw->workqueue); + fsl_mc_portal_free(ethsw->mc_io); kfree(ethsw); -- cgit v1.2.3-58-ga151 From 1867a402d801d93f9f9b24fdaef1bc84b9debd5d Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 21 Jul 2020 12:19:18 +0300 Subject: staging: dpaa2-ethsw: read the port state from firmware Rely on the port state seen by the firmware since it will also be the one erroring out when trying to setup anything major when the port is up. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20200721091919.20394-6-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index c4267ef44597..4165594551e0 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -43,6 +43,25 @@ static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid) return 0; } +static bool ethsw_port_is_up(struct ethsw_port_priv *port_priv) +{ + struct net_device *netdev = port_priv->netdev; + struct dpsw_link_state state; + int err; + + err = dpsw_if_get_link_state(port_priv->ethsw_data->mc_io, 0, + port_priv->ethsw_data->dpsw_handle, + port_priv->idx, &state); + if (err) { + netdev_err(netdev, "dpsw_if_get_link_state() err %d\n", err); + return true; + } + + WARN_ONCE(state.up > 1, "Garbage read into link_state"); + + return state.up ? true : false; +} + static int ethsw_port_set_pvid(struct ethsw_port_priv *port_priv, u16 pvid) { struct ethsw_core *ethsw = port_priv->ethsw_data; @@ -61,7 +80,7 @@ static int ethsw_port_set_pvid(struct ethsw_port_priv *port_priv, u16 pvid) tci_cfg.vlan_id = pvid; /* Interface needs to be down to change PVID */ - up = netif_running(netdev); + up = ethsw_port_is_up(port_priv); if (up) { err = dpsw_if_disable(ethsw->mc_io, 0, ethsw->dpsw_handle, -- cgit v1.2.3-58-ga151 From 70476feb62ce9955b8101fca84f3f8b3788e6eb2 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Tue, 21 Jul 2020 12:19:19 +0300 Subject: staging: dpaa2-ethsw: check if there is space for a new VLAN Avoid getting into a WARNING as below by checking, while in the prepare state of the transactional operation, if there is space for a new VLAN. If we reached the maximum number, return an appropriate error. [ 6503.657564] eth3: Commit of object (id=1) failed. [ 6503.657588] WARNING: CPU: 2 PID: 17144 at net/switchdev/switchdev.c:277 switchdev_port_obj_add_now+0xcc/0x110 ... [ 6503.657628] x1 : 70887ce26695c500 x0 : 0000000000000000 [ 6503.657630] Call trace: [ 6503.657633] switchdev_port_obj_add_now+0xcc/0x110 [ 6503.657635] switchdev_port_obj_add+0x40/0xc0 [ 6503.657638] br_switchdev_port_vlan_add+0x50/0x78 [ 6503.657640] __vlan_add+0x2dc/0x758 [ 6503.657642] nbp_vlan_add+0xc0/0x180 [ 6503.657644] br_vlan_info.isra.0+0x68/0x128 [ 6503.657646] br_process_vlan_info+0x224/0x2f8 [ 6503.657647] br_afspec+0x158/0x188 [ 6503.657649] br_setlink+0x1a4/0x290 Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20200721091919.20394-7-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 4165594551e0..316fd9afd461 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -979,10 +979,27 @@ static int port_vlans_add(struct net_device *netdev, struct switchdev_trans *trans) { struct ethsw_port_priv *port_priv = netdev_priv(netdev); - int vid, err = 0; + struct ethsw_core *ethsw = port_priv->ethsw_data; + struct dpsw_attr *attr = ðsw->sw_attr; + int vid, err = 0, new_vlans = 0; + + if (switchdev_trans_ph_prepare(trans)) { + for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) + if (!port_priv->ethsw_data->vlans[vid]) + new_vlans++; + + /* Check if there is space for a new VLAN */ + err = dpsw_get_attributes(ethsw->mc_io, 0, ethsw->dpsw_handle, + ðsw->sw_attr); + if (err) { + netdev_err(netdev, "dpsw_get_attributes err %d\n", err); + return err; + } + if (attr->max_vlans - attr->num_vlans < new_vlans) + return -ENOSPC; - if (switchdev_trans_ph_prepare(trans)) return 0; + } for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { if (!port_priv->ethsw_data->vlans[vid]) { -- cgit v1.2.3-58-ga151 From 869090266ceb60210f69f96fb29fe8ad6b4b850d Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 23 Jul 2020 09:52:42 +0200 Subject: staging: rtl8188eu: clear alignment style issues Clear checkpatch alignment style issues in rtl8188eu_recv.c. CHECK: Alignment should match open parenthesis The file is now checkpatch clean. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200723075243.21924-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index 1cf8cff9a2a4..ab8313cf5bf0 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -33,7 +33,7 @@ int rtw_hal_init_recv_priv(struct adapter *padapter) if (!precvpriv->precv_buf) { res = _FAIL; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, - ("alloc recv_buf fail!\n")); + ("alloc recv_buf fail!\n")); goto exit; } precvbuf = precvpriv->precv_buf; @@ -54,11 +54,11 @@ int rtw_hal_init_recv_priv(struct adapter *padapter) for (i = 0; i < NR_PREALLOC_RECV_SKB; i++) { pskb = __netdev_alloc_skb(padapter->pnetdev, - MAX_RECVBUF_SZ, GFP_KERNEL); + MAX_RECVBUF_SZ, GFP_KERNEL); if (pskb) { kmemleak_not_leak(pskb); skb_queue_tail(&precvpriv->free_recv_skb_queue, - pskb); + pskb); } pskb = NULL; } @@ -88,7 +88,7 @@ void rtw_hal_free_recv_priv(struct adapter *padapter) if (skb_queue_len(&precvpriv->free_recv_skb_queue)) DBG_88E(KERN_WARNING "free_recv_skb_queue not empty, %d\n", - skb_queue_len(&precvpriv->free_recv_skb_queue)); + skb_queue_len(&precvpriv->free_recv_skb_queue)); skb_queue_purge(&precvpriv->free_recv_skb_queue); } -- cgit v1.2.3-58-ga151 From a176db57611f260d920e34d36bb43460069da1ed Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 23 Jul 2020 09:52:43 +0200 Subject: staging: rtl8188eu: cleanup whitespace in declarations Replace tabs with spaces in declarations to cleanup whitespace in rtl8188eu_recv.c. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20200723075243.21924-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c index ab8313cf5bf0..7badfc2e45df 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -16,10 +16,10 @@ #include -int rtw_hal_init_recv_priv(struct adapter *padapter) +int rtw_hal_init_recv_priv(struct adapter *padapter) { - struct recv_priv *precvpriv = &padapter->recvpriv; - int i, res = _SUCCESS; + struct recv_priv *precvpriv = &padapter->recvpriv; + int i, res = _SUCCESS; struct recv_buf *precvbuf; tasklet_init(&precvpriv->recv_tasklet, rtl8188eu_recv_tasklet, @@ -69,9 +69,9 @@ exit: void rtw_hal_free_recv_priv(struct adapter *padapter) { - int i; - struct recv_buf *precvbuf; - struct recv_priv *precvpriv = &padapter->recvpriv; + int i; + struct recv_buf *precvbuf; + struct recv_priv *precvpriv = &padapter->recvpriv; precvbuf = precvpriv->precv_buf; -- cgit v1.2.3-58-ga151 From 12d9516944c9beacf82194069197bc286af6dc31 Mon Sep 17 00:00:00 2001 From: Anmol Karn Date: Thu, 23 Jul 2020 12:51:15 +0530 Subject: staging: vc04_services: vchiq-mmal: Fixed tab styling issue in mmal-vchiq.c This cahnge fixes a checkpatch error for "code indent should use tabs where possible". compile Tested only [Linux-next-20200722] Signed-off-by: Anmol Karn Link: https://lore.kernel.org/r/20200723072115.408070-1-anmol.karan123@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index dc767730db43..744ceb50f7bb 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -295,12 +295,12 @@ static void buffer_to_host_work_cb(struct work_struct *work) vchiq_use_service(instance->service_handle); ret = vchiq_bulk_receive(instance->service_handle, msg_context->u.bulk.buffer->buffer, - /* Actual receive needs to be a multiple - * of 4 bytes - */ - (len + 3) & ~3, - msg_context, - VCHIQ_BULK_MODE_CALLBACK); + /* Actual receive needs to be a multiple + * of 4 bytes + */ + (len + 3) & ~3, + msg_context, + VCHIQ_BULK_MODE_CALLBACK); vchiq_release_service(instance->service_handle); -- cgit v1.2.3-58-ga151 From 032ae2fd3ce12e8aa538165b44dc129c355a1ee1 Mon Sep 17 00:00:00 2001 From: Mrinal Pandey Date: Wed, 22 Jul 2020 20:49:00 +0530 Subject: staging: rtl8188eu: Fix an indent coding style issue Only a single tab space is required after the if statement. Fix this issue by running scripts/checkpatch.pl on the file. Signed-off-by: Mrinal Pandey Link: https://lore.kernel.org/r/20200722151900.5dcebtavkdi5cc77@mrinalpandey Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 656fe70ae4fb..0a4c1b2686b5 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -671,8 +671,8 @@ static int sta2sta_data_frame(struct adapter *adapter, if (mcast) { /* For AP mode, if DA == MCAST, then BSSID should be also MCAST */ if (!is_multicast_ether_addr(pattrib->bssid)) { - ret = _FAIL; - goto exit; + ret = _FAIL; + goto exit; } } else { /* not mc-frame */ /* For AP mode, if DA is non-MCAST, then it must be BSSID, and bssid == BSSID */ -- cgit v1.2.3-58-ga151 From 20a2d16d22f28d27a3312b66d7b276d96e0af271 Mon Sep 17 00:00:00 2001 From: Muhammad Usama Anjum Date: Thu, 23 Jul 2020 23:07:23 +0500 Subject: staging: octeon: Add the license identifier This patch fixes the checkpatch.pl warning: WARNING: Missing or malformed SPDX-License-Identifier tag Add a the SPDX-License-Identifier tag on line 1 Other files in this folder have GPL-2.0 license. So this file should have the same license which was missing before and checkpatch.pl was giving the warning. Signed-off-by: Muhammad Usama Anjum Link: https://lore.kernel.org/r/20200723180723.GA30699@musamaanjum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/octeon-stubs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon/octeon-stubs.h b/drivers/staging/octeon/octeon-stubs.h index d06743504f2b..3f8e5713b8a8 100644 --- a/drivers/staging/octeon/octeon-stubs.h +++ b/drivers/staging/octeon/octeon-stubs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #define CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE 512 #ifndef XKPHYS_TO_PHYS -- cgit v1.2.3-58-ga151 From fa74af6b128cc238bf851f0235d4ae5b42108a66 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 23 Jul 2020 16:54:15 +0100 Subject: staging: unisys: visorhba: remove redundant initialization of variables scsicmd_id and rc The variables scsicmd_id and rc is being initialized with a value that is never read and are being updated later with a new value. The initializations are redundant and can be removed. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20200723155415.994036-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorhba/visorhba_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 99c57ceeb357..7ae5306b92fe 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -305,7 +305,7 @@ static int forward_taskmgmt_command(enum task_mgmt_types tasktype, (struct visorhba_devdata *)scsidev->host->hostdata; int notifyresult = 0xffff; wait_queue_head_t notifyevent; - int scsicmd_id = 0; + int scsicmd_id; if (devdata->serverdown || devdata->serverchangingstate) return FAILED; @@ -1186,7 +1186,7 @@ static struct visor_driver visorhba_driver = { */ static int visorhba_init(void) { - int rc = -ENOMEM; + int rc; visorhba_debugfs_dir = debugfs_create_dir("visorhba", NULL); if (!visorhba_debugfs_dir) -- cgit v1.2.3-58-ga151 From d05c9a9eefd73d3cf4cccb69d859a7f260f8b64e Mon Sep 17 00:00:00 2001 From: Muhammad Usama Anjum Date: Thu, 23 Jul 2020 18:21:23 +0500 Subject: staging: octeon: Indent with tabs instead of spaces Remove a coding style error. It makes code more readable. Signed-off-by: Muhammad Usama Anjum Link: https://lore.kernel.org/r/20200723132123.GA26221@musamaanjum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-defines.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h index ef9e767b0e2e..c060374a3da2 100644 --- a/drivers/staging/octeon/ethernet-defines.h +++ b/drivers/staging/octeon/ethernet-defines.h @@ -22,19 +22,19 @@ #define __ETHERNET_DEFINES_H__ #ifdef CONFIG_NETFILTER -#define REUSE_SKBUFFS_WITHOUT_FREE 0 +#define REUSE_SKBUFFS_WITHOUT_FREE 0 #else -#define REUSE_SKBUFFS_WITHOUT_FREE 1 +#define REUSE_SKBUFFS_WITHOUT_FREE 1 #endif -#define USE_ASYNC_IOBDMA (CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0) +#define USE_ASYNC_IOBDMA (CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0) /* Maximum number of SKBs to try to free per xmit packet. */ -#define MAX_OUT_QUEUE_DEPTH 1000 +#define MAX_OUT_QUEUE_DEPTH 1000 #define FAU_TOTAL_TX_TO_CLEAN (CVMX_FAU_REG_END - sizeof(u32)) #define FAU_NUM_PACKET_BUFFERS_TO_FREE (FAU_TOTAL_TX_TO_CLEAN - sizeof(u32)) -#define TOTAL_NUMBER_OF_PORTS (CVMX_PIP_NUM_INPUT_PORTS + 1) +#define TOTAL_NUMBER_OF_PORTS (CVMX_PIP_NUM_INPUT_PORTS + 1) #endif /* __ETHERNET_DEFINES_H__ */ -- cgit v1.2.3-58-ga151 From b311b98d80a9b961cf7a699d03b69661275635e2 Mon Sep 17 00:00:00 2001 From: Fox Chen Date: Thu, 23 Jul 2020 17:30:02 +0800 Subject: staging: rtl8723bs: Cleanup open brace issues This cleans up open brace issues reported by checkpatch.pl Signed-off-by: Fox Chen Link: https://lore.kernel.org/r/20200723093002.6175-1-foxhlchen@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h | 6 +-- drivers/staging/rtl8723bs/include/HalVerDef.h | 18 +++----- drivers/staging/rtl8723bs/include/drv_types.h | 6 +-- drivers/staging/rtl8723bs/include/drv_types_sdio.h | 3 +- drivers/staging/rtl8723bs/include/hal_btcoex.h | 3 +- drivers/staging/rtl8723bs/include/hal_com.h | 3 +- drivers/staging/rtl8723bs/include/ieee80211.h | 3 +- drivers/staging/rtl8723bs/include/ioctl_cfg80211.h | 3 +- drivers/staging/rtl8723bs/include/rtl8192c_recv.h | 3 +- drivers/staging/rtl8723bs/include/rtl8723b_recv.h | 6 +-- drivers/staging/rtl8723bs/include/rtl8723b_xmit.h | 3 +- drivers/staging/rtl8723bs/include/rtw_cmd.h | 30 +++++-------- drivers/staging/rtl8723bs/include/rtw_eeprom.h | 6 +-- drivers/staging/rtl8723bs/include/rtw_event.h | 6 +-- drivers/staging/rtl8723bs/include/rtw_ht.h | 3 +- drivers/staging/rtl8723bs/include/rtw_mlme.h | 6 +-- drivers/staging/rtl8723bs/include/rtw_mlme_ext.h | 51 ++++++++-------------- drivers/staging/rtl8723bs/include/rtw_mp.h | 15 +++---- drivers/staging/rtl8723bs/include/rtw_pwrctrl.h | 12 ++--- drivers/staging/rtl8723bs/include/rtw_recv.h | 12 ++--- drivers/staging/rtl8723bs/include/rtw_security.h | 9 ++-- drivers/staging/rtl8723bs/include/rtw_xmit.h | 12 ++--- drivers/staging/rtl8723bs/include/wifi.h | 24 ++++------ drivers/staging/rtl8723bs/include/wlan_bssdef.h | 9 ++-- 24 files changed, 84 insertions(+), 168 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h b/drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h index 7040cfc507d8..459f2f9d4bbb 100644 --- a/drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h +++ b/drivers/staging/rtl8723bs/include/HalPwrSeqCmd.h @@ -82,14 +82,12 @@ #define PWR_CUT_ALL_MSK 0xFF -typedef enum _PWRSEQ_CMD_DELAY_UNIT_ -{ +typedef enum _PWRSEQ_CMD_DELAY_UNIT_ { PWRSEQ_DELAY_US, PWRSEQ_DELAY_MS, } PWRSEQ_DELAY_UNIT; -typedef struct _WL_PWR_CFG_ -{ +typedef struct _WL_PWR_CFG_ { u16 offset; u8 cut_msk; u8 fab_msk:4; diff --git a/drivers/staging/rtl8723bs/include/HalVerDef.h b/drivers/staging/rtl8723bs/include/HalVerDef.h index c548fb126683..b4744be2cbe1 100644 --- a/drivers/staging/rtl8723bs/include/HalVerDef.h +++ b/drivers/staging/rtl8723bs/include/HalVerDef.h @@ -8,8 +8,7 @@ #define __HAL_VERSION_DEF_H__ /* HAL_IC_TYPE_E */ -typedef enum tag_HAL_IC_Type_Definition -{ +typedef enum tag_HAL_IC_Type_Definition { CHIP_8192S = 0, CHIP_8188C = 1, CHIP_8192C = 2, @@ -23,16 +22,14 @@ typedef enum tag_HAL_IC_Type_Definition } HAL_IC_TYPE_E; /* HAL_CHIP_TYPE_E */ -typedef enum tag_HAL_CHIP_Type_Definition -{ +typedef enum tag_HAL_CHIP_Type_Definition { TEST_CHIP = 0, NORMAL_CHIP = 1, FPGA = 2, } HAL_CHIP_TYPE_E; /* HAL_CUT_VERSION_E */ -typedef enum tag_HAL_Cut_Version_Definition -{ +typedef enum tag_HAL_Cut_Version_Definition { A_CUT_VERSION = 0, B_CUT_VERSION = 1, C_CUT_VERSION = 2, @@ -47,15 +44,13 @@ typedef enum tag_HAL_Cut_Version_Definition } HAL_CUT_VERSION_E; /* HAL_Manufacturer */ -typedef enum tag_HAL_Manufacturer_Version_Definition -{ +typedef enum tag_HAL_Manufacturer_Version_Definition { CHIP_VENDOR_TSMC = 0, CHIP_VENDOR_UMC = 1, CHIP_VENDOR_SMIC = 2, } HAL_VENDOR_E; -typedef enum tag_HAL_RF_Type_Definition -{ +typedef enum tag_HAL_RF_Type_Definition { RF_TYPE_1T1R = 0, RF_TYPE_1T2R = 1, RF_TYPE_2T2R = 2, @@ -66,8 +61,7 @@ typedef enum tag_HAL_RF_Type_Definition RF_TYPE_4T4R = 7, } HAL_RF_TYPE_E; -typedef struct tag_HAL_VERSION -{ +typedef struct tag_HAL_VERSION { HAL_IC_TYPE_E ICType; HAL_CHIP_TYPE_E ChipType; HAL_CUT_VERSION_E CUTVersion; diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h index dba75216cbfe..c73f581aea06 100644 --- a/drivers/staging/rtl8723bs/include/drv_types.h +++ b/drivers/staging/rtl8723bs/include/drv_types.h @@ -86,8 +86,7 @@ struct specific_device_id { }; -struct registry_priv -{ +struct registry_priv { u8 chip_version; u8 rfintfs; u8 lbkmode; @@ -418,8 +417,7 @@ struct cam_entry_cache { ((u8 *)(x))[6], ((u8 *)(x))[7], ((u8 *)(x))[8], ((u8 *)(x))[9], ((u8 *)(x))[10], ((u8 *)(x))[11], \ ((u8 *)(x))[12], ((u8 *)(x))[13], ((u8 *)(x))[14], ((u8 *)(x))[15] -struct dvobj_priv -{ +struct dvobj_priv { /*-------- below is common data --------*/ struct adapter *if1; /* PRIMARY_ADAPTER */ struct adapter *if2; /* SECONDARY_ADAPTER */ diff --git a/drivers/staging/rtl8723bs/include/drv_types_sdio.h b/drivers/staging/rtl8723bs/include/drv_types_sdio.h index 09263ad27ce9..5e079838f59c 100644 --- a/drivers/staging/rtl8723bs/include/drv_types_sdio.h +++ b/drivers/staging/rtl8723bs/include/drv_types_sdio.h @@ -16,8 +16,7 @@ #include #endif -struct sdio_data -{ +struct sdio_data { u8 func_number; u8 tx_block_mode; diff --git a/drivers/staging/rtl8723bs/include/hal_btcoex.h b/drivers/staging/rtl8723bs/include/hal_btcoex.h index eb03813fdcb9..29318b49c3ff 100644 --- a/drivers/staging/rtl8723bs/include/hal_btcoex.h +++ b/drivers/staging/rtl8723bs/include/hal_btcoex.h @@ -11,8 +11,7 @@ /* Some variables can't get from outsrc BT-Coex, */ /* so we need to save here */ -typedef struct _BT_COEXIST -{ +typedef struct _BT_COEXIST { u8 bBtExist; u8 btTotalAntNum; u8 btChipType; diff --git a/drivers/staging/rtl8723bs/include/hal_com.h b/drivers/staging/rtl8723bs/include/hal_com.h index a46626d0509a..fe7e2efce0e3 100644 --- a/drivers/staging/rtl8723bs/include/hal_com.h +++ b/drivers/staging/rtl8723bs/include/hal_com.h @@ -288,8 +288,7 @@ void SetHalODMVar( bool bSet); #ifdef CONFIG_BACKGROUND_NOISE_MONITOR -struct noise_info -{ +struct noise_info { u8 bPauseDIG; u8 IGIValue; u32 max_time;/* ms */ diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 7243e656d589..b7c4b1cf204e 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -152,8 +152,7 @@ typedef enum _RATR_TABLE_MODE { } RATR_TABLE_MODE, *PRATR_TABLE_MODE; -enum NETWORK_TYPE -{ +enum NETWORK_TYPE { WIRELESS_INVALID = 0, /* Sub-Element */ WIRELESS_11B = BIT(0), /* tx: cck only , rx: cck only, hw: cck */ diff --git a/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h b/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h index 931599d8b08a..44d0a0982659 100644 --- a/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h +++ b/drivers/staging/rtl8723bs/include/ioctl_cfg80211.h @@ -61,8 +61,7 @@ struct rtw_wdev_nego_info { (nego_info)->conf_op_ch = 0; \ } while (0) -struct rtw_wdev_priv -{ +struct rtw_wdev_priv { struct wireless_dev *rtw_wdev; struct adapter *padapter; diff --git a/drivers/staging/rtl8723bs/include/rtl8192c_recv.h b/drivers/staging/rtl8723bs/include/rtl8192c_recv.h index c77d172de7d0..9664758e21be 100644 --- a/drivers/staging/rtl8723bs/include/rtl8192c_recv.h +++ b/drivers/staging/rtl8723bs/include/rtl8192c_recv.h @@ -13,8 +13,7 @@ #define MAX_RECVBUF_SZ (10240) -struct phy_stat -{ +struct phy_stat { unsigned int phydw0; unsigned int phydw1; diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_recv.h b/drivers/staging/rtl8723bs/include/rtl8723b_recv.h index 31ae83f2557f..fad6749af768 100644 --- a/drivers/staging/rtl8723bs/include/rtl8723b_recv.h +++ b/drivers/staging/rtl8723bs/include/rtl8723b_recv.h @@ -9,8 +9,7 @@ #include -typedef struct rxreport_8723b -{ +typedef struct rxreport_8723b { /* DWORD 0 */ u32 pktlen:14; u32 crc32:1; @@ -82,8 +81,7 @@ typedef struct rxreport_8723b u32 tsfl; } RXREPORT, *PRXREPORT; -typedef struct phystatus_8723b -{ +typedef struct phystatus_8723b { u32 rxgain_a:7; u32 trsw_a:1; u32 rxgain_b:7; diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h b/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h index 320ca65e5faa..243d36d9bc7b 100644 --- a/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h +++ b/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h @@ -59,8 +59,7 @@ /* */ /* defined for TX DESC Operation */ /* */ -typedef struct txdesc_8723b -{ +typedef struct txdesc_8723b { /* Offset 0 */ u32 pktlen:16; u32 offset:8; diff --git a/drivers/staging/rtl8723bs/include/rtw_cmd.h b/drivers/staging/rtl8723bs/include/rtw_cmd.h index 3e025a652e38..56c77bc7ca81 100644 --- a/drivers/staging/rtl8723bs/include/rtw_cmd.h +++ b/drivers/staging/rtl8723bs/include/rtw_cmd.h @@ -134,8 +134,7 @@ extern void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv); extern void rtw_free_evt_priv(struct evt_priv *pevtpriv); extern void rtw_evt_notify_isr(struct evt_priv *pevtpriv); -enum rtw_drvextra_cmd_id -{ +enum rtw_drvextra_cmd_id { NONE_WK_CID, DYNAMIC_CHK_WK_CID, DM_CTRL_WK_CID, @@ -159,8 +158,7 @@ enum rtw_drvextra_cmd_id MAX_WK_CID }; -enum LPS_CTRL_TYPE -{ +enum LPS_CTRL_TYPE { LPS_CTRL_SCAN = 0, LPS_CTRL_JOINBSS = 1, LPS_CTRL_CONNECT = 2, @@ -530,8 +528,7 @@ struct getrfintfs_parm { }; -struct Tx_Beacon_param -{ +struct Tx_Beacon_param { struct wlan_bssid_ex network; }; @@ -754,8 +751,7 @@ struct setassocrspextraie_parm { }; -struct addBaReq_parm -{ +struct addBaReq_parm { unsigned int tid; u8 addr[ETH_ALEN]; }; @@ -768,33 +764,28 @@ struct set_ch_parm { }; /*H2C Handler index: 59 */ -struct SetChannelPlan_param -{ +struct SetChannelPlan_param { u8 channel_plan; }; /*H2C Handler index: 60 */ -struct LedBlink_param -{ +struct LedBlink_param { void *pLed; }; /*H2C Handler index: 61 */ -struct SetChannelSwitch_param -{ +struct SetChannelSwitch_param { u8 new_ch_no; }; /*H2C Handler index: 62 */ -struct TDLSoption_param -{ +struct TDLSoption_param { u8 addr[ETH_ALEN]; u8 option; }; /*H2C Handler index: 64 */ -struct RunInThread_param -{ +struct RunInThread_param { void (*func)(void*); void *context; }; @@ -881,8 +872,7 @@ struct _cmd_callback { void (*callback)(struct adapter *padapter, struct cmd_obj *cmd); }; -enum rtw_h2c_cmd -{ +enum rtw_h2c_cmd { GEN_CMD_CODE(_Read_MACREG), /*0*/ GEN_CMD_CODE(_Write_MACREG), GEN_CMD_CODE(_Read_BBREG), diff --git a/drivers/staging/rtl8723bs/include/rtw_eeprom.h b/drivers/staging/rtl8723bs/include/rtw_eeprom.h index 704c6461333a..78f34f6cebb4 100644 --- a/drivers/staging/rtl8723bs/include/rtw_eeprom.h +++ b/drivers/staging/rtl8723bs/include/rtw_eeprom.h @@ -42,8 +42,7 @@ /* Besides, CustomerID of registry has precedence of that of EEPROM. */ /* defined below. 060703, by rcnjko. */ /* */ -typedef enum _RT_CUSTOMER_ID -{ +typedef enum _RT_CUSTOMER_ID { RT_CID_DEFAULT = 0, RT_CID_8187_ALPHA0 = 1, RT_CID_8187_SERCOMM_PS = 2, @@ -93,8 +92,7 @@ typedef enum _RT_CUSTOMER_ID RT_CID_DNI_BUFFALO = 46,/* add by page for NEC */ } RT_CUSTOMER_ID, *PRT_CUSTOMER_ID; -struct eeprom_priv -{ +struct eeprom_priv { u8 bautoload_fail_flag; u8 bloadfile_fail_flag; u8 bloadmac_fail_flag; diff --git a/drivers/staging/rtl8723bs/include/rtw_event.h b/drivers/staging/rtl8723bs/include/rtw_event.h index aeaabab780e5..560521c80ace 100644 --- a/drivers/staging/rtl8723bs/include/rtw_event.h +++ b/drivers/staging/rtl8723bs/include/rtw_event.h @@ -60,13 +60,11 @@ struct stadel_event { int mac_id; }; -struct addba_event -{ +struct addba_event { unsigned int tid; }; -struct wmm_event -{ +struct wmm_event { unsigned char wmm; }; diff --git a/drivers/staging/rtl8723bs/include/rtw_ht.h b/drivers/staging/rtl8723bs/include/rtw_ht.h index 4c224c128327..13489913f40b 100644 --- a/drivers/staging/rtl8723bs/include/rtw_ht.h +++ b/drivers/staging/rtl8723bs/include/rtw_ht.h @@ -8,8 +8,7 @@ #define _RTW_HT_H_ -struct ht_priv -{ +struct ht_priv { u8 ht_option; u8 ampdu_enable;/* for enable Tx A-MPDU */ u8 tx_amsdu_enable;/* for enable Tx A-MSDU */ diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme.h b/drivers/staging/rtl8723bs/include/rtw_mlme.h index 14e4bce28856..cd98efccb321 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme.h @@ -101,8 +101,7 @@ enum DriverInterface { DRIVER_CFG80211 = 2 }; -enum SCAN_RESULT_TYPE -{ +enum SCAN_RESULT_TYPE { SCAN_RESULT_P2P_ONLY = 0, /* Will return all the P2P devices. */ SCAN_RESULT_ALL = 1, /* Will return all the scanned device, include AP. */ SCAN_RESULT_WFD_TYPE = 2 /* Will just return the correct WFD device. */ @@ -463,8 +462,7 @@ struct mlme_priv { void rtw_mlme_reset_auto_scan_int(struct adapter *adapter); -struct hostapd_priv -{ +struct hostapd_priv { struct adapter *padapter; }; diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h index 6c1ed6211c7e..14583799039f 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h @@ -115,8 +115,7 @@ extern unsigned char WMM_PARA_OUI[]; /* If you just wnat to customize the acitions(scan period or join actions) about one of the channel plan, */ /* customize them in RT_CHANNEL_INFO in the RT_CHANNEL_LIST. */ /* */ -typedef enum _RT_CHANNEL_DOMAIN -{ +typedef enum _RT_CHANNEL_DOMAIN { /* old channel plan mapping ===== */ RT_CHANNEL_DOMAIN_FCC = 0x00, RT_CHANNEL_DOMAIN_IC = 0x01, @@ -184,8 +183,7 @@ typedef enum _RT_CHANNEL_DOMAIN RT_CHANNEL_DOMAIN_REALTEK_DEFINE = 0x7F, } RT_CHANNEL_DOMAIN, *PRT_CHANNEL_DOMAIN; -typedef enum _RT_CHANNEL_DOMAIN_2G -{ +typedef enum _RT_CHANNEL_DOMAIN_2G { RT_CHANNEL_DOMAIN_2G_WORLD = 0x00, /* Worldwird 13 */ RT_CHANNEL_DOMAIN_2G_ETSI1 = 0x01, /* Europe */ RT_CHANNEL_DOMAIN_2G_FCC1 = 0x02, /* US */ @@ -197,8 +195,7 @@ typedef enum _RT_CHANNEL_DOMAIN_2G RT_CHANNEL_DOMAIN_2G_MAX, } RT_CHANNEL_DOMAIN_2G, *PRT_CHANNEL_DOMAIN_2G; -typedef enum _RT_CHANNEL_DOMAIN_5G -{ +typedef enum _RT_CHANNEL_DOMAIN_5G { RT_CHANNEL_DOMAIN_5G_NULL = 0x00, RT_CHANNEL_DOMAIN_5G_ETSI1 = 0x01, /* Europe */ RT_CHANNEL_DOMAIN_5G_ETSI2 = 0x02, /* Australia, New Zealand */ @@ -241,32 +238,27 @@ typedef enum _RT_CHANNEL_DOMAIN_5G #define rtw_is_channel_plan_valid(chplan) (chplan < RT_CHANNEL_DOMAIN_MAX || chplan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE) -typedef struct _RT_CHANNEL_PLAN -{ +typedef struct _RT_CHANNEL_PLAN { unsigned char Channel[MAX_CHANNEL_NUM]; unsigned char Len; } RT_CHANNEL_PLAN, *PRT_CHANNEL_PLAN; -typedef struct _RT_CHANNEL_PLAN_2G -{ +typedef struct _RT_CHANNEL_PLAN_2G { unsigned char Channel[MAX_CHANNEL_NUM_2G]; unsigned char Len; } RT_CHANNEL_PLAN_2G, *PRT_CHANNEL_PLAN_2G; -typedef struct _RT_CHANNEL_PLAN_5G -{ +typedef struct _RT_CHANNEL_PLAN_5G { unsigned char Channel[MAX_CHANNEL_NUM_5G]; unsigned char Len; } RT_CHANNEL_PLAN_5G, *PRT_CHANNEL_PLAN_5G; -typedef struct _RT_CHANNEL_PLAN_MAP -{ +typedef struct _RT_CHANNEL_PLAN_MAP { unsigned char Index2G; unsigned char Index5G; } RT_CHANNEL_PLAN_MAP, *PRT_CHANNEL_PLAN_MAP; -enum Associated_AP -{ +enum Associated_AP { atherosAP = 0, broadcomAP = 1, ciscoAP = 2, @@ -278,8 +270,7 @@ enum Associated_AP maxAP, }; -typedef enum _HT_IOT_PEER -{ +typedef enum _HT_IOT_PEER { HT_IOT_PEER_UNKNOWN = 0, HT_IOT_PEER_REALTEK = 1, HT_IOT_PEER_REALTEK_92SE = 2, @@ -302,8 +293,7 @@ typedef enum _HT_IOT_PEER } HT_IOT_PEER_E, *PHTIOT_PEER_E; -enum SCAN_STATE -{ +enum SCAN_STATE { SCAN_DISABLE = 0, SCAN_START = 1, SCAN_TXNULL = 2, @@ -324,8 +314,7 @@ struct action_handler { unsigned int (*func)(struct adapter *padapter, union recv_frame *precv_frame); }; -struct ss_res -{ +struct ss_res { int state; int bss_cnt; int channel_idx; @@ -355,8 +344,7 @@ struct ss_res #define WIFI_FW_LINKING_STATE (WIFI_FW_AUTH_NULL | WIFI_FW_AUTH_STATE | WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE) -struct FW_Sta_Info -{ +struct FW_Sta_Info { struct sta_info *psta; u32 status; u32 rx_pkt; @@ -382,8 +370,7 @@ struct FW_Sta_Info * 4. Back to channel 1 for 300 milliseconds * 5. ... and so on, till survey done. */ -struct mlme_ext_info -{ +struct mlme_ext_info { u32 state; u32 reauth_count; u32 reassoc_count; @@ -430,8 +417,7 @@ struct mlme_ext_info }; /* The channel information about this channel including joining, scanning, and power constraints. */ -typedef struct _RT_CHANNEL_INFO -{ +typedef struct _RT_CHANNEL_INFO { u8 ChannelNum; /* The channel number. */ RT_SCAN_TYPE ScanType; /* Scan type such as passive or active scan. */ } RT_CHANNEL_INFO, *PRT_CHANNEL_INFO; @@ -472,8 +458,7 @@ struct p2p_oper_class_map { enum { BW20, BW40PLUS, BW40MINUS } bw; }; -struct mlme_ext_priv -{ +struct mlme_ext_priv { struct adapter *padapter; u8 mlmeext_init; atomic_t event_seq; @@ -786,8 +771,7 @@ u8 run_in_thread_hdl(struct adapter *padapter, u8 *pbuf); #define GEN_DRV_CMD_HANDLER(size, cmd) {size, &cmd ## _hdl}, #define GEN_MLME_EXT_HANDLER(size, cmd) {size, cmd}, -struct C2HEvent_Header -{ +struct C2HEvent_Header { #ifdef __LITTLE_ENDIAN @@ -805,8 +789,7 @@ struct C2HEvent_Header void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf); void rtw_fwdbg_event_callback(struct adapter *adapter, u8 *pbuf); -enum rtw_c2h_event -{ +enum rtw_c2h_event { GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/ GEN_EVT_CODE(_Read_BBREG), GEN_EVT_CODE(_Read_RFREG), diff --git a/drivers/staging/rtl8723bs/include/rtw_mp.h b/drivers/staging/rtl8723bs/include/rtw_mp.h index e5a801b40582..4d156eab029c 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mp.h +++ b/drivers/staging/rtl8723bs/include/rtw_mp.h @@ -10,8 +10,7 @@ #define MAX_MP_XMITBUF_SZ 2048 #define NR_MP_XMITFRAME 8 -struct mp_xmit_frame -{ +struct mp_xmit_frame { struct list_head list; struct pkt_attrib attrib; @@ -25,8 +24,7 @@ struct mp_xmit_frame uint mem[(MAX_MP_XMITBUF_SZ >> 2)]; }; -struct mp_wiparam -{ +struct mp_wiparam { u32 bcompleted; u32 act_type; u32 io_offset; @@ -35,8 +33,7 @@ struct mp_wiparam typedef void(*wi_act_func)(void* padapter); -struct mp_tx -{ +struct mp_tx { u8 stop; u32 count, sended; u8 payload; @@ -54,8 +51,7 @@ struct mp_tx #define MP_MAX_LINES_BYTES 256 typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter); -typedef struct _MPT_CONTEXT -{ +typedef struct _MPT_CONTEXT { /* Indicate if we have started Mass Production Test. */ bool bMassProdTest; @@ -205,8 +201,7 @@ enum { MP_GET_TXPOWER_INX, }; -struct mp_priv -{ +struct mp_priv { struct adapter *papdater; /* Testing Flag */ diff --git a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h index 2bc922ce5ae1..3d999540e239 100644 --- a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h @@ -159,8 +159,7 @@ enum PS_DENY_REASON { }; #ifdef CONFIG_PNO_SUPPORT -struct pno_nlo_info -{ +struct pno_nlo_info { u32 fast_scan_period; /* Fast scan period */ u32 ssid_num; /* number of entry */ u32 slow_scan_period; /* slow scan period */ @@ -179,16 +178,14 @@ struct pno_ssid_list { struct pno_ssid node[MAX_PNO_LIST_COUNT]; }; -struct pno_scan_channel_info -{ +struct pno_scan_channel_info { u8 channel; u8 tx_power; u8 timeout; u8 active; /* set 1 means active scan, or pasivite scan. */ }; -struct pno_scan_info -{ +struct pno_scan_info { u8 enableRFE; /* Enable RFE */ u8 period_scan_time; /* exclusive with fast_scan_period and slow_scan_period */ u8 periodScan; /* exclusive with fast_scan_period and slow_scan_period */ @@ -202,8 +199,7 @@ struct pno_scan_info }; #endif /* CONFIG_PNO_SUPPORT */ -struct pwrctrl_priv -{ +struct pwrctrl_priv { struct mutex lock; volatile u8 rpwm; /* requested power state for fw */ volatile u8 cpwm; /* fw current power state. updated when 1. read from HCPWM 2. driver lowers power level */ diff --git a/drivers/staging/rtl8723bs/include/rtw_recv.h b/drivers/staging/rtl8723bs/include/rtw_recv.h index a851b818ef0e..60bf00f35cae 100644 --- a/drivers/staging/rtl8723bs/include/rtw_recv.h +++ b/drivers/staging/rtl8723bs/include/rtw_recv.h @@ -40,8 +40,7 @@ #define MAX_SUBFRAME_COUNT 64 /* for Rx reordering buffer control */ -struct recv_reorder_ctrl -{ +struct recv_reorder_ctrl { struct adapter *padapter; u8 enable; u16 indicate_seq;/* wstart_b, init_value = 0xffff */ @@ -112,8 +111,7 @@ struct phy_info { }; #ifdef DBG_RX_SIGNAL_DISPLAY_RAW_DATA -struct rx_raw_rssi -{ +struct rx_raw_rssi { u8 data_rate; u8 pwdball; s8 pwr_all; @@ -292,8 +290,7 @@ struct sta_recv_priv { }; -struct recv_buf -{ +struct recv_buf { struct list_head list; _lock recvbuf_lock; @@ -331,8 +328,7 @@ struct recv_buf len = (unsigned int)(tail - data); */ -struct recv_frame_hdr -{ +struct recv_frame_hdr { struct list_head list; #ifndef CONFIG_BSD_RX_USE_MBUF struct sk_buff *pkt; diff --git a/drivers/staging/rtl8723bs/include/rtw_security.h b/drivers/staging/rtl8723bs/include/rtw_security.h index aa60b6f867dd..514c0799c34b 100644 --- a/drivers/staging/rtl8723bs/include/rtw_security.h +++ b/drivers/staging/rtl8723bs/include/rtw_security.h @@ -87,8 +87,7 @@ union Keytype { }; -typedef struct _RT_PMKID_LIST -{ +typedef struct _RT_PMKID_LIST { u8 bUsed; u8 Bssid[6]; u8 PMKID[16]; @@ -98,8 +97,7 @@ typedef struct _RT_PMKID_LIST } RT_PMKID_LIST, *PRT_PMKID_LIST; -struct security_priv -{ +struct security_priv { u32 dot11AuthAlgrthm; /* 802.11 auth, could be open, shared, 8021x and authswitch */ u32 dot11PrivacyAlgrthm; /* This specify the privacy for shared auth. algorithm. */ @@ -273,8 +271,7 @@ do {\ #define ROL32(A, n) (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1))) #define ROR32(A, n) ROL32((A), 32-(n)) -struct mic_data -{ +struct mic_data { u32 K0, K1; /* Key */ u32 L, R; /* Current state */ u32 M; /* Message accumulator (single word) */ diff --git a/drivers/staging/rtl8723bs/include/rtw_xmit.h b/drivers/staging/rtl8723bs/include/rtw_xmit.h index cd2be0056aa1..196e70865c00 100644 --- a/drivers/staging/rtl8723bs/include/rtw_xmit.h +++ b/drivers/staging/rtl8723bs/include/rtw_xmit.h @@ -137,8 +137,7 @@ struct hw_xmit { }; /* reduce size */ -struct pkt_attrib -{ +struct pkt_attrib { u8 type; u8 subtype; u8 bswenc; @@ -246,8 +245,7 @@ int rtw_sctx_wait(struct submit_ctx *sctx, const char *msg); void rtw_sctx_done_err(struct submit_ctx **sctx, int status); void rtw_sctx_done(struct submit_ctx **sctx); -struct xmit_buf -{ +struct xmit_buf { struct list_head list; struct adapter *padapter; @@ -281,8 +279,7 @@ struct xmit_buf }; -struct xmit_frame -{ +struct xmit_frame { struct list_head list; struct pkt_attrib attrib; @@ -314,8 +311,7 @@ struct tx_servq { }; -struct sta_xmit_priv -{ +struct sta_xmit_priv { _lock lock; sint option; sint apsd_setting; /* When bit mask is on, the associated edca queue supports APSD. */ diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index f75df547a946..3a7dd2ed26a8 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -688,12 +688,9 @@ struct ieee80211_ht_addt_info { } __attribute__ ((packed)); -struct HT_caps_element -{ - union - { - struct - { +struct HT_caps_element { + union { + struct { __le16 HT_caps_info; unsigned char AMPDU_para; unsigned char MCS_rate[16]; @@ -705,29 +702,25 @@ struct HT_caps_element } u; } __attribute__ ((packed)); -struct HT_info_element -{ +struct HT_info_element { unsigned char primary_channel; unsigned char infos[5]; unsigned char MCS_rate[16]; } __attribute__ ((packed)); -struct AC_param -{ +struct AC_param { unsigned char ACI_AIFSN; unsigned char CW; __le16 TXOP_limit; } __attribute__ ((packed)); -struct WMM_para_element -{ +struct WMM_para_element { unsigned char QoS_info; unsigned char reserved; struct AC_param ac_param[4]; } __attribute__ ((packed)); -struct ADDBA_request -{ +struct ADDBA_request { unsigned char dialog_token; __le16 BA_para_set; __le16 BA_timeout_value; @@ -1090,8 +1083,7 @@ enum P2P_WPSINFO { #define P2P_PRIVATE_IOCTL_SET_LEN 64 -enum P2P_PROTO_WK_ID -{ +enum P2P_PROTO_WK_ID { P2P_FIND_PHASE_WK = 0, P2P_RESTORE_STATE_WK = 1, P2P_PRE_TX_PROVDISC_PROCESS_WK = 2, diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h index 723fc5b546ef..ea370b2bb8db 100644 --- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h @@ -127,8 +127,7 @@ struct ndis_801_11_ai_resfi { u16 AssociationId; }; -typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION -{ +typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION { u32 Length; u16 AvailableRequestFixedIEs; struct ndis_802_11_ai_reqfi RequestFixedIEs; @@ -146,8 +145,7 @@ enum NDIS_802_11_RELOAD_DEFAULTS { /* Key mapping keys require a BSSID */ -typedef struct _NDIS_802_11_KEY -{ +typedef struct _NDIS_802_11_KEY { u32 Length; /* Length of this structure */ u32 KeyIndex; u32 KeyLength; /* length of key in bytes */ @@ -156,8 +154,7 @@ typedef struct _NDIS_802_11_KEY u8 KeyMaterial[32]; /* variable length depending on above field */ } NDIS_802_11_KEY, *PNDIS_802_11_KEY; -typedef struct _NDIS_802_11_REMOVE_KEY -{ +typedef struct _NDIS_802_11_REMOVE_KEY { u32 Length; /* Length of this structure */ u32 KeyIndex; NDIS_802_11_MAC_ADDRESS BSSID; -- cgit v1.2.3-58-ga151 From b5dbbadb0eb93aaca51d5effeed96b94af150e07 Mon Sep 17 00:00:00 2001 From: Priti Chattopadhyay Date: Thu, 23 Jul 2020 14:51:55 +0530 Subject: Staging: rtl8188eu: Fix a constant comparison coding style issue Modify equality comparison involving constants by shifting the constant operand to the right side of the comparison as suggested by scripts/checkpatch.pl Signed-off-by: Priti Chattopadhyay Link: https://lore.kernel.org/r/20200723092150.y34bentngeeci2oc@pritichattopadhyay Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 6df873e4c2ed..be843fd2461a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -967,7 +967,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) pbuf = rtw_get_wpa_ie(&bssid->ies[12], &wpa_ielen, bssid->ie_length - 12); if (pbuf && (wpa_ielen > 0)) { - if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is_8021x)) { + if (rtw_parse_wpa_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is_8021x) == _SUCCESS) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s pnetwork->pairwise_cipher: %d, group_cipher is %d, is_8021x is %d\n", __func__, pairwise_cipher, group_cipher, is_8021x)); @@ -977,7 +977,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) bssid->ie_length - 12); if (pbuf && (wpa_ielen > 0)) { - if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is_8021x)) { + if (rtw_parse_wpa2_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is_8021x) == _SUCCESS) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n", __func__, pairwise_cipher, group_cipher, is_8021x)); -- cgit v1.2.3-58-ga151 From d8cc6b5664b40b10bd2896f0bbbfe451a02c8457 Mon Sep 17 00:00:00 2001 From: Anant Thazhemadam Date: Sat, 25 Jul 2020 17:50:38 +0530 Subject: STAGING - REALTEK RTL8188EU DRIVERS: Fix Coding Style Error Running the checkpatch.pl script on the file for which patch was created, the following error was found to exist. ERROR: space required after that ',' (ctx:VxV) Fixed the above error which was found on line #721 by inserting a blank space at the appropriate position. Signed-off-by: Anant Thazhemadam Link: https://lore.kernel.org/r/20200725122041.5663-1-anant.thazhemadam@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index 21f6652dd69f..57e171d3e48d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -718,7 +718,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) res = _FAIL; } } else { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo==NULL!!!\n",__func__)); + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo==NULL!!!\n", __func__)); res = _FAIL; } } -- cgit v1.2.3-58-ga151 From 13d8b1f3c032462cdda0906978f9fb74ae41f80a Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 23 Jul 2020 21:40:53 +0200 Subject: staging: comedi: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200723194053.72227-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 2 +- drivers/staging/comedi/comedi_pci.c | 2 +- drivers/staging/comedi/comedi_pcmcia.c | 2 +- drivers/staging/comedi/comedi_usb.c | 2 +- drivers/staging/comedi/drivers/8255.c | 2 +- drivers/staging/comedi/drivers/8255_pci.c | 2 +- drivers/staging/comedi/drivers/adq12b.c | 2 +- drivers/staging/comedi/drivers/aio_aio12_8.c | 2 +- drivers/staging/comedi/drivers/aio_iiro_16.c | 2 +- drivers/staging/comedi/drivers/c6xdigio.c | 2 +- drivers/staging/comedi/drivers/comedi_8255.c | 2 +- drivers/staging/comedi/drivers/comedi_parport.c | 2 +- drivers/staging/comedi/drivers/comedi_test.c | 2 +- drivers/staging/comedi/drivers/contec_pci_dio.c | 2 +- drivers/staging/comedi/drivers/daqboard2000.c | 4 ++-- drivers/staging/comedi/drivers/dmm32at.c | 2 +- drivers/staging/comedi/drivers/fl512.c | 2 +- drivers/staging/comedi/drivers/gsc_hpdi.c | 2 +- drivers/staging/comedi/drivers/icp_multi.c | 2 +- drivers/staging/comedi/drivers/ii_pci20kc.c | 2 +- drivers/staging/comedi/drivers/jr3_pci.c | 4 ++-- drivers/staging/comedi/drivers/ke_counter.c | 2 +- drivers/staging/comedi/drivers/me4000.c | 4 ++-- drivers/staging/comedi/drivers/me_daq.c | 2 +- drivers/staging/comedi/drivers/mite.c | 2 +- drivers/staging/comedi/drivers/mpc624.c | 2 +- drivers/staging/comedi/drivers/multiq3.c | 2 +- drivers/staging/comedi/drivers/plx9052.h | 2 +- drivers/staging/comedi/drivers/quatech_daqp_cs.c | 2 +- drivers/staging/comedi/drivers/rtd520.c | 2 +- drivers/staging/comedi/drivers/rti800.c | 2 +- drivers/staging/comedi/drivers/rti802.c | 2 +- drivers/staging/comedi/drivers/s526.c | 2 +- drivers/staging/comedi/drivers/ssv_dnp.c | 2 +- drivers/staging/comedi/drivers/tests/ni_routes_test.c | 2 +- 35 files changed, 38 insertions(+), 38 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 9cdc1e8a022d..d99231c737fb 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -3429,6 +3429,6 @@ static void __exit comedi_cleanup(void) } module_exit(comedi_cleanup); -MODULE_AUTHOR("http://www.comedi.org"); +MODULE_AUTHOR("https://www.comedi.org"); MODULE_DESCRIPTION("Comedi core module"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/comedi_pci.c b/drivers/staging/comedi/comedi_pci.c index 126048b03f43..54739af7eb71 100644 --- a/drivers/staging/comedi/comedi_pci.c +++ b/drivers/staging/comedi/comedi_pci.c @@ -223,6 +223,6 @@ static void __exit comedi_pci_exit(void) } module_exit(comedi_pci_exit); -MODULE_AUTHOR("http://www.comedi.org"); +MODULE_AUTHOR("https://www.comedi.org"); MODULE_DESCRIPTION("Comedi PCI interface module"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/comedi_pcmcia.c b/drivers/staging/comedi/comedi_pcmcia.c index e16f35eae343..bb273bb202e6 100644 --- a/drivers/staging/comedi/comedi_pcmcia.c +++ b/drivers/staging/comedi/comedi_pcmcia.c @@ -204,6 +204,6 @@ static void __exit comedi_pcmcia_exit(void) } module_exit(comedi_pcmcia_exit); -MODULE_AUTHOR("http://www.comedi.org"); +MODULE_AUTHOR("https://www.comedi.org"); MODULE_DESCRIPTION("Comedi PCMCIA interface module"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/comedi_usb.c b/drivers/staging/comedi/comedi_usb.c index c632c2bae722..eea8ebf32ed0 100644 --- a/drivers/staging/comedi/comedi_usb.c +++ b/drivers/staging/comedi/comedi_usb.c @@ -146,6 +146,6 @@ static void __exit comedi_usb_exit(void) } module_exit(comedi_usb_exit); -MODULE_AUTHOR("http://www.comedi.org"); +MODULE_AUTHOR("https://www.comedi.org"); MODULE_DESCRIPTION("Comedi USB interface module"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index 3d6105b5a11b..e23335c75867 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -120,6 +120,6 @@ static struct comedi_driver dev_8255_driver = { }; module_comedi_driver(dev_8255_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for standalone 8255 devices"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/8255_pci.c b/drivers/staging/comedi/drivers/8255_pci.c index 9ed05f962fdb..5a810f0e532a 100644 --- a/drivers/staging/comedi/drivers/8255_pci.c +++ b/drivers/staging/comedi/drivers/8255_pci.c @@ -291,5 +291,5 @@ static struct pci_driver pci_8255_pci_driver = { module_comedi_pci_driver(pci_8255_driver, pci_8255_pci_driver); MODULE_DESCRIPTION("COMEDI - Generic PCI based 8255 Digital I/O boards"); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/staging/comedi/drivers/adq12b.c index 5d431573bcca..d719f76709ef 100644 --- a/drivers/staging/comedi/drivers/adq12b.c +++ b/drivers/staging/comedi/drivers/adq12b.c @@ -238,6 +238,6 @@ static struct comedi_driver adq12b_driver = { }; module_comedi_driver(adq12b_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index f4beda1ed640..4829115921a3 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -272,6 +272,6 @@ static struct comedi_driver aio_aio12_8_driver = { }; module_comedi_driver(aio_aio12_8_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Access I/O AIO12-8 Analog I/O Board"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c index 41c9c56816ef..fe3876235075 100644 --- a/drivers/staging/comedi/drivers/aio_iiro_16.c +++ b/drivers/staging/comedi/drivers/aio_iiro_16.c @@ -230,6 +230,6 @@ static struct comedi_driver aio_iiro_16_driver = { }; module_comedi_driver(aio_iiro_16_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Access I/O Products 104-IIRO-16 board"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/c6xdigio.c b/drivers/staging/comedi/drivers/c6xdigio.c index 41cc784320a9..786fd15698df 100644 --- a/drivers/staging/comedi/drivers/c6xdigio.c +++ b/drivers/staging/comedi/drivers/c6xdigio.c @@ -293,6 +293,6 @@ static struct comedi_driver c6xdigio_driver = { }; module_comedi_driver(c6xdigio_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for the C6x_DIGIO DSP daughter card"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/comedi_8255.c b/drivers/staging/comedi/drivers/comedi_8255.c index 62baa0d79302..3298725b9ba5 100644 --- a/drivers/staging/comedi/drivers/comedi_8255.c +++ b/drivers/staging/comedi/drivers/comedi_8255.c @@ -271,6 +271,6 @@ static void __exit comedi_8255_module_exit(void) } module_exit(comedi_8255_module_exit); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi: Generic 8255 digital I/O support"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index efaa57372aeb..9361b2dcf949 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -300,6 +300,6 @@ static struct comedi_driver parport_driver = { }; module_comedi_driver(parport_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi: Standard parallel port driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index ef4c7c8a2b71..cbc225eb1991 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -844,6 +844,6 @@ static void __exit comedi_test_exit(void) } module_exit(comedi_test_exit); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c index 49be795b4971..b8fdd9c1f166 100644 --- a/drivers/staging/comedi/drivers/contec_pci_dio.c +++ b/drivers/staging/comedi/drivers/contec_pci_dio.c @@ -112,6 +112,6 @@ static struct pci_driver contec_pci_dio_pci_driver = { }; module_comedi_pci_driver(contec_pci_dio_driver, contec_pci_dio_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 28603dfadce2..f64e747078bd 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -18,7 +18,7 @@ * the source code for the Windows driver. * * The FPGA on the board requires firmware, which is available from - * http://www.comedi.org in the comedi_nonfree_firmware tarball. + * https://www.comedi.org in the comedi_nonfree_firmware tarball. * * Configuration options: not applicable, uses PCI auto config */ @@ -781,7 +781,7 @@ static struct pci_driver db2k_pci_driver = { }; module_comedi_pci_driver(db2k_driver, db2k_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); MODULE_FIRMWARE(DB2K_FIRMWARE); diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 75693cdde313..17e6018918bb 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -611,6 +611,6 @@ static struct comedi_driver dmm32at_driver = { }; module_comedi_driver(dmm32at_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi: Diamond Systems Diamond-MM-32-AT"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c index 41c50c7a8f59..b715f30659fa 100644 --- a/drivers/staging/comedi/drivers/fl512.c +++ b/drivers/staging/comedi/drivers/fl512.c @@ -138,6 +138,6 @@ static struct comedi_driver fl512_driver = { }; module_comedi_driver(fl512_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index dc62db1ee1dd..e35e4a743714 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -718,6 +718,6 @@ static struct pci_driver gsc_hpdi_pci_driver = { }; module_comedi_pci_driver(gsc_hpdi_driver, gsc_hpdi_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for General Standards PCI-HPDI32/PMC-HPDI32"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index b14aaed6b525..16d2b78de83c 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -331,6 +331,6 @@ static struct pci_driver icp_multi_pci_driver = { }; module_comedi_pci_driver(icp_multi_driver, icp_multi_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Inova ICP_MULTI board"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 3eaf7c59de75..399255dbe388 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -519,6 +519,6 @@ static struct comedi_driver ii20k_driver = { }; module_comedi_driver(ii20k_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Intelligent Instruments PCI-20001C"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index c3c88e6d298f..7a02c4fa3cda 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -24,7 +24,7 @@ * The DSP on the board requires initialization code, which can be * loaded by placing it in /lib/firmware/comedi. The initialization * code should be somewhere on the media you got with your card. One - * version is available from http://www.comedi.org in the + * version is available from https://www.comedi.org in the * comedi_nonfree_firmware tarball. The file is called "jr3pci.idm". */ @@ -810,7 +810,7 @@ static struct pci_driver jr3_pci_pci_driver = { }; module_comedi_pci_driver(jr3_pci_driver, jr3_pci_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for JR3/PCI force sensor board"); MODULE_LICENSE("GPL"); MODULE_FIRMWARE("comedi/jr3pci.idm"); diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/staging/comedi/drivers/ke_counter.c index e612cf605700..bef1b20c1c8d 100644 --- a/drivers/staging/comedi/drivers/ke_counter.c +++ b/drivers/staging/comedi/drivers/ke_counter.c @@ -227,6 +227,6 @@ static struct pci_driver ke_counter_pci_driver = { }; module_comedi_pci_driver(ke_counter_driver, ke_counter_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Kolter Electronic Counter Card"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index ee53571a8969..726e40dc17b6 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -26,7 +26,7 @@ * * The firmware required by these boards is available in the * comedi_nonfree_firmware tarball available from - * http://www.comedi.org. + * https://www.comedi.org. */ #include @@ -1272,7 +1272,7 @@ static struct pci_driver me4000_pci_driver = { }; module_comedi_pci_driver(me4000_driver, me4000_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Meilhaus ME-4000 series boards"); MODULE_LICENSE("GPL"); MODULE_FIRMWARE(ME4000_FIRMWARE); diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 169742be17b8..ef18e387471b 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -550,7 +550,7 @@ static struct pci_driver me_daq_pci_driver = { }; module_comedi_pci_driver(me_daq_driver, me_daq_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); MODULE_FIRMWARE(ME2600_FIRMWARE); diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index cc9fc263573e..70960e3ba878 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -933,6 +933,6 @@ static void __exit mite_module_exit(void) } module_exit(mite_module_exit); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi helper for NI Mite PCI interface chip"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c index bf3a3a08c7ab..646f4c086204 100644 --- a/drivers/staging/comedi/drivers/mpc624.c +++ b/drivers/staging/comedi/drivers/mpc624.c @@ -306,6 +306,6 @@ static struct comedi_driver mpc624_driver = { }; module_comedi_driver(mpc624_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Micro/sys MPC-624 PC/104 board"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/multiq3.c b/drivers/staging/comedi/drivers/multiq3.c index c85c9ab3655f..c1897aee9a9a 100644 --- a/drivers/staging/comedi/drivers/multiq3.c +++ b/drivers/staging/comedi/drivers/multiq3.c @@ -327,6 +327,6 @@ static struct comedi_driver multiq3_driver = { }; module_comedi_driver(multiq3_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Quanser Consulting MultiQ-3 board"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/plx9052.h b/drivers/staging/comedi/drivers/plx9052.h index 8ec5a5f2837d..e68a7afef025 100644 --- a/drivers/staging/comedi/drivers/plx9052.h +++ b/drivers/staging/comedi/drivers/plx9052.h @@ -2,7 +2,7 @@ /* * Definitions for the PLX-9052 PCI interface chip * - * Copyright (C) 2002 MEV Ltd. + * Copyright (C) 2002 MEV Ltd. * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 2000 David A. Schleef diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index 6daaacf7a26a..1b1efa4d31f6 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -7,7 +7,7 @@ * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 1998 David A. Schleef - * http://www.comedi.org/ + * https://www.comedi.org/ * * Documentation for the DAQP PCMCIA cards can be found on Quatech's site: * ftp://ftp.quatech.com/Manuals/daqp-208.pdf diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 8c04af09be2c..2d99a648b054 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -1360,6 +1360,6 @@ static struct pci_driver rtd520_pci_driver = { }; module_comedi_pci_driver(rtd520_driver, rtd520_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c index f7c320c89ee6..327fd93b8b12 100644 --- a/drivers/staging/comedi/drivers/rti800.c +++ b/drivers/staging/comedi/drivers/rti800.c @@ -353,5 +353,5 @@ static struct comedi_driver rti800_driver = { module_comedi_driver(rti800_driver); MODULE_DESCRIPTION("Comedi: RTI-800 Multifunction Analog/Digital board"); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/rti802.c b/drivers/staging/comedi/drivers/rti802.c index c6cf92bfff73..195e2b1ac4c1 100644 --- a/drivers/staging/comedi/drivers/rti802.c +++ b/drivers/staging/comedi/drivers/rti802.c @@ -115,6 +115,6 @@ static struct comedi_driver rti802_driver = { }; module_comedi_driver(rti802_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Analog Devices RTI-802 board"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index 5d567ae78f28..ba485f106c1e 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -624,6 +624,6 @@ static struct comedi_driver s526_driver = { }; module_comedi_driver(s526_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c index 0628060e42ca..016d315aa584 100644 --- a/drivers/staging/comedi/drivers/ssv_dnp.c +++ b/drivers/staging/comedi/drivers/ssv_dnp.c @@ -175,6 +175,6 @@ static struct comedi_driver dnp_driver = { }; module_comedi_driver(dnp_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/tests/ni_routes_test.c b/drivers/staging/comedi/drivers/tests/ni_routes_test.c index f809051820ac..eaefaf596a37 100644 --- a/drivers/staging/comedi/drivers/tests/ni_routes_test.c +++ b/drivers/staging/comedi/drivers/tests/ni_routes_test.c @@ -607,7 +607,7 @@ static void __exit ni_routes_unittest_exit(void) { } module_init(ni_routes_unittest); module_exit(ni_routes_unittest_exit); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi unit-tests for ni_routes module"); MODULE_LICENSE("GPL"); /* **** END simple module entry/exit functions **** */ -- cgit v1.2.3-58-ga151 From 28ce4c5b1930080b74ae52504f3a4756e5a7a968 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 23 Jul 2020 21:28:42 +0200 Subject: staging: comedi: cb: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200723192842.72124-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 2 +- drivers/staging/comedi/drivers/cb_pcidas64.c | 2 +- drivers/staging/comedi/drivers/cb_pcidda.c | 2 +- drivers/staging/comedi/drivers/cb_pcimdas.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 02ae00c95313..48ec2ee953dc 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1493,6 +1493,6 @@ static struct pci_driver cb_pcidas_pci_driver = { }; module_comedi_pci_driver(cb_pcidas_driver, cb_pcidas_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for MeasurementComputing PCI-DAS series"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index e1774e09a320..fa987bb0e7cd 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -4119,6 +4119,6 @@ static struct pci_driver cb_pcidas64_pci_driver = { }; module_comedi_pci_driver(cb_pcidas64_driver, cb_pcidas64_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c index 1d09dd265ab7..78cf1603638c 100644 --- a/drivers/staging/comedi/drivers/cb_pcidda.c +++ b/drivers/staging/comedi/drivers/cb_pcidda.c @@ -416,6 +416,6 @@ static struct pci_driver cb_pcidda_pci_driver = { }; module_comedi_pci_driver(cb_pcidda_driver, cb_pcidda_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index a9d052bfda38..2292f69da4f4 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -28,8 +28,8 @@ * No interrupts, multi channel or FIFO AI, * although the card looks like it could support this. * - * http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf - * http://www.mccdaq.com/PDFs/Manuals/pcie-das1602-16.pdf + * https://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf + * https://www.mccdaq.com/PDFs/Manuals/pcie-das1602-16.pdf */ #include @@ -470,6 +470,6 @@ static struct pci_driver cb_pcimdas_pci_driver = { }; module_comedi_pci_driver(cb_pcimdas_driver, cb_pcimdas_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for PCIM-DAS1602/16 and PCIe-DAS1602/16"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-58-ga151 From d761e90e6ab0f414321079a1f8e3d4912d731651 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 23 Jul 2020 21:18:27 +0200 Subject: staging: comedi: adv: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200723191827.72047-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1710.c | 2 +- drivers/staging/comedi/drivers/adv_pci1723.c | 2 +- drivers/staging/comedi/drivers/adv_pci1760.c | 2 +- drivers/staging/comedi/drivers/adv_pci_dio.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index ddc0dc93d08b..692893c7e5c3 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -958,6 +958,6 @@ static struct pci_driver adv_pci1710_pci_driver = { }; module_comedi_pci_driver(adv_pci1710_driver, adv_pci1710_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi: Advantech PCI-1710 Series Multifunction DAS Cards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 771d61f87427..23660a9fdb9c 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -222,6 +222,6 @@ static struct pci_driver adv_pci1723_pci_driver = { }; module_comedi_pci_driver(adv_pci1723_driver, adv_pci1723_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Advantech PCI-1723 Comedi driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adv_pci1760.c b/drivers/staging/comedi/drivers/adv_pci1760.c index f460f21efb90..6de8ab97d346 100644 --- a/drivers/staging/comedi/drivers/adv_pci1760.c +++ b/drivers/staging/comedi/drivers/adv_pci1760.c @@ -419,6 +419,6 @@ static struct pci_driver pci1760_pci_driver = { }; module_comedi_pci_driver(pci1760_driver, pci1760_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Advantech PCI-1760"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 5fef2aef7e03..0df28ec00f37 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -532,6 +532,6 @@ static struct pci_driver adv_pci_dio_pci_driver = { }; module_comedi_pci_driver(adv_pci_dio_driver, adv_pci_dio_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Advantech Digital I/O Cards"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-58-ga151 From a5fc6f6d39a642444ce703cc616ea1ada522d486 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 23 Jul 2020 21:08:13 +0200 Subject: staging: comedi: adl: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200723190813.71971-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci6208.c | 2 +- drivers/staging/comedi/drivers/adl_pci8164.c | 2 +- drivers/staging/comedi/drivers/adl_pci9111.c | 2 +- drivers/staging/comedi/drivers/adl_pci9118.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c index e21840e9002d..9ae4cc523dd4 100644 --- a/drivers/staging/comedi/drivers/adl_pci6208.c +++ b/drivers/staging/comedi/drivers/adl_pci6208.c @@ -196,6 +196,6 @@ static struct pci_driver adl_pci6208_pci_driver = { }; module_comedi_pci_driver(adl_pci6208_driver, adl_pci6208_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for ADLink 6208 series cards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adl_pci8164.c b/drivers/staging/comedi/drivers/adl_pci8164.c index 3022793b1bc5..d5e1bda81557 100644 --- a/drivers/staging/comedi/drivers/adl_pci8164.c +++ b/drivers/staging/comedi/drivers/adl_pci8164.c @@ -149,6 +149,6 @@ static struct pci_driver adl_pci8164_pci_driver = { }; module_comedi_pci_driver(adl_pci8164_driver, adl_pci8164_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index f4dba6271d0d..a062c5ab20e9 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -742,6 +742,6 @@ static struct pci_driver adl_pci9111_pci_driver = { }; module_comedi_pci_driver(adl_pci9111_driver, adl_pci9111_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 2528ca0ede6d..cda3a4267dca 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -1731,6 +1731,6 @@ static struct pci_driver adl_pci9118_pci_driver = { }; module_comedi_pci_driver(adl_pci9118_driver, adl_pci9118_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-58-ga151 From e3913b6e062d6e653e83faa91efd1830380e66ba Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 21 Jul 2020 21:38:06 +0200 Subject: staging: comedi: pcm: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200721193806.68010-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcm3724.c | 2 +- drivers/staging/comedi/drivers/pcmad.c | 2 +- drivers/staging/comedi/drivers/pcmda12.c | 2 +- drivers/staging/comedi/drivers/pcmmio.c | 2 +- drivers/staging/comedi/drivers/pcmuio.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index 5779e005c0cb..0cb1ad060402 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -222,6 +222,6 @@ static struct comedi_driver pcm3724_driver = { }; module_comedi_driver(pcm3724_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Advantech PCM-3724 Digital I/O board"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcmad.c b/drivers/staging/comedi/drivers/pcmad.c index fe5449bb1716..eec89a0afb2f 100644 --- a/drivers/staging/comedi/drivers/pcmad.c +++ b/drivers/staging/comedi/drivers/pcmad.c @@ -144,6 +144,6 @@ static struct comedi_driver pcmad_driver = { }; module_comedi_driver(pcmad_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/staging/comedi/drivers/pcmda12.c index 33e463b193a1..14ab1f0d1e9f 100644 --- a/drivers/staging/comedi/drivers/pcmda12.c +++ b/drivers/staging/comedi/drivers/pcmda12.c @@ -160,6 +160,6 @@ static struct comedi_driver pcmda12_driver = { }; module_comedi_driver(pcmda12_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 72af1776f785..24a9568d3378 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -772,6 +772,6 @@ static struct comedi_driver pcmmio_driver = { }; module_comedi_driver(pcmmio_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Winsystems PCM-MIO PC/104 board"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index 743fb226e2e4..7e1fc6ffb48c 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -619,6 +619,6 @@ static struct comedi_driver pcmuio_driver = { }; module_comedi_driver(pcmuio_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-58-ga151 From 2c183944ac857e1a0b02678e9784aca9e5e1cadd Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 21 Jul 2020 21:27:50 +0200 Subject: staging: comedi: pcl: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200721192750.67925-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl711.c | 2 +- drivers/staging/comedi/drivers/pcl724.c | 2 +- drivers/staging/comedi/drivers/pcl726.c | 2 +- drivers/staging/comedi/drivers/pcl730.c | 2 +- drivers/staging/comedi/drivers/pcl812.c | 2 +- drivers/staging/comedi/drivers/pcl816.c | 2 +- drivers/staging/comedi/drivers/pcl818.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index a5937206bf1c..2dbf69e30965 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -508,6 +508,6 @@ static struct comedi_driver pcl711_driver = { }; module_comedi_driver(pcl711_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for PCL-711 compatible boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/staging/comedi/drivers/pcl724.c index 9c174f1f2fcf..1a5799278a7a 100644 --- a/drivers/staging/comedi/drivers/pcl724.c +++ b/drivers/staging/comedi/drivers/pcl724.c @@ -148,6 +148,6 @@ static struct comedi_driver pcl724_driver = { }; module_comedi_driver(pcl724_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for 8255 based ISA and PC/104 DIO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c index 0963d85873a9..58b3d07ae907 100644 --- a/drivers/staging/comedi/drivers/pcl726.c +++ b/drivers/staging/comedi/drivers/pcl726.c @@ -418,6 +418,6 @@ static struct comedi_driver pcl726_driver = { }; module_comedi_driver(pcl726_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Advantech PCL-726 & compatibles"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/staging/comedi/drivers/pcl730.c index 3d1e9150e5b5..32a29129e6e8 100644 --- a/drivers/staging/comedi/drivers/pcl730.c +++ b/drivers/staging/comedi/drivers/pcl730.c @@ -345,6 +345,6 @@ static struct comedi_driver pcl730_driver = { }; module_comedi_driver(pcl730_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index aefc1b849cf7..b87ab3840eee 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -1331,6 +1331,6 @@ static struct comedi_driver pcl812_driver = { }; module_comedi_driver(pcl812_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index d87cf6d4a161..c368a337a0ae 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -691,6 +691,6 @@ static struct comedi_driver pcl816_driver = { }; module_comedi_driver(pcl816_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 0af5315d4357..63e3011158f2 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -1132,6 +1132,6 @@ static struct comedi_driver pcl818_driver = { }; module_comedi_driver(pcl818_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-58-ga151 From 3659743d481f67453ca409f4502f3b51dbf1c3e1 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 21 Jul 2020 21:17:29 +0200 Subject: staging: comedi: ni: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200721191729.67847-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_6527.c | 2 +- drivers/staging/comedi/drivers/ni_65xx.c | 2 +- drivers/staging/comedi/drivers/ni_660x.c | 2 +- drivers/staging/comedi/drivers/ni_670x.c | 2 +- drivers/staging/comedi/drivers/ni_at_a2150.c | 2 +- drivers/staging/comedi/drivers/ni_at_ao.c | 2 +- drivers/staging/comedi/drivers/ni_atmio.c | 2 +- drivers/staging/comedi/drivers/ni_atmio16d.c | 2 +- drivers/staging/comedi/drivers/ni_daq_700.c | 4 ++-- drivers/staging/comedi/drivers/ni_labpc.c | 4 ++-- drivers/staging/comedi/drivers/ni_labpc_common.c | 2 +- drivers/staging/comedi/drivers/ni_labpc_isadma.c | 2 +- drivers/staging/comedi/drivers/ni_labpc_pci.c | 2 +- drivers/staging/comedi/drivers/ni_pcidio.c | 4 ++-- drivers/staging/comedi/drivers/ni_pcimio.c | 2 +- drivers/staging/comedi/drivers/ni_routes.c | 2 +- drivers/staging/comedi/drivers/ni_usb6501.c | 2 +- 17 files changed, 20 insertions(+), 20 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index 4d1eccb5041d..ba7f40b46c3a 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -486,6 +486,6 @@ static struct pci_driver ni6527_pci_driver = { }; module_comedi_pci_driver(ni6527_driver, ni6527_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for National Instruments PCI-6527"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 996074e471d3..eb3f9f7109da 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -817,6 +817,6 @@ static struct pci_driver ni_65xx_pci_driver = { }; module_comedi_pci_driver(ni_65xx_driver, ni_65xx_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for NI PCI-65xx static dio boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index 75d5c9c24596..e60d0125bcb2 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -1250,6 +1250,6 @@ static struct pci_driver ni_660x_pci_driver = { }; module_comedi_pci_driver(ni_660x_driver, ni_660x_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for NI 660x counter/timer boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 4e4ae31c8d0b..c197e47486be 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -277,6 +277,6 @@ static struct pci_driver ni_670x_pci_driver = { }; module_comedi_pci_driver(ni_670x_driver, ni_670x_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index 76e8d047f71e..10ad7b88713e 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -777,6 +777,6 @@ static struct comedi_driver ni_at_a2150_driver = { }; module_comedi_driver(ni_at_a2150_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index 814895d01ffa..2a0fb4d460db 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -369,6 +369,6 @@ static struct comedi_driver ni_at_ao_driver = { }; module_comedi_driver(ni_at_ao_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for NI AT-AO-6/10 boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_atmio.c b/drivers/staging/comedi/drivers/ni_atmio.c index 2b7bfe0dd7f3..56c78da475e7 100644 --- a/drivers/staging/comedi/drivers/ni_atmio.c +++ b/drivers/staging/comedi/drivers/ni_atmio.c @@ -354,7 +354,7 @@ static struct comedi_driver ni_atmio_driver = { }; module_comedi_driver(ni_atmio_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index 0bca7d752015..dffce1aa3e69 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -724,6 +724,6 @@ static struct comedi_driver atmio16d_driver = { }; module_comedi_driver(atmio16d_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index 81fd4c26a16f..d40fc89f9cef 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -34,8 +34,8 @@ * * IRQ is assigned but not used. * - * Manuals: Register level: http://www.ni.com/pdf/manuals/340698.pdf - * User Manual: http://www.ni.com/pdf/manuals/320676d.pdf + * Manuals: Register level: https://www.ni.com/pdf/manuals/340698.pdf + * User Manual: https://www.ni.com/pdf/manuals/320676d.pdf */ #include diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index c6cf37ccbc92..1f4a07bd1d26 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -27,7 +27,7 @@ * Kernel-level ISA plug-and-play support for the lab-pc-1200 boards * has not yet been added to the driver, mainly due to the fact that * I don't know the device id numbers. If you have one of these boards, - * please file a bug report at http://comedi.org/ so I can get the + * please file a bug report at https://comedi.org/ so I can get the * necessary information from you. * * The 1200 series boards have onboard calibration dacs for correcting @@ -111,6 +111,6 @@ static struct comedi_driver labpc_driver = { }; module_comedi_driver(labpc_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for NI Lab-PC ISA boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index ce0f85026277..dd97946eacaf 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -1358,6 +1358,6 @@ static void __exit labpc_common_exit(void) } module_exit(labpc_common_exit); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi helper for ni_labpc, ni_labpc_pci, ni_labpc_cs"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.c b/drivers/staging/comedi/drivers/ni_labpc_isadma.c index 5657736a9408..a551aca6e615 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_isadma.c +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.c @@ -176,6 +176,6 @@ static void __exit ni_labpc_isadma_cleanup_module(void) } module_exit(ni_labpc_isadma_cleanup_module); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi NI Lab-PC ISA DMA support"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_labpc_pci.c b/drivers/staging/comedi/drivers/ni_labpc_pci.c index d7d5a7973558..ec180b0fedf7 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_pci.c +++ b/drivers/staging/comedi/drivers/ni_labpc_pci.c @@ -128,5 +128,5 @@ static struct pci_driver labpc_pci_driver = { module_comedi_pci_driver(labpc_pci_comedi_driver, labpc_pci_driver); MODULE_DESCRIPTION("Comedi: National Instruments Lab-PC PCI-1200 driver"); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 8f3864799c19..623f8d08d13a 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -33,7 +33,7 @@ * The PCI-6534 requires a firmware upload after power-up to work, the * firmware data and instructions for loading it with comedi_config * it are contained in the comedi_nonfree_firmware tarball available from - * http://www.comedi.org + * https://www.comedi.org */ #define USE_DMA @@ -1005,6 +1005,6 @@ static struct pci_driver ni_pcidio_pci_driver = { }; module_comedi_pci_driver(ni_pcidio_driver, ni_pcidio_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index c1d70eec24ab..6c813a490ba5 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -1472,6 +1472,6 @@ static struct pci_driver ni_pcimio_pci_driver = { }; module_comedi_pci_driver(ni_pcimio_driver, ni_pcimio_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_routes.c b/drivers/staging/comedi/drivers/ni_routes.c index 07cb970340db..c426a9286f15 100644 --- a/drivers/staging/comedi/drivers/ni_routes.c +++ b/drivers/staging/comedi/drivers/ni_routes.c @@ -556,7 +556,7 @@ static void __exit ni_routes_module_exit(void) module_init(ni_routes_module_init); module_exit(ni_routes_module_exit); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi helper for routing signals-->terminals for NI"); MODULE_LICENSE("GPL"); /* **** END simple module entry/exit functions **** */ diff --git a/drivers/staging/comedi/drivers/ni_usb6501.c b/drivers/staging/comedi/drivers/ni_usb6501.c index 360e86a19fe3..5b6d9d783b2f 100644 --- a/drivers/staging/comedi/drivers/ni_usb6501.c +++ b/drivers/staging/comedi/drivers/ni_usb6501.c @@ -79,7 +79,7 @@ * RES: 00 01 00 0C 00 08 01 00 00 00 00 02 * * - * Please visit http://www.brickedbrain.com if you need + * Please visit https://www.brickedbrain.com if you need * additional information or have any questions. * */ -- cgit v1.2.3-58-ga151 From f8cdbd4f4dd5b72b7e448849e63d041994d89fff Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 21 Jul 2020 21:06:53 +0200 Subject: staging: comedi: dt: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200721190653.67751-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2801.c | 2 +- drivers/staging/comedi/drivers/dt2811.c | 2 +- drivers/staging/comedi/drivers/dt2814.c | 2 +- drivers/staging/comedi/drivers/dt2815.c | 2 +- drivers/staging/comedi/drivers/dt2817.c | 2 +- drivers/staging/comedi/drivers/dt282x.c | 2 +- drivers/staging/comedi/drivers/dt3000.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index a29880981d81..0d571d817b4e 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -640,6 +640,6 @@ static struct comedi_driver dt2801_driver = { }; module_comedi_driver(dt2801_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 8a1f9efe7d4e..0eb5e6ba6916 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -640,6 +640,6 @@ static struct comedi_driver dt2811_driver = { }; module_comedi_driver(dt2811_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Data Translation DT2811 series boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index d2c715737361..bcf4d5444faf 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c @@ -285,6 +285,6 @@ static struct comedi_driver dt2814_driver = { }; module_comedi_driver(dt2814_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c index 78a7c1b3448a..5906f32aa01f 100644 --- a/drivers/staging/comedi/drivers/dt2815.c +++ b/drivers/staging/comedi/drivers/dt2815.c @@ -212,6 +212,6 @@ static struct comedi_driver dt2815_driver = { }; module_comedi_driver(dt2815_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c index 9babb2a5196a..7c1463e835d3 100644 --- a/drivers/staging/comedi/drivers/dt2817.c +++ b/drivers/staging/comedi/drivers/dt2817.c @@ -135,6 +135,6 @@ static struct comedi_driver dt2817_driver = { }; module_comedi_driver(dt2817_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 89dc84d3c803..2656b4b0e3d0 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -1167,6 +1167,6 @@ static struct comedi_driver dt282x_driver = { }; module_comedi_driver(dt282x_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Data Translation DT2821 series"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index 011e19161b78..ec27aa4730d4 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -735,6 +735,6 @@ static struct pci_driver dt3000_pci_driver = { }; module_comedi_pci_driver(dt3000_driver, dt3000_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Data Translation DT3000 series boards"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-58-ga151 From a5dfb77533484026a8452dc9418784636131e14d Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 21 Jul 2020 20:56:33 +0200 Subject: staging: comedi: das: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200721185633.67671-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 2 +- drivers/staging/comedi/drivers/das08_isa.c | 2 +- drivers/staging/comedi/drivers/das08_pci.c | 2 +- drivers/staging/comedi/drivers/das16.c | 2 +- drivers/staging/comedi/drivers/das16m1.c | 2 +- drivers/staging/comedi/drivers/das1800.c | 2 +- drivers/staging/comedi/drivers/das800.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 65e5f2e6c122..b50743c5b822 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -465,6 +465,6 @@ static void __exit das08_exit(void) } module_exit(das08_exit); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi common DAS08 support module"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das08_isa.c b/drivers/staging/comedi/drivers/das08_isa.c index b22a45bd21d1..8c4cfa821423 100644 --- a/drivers/staging/comedi/drivers/das08_isa.c +++ b/drivers/staging/comedi/drivers/das08_isa.c @@ -185,6 +185,6 @@ static struct comedi_driver das08_isa_driver = { }; module_comedi_driver(das08_isa_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das08_pci.c b/drivers/staging/comedi/drivers/das08_pci.c index 7856fc13466a..1cd903336a4c 100644 --- a/drivers/staging/comedi/drivers/das08_pci.c +++ b/drivers/staging/comedi/drivers/das08_pci.c @@ -91,6 +91,6 @@ static struct pci_driver das08_pci_driver = { }; module_comedi_pci_driver(das08_pci_comedi_driver, das08_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 81eb51b1be25..4ac2622b0fac 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -1195,6 +1195,6 @@ static struct comedi_driver das16_driver = { }; module_comedi_driver(das16_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for DAS16 compatible boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 4e36377b592a..75f3dbbe97ac 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -617,6 +617,6 @@ static struct comedi_driver das16m1_driver = { }; module_comedi_driver(das16m1_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for CIO-DAS16/M1 ISA cards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index f16aa7e9f4f3..f50891a6ee7d 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -1359,6 +1359,6 @@ static struct comedi_driver das1800_driver = { }; module_comedi_driver(das1800_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for DAS1800 compatible ISA boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 8cf09ef3012f..4ea100ff6930 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -739,6 +739,6 @@ static struct comedi_driver driver_das800 = { }; module_comedi_driver(driver_das800); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-58-ga151 From 411adf23ceab9d570b61696f7c9516b3599c4862 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 21 Jul 2020 20:46:13 +0200 Subject: staging: comedi: amplc: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200721184613.67596-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200.c | 4 ++-- drivers/staging/comedi/drivers/amplc_dio200.h | 2 +- drivers/staging/comedi/drivers/amplc_dio200_common.c | 4 ++-- drivers/staging/comedi/drivers/amplc_dio200_pci.c | 4 ++-- drivers/staging/comedi/drivers/amplc_pc236.c | 4 ++-- drivers/staging/comedi/drivers/amplc_pc236.h | 2 +- drivers/staging/comedi/drivers/amplc_pc236_common.c | 4 ++-- drivers/staging/comedi/drivers/amplc_pc263.c | 4 ++-- drivers/staging/comedi/drivers/amplc_pci224.c | 4 ++-- drivers/staging/comedi/drivers/amplc_pci230.c | 2 +- drivers/staging/comedi/drivers/amplc_pci236.c | 4 ++-- drivers/staging/comedi/drivers/amplc_pci263.c | 4 ++-- 12 files changed, 21 insertions(+), 21 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index 26e63d64ffc6..fa19c9e7c56b 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -4,7 +4,7 @@ * * Driver for Amplicon PC212E, PC214E, PC215E, PC218E, PC272E. * - * Copyright (C) 2005-2013 MEV Ltd. + * Copyright (C) 2005-2013 MEV Ltd. * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 1998,2000 David A. Schleef @@ -260,6 +260,6 @@ static struct comedi_driver amplc_dio200_driver = { }; module_comedi_driver(amplc_dio200_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Amplicon 200 Series ISA DIO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_dio200.h b/drivers/staging/comedi/drivers/amplc_dio200.h index 1d81393be6df..745baaf940ee 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.h +++ b/drivers/staging/comedi/drivers/amplc_dio200.h @@ -5,7 +5,7 @@ * Header for amplc_dio200.c, amplc_dio200_common.c and * amplc_dio200_pci.c. * - * Copyright (C) 2005-2013 MEV Ltd. + * Copyright (C) 2005-2013 MEV Ltd. * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 1998,2000 David A. Schleef diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 0b2f04b02ebc..a3454130d5f8 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -4,7 +4,7 @@ * * Common support code for "amplc_dio200" and "amplc_dio200_pci". * - * Copyright (C) 2005-2013 MEV Ltd. + * Copyright (C) 2005-2013 MEV Ltd. * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 1998,2000 David A. Schleef @@ -853,6 +853,6 @@ static void __exit amplc_dio200_common_exit(void) } module_exit(amplc_dio200_common_exit); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi helper for amplc_dio200 and amplc_dio200_pci"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_dio200_pci.c b/drivers/staging/comedi/drivers/amplc_dio200_pci.c index 30d239731e0b..1bd7a42c8464 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_pci.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_pci.c @@ -3,7 +3,7 @@ * * Driver for Amplicon PCI215, PCI272, PCIe215, PCIe236, PCIe296. * - * Copyright (C) 2005-2013 MEV Ltd. + * Copyright (C) 2005-2013 MEV Ltd. * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 1998,2000 David A. Schleef @@ -410,6 +410,6 @@ static struct pci_driver dio200_pci_pci_driver = { }; module_comedi_pci_driver(dio200_pci_comedi_driver, dio200_pci_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Amplicon 200 Series PCI(e) DIO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index b7dd15f5ec63..c377af1d5246 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -3,7 +3,7 @@ * comedi/drivers/amplc_pc236.c * Driver for Amplicon PC36AT DIO boards. * - * Copyright (C) 2002 MEV Ltd. + * Copyright (C) 2002 MEV Ltd. * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 2000 David A. Schleef @@ -71,6 +71,6 @@ static struct comedi_driver amplc_pc236_driver = { module_comedi_driver(amplc_pc236_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Amplicon PC36AT DIO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_pc236.h b/drivers/staging/comedi/drivers/amplc_pc236.h index 45e933ee8735..7e72729f7492 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.h +++ b/drivers/staging/comedi/drivers/amplc_pc236.h @@ -3,7 +3,7 @@ * comedi/drivers/amplc_pc236.h * Header for "amplc_pc236", "amplc_pci236" and "amplc_pc236_common". * - * Copyright (C) 2002-2014 MEV Ltd. + * Copyright (C) 2002-2014 MEV Ltd. * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 2000 David A. Schleef diff --git a/drivers/staging/comedi/drivers/amplc_pc236_common.c b/drivers/staging/comedi/drivers/amplc_pc236_common.c index 01b90e4eca8a..043752663188 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236_common.c +++ b/drivers/staging/comedi/drivers/amplc_pc236_common.c @@ -3,7 +3,7 @@ * comedi/drivers/amplc_pc236_common.c * Common support code for "amplc_pc236" and "amplc_pci236". * - * Copyright (C) 2002-2014 MEV Ltd. + * Copyright (C) 2002-2014 MEV Ltd. * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 2000 David A. Schleef @@ -186,6 +186,6 @@ static void __exit amplc_pc236_common_exit(void) } module_exit(amplc_pc236_common_exit); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi helper for amplc_pc236 and amplc_pci236"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c index 84c989f12faf..68da6098ee84 100644 --- a/drivers/staging/comedi/drivers/amplc_pc263.c +++ b/drivers/staging/comedi/drivers/amplc_pc263.c @@ -2,7 +2,7 @@ /* * Driver for Amplicon PC263 relay board. * - * Copyright (C) 2002 MEV Ltd. + * Copyright (C) 2002 MEV Ltd. * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 2000 David A. Schleef @@ -97,6 +97,6 @@ static struct comedi_driver amplc_pc263_driver = { module_comedi_driver(amplc_pc263_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Amplicon PC263 relay board"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 657b736ef46d..bcf6d61af863 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -3,7 +3,7 @@ * comedi/drivers/amplc_pci224.c * Driver for Amplicon PCI224 and PCI234 AO boards. * - * Copyright (C) 2005 MEV Ltd. + * Copyright (C) 2005 MEV Ltd. * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 1998,2000 David A. Schleef @@ -1138,6 +1138,6 @@ static struct pci_driver amplc_pci224_pci_driver = { }; module_comedi_pci_driver(amplc_pci224_driver, amplc_pci224_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Amplicon PCI224 and PCI234 AO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index f7e673121864..8911dc2bd2c6 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -2570,6 +2570,6 @@ static struct pci_driver amplc_pci230_pci_driver = { }; module_comedi_pci_driver(amplc_pci230_driver, amplc_pci230_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Amplicon PCI230(+) and PCI260(+)"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_pci236.c b/drivers/staging/comedi/drivers/amplc_pci236.c index 86ea876a11be..e7f6fa4d101a 100644 --- a/drivers/staging/comedi/drivers/amplc_pci236.c +++ b/drivers/staging/comedi/drivers/amplc_pci236.c @@ -3,7 +3,7 @@ * comedi/drivers/amplc_pci236.c * Driver for Amplicon PCI236 DIO boards. * - * Copyright (C) 2002-2014 MEV Ltd. + * Copyright (C) 2002-2014 MEV Ltd. * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 2000 David A. Schleef @@ -139,6 +139,6 @@ static struct pci_driver amplc_pci236_pci_driver = { module_comedi_pci_driver(amplc_pci236_driver, amplc_pci236_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Amplicon PCI236 DIO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_pci263.c b/drivers/staging/comedi/drivers/amplc_pci263.c index c3efe14020a8..9217973f1141 100644 --- a/drivers/staging/comedi/drivers/amplc_pci263.c +++ b/drivers/staging/comedi/drivers/amplc_pci263.c @@ -2,7 +2,7 @@ /* * Driver for Amplicon PCI263 relay board. * - * Copyright (C) 2002 MEV Ltd. + * Copyright (C) 2002 MEV Ltd. * * COMEDI - Linux Control and Measurement Device Interface * Copyright (C) 2000 David A. Schleef @@ -106,6 +106,6 @@ static struct pci_driver amplc_pci263_pci_driver = { }; module_comedi_pci_driver(amplc_pci263_driver, amplc_pci263_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi driver for Amplicon PCI263 relay board"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-58-ga151 From 58b1d3f864b1f32521d60642e240face22e9ee68 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 21 Jul 2020 20:35:45 +0200 Subject: staging: comedi: addi: Replace HTTP links with HTTPS ones Rationale: Reduces attack surface on kernel devs opening the links for MITM as HTTPS traffic is much harder to manipulate. Deterministic algorithm: For each file: If not .svg: For each line: If doesn't contain `\bxmlns\b`: For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`: If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`: If both the HTTP and HTTPS versions return 200 OK and serve the same content: Replace HTTP with HTTPS. Signed-off-by: Alexander A. Klimov Link: https://lore.kernel.org/r/20200721183545.67500-1-grandmaster@al2klimov.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1032.c | 2 +- drivers/staging/comedi/drivers/addi_apci_1500.c | 2 +- drivers/staging/comedi/drivers/addi_apci_1516.c | 2 +- drivers/staging/comedi/drivers/addi_apci_1564.c | 2 +- drivers/staging/comedi/drivers/addi_apci_16xx.c | 2 +- drivers/staging/comedi/drivers/addi_apci_2032.c | 2 +- drivers/staging/comedi/drivers/addi_apci_2200.c | 2 +- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 +- drivers/staging/comedi/drivers/addi_apci_3501.c | 2 +- drivers/staging/comedi/drivers/addi_apci_3xxx.c | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c index 560649be9d13..8df968081754 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -381,6 +381,6 @@ static struct pci_driver apci1032_pci_driver = { }; module_comedi_pci_driver(apci1032_driver, apci1032_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("ADDI-DATA APCI-1032, 32 channel DI boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index 689acd69a1b9..84c22ae9ba24 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -868,6 +868,6 @@ static struct pci_driver apci1500_pci_driver = { }; module_comedi_pci_driver(apci1500_driver, apci1500_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("ADDI-DATA APCI-1500, 16 channel DI / 16 channel DO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_1516.c b/drivers/staging/comedi/drivers/addi_apci_1516.c index 6c8213ee1a74..274ec9fb030c 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1516.c +++ b/drivers/staging/comedi/drivers/addi_apci_1516.c @@ -212,5 +212,5 @@ static struct pci_driver apci1516_pci_driver = { module_comedi_pci_driver(apci1516_driver, apci1516_pci_driver); MODULE_DESCRIPTION("ADDI-DATA APCI-1016/1516/2016, 16 channel DIO boards"); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 10501fe6bb25..a6d8d32d4896 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -807,6 +807,6 @@ static struct pci_driver apci1564_pci_driver = { }; module_comedi_pci_driver(apci1564_driver, apci1564_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("ADDI-DATA APCI-1564, 32 channel DI / 32 channel DO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_16xx.c b/drivers/staging/comedi/drivers/addi_apci_16xx.c index 050d0b4b3209..9bbef3b15f3f 100644 --- a/drivers/staging/comedi/drivers/addi_apci_16xx.c +++ b/drivers/staging/comedi/drivers/addi_apci_16xx.c @@ -174,5 +174,5 @@ static struct pci_driver apci16xx_pci_driver = { module_comedi_pci_driver(apci16xx_driver, apci16xx_pci_driver); MODULE_DESCRIPTION("ADDI-DATA APCI-1648/1696, TTL I/O boards"); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index a122f3f3f5ec..e9a2b37a4ae0 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -325,6 +325,6 @@ static struct pci_driver apci2032_pci_driver = { }; module_comedi_pci_driver(apci2032_driver, apci2032_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("ADDI-DATA APCI-2032, 32 channel DO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_2200.c b/drivers/staging/comedi/drivers/addi_apci_2200.c index 140d1514a106..4c5aee784bd9 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2200.c +++ b/drivers/staging/comedi/drivers/addi_apci_2200.c @@ -139,5 +139,5 @@ static struct pci_driver apci2200_pci_driver = { module_comedi_pci_driver(apci2200_driver, apci2200_pci_driver); MODULE_DESCRIPTION("ADDI-DATA APCI-2200 Relay board, optically isolated"); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index d2810fdd5e63..1ed3b33d1a30 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -1112,6 +1112,6 @@ static struct pci_driver apci3120_pci_driver = { }; module_comedi_pci_driver(apci3120_driver, apci3120_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("ADDI-DATA APCI-3120, Analog input board"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c index b4aa588975df..f0c9642f3f1a 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3501.c +++ b/drivers/staging/comedi/drivers/addi_apci_3501.c @@ -413,5 +413,5 @@ static struct pci_driver apci3501_pci_driver = { module_comedi_pci_driver(apci3501_driver, apci3501_pci_driver); MODULE_DESCRIPTION("ADDI-DATA APCI-3501 Analog output board"); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index 55784f24e2a7..a90d59377e18 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -956,6 +956,6 @@ static struct pci_driver apci3xxx_pci_driver = { }; module_comedi_pci_driver(apci3xxx_driver, apci3xxx_pci_driver); -MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_AUTHOR("Comedi https://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); MODULE_LICENSE("GPL"); -- cgit v1.2.3-58-ga151 From 50b2677c4e276771a6383382929180b1589b835f Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 22 Jul 2020 16:06:51 +0300 Subject: staging: vchiq: Fix refcounting bug in buffer_from_host() If we fail to queue the buffer then it can never be dequeued. This can lead to a forever loop in stop_streaming() when we wait for everything to finish. Fixes: 70ec64ccdaac ("staging: bcm2835-camera: Ensure all buffers are returned on disable") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/20200722130651.GC220681@mwanda Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c index 744ceb50f7bb..e798d494f00f 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c @@ -441,6 +441,8 @@ buffer_from_host(struct vchiq_mmal_instance *instance, ret = vchiq_queue_kernel_message(instance->service_handle, &m, sizeof(struct mmal_msg_header) + sizeof(m.u.buffer_from_host)); + if (ret) + atomic_dec(&port->buffers_with_vpu); vchiq_release_service(instance->service_handle); -- cgit v1.2.3-58-ga151 From 8750d02d1acebcb472673399b7315b0f74f5b3cf Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 22 Jul 2020 09:44:14 +0200 Subject: staging: greybus: gpio: Use irqchip template This makes the driver use the irqchip template to assign properties to the gpio_irq_chip instead of using the explicit calls to gpiochip_irqchip_add(). The irqchip is instead added while adding the gpiochip. Cc: Nishad Kamdar Cc: Johan Hovold Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20200722074414.48457-1-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/gpio.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c index 36d99f9e419e..7e6347fe93f9 100644 --- a/drivers/staging/greybus/gpio.c +++ b/drivers/staging/greybus/gpio.c @@ -504,6 +504,7 @@ static int gb_gpio_probe(struct gbphy_device *gbphy_dev, struct gb_connection *connection; struct gb_gpio_controller *ggc; struct gpio_chip *gpio; + struct gpio_irq_chip *girq; struct irq_chip *irqc; int ret; @@ -561,6 +562,15 @@ static int gb_gpio_probe(struct gbphy_device *gbphy_dev, gpio->ngpio = ggc->line_max + 1; gpio->can_sleep = true; + girq = &gpio->irq; + girq->chip = irqc; + /* The event comes from the outside so no parent handler */ + girq->parent_handler = NULL; + girq->num_parents = 0; + girq->parents = NULL; + girq->default_type = IRQ_TYPE_NONE; + girq->handler = handle_level_irq; + ret = gb_connection_enable(connection); if (ret) goto exit_line_free; @@ -571,18 +581,9 @@ static int gb_gpio_probe(struct gbphy_device *gbphy_dev, goto exit_line_free; } - ret = gpiochip_irqchip_add(gpio, irqc, 0, handle_level_irq, - IRQ_TYPE_NONE); - if (ret) { - dev_err(&gbphy_dev->dev, "failed to add irq chip: %d\n", ret); - goto exit_gpiochip_remove; - } - gbphy_runtime_put_autosuspend(gbphy_dev); return 0; -exit_gpiochip_remove: - gpiochip_remove(gpio); exit_line_free: kfree(ggc->lines); exit_connection_disable: -- cgit v1.2.3-58-ga151 From 01713f0d58322f0029f5ac99ce60dd44414b4902 Mon Sep 17 00:00:00 2001 From: Ivan Safonov Date: Mon, 27 Jul 2020 00:02:46 +0300 Subject: staging: r8188eu: use proper type for second argiment of rtw_(aes|tkip|wep)_(decrypt|encrypt) rtw_aes_decrypt, rtw_tkip_decrypt, rtw_wep_decrypt, rtw_aes_encrypt, rtw_tkip_encrypt, rtw_wep_encrypt are takes (u8 *) second argiment and always uses it as (struct recv_frame *) or (struct xmit_frame *). This is causes a lot of unnecessary type casts and complicates refactoring. Signed-off-by: Ivan Safonov Link: https://lore.kernel.org/r/20200726210246.68633-1-insafonov@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8188eu/core/rtw_recv.c | 6 +-- drivers/staging/rtl8188eu/core/rtw_security.c | 50 ++++++++++++------------ drivers/staging/rtl8188eu/core/rtw_xmit.c | 6 +-- drivers/staging/rtl8188eu/include/rtw_security.h | 12 +++--- 5 files changed, 38 insertions(+), 38 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 46a0ac08e90a..98b1ba2e489f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -870,7 +870,7 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, pattrib->last_txcmdsz = pattrib->pktlen; - rtw_wep_encrypt(padapter, (u8 *)pmgntframe); + rtw_wep_encrypt(padapter, pmgntframe); DBG_88E("%s\n", __func__); dump_mgntframe(padapter, pmgntframe); } diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 0a4c1b2686b5..5fe7a0458dd2 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -384,13 +384,13 @@ static struct recv_frame *decryptor(struct adapter *padapter, switch (prxattrib->encrypt) { case _WEP40_: case _WEP104_: - res = rtw_wep_decrypt(padapter, (u8 *)precv_frame); + res = rtw_wep_decrypt(padapter, precv_frame); break; case _TKIP_: - res = rtw_tkip_decrypt(padapter, (u8 *)precv_frame); + res = rtw_tkip_decrypt(padapter, precv_frame); break; case _AES_: - res = rtw_aes_decrypt(padapter, (u8 *)precv_frame); + res = rtw_aes_decrypt(padapter, precv_frame); break; default: break; diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index 57e171d3e48d..78a8ac60bf3d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -129,12 +129,12 @@ static __le32 getcrc32(u8 *buf, int len) /* Need to consider the fragment situation */ -void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) +void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) { int curfragnum, length; u8 *pframe; u8 hw_hdr_offset = 0; - struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct pkt_attrib *pattrib = &pxmitframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; const int keyindex = psecuritypriv->dot11PrivacyKeyIndex; @@ -142,16 +142,16 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) struct sk_buff *skb; struct lib80211_crypto_ops *crypto_ops; - if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + if (pxmitframe->buf_addr == NULL) return; if ((pattrib->encrypt != _WEP40_) && (pattrib->encrypt != _WEP104_)) return; hw_hdr_offset = TXDESC_SIZE + - (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); - pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + pframe = pxmitframe->buf_addr + hw_hdr_offset; crypto_ops = lib80211_get_crypto_ops("WEP"); @@ -198,13 +198,13 @@ free_crypto_private: crypto_ops->deinit(crypto_private); } -int rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) +int rtw_wep_decrypt(struct adapter *padapter, struct recv_frame *precvframe) { - struct rx_pkt_attrib *prxattrib = &(((struct recv_frame *)precvframe)->attrib); + struct rx_pkt_attrib *prxattrib = &precvframe->attrib; if ((prxattrib->encrypt == _WEP40_) || (prxattrib->encrypt == _WEP104_)) { struct security_priv *psecuritypriv = &padapter->securitypriv; - struct sk_buff *skb = ((struct recv_frame *)precvframe)->pkt; + struct sk_buff *skb = precvframe->pkt; u8 *pframe = skb->data; void *crypto_private = NULL; int status = _SUCCESS; @@ -572,7 +572,7 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) } /* The hlen isn't include the IV */ -u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) +u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) { /* exclude ICV */ u16 pnl; u32 pnh; @@ -586,17 +586,17 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) u8 *pframe, *payload, *iv, *prwskey; union pn48 dot11txpn; struct sta_info *stainfo; - struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct pkt_attrib *pattrib = &pxmitframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; u32 res = _SUCCESS; - if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + if (pxmitframe->buf_addr == NULL) return _FAIL; hw_hdr_offset = TXDESC_SIZE + - (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); - pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); + pframe = pxmitframe->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ if (pattrib->encrypt == _TKIP_) { if (pattrib->psta) @@ -653,7 +653,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) } /* The hlen isn't include the IV */ -u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) +u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe) { /* exclude ICV */ u16 pnl; u32 pnh; @@ -666,12 +666,12 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) u8 *pframe, *payload, *iv, *prwskey; union pn48 dot11txpn; struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib; + struct rx_pkt_attrib *prxattrib = &precvframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; u32 res = _SUCCESS; - pframe = (unsigned char *)((struct recv_frame *)precvframe)->pkt->data; + pframe = (unsigned char *)precvframe->pkt->data; /* 4 start to decrypt recvframe */ if (prxattrib->encrypt == _TKIP_) { @@ -691,7 +691,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) iv = pframe + prxattrib->hdrlen; payload = pframe + prxattrib->iv_len + prxattrib->hdrlen; - length = ((struct recv_frame *)precvframe)->pkt->len - prxattrib->hdrlen - prxattrib->iv_len; + length = precvframe->pkt->len - prxattrib->hdrlen - prxattrib->iv_len; GET_TKIP_PN(iv, dot11txpn); @@ -1214,7 +1214,7 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) return _SUCCESS; } -u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) +u32 rtw_aes_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) { /* exclude ICV */ /*static*/ @@ -1225,20 +1225,20 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) u8 *pframe, *prwskey; /* *payload,*iv */ u8 hw_hdr_offset = 0; struct sta_info *stainfo; - struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct pkt_attrib *pattrib = &pxmitframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; /* uint offset = 0; */ u32 res = _SUCCESS; - if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + if (pxmitframe->buf_addr == NULL) return _FAIL; hw_hdr_offset = TXDESC_SIZE + - (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); - pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + pframe = pxmitframe->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ if (pattrib->encrypt == _AES_) { @@ -1276,9 +1276,9 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) return res; } -u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) +u32 rtw_aes_decrypt(struct adapter *padapter, struct recv_frame *precvframe) { - struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib; + struct rx_pkt_attrib *prxattrib = &precvframe->attrib; u32 res = _SUCCESS; /* 4 start to encrypt each fragment */ @@ -1288,7 +1288,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) if (stainfo != NULL) { int key_idx; const int key_length = 16, iv_len = 8, icv_len = 8; - struct sk_buff *skb = ((struct recv_frame *)precvframe)->pkt; + struct sk_buff *skb = precvframe->pkt; void *crypto_private = NULL; u8 *key, *pframe = skb->data; struct lib80211_crypto_ops *crypto_ops = lib80211_get_crypto_ops("CCMP"); diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index d3b1b32bbf76..314790fea1ae 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -713,13 +713,13 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi switch (pattrib->encrypt) { case _WEP40_: case _WEP104_: - rtw_wep_encrypt(padapter, (u8 *)pxmitframe); + rtw_wep_encrypt(padapter, pxmitframe); break; case _TKIP_: - rtw_tkip_encrypt(padapter, (u8 *)pxmitframe); + rtw_tkip_encrypt(padapter, pxmitframe); break; case _AES_: - rtw_aes_encrypt(padapter, (u8 *)pxmitframe); + rtw_aes_encrypt(padapter, pxmitframe); break; default: break; diff --git a/drivers/staging/rtl8188eu/include/rtw_security.h b/drivers/staging/rtl8188eu/include/rtw_security.h index 2a3c58fbf805..8ba02a7cea60 100644 --- a/drivers/staging/rtl8188eu/include/rtw_security.h +++ b/drivers/staging/rtl8188eu/include/rtw_security.h @@ -292,11 +292,11 @@ void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nBytes); void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst); void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *Miccode, u8 priority); -u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe); -u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe); -void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe); -u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe); -u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe); -int rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe); +u32 rtw_aes_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe); +u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe); +void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe); +u32 rtw_aes_decrypt(struct adapter *padapter, struct recv_frame *precvframe); +u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe); +int rtw_wep_decrypt(struct adapter *padapter, struct recv_frame *precvframe); #endif /* __RTL871X_SECURITY_H_ */ -- cgit v1.2.3-58-ga151 From b031d10abfeeffc5d015a3d135babce16930bf62 Mon Sep 17 00:00:00 2001 From: Sumera Priyadarsini Date: Sun, 26 Jul 2020 18:37:20 +0530 Subject: staging: wfx: Remove unnecessary return variable Remove redundant variable in file fwio.c used for returning value. Issue was found using Coccinelle: @@ local idexpression ret; expression e; @@ -ret = +return e; -return ret; Signed-off-by: Sumera Priyadarsini Link: https://lore.kernel.org/r/20200726130720.12993-1-sylphrenadin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/fwio.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/fwio.c b/drivers/staging/wfx/fwio.c index 206c6cf6511c..22d3b684f04f 100644 --- a/drivers/staging/wfx/fwio.c +++ b/drivers/staging/wfx/fwio.c @@ -397,10 +397,9 @@ int wfx_init_device(struct wfx_dev *wdev) ret = load_firmware_secure(wdev); if (ret < 0) return ret; - ret = config_reg_write_bits(wdev, - CFG_DIRECT_ACCESS_MODE | - CFG_IRQ_ENABLE_DATA | - CFG_IRQ_ENABLE_WRDY, - CFG_IRQ_ENABLE_DATA); - return ret; + return config_reg_write_bits(wdev, + CFG_DIRECT_ACCESS_MODE | + CFG_IRQ_ENABLE_DATA | + CFG_IRQ_ENABLE_WRDY, + CFG_IRQ_ENABLE_DATA); } -- cgit v1.2.3-58-ga151 From 49e86ae1324e55200e87605b8922542e12f96492 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Mon, 27 Jul 2020 14:10:06 -0500 Subject: staging: rtl8192e: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200727191006.GA30474@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_wx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c index 7e7df50164fb..aa26b2fd2774 100644 --- a/drivers/staging/rtl8192e/rtllib_wx.c +++ b/drivers/staging/rtl8192e/rtllib_wx.c @@ -680,7 +680,7 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee, switch (mlme->cmd) { case IW_MLME_DEAUTH: deauth = true; - /* fall through */ + fallthrough; case IW_MLME_DISASSOC: if (deauth) netdev_info(ieee->dev, "disauth packet !\n"); -- cgit v1.2.3-58-ga151 From 43feb001cbaf38b35fc6036a2cdebe721a27e080 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Mon, 27 Jul 2020 14:08:29 -0500 Subject: staging: gdm724x: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200727190829.GA30332@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_lte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index eb309190f5be..571f47d39484 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -784,7 +784,7 @@ static int gdm_lte_receive_pkt(struct phy_dev *phy_dev, char *buf, int len) return index; dev = phy_dev->dev[index]; gdm_lte_pdn_table(dev, buf, len); - /* Fall through */ + fallthrough; default: ret = gdm_lte_event_send(dev, buf, len); break; -- cgit v1.2.3-58-ga151 From 52a1d9d4bec4d7690d71277c2fb5dcf9a909d8d1 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Mon, 27 Jul 2020 14:06:57 -0500 Subject: staging: rtl8723bs: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200727190657.GA30194@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index d6d7198dfe45..6db637701063 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -568,7 +568,7 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) ptable->func = &OnAuth; else ptable->func = &OnAuthClient; - /* fall through */ + fallthrough; case WIFI_ASSOCREQ: case WIFI_REASSOCREQ: _mgt_dispatcher(padapter, ptable, precv_frame); -- cgit v1.2.3-58-ga151 From 29ca39b5b8c62e23833a72794247097333f5b7f9 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Mon, 27 Jul 2020 14:04:17 -0500 Subject: staging: ks7010: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200727190417.GA29944@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 334ae1ded684..dc09cc6e1c47 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -426,16 +426,16 @@ static int ks_wlan_set_rate(struct net_device *dev, priv->reg.rate_set.body[3] = TX_RATE_11M; i++; - /* fall through */ + fallthrough; case 5500000: priv->reg.rate_set.body[2] = TX_RATE_5M; i++; - /* fall through */ + fallthrough; case 2000000: priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE; i++; - /* fall through */ + fallthrough; case 1000000: priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE; @@ -491,17 +491,17 @@ static int ks_wlan_set_rate(struct net_device *dev, priv->reg.rate_set.body[11] = TX_RATE_54M; i++; - /* fall through */ + fallthrough; case 48000000: priv->reg.rate_set.body[10] = TX_RATE_48M; i++; - /* fall through */ + fallthrough; case 36000000: priv->reg.rate_set.body[9] = TX_RATE_36M; i++; - /* fall through */ + fallthrough; case 24000000: case 18000000: case 12000000: @@ -578,17 +578,17 @@ static int ks_wlan_set_rate(struct net_device *dev, TX_RATE_6M | BASIC_RATE; i++; } - /* fall through */ + fallthrough; case 5500000: priv->reg.rate_set.body[2] = TX_RATE_5M | BASIC_RATE; i++; - /* fall through */ + fallthrough; case 2000000: priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE; i++; - /* fall through */ + fallthrough; case 1000000: priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE; -- cgit v1.2.3-58-ga151 From 8dda212c69c9a42d062b36fdf6dd09cf6d3cd392 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Mon, 27 Jul 2020 13:58:38 -0500 Subject: staging: rtl8712: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200727185838.GA29595@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/usb_ops_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c index 0045da3bb69a..9a04a752af13 100644 --- a/drivers/staging/rtl8712/usb_ops_linux.c +++ b/drivers/staging/rtl8712/usb_ops_linux.c @@ -225,7 +225,7 @@ static void r8712_usb_read_port_complete(struct urb *purb) padapter->driver_stopped = true; break; } - /* Fall through. */ + fallthrough; case -EPROTO: r8712_read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); -- cgit v1.2.3-58-ga151 From 848e28b4dc505ccd6058186f827c0b07b95d459e Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Mon, 27 Jul 2020 13:42:47 -0500 Subject: staging: comedi: s526: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200727184247.GA29207@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s526.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index ba485f106c1e..085cf5b449e5 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -400,7 +400,7 @@ static int s526_gpct_winsn(struct comedi_device *dev, if ((data[1] <= data[0]) || !data[0]) return -EINVAL; /* to write the PULSE_WIDTH */ - /* fall through */ + fallthrough; case INSN_CONFIG_GPCT_QUADRATURE_ENCODER: case INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR: s526_gpct_write(dev, chan, data[0]); -- cgit v1.2.3-58-ga151 From 02a25c9bbba5cbbc6da325e6c1fdfb2541a37bae Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Mon, 27 Jul 2020 13:40:42 -0500 Subject: staging: qlge: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200727184042.GA29074@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_mpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c index 94d504af84ff..e85c6ab538df 100644 --- a/drivers/staging/qlge/qlge_mpi.c +++ b/drivers/staging/qlge/qlge_mpi.c @@ -1174,7 +1174,7 @@ void ql_mpi_idc_work(struct work_struct *work) case MB_CMD_PORT_RESET: case MB_CMD_STOP_FW: ql_link_off(qdev); - /* Fall through */ + fallthrough; case MB_CMD_SET_PORT_CFG: /* Signal the resulting link up AEN * that the frame routing and mac addr @@ -1207,7 +1207,7 @@ void ql_mpi_idc_work(struct work_struct *work) */ ql_link_off(qdev); set_bit(QL_CAM_RT_SET, &qdev->flags); - /* Fall through. */ + fallthrough; case MB_CMD_IOP_DVR_START: case MB_CMD_IOP_FLASH_ACC: case MB_CMD_IOP_CORE_DUMP_MPI: -- cgit v1.2.3-58-ga151 From 9038c6ac407ab751c0f9f5ab61d6e8772e0b8b24 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Mon, 27 Jul 2020 13:37:34 -0500 Subject: staging: vc04_services: Use fallthrough pseudo-keyword Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200727183734.GA28824@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index af64cde82d36..5a361e8e7c6c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2710,7 +2710,7 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) case VCHIQ_SRVSTATE_OPENSYNC: mutex_lock(&state->sync_mutex); - /* fall through */ + fallthrough; case VCHIQ_SRVSTATE_OPEN: if (close_recvd) { if (!do_abort_bulks(service)) -- cgit v1.2.3-58-ga151 From 53754e432c0cdcb56a082fb1c06ed1ac403f3cdf Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 26 Jul 2020 18:54:52 +0200 Subject: staging/speakup: Update TODO list Thanks to Okash's latest work, the TODO list is essentially empty, so the way out from staging now seems open. The status of the remaining issue mentioned in TODO is not clear, we asked the speakup user mailing list for reproducer cases, but didn't get a really specific scenario. One serious bug was fixed by 9d32c0cde4e2 ("staging/speakup: fix get_word non-space look-ahead"), which does not seem to really be related to the bug mentioned in TODO. Possibly the bug mentioned in TODO has been fixed long ago and people have been thinking that it was not because they can not distinguish the symptoms mentioned in TODO from the symptoms of the bug fixed by 9d32c0cde4e2. Signed-off-by: Samuel Thibault Link: https://lore.kernel.org/r/20200726165452.qhos3wrjcm6jmcmx@function Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/TODO | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/speakup/TODO b/drivers/staging/speakup/TODO index 993410c3e531..d4ca093bf0bd 100644 --- a/drivers/staging/speakup/TODO +++ b/drivers/staging/speakup/TODO @@ -6,35 +6,11 @@ Speakup is a kernel based screen review package for the linux operating system. It allows blind users to interact with applications on the linux console by means of synthetic speech. -Currently, speakup has several issues we know of. +Currently, speakup has one issue we know of. -The first issue has to do with the way speakup communicates with serial -ports. Currently, we communicate directly with the hardware -ports. This however conflicts with the standard serial port drivers, -which poses various problems. This is also not working for modern hardware -such as PCI-based serial ports. Also, there is not a way we can -communicate with USB devices. The current serial port handling code is -in serialio.c in this directory. - -Some places are currently using in_atomic() because speakup functions -are called in various contexts, and a couple of things can't happen -in these cases. Pushing work to some worker thread would probably help, -as was already done for the serial port driving part. - -There is a duplication of the selection functions in selections.c. These -functions should get exported from drivers/char/selection.c (clear_selection -notably) and used from there instead. - -The kobjects may have to move to a more proper place in /sys. The -discussion on lkml resulted to putting speech synthesizers in the -"speech" class, and the speakup screen reader itself into -/sys/class/vtconsole/vtcon0/speakup, the nasty path being handled by -userland tools. - -Another issue seems to only happen on SMP systems. It seems -that text in the output buffer gets garbled because a lock is not set. -This bug happens regularly, but no one has been able to find a situation -which produces it consistently. +It seems to only happen on SMP systems. It seems that text in the output buffer +gets garbled because a lock is not set. This bug happens regularly, but no one +has been able to find a situation which produces it consistently. Patches, suggestions, corrections, etc, are definitely welcome. @@ -42,6 +18,5 @@ We prefer that you contact us on the mailing list; however, if you do not want to subscribe to a mailing list, send your email to all of the following: -w.d.hubbs@gmail.com, chris@the-brannons.com, kirk@reisers.ca and -samuel.thibault@ens-lyon.org. - +okash.khawaja@gmail.com, w.d.hubbs@gmail.com, chris@the-brannons.com, +kirk@reisers.ca and samuel.thibault@ens-lyon.org. -- cgit v1.2.3-58-ga151 From 11536442a3b4e1de6890ea5e805908debb74f94a Mon Sep 17 00:00:00 2001 From: Dinghao Liu Date: Tue, 28 Jul 2020 15:21:51 +0800 Subject: Staging: rtl8188eu: rtw_mlme: Fix uninitialized variable authmode The variable authmode can be uninitialized. The danger would be if it equals to _WPA_IE_ID_ (0xdd) or _WPA2_IE_ID_ (0x33). We can avoid this by setting it to zero instead. This is the approach that was used in the rtl8723bs driver. Fixes: 7b464c9fa5cc ("staging: r8188eu: Add files for new driver - part 4") Co-developed-by: Dan Carpenter Signed-off-by: Dan Carpenter Signed-off-by: Dinghao Liu Cc: stable Link: https://lore.kernel.org/r/20200728072153.9202-1-dinghao.liu@zju.edu.cn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 5d7a749f1aac..d334dc335914 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -1729,9 +1729,11 @@ int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ if ((ndisauthmode == Ndis802_11AuthModeWPA) || (ndisauthmode == Ndis802_11AuthModeWPAPSK)) authmode = _WPA_IE_ID_; - if ((ndisauthmode == Ndis802_11AuthModeWPA2) || + else if ((ndisauthmode == Ndis802_11AuthModeWPA2) || (ndisauthmode == Ndis802_11AuthModeWPA2PSK)) authmode = _WPA2_IE_ID_; + else + authmode = 0x0; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { memcpy(out_ie + ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len); -- cgit v1.2.3-58-ga151 From 7f921e92e72a52e6390207d3ebeb8f3b5966ebde Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Tue, 28 Jul 2020 11:07:55 +0200 Subject: staging: most: usb: remove NET dependency This patch removes the dependency to NET as it is no longer needed. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1595927275-27462-1-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/usb/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/usb/Kconfig b/drivers/staging/most/usb/Kconfig index 75dc25c0e0e5..a47a973dfb1d 100644 --- a/drivers/staging/most/usb/Kconfig +++ b/drivers/staging/most/usb/Kconfig @@ -5,10 +5,9 @@ config MOST_USB tristate "USB" - depends on USB && NET + depends on USB help Say Y here if you want to connect via USB to network transceiver. - This device driver depends on the networking AIM. To compile this driver as a module, choose M here: the module will be called most_usb. -- cgit v1.2.3-58-ga151 From 100a149ff153702f8fc7b005df7e9ea9aba5f79e Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 29 Jul 2020 11:05:25 +0100 Subject: staging: rtl8723bs: remove redundant assignment to variable ret The variable ret is being assigned an error return value that is never read, the control passes to a return statement and ret is never referenced. Remove the redundant assignment. Also remove an empty line. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20200729100525.573500-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/osdep_service.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c index 6d443197a0cf..f61ad9200960 100644 --- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c @@ -146,10 +146,8 @@ int rtw_change_ifname(struct adapter *padapter, const char *ifname) rereg_priv->old_pnetdev = cur_pnetdev; pnetdev = rtw_init_netdev(padapter); - if (!pnetdev) { - ret = -1; + if (!pnetdev) goto error; - } SET_NETDEV_DEV(pnetdev, dvobj_to_dev(adapter_to_dvobj(padapter))); @@ -170,9 +168,7 @@ int rtw_change_ifname(struct adapter *padapter, const char *ifname) return 0; error: - return -1; - } void rtw_buf_free(u8 **buf, u32 *buf_len) -- cgit v1.2.3-58-ga151 From 341a8f866e7252e7c0410fdd53fe513a9c12f3d2 Mon Sep 17 00:00:00 2001 From: Ankit Baluni Date: Wed, 29 Jul 2020 13:15:41 +0530 Subject: Staging: rtl8712: Fixed a coding sytle issue Removed braces for a 'if' condition as it contain only single line & there is no need for braces for such case according to coding style rules. Signed-off-by: Ankit Baluni Link: https://lore.kernel.org/r/20200729074541.1972-1-b18007@students.iitmandi.ac.in Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index c6f6ccd060bb..df6ae855f3c1 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -238,9 +238,8 @@ static char *translate_scan(struct _adapter *padapter, /* parsing HT_CAP_IE */ p = r8712_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength - 12); - if (p && ht_ielen > 0) { + if (p && ht_ielen > 0) ht_cap = true; - } /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; if (r8712_is_cckratesonly_included(pnetwork->network.rates)) { -- cgit v1.2.3-58-ga151 From 408a68c5f64fe2f7921449d655ffef5038144f06 Mon Sep 17 00:00:00 2001 From: Vaibhav Gupta Date: Tue, 28 Jul 2020 18:03:49 +0530 Subject: staging: sm750fb: use generic power management Drivers using legacy power management .suspen()/.resume() callbacks have to manage PCI states and device's PM states themselves. They also need to take care of standard configuration registers. Switch to generic power management framework using a single "struct dev_pm_ops" variable to take the unnecessary load from the driver. This also avoids the need for the driver to directly call most of the PCI helper functions and device power state control functions, as through the generic framework PCI Core takes care of the necessary operations, and drivers are required to do only device-specific jobs. Signed-off-by: Vaibhav Gupta Link: https://lore.kernel.org/r/20200728123349.1331679-1-vaibhavgupta40@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750.c | 91 ++++++++--------------------------------- 1 file changed, 17 insertions(+), 74 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index a1a82e59dfee..84fb585a5739 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -407,61 +407,29 @@ static inline unsigned int chan_to_field(unsigned int chan, return chan << bf->offset; } -#ifdef CONFIG_PM -static int lynxfb_suspend(struct pci_dev *pdev, pm_message_t mesg) +static int __maybe_unused lynxfb_suspend(struct device *dev) { struct fb_info *info; struct sm750_dev *sm750_dev; - int ret; - - if (mesg.event == pdev->dev.power.power_state.event) - return 0; - - ret = 0; - sm750_dev = pci_get_drvdata(pdev); - switch (mesg.event) { - case PM_EVENT_FREEZE: - case PM_EVENT_PRETHAW: - pdev->dev.power.power_state = mesg; - return 0; - } + sm750_dev = dev_get_drvdata(dev); console_lock(); - if (mesg.event & PM_EVENT_SLEEP) { - info = sm750_dev->fbinfo[0]; - if (info) - /* 1 means do suspend */ - fb_set_suspend(info, 1); - info = sm750_dev->fbinfo[1]; - if (info) - /* 1 means do suspend */ - fb_set_suspend(info, 1); - - ret = pci_save_state(pdev); - if (ret) { - dev_err(&pdev->dev, - "error:%d occurred in pci_save_state\n", ret); - goto lynxfb_suspend_err; - } - - ret = pci_set_power_state(pdev, pci_choose_state(pdev, mesg)); - if (ret) { - dev_err(&pdev->dev, - "error:%d occurred in pci_set_power_state\n", - ret); - goto lynxfb_suspend_err; - } - } - - pdev->dev.power.power_state = mesg; + info = sm750_dev->fbinfo[0]; + if (info) + /* 1 means do suspend */ + fb_set_suspend(info, 1); + info = sm750_dev->fbinfo[1]; + if (info) + /* 1 means do suspend */ + fb_set_suspend(info, 1); -lynxfb_suspend_err: console_unlock(); - return ret; + return 0; } -static int lynxfb_resume(struct pci_dev *pdev) +static int __maybe_unused lynxfb_resume(struct device *dev) { + struct pci_dev *pdev = to_pci_dev(dev); struct fb_info *info; struct sm750_dev *sm750_dev; @@ -469,32 +437,10 @@ static int lynxfb_resume(struct pci_dev *pdev) struct lynxfb_crtc *crtc; struct lynx_cursor *cursor; - int ret; - - ret = 0; sm750_dev = pci_get_drvdata(pdev); console_lock(); - ret = pci_set_power_state(pdev, PCI_D0); - if (ret) { - dev_err(&pdev->dev, - "error:%d occurred in pci_set_power_state\n", ret); - goto lynxfb_resume_err; - } - - if (pdev->dev.power.power_state.event != PM_EVENT_FREEZE) { - pci_restore_state(pdev); - ret = pci_enable_device(pdev); - if (ret) { - dev_err(&pdev->dev, - "error:%d occurred in pci_enable_device\n", - ret); - goto lynxfb_resume_err; - } - pci_set_master(pdev); - } - hw_sm750_inithw(sm750_dev, pdev); info = sm750_dev->fbinfo[0]; @@ -523,11 +469,9 @@ static int lynxfb_resume(struct pci_dev *pdev) pdev->dev.power.power_state.event = PM_EVENT_RESUME; -lynxfb_resume_err: console_unlock(); - return ret; + return 0; } -#endif static int lynxfb_ops_check_var(struct fb_var_screeninfo *var, struct fb_info *info) @@ -1210,15 +1154,14 @@ static const struct pci_device_id smi_pci_table[] = { MODULE_DEVICE_TABLE(pci, smi_pci_table); +static SIMPLE_DEV_PM_OPS(lynxfb_pm_ops, lynxfb_suspend, lynxfb_resume); + static struct pci_driver lynxfb_driver = { .name = "sm750fb", .id_table = smi_pci_table, .probe = lynxfb_pci_probe, .remove = lynxfb_pci_remove, -#ifdef CONFIG_PM - .suspend = lynxfb_suspend, - .resume = lynxfb_resume, -#endif + .driver.pm = &lynxfb_pm_ops, }; static int __init lynxfb_init(void) -- cgit v1.2.3-58-ga151 From 2067fd92d75b6d9085a43caf050bca5d88c491b8 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 29 Jul 2020 02:35:31 +0200 Subject: staging/speakup: Move out of staging The nasty TODO items are done. Signed-off-by: Samuel Thibault Link: https://lore.kernel.org/r/20200729003531.907370-1-samuel.thibault@ens-lyon.org Signed-off-by: Greg Kroah-Hartman --- Documentation/ABI/stable/sysfs-driver-speakup | 375 +++ Documentation/admin-guide/spkguide.txt | 1575 +++++++++++++ MAINTAINERS | 20 +- drivers/accessibility/Kconfig | 2 + drivers/accessibility/Makefile | 1 + .../accessibility/speakup/DefaultKeyAssignments | 46 + drivers/accessibility/speakup/Kconfig | 200 ++ drivers/accessibility/speakup/Makefile | 32 + drivers/accessibility/speakup/TODO | 22 + drivers/accessibility/speakup/buffers.c | 124 + drivers/accessibility/speakup/devsynth.c | 92 + drivers/accessibility/speakup/fakekey.c | 87 + drivers/accessibility/speakup/i18n.c | 625 +++++ drivers/accessibility/speakup/i18n.h | 235 ++ drivers/accessibility/speakup/keyhelp.c | 209 ++ drivers/accessibility/speakup/kobjects.c | 1056 +++++++++ drivers/accessibility/speakup/main.c | 2460 ++++++++++++++++++++ drivers/accessibility/speakup/selection.c | 144 ++ drivers/accessibility/speakup/serialio.c | 316 +++ drivers/accessibility/speakup/serialio.h | 41 + drivers/accessibility/speakup/speakup.h | 121 + drivers/accessibility/speakup/speakup_acnt.h | 19 + drivers/accessibility/speakup/speakup_acntpc.c | 319 +++ drivers/accessibility/speakup/speakup_acntsa.c | 144 ++ drivers/accessibility/speakup/speakup_apollo.c | 208 ++ drivers/accessibility/speakup/speakup_audptr.c | 171 ++ drivers/accessibility/speakup/speakup_bns.c | 128 + drivers/accessibility/speakup/speakup_decext.c | 240 ++ drivers/accessibility/speakup/speakup_decpc.c | 495 ++++ drivers/accessibility/speakup/speakup_dectlk.c | 311 +++ drivers/accessibility/speakup/speakup_dtlk.c | 390 ++++ drivers/accessibility/speakup/speakup_dtlk.h | 63 + drivers/accessibility/speakup/speakup_dummy.c | 134 ++ drivers/accessibility/speakup/speakup_keypc.c | 318 +++ drivers/accessibility/speakup/speakup_ltlk.c | 175 ++ drivers/accessibility/speakup/speakup_soft.c | 430 ++++ drivers/accessibility/speakup/speakup_spkout.c | 139 ++ drivers/accessibility/speakup/speakup_txprt.c | 127 + drivers/accessibility/speakup/speakupmap.h | 66 + drivers/accessibility/speakup/speakupmap.map | 93 + drivers/accessibility/speakup/spk_priv.h | 84 + drivers/accessibility/speakup/spk_priv_keyinfo.h | 100 + drivers/accessibility/speakup/spk_ttyio.c | 384 +++ drivers/accessibility/speakup/spk_types.h | 221 ++ drivers/accessibility/speakup/synth.c | 490 ++++ drivers/accessibility/speakup/thread.c | 62 + drivers/accessibility/speakup/varhandlers.c | 339 +++ drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/speakup/DefaultKeyAssignments | 46 - drivers/staging/speakup/Kconfig | 200 -- drivers/staging/speakup/Makefile | 32 - drivers/staging/speakup/TODO | 22 - drivers/staging/speakup/buffers.c | 124 - drivers/staging/speakup/devsynth.c | 92 - drivers/staging/speakup/fakekey.c | 87 - drivers/staging/speakup/i18n.c | 625 ----- drivers/staging/speakup/i18n.h | 235 -- drivers/staging/speakup/keyhelp.c | 209 -- drivers/staging/speakup/kobjects.c | 1056 --------- drivers/staging/speakup/main.c | 2460 -------------------- drivers/staging/speakup/selection.c | 144 -- drivers/staging/speakup/serialio.c | 316 --- drivers/staging/speakup/serialio.h | 41 - drivers/staging/speakup/speakup.h | 121 - drivers/staging/speakup/speakup_acnt.h | 19 - drivers/staging/speakup/speakup_acntpc.c | 319 --- drivers/staging/speakup/speakup_acntsa.c | 144 -- drivers/staging/speakup/speakup_apollo.c | 208 -- drivers/staging/speakup/speakup_audptr.c | 171 -- drivers/staging/speakup/speakup_bns.c | 128 - drivers/staging/speakup/speakup_decext.c | 240 -- drivers/staging/speakup/speakup_decpc.c | 495 ---- drivers/staging/speakup/speakup_dectlk.c | 311 --- drivers/staging/speakup/speakup_dtlk.c | 390 ---- drivers/staging/speakup/speakup_dtlk.h | 63 - drivers/staging/speakup/speakup_dummy.c | 134 -- drivers/staging/speakup/speakup_keypc.c | 318 --- drivers/staging/speakup/speakup_ltlk.c | 175 -- drivers/staging/speakup/speakup_soft.c | 430 ---- drivers/staging/speakup/speakup_spkout.c | 139 -- drivers/staging/speakup/speakup_txprt.c | 127 - drivers/staging/speakup/speakupmap.h | 66 - drivers/staging/speakup/speakupmap.map | 93 - drivers/staging/speakup/spk_priv.h | 84 - drivers/staging/speakup/spk_priv_keyinfo.h | 100 - drivers/staging/speakup/spk_ttyio.c | 384 --- drivers/staging/speakup/spk_types.h | 221 -- drivers/staging/speakup/spkguide.txt | 1575 ------------- drivers/staging/speakup/synth.c | 490 ---- drivers/staging/speakup/sysfs-driver-speakup | 375 --- drivers/staging/speakup/thread.c | 62 - drivers/staging/speakup/varhandlers.c | 339 --- 93 files changed, 13423 insertions(+), 13423 deletions(-) create mode 100644 Documentation/ABI/stable/sysfs-driver-speakup create mode 100644 Documentation/admin-guide/spkguide.txt create mode 100644 drivers/accessibility/speakup/DefaultKeyAssignments create mode 100644 drivers/accessibility/speakup/Kconfig create mode 100644 drivers/accessibility/speakup/Makefile create mode 100644 drivers/accessibility/speakup/TODO create mode 100644 drivers/accessibility/speakup/buffers.c create mode 100644 drivers/accessibility/speakup/devsynth.c create mode 100644 drivers/accessibility/speakup/fakekey.c create mode 100644 drivers/accessibility/speakup/i18n.c create mode 100644 drivers/accessibility/speakup/i18n.h create mode 100644 drivers/accessibility/speakup/keyhelp.c create mode 100644 drivers/accessibility/speakup/kobjects.c create mode 100644 drivers/accessibility/speakup/main.c create mode 100644 drivers/accessibility/speakup/selection.c create mode 100644 drivers/accessibility/speakup/serialio.c create mode 100644 drivers/accessibility/speakup/serialio.h create mode 100644 drivers/accessibility/speakup/speakup.h create mode 100644 drivers/accessibility/speakup/speakup_acnt.h create mode 100644 drivers/accessibility/speakup/speakup_acntpc.c create mode 100644 drivers/accessibility/speakup/speakup_acntsa.c create mode 100644 drivers/accessibility/speakup/speakup_apollo.c create mode 100644 drivers/accessibility/speakup/speakup_audptr.c create mode 100644 drivers/accessibility/speakup/speakup_bns.c create mode 100644 drivers/accessibility/speakup/speakup_decext.c create mode 100644 drivers/accessibility/speakup/speakup_decpc.c create mode 100644 drivers/accessibility/speakup/speakup_dectlk.c create mode 100644 drivers/accessibility/speakup/speakup_dtlk.c create mode 100644 drivers/accessibility/speakup/speakup_dtlk.h create mode 100644 drivers/accessibility/speakup/speakup_dummy.c create mode 100644 drivers/accessibility/speakup/speakup_keypc.c create mode 100644 drivers/accessibility/speakup/speakup_ltlk.c create mode 100644 drivers/accessibility/speakup/speakup_soft.c create mode 100644 drivers/accessibility/speakup/speakup_spkout.c create mode 100644 drivers/accessibility/speakup/speakup_txprt.c create mode 100644 drivers/accessibility/speakup/speakupmap.h create mode 100644 drivers/accessibility/speakup/speakupmap.map create mode 100644 drivers/accessibility/speakup/spk_priv.h create mode 100644 drivers/accessibility/speakup/spk_priv_keyinfo.h create mode 100644 drivers/accessibility/speakup/spk_ttyio.c create mode 100644 drivers/accessibility/speakup/spk_types.h create mode 100644 drivers/accessibility/speakup/synth.c create mode 100644 drivers/accessibility/speakup/thread.c create mode 100644 drivers/accessibility/speakup/varhandlers.c delete mode 100644 drivers/staging/speakup/DefaultKeyAssignments delete mode 100644 drivers/staging/speakup/Kconfig delete mode 100644 drivers/staging/speakup/Makefile delete mode 100644 drivers/staging/speakup/TODO delete mode 100644 drivers/staging/speakup/buffers.c delete mode 100644 drivers/staging/speakup/devsynth.c delete mode 100644 drivers/staging/speakup/fakekey.c delete mode 100644 drivers/staging/speakup/i18n.c delete mode 100644 drivers/staging/speakup/i18n.h delete mode 100644 drivers/staging/speakup/keyhelp.c delete mode 100644 drivers/staging/speakup/kobjects.c delete mode 100644 drivers/staging/speakup/main.c delete mode 100644 drivers/staging/speakup/selection.c delete mode 100644 drivers/staging/speakup/serialio.c delete mode 100644 drivers/staging/speakup/serialio.h delete mode 100644 drivers/staging/speakup/speakup.h delete mode 100644 drivers/staging/speakup/speakup_acnt.h delete mode 100644 drivers/staging/speakup/speakup_acntpc.c delete mode 100644 drivers/staging/speakup/speakup_acntsa.c delete mode 100644 drivers/staging/speakup/speakup_apollo.c delete mode 100644 drivers/staging/speakup/speakup_audptr.c delete mode 100644 drivers/staging/speakup/speakup_bns.c delete mode 100644 drivers/staging/speakup/speakup_decext.c delete mode 100644 drivers/staging/speakup/speakup_decpc.c delete mode 100644 drivers/staging/speakup/speakup_dectlk.c delete mode 100644 drivers/staging/speakup/speakup_dtlk.c delete mode 100644 drivers/staging/speakup/speakup_dtlk.h delete mode 100644 drivers/staging/speakup/speakup_dummy.c delete mode 100644 drivers/staging/speakup/speakup_keypc.c delete mode 100644 drivers/staging/speakup/speakup_ltlk.c delete mode 100644 drivers/staging/speakup/speakup_soft.c delete mode 100644 drivers/staging/speakup/speakup_spkout.c delete mode 100644 drivers/staging/speakup/speakup_txprt.c delete mode 100644 drivers/staging/speakup/speakupmap.h delete mode 100644 drivers/staging/speakup/speakupmap.map delete mode 100644 drivers/staging/speakup/spk_priv.h delete mode 100644 drivers/staging/speakup/spk_priv_keyinfo.h delete mode 100644 drivers/staging/speakup/spk_ttyio.c delete mode 100644 drivers/staging/speakup/spk_types.h delete mode 100644 drivers/staging/speakup/spkguide.txt delete mode 100644 drivers/staging/speakup/synth.c delete mode 100644 drivers/staging/speakup/sysfs-driver-speakup delete mode 100644 drivers/staging/speakup/thread.c delete mode 100644 drivers/staging/speakup/varhandlers.c (limited to 'drivers/staging') diff --git a/Documentation/ABI/stable/sysfs-driver-speakup b/Documentation/ABI/stable/sysfs-driver-speakup new file mode 100644 index 000000000000..c6a32c434ce9 --- /dev/null +++ b/Documentation/ABI/stable/sysfs-driver-speakup @@ -0,0 +1,375 @@ +What: /sys/accessibility/speakup/attrib_bleep +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Beeps the PC speaker when there is an attribute change such as + foreground or background color when using speakup review + commands. One = on, zero = off. + +What: /sys/accessibility/speakup/bell_pos +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This works much like a typewriter bell. If for example 72 is + echoed to bell_pos, it will beep the PC speaker when typing on + a line past character 72. + +What: /sys/accessibility/speakup/bleeps +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This controls whether one hears beeps through the PC speaker + when using speakup's review commands. + TODO: what values does it accept? + +What: /sys/accessibility/speakup/bleep_time +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This controls the duration of the PC speaker beeps speakup + produces. + TODO: What are the units? Jiffies? + +What: /sys/accessibility/speakup/cursor_time +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This controls cursor delay when using arrow keys. When a + connection is very slow, with the default setting, when moving + with the arrows, or backspacing etc. speakup says the incorrect + characters. Set this to a higher value to adjust for the delay + and better synchronisation between cursor position and speech. + +What: /sys/accessibility/speakup/delimiters +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Delimit a word from speakup. + TODO: add more info + +What: /sys/accessibility/speakup/ex_num +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: TODO: + +What: /sys/accessibility/speakup/key_echo +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Controls if speakup speaks keys when they are typed. One = on, + zero = off or don't echo keys. + +What: /sys/accessibility/speakup/keymap +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Speakup keymap remaps keys to Speakup functions. + It uses a binary + format. A special program called genmap is needed to compile a + textual keymap into the binary format which is then loaded into + /sys/accessibility/speakup/keymap. + +What: /sys/accessibility/speakup/no_interrupt +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Controls if typing interrupts output from speakup. With + no_interrupt set to zero, typing on the keyboard will interrupt + speakup if for example + the say screen command is used before the + entire screen is read. + With no_interrupt set to one, if the say + screen command is used, and one then types on the keyboard, + speakup will continue to say the whole screen regardless until + it finishes. + +What: /sys/accessibility/speakup/punc_all +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This is a list of all the punctuation speakup should speak when + punc_level is set to four. + +What: /sys/accessibility/speakup/punc_level +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Controls the level of punctuation spoken as the screen is + displayed, not reviewed. Levels range from zero no punctuation, + to four, all punctuation. One corresponds to punc_some, two + corresponds to punc_most, and three as well as four both + correspond to punc_all. Some hardware synthesizers may have + different levels each corresponding to three and four for + punc_level. Also note that if punc_level is set to zero, and + key_echo is set to one, typed punctuation is still spoken as it + is typed. + +What: /sys/accessibility/speakup/punc_most +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This is a list of all the punctuation speakup should speak when + punc_level is set to two. + +What: /sys/accessibility/speakup/punc_some +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This is a list of all the punctuation speakup should speak when + punc_level is set to one. + +What: /sys/accessibility/speakup/reading_punc +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Almost the same as punc_level, the differences being that + reading_punc controls the level of punctuation when reviewing + the screen with speakup's screen review commands. The other + difference is that reading_punc set to three speaks punc_all, + and reading_punc set to four speaks all punctuation, including + spaces. + +What: /sys/accessibility/speakup/repeats +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: A list of characters speakup repeats. Normally, when there are + more than three characters in a row, speakup + just reads three of + those characters. For example, "......" would be read as dot, + dot, dot. If a . is added to the list of characters in repeats, + "......" would be read as dot, dot, dot, times six. + +What: /sys/accessibility/speakup/say_control +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: If set to one, speakup speaks shift, alt and control when those + keys are pressed. If say_control is set to zero, shift, ctrl, + and alt are not spoken when they are pressed. + +What: /sys/accessibility/speakup/say_word_ctl +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: TODO: + +What: /sys/accessibility/speakup/silent +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: TODO: + +What: /sys/accessibility/speakup/spell_delay +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This controls how fast a word is spelled + when speakup's say word + review command is pressed twice quickly to speak the current + word being reviewed. Zero just speaks the letters one after + another, while values one through four + seem to introduce more of + a pause between the spelling of each letter by speakup. + +What: /sys/accessibility/speakup/synth +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Gets or sets the synthesizer driver currently in use. Reading + synth returns the synthesizer driver currently in use. Writing + synth switches to the given synthesizer driver, provided it is + either built into the kernel, or already loaded as a module. + +What: /sys/accessibility/speakup/synth_direct +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Sends whatever is written to synth_direct + directly to the speech synthesizer in use, bypassing speakup. + This could be used to make the synthesizer speak + a string, or to + send control sequences to the synthesizer to change how the + synthesizer behaves. + +What: /sys/accessibility/speakup/version +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Reading version returns the version of speakup, and the version + of the synthesizer driver currently in use. + +What: /sys/accessibility/speakup/i18n/announcements +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This file contains various general announcements, most of which + cannot be categorized. You will find messages such as "You + killed Speakup", "I'm alive", "leaving help", "parked", + "unparked", and others. You will also find the names of the + screen edges and cursor tracking modes here. + +What: /sys/accessibility/speakup/i18n/chartab +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: TODO + +What: /sys/accessibility/speakup/i18n/ctl_keys +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Here, you will find names of control keys. These are used with + Speakup's say_control feature. + +What: /sys/accessibility/speakup/i18n/function_names +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Here, you will find a list of names for Speakup functions. + These are used by the help system. For example, suppose that + you have activated help mode, and you pressed + keypad 3. Speakup + says: "keypad 3 is character, say next." + The message "character, say next" names a Speakup function, and + it comes from this function_names file. + +What: /sys/accessibility/speakup/i18n/states +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This file contains names for key states. + Again, these are part of the help system. For instance, if you + had pressed speakup + keypad 3, you would hear: + "speakup keypad 3 is go to bottom edge." + The speakup key is depressed, so the name of the key state is + speakup. + This part of the message comes from the states collection. + +What: /sys/accessibility/speakup/i18n/characters +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Through this sys entry, Speakup gives you the ability to change + how Speakup pronounces a given character. You could, for + example, change how some punctuation characters are spoken. You + can even change how Speakup will pronounce certain letters. For + further details see '12. Changing the Pronunciation of + Characters' in Speakup User's Guide (file spkguide.txt in + source). + +What: /sys/accessibility/speakup/i18n/colors +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: When you use the "say attributes" function, Speakup says the + name of the foreground and background colors. These names come + from the i18n/colors file. + +What: /sys/accessibility/speakup/i18n/formatted +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This group of messages contains embedded formatting codes, to + specify the type and width of displayed data. If you change + these, you must preserve all of the formatting codes, and they + must appear in the order used by the default messages. + +What: /sys/accessibility/speakup/i18n/key_names +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Again, key_names is used by Speakup's help system. In the + previous example, Speakup said that you pressed "keypad 3." + This name came from the key_names file. + +What: /sys/accessibility/speakup// +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: In `/sys/accessibility/speakup` is a directory corresponding to + the synthesizer driver currently in use (E.G) `soft` for the + soft driver. This directory contains files which control the + speech synthesizer itself, + as opposed to controlling the speakup + screen reader. The parameters in this directory have the same + names and functions across all + supported synthesizers. The range + of values for freq, pitch, rate, and vol is the same for all + supported synthesizers, with the given range being internally + mapped by the driver to more or less fit the range of values + supported for a given parameter by the individual synthesizer. + Below is a description of values and parameters for soft + synthesizer, which is currently the most commonly used. + +What: /sys/accessibility/speakup/soft/caps_start +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This is the string that is sent to the synthesizer to cause it + to start speaking uppercase letters. For the soft synthesizer + and most others, this causes the pitch of the voice to rise + above the currently set pitch. + +What: /sys/accessibility/speakup/soft/caps_stop +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This is the string sent to the synthesizer to cause it to stop + speaking uppercase letters. In the case of the soft synthesizer + and most others, this returns the pitch of the voice + down to the + currently set pitch. + +What: /sys/accessibility/speakup/soft/delay_time +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: TODO: + +What: /sys/accessibility/speakup/soft/direct +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Controls if punctuation is spoken by speakup, or by the + synthesizer. + For example, speakup speaks ">" as "greater", while + the espeak synthesizer used by the soft driver speaks "greater + than". Zero lets speakup speak the punctuation. One lets the + synthesizer itself speak punctuation. + +What: /sys/accessibility/speakup/soft/freq +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Gets or sets the frequency of the speech synthesizer. Range is + 0-9. + +What: /sys/accessibility/speakup/soft/full_time +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: TODO: + +What: /sys/accessibility/speakup/soft/jiffy_delta +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: This controls how many jiffys the kernel gives to the + synthesizer. Setting this too high can make a system unstable, + or even crash it. + +What: /sys/accessibility/speakup/soft/pitch +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Gets or sets the pitch of the synthesizer. The range is 0-9. + +What: /sys/accessibility/speakup/soft/inflection +KernelVersion: 5.8 +Contact: speakup@linux-speakup.org +Description: Gets or sets the inflection of the synthesizer, i.e. the pitch + range. The range is 0-9. + +What: /sys/accessibility/speakup/soft/punct +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Gets or sets the amount of punctuation spoken by the + synthesizer. The range for the soft driver seems to be 0-2. + TODO: How is this related to speakup's punc_level, or + reading_punc. + +What: /sys/accessibility/speakup/soft/rate +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Gets or sets the rate of the synthesizer. Range is from zero + slowest, to nine fastest. + +What: /sys/accessibility/speakup/soft/tone +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Gets or sets the tone of the speech synthesizer. The range for + the soft driver seems to be 0-2. This seems to make no + difference if using espeak and the espeakup connector. + TODO: does espeakup support different tonalities? + +What: /sys/accessibility/speakup/soft/trigger_time +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: TODO: + +What: /sys/accessibility/speakup/soft/voice +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Gets or sets the voice used by the synthesizer if the + synthesizer can speak in more than one voice. The range for the + soft driver is 0-7. Note that while espeak supports multiple + voices, this parameter will not set the voice when the espeakup + connector is used between speakup and espeak. + +What: /sys/accessibility/speakup/soft/vol +KernelVersion: 2.6 +Contact: speakup@linux-speakup.org +Description: Gets or sets the volume of the speech synthesizer. Range is 0-9, + with zero being the softest, and nine being the loudest. + diff --git a/Documentation/admin-guide/spkguide.txt b/Documentation/admin-guide/spkguide.txt new file mode 100644 index 000000000000..3782f6a09e97 --- /dev/null +++ b/Documentation/admin-guide/spkguide.txt @@ -0,0 +1,1575 @@ + +The Speakup User's Guide +For Speakup 3.1.2 and Later +By Gene Collins +Updated by others +Last modified on Mon Sep 27 14:26:31 2010 +Document version 1.3 + +Copyright (c) 2005 Gene Collins +Copyright (c) 2008 Samuel Thibault +Copyright (c) 2009, 2010 the Speakup Team + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.2 or +any later version published by the Free Software Foundation; with no +Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A +copy of the license is included in the section entitled "GNU Free +Documentation License". + +Preface + +The purpose of this document is to familiarize users with the user +interface to Speakup, a Linux Screen Reader. If you need instructions +for installing or obtaining Speakup, visit the web site at +http://linux-speakup.org/. Speakup is a set of patches to the standard +Linux kernel source tree. It can be built as a series of modules, or as +a part of a monolithic kernel. These details are beyond the scope of +this manual, but the user may need to be aware of the module +capabilities, depending on how your system administrator has installed +Speakup. If Speakup is built as a part of a monolithic kernel, and the +user is using a hardware synthesizer, then Speakup will be able to +provide speech access from the time the kernel is loaded, until the time +the system is shutdown. This means that if you have obtained Linux +installation media for a distribution which includes Speakup as a part +of its kernel, you will be able, as a blind person, to install Linux +with speech access unaided by a sighted person. Again, these details +are beyond the scope of this manual, but the user should be aware of +them. See the web site mentioned above for further details. + +1. Starting Speakup + +If your system administrator has installed Speakup to work with your +specific synthesizer by default, then all you need to do to use Speakup +is to boot your system, and Speakup should come up talking. This +assumes of course that your synthesizer is a supported hardware +synthesizer, and that it is either installed in or connected to your +system, and is if necessary powered on. + +It is possible, however, that Speakup may have been compiled into the +kernel with no default synthesizer. It is even possible that your +kernel has been compiled with support for some of the supported +synthesizers and not others. If you find that this is the case, and +your synthesizer is supported but not available, complain to the person +who compiled and installed your kernel. Or better yet, go to the web +site, and learn how to patch Speakup into your own kernel source, and +build and install your own kernel. + +If your kernel has been compiled with Speakup, and has no default +synthesizer set, or you would like to use a different synthesizer than +the default one, then you may issue the following command at the boot +prompt of your boot loader. + +linux speakup.synth=ltlk + +This command would tell Speakup to look for and use a LiteTalk or +DoubleTalk LT at boot up. You may replace the ltlk synthesizer keyword +with the keyword for whatever synthesizer you wish to use. The +speakup.synth parameter will accept the following keywords, provided +that support for the related synthesizers has been built into the +kernel. + +acntsa -- Accent SA +acntpc -- Accent PC +apollo -- Apollo +audptr -- Audapter +bns -- Braille 'n Speak +dectlk -- DecTalk Express (old and new, db9 serial only) +decext -- DecTalk (old) External +dtlk -- DoubleTalk PC +keypc -- Keynote Gold PC +ltlk -- DoubleTalk LT, LiteTalk, or external Tripletalk (db9 serial only) +spkout -- Speak Out +txprt -- Transport +dummy -- Plain text terminal + +Note: Speakup does * NOT * support usb connections! Speakup also does * +NOT * support the internal Tripletalk! + +Speakup does support two other synthesizers, but because they work in +conjunction with other software, they must be loaded as modules after +their related software is loaded, and so are not available at boot up. +These are as follows: + +decpc -- DecTalk PC (not available at boot up) +soft -- One of several software synthesizers (not available at boot up) + +See the sections on loading modules and software synthesizers later in +this manual for further details. It should be noted here that the +speakup.synth boot parameter will have no effect if Speakup has been +compiled as modules. In order for Speakup modules to be loaded during +the boot process, such action must be configured by your system +administrator. This will mean that you will hear some, but not all, of +the bootup messages. + +2. Basic operation + +Once you have booted the system, and if necessary, have supplied the +proper bootup parameter for your synthesizer, Speakup will begin +talking as soon as the kernel is loaded. In fact, it will talk a lot! +It will speak all the boot up messages that the kernel prints on the +screen during the boot process. This is because Speakup is not a +separate screen reader, but is actually built into the operating +system. Since almost all console applications must print text on the +screen using the kernel, and must get their keyboard input through the +kernel, they are automatically handled properly by Speakup. There are a +few exceptions, but we'll come to those later. + +Note: In this guide I will refer to the numeric keypad as the keypad. +This is done because the speakupmap.map file referred to later in this +manual uses the term keypad instead of numeric keypad. Also I'm lazy +and would rather only type one word. So keypad it is. Got it? Good. + +Most of the Speakup review keys are located on the keypad at the far +right of the keyboard. The numlock key should be off, in order for these +to work. If you toggle the numlock on, the keypad will produce numbers, +which is exactly what you want for spreadsheets and such. For the +purposes of this guide, you should have the numlock turned off, which is +its default state at bootup. + +You probably won't want to listen to all the bootup messages every time +you start your system, though it's a good idea to listen to them at +least once, just so you'll know what kind of information is available to +you during the boot process. You can always review these messages after +bootup with the command: + +dmesg | more + +In order to speed the boot process, and to silence the speaking of the +bootup messages, just press the keypad enter key. This key is located +in the bottom right corner of the keypad. Speakup will shut up and stay +that way, until you press another key. + +You can check to see if the boot process has completed by pressing the 8 +key on the keypad, which reads the current line. This also has the +effect of starting Speakup talking again, so you can press keypad enter +to silence it again if the boot process has not completed. + +When the boot process is complete, you will arrive at a "login" prompt. +At this point, you'll need to type in your user id and password, as +provided by your system administrator. You will hear Speakup speak the +letters of your user id as you type it, but not the password. This is +because the password is not displayed on the screen for security +reasons. This has nothing to do with Speakup, it's a Linux security +feature. + +Once you've logged in, you can run any Linux command or program which is +allowed by your user id. Normal users will not be able to run programs +which require root privileges. + +When you are running a program or command, Speakup will automatically +speak new text as it arrives on the screen. You can at any time silence +the speech with keypad enter, or use any of the Speakup review keys. + +Here are some basic Speakup review keys, and a short description of what +they do. + +keypad 1 -- read previous character +keypad 2 -- read current character (pressing keypad 2 twice rapidly will speak + the current character phonetically) +keypad 3 -- read next character +keypad 4 -- read previous word +keypad 5 -- read current word (press twice rapidly to spell the current word) +keypad 6 -- read next word +keypad 7 -- read previous line +keypad 8 -- read current line (press twice rapidly to hear how much the + text on the current line is indented) +keypad 9 -- read next line +keypad period -- speak current cursor position and announce current + virtual console + +It's also worth noting that the insert key on the keypad is mapped +as the speakup key. Instead of pressing and releasing this key, as you +do under DOS or Windows, you hold it like a shift key, and press other +keys in combination with it. For example, repeatedly holding keypad +insert, from now on called speakup, and keypad enter will toggle the +speaking of new text on the screen on and off. This is not the same as +just pressing keypad enter by itself, which just silences the speech +until you hit another key. When you hit speakup plus keypad enter, +Speakup will say, "You turned me off.", or "Hey, that's better." When +Speakup is turned off, no new text on the screen will be spoken. You +can still use the reading controls to review the screen however. + +3. Using the Speakup Help System + +In order to enter the Speakup help system, press and hold the speakup +key (remember that this is the keypad insert key), and press the f1 key. +You will hear the message: + +"Press space to leave help, cursor up or down to scroll, or a letter to +go to commands in list." + +When you press the spacebar to leave the help system, you will hear: + +"Leaving help." + +While you are in the Speakup help system, you can scroll up or down +through the list of available commands using the cursor keys. The list +of commands is arranged in alphabetical order. If you wish to jump to +commands in a specific part of the alphabet, you may press the letter of +the alphabet you wish to jump to. + +You can also just explore by typing keyboard keys. Pressing keys will +cause Speakup to speak the command associated with that key. For +example, if you press the keypad 8 key, you will hear: + +"Keypad 8 is line, say current." + +You'll notice that some commands do not have keys assigned to them. +This is because they are very infrequently used commands, and are also +accessible through the sys system. We'll discuss the sys system later +in this manual. + +You'll also notice that some commands have two keys assigned to them. +This is because Speakup has a built in set of alternative key bindings +for laptop users. The alternate speakup key is the caps lock key. You +can press and hold the caps lock key, while pressing an alternate +speakup command key to activate the command. On most laptops, the +numeric keypad is defined as the keys in the j k l area of the keyboard. + +There is usually a function key which turns this keypad function on and +off, and some other key which controls the numlock state. Toggling the +keypad functionality on and off can become a royal pain. So, Speakup +gives you a simple way to get at an alternative set of key mappings for +your laptop. These are also available by default on desktop systems, +because Speakup does not know whether it is running on a desktop or +laptop. So you may choose which set of Speakup keys to use. Some +system administrators may have chosen to compile Speakup for a desktop +system without this set of alternate key bindings, but these details are +beyond the scope of this manual. To use the caps lock for its normal +purpose, hold the shift key while toggling the caps lock on and off. We +should note here, that holding the caps lock key and pressing the z key +will toggle the alternate j k l keypad on and off. + +4. Keys and Their Assigned Commands + +In this section, we'll go through a list of all the speakup keys and +commands. You can also get a list of commands and assigned keys from +the help system. + +The following list was taken from the speakupmap.map file. Key +assignments are on the left of the equal sign, and the associated +Speakup commands are on the right. The designation "spk" means to press +and hold the speakup key, a.k.a. keypad insert, a.k.a. caps lock, while +pressing the other specified key. + +spk key_f9 = punc_level_dec +spk key_f10 = punc_level_inc +spk key_f11 = reading_punc_dec +spk key_f12 = reading_punc_inc +spk key_1 = vol_dec +spk key_2 = vol_inc +spk key_3 = pitch_dec +spk key_4 = pitch_inc +spk key_5 = rate_dec +spk key_6 = rate_inc +key_kpasterisk = toggle_cursoring +spk key_kpasterisk = speakup_goto +spk key_f1 = speakup_help +spk key_f2 = set_win +spk key_f3 = clear_win +spk key_f4 = enable_win +spk key_f5 = edit_some +spk key_f6 = edit_most +spk key_f7 = edit_delim +spk key_f8 = edit_repeat +shift spk key_f9 = edit_exnum + key_kp7 = say_prev_line +spk key_kp7 = left_edge + key_kp8 = say_line +double key_kp8 = say_line_indent +spk key_kp8 = say_from_top + key_kp9 = say_next_line +spk key_kp9 = top_edge + key_kpminus = speakup_parked +spk key_kpminus = say_char_num + key_kp4 = say_prev_word +spk key_kp4 = say_from_left + key_kp5 = say_word +double key_kp5 = spell_word +spk key_kp5 = spell_phonetic + key_kp6 = say_next_word +spk key_kp6 = say_to_right + key_kpplus = say_screen +spk key_kpplus = say_win + key_kp1 = say_prev_char +spk key_kp1 = right_edge + key_kp2 = say_char +spk key_kp2 = say_to_bottom +double key_kp2 = say_phonetic_char + key_kp3 = say_next_char +spk key_kp3 = bottom_edge + key_kp0 = spk_key + key_kpdot = say_position +spk key_kpdot = say_attributes +key_kpenter = speakup_quiet +spk key_kpenter = speakup_off +key_sysrq = speech_kill + key_kpslash = speakup_cut +spk key_kpslash = speakup_paste +spk key_pageup = say_first_char +spk key_pagedown = say_last_char +key_capslock = spk_key + spk key_z = spk_lock +key_leftmeta = spk_key +ctrl spk key_0 = speakup_goto +spk key_u = say_prev_line +spk key_i = say_line +double spk key_i = say_line_indent +spk key_o = say_next_line +spk key_minus = speakup_parked +shift spk key_minus = say_char_num +spk key_j = say_prev_word +spk key_k = say_word +double spk key_k = spell_word +spk key_l = say_next_word +spk key_m = say_prev_char +spk key_comma = say_char +double spk key_comma = say_phonetic_char +spk key_dot = say_next_char +spk key_n = say_position + ctrl spk key_m = left_edge + ctrl spk key_y = top_edge + ctrl spk key_dot = right_edge +ctrl spk key_p = bottom_edge +spk key_apostrophe = say_screen +spk key_h = say_from_left +spk key_y = say_from_top +spk key_semicolon = say_to_right +spk key_p = say_to_bottom +spk key_slash = say_attributes + spk key_enter = speakup_quiet + ctrl spk key_enter = speakup_off + spk key_9 = speakup_cut +spk key_8 = speakup_paste +shift spk key_m = say_first_char + ctrl spk key_semicolon = say_last_char + +5. The Speakup Sys System + +The Speakup screen reader also creates a speakup subdirectory as a part +of the sys system. + +As a convenience, run as root + +ln -s /sys/accessibility/speakup /speakup + +to directly access speakup parameters from /speakup. +You can see these entries by typing the command: + +ls -1 /speakup/* + +If you issue the above ls command, you will get back something like +this: + +/speakup/attrib_bleep +/speakup/bell_pos +/speakup/bleep_time +/speakup/bleeps +/speakup/cursor_time +/speakup/delimiters +/speakup/ex_num +/speakup/key_echo +/speakup/keymap +/speakup/no_interrupt +/speakup/punc_all +/speakup/punc_level +/speakup/punc_most +/speakup/punc_some +/speakup/reading_punc +/speakup/repeats +/speakup/say_control +/speakup/say_word_ctl +/speakup/silent +/speakup/spell_delay +/speakup/synth +/speakup/synth_direct +/speakup/version + +/speakup/i18n: +announcements +characters +chartab +colors +ctl_keys +formatted +function_names +key_names +states + +/speakup/soft: +caps_start +caps_stop +delay_time +direct +freq +full_time +jiffy_delta +pitch +inflection +punct +rate +tone +trigger_time +voice +vol + +Notice the two subdirectories of /speakup: /speakup/i18n and +/speakup/soft. +The i18n subdirectory is described in a later section. +The files under /speakup/soft represent settings that are specific to the +driver for the software synthesizer. If you use the LiteTalk, your +synthesizer-specific settings would be found in /speakup/ltlk. In other words, +a subdirectory named /speakup/KWD is created to hold parameters specific +to the device whose keyword is KWD. +These parameters include volume, rate, pitch, and others. + +In addition to using the Speakup hot keys to change such things as +volume, pitch, and rate, you can also echo values to the appropriate +entry in the /speakup directory. This is very useful, since it +lets you control Speakup parameters from within a script. How you +would write such scripts is somewhat beyond the scope of this manual, +but I will include a couple of simple examples here to give you a +general idea of what such scripts can do. + +Suppose for example, that you wanted to control both the punctuation +level and the reading punctuation level at the same time. For +simplicity, we'll call them punc0, punc1, punc2, and punc3. The scripts +might look something like this: + +#!/bin/bash +# punc0 +# set punc and reading punc levels to 0 +echo 0 >/speakup/punc_level +echo 0 >/speakup/reading_punc +echo Punctuation level set to 0. + +#!/bin/bash +# punc1 +# set punc and reading punc levels to 1 +echo 1 >/speakup/punc_level +echo 1 >/speakup/reading_punc +echo Punctuation level set to 1. + +#!/bin/bash +# punc2 +# set punc and reading punc levels to 2 +echo 2 >/speakup/punc_level +echo 2 >/speakup/reading_punc +echo Punctuation level set to 2. + +#!/bin/bash +# punc3 +# set punc and reading punc levels to 3 +echo 3 >/speakup/punc_level +echo 3 >/speakup/reading_punc +echo Punctuation level set to 3. + +If you were to store these four small scripts in a directory in your +path, perhaps /usr/local/bin, and set the permissions to 755 with the +chmod command, then you could change the default reading punc and +punctuation levels at the same time by issuing just one command. For +example, if you were to execute the punc3 command at your shell prompt, +then the reading punc and punc level would both get set to 3. + +I should note that the above scripts were written to work with bash, but +regardless of which shell you use, you should be able to do something +similar. + +The Speakup sys system also has another interesting use. You can echo +Speakup parameters into the sys system in a script during system +startup, and speakup will return to your preferred parameters every time +the system is rebooted. + +Most of the Speakup sys parameters can be manipulated by a regular user +on the system. However, there are a few parameters that are dangerous +enough that they should only be manipulated by the root user on your +system. There are even some parameters that are read only, and cannot +be written to at all. For example, the version entry in the Speakup +sys system is read only. This is because there is no reason for a user +to tamper with the version number which is reported by Speakup. Doing +an ls -l on /speakup/version will return this: + +-r--r--r-- 1 root root 0 Mar 21 13:46 /speakup/version + +As you can see, the version entry in the Speakup sys system is read +only, is owned by root, and belongs to the root group. Doing a cat of +/speakup/version will display the Speakup version number, like +this: + +cat /speakup/version +Speakup v-2.00 CVS: Thu Oct 21 10:38:21 EDT 2004 +synth dtlk version 1.1 + +The display shows the Speakup version number, along with the version +number of the driver for the current synthesizer. + +Looking at entries in the Speakup sys system can be useful in many +ways. For example, you might wish to know what level your volume is set +at. You could type: + +cat /speakup/KWD/vol +# Replace KWD with the keyword for your synthesizer, E.G., ltlk for LiteTalk. +5 + +The number five which comes back is the level at which the synthesizer +volume is set at. + +All the entries in the Speakup sys system are readable, some are +writable by root only, and some are writable by everyone. Unless you +know what you are doing, you should probably leave the ones that are +writable by root only alone. Most of the names are self explanatory. +Vol for controlling volume, pitch for pitch, inflection for pitch range, rate +for controlling speaking rate, etc. If you find one you aren't sure about, you +can post a query on the Speakup list. + +6. Changing Synthesizers + +It is possible to change to a different synthesizer while speakup is +running. In other words, it is not necessary to reboot the system +in order to use a different synthesizer. You can simply echo the +synthesizer keyword to the /speakup/synth sys entry. +Depending on your situation, you may wish to echo none to the synth +sys entry, to disable speech while one synthesizer is disconnected and +a second one is connected in its place. Then echo the keyword for the +new synthesizer into the synth sys entry in order to start speech +with the newly connected synthesizer. See the list of synthesizer +keywords in section 1 to find the keyword which matches your synth. + +7. Loading modules + +As mentioned earlier, Speakup can either be completely compiled into the +kernel, with the exception of the help module, or it can be compiled as +a series of modules. When compiled as modules, Speakup will only be +able to speak some of the bootup messages if your system administrator +has configured the system to load the modules at boo time. The modules +can be loaded after the file systems have been checked and mounted, or +from an initrd. There is a third possibility. Speakup can be compiled +with some components built into the kernel, and others as modules. As +we'll see in the next section, this is particularly useful when you are +working with software synthesizers. + +If Speakup is completely compiled as modules, then you must use the +modprobe command to load Speakup. You do this by loading the module for +the synthesizer driver you wish to use. The driver modules are all +named speakup_, where is the keyword for the +synthesizer you want. So, in order to load the driver for the DecTalk +Express, you would type the following command: + +modprobe speakup_dectlk + +Issuing this command would load the DecTalk Express driver and all other +related Speakup modules necessary to get Speakup up and running. + +To completely unload Speakup, again presuming that it is entirely built +as modules, you would give the command: + +modprobe -r speakup_dectlk + +The above command assumes you were running a DecTalk Express. If you +were using a different synth, then you would substitute its keyword in +place of dectlk. + +If you have multiple drivers loaded, you need to unload all of them, in +order to completely unload Speakup. +For example, if you have loaded both the dectlk and ltlk drivers, use the +command: +modprobe -r speakup_dectlk speakup_ltlk + +You cannot unload the driver for software synthesizers when a user-space +daemon is using /dev/softsynth. First, kill the daemon. Next, remove +the driver with the command: +modprobe -r speakup_soft + +Now, suppose we have a situation where the main Speakup component +is built into the kernel, and some or all of the drivers are built as +modules. Since the main part of Speakup is compiled into the kernel, a +partial Speakup sys system has been created which we can take advantage +of by simply echoing the synthesizer keyword into the +/speakup/synth sys entry. This will cause the kernel to +automatically load the appropriate driver module, and start Speakup +talking. To switch to another synth, just echo a new keyword to the +synth sys entry. For example, to load the DoubleTalk LT driver, +you would type: + +echo ltlk >/speakup/synth + +You can use the modprobe -r command to unload driver modules, regardless +of whether the main part of Speakup has been built into the kernel or +not. + +8. Using Software Synthesizers + +Using a software synthesizer requires that some other software be +installed and running on your system. For this reason, software +synthesizers are not available for use at bootup, or during a system +installation process. +There are two freely-available solutions for software speech: Espeakup and +Speech Dispatcher. +These are described in subsections 8.1 and 8.2, respectively. + +During the rest of this section, we assume that speakup_soft is either +built in to your kernel, or loaded as a module. + +If your system does not have udev installed , before you can use a +software synthesizer, you must have created the /dev/softsynth device. +If you have not already done so, issue the following commands as root: + +cd /dev +mknod softsynth c 10 26 + +While we are at it, we might just as well create the /dev/synth device, +which can be used to let user space programs send information to your +synthesizer. To create /dev/synth, change to the /dev directory, and +issue the following command as root: + +mknod synth c 10 25 + +of both. + +8.1. Espeakup + +Espeakup is a connector between Speakup and the eSpeak software synthesizer. +Espeakup may already be available as a package for your distribution +of Linux. If it is not packaged, you need to install it manually. +You can find it in the contrib/ subdirectory of the Speakup sources. +The filename is espeakup-$VERSION.tar.bz2, where $VERSION +depends on the current release of Espeakup. The Speakup 3.1.2 source +ships with version 0.71 of Espeakup. +The README file included with the Espeakup sources describes the process +of manual installation. + +Assuming that Espeakup is installed, either by the user or by the distributor, +follow these steps to use it. + +Tell Speakup to use the "soft driver: +echo soft > /speakup/synth + +Finally, start the espeakup program. There are two ways to do it. +Both require root privileges. + +If Espeakup was installed as a package for your Linux distribution, +you probably have a distribution-specific script that controls the operation +of the daemon. Look for a file named espeakup under /etc/init.d or +/etc/rc.d. Execute the following command with root privileges: +/etc/init.d/espeakup start +Replace init.d with rc.d, if your distribution uses scripts located under +/etc/rc.d. +Your distribution will also have a procedure for starting daemons at +boot-time, so it is possible to have software speech as soon as user-space +daemons are started by the bootup scripts. +These procedures are not described in this document. + +If you built Espeakup manually, the "make install" step placed the binary +under /usr/bin. +Run the following command as root: +/usr/bin/espeakup +Espeakup should start speaking. + +8.2. Speech Dispatcher + +For this option, you must have a package called +Speech Dispatcher running on your system, and it must be configured to +work with one of its supported software synthesizers. + +Two open source synthesizers you might use are Flite and Festival. You +might also choose to purchase the Software DecTalk from Fonix Sales Inc. +If you run a google search for Fonix, you'll find their web site. + +You can obtain a copy of Speech Dispatcher from free(b)soft at +http://www.freebsoft.org/. Follow the installation instructions that +come with Speech Dispatcher in order to install and configure Speech +Dispatcher. You can check out the web site for your Linux distribution +in order to get a copy of either Flite or Festival. Your Linux +distribution may also have a precompiled Speech Dispatcher package. + +Once you've installed, configured, and tested Speech Dispatcher with your +chosen software synthesizer, you still need one more piece of software +in order to make things work. You need a package called speechd-up. +You get it from the free(b)soft web site mentioned above. After you've +compiled and installed speechd-up, you are almost ready to begin using +your software synthesizer. + +Now you can begin using your software synthesizer. In order to do so, +echo the soft keyword to the synth sys entry like this: + +echo soft >/speakup/synth + +Next run the speechd_up command like this: + +speechd_up & + +Your synth should now start talking, and you should be able to adjust +the pitch, rate, etc. + +9. Using The DecTalk PC Card + +The DecTalk PC card is an ISA card that is inserted into one of the ISA +slots in your computer. It requires that the DecTalk PC software be +installed on your computer, and that the software be loaded onto the +Dectalk PC card before it can be used. + +You can get the dec_pc.tgz file from the linux-speakup.org site. The +dec_pc.tgz file is in the ~ftp/pub/linux/speakup directory. + +After you have downloaded the dec_pc.tgz file, untar it in your home +directory, and read the Readme file in the newly created dec_pc +directory. + +The easiest way to get the software working is to copy the entire dec_pc +directory into /user/local/lib. To do this, su to root in your home +directory, and issue the command: + +cp dec_pc /usr/local/lib + +You will need to copy the dtload command from the dec_pc directory to a +directory in your path. Either /usr/bin or /usr/local/bin is a good +choice. + +You can now run the dtload command in order to load the DecTalk PC +software onto the card. After you have done this, echo the decpc +keyword to the synth entry in the sys system like this: + +echo decpc >/speakup/synth + +Your DecTalk PC should start talking, and then you can adjust the pitch, +rate, volume, voice, etc. The voice entry in the Speakup sys system +will accept a number from 0 through 7 for the DecTalk PC synthesizer, +which will give you access to some of the DecTalk voices. + +10. Using Cursor Tracking + +In Speakup version 2.0 and later, cursor tracking is turned on by +default. This means that when you are using an editor, Speakup will +automatically speak characters as you move left and right with the +cursor keys, and lines as you move up and down with the cursor keys. +This is the traditional sort of cursor tracking. +Recent versions of Speakup provide two additional ways to control the +text that is spoken when the cursor is moved: +"highlight tracking" and "read window." +They are described later in this section. +Sometimes, these modes get in your way, so you can disable cursor tracking +altogether. + +You may select among the various forms of cursor tracking using the keypad +asterisk key. +Each time you press this key, a new mode is selected, and Speakup speaks +the name of the new mode. The names for the four possible states of cursor +tracking are: "cursoring on", "highlight tracking", "read window", +and "cursoring off." The keypad asterisk key moves through the list of +modes in a circular fashion. + +If highlight tracking is enabled, Speakup tracks highlighted text, +rather than the cursor itself. When you move the cursor with the arrow keys, +Speakup speaks the currently highlighted information. +This is useful when moving through various menus and dialog boxes. +If cursor tracking isn't helping you while navigating a menu, +try highlight tracking. + +With the "read window" variety of cursor tracking, you can limit the text +that Speakup speaks by specifying a window of interest on the screen. +See section 15 for a description of the process of defining windows. +When you move the cursor via the arrow keys, Speakup only speaks +the contents of the window. This is especially helpful when you are hearing +superfluous speech. Consider the following example. + +Suppose that you are at a shell prompt. You use bash, and you want to +explore your command history using the up and down arrow keys. If you +have enabled cursor tracking, you will hear two pieces of information. +Speakup speaks both your shell prompt and the current entry from the +command history. You may not want to hear the prompt repeated +each time you move, so you can silence it by specifying a window. Find +the last line of text on the screen. Clear the current window by pressing +the key combination speakup f3. Use the review cursor to find the first +character that follows your shell prompt. Press speakup + f2 twice, to +define a one-line window. The boundaries of the window are the +character following the shell prompt and the end of the line. Now, cycle +through the cursor tracking modes using keypad asterisk, until Speakup +says "read window." Move through your history using your arrow keys. +You will notice that Speakup no longer speaks the redundant prompt. + +Some folks like to turn cursor tracking off while they are using the +lynx web browser. You definitely want to turn cursor tracking off when +you are using the alsamixer application. Otherwise, you won't be able +to hear your mixer settings while you are using the arrow keys. + +11. Cut and Paste + +One of Speakup's more useful features is the ability to cut and paste +text on the screen. This means that you can capture information from a +program, and paste that captured text into a different place in the +program, or into an entirely different program, which may even be +running on a different console. + +For example, in this manual, we have made references to several web +sites. It would be nice if you could cut and paste these urls into your +web browser. Speakup does this quite nicely. Suppose you wanted to +past the following url into your browser: + +http://linux-speakup.org/ + +Use the speakup review keys to position the reading cursor on the first +character of the above url. When the reading cursor is in position, +press the keypad slash key once. Speakup will say, "mark". Next, +position the reading cursor on the rightmost character of the above +url. Press the keypad slash key once again to actually cut the text +from the screen. Speakup will say, "cut". Although we call this +cutting, Speakup does not actually delete the cut text from the screen. +It makes a copy of the text in a special buffer for later pasting. + +Now that you have the url cut from the screen, you can paste it into +your browser, or even paste the url on a command line as an argument to +your browser. + +Suppose you want to start lynx and go to the Speakup site. + +You can switch to a different console with the alt left and right +arrows, or you can switch to a specific console by typing alt and a +function key. These are not Speakup commands, just standard Linux +console capabilities. + +Once you've changed to an appropriate console, and are at a shell prompt, +type the word lynx, followed by a space. Now press and hold the speakup +key, while you type the keypad slash character. The url will be pasted +onto the command line, just as though you had typed it in. Press the +enter key to execute the command. + +The paste buffer will continue to hold the cut information, until a new +mark and cut operation is carried out. This means you can paste the cut +information as many times as you like before doing another cut +operation. + +You are not limited to cutting and pasting only one line on the screen. +You can also cut and paste rectangular regions of the screen. Just +position the reading cursor at the top left corner of the text to be +cut, mark it with the keypad slash key, then position the reading cursor +at the bottom right corner of the region to be cut, and cut it with the +keypad slash key. + +12. Changing the Pronunciation of Characters + +Through the /speakup/i18n/characters sys entry, Speakup gives you the +ability to change how Speakup pronounces a given character. You could, +for example, change how some punctuation characters are spoken. You can +even change how Speakup will pronounce certain letters. + +You may, for example, wish to change how Speakup pronounces the z +character. The author of Speakup, Kirk Reiser, is Canadian, and thus +believes that the z should be pronounced zed. If you are an American, +you might wish to use the zee pronunciation instead of zed. You can +change the pronunciation of both the upper and lower case z with the +following two commands: + +echo 90 zee >/speakup/characters +echo 122 zee >/speakup/characters + +Let's examine the parts of the two previous commands. They are issued +at the shell prompt, and could be placed in a startup script. + +The word echo tells the shell that you want to have it display the +string of characters that follow the word echo. If you were to just +type: + +echo hello. + +You would get the word hello printed on your screen as soon as you +pressed the enter key. In this case, we are echoing strings that we +want to be redirected into the sys system. + +The numbers 90 and 122 in the above echo commands are the ascii numeric +values for the upper and lower case z, the characters we wish to change. + +The string zee is the pronunciation that we want Speakup to use for the +upper and lower case z. + +The > symbol redirects the output of the echo command to a file, just +like in DOS, or at the Windows command prompt. + +And finally, /speakup/i18n/characters is the file entry in the sys system +where we want the output to be directed. Speakup looks at the numeric +value of the character we want to change, and inserts the pronunciation +string into an internal table. + +You can look at the whole table with the following command: + +cat /speakup/i18n/characters + +Speakup will then print out the entire character pronunciation table. I +won't display it here, but leave you to look at it at your convenience. + +13. Mapping Keys + +Speakup has the capability of allowing you to assign or "map" keys to +internal Speakup commands. This section necessarily assumes you have a +Linux kernel source tree installed, and that it has been patched and +configured with Speakup. How you do this is beyond the scope of this +manual. For this information, visit the Speakup web site at +http://linux-speakup.org/. The reason you'll need the kernel source +tree patched with Speakup is that the genmap utility you'll need for +processing keymaps is in the +/usr/src/linux-/drivers/char/speakup directory. The + in the above directory path is the version number of +the Linux source tree you are working with. + +So ok, you've gone off and gotten your kernel source tree, and patched +and configured it. Now you can start manipulating keymaps. + +You can either use the +/usr/src/linux-/drivers/char/speakup/speakupmap.map file +included with the Speakup source, or you can cut and paste the copy in +section 4 into a separate file. If you use the one in the Speakup +source tree, make sure you make a backup of it before you start making +changes. You have been warned! + +Suppose that you want to swap the key assignments for the Speakup +say_last_char and the Speakup say_first_char commands. The +speakupmap.map lists the key mappings for these two commands as follows: + +spk key_pageup = say_first_char +spk key_pagedown = say_last_char + +You can edit your copy of the speakupmap.map file and swap the command +names on the right side of the = (equals) sign. You did make a backup, +right? The new keymap lines would look like this: + +spk key_pageup = say_last_char +spk key_pagedown = say_first_char + +After you edit your copy of the speakupmap.map file, save it under a new +file name, perhaps newmap.map. Then exit your editor and return to the +shell prompt. + +You are now ready to load your keymap with your swapped key assignments. + Assuming that you saved your new keymap as the file newmap.map, you +would load your keymap into the sys system like this: + +/usr/src/linux-/drivers/char/speakup/genmap newmap.map +>/speakup/keymap + +Remember to substitute your kernel version number for the + in the above command. Also note that although the +above command wrapped onto two lines in this document, you should type +it all on one line. + +Your say first and say last characters should now be swapped. Pressing +speakup pagedown should read you the first non-whitespace character on +the line your reading cursor is in, and pressing speakup pageup should +read you the last character on the line your reading cursor is in. + +You should note that these new mappings will only stay in effect until +you reboot, or until you load another keymap. + +One final warning. If you try to load a partial map, you will quickly +find that all the mappings you didn't include in your file got deleted +from the working map. Be extremely careful, and always make a backup! +You have been warned! + +14. Internationalizing Speakup + +Speakup indicates various conditions to the user by speaking messages. +For instance, when you move to the left edge of the screen with the +review keys, Speakup says, "left." +Prior to version 3.1.0 of Speakup, all of these messages were in English, +and they could not be changed. If you used a non-English synthesizer, +you still heard English messages, such as "left" and "cursoring on." +In version 3.1.0 or higher, one may load translations for the various +messages via the /sys filesystem. + +The directory /speakup/i18n contains several collections of messages. +Each group of messages is stored in its own file. +The following section lists all of these files, along with a brief description +of each. + +14.1. Files Under the i18n Subdirectory + +* announcements: +This file contains various general announcements, most of which cannot +be categorized. You will find messages such as "You killed Speakup", +"I'm alive", "leaving help", "parked", "unparked", and others. +You will also find the names of the screen edges and cursor tracking modes +here. + +* characters: +See section 12 for a description of this file. + +* chartab: +See section 12. Unlike the rest of the files in the i18n subdirectory, +this one does not contain messages to be spoken. + +* colors: +When you use the "say attributes" function, Speakup says the name of the +foreground and background colors. These names come from the i18n/colors +file. + +* ctl_keys: +Here, you will find names of control keys. These are used with Speakup's +say_control feature. + +* formatted: +This group of messages contains embedded formatting codes, to specify +the type and width of displayed data. If you change these, you must +preserve all of the formatting codes, and they must appear in the order +used by the default messages. + +* function_names: +Here, you will find a list of names for Speakup functions. These are used +by the help system. For example, suppose that you have activated help mode, +and you pressed keypad 3. Speakup says: +"keypad 3 is character, say next." +The message "character, say next" names a Speakup function, and it +comes from this function_names file. + +* key_names: +Again, key_names is used by Speakup's help system. In the previous +example, Speakup said that you pressed "keypad 3." +This name came from the key_names file. + +* states: +This file contains names for key states. +Again, these are part of the help system. For instance, if you had pressed +speakup + keypad 3, you would hear: +"speakup keypad 3 is go to bottom edge." +The speakup key is depressed, so the name of the key state is speakup. +This part of the message comes from the states collection. + +14.2. Loading Your Own Messages + +The files under the i18n subdirectory all follow the same format. +They consist of lines, with one message per line. +Each message is represented by a number, followed by the text of the message. +The number is the position of the message in the given collection. +For example, if you view the file /speakup/i18n/colors, you will see the +following list: + +0 black +1 blue +2 green +3 cyan +4 red +5 magenta +6 yellow +7 white +8 grey + +You can change one message, or you can change a whole group. +To load a whole collection of messages from a new source, simply use +the cp command: +cp ~/my_colors /speakup/i18n/colors +You can change an individual message with the echo command, +as shown in the following example. + +The Spanish name for the color blue is azul. +Looking at the colors file, we see that the name "blue" is at position 1 +within the colors group. Let's change blue to azul: +echo '1 azul' > /speakup/i18n/colors +The next time that Speakup says message 1 from the colors group, it will +say "azul", rather than "blue." + +In the future, translations into various languages will be made available, +and most users will just load the files necessary for their language. + +14.3. No Support for Non-Western-European Languages + +As of the current release, Speakup only supports Western European languages. +Support for the extended characters used by languages outside of the Western +European family of languages is a work in progress. + +15. Using Speakup's Windowing Capability + +Speakup has the capability of defining and manipulating windows on the +screen. Speakup uses the term "Window", to mean a user defined area of +the screen. The key strokes for defining and manipulating Speakup +windows are as follows: + +speakup + f2 -- Set the bounds of the window. +Speakup + f3 -- clear the current window definition. +speakup + f4 -- Toggle window silence on and off. +speakup + keypad plus -- Say the currently defined window. + +These capabilities are useful for tracking a certain part of the screen +without rereading the whole screen, or for silencing a part of the +screen that is constantly changing, such as a clock or status line. + +There is no way to save these window settings, and you can only have one +window defined for each virtual console. There is also no way to have +windows automatically defined for specific applications. + +In order to define a window, use the review keys to move your reading +cursor to the beginning of the area you want to define. Then press +speakup + f2. Speakup will tell you that the window starts at the +indicated row and column position. Then move the reading cursor to the +end of the area to be defined as a window, and press speakup + f2 again. + If there is more than one line in the window, Speakup will tell you +that the window ends at the indicated row and column position. If there +is only one line in the window, then Speakup will tell you that the +window is the specified line on the screen. If you are only defining a +one line window, you can just press speakup + f2 twice after placing the +reading cursor on the line you want to define as a window. It is not +necessary to position the reading cursor at the end of the line in order +to define the whole line as a window. + +16. Tools for Controlling Speakup + +The speakup distribution includes extra tools (in the tools directory) +which were written to make speakup easier to use. This section will +briefly describe the use of these tools. + +16.1. Speakupconf + +speakupconf began life as a contribution from Steve Holmes, a member of +the speakup community. We would like to thank him for his work on the +early versions of this project. + +This script may be installed as part of your linux distribution, but if +it isn't, the recommended places to put it are /usr/local/bin or +/usr/bin. This script can be run by any user, so it does not require +root privileges. + +Speakupconf allows you to save and load your Speakup settings. It works +by reading and writing the /sys files described above. + +The directory that speakupconf uses to store your settings depends on +whether it is run from the root account. If you execute speakupconf as +root, it uses the directory /etc/speakup. Otherwise, it uses the directory +~/.speakup, where ~ is your home directory. +Anyone who needs to use Speakup from your console can load his own custom +settings with this script. + +speakupconf takes one required argument: load or save. +Use the command +speakupconf save +to save your Speakup settings, and +speakupconf load +to load them into Speakup. +A second argument may be specified to use an alternate directory to +load or save the speakup parameters. + +16.2. Talkwith + +Charles Hallenbeck, another member of the speakup community, wrote the +initial versions of this script, and we would also like to thank him for +his work on it. + +This script needs root privileges to run, so if it is not installed as +part of your linux distribution, the recommended places to install it +are /usr/local/sbin or /usr/sbin. + +Talkwith allows you to switch synthesizers on the fly. It takes a synthesizer +name as an argument. For instance, +talkwith dectlk +causes Speakup to use the DecTalk Express. If you wish to switch to a +software synthesizer, you must also indicate which daemon you wish to +use. There are two possible choices: +spd and espeakup. spd is an abbreviation for speechd-up. +If you wish to use espeakup for software synthesis, give the command +talkwith soft espeakup +To use speechd-up, type: +talkwith soft spd +Any arguments that follow the name of the daemon are passed to the daemon +when it is invoked. For instance: +talkwith espeakup --default-voice=fr +causes espeakup to use the French voice. +Note that talkwith must always be executed with root privileges. + +Talkwith does not attempt to load your settings after the new +synthesizer is activated. You can use speakupconf to load your settings +if desired. + + GNU Free Documentation License + Version 1.2, November 2002 + + + Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + +0. PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +functional and useful document "free" in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of "copyleft", which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + + +1. APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The "Document", below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as "you". You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. + +A "Modified Version" of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A "Secondary Section" is a named appendix or a front-matter section of +the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall subject +(or to related matters) and contains nothing that could fall directly +within that overall subject. (Thus, if the Document is in part a +textbook of mathematics, a Secondary Section may not explain any +mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The "Invariant Sections" are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The "Cover Texts" are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A "Transparent" copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not "Transparent" is called "Opaque". + +Examples of suitable formats for Transparent copies include plain +ASCII without markup, Texinfo input format, LaTeX input format, SGML +or XML using a publicly available DTD, and standard-conforming simple +HTML, PostScript or PDF designed for human modification. Examples of +transparent image formats include PNG, XCF and JPG. Opaque formats +include proprietary formats that can be read and edited only by +proprietary word processors, SGML or XML for which the DTD and/or +processing tools are not generally available, and the +machine-generated HTML, PostScript or PDF produced by some word +processors for output purposes only. + +The "Title Page" means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, "Title Page" means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +A section "Entitled XYZ" means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as "Acknowledgements", +"Dedications", "Endorsements", or "History".) To "Preserve the Title" +of such a section when you modify the Document means that it remains a +section "Entitled XYZ" according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + + +2. VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + + +3. COPYING IN QUANTITY + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + + +4. MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +A. Use in the Title Page (and on the covers, if any) a title distinct + from that of the Document, and from those of previous versions + (which should, if there were any, be listed in the History section + of the Document). You may use the same title as a previous version + if the original publisher of that version gives permission. +B. List on the Title Page, as authors, one or more persons or entities + responsible for authorship of the modifications in the Modified + Version, together with at least five of the principal authors of the + Document (all of its principal authors, if it has fewer than five), + unless they release you from this requirement. +C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. +D. Preserve all the copyright notices of the Document. +E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. +F. Include, immediately after the copyright notices, a license notice + giving the public permission to use the Modified Version under the + terms of this License, in the form shown in the Addendum below. +G. Preserve in that license notice the full lists of Invariant Sections + and required Cover Texts given in the Document's license notice. +H. Include an unaltered copy of this License. +I. Preserve the section Entitled "History", Preserve its Title, and add + to it an item stating at least the title, year, new authors, and + publisher of the Modified Version as given on the Title Page. If + there is no section Entitled "History" in the Document, create one + stating the title, year, authors, and publisher of the Document as + given on its Title Page, then add an item describing the Modified + Version as stated in the previous sentence. +J. Preserve the network location, if any, given in the Document for + public access to a Transparent copy of the Document, and likewise + the network locations given in the Document for previous versions + it was based on. These may be placed in the "History" section. + You may omit a network location for a work that was published at + least four years before the Document itself, or if the original + publisher of the version it refers to gives permission. +K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the section all + the substance and tone of each of the contributor acknowledgements + and/or dedications given therein. +L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section titles. +M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. +N. Do not retitle any existing section to be Entitled "Endorsements" + or to conflict in title with any Invariant Section. +O. Preserve any Warranty Disclaimers. + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled "Endorsements", provided it contains +nothing but endorsements of your Modified Version by various +parties--for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + + +5. COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled "History" +in the various original documents, forming one section Entitled +"History"; likewise combine any sections Entitled "Acknowledgements", +and any sections Entitled "Dedications". You must delete all sections +Entitled "Endorsements". + + +6. COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + + +7. AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an "aggregate" if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + + +8. TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled "Acknowledgements", +"Dedications", or "History", the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + + +9. TERMINATION + +You may not copy, modify, sublicense, or distribute the Document except +as expressly provided for under this License. Any other attempt to +copy, modify, sublicense or distribute the Document is void, and will +automatically terminate your rights under this License. However, +parties who have received copies, or rights, from you under this +License will not have their licenses terminated so long as such +parties remain in full compliance. + + +10. FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. See +https://www.gnu.org/copyleft/. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License "or any later version" applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. + + +ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + + Copyright (c) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. + A copy of the license is included in the section entitled "GNU + Free Documentation License". + +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with the + Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. + +The End. diff --git a/MAINTAINERS b/MAINTAINERS index 8d5294bfade6..49a29c557592 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16100,6 +16100,16 @@ Q: https://patchwork.kernel.org/project/linux-sparse/list/ B: https://bugzilla.kernel.org/enter_bug.cgi?component=Sparse&product=Tools F: include/linux/compiler.h +SPEAKUP CONSOLE SPEECH DRIVER +M: William Hubbs +M: Chris Brannon +M: Kirk Reiser +M: Samuel Thibault +L: speakup@linux-speakup.org +S: Odd Fixes +W: http://www.linux-speakup.org/ +F: drivers/accessibility/speakup/ + SPEAR CLOCK FRAMEWORK SUPPORT M: Viresh Kumar L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) @@ -16287,16 +16297,6 @@ L: linux-fbdev@vger.kernel.org S: Maintained F: drivers/staging/sm750fb/ -STAGING - SPEAKUP CONSOLE SPEECH DRIVER -M: William Hubbs -M: Chris Brannon -M: Kirk Reiser -M: Samuel Thibault -L: speakup@linux-speakup.org -S: Odd Fixes -W: http://www.linux-speakup.org/ -F: drivers/staging/speakup/ - STAGING - VIA VT665X DRIVERS M: Forest Bond S: Odd Fixes diff --git a/drivers/accessibility/Kconfig b/drivers/accessibility/Kconfig index f10c17dc1dee..6b2f79d1f1b8 100644 --- a/drivers/accessibility/Kconfig +++ b/drivers/accessibility/Kconfig @@ -31,4 +31,6 @@ config A11Y_BRAILLE_CONSOLE If unsure, say N. +source "drivers/accessibility/speakup/Kconfig" + endif # ACCESSIBILITY diff --git a/drivers/accessibility/Makefile b/drivers/accessibility/Makefile index e8c182f82c44..833603086530 100644 --- a/drivers/accessibility/Makefile +++ b/drivers/accessibility/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only obj-y += braille/ +obj-$(CONFIG_SPEAKUP) += speakup/ diff --git a/drivers/accessibility/speakup/DefaultKeyAssignments b/drivers/accessibility/speakup/DefaultKeyAssignments new file mode 100644 index 000000000000..101c803b21fd --- /dev/null +++ b/drivers/accessibility/speakup/DefaultKeyAssignments @@ -0,0 +1,46 @@ +This file is intended to give you an overview of the default keys used +by speakup for it's review functions. You may change them to be +anything you want but that will take some familiarity with key +mapping. + +We have remapped the insert or zero key on the keypad to act as a +shift key. Well, actually as an altgr key. So in the following list +InsKeyPad-period means hold down the insert key like a shift key and +hit the keypad period. + +KeyPad-8 Say current Line +InsKeyPad-8 say from top of screen to reading cursor. +KeyPad-7 Say Previous Line (UP one line) +KeyPad-9 Say Next Line (down one line) +KeyPad-5 Say Current Word +InsKeyPad-5 Spell Current Word +KeyPad-4 Say Previous Word (left one word) +InsKeyPad-4 say from left edge of line to reading cursor. +KeyPad-6 Say Next Word (right one word) +InsKeyPad-6 Say from reading cursor to right edge of line. +KeyPad-2 Say Current Letter +InsKeyPad-2 say current letter phonetically +KeyPad-1 Say Previous Character (left one letter) +KeyPad-3 Say Next Character (right one letter) +KeyPad-plus Say Entire Screen +InsKeyPad-plus Say from reading cursor line to bottom of screen. +KeyPad-Minus Park reading cursor (toggle) +InsKeyPad-minus Say character hex and decimal value. +KeyPad-period Say Position (current line, position and console) +InsKeyPad-period say colour attributes of current position. +InsKeyPad-9 Move reading cursor to top of screen (insert pgup) +InsKeyPad-3 Move reading cursor to bottom of screen (insert pgdn) +InsKeyPad-7 Move reading cursor to left edge of screen (insert home) +InsKeyPad-1 Move reading cursor to right edge of screen (insert end) +ControlKeyPad-1 Move reading cursor to last character on current line. +KeyPad-Enter Shut Up (until another key is hit) and sync reading cursor +InsKeyPad-Enter Shut Up (until toggled back on). +InsKeyPad-star n go to line (y) or column (x). Where 'n' is any + allowed value for the row or column for your current screen. +KeyPad-/ Mark and Cut screen region. +InsKeyPad-/ Paste screen region into any console. + +Hitting any key while speakup is outputting speech will quiet the +synth until it has caught up with what is being printed on the +console. + diff --git a/drivers/accessibility/speakup/Kconfig b/drivers/accessibility/speakup/Kconfig new file mode 100644 index 000000000000..0803c2013cf4 --- /dev/null +++ b/drivers/accessibility/speakup/Kconfig @@ -0,0 +1,200 @@ +# SPDX-License-Identifier: GPL-2.0 +menu "Speakup console speech" + +config SPEAKUP + depends on VT + tristate "Speakup core" + help + This is the Speakup screen reader. Think of it as a + video console for blind people. If built in to the + kernel, it can speak everything on the text console from + boot up to shutdown. For more information on Speakup, + point your browser at . + There is also a mailing list at the above url that you + can subscribe to. + + Supported synthesizers are accent sa, accent pc, + appollo II., Auddapter, Braille 'n Speak, Dectalk + external (old), Dectalk PC (full length isa board), + Dectalk express, Doubletalk, Doubletalk LT or + Litetalk, Keynote Gold internal PC, software + synthesizers, Speakout, transport, and a dummy module + that can be used with a plain text terminal. + + Speakup can either be built in or compiled as a module + by answering y or m. If you answer y here, then you + must answer either y or m to at least one of the + synthesizer drivers below. If you answer m here, then + the synthesizer drivers below can only be built as + modules. + + These drivers are not standalone drivers, but must be + used in conjunction with Speakup. Think of them as + video cards for blind people. + + + The Dectalk pc driver can only be built as a module, and + requires software to be pre-loaded on to the card before + the module can be loaded. See the decpc choice below + for more details. + + If you are not a blind person, or don't have access to + one of the listed synthesizers, you should say n. + +if SPEAKUP +config SPEAKUP_SYNTH_ACNTSA + tristate "Accent SA synthesizer support" + help + This is the Speakup driver for the Accent SA + synthesizer. You can say y to build it into the kernel, + or m to build it as a module. See the configuration + help on the Speakup choice above for more info. + +config SPEAKUP_SYNTH_ACNTPC + tristate "Accent PC synthesizer support" + depends on ISA || COMPILE_TEST + help + This is the Speakup driver for the accent pc + synthesizer. You can say y to build it into the kernel, + or m to build it as a module. See the configuration + help on the Speakup choice above for more info. + +config SPEAKUP_SYNTH_APOLLO + tristate "Apollo II synthesizer support" + help + This is the Speakup driver for the Apollo II + synthesizer. You can say y to build it into the kernel, + or m to build it as a module. See the configuration + help on the Speakup choice above for more info. + +config SPEAKUP_SYNTH_AUDPTR + tristate "Audapter synthesizer support" + help + This is the Speakup driver for the Audapter synthesizer. + You can say y to build it into the kernel, or m to + build it as a module. See the configuration help on the + Speakup choice above for more info. + +config SPEAKUP_SYNTH_BNS + tristate "Braille 'n' Speak synthesizer support" + help + This is the Speakup driver for the Braille 'n' Speak + synthesizer. You can say y to build it into the kernel, + or m to build it as a module. See the configuration + help on the Speakup choice above for more info. + +config SPEAKUP_SYNTH_DECTLK + tristate "DECtalk Express synthesizer support" + help + + This is the Speakup driver for the DecTalk Express + synthesizer. You can say y to build it into the kernel, + or m to build it as a module. See the configuration + help on the Speakup choice above for more info. + +config SPEAKUP_SYNTH_DECEXT + tristate "DECtalk External (old) synthesizer support" + help + + This is the Speakup driver for the DecTalk External + (old) synthesizer. You can say y to build it into the + kernel, or m to build it as a module. See the + configuration help on the Speakup choice above for more + info. + +config SPEAKUP_SYNTH_DECPC + depends on m + depends on ISA || COMPILE_TEST + tristate "DECtalk PC (big ISA card) synthesizer support" + help + + This is the Speakup driver for the DecTalk PC (full + length ISA) synthesizer. You can say m to build it as + a module. See the configuration help on the Speakup + choice above for more info. + + In order to use the DecTalk PC driver, you must download + the dec_pc.tgz file from linux-speakup.org. It is in + the pub/linux/goodies directory. The dec_pc.tgz file + contains the software which must be pre-loaded on to the + DecTalk PC board in order to use it with this driver. + This driver must be built as a module, and can not be + loaded until the file system is mounted and the DecTalk + PC software has been pre-loaded on to the board. + + See the README file in the dec_pc.tgz file for more + details. + +config SPEAKUP_SYNTH_DTLK + tristate "DoubleTalk PC synthesizer support" + depends on ISA || COMPILE_TEST + help + + This is the Speakup driver for the internal DoubleTalk + PC synthesizer. You can say y to build it into the + kernel, or m to build it as a module. See the + configuration help on the Speakup choice above for more + info. + +config SPEAKUP_SYNTH_KEYPC + tristate "Keynote Gold PC synthesizer support" + depends on ISA || COMPILE_TEST + help + + This is the Speakup driver for the Keynote Gold + PC synthesizer. You can say y to build it into the + kernel, or m to build it as a module. See the + configuration help on the Speakup choice above for more + info. + +config SPEAKUP_SYNTH_LTLK + tristate "DoubleTalk LT/LiteTalk synthesizer support" +help + + This is the Speakup driver for the LiteTalk/DoubleTalk + LT synthesizer. You can say y to build it into the + kernel, or m to build it as a module. See the + configuration help on the Speakup choice above for more + info. + +config SPEAKUP_SYNTH_SOFT + tristate "Userspace software synthesizer support" + help + + This is the software synthesizer device node. It will + register a device /dev/softsynth which midware programs + and speech daemons may open and read to provide kernel + output to software synths such as espeak, festival, + flite and so forth. You can select 'y' or 'm' to have + it built-in to the kernel or loaded as a module. + +config SPEAKUP_SYNTH_SPKOUT + tristate "Speak Out synthesizer support" + help + + This is the Speakup driver for the Speakout synthesizer. + You can say y to build it into the kernel, or m to + build it as a module. See the configuration help on the + Speakup choice above for more info. + +config SPEAKUP_SYNTH_TXPRT + tristate "Transport synthesizer support" + help + + This is the Speakup driver for the Transport + synthesizer. You can say y to build it into the kernel, + or m to build it as a module. See the configuration + help on the Speakup choice above for more info. + +config SPEAKUP_SYNTH_DUMMY + tristate "Dummy synthesizer driver (for testing)" + help + + This is a dummy Speakup driver for plugging a mere serial + terminal. This is handy if you want to test speakup but + don't have the hardware. You can say y to build it into + the kernel, or m to build it as a module. See the + configuration help on the Speakup choice above for more info. + +endif # SPEAKUP +endmenu diff --git a/drivers/accessibility/speakup/Makefile b/drivers/accessibility/speakup/Makefile new file mode 100644 index 000000000000..5befb4933b85 --- /dev/null +++ b/drivers/accessibility/speakup/Makefile @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_SPEAKUP_SYNTH_ACNTSA) += speakup_acntsa.o +obj-$(CONFIG_SPEAKUP_SYNTH_ACNTPC) += speakup_acntpc.o +obj-$(CONFIG_SPEAKUP_SYNTH_APOLLO) += speakup_apollo.o +obj-$(CONFIG_SPEAKUP_SYNTH_AUDPTR) += speakup_audptr.o +obj-$(CONFIG_SPEAKUP_SYNTH_BNS) += speakup_bns.o +obj-$(CONFIG_SPEAKUP_SYNTH_DECTLK) += speakup_dectlk.o +obj-$(CONFIG_SPEAKUP_SYNTH_DECEXT) += speakup_decext.o +obj-$(CONFIG_SPEAKUP_SYNTH_DECPC) += speakup_decpc.o +obj-$(CONFIG_SPEAKUP_SYNTH_DTLK) += speakup_dtlk.o +obj-$(CONFIG_SPEAKUP_SYNTH_KEYPC) += speakup_keypc.o +obj-$(CONFIG_SPEAKUP_SYNTH_LTLK) += speakup_ltlk.o +obj-$(CONFIG_SPEAKUP_SYNTH_SOFT) += speakup_soft.o +obj-$(CONFIG_SPEAKUP_SYNTH_SPKOUT) += speakup_spkout.o +obj-$(CONFIG_SPEAKUP_SYNTH_TXPRT) += speakup_txprt.o +obj-$(CONFIG_SPEAKUP_SYNTH_DUMMY) += speakup_dummy.o + +obj-$(CONFIG_SPEAKUP) += speakup.o +speakup-y := \ + buffers.o \ + devsynth.o \ + i18n.o \ + fakekey.o \ + main.o \ + keyhelp.o \ + kobjects.o \ + selection.o \ + serialio.o \ + spk_ttyio.o \ + synth.o \ + thread.o \ + varhandlers.o diff --git a/drivers/accessibility/speakup/TODO b/drivers/accessibility/speakup/TODO new file mode 100644 index 000000000000..d4ca093bf0bd --- /dev/null +++ b/drivers/accessibility/speakup/TODO @@ -0,0 +1,22 @@ +Speakup project home: http://www.linux-speakup.org + +Mailing List: speakup@linux-speakup.org + +Speakup is a kernel based screen review package for the linux operating +system. It allows blind users to interact with applications on the +linux console by means of synthetic speech. + +Currently, speakup has one issue we know of. + +It seems to only happen on SMP systems. It seems that text in the output buffer +gets garbled because a lock is not set. This bug happens regularly, but no one +has been able to find a situation which produces it consistently. + +Patches, suggestions, corrections, etc, are definitely welcome. + +We prefer that you contact us on the mailing list; however, if you do +not want to subscribe to a mailing list, send your email to all of the +following: + +okash.khawaja@gmail.com, w.d.hubbs@gmail.com, chris@the-brannons.com, +kirk@reisers.ca and samuel.thibault@ens-lyon.org. diff --git a/drivers/accessibility/speakup/buffers.c b/drivers/accessibility/speakup/buffers.c new file mode 100644 index 000000000000..1371ced2f5ca --- /dev/null +++ b/drivers/accessibility/speakup/buffers.c @@ -0,0 +1,124 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include + +#include "speakup.h" +#include "spk_priv.h" + +#define SYNTH_BUF_SIZE 8192 /* currently 8K bytes */ + +static u16 synth_buffer[SYNTH_BUF_SIZE]; /* guess what this is for! */ +static u16 *buff_in = synth_buffer; +static u16 *buff_out = synth_buffer; +static u16 *buffer_end = synth_buffer + SYNTH_BUF_SIZE - 1; + +/* These try to throttle applications by stopping the TTYs + * Note: we need to make sure that we will restart them eventually, which is + * usually not possible to do from the notifiers. TODO: it should be possible + * starting from linux 2.6.26. + * + * So we only stop when we know alive == 1 (else we discard the data anyway), + * and the alive synth will eventually call start_ttys from the thread context. + */ +void speakup_start_ttys(void) +{ + int i; + + for (i = 0; i < MAX_NR_CONSOLES; i++) { + if (speakup_console[i] && speakup_console[i]->tty_stopped) + continue; + if (vc_cons[i].d && vc_cons[i].d->port.tty) + start_tty(vc_cons[i].d->port.tty); + } +} +EXPORT_SYMBOL_GPL(speakup_start_ttys); + +static void speakup_stop_ttys(void) +{ + int i; + + for (i = 0; i < MAX_NR_CONSOLES; i++) + if (vc_cons[i].d && vc_cons[i].d->port.tty) + stop_tty(vc_cons[i].d->port.tty); +} + +static int synth_buffer_free(void) +{ + int chars_free; + + if (buff_in >= buff_out) + chars_free = SYNTH_BUF_SIZE - (buff_in - buff_out); + else + chars_free = buff_out - buff_in; + return chars_free; +} + +int synth_buffer_empty(void) +{ + return (buff_in == buff_out); +} +EXPORT_SYMBOL_GPL(synth_buffer_empty); + +void synth_buffer_add(u16 ch) +{ + if (!synth->alive) { + /* This makes sure that we won't stop TTYs if there is no synth + * to restart them + */ + return; + } + if (synth_buffer_free() <= 100) { + synth_start(); + speakup_stop_ttys(); + } + if (synth_buffer_free() <= 1) + return; + *buff_in++ = ch; + if (buff_in > buffer_end) + buff_in = synth_buffer; + /* We have written something to the speech synthesis, so we are not + * paused any more. + */ + spk_paused = false; +} + +u16 synth_buffer_getc(void) +{ + u16 ch; + + if (buff_out == buff_in) + return 0; + ch = *buff_out++; + if (buff_out > buffer_end) + buff_out = synth_buffer; + return ch; +} +EXPORT_SYMBOL_GPL(synth_buffer_getc); + +u16 synth_buffer_peek(void) +{ + if (buff_out == buff_in) + return 0; + return *buff_out; +} +EXPORT_SYMBOL_GPL(synth_buffer_peek); + +void synth_buffer_skip_nonlatin1(void) +{ + while (buff_out != buff_in) { + if (*buff_out < 0x100) + return; + buff_out++; + if (buff_out > buffer_end) + buff_out = synth_buffer; + } +} +EXPORT_SYMBOL_GPL(synth_buffer_skip_nonlatin1); + +void synth_buffer_clear(void) +{ + buff_in = synth_buffer; + buff_out = synth_buffer; +} +EXPORT_SYMBOL_GPL(synth_buffer_clear); diff --git a/drivers/accessibility/speakup/devsynth.c b/drivers/accessibility/speakup/devsynth.c new file mode 100644 index 000000000000..d30571663585 --- /dev/null +++ b/drivers/accessibility/speakup/devsynth.c @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include /* for misc_register, and MISC_DYNAMIC_MINOR */ +#include +#include + +#include "speakup.h" +#include "spk_priv.h" + +static int misc_registered; +static int dev_opened; + +static ssize_t speakup_file_write(struct file *fp, const char __user *buffer, + size_t nbytes, loff_t *ppos) +{ + size_t count = nbytes; + const char __user *ptr = buffer; + size_t bytes; + unsigned long flags; + u_char buf[256]; + + if (!synth) + return -ENODEV; + while (count > 0) { + bytes = min(count, sizeof(buf)); + if (copy_from_user(buf, ptr, bytes)) + return -EFAULT; + count -= bytes; + ptr += bytes; + spin_lock_irqsave(&speakup_info.spinlock, flags); + synth_write(buf, bytes); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + } + return (ssize_t)nbytes; +} + +static ssize_t speakup_file_read(struct file *fp, char __user *buf, + size_t nbytes, loff_t *ppos) +{ + return 0; +} + +static int speakup_file_open(struct inode *ip, struct file *fp) +{ + if (!synth) + return -ENODEV; + if (xchg(&dev_opened, 1)) + return -EBUSY; + return 0; +} + +static int speakup_file_release(struct inode *ip, struct file *fp) +{ + dev_opened = 0; + return 0; +} + +static const struct file_operations synth_fops = { + .read = speakup_file_read, + .write = speakup_file_write, + .open = speakup_file_open, + .release = speakup_file_release, +}; + +static struct miscdevice synth_device = { + .minor = MISC_DYNAMIC_MINOR, + .name = "synth", + .fops = &synth_fops, +}; + +void speakup_register_devsynth(void) +{ + if (misc_registered != 0) + return; +/* zero it so if register fails, deregister will not ref invalid ptrs */ + if (misc_register(&synth_device)) { + pr_warn("Couldn't initialize miscdevice /dev/synth.\n"); + } else { + pr_info("initialized device: /dev/synth, node (MAJOR %d, MINOR %d)\n", + MISC_MAJOR, synth_device.minor); + misc_registered = 1; + } +} + +void speakup_unregister_devsynth(void) +{ + if (!misc_registered) + return; + pr_info("speakup: unregistering synth device /dev/synth\n"); + misc_deregister(&synth_device); + misc_registered = 0; +} diff --git a/drivers/accessibility/speakup/fakekey.c b/drivers/accessibility/speakup/fakekey.c new file mode 100644 index 000000000000..cd029968462f --- /dev/null +++ b/drivers/accessibility/speakup/fakekey.c @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* fakekey.c + * Functions for simulating keypresses. + * + * Copyright (C) 2010 the Speakup Team + */ +#include +#include +#include +#include +#include + +#include "speakup.h" + +#define PRESSED 1 +#define RELEASED 0 + +static DEFINE_PER_CPU(int, reporting_keystroke); + +static struct input_dev *virt_keyboard; + +int speakup_add_virtual_keyboard(void) +{ + int err; + + virt_keyboard = input_allocate_device(); + + if (!virt_keyboard) + return -ENOMEM; + + virt_keyboard->name = "Speakup"; + virt_keyboard->id.bustype = BUS_VIRTUAL; + virt_keyboard->phys = "speakup/input0"; + virt_keyboard->dev.parent = NULL; + + __set_bit(EV_KEY, virt_keyboard->evbit); + __set_bit(KEY_DOWN, virt_keyboard->keybit); + + err = input_register_device(virt_keyboard); + if (err) { + input_free_device(virt_keyboard); + virt_keyboard = NULL; + } + + return err; +} + +void speakup_remove_virtual_keyboard(void) +{ + if (virt_keyboard) { + input_unregister_device(virt_keyboard); + virt_keyboard = NULL; + } +} + +/* + * Send a simulated down-arrow to the application. + */ +void speakup_fake_down_arrow(void) +{ + unsigned long flags; + + /* disable keyboard interrupts */ + local_irq_save(flags); + /* don't change CPU */ + preempt_disable(); + + __this_cpu_write(reporting_keystroke, true); + input_report_key(virt_keyboard, KEY_DOWN, PRESSED); + input_report_key(virt_keyboard, KEY_DOWN, RELEASED); + input_sync(virt_keyboard); + __this_cpu_write(reporting_keystroke, false); + + /* reenable preemption */ + preempt_enable(); + /* reenable keyboard interrupts */ + local_irq_restore(flags); +} + +/* + * Are we handling a simulated keypress on the current CPU? + * Returns a boolean. + */ +bool speakup_fake_key_pressed(void) +{ + return this_cpu_read(reporting_keystroke); +} diff --git a/drivers/accessibility/speakup/i18n.c b/drivers/accessibility/speakup/i18n.c new file mode 100644 index 000000000000..ee240d36f947 --- /dev/null +++ b/drivers/accessibility/speakup/i18n.c @@ -0,0 +1,625 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Internationalization implementation. Includes definitions of English + * string arrays, and the i18n pointer. + */ + +#include /* For kmalloc. */ +#include +#include +#include +#include "speakup.h" +#include "spk_priv.h" + +static char *speakup_msgs[MSG_LAST_INDEX]; +static char *speakup_default_msgs[MSG_LAST_INDEX] = { + [MSG_BLANK] = "blank", + [MSG_IAM_ALIVE] = "I'm aLive!", + [MSG_YOU_KILLED_SPEAKUP] = "You killed speakup!", + [MSG_HEY_THATS_BETTER] = "hey. That's better!", + [MSG_YOU_TURNED_ME_OFF] = "You turned me off!", + [MSG_PARKED] = "parked!", + [MSG_UNPARKED] = "unparked!", + [MSG_MARK] = "mark", + [MSG_CUT] = "cut", + [MSG_MARK_CLEARED] = "mark, cleared", + [MSG_PASTE] = "paste", + [MSG_BRIGHT] = "bright", + [MSG_ON_BLINKING] = "on blinking", + [MSG_OFF] = "off", + [MSG_ON] = "on", + [MSG_NO_WINDOW] = "no window", + [MSG_CURSORING_OFF] = "cursoring off", + [MSG_CURSORING_ON] = "cursoring on", + [MSG_HIGHLIGHT_TRACKING] = "highlight tracking", + [MSG_READ_WINDOW] = "read windo", + [MSG_READ_ALL] = "read all", + [MSG_EDIT_DONE] = "edit done", + [MSG_WINDOW_ALREADY_SET] = "window already set, clear then reset", + [MSG_END_BEFORE_START] = "error end before start", + [MSG_WINDOW_CLEARED] = "window cleared", + [MSG_WINDOW_SILENCED] = "window silenced", + [MSG_WINDOW_SILENCE_DISABLED] = "window silence disabled", + [MSG_ERROR] = "error", + [MSG_GOTO_CANCELED] = "goto canceled", + [MSG_GOTO] = "go to?", + [MSG_LEAVING_HELP] = "leaving help", + [MSG_IS_UNASSIGNED] = "is unassigned", + [MSG_HELP_INFO] = + "press space to exit, up or down to scroll, or a letter to go to a command", + [MSG_EDGE_TOP] = "top,", + [MSG_EDGE_BOTTOM] = "bottom,", + [MSG_EDGE_LEFT] = "left,", + [MSG_EDGE_RIGHT] = "right,", + [MSG_NUMBER] = "number", + [MSG_SPACE] = "space", + [MSG_START] = "start", + [MSG_END] = "end", + [MSG_CTRL] = "control-", + [MSG_DISJUNCTION] = "or", + +/* Messages with embedded format specifiers. */ + [MSG_POS_INFO] = "line %ld, col %ld, t t y %d", + [MSG_CHAR_INFO] = "hex %02x, decimal %d", + [MSG_REPEAT_DESC] = "times %d .", + [MSG_REPEAT_DESC2] = "repeated %d .", + [MSG_WINDOW_LINE] = "window is line %d", + [MSG_WINDOW_BOUNDARY] = "%s at line %d, column %d", + [MSG_EDIT_PROMPT] = "edit %s, press space when done", + [MSG_NO_COMMAND] = "no commands for %c", + [MSG_KEYDESC] = "is %s", + + /* Control keys. */ + /* Most of these duplicate the entries in state names. */ + [MSG_CTL_SHIFT] = "shift", + [MSG_CTL_ALTGR] = "altgr", + [MSG_CTL_CONTROL] = "control", + [MSG_CTL_ALT] = "alt", + [MSG_CTL_LSHIFT] = "l shift", + [MSG_CTL_SPEAKUP] = "speakup", + [MSG_CTL_LCONTROL] = "l control", + [MSG_CTL_RCONTROL] = "r control", + [MSG_CTL_CAPSSHIFT] = "caps shift", + + /* Color names. */ + [MSG_COLOR_BLACK] = "black", + [MSG_COLOR_BLUE] = "blue", + [MSG_COLOR_GREEN] = "green", + [MSG_COLOR_CYAN] = "cyan", + [MSG_COLOR_RED] = "red", + [MSG_COLOR_MAGENTA] = "magenta", + [MSG_COLOR_YELLOW] = "yellow", + [MSG_COLOR_WHITE] = "white", + [MSG_COLOR_GREY] = "grey", + + /* Names of key states. */ + [MSG_STATE_DOUBLE] = "double", + [MSG_STATE_SPEAKUP] = "speakup", + [MSG_STATE_ALT] = "alt", + [MSG_STATE_CONTROL] = "ctrl", + [MSG_STATE_ALTGR] = "altgr", + [MSG_STATE_SHIFT] = "shift", + + /* Key names. */ + [MSG_KEYNAME_ESC] = "escape", + [MSG_KEYNAME_1] = "1", + [MSG_KEYNAME_2] = "2", + [MSG_KEYNAME_3] = "3", + [MSG_KEYNAME_4] = "4", + [MSG_KEYNAME_5] = "5", + [MSG_KEYNAME_6] = "6", + [MSG_KEYNAME_7] = "7", + [MSG_KEYNAME_8] = "8", + [MSG_KEYNAME_9] = "9", + [MSG_KEYNAME_0] = "0", + [MSG_KEYNAME_DASH] = "minus", + [MSG_KEYNAME_EQUAL] = "equal", + [MSG_KEYNAME_BS] = "back space", + [MSG_KEYNAME_TAB] = "tab", + [MSG_KEYNAME_Q] = "q", + [MSG_KEYNAME_W] = "w", + [MSG_KEYNAME_E] = "e", + [MSG_KEYNAME_R] = "r", + [MSG_KEYNAME_T] = "t", + [MSG_KEYNAME_Y] = "y", + [MSG_KEYNAME_U] = "u", + [MSG_KEYNAME_I] = "i", + [MSG_KEYNAME_O] = "o", + [MSG_KEYNAME_P] = "p", + [MSG_KEYNAME_LEFTBRACE] = "left brace", + [MSG_KEYNAME_RIGHTBRACE] = "right brace", + [MSG_KEYNAME_ENTER] = "enter", + [MSG_KEYNAME_LEFTCTRL] = "left control", + [MSG_KEYNAME_A] = "a", + [MSG_KEYNAME_S] = "s", + [MSG_KEYNAME_D] = "d", + [MSG_KEYNAME_F] = "f", + [MSG_KEYNAME_G] = "g", + [MSG_KEYNAME_H] = "h", + [MSG_KEYNAME_J] = "j", + [MSG_KEYNAME_K] = "k", + [MSG_KEYNAME_L] = "l", + [MSG_KEYNAME_SEMICOLON] = "semicolon", + [MSG_KEYNAME_SINGLEQUOTE] = "apostrophe", + [MSG_KEYNAME_GRAVE] = "accent", + [MSG_KEYNAME_LEFTSHFT] = "left shift", + [MSG_KEYNAME_BACKSLASH] = "back slash", + [MSG_KEYNAME_Z] = "z", + [MSG_KEYNAME_X] = "x", + [MSG_KEYNAME_C] = "c", + [MSG_KEYNAME_V] = "v", + [MSG_KEYNAME_B] = "b", + [MSG_KEYNAME_N] = "n", + [MSG_KEYNAME_M] = "m", + [MSG_KEYNAME_COMMA] = "comma", + [MSG_KEYNAME_DOT] = "dot", + [MSG_KEYNAME_SLASH] = "slash", + [MSG_KEYNAME_RIGHTSHFT] = "right shift", + [MSG_KEYNAME_KPSTAR] = "keypad asterisk", + [MSG_KEYNAME_LEFTALT] = "left alt", + [MSG_KEYNAME_SPACE] = "space", + [MSG_KEYNAME_CAPSLOCK] = "caps lock", + [MSG_KEYNAME_F1] = "f1", + [MSG_KEYNAME_F2] = "f2", + [MSG_KEYNAME_F3] = "f3", + [MSG_KEYNAME_F4] = "f4", + [MSG_KEYNAME_F5] = "f5", + [MSG_KEYNAME_F6] = "f6", + [MSG_KEYNAME_F7] = "f7", + [MSG_KEYNAME_F8] = "f8", + [MSG_KEYNAME_F9] = "f9", + [MSG_KEYNAME_F10] = "f10", + [MSG_KEYNAME_NUMLOCK] = "num lock", + [MSG_KEYNAME_SCROLLLOCK] = "scroll lock", + [MSG_KEYNAME_KP7] = "keypad 7", + [MSG_KEYNAME_KP8] = "keypad 8", + [MSG_KEYNAME_KP9] = "keypad 9", + [MSG_KEYNAME_KPMINUS] = "keypad minus", + [MSG_KEYNAME_KP4] = "keypad 4", + [MSG_KEYNAME_KP5] = "keypad 5", + [MSG_KEYNAME_KP6] = "keypad 6", + [MSG_KEYNAME_KPPLUS] = "keypad plus", + [MSG_KEYNAME_KP1] = "keypad 1", + [MSG_KEYNAME_KP2] = "keypad 2", + [MSG_KEYNAME_KP3] = "keypad 3", + [MSG_KEYNAME_KP0] = "keypad 0", + [MSG_KEYNAME_KPDOT] = "keypad dot", + [MSG_KEYNAME_103RD] = "103rd", + [MSG_KEYNAME_F13] = "f13", + [MSG_KEYNAME_102ND] = "102nd", + [MSG_KEYNAME_F11] = "f11", + [MSG_KEYNAME_F12] = "f12", + [MSG_KEYNAME_F14] = "f14", + [MSG_KEYNAME_F15] = "f15", + [MSG_KEYNAME_F16] = "f16", + [MSG_KEYNAME_F17] = "f17", + [MSG_KEYNAME_F18] = "f18", + [MSG_KEYNAME_F19] = "f19", + [MSG_KEYNAME_F20] = "f20", + [MSG_KEYNAME_KPENTER] = "keypad enter", + [MSG_KEYNAME_RIGHTCTRL] = "right control", + [MSG_KEYNAME_KPSLASH] = "keypad slash", + [MSG_KEYNAME_SYSRQ] = "sysrq", + [MSG_KEYNAME_RIGHTALT] = "right alt", + [MSG_KEYNAME_LF] = "line feed", + [MSG_KEYNAME_HOME] = "home", + [MSG_KEYNAME_UP] = "up", + [MSG_KEYNAME_PGUP] = "page up", + [MSG_KEYNAME_LEFT] = "left", + [MSG_KEYNAME_RIGHT] = "right", + [MSG_KEYNAME_END] = "end", + [MSG_KEYNAME_DOWN] = "down", + [MSG_KEYNAME_PGDN] = "page down", + [MSG_KEYNAME_INS] = "insert", + [MSG_KEYNAME_DEL] = "delete", + [MSG_KEYNAME_MACRO] = "macro", + [MSG_KEYNAME_MUTE] = "mute", + [MSG_KEYNAME_VOLDOWN] = "volume down", + [MSG_KEYNAME_VOLUP] = "volume up", + [MSG_KEYNAME_POWER] = "power", + [MSG_KEYNAME_KPEQUAL] = "keypad equal", + [MSG_KEYNAME_KPPLUSDASH] = "keypad plusminus", + [MSG_KEYNAME_PAUSE] = "pause", + [MSG_KEYNAME_F21] = "f21", + [MSG_KEYNAME_F22] = "f22", + [MSG_KEYNAME_F23] = "f23", + [MSG_KEYNAME_F24] = "f24", + [MSG_KEYNAME_KPCOMMA] = "keypad comma", + [MSG_KEYNAME_LEFTMETA] = "left meta", + [MSG_KEYNAME_RIGHTMETA] = "right meta", + [MSG_KEYNAME_COMPOSE] = "compose", + [MSG_KEYNAME_STOP] = "stop", + [MSG_KEYNAME_AGAIN] = "again", + [MSG_KEYNAME_PROPS] = "props", + [MSG_KEYNAME_UNDO] = "undo", + [MSG_KEYNAME_FRONT] = "front", + [MSG_KEYNAME_COPY] = "copy", + [MSG_KEYNAME_OPEN] = "open", + [MSG_KEYNAME_PASTE] = "paste", + [MSG_KEYNAME_FIND] = "find", + [MSG_KEYNAME_CUT] = "cut", + [MSG_KEYNAME_HELP] = "help", + [MSG_KEYNAME_MENU] = "menu", + [MSG_KEYNAME_CALC] = "calc", + [MSG_KEYNAME_SETUP] = "setup", + [MSG_KEYNAME_SLEEP] = "sleep", + [MSG_KEYNAME_WAKEUP] = "wakeup", + [MSG_KEYNAME_FILE] = "file", + [MSG_KEYNAME_SENDFILE] = "send file", + [MSG_KEYNAME_DELFILE] = "delete file", + [MSG_KEYNAME_XFER] = "transfer", + [MSG_KEYNAME_PROG1] = "prog1", + [MSG_KEYNAME_PROG2] = "prog2", + [MSG_KEYNAME_WWW] = "www", + [MSG_KEYNAME_MSDOS] = "msdos", + [MSG_KEYNAME_COFFEE] = "coffee", + [MSG_KEYNAME_DIRECTION] = "direction", + [MSG_KEYNAME_CYCLEWINDOWS] = "cycle windows", + [MSG_KEYNAME_MAIL] = "mail", + [MSG_KEYNAME_BOOKMARKS] = "bookmarks", + [MSG_KEYNAME_COMPUTER] = "computer", + [MSG_KEYNAME_BACK] = "back", + [MSG_KEYNAME_FORWARD] = "forward", + [MSG_KEYNAME_CLOSECD] = "close cd", + [MSG_KEYNAME_EJECTCD] = "eject cd", + [MSG_KEYNAME_EJECTCLOSE] = "eject close cd", + [MSG_KEYNAME_NEXTSONG] = "next song", + [MSG_KEYNAME_PLAYPAUSE] = "play pause", + [MSG_KEYNAME_PREVSONG] = "previous song", + [MSG_KEYNAME_STOPCD] = "stop cd", + [MSG_KEYNAME_RECORD] = "record", + [MSG_KEYNAME_REWIND] = "rewind", + [MSG_KEYNAME_PHONE] = "phone", + [MSG_KEYNAME_ISO] = "iso", + [MSG_KEYNAME_CONFIG] = "config", + [MSG_KEYNAME_HOMEPG] = "home page", + [MSG_KEYNAME_REFRESH] = "refresh", + [MSG_KEYNAME_EXIT] = "exit", + [MSG_KEYNAME_MOVE] = "move", + [MSG_KEYNAME_EDIT] = "edit", + [MSG_KEYNAME_SCROLLUP] = "scroll up", + [MSG_KEYNAME_SCROLLDN] = "scroll down", + [MSG_KEYNAME_KPLEFTPAR] = "keypad left paren", + [MSG_KEYNAME_KPRIGHTPAR] = "keypad right paren", + + /* Function names. */ + [MSG_FUNCNAME_ATTRIB_BLEEP_DEC] = "attribute bleep decrement", + [MSG_FUNCNAME_ATTRIB_BLEEP_INC] = "attribute bleep increment", + [MSG_FUNCNAME_BLEEPS_DEC] = "bleeps decrement", + [MSG_FUNCNAME_BLEEPS_INC] = "bleeps increment", + [MSG_FUNCNAME_CHAR_FIRST] = "character, first", + [MSG_FUNCNAME_CHAR_LAST] = "character, last", + [MSG_FUNCNAME_CHAR_CURRENT] = "character, say current", + [MSG_FUNCNAME_CHAR_HEX_AND_DEC] = "character, say hex and decimal", + [MSG_FUNCNAME_CHAR_NEXT] = "character, say next", + [MSG_FUNCNAME_CHAR_PHONETIC] = "character, say phonetic", + [MSG_FUNCNAME_CHAR_PREVIOUS] = "character, say previous", + [MSG_FUNCNAME_CURSOR_PARK] = "cursor park", + [MSG_FUNCNAME_CUT] = "cut", + [MSG_FUNCNAME_EDIT_DELIM] = "edit delimiters", + [MSG_FUNCNAME_EDIT_EXNUM] = "edit exnum", + [MSG_FUNCNAME_EDIT_MOST] = "edit most", + [MSG_FUNCNAME_EDIT_REPEATS] = "edit repeats", + [MSG_FUNCNAME_EDIT_SOME] = "edit some", + [MSG_FUNCNAME_GOTO] = "go to", + [MSG_FUNCNAME_GOTO_BOTTOM] = "go to bottom edge", + [MSG_FUNCNAME_GOTO_LEFT] = "go to left edge", + [MSG_FUNCNAME_GOTO_RIGHT] = "go to right edge", + [MSG_FUNCNAME_GOTO_TOP] = "go to top edge", + [MSG_FUNCNAME_HELP] = "help", + [MSG_FUNCNAME_LINE_SAY_CURRENT] = "line, say current", + [MSG_FUNCNAME_LINE_SAY_NEXT] = "line, say next", + [MSG_FUNCNAME_LINE_SAY_PREVIOUS] = "line, say previous", + [MSG_FUNCNAME_LINE_SAY_WITH_INDENT] = "line, say with indent", + [MSG_FUNCNAME_PASTE] = "paste", + [MSG_FUNCNAME_PITCH_DEC] = "pitch decrement", + [MSG_FUNCNAME_PITCH_INC] = "pitch increment", + [MSG_FUNCNAME_PUNC_DEC] = "punctuation decrement", + [MSG_FUNCNAME_PUNC_INC] = "punctuation increment", + [MSG_FUNCNAME_PUNC_LEVEL_DEC] = "punc level decrement", + [MSG_FUNCNAME_PUNC_LEVEL_INC] = "punc level increment", + [MSG_FUNCNAME_QUIET] = "quiet", + [MSG_FUNCNAME_RATE_DEC] = "rate decrement", + [MSG_FUNCNAME_RATE_INC] = "rate increment", + [MSG_FUNCNAME_READING_PUNC_DEC] = "reading punctuation decrement", + [MSG_FUNCNAME_READING_PUNC_INC] = "reading punctuation increment", + [MSG_FUNCNAME_SAY_ATTRIBUTES] = "say attributes", + [MSG_FUNCNAME_SAY_FROM_LEFT] = "say from left", + [MSG_FUNCNAME_SAY_FROM_TOP] = "say from top", + [MSG_FUNCNAME_SAY_POSITION] = "say position", + [MSG_FUNCNAME_SAY_SCREEN] = "say screen", + [MSG_FUNCNAME_SAY_TO_BOTTOM] = "say to bottom", + [MSG_FUNCNAME_SAY_TO_RIGHT] = "say to right", + [MSG_FUNCNAME_SPEAKUP] = "speakup", + [MSG_FUNCNAME_SPEAKUP_LOCK] = "speakup lock", + [MSG_FUNCNAME_SPEAKUP_OFF] = "speakup off", + [MSG_FUNCNAME_SPEECH_KILL] = "speech kill", + [MSG_FUNCNAME_SPELL_DELAY_DEC] = "spell delay decrement", + [MSG_FUNCNAME_SPELL_DELAY_INC] = "spell delay increment", + [MSG_FUNCNAME_SPELL_WORD] = "spell word", + [MSG_FUNCNAME_SPELL_WORD_PHONETICALLY] = "spell word phonetically", + [MSG_FUNCNAME_TONE_DEC] = "tone decrement", + [MSG_FUNCNAME_TONE_INC] = "tone increment", + [MSG_FUNCNAME_VOICE_DEC] = "voice decrement", + [MSG_FUNCNAME_VOICE_INC] = "voice increment", + [MSG_FUNCNAME_VOLUME_DEC] = "volume decrement", + [MSG_FUNCNAME_VOLUME_INC] = "volume increment", + [MSG_FUNCNAME_WINDOW_CLEAR] = "window, clear", + [MSG_FUNCNAME_WINDOW_SAY] = "window, say", + [MSG_FUNCNAME_WINDOW_SET] = "window, set", + [MSG_FUNCNAME_WINDOW_SILENCE] = "window, silence", + [MSG_FUNCNAME_WORD_SAY_CURRENT] = "word, say current", + [MSG_FUNCNAME_WORD_SAY_NEXT] = "word, say next", + [MSG_FUNCNAME_WORD_SAY_PREVIOUS] = "word, say previous", +}; + +static struct msg_group_t all_groups[] = { + { + .name = "ctl_keys", + .start = MSG_CTL_START, + .end = MSG_CTL_END, + }, + { + .name = "colors", + .start = MSG_COLORS_START, + .end = MSG_COLORS_END, + }, + { + .name = "formatted", + .start = MSG_FORMATTED_START, + .end = MSG_FORMATTED_END, + }, + { + .name = "function_names", + .start = MSG_FUNCNAMES_START, + .end = MSG_FUNCNAMES_END, + }, + { + .name = "key_names", + .start = MSG_KEYNAMES_START, + .end = MSG_KEYNAMES_END, + }, + { + .name = "announcements", + .start = MSG_ANNOUNCEMENTS_START, + .end = MSG_ANNOUNCEMENTS_END, + }, + { + .name = "states", + .start = MSG_STATES_START, + .end = MSG_STATES_END, + }, +}; + +static const int num_groups = ARRAY_SIZE(all_groups); + +char *spk_msg_get(enum msg_index_t index) +{ + return speakup_msgs[index]; +} + +/* + * Function: next_specifier + * Finds the start of the next format specifier in the argument string. + * Return value: pointer to start of format + * specifier, or NULL if no specifier exists. + */ +static char *next_specifier(char *input) +{ + int found = 0; + char *next_percent = input; + + while (next_percent && !found) { + next_percent = strchr(next_percent, '%'); + if (next_percent) { + /* skip over doubled percent signs */ + while (next_percent[0] == '%' && + next_percent[1] == '%') + next_percent += 2; + if (*next_percent == '%') + found = 1; + else if (*next_percent == '\0') + next_percent = NULL; + } + } + + return next_percent; +} + +/* Skip over 0 or more flags. */ +static char *skip_flags(char *input) +{ + while ((*input != '\0') && strchr(" 0+-#", *input)) + input++; + return input; +} + +/* Skip over width.precision, if it exists. */ +static char *skip_width(char *input) +{ + while (isdigit(*input)) + input++; + if (*input == '.') { + input++; + while (isdigit(*input)) + input++; + } + return input; +} + +/* + * Skip past the end of the conversion part. + * Note that this code only accepts a handful of conversion specifiers: + * c d s x and ld. Not accidental; these are exactly the ones used in + * the default group of formatted messages. + */ +static char *skip_conversion(char *input) +{ + if ((input[0] == 'l') && (input[1] == 'd')) + input += 2; + else if ((*input != '\0') && strchr("cdsx", *input)) + input++; + return input; +} + +/* + * Function: find_specifier_end + * Return a pointer to the end of the format specifier. + */ +static char *find_specifier_end(char *input) +{ + input++; /* Advance over %. */ + input = skip_flags(input); + input = skip_width(input); + input = skip_conversion(input); + return input; +} + +/* + * Function: compare_specifiers + * Compare the format specifiers pointed to by *input1 and *input2. + * Return true if they are the same, false otherwise. + * Advance *input1 and *input2 so that they point to the character following + * the end of the specifier. + */ +static bool compare_specifiers(char **input1, char **input2) +{ + bool same = false; + char *end1 = find_specifier_end(*input1); + char *end2 = find_specifier_end(*input2); + size_t length1 = end1 - *input1; + size_t length2 = end2 - *input2; + + if ((length1 == length2) && !memcmp(*input1, *input2, length1)) + same = true; + + *input1 = end1; + *input2 = end2; + return same; +} + +/* + * Function: fmt_validate + * Check that two format strings contain the same number of format specifiers, + * and that the order of specifiers is the same in both strings. + * Return true if the condition holds, false if it doesn't. + */ +static bool fmt_validate(char *template, char *user) +{ + bool valid = true; + bool still_comparing = true; + char *template_ptr = template; + char *user_ptr = user; + + while (still_comparing && valid) { + template_ptr = next_specifier(template_ptr); + user_ptr = next_specifier(user_ptr); + if (template_ptr && user_ptr) { + /* Both have at least one more specifier. */ + valid = compare_specifiers(&template_ptr, &user_ptr); + } else { + /* No more format specifiers in one or both strings. */ + still_comparing = false; + /* See if one has more specifiers than the other. */ + if (template_ptr || user_ptr) + valid = false; + } + } + return valid; +} + +/* + * Function: msg_set + * Description: Add a user-supplied message to the user_messages array. + * The message text is copied to a memory area allocated with kmalloc. + * If the function fails, then user_messages is untouched. + * Arguments: + * - index: a message number, as found in i18n.h. + * - text: text of message. Not NUL-terminated. + * - length: number of bytes in text. + * Failure conditions: + * -EINVAL - Invalid format specifiers in formatted message or illegal index. + * -ENOMEM - Unable to allocate memory. + */ +ssize_t spk_msg_set(enum msg_index_t index, char *text, size_t length) +{ + char *newstr = NULL; + unsigned long flags; + + if ((index < MSG_FIRST_INDEX) || (index >= MSG_LAST_INDEX)) + return -EINVAL; + + newstr = kmalloc(length + 1, GFP_KERNEL); + if (!newstr) + return -ENOMEM; + + memcpy(newstr, text, length); + newstr[length] = '\0'; + if (index >= MSG_FORMATTED_START && + index <= MSG_FORMATTED_END && + !fmt_validate(speakup_default_msgs[index], newstr)) { + kfree(newstr); + return -EINVAL; + } + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (speakup_msgs[index] != speakup_default_msgs[index]) + kfree(speakup_msgs[index]); + speakup_msgs[index] = newstr; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return 0; +} + +/* + * Find a message group, given its name. Return a pointer to the structure + * if found, or NULL otherwise. + */ +struct msg_group_t *spk_find_msg_group(const char *group_name) +{ + struct msg_group_t *group = NULL; + int i; + + for (i = 0; i < num_groups; i++) { + if (!strcmp(all_groups[i].name, group_name)) { + group = &all_groups[i]; + break; + } + } + return group; +} + +void spk_reset_msg_group(struct msg_group_t *group) +{ + unsigned long flags; + enum msg_index_t i; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + + for (i = group->start; i <= group->end; i++) { + if (speakup_msgs[i] != speakup_default_msgs[i]) + kfree(speakup_msgs[i]); + speakup_msgs[i] = speakup_default_msgs[i]; + } + spin_unlock_irqrestore(&speakup_info.spinlock, flags); +} + +/* Called at initialization time, to establish default messages. */ +void spk_initialize_msgs(void) +{ + memcpy(speakup_msgs, speakup_default_msgs, + sizeof(speakup_default_msgs)); +} + +/* Free user-supplied strings when module is unloaded: */ +void spk_free_user_msgs(void) +{ + enum msg_index_t index; + unsigned long flags; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + for (index = MSG_FIRST_INDEX; index < MSG_LAST_INDEX; index++) { + if (speakup_msgs[index] != speakup_default_msgs[index]) { + kfree(speakup_msgs[index]); + speakup_msgs[index] = speakup_default_msgs[index]; + } + } + spin_unlock_irqrestore(&speakup_info.spinlock, flags); +} diff --git a/drivers/accessibility/speakup/i18n.h b/drivers/accessibility/speakup/i18n.h new file mode 100644 index 000000000000..2ec6e659d02b --- /dev/null +++ b/drivers/accessibility/speakup/i18n.h @@ -0,0 +1,235 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef I18N_H +#define I18N_H +/* Internationalization declarations */ + +enum msg_index_t { + MSG_FIRST_INDEX, + MSG_ANNOUNCEMENTS_START = MSG_FIRST_INDEX, + MSG_BLANK = MSG_ANNOUNCEMENTS_START, + MSG_IAM_ALIVE, + MSG_YOU_KILLED_SPEAKUP, + MSG_HEY_THATS_BETTER, + MSG_YOU_TURNED_ME_OFF, + MSG_PARKED, + MSG_UNPARKED, + MSG_MARK, + MSG_CUT, + MSG_MARK_CLEARED, + MSG_PASTE, + MSG_BRIGHT, + MSG_ON_BLINKING, + MSG_STATUS_START, + MSG_OFF = MSG_STATUS_START, + MSG_ON, + MSG_NO_WINDOW, + MSG_CURSOR_MSGS_START, + MSG_CURSORING_OFF = MSG_CURSOR_MSGS_START, + MSG_CURSORING_ON, + MSG_HIGHLIGHT_TRACKING, + MSG_READ_WINDOW, + MSG_READ_ALL, + MSG_EDIT_DONE, + MSG_WINDOW_ALREADY_SET, + MSG_END_BEFORE_START, + MSG_WINDOW_CLEARED, + MSG_WINDOW_SILENCED, + MSG_WINDOW_SILENCE_DISABLED, + MSG_ERROR, + MSG_GOTO_CANCELED, + MSG_GOTO, + MSG_LEAVING_HELP, + MSG_IS_UNASSIGNED, + MSG_HELP_INFO, + MSG_EDGE_MSGS_START, + MSG_EDGE_TOP = MSG_EDGE_MSGS_START, + MSG_EDGE_BOTTOM, + MSG_EDGE_LEFT, + MSG_EDGE_RIGHT, + MSG_NUMBER, + MSG_SPACE, + MSG_START, /* A little confusing, given our convention. */ + MSG_END, /* A little confusing, given our convention. */ + MSG_CTRL, + +/* A message containing the single word "or". */ + MSG_DISJUNCTION, + MSG_ANNOUNCEMENTS_END = MSG_DISJUNCTION, + +/* Messages with format specifiers. */ + MSG_FORMATTED_START, + MSG_POS_INFO = MSG_FORMATTED_START, + MSG_CHAR_INFO, + MSG_REPEAT_DESC, + MSG_REPEAT_DESC2, + MSG_WINDOW_LINE, + MSG_WINDOW_BOUNDARY, + MSG_EDIT_PROMPT, + MSG_NO_COMMAND, + MSG_KEYDESC, + MSG_FORMATTED_END = MSG_KEYDESC, + + /* Control keys. */ + MSG_CTL_START, + MSG_CTL_SHIFT = MSG_CTL_START, + MSG_CTL_ALTGR, + MSG_CTL_CONTROL, + MSG_CTL_ALT, + MSG_CTL_LSHIFT, + MSG_CTL_SPEAKUP, + MSG_CTL_LCONTROL, + MSG_CTL_RCONTROL, + MSG_CTL_CAPSSHIFT, + MSG_CTL_END = MSG_CTL_CAPSSHIFT, + + /* Colors. */ + MSG_COLORS_START, + MSG_COLOR_BLACK = MSG_COLORS_START, + MSG_COLOR_BLUE, + MSG_COLOR_GREEN, + MSG_COLOR_CYAN, + MSG_COLOR_RED, + MSG_COLOR_MAGENTA, + MSG_COLOR_YELLOW, + MSG_COLOR_WHITE, + MSG_COLOR_GREY, + MSG_COLORS_END = MSG_COLOR_GREY, + + MSG_STATES_START, + MSG_STATE_DOUBLE = MSG_STATES_START, + MSG_STATE_SPEAKUP, + MSG_STATE_ALT, + MSG_STATE_CONTROL, + MSG_STATE_ALTGR, + MSG_STATE_SHIFT, + MSG_STATES_END = MSG_STATE_SHIFT, + + MSG_KEYNAMES_START, + MSG_KEYNAME_ESC = MSG_KEYNAMES_START, + MSG_KEYNAME_1, MSG_KEYNAME_2, MSG_KEYNAME_3, MSG_KEYNAME_4, + MSG_KEYNAME_5, MSG_KEYNAME_6, MSG_KEYNAME_7, MSG_KEYNAME_8, + MSG_KEYNAME_9, + MSG_KEYNAME_0, MSG_KEYNAME_DASH, MSG_KEYNAME_EQUAL, MSG_KEYNAME_BS, + MSG_KEYNAME_TAB, + MSG_KEYNAME_Q, MSG_KEYNAME_W, MSG_KEYNAME_E, MSG_KEYNAME_R, + MSG_KEYNAME_T, MSG_KEYNAME_Y, MSG_KEYNAME_U, MSG_KEYNAME_I, + MSG_KEYNAME_O, MSG_KEYNAME_P, + MSG_KEYNAME_LEFTBRACE, MSG_KEYNAME_RIGHTBRACE, MSG_KEYNAME_ENTER, + MSG_KEYNAME_LEFTCTRL, MSG_KEYNAME_A, + MSG_KEYNAME_S, MSG_KEYNAME_D, MSG_KEYNAME_F, MSG_KEYNAME_G, + MSG_KEYNAME_H, MSG_KEYNAME_J, MSG_KEYNAME_K, MSG_KEYNAME_L, + MSG_KEYNAME_SEMICOLON, + MSG_KEYNAME_SINGLEQUOTE, MSG_KEYNAME_GRAVE, + MSG_KEYNAME_LEFTSHFT, MSG_KEYNAME_BACKSLASH, MSG_KEYNAME_Z, + MSG_KEYNAME_X, MSG_KEYNAME_C, MSG_KEYNAME_V, MSG_KEYNAME_B, + MSG_KEYNAME_N, MSG_KEYNAME_M, MSG_KEYNAME_COMMA, MSG_KEYNAME_DOT, + MSG_KEYNAME_SLASH, MSG_KEYNAME_RIGHTSHFT, + MSG_KEYNAME_KPSTAR, + MSG_KEYNAME_LEFTALT, MSG_KEYNAME_SPACE, MSG_KEYNAME_CAPSLOCK, + MSG_KEYNAME_F1, MSG_KEYNAME_F2, + MSG_KEYNAME_F3, MSG_KEYNAME_F4, MSG_KEYNAME_F5, MSG_KEYNAME_F6, + MSG_KEYNAME_F7, + MSG_KEYNAME_F8, MSG_KEYNAME_F9, MSG_KEYNAME_F10, MSG_KEYNAME_NUMLOCK, + MSG_KEYNAME_SCROLLLOCK, + MSG_KEYNAME_KP7, MSG_KEYNAME_KP8, MSG_KEYNAME_KP9, MSG_KEYNAME_KPMINUS, + MSG_KEYNAME_KP4, + MSG_KEYNAME_KP5, MSG_KEYNAME_KP6, MSG_KEYNAME_KPPLUS, MSG_KEYNAME_KP1, + MSG_KEYNAME_KP2, + MSG_KEYNAME_KP3, MSG_KEYNAME_KP0, MSG_KEYNAME_KPDOT, MSG_KEYNAME_103RD, + MSG_KEYNAME_F13, + MSG_KEYNAME_102ND, MSG_KEYNAME_F11, MSG_KEYNAME_F12, MSG_KEYNAME_F14, + MSG_KEYNAME_F15, + MSG_KEYNAME_F16, MSG_KEYNAME_F17, MSG_KEYNAME_F18, MSG_KEYNAME_F19, + MSG_KEYNAME_F20, + MSG_KEYNAME_KPENTER, MSG_KEYNAME_RIGHTCTRL, MSG_KEYNAME_KPSLASH, + MSG_KEYNAME_SYSRQ, MSG_KEYNAME_RIGHTALT, + MSG_KEYNAME_LF, MSG_KEYNAME_HOME, MSG_KEYNAME_UP, MSG_KEYNAME_PGUP, + MSG_KEYNAME_LEFT, + MSG_KEYNAME_RIGHT, MSG_KEYNAME_END, MSG_KEYNAME_DOWN, MSG_KEYNAME_PGDN, + MSG_KEYNAME_INS, + MSG_KEYNAME_DEL, MSG_KEYNAME_MACRO, MSG_KEYNAME_MUTE, + MSG_KEYNAME_VOLDOWN, MSG_KEYNAME_VOLUP, + MSG_KEYNAME_POWER, MSG_KEYNAME_KPEQUAL, MSG_KEYNAME_KPPLUSDASH, + MSG_KEYNAME_PAUSE, MSG_KEYNAME_F21, MSG_KEYNAME_F22, MSG_KEYNAME_F23, + MSG_KEYNAME_F24, MSG_KEYNAME_KPCOMMA, MSG_KEYNAME_LEFTMETA, + MSG_KEYNAME_RIGHTMETA, MSG_KEYNAME_COMPOSE, MSG_KEYNAME_STOP, + MSG_KEYNAME_AGAIN, MSG_KEYNAME_PROPS, + MSG_KEYNAME_UNDO, MSG_KEYNAME_FRONT, MSG_KEYNAME_COPY, MSG_KEYNAME_OPEN, + MSG_KEYNAME_PASTE, + MSG_KEYNAME_FIND, MSG_KEYNAME_CUT, MSG_KEYNAME_HELP, MSG_KEYNAME_MENU, + MSG_KEYNAME_CALC, + MSG_KEYNAME_SETUP, MSG_KEYNAME_SLEEP, MSG_KEYNAME_WAKEUP, + MSG_KEYNAME_FILE, MSG_KEYNAME_SENDFILE, + MSG_KEYNAME_DELFILE, MSG_KEYNAME_XFER, MSG_KEYNAME_PROG1, + MSG_KEYNAME_PROG2, MSG_KEYNAME_WWW, + MSG_KEYNAME_MSDOS, MSG_KEYNAME_COFFEE, MSG_KEYNAME_DIRECTION, + MSG_KEYNAME_CYCLEWINDOWS, MSG_KEYNAME_MAIL, + MSG_KEYNAME_BOOKMARKS, MSG_KEYNAME_COMPUTER, MSG_KEYNAME_BACK, + MSG_KEYNAME_FORWARD, MSG_KEYNAME_CLOSECD, + MSG_KEYNAME_EJECTCD, MSG_KEYNAME_EJECTCLOSE, MSG_KEYNAME_NEXTSONG, + MSG_KEYNAME_PLAYPAUSE, MSG_KEYNAME_PREVSONG, + MSG_KEYNAME_STOPCD, MSG_KEYNAME_RECORD, MSG_KEYNAME_REWIND, + MSG_KEYNAME_PHONE, MSG_KEYNAME_ISO, + MSG_KEYNAME_CONFIG, MSG_KEYNAME_HOMEPG, MSG_KEYNAME_REFRESH, + MSG_KEYNAME_EXIT, MSG_KEYNAME_MOVE, + MSG_KEYNAME_EDIT, MSG_KEYNAME_SCROLLUP, MSG_KEYNAME_SCROLLDN, + MSG_KEYNAME_KPLEFTPAR, MSG_KEYNAME_KPRIGHTPAR, + MSG_KEYNAMES_END = MSG_KEYNAME_KPRIGHTPAR, + + MSG_FUNCNAMES_START, + MSG_FUNCNAME_ATTRIB_BLEEP_DEC = MSG_FUNCNAMES_START, + MSG_FUNCNAME_ATTRIB_BLEEP_INC, + MSG_FUNCNAME_BLEEPS_DEC, MSG_FUNCNAME_BLEEPS_INC, + MSG_FUNCNAME_CHAR_FIRST, MSG_FUNCNAME_CHAR_LAST, + MSG_FUNCNAME_CHAR_CURRENT, MSG_FUNCNAME_CHAR_HEX_AND_DEC, + MSG_FUNCNAME_CHAR_NEXT, + MSG_FUNCNAME_CHAR_PHONETIC, MSG_FUNCNAME_CHAR_PREVIOUS, + MSG_FUNCNAME_CURSOR_PARK, MSG_FUNCNAME_CUT, + MSG_FUNCNAME_EDIT_DELIM, MSG_FUNCNAME_EDIT_EXNUM, + MSG_FUNCNAME_EDIT_MOST, MSG_FUNCNAME_EDIT_REPEATS, + MSG_FUNCNAME_EDIT_SOME, + MSG_FUNCNAME_GOTO, MSG_FUNCNAME_GOTO_BOTTOM, MSG_FUNCNAME_GOTO_LEFT, + MSG_FUNCNAME_GOTO_RIGHT, MSG_FUNCNAME_GOTO_TOP, MSG_FUNCNAME_HELP, + MSG_FUNCNAME_LINE_SAY_CURRENT, MSG_FUNCNAME_LINE_SAY_NEXT, + MSG_FUNCNAME_LINE_SAY_PREVIOUS, MSG_FUNCNAME_LINE_SAY_WITH_INDENT, + MSG_FUNCNAME_PASTE, MSG_FUNCNAME_PITCH_DEC, MSG_FUNCNAME_PITCH_INC, + MSG_FUNCNAME_PUNC_DEC, MSG_FUNCNAME_PUNC_INC, + MSG_FUNCNAME_PUNC_LEVEL_DEC, MSG_FUNCNAME_PUNC_LEVEL_INC, + MSG_FUNCNAME_QUIET, + MSG_FUNCNAME_RATE_DEC, MSG_FUNCNAME_RATE_INC, + MSG_FUNCNAME_READING_PUNC_DEC, MSG_FUNCNAME_READING_PUNC_INC, + MSG_FUNCNAME_SAY_ATTRIBUTES, + MSG_FUNCNAME_SAY_FROM_LEFT, MSG_FUNCNAME_SAY_FROM_TOP, + MSG_FUNCNAME_SAY_POSITION, MSG_FUNCNAME_SAY_SCREEN, + MSG_FUNCNAME_SAY_TO_BOTTOM, MSG_FUNCNAME_SAY_TO_RIGHT, + MSG_FUNCNAME_SPEAKUP, MSG_FUNCNAME_SPEAKUP_LOCK, + MSG_FUNCNAME_SPEAKUP_OFF, MSG_FUNCNAME_SPEECH_KILL, + MSG_FUNCNAME_SPELL_DELAY_DEC, MSG_FUNCNAME_SPELL_DELAY_INC, + MSG_FUNCNAME_SPELL_WORD, MSG_FUNCNAME_SPELL_WORD_PHONETICALLY, + MSG_FUNCNAME_TONE_DEC, MSG_FUNCNAME_TONE_INC, + MSG_FUNCNAME_VOICE_DEC, MSG_FUNCNAME_VOICE_INC, + MSG_FUNCNAME_VOLUME_DEC, MSG_FUNCNAME_VOLUME_INC, + MSG_FUNCNAME_WINDOW_CLEAR, MSG_FUNCNAME_WINDOW_SAY, + MSG_FUNCNAME_WINDOW_SET, MSG_FUNCNAME_WINDOW_SILENCE, + MSG_FUNCNAME_WORD_SAY_CURRENT, MSG_FUNCNAME_WORD_SAY_NEXT, + MSG_FUNCNAME_WORD_SAY_PREVIOUS, + MSG_FUNCNAMES_END = MSG_FUNCNAME_WORD_SAY_PREVIOUS, + + /* all valid indices must be above this */ + MSG_LAST_INDEX +}; + +struct msg_group_t { + char *name; + enum msg_index_t start; + enum msg_index_t end; +}; + +char *spk_msg_get(enum msg_index_t index); +ssize_t spk_msg_set(enum msg_index_t index, char *text, size_t length); +struct msg_group_t *spk_find_msg_group(const char *group_name); +void spk_reset_msg_group(struct msg_group_t *group); +void spk_initialize_msgs(void); +void spk_free_user_msgs(void); + +#endif diff --git a/drivers/accessibility/speakup/keyhelp.c b/drivers/accessibility/speakup/keyhelp.c new file mode 100644 index 000000000000..822ceac83068 --- /dev/null +++ b/drivers/accessibility/speakup/keyhelp.c @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* speakup_keyhelp.c + * help module for speakup + * + *written by David Borowski. + * + * Copyright (C) 2003 David Borowski. + */ + +#include +#include "spk_priv.h" +#include "speakup.h" + +#define MAXFUNCS 130 +#define MAXKEYS 256 +static const int num_key_names = MSG_KEYNAMES_END - MSG_KEYNAMES_START + 1; +static u_short key_offsets[MAXFUNCS], key_data[MAXKEYS]; +static u_short masks[] = { 32, 16, 8, 4, 2, 1 }; + +static short letter_offsets[26] = { + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1 }; + +static u_char funcvals[] = { + ATTRIB_BLEEP_DEC, ATTRIB_BLEEP_INC, BLEEPS_DEC, BLEEPS_INC, + SAY_FIRST_CHAR, SAY_LAST_CHAR, SAY_CHAR, SAY_CHAR_NUM, + SAY_NEXT_CHAR, SAY_PHONETIC_CHAR, SAY_PREV_CHAR, SPEAKUP_PARKED, + SPEAKUP_CUT, EDIT_DELIM, EDIT_EXNUM, EDIT_MOST, + EDIT_REPEAT, EDIT_SOME, SPEAKUP_GOTO, BOTTOM_EDGE, + LEFT_EDGE, RIGHT_EDGE, TOP_EDGE, SPEAKUP_HELP, + SAY_LINE, SAY_NEXT_LINE, SAY_PREV_LINE, SAY_LINE_INDENT, + SPEAKUP_PASTE, PITCH_DEC, PITCH_INC, PUNCT_DEC, + PUNCT_INC, PUNC_LEVEL_DEC, PUNC_LEVEL_INC, SPEAKUP_QUIET, + RATE_DEC, RATE_INC, READING_PUNC_DEC, READING_PUNC_INC, + SAY_ATTRIBUTES, SAY_FROM_LEFT, SAY_FROM_TOP, SAY_POSITION, + SAY_SCREEN, SAY_TO_BOTTOM, SAY_TO_RIGHT, SPK_KEY, + SPK_LOCK, SPEAKUP_OFF, SPEECH_KILL, SPELL_DELAY_DEC, + SPELL_DELAY_INC, SPELL_WORD, SPELL_PHONETIC, TONE_DEC, + TONE_INC, VOICE_DEC, VOICE_INC, VOL_DEC, + VOL_INC, CLEAR_WIN, SAY_WIN, SET_WIN, + ENABLE_WIN, SAY_WORD, SAY_NEXT_WORD, SAY_PREV_WORD, 0 +}; + +static u_char *state_tbl; +static int cur_item, nstates; + +static void build_key_data(void) +{ + u_char *kp, counters[MAXFUNCS], ch, ch1; + u_short *p_key, key; + int i, offset = 1; + + nstates = (int)(state_tbl[-1]); + memset(counters, 0, sizeof(counters)); + memset(key_offsets, 0, sizeof(key_offsets)); + kp = state_tbl + nstates + 1; + while (*kp++) { + /* count occurrences of each function */ + for (i = 0; i < nstates; i++, kp++) { + if (!*kp) + continue; + if ((state_tbl[i] & 16) != 0 && *kp == SPK_KEY) + continue; + counters[*kp]++; + } + } + for (i = 0; i < MAXFUNCS; i++) { + if (counters[i] == 0) + continue; + key_offsets[i] = offset; + offset += (counters[i] + 1); + if (offset >= MAXKEYS) + break; + } +/* leave counters set so high keycodes come first. + * this is done so num pad and other extended keys maps are spoken before + * the alpha with speakup type mapping. + */ + kp = state_tbl + nstates + 1; + while ((ch = *kp++)) { + for (i = 0; i < nstates; i++) { + ch1 = *kp++; + if (!ch1) + continue; + if ((state_tbl[i] & 16) != 0 && ch1 == SPK_KEY) + continue; + key = (state_tbl[i] << 8) + ch; + counters[ch1]--; + offset = key_offsets[ch1]; + if (!offset) + continue; + p_key = key_data + offset + counters[ch1]; + *p_key = key; + } + } +} + +static void say_key(int key) +{ + int i, state = key >> 8; + + key &= 0xff; + for (i = 0; i < 6; i++) { + if (state & masks[i]) + synth_printf(" %s", spk_msg_get(MSG_STATES_START + i)); + } + if ((key > 0) && (key <= num_key_names)) + synth_printf(" %s\n", + spk_msg_get(MSG_KEYNAMES_START + (key - 1))); +} + +static int help_init(void) +{ + char start = SPACE; + int i; + int num_funcs = MSG_FUNCNAMES_END - MSG_FUNCNAMES_START + 1; + + state_tbl = spk_our_keys[0] + SHIFT_TBL_SIZE + 2; + for (i = 0; i < num_funcs; i++) { + char *cur_funcname = spk_msg_get(MSG_FUNCNAMES_START + i); + + if (start == *cur_funcname) + continue; + start = *cur_funcname; + letter_offsets[(start & 31) - 1] = i; + } + return 0; +} + +int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key) +{ + int i, n; + char *name; + u_char func, *kp; + u_short *p_keys, val; + + if (letter_offsets[0] == -1) + help_init(); + if (type == KT_LATIN) { + if (ch == SPACE) { + spk_special_handler = NULL; + synth_printf("%s\n", spk_msg_get(MSG_LEAVING_HELP)); + return 1; + } + ch |= 32; /* lower case */ + if (ch < 'a' || ch > 'z') + return -1; + if (letter_offsets[ch - 'a'] == -1) { + synth_printf(spk_msg_get(MSG_NO_COMMAND), ch); + synth_printf("\n"); + return 1; + } + cur_item = letter_offsets[ch - 'a']; + } else if (type == KT_CUR) { + if (ch == 0 && + (MSG_FUNCNAMES_START + cur_item + 1) <= MSG_FUNCNAMES_END) + cur_item++; + else if (ch == 3 && cur_item > 0) + cur_item--; + else + return -1; + } else if (type == KT_SPKUP && ch == SPEAKUP_HELP && + !spk_special_handler) { + spk_special_handler = spk_handle_help; + synth_printf("%s\n", spk_msg_get(MSG_HELP_INFO)); + build_key_data(); /* rebuild each time in case new mapping */ + return 1; + } else { + name = NULL; + if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) { + synth_printf("%s\n", + spk_msg_get(MSG_KEYNAMES_START + key - 1)); + return 1; + } + for (i = 0; funcvals[i] != 0 && !name; i++) { + if (ch == funcvals[i]) + name = spk_msg_get(MSG_FUNCNAMES_START + i); + } + if (!name) + return -1; + kp = spk_our_keys[key] + 1; + for (i = 0; i < nstates; i++) { + if (ch == kp[i]) + break; + } + key += (state_tbl[i] << 8); + say_key(key); + synth_printf(spk_msg_get(MSG_KEYDESC), name); + synth_printf("\n"); + return 1; + } + name = spk_msg_get(MSG_FUNCNAMES_START + cur_item); + func = funcvals[cur_item]; + synth_printf("%s", name); + if (key_offsets[func] == 0) { + synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED)); + return 1; + } + p_keys = key_data + key_offsets[func]; + for (n = 0; p_keys[n]; n++) { + val = p_keys[n]; + if (n > 0) + synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION)); + say_key(val); + } + return 1; +} diff --git a/drivers/accessibility/speakup/kobjects.c b/drivers/accessibility/speakup/kobjects.c new file mode 100644 index 000000000000..41ae24ab5d08 --- /dev/null +++ b/drivers/accessibility/speakup/kobjects.c @@ -0,0 +1,1056 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Speakup kobject implementation + * + * Copyright (C) 2009 William Hubbs + * + * This code is based on kobject-example.c, which came with linux 2.6.x. + * + * Copyright (C) 2004-2007 Greg Kroah-Hartman + * Copyright (C) 2007 Novell Inc. + * + * Released under the GPL version 2 only. + * + */ +#include /* For kmalloc. */ +#include +#include +#include +#include +#include +#include + +#include "speakup.h" +#include "spk_priv.h" + +/* + * This is called when a user reads the characters or chartab sys file. + */ +static ssize_t chars_chartab_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + int i; + int len = 0; + char *cp; + char *buf_pointer = buf; + size_t bufsize = PAGE_SIZE; + unsigned long flags; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + *buf_pointer = '\0'; + for (i = 0; i < 256; i++) { + if (bufsize <= 1) + break; + if (strcmp("characters", attr->attr.name) == 0) { + len = scnprintf(buf_pointer, bufsize, "%d\t%s\n", + i, spk_characters[i]); + } else { /* show chartab entry */ + if (IS_TYPE(i, B_CTL)) + cp = "B_CTL"; + else if (IS_TYPE(i, WDLM)) + cp = "WDLM"; + else if (IS_TYPE(i, A_PUNC)) + cp = "A_PUNC"; + else if (IS_TYPE(i, PUNC)) + cp = "PUNC"; + else if (IS_TYPE(i, NUM)) + cp = "NUM"; + else if (IS_TYPE(i, A_CAP)) + cp = "A_CAP"; + else if (IS_TYPE(i, ALPHA)) + cp = "ALPHA"; + else if (IS_TYPE(i, B_CAPSYM)) + cp = "B_CAPSYM"; + else if (IS_TYPE(i, B_SYM)) + cp = "B_SYM"; + else + cp = "0"; + len = + scnprintf(buf_pointer, bufsize, "%d\t%s\n", i, cp); + } + bufsize -= len; + buf_pointer += len; + } + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return buf_pointer - buf; +} + +/* + * Print informational messages or warnings after updating + * character descriptions or chartab entries. + */ +static void report_char_chartab_status(int reset, int received, int used, + int rejected, int do_characters) +{ + static char const *object_type[] = { + "character class entries", + "character descriptions", + }; + int len; + char buf[80]; + + if (reset) { + pr_info("%s reset to defaults\n", object_type[do_characters]); + } else if (received) { + len = snprintf(buf, sizeof(buf), + " updated %d of %d %s\n", + used, received, object_type[do_characters]); + if (rejected) + snprintf(buf + (len - 1), sizeof(buf) - (len - 1), + " with %d reject%s\n", + rejected, rejected > 1 ? "s" : ""); + pr_info("%s", buf); + } +} + +/* + * This is called when a user changes the characters or chartab parameters. + */ +static ssize_t chars_chartab_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + char *cp = (char *)buf; + char *end = cp + count; /* the null at the end of the buffer */ + char *linefeed = NULL; + char keyword[MAX_DESC_LEN + 1]; + char *outptr = NULL; /* Will hold keyword or desc. */ + char *temp = NULL; + char *desc = NULL; + ssize_t retval = count; + unsigned long flags; + unsigned long index = 0; + int charclass = 0; + int received = 0; + int used = 0; + int rejected = 0; + int reset = 0; + int do_characters = !strcmp(attr->attr.name, "characters"); + size_t desc_length = 0; + int i; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + while (cp < end) { + while ((cp < end) && (*cp == ' ' || *cp == '\t')) + cp++; + + if (cp == end) + break; + if ((*cp == '\n') || strchr("dDrR", *cp)) { + reset = 1; + break; + } + received++; + + linefeed = strchr(cp, '\n'); + if (!linefeed) { + rejected++; + break; + } + + if (!isdigit(*cp)) { + rejected++; + cp = linefeed + 1; + continue; + } + + /* + * Do not replace with kstrtoul: + * here we need temp to be updated + */ + index = simple_strtoul(cp, &temp, 10); + if (index > 255) { + rejected++; + cp = linefeed + 1; + continue; + } + + while ((temp < linefeed) && (*temp == ' ' || *temp == '\t')) + temp++; + + desc_length = linefeed - temp; + if (desc_length > MAX_DESC_LEN) { + rejected++; + cp = linefeed + 1; + continue; + } + if (do_characters) { + desc = kmalloc(desc_length + 1, GFP_ATOMIC); + if (!desc) { + retval = -ENOMEM; + reset = 1; /* just reset on error. */ + break; + } + outptr = desc; + } else { + outptr = keyword; + } + + for (i = 0; i < desc_length; i++) + outptr[i] = temp[i]; + outptr[desc_length] = '\0'; + + if (do_characters) { + if (spk_characters[index] != spk_default_chars[index]) + kfree(spk_characters[index]); + spk_characters[index] = desc; + used++; + } else { + charclass = spk_chartab_get_value(keyword); + if (charclass == 0) { + rejected++; + cp = linefeed + 1; + continue; + } + if (charclass != spk_chartab[index]) { + spk_chartab[index] = charclass; + used++; + } + } + cp = linefeed + 1; + } + + if (reset) { + if (do_characters) + spk_reset_default_chars(); + else + spk_reset_default_chartab(); + } + + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + report_char_chartab_status(reset, received, used, rejected, + do_characters); + return retval; +} + +/* + * This is called when a user reads the keymap parameter. + */ +static ssize_t keymap_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + char *cp = buf; + int i; + int n; + int num_keys; + int nstates; + u_char *cp1; + u_char ch; + unsigned long flags; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + cp1 = spk_key_buf + SHIFT_TBL_SIZE; + num_keys = (int)(*cp1); + nstates = (int)cp1[1]; + cp += sprintf(cp, "%d, %d, %d,\n", KEY_MAP_VER, num_keys, nstates); + cp1 += 2; /* now pointing at shift states */ + /* dump num_keys+1 as first row is shift states + flags, + * each subsequent row is key + states + */ + for (n = 0; n <= num_keys; n++) { + for (i = 0; i <= nstates; i++) { + ch = *cp1++; + cp += sprintf(cp, "%d,", (int)ch); + *cp++ = (i < nstates) ? SPACE : '\n'; + } + } + cp += sprintf(cp, "0, %d\n", KEY_MAP_VER); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return (int)(cp - buf); +} + +/* + * This is called when a user changes the keymap parameter. + */ +static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) +{ + int i; + ssize_t ret = count; + char *in_buff = NULL; + char *cp; + u_char *cp1; + unsigned long flags; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + in_buff = kmemdup(buf, count + 1, GFP_ATOMIC); + if (!in_buff) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return -ENOMEM; + } + if (strchr("dDrR", *in_buff)) { + spk_set_key_info(spk_key_defaults, spk_key_buf); + pr_info("keymap set to default values\n"); + kfree(in_buff); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return count; + } + if (in_buff[count - 1] == '\n') + in_buff[count - 1] = '\0'; + cp = in_buff; + cp1 = (u_char *)in_buff; + for (i = 0; i < 3; i++) { + cp = spk_s2uchar(cp, cp1); + cp1++; + } + i = (int)cp1[-2] + 1; + i *= (int)cp1[-1] + 1; + i += 2; /* 0 and last map ver */ + if (cp1[-3] != KEY_MAP_VER || cp1[-1] > 10 || + i + SHIFT_TBL_SIZE + 4 >= sizeof(spk_key_buf)) { + pr_warn("i %d %d %d %d\n", i, + (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]); + kfree(in_buff); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return -EINVAL; + } + while (--i >= 0) { + cp = spk_s2uchar(cp, cp1); + cp1++; + if (!(*cp)) + break; + } + if (i != 0 || cp1[-1] != KEY_MAP_VER || cp1[-2] != 0) { + ret = -EINVAL; + pr_warn("end %d %d %d %d\n", i, + (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]); + } else { + if (spk_set_key_info(in_buff, spk_key_buf)) { + spk_set_key_info(spk_key_defaults, spk_key_buf); + ret = -EINVAL; + pr_warn("set key failed\n"); + } + } + kfree(in_buff); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return ret; +} + +/* + * This is called when a user changes the value of the silent parameter. + */ +static ssize_t silent_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) +{ + int len; + struct vc_data *vc = vc_cons[fg_console].d; + char ch = 0; + char shut; + unsigned long flags; + + len = strlen(buf); + if (len > 0 && len < 3) { + ch = buf[0]; + if (ch == '\n') + ch = '0'; + } + if (ch < '0' || ch > '7') { + pr_warn("silent value '%c' not in range (0,7)\n", ch); + return -EINVAL; + } + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (ch & 2) { + shut = 1; + spk_do_flush(); + } else { + shut = 0; + } + if (ch & 4) + shut |= 0x40; + if (ch & 1) + spk_shut_up |= shut; + else + spk_shut_up &= ~shut; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return count; +} + +/* + * This is called when a user reads the synth setting. + */ +static ssize_t synth_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + int rv; + + if (!synth) + rv = sprintf(buf, "%s\n", "none"); + else + rv = sprintf(buf, "%s\n", synth->name); + return rv; +} + +/* + * This is called when a user requests to change synthesizers. + */ +static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) +{ + int len; + char new_synth_name[10]; + + len = strlen(buf); + if (len < 2 || len > 9) + return -EINVAL; + memcpy(new_synth_name, buf, len); + if (new_synth_name[len - 1] == '\n') + len--; + new_synth_name[len] = '\0'; + spk_strlwr(new_synth_name); + if (synth && !strcmp(new_synth_name, synth->name)) { + pr_warn("%s already in use\n", new_synth_name); + } else if (synth_init(new_synth_name) != 0) { + pr_warn("failed to init synth %s\n", new_synth_name); + return -ENODEV; + } + return count; +} + +/* + * This is called when text is sent to the synth via the synth_direct file. + */ +static ssize_t synth_direct_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + u_char tmp[256]; + int len; + int bytes; + const char *ptr = buf; + unsigned long flags; + + if (!synth) + return -EPERM; + + len = strlen(buf); + spin_lock_irqsave(&speakup_info.spinlock, flags); + while (len > 0) { + bytes = min_t(size_t, len, 250); + strncpy(tmp, ptr, bytes); + tmp[bytes] = '\0'; + string_unescape_any_inplace(tmp); + synth_printf("%s", tmp); + ptr += bytes; + len -= bytes; + } + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return count; +} + +/* + * This function is called when a user reads the version. + */ +static ssize_t version_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + char *cp; + + cp = buf; + cp += sprintf(cp, "Speakup version %s\n", SPEAKUP_VERSION); + if (synth) + cp += sprintf(cp, "%s synthesizer driver version %s\n", + synth->name, synth->version); + return cp - buf; +} + +/* + * This is called when a user reads the punctuation settings. + */ +static ssize_t punc_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + int i; + char *cp = buf; + struct st_var_header *p_header; + struct punc_var_t *var; + struct st_bits_data *pb; + short mask; + unsigned long flags; + + p_header = spk_var_header_by_name(attr->attr.name); + if (!p_header) { + pr_warn("p_header is null, attr->attr.name is %s\n", + attr->attr.name); + return -EINVAL; + } + + var = spk_get_punc_var(p_header->var_id); + if (!var) { + pr_warn("var is null, p_header->var_id is %i\n", + p_header->var_id); + return -EINVAL; + } + + spin_lock_irqsave(&speakup_info.spinlock, flags); + pb = (struct st_bits_data *)&spk_punc_info[var->value]; + mask = pb->mask; + for (i = 33; i < 128; i++) { + if (!(spk_chartab[i] & mask)) + continue; + *cp++ = (char)i; + } + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return cp - buf; +} + +/* + * This is called when a user changes the punctuation settings. + */ +static ssize_t punc_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) +{ + int x; + struct st_var_header *p_header; + struct punc_var_t *var; + char punc_buf[100]; + unsigned long flags; + + x = strlen(buf); + if (x < 1 || x > 99) + return -EINVAL; + + p_header = spk_var_header_by_name(attr->attr.name); + if (!p_header) { + pr_warn("p_header is null, attr->attr.name is %s\n", + attr->attr.name); + return -EINVAL; + } + + var = spk_get_punc_var(p_header->var_id); + if (!var) { + pr_warn("var is null, p_header->var_id is %i\n", + p_header->var_id); + return -EINVAL; + } + + memcpy(punc_buf, buf, x); + + while (x && punc_buf[x - 1] == '\n') + x--; + punc_buf[x] = '\0'; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + + if (*punc_buf == 'd' || *punc_buf == 'r') + x = spk_set_mask_bits(NULL, var->value, 3); + else + x = spk_set_mask_bits(punc_buf, var->value, 3); + + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return count; +} + +/* + * This function is called when a user reads one of the variable parameters. + */ +ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + int rv = 0; + struct st_var_header *param; + struct var_t *var; + char *cp1; + char *cp; + char ch; + unsigned long flags; + + param = spk_var_header_by_name(attr->attr.name); + if (!param) + return -EINVAL; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + var = (struct var_t *)param->data; + switch (param->var_type) { + case VAR_NUM: + case VAR_TIME: + if (var) + rv = sprintf(buf, "%i\n", var->u.n.value); + else + rv = sprintf(buf, "0\n"); + break; + case VAR_STRING: + if (var) { + cp1 = buf; + *cp1++ = '"'; + for (cp = (char *)param->p_val; (ch = *cp); cp++) { + if (ch >= ' ' && ch < '~') + *cp1++ = ch; + else + cp1 += sprintf(cp1, "\\x%02x", ch); + } + *cp1++ = '"'; + *cp1++ = '\n'; + *cp1 = '\0'; + rv = cp1 - buf; + } else { + rv = sprintf(buf, "\"\"\n"); + } + break; + default: + rv = sprintf(buf, "Bad parameter %s, type %i\n", + param->name, param->var_type); + break; + } + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return rv; +} +EXPORT_SYMBOL_GPL(spk_var_show); + +/* + * Used to reset either default_pitch or default_vol. + */ +static inline void spk_reset_default_value(char *header_name, + int *synth_default_value, int idx) +{ + struct st_var_header *param; + + if (synth && synth_default_value) { + param = spk_var_header_by_name(header_name); + if (param) { + spk_set_num_var(synth_default_value[idx], + param, E_NEW_DEFAULT); + spk_set_num_var(0, param, E_DEFAULT); + pr_info("%s reset to default value\n", param->name); + } + } +} + +/* + * This function is called when a user echos a value to one of the + * variable parameters. + */ +ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) +{ + struct st_var_header *param; + int ret; + int len; + char *cp; + struct var_t *var_data; + long value; + unsigned long flags; + + param = spk_var_header_by_name(attr->attr.name); + if (!param) + return -EINVAL; + if (!param->data) + return 0; + ret = 0; + cp = (char *)buf; + string_unescape_any_inplace(cp); + + spin_lock_irqsave(&speakup_info.spinlock, flags); + switch (param->var_type) { + case VAR_NUM: + case VAR_TIME: + if (*cp == 'd' || *cp == 'r' || *cp == '\0') + len = E_DEFAULT; + else if (*cp == '+' || *cp == '-') + len = E_INC; + else + len = E_SET; + if (kstrtol(cp, 10, &value) == 0) + ret = spk_set_num_var(value, param, len); + else + pr_warn("overflow or parsing error has occurred"); + if (ret == -ERANGE) { + var_data = param->data; + pr_warn("value for %s out of range, expect %d to %d\n", + param->name, + var_data->u.n.low, var_data->u.n.high); + } + + /* + * If voice was just changed, we might need to reset our default + * pitch and volume. + */ + if (param->var_id == VOICE && synth && + (ret == 0 || ret == -ERESTART)) { + var_data = param->data; + value = var_data->u.n.value; + spk_reset_default_value("pitch", synth->default_pitch, + value); + spk_reset_default_value("vol", synth->default_vol, + value); + } + break; + case VAR_STRING: + len = strlen(cp); + if ((len >= 1) && (cp[len - 1] == '\n')) + --len; + if ((len >= 2) && (cp[0] == '"') && (cp[len - 1] == '"')) { + ++cp; + len -= 2; + } + cp[len] = '\0'; + ret = spk_set_string_var(cp, param, len); + if (ret == -E2BIG) + pr_warn("value too long for %s\n", + param->name); + break; + default: + pr_warn("%s unknown type %d\n", + param->name, (int)param->var_type); + break; + } + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + + if (ret == -ERESTART) + pr_info("%s reset to default value\n", param->name); + return count; +} +EXPORT_SYMBOL_GPL(spk_var_store); + +/* + * Functions for reading and writing lists of i18n messages. Incomplete. + */ + +static ssize_t message_show_helper(char *buf, enum msg_index_t first, + enum msg_index_t last) +{ + size_t bufsize = PAGE_SIZE; + char *buf_pointer = buf; + int printed; + enum msg_index_t cursor; + int index = 0; + *buf_pointer = '\0'; /* buf_pointer always looking at a NUL byte. */ + + for (cursor = first; cursor <= last; cursor++, index++) { + if (bufsize <= 1) + break; + printed = scnprintf(buf_pointer, bufsize, "%d\t%s\n", + index, spk_msg_get(cursor)); + buf_pointer += printed; + bufsize -= printed; + } + + return buf_pointer - buf; +} + +static void report_msg_status(int reset, int received, int used, + int rejected, char *groupname) +{ + int len; + char buf[160]; + + if (reset) { + pr_info("i18n messages from group %s reset to defaults\n", + groupname); + } else if (received) { + len = snprintf(buf, sizeof(buf), + " updated %d of %d i18n messages from group %s\n", + used, received, groupname); + if (rejected) + snprintf(buf + (len - 1), sizeof(buf) - (len - 1), + " with %d reject%s\n", + rejected, rejected > 1 ? "s" : ""); + pr_info("%s", buf); + } +} + +static ssize_t message_store_helper(const char *buf, size_t count, + struct msg_group_t *group) +{ + char *cp = (char *)buf; + char *end = cp + count; + char *linefeed = NULL; + char *temp = NULL; + ssize_t msg_stored = 0; + ssize_t retval = count; + size_t desc_length = 0; + unsigned long index = 0; + int received = 0; + int used = 0; + int rejected = 0; + int reset = 0; + enum msg_index_t firstmessage = group->start; + enum msg_index_t lastmessage = group->end; + enum msg_index_t curmessage; + + while (cp < end) { + while ((cp < end) && (*cp == ' ' || *cp == '\t')) + cp++; + + if (cp == end) + break; + if (strchr("dDrR", *cp)) { + reset = 1; + break; + } + received++; + + linefeed = strchr(cp, '\n'); + if (!linefeed) { + rejected++; + break; + } + + if (!isdigit(*cp)) { + rejected++; + cp = linefeed + 1; + continue; + } + + /* + * Do not replace with kstrtoul: + * here we need temp to be updated + */ + index = simple_strtoul(cp, &temp, 10); + + while ((temp < linefeed) && (*temp == ' ' || *temp == '\t')) + temp++; + + desc_length = linefeed - temp; + curmessage = firstmessage + index; + + /* + * Note the check (curmessage < firstmessage). It is not + * redundant. Suppose that the user gave us an index + * equal to ULONG_MAX - 1. If firstmessage > 1, then + * firstmessage + index < firstmessage! + */ + + if ((curmessage < firstmessage) || (curmessage > lastmessage)) { + rejected++; + cp = linefeed + 1; + continue; + } + + msg_stored = spk_msg_set(curmessage, temp, desc_length); + if (msg_stored < 0) { + retval = msg_stored; + if (msg_stored == -ENOMEM) + reset = 1; + break; + } + + used++; + + cp = linefeed + 1; + } + + if (reset) + spk_reset_msg_group(group); + + report_msg_status(reset, received, used, rejected, group->name); + return retval; +} + +static ssize_t message_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + ssize_t retval = 0; + struct msg_group_t *group = spk_find_msg_group(attr->attr.name); + unsigned long flags; + + if (WARN_ON(!group)) + return -EINVAL; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + retval = message_show_helper(buf, group->start, group->end); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return retval; +} + +static ssize_t message_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) +{ + struct msg_group_t *group = spk_find_msg_group(attr->attr.name); + + if (WARN_ON(!group)) + return -EINVAL; + + return message_store_helper(buf, count, group); +} + +/* + * Declare the attributes. + */ +static struct kobj_attribute keymap_attribute = + __ATTR_RW(keymap); +static struct kobj_attribute silent_attribute = + __ATTR_WO(silent); +static struct kobj_attribute synth_attribute = + __ATTR_RW(synth); +static struct kobj_attribute synth_direct_attribute = + __ATTR_WO(synth_direct); +static struct kobj_attribute version_attribute = + __ATTR_RO(version); + +static struct kobj_attribute delimiters_attribute = + __ATTR(delimiters, 0644, punc_show, punc_store); +static struct kobj_attribute ex_num_attribute = + __ATTR(ex_num, 0644, punc_show, punc_store); +static struct kobj_attribute punc_all_attribute = + __ATTR(punc_all, 0644, punc_show, punc_store); +static struct kobj_attribute punc_most_attribute = + __ATTR(punc_most, 0644, punc_show, punc_store); +static struct kobj_attribute punc_some_attribute = + __ATTR(punc_some, 0644, punc_show, punc_store); +static struct kobj_attribute repeats_attribute = + __ATTR(repeats, 0644, punc_show, punc_store); + +static struct kobj_attribute attrib_bleep_attribute = + __ATTR(attrib_bleep, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute bell_pos_attribute = + __ATTR(bell_pos, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute bleep_time_attribute = + __ATTR(bleep_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute bleeps_attribute = + __ATTR(bleeps, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute cursor_time_attribute = + __ATTR(cursor_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute key_echo_attribute = + __ATTR(key_echo, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute no_interrupt_attribute = + __ATTR(no_interrupt, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute punc_level_attribute = + __ATTR(punc_level, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute reading_punc_attribute = + __ATTR(reading_punc, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute say_control_attribute = + __ATTR(say_control, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute say_word_ctl_attribute = + __ATTR(say_word_ctl, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute spell_delay_attribute = + __ATTR(spell_delay, 0644, spk_var_show, spk_var_store); + +/* + * These attributes are i18n related. + */ +static struct kobj_attribute announcements_attribute = + __ATTR(announcements, 0644, message_show, message_store); +static struct kobj_attribute characters_attribute = + __ATTR(characters, 0644, chars_chartab_show, + chars_chartab_store); +static struct kobj_attribute chartab_attribute = + __ATTR(chartab, 0644, chars_chartab_show, + chars_chartab_store); +static struct kobj_attribute ctl_keys_attribute = + __ATTR(ctl_keys, 0644, message_show, message_store); +static struct kobj_attribute colors_attribute = + __ATTR(colors, 0644, message_show, message_store); +static struct kobj_attribute formatted_attribute = + __ATTR(formatted, 0644, message_show, message_store); +static struct kobj_attribute function_names_attribute = + __ATTR(function_names, 0644, message_show, message_store); +static struct kobj_attribute key_names_attribute = + __ATTR(key_names, 0644, message_show, message_store); +static struct kobj_attribute states_attribute = + __ATTR(states, 0644, message_show, message_store); + +/* + * Create groups of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *main_attrs[] = { + &keymap_attribute.attr, + &silent_attribute.attr, + &synth_attribute.attr, + &synth_direct_attribute.attr, + &version_attribute.attr, + &delimiters_attribute.attr, + &ex_num_attribute.attr, + &punc_all_attribute.attr, + &punc_most_attribute.attr, + &punc_some_attribute.attr, + &repeats_attribute.attr, + &attrib_bleep_attribute.attr, + &bell_pos_attribute.attr, + &bleep_time_attribute.attr, + &bleeps_attribute.attr, + &cursor_time_attribute.attr, + &key_echo_attribute.attr, + &no_interrupt_attribute.attr, + &punc_level_attribute.attr, + &reading_punc_attribute.attr, + &say_control_attribute.attr, + &say_word_ctl_attribute.attr, + &spell_delay_attribute.attr, + NULL, +}; + +static struct attribute *i18n_attrs[] = { + &announcements_attribute.attr, + &characters_attribute.attr, + &chartab_attribute.attr, + &ctl_keys_attribute.attr, + &colors_attribute.attr, + &formatted_attribute.attr, + &function_names_attribute.attr, + &key_names_attribute.attr, + &states_attribute.attr, + NULL, +}; + +/* + * An unnamed attribute group will put all of the attributes directly in + * the kobject directory. If we specify a name, a subdirectory will be + * created for the attributes with the directory being the name of the + * attribute group. + */ +static const struct attribute_group main_attr_group = { + .attrs = main_attrs, +}; + +static const struct attribute_group i18n_attr_group = { + .attrs = i18n_attrs, + .name = "i18n", +}; + +static struct kobject *accessibility_kobj; +struct kobject *speakup_kobj; + +int speakup_kobj_init(void) +{ + int retval; + + /* + * Create a simple kobject with the name of "accessibility", + * located under /sys/ + * + * As this is a simple directory, no uevent will be sent to + * userspace. That is why this function should not be used for + * any type of dynamic kobjects, where the name and number are + * not known ahead of time. + */ + accessibility_kobj = kobject_create_and_add("accessibility", NULL); + if (!accessibility_kobj) { + retval = -ENOMEM; + goto out; + } + + speakup_kobj = kobject_create_and_add("speakup", accessibility_kobj); + if (!speakup_kobj) { + retval = -ENOMEM; + goto err_acc; + } + + /* Create the files associated with this kobject */ + retval = sysfs_create_group(speakup_kobj, &main_attr_group); + if (retval) + goto err_speakup; + + retval = sysfs_create_group(speakup_kobj, &i18n_attr_group); + if (retval) + goto err_group; + + goto out; + +err_group: + sysfs_remove_group(speakup_kobj, &main_attr_group); +err_speakup: + kobject_put(speakup_kobj); +err_acc: + kobject_put(accessibility_kobj); +out: + return retval; +} + +void speakup_kobj_exit(void) +{ + sysfs_remove_group(speakup_kobj, &i18n_attr_group); + sysfs_remove_group(speakup_kobj, &main_attr_group); + kobject_put(speakup_kobj); + kobject_put(accessibility_kobj); +} diff --git a/drivers/accessibility/speakup/main.c b/drivers/accessibility/speakup/main.c new file mode 100644 index 000000000000..02471d932d71 --- /dev/null +++ b/drivers/accessibility/speakup/main.c @@ -0,0 +1,2460 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* speakup.c + * review functions for the speakup screen review package. + * originally written by: Kirk Reiser and Andy Berdan. + * + * extensively modified by David Borowski. + * + ** Copyright (C) 1998 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + */ + +#include +#include +#include +#include /* __get_free_page() and friends */ +#include +#include +#include +#include +#include +#include +#include /* for KT_SHIFT */ +#include /* for vc_kbd_* and friends */ +#include +#include + +/* speakup_*_selection */ +#include +#include +#include +#include +#include + +#include +#include + +#include /* copy_from|to|user() and others */ + +#include "spk_priv.h" +#include "speakup.h" + +#define MAX_DELAY msecs_to_jiffies(500) +#define MINECHOCHAR SPACE + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_AUTHOR("Daniel Drake "); +MODULE_DESCRIPTION("Speakup console speech"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(SPEAKUP_VERSION); + +char *synth_name; +module_param_named(synth, synth_name, charp, 0444); +module_param_named(quiet, spk_quiet_boot, bool, 0444); + +MODULE_PARM_DESC(synth, "Synth to start if speakup is built in."); +MODULE_PARM_DESC(quiet, "Do not announce when the synthesizer is found."); + +special_func spk_special_handler; + +short spk_pitch_shift, synth_flags; +static u16 buf[256]; +int spk_attrib_bleep, spk_bleeps, spk_bleep_time = 10; +int spk_no_intr, spk_spell_delay; +int spk_key_echo, spk_say_word_ctl; +int spk_say_ctrl, spk_bell_pos; +short spk_punc_mask; +int spk_punc_level, spk_reading_punc; +char spk_str_caps_start[MAXVARLEN + 1] = "\0"; +char spk_str_caps_stop[MAXVARLEN + 1] = "\0"; +char spk_str_pause[MAXVARLEN + 1] = "\0"; +bool spk_paused; +const struct st_bits_data spk_punc_info[] = { + {"none", "", 0}, + {"some", "/$%&@", SOME}, + {"most", "$%&#()=+*/@^<>|\\", MOST}, + {"all", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", PUNC}, + {"delimiters", "", B_WDLM}, + {"repeats", "()", CH_RPT}, + {"extended numeric", "", B_EXNUM}, + {"symbols", "", B_SYM}, + {NULL, NULL} +}; + +static char mark_cut_flag; +#define MAX_KEY 160 +static u_char *spk_shift_table; +u_char *spk_our_keys[MAX_KEY]; +u_char spk_key_buf[600]; +const u_char spk_key_defaults[] = { +#include "speakupmap.h" +}; + +/* Speakup Cursor Track Variables */ +static int cursor_track = 1, prev_cursor_track = 1; + +/* cursor track modes, must be ordered same as cursor_msgs */ +enum { + CT_Off = 0, + CT_On, + CT_Highlight, + CT_Window, + CT_Max +}; + +#define read_all_mode CT_Max + +static struct tty_struct *tty; + +static void spkup_write(const u16 *in_buf, int count); + +static char *phonetic[] = { + "alfa", "bravo", "charlie", "delta", "echo", "foxtrot", "golf", "hotel", + "india", "juliett", "keelo", "leema", "mike", "november", "oscar", + "papa", + "keh beck", "romeo", "sierra", "tango", "uniform", "victer", "whiskey", + "x ray", "yankee", "zulu" +}; + +/* array of 256 char pointers (one for each character description) + * initialized to default_chars and user selectable via + * /proc/speakup/characters + */ +char *spk_characters[256]; + +char *spk_default_chars[256] = { +/*000*/ "null", "^a", "^b", "^c", "^d", "^e", "^f", "^g", +/*008*/ "^h", "^i", "^j", "^k", "^l", "^m", "^n", "^o", +/*016*/ "^p", "^q", "^r", "^s", "^t", "^u", "^v", "^w", +/*024*/ "^x", "^y", "^z", "control", "control", "control", "control", + "control", +/*032*/ "space", "bang!", "quote", "number", "dollar", "percent", "and", + "tick", +/*040*/ "left paren", "right paren", "star", "plus", "comma", "dash", + "dot", + "slash", +/*048*/ "zero", "one", "two", "three", "four", "five", "six", "seven", + "eight", "nine", +/*058*/ "colon", "semmy", "less", "equals", "greater", "question", "at", +/*065*/ "EIGH", "B", "C", "D", "E", "F", "G", +/*072*/ "H", "I", "J", "K", "L", "M", "N", "O", +/*080*/ "P", "Q", "R", "S", "T", "U", "V", "W", "X", +/*089*/ "Y", "ZED", "left bracket", "backslash", "right bracket", + "caret", + "line", +/*096*/ "accent", "a", "b", "c", "d", "e", "f", "g", +/*104*/ "h", "i", "j", "k", "l", "m", "n", "o", +/*112*/ "p", "q", "r", "s", "t", "u", "v", "w", +/*120*/ "x", "y", "zed", "left brace", "bar", "right brace", "tihlduh", +/*127*/ "del", "control", "control", "control", "control", "control", + "control", "control", "control", "control", "control", +/*138*/ "control", "control", "control", "control", "control", + "control", "control", "control", "control", "control", + "control", "control", +/*150*/ "control", "control", "control", "control", "control", + "control", "control", "control", "control", "control", +/*160*/ "nbsp", "inverted bang", +/*162*/ "cents", "pounds", "currency", "yen", "broken bar", "section", +/*168*/ "diaeresis", "copyright", "female ordinal", "double left angle", +/*172*/ "not", "soft hyphen", "registered", "macron", +/*176*/ "degrees", "plus or minus", "super two", "super three", +/*180*/ "acute accent", "micro", "pilcrow", "middle dot", +/*184*/ "cedilla", "super one", "male ordinal", "double right angle", +/*188*/ "one quarter", "one half", "three quarters", + "inverted question", +/*192*/ "A GRAVE", "A ACUTE", "A CIRCUMFLEX", "A TILDE", "A OOMLAUT", + "A RING", +/*198*/ "AE", "C CIDELLA", "E GRAVE", "E ACUTE", "E CIRCUMFLEX", + "E OOMLAUT", +/*204*/ "I GRAVE", "I ACUTE", "I CIRCUMFLEX", "I OOMLAUT", "ETH", + "N TILDE", +/*210*/ "O GRAVE", "O ACUTE", "O CIRCUMFLEX", "O TILDE", "O OOMLAUT", +/*215*/ "multiplied by", "O STROKE", "U GRAVE", "U ACUTE", + "U CIRCUMFLEX", +/*220*/ "U OOMLAUT", "Y ACUTE", "THORN", "sharp s", "a grave", +/*225*/ "a acute", "a circumflex", "a tilde", "a oomlaut", "a ring", +/*230*/ "ae", "c cidella", "e grave", "e acute", +/*234*/ "e circumflex", "e oomlaut", "i grave", "i acute", + "i circumflex", +/*239*/ "i oomlaut", "eth", "n tilde", "o grave", "o acute", + "o circumflex", +/*245*/ "o tilde", "o oomlaut", "divided by", "o stroke", "u grave", + "u acute", +/* 251 */ "u circumflex", "u oomlaut", "y acute", "thorn", "y oomlaut" +}; + +/* array of 256 u_short (one for each character) + * initialized to default_chartab and user selectable via + * /sys/module/speakup/parameters/chartab + */ +u_short spk_chartab[256]; + +static u_short default_chartab[256] = { + B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, /* 0-7 */ + B_CTL, B_CTL, A_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, /* 8-15 */ + B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, /*16-23 */ + B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, /* 24-31 */ + WDLM, A_PUNC, PUNC, PUNC, PUNC, PUNC, PUNC, A_PUNC, /* !"#$%&' */ + PUNC, PUNC, PUNC, PUNC, A_PUNC, A_PUNC, A_PUNC, PUNC, /* ()*+, -./ */ + NUM, NUM, NUM, NUM, NUM, NUM, NUM, NUM, /* 01234567 */ + NUM, NUM, A_PUNC, PUNC, PUNC, PUNC, PUNC, A_PUNC, /* 89:;<=>? */ + PUNC, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, /* @ABCDEFG */ + A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, /* HIJKLMNO */ + A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, /* PQRSTUVW */ + A_CAP, A_CAP, A_CAP, PUNC, PUNC, PUNC, PUNC, PUNC, /* XYZ[\]^_ */ + PUNC, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, /* `abcdefg */ + ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, /* hijklmno */ + ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, /* pqrstuvw */ + ALPHA, ALPHA, ALPHA, PUNC, PUNC, PUNC, PUNC, 0, /* xyz{|}~ */ + B_CAPSYM, B_CAPSYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, /* 128-134 */ + B_SYM, /* 135 */ + B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, /* 136-142 */ + B_CAPSYM, /* 143 */ + B_CAPSYM, B_CAPSYM, B_SYM, B_CAPSYM, B_SYM, B_SYM, B_SYM, /* 144-150 */ + B_SYM, /* 151 */ + B_SYM, B_SYM, B_CAPSYM, B_CAPSYM, B_SYM, B_SYM, B_SYM, /*152-158 */ + B_SYM, /* 159 */ + WDLM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_CAPSYM, /* 160-166 */ + B_SYM, /* 167 */ + B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, /* 168-175 */ + B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, /* 176-183 */ + B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, /* 184-191 */ + A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, /* 192-199 */ + A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, /* 200-207 */ + A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, B_SYM, /* 208-215 */ + A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, ALPHA, /* 216-223 */ + ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, /* 224-231 */ + ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, /* 232-239 */ + ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, B_SYM, /* 240-247 */ + ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA /* 248-255 */ +}; + +struct task_struct *speakup_task; +struct bleep spk_unprocessed_sound; +static int spk_keydown; +static u16 spk_lastkey; +static u_char spk_close_press, keymap_flags; +static u_char last_keycode, this_speakup_key; +static u_long last_spk_jiffy; + +struct st_spk_t *speakup_console[MAX_NR_CONSOLES]; + +DEFINE_MUTEX(spk_mutex); + +static int keyboard_notifier_call(struct notifier_block *, + unsigned long code, void *param); + +static struct notifier_block keyboard_notifier_block = { + .notifier_call = keyboard_notifier_call, +}; + +static int vt_notifier_call(struct notifier_block *, + unsigned long code, void *param); + +static struct notifier_block vt_notifier_block = { + .notifier_call = vt_notifier_call, +}; + +static unsigned char get_attributes(struct vc_data *vc, u16 *pos) +{ + pos = screen_pos(vc, pos - (u16 *)vc->vc_origin, 1); + return (scr_readw(pos) & ~vc->vc_hi_font_mask) >> 8; +} + +static void speakup_date(struct vc_data *vc) +{ + spk_x = spk_cx = vc->vc_x; + spk_y = spk_cy = vc->vc_y; + spk_pos = spk_cp = vc->vc_pos; + spk_old_attr = spk_attr; + spk_attr = get_attributes(vc, (u_short *)spk_pos); +} + +static void bleep(u_short val) +{ + static const short vals[] = { + 350, 370, 392, 414, 440, 466, 491, 523, 554, 587, 619, 659 + }; + short freq; + int time = spk_bleep_time; + + freq = vals[val % 12]; + if (val > 11) + freq *= (1 << (val / 12)); + spk_unprocessed_sound.freq = freq; + spk_unprocessed_sound.jiffies = msecs_to_jiffies(time); + spk_unprocessed_sound.active = 1; + /* We can only have 1 active sound at a time. */ +} + +static void speakup_shut_up(struct vc_data *vc) +{ + if (spk_killed) + return; + spk_shut_up |= 0x01; + spk_parked &= 0xfe; + speakup_date(vc); + if (synth) + spk_do_flush(); +} + +static void speech_kill(struct vc_data *vc) +{ + char val = synth->is_alive(synth); + + if (val == 0) + return; + + /* re-enables synth, if disabled */ + if (val == 2 || spk_killed) { + /* dead */ + spk_shut_up &= ~0x40; + synth_printf("%s\n", spk_msg_get(MSG_IAM_ALIVE)); + } else { + synth_printf("%s\n", spk_msg_get(MSG_YOU_KILLED_SPEAKUP)); + spk_shut_up |= 0x40; + } +} + +static void speakup_off(struct vc_data *vc) +{ + if (spk_shut_up & 0x80) { + spk_shut_up &= 0x7f; + synth_printf("%s\n", spk_msg_get(MSG_HEY_THATS_BETTER)); + } else { + spk_shut_up |= 0x80; + synth_printf("%s\n", spk_msg_get(MSG_YOU_TURNED_ME_OFF)); + } + speakup_date(vc); +} + +static void speakup_parked(struct vc_data *vc) +{ + if (spk_parked & 0x80) { + spk_parked = 0; + synth_printf("%s\n", spk_msg_get(MSG_UNPARKED)); + } else { + spk_parked |= 0x80; + synth_printf("%s\n", spk_msg_get(MSG_PARKED)); + } +} + +static void speakup_cut(struct vc_data *vc) +{ + static const char err_buf[] = "set selection failed"; + int ret; + + if (!mark_cut_flag) { + mark_cut_flag = 1; + spk_xs = (u_short)spk_x; + spk_ys = (u_short)spk_y; + spk_sel_cons = vc; + synth_printf("%s\n", spk_msg_get(MSG_MARK)); + return; + } + spk_xe = (u_short)spk_x; + spk_ye = (u_short)spk_y; + mark_cut_flag = 0; + synth_printf("%s\n", spk_msg_get(MSG_CUT)); + + speakup_clear_selection(); + ret = speakup_set_selection(tty); + + switch (ret) { + case 0: + break; /* no error */ + case -EFAULT: + pr_warn("%sEFAULT\n", err_buf); + break; + case -EINVAL: + pr_warn("%sEINVAL\n", err_buf); + break; + case -ENOMEM: + pr_warn("%sENOMEM\n", err_buf); + break; + } +} + +static void speakup_paste(struct vc_data *vc) +{ + if (mark_cut_flag) { + mark_cut_flag = 0; + synth_printf("%s\n", spk_msg_get(MSG_MARK_CLEARED)); + } else { + synth_printf("%s\n", spk_msg_get(MSG_PASTE)); + speakup_paste_selection(tty); + } +} + +static void say_attributes(struct vc_data *vc) +{ + int fg = spk_attr & 0x0f; + int bg = spk_attr >> 4; + + if (fg > 8) { + synth_printf("%s ", spk_msg_get(MSG_BRIGHT)); + fg -= 8; + } + synth_printf("%s", spk_msg_get(MSG_COLORS_START + fg)); + if (bg > 7) { + synth_printf(" %s ", spk_msg_get(MSG_ON_BLINKING)); + bg -= 8; + } else { + synth_printf(" %s ", spk_msg_get(MSG_ON)); + } + synth_printf("%s\n", spk_msg_get(MSG_COLORS_START + bg)); +} + +enum { + edge_top = 1, + edge_bottom, + edge_left, + edge_right, + edge_quiet +}; + +static void announce_edge(struct vc_data *vc, int msg_id) +{ + if (spk_bleeps & 1) + bleep(spk_y); + if ((spk_bleeps & 2) && (msg_id < edge_quiet)) + synth_printf("%s\n", + spk_msg_get(MSG_EDGE_MSGS_START + msg_id - 1)); +} + +static void speak_char(u16 ch) +{ + char *cp; + struct var_t *direct = spk_get_var(DIRECT); + + if (ch >= 0x100 || (direct && direct->u.n.value)) { + if (ch < 0x100 && IS_CHAR(ch, B_CAP)) { + spk_pitch_shift++; + synth_printf("%s", spk_str_caps_start); + } + synth_putwc_s(ch); + if (ch < 0x100 && IS_CHAR(ch, B_CAP)) + synth_printf("%s", spk_str_caps_stop); + return; + } + + cp = spk_characters[ch]; + if (!cp) { + pr_info("%s: cp == NULL!\n", __func__); + return; + } + if (IS_CHAR(ch, B_CAP)) { + spk_pitch_shift++; + synth_printf("%s %s %s", + spk_str_caps_start, cp, spk_str_caps_stop); + } else { + if (*cp == '^') { + cp++; + synth_printf(" %s%s ", spk_msg_get(MSG_CTRL), cp); + } else { + synth_printf(" %s ", cp); + } + } +} + +static u16 get_char(struct vc_data *vc, u16 *pos, u_char *attribs) +{ + u16 ch = ' '; + + if (vc && pos) { + u16 w; + u16 c; + + pos = screen_pos(vc, pos - (u16 *)vc->vc_origin, 1); + w = scr_readw(pos); + c = w & 0xff; + + if (w & vc->vc_hi_font_mask) { + w &= ~vc->vc_hi_font_mask; + c |= 0x100; + } + + ch = inverse_translate(vc, c, 1); + *attribs = (w & 0xff00) >> 8; + } + return ch; +} + +static void say_char(struct vc_data *vc) +{ + u16 ch; + + spk_old_attr = spk_attr; + ch = get_char(vc, (u_short *)spk_pos, &spk_attr); + if (spk_attr != spk_old_attr) { + if (spk_attrib_bleep & 1) + bleep(spk_y); + if (spk_attrib_bleep & 2) + say_attributes(vc); + } + speak_char(ch); +} + +static void say_phonetic_char(struct vc_data *vc) +{ + u16 ch; + + spk_old_attr = spk_attr; + ch = get_char(vc, (u_short *)spk_pos, &spk_attr); + if (ch <= 0x7f && isalpha(ch)) { + ch &= 0x1f; + synth_printf("%s\n", phonetic[--ch]); + } else { + if (ch < 0x100 && IS_CHAR(ch, B_NUM)) + synth_printf("%s ", spk_msg_get(MSG_NUMBER)); + speak_char(ch); + } +} + +static void say_prev_char(struct vc_data *vc) +{ + spk_parked |= 0x01; + if (spk_x == 0) { + announce_edge(vc, edge_left); + return; + } + spk_x--; + spk_pos -= 2; + say_char(vc); +} + +static void say_next_char(struct vc_data *vc) +{ + spk_parked |= 0x01; + if (spk_x == vc->vc_cols - 1) { + announce_edge(vc, edge_right); + return; + } + spk_x++; + spk_pos += 2; + say_char(vc); +} + +/* get_word - will first check to see if the character under the + * reading cursor is a space and if spk_say_word_ctl is true it will + * return the word space. If spk_say_word_ctl is not set it will check to + * see if there is a word starting on the next position to the right + * and return that word if it exists. If it does not exist it will + * move left to the beginning of any previous word on the line or the + * beginning off the line whichever comes first.. + */ + +static u_long get_word(struct vc_data *vc) +{ + u_long cnt = 0, tmpx = spk_x, tmp_pos = spk_pos; + u16 ch; + u16 attr_ch; + u_char temp; + + spk_old_attr = spk_attr; + ch = get_char(vc, (u_short *)tmp_pos, &temp); + +/* decided to take out the sayword if on a space (mis-information */ + if (spk_say_word_ctl && ch == SPACE) { + *buf = '\0'; + synth_printf("%s\n", spk_msg_get(MSG_SPACE)); + return 0; + } else if (tmpx < vc->vc_cols - 2 && + (ch == SPACE || ch == 0 || (ch < 0x100 && IS_WDLM(ch))) && + get_char(vc, (u_short *)tmp_pos + 1, &temp) > SPACE) { + tmp_pos += 2; + tmpx++; + } else { + while (tmpx > 0) { + ch = get_char(vc, (u_short *)tmp_pos - 1, &temp); + if ((ch == SPACE || ch == 0 || + (ch < 0x100 && IS_WDLM(ch))) && + get_char(vc, (u_short *)tmp_pos, &temp) > SPACE) + break; + tmp_pos -= 2; + tmpx--; + } + } + attr_ch = get_char(vc, (u_short *)tmp_pos, &spk_attr); + buf[cnt++] = attr_ch; + while (tmpx < vc->vc_cols - 1) { + tmp_pos += 2; + tmpx++; + ch = get_char(vc, (u_short *)tmp_pos, &temp); + if (ch == SPACE || ch == 0 || + (buf[cnt - 1] < 0x100 && IS_WDLM(buf[cnt - 1]) && + ch > SPACE)) + break; + buf[cnt++] = ch; + } + buf[cnt] = '\0'; + return cnt; +} + +static void say_word(struct vc_data *vc) +{ + u_long cnt = get_word(vc); + u_short saved_punc_mask = spk_punc_mask; + + if (cnt == 0) + return; + spk_punc_mask = PUNC; + buf[cnt++] = SPACE; + spkup_write(buf, cnt); + spk_punc_mask = saved_punc_mask; +} + +static void say_prev_word(struct vc_data *vc) +{ + u_char temp; + u16 ch; + u_short edge_said = 0, last_state = 0, state = 0; + + spk_parked |= 0x01; + + if (spk_x == 0) { + if (spk_y == 0) { + announce_edge(vc, edge_top); + return; + } + spk_y--; + spk_x = vc->vc_cols; + edge_said = edge_quiet; + } + while (1) { + if (spk_x == 0) { + if (spk_y == 0) { + edge_said = edge_top; + break; + } + if (edge_said != edge_quiet) + edge_said = edge_left; + if (state > 0) + break; + spk_y--; + spk_x = vc->vc_cols - 1; + } else { + spk_x--; + } + spk_pos -= 2; + ch = get_char(vc, (u_short *)spk_pos, &temp); + if (ch == SPACE || ch == 0) + state = 0; + else if (ch < 0x100 && IS_WDLM(ch)) + state = 1; + else + state = 2; + if (state < last_state) { + spk_pos += 2; + spk_x++; + break; + } + last_state = state; + } + if (spk_x == 0 && edge_said == edge_quiet) + edge_said = edge_left; + if (edge_said > 0 && edge_said < edge_quiet) + announce_edge(vc, edge_said); + say_word(vc); +} + +static void say_next_word(struct vc_data *vc) +{ + u_char temp; + u16 ch; + u_short edge_said = 0, last_state = 2, state = 0; + + spk_parked |= 0x01; + if (spk_x == vc->vc_cols - 1 && spk_y == vc->vc_rows - 1) { + announce_edge(vc, edge_bottom); + return; + } + while (1) { + ch = get_char(vc, (u_short *)spk_pos, &temp); + if (ch == SPACE || ch == 0) + state = 0; + else if (ch < 0x100 && IS_WDLM(ch)) + state = 1; + else + state = 2; + if (state > last_state) + break; + if (spk_x >= vc->vc_cols - 1) { + if (spk_y == vc->vc_rows - 1) { + edge_said = edge_bottom; + break; + } + state = 0; + spk_y++; + spk_x = 0; + edge_said = edge_right; + } else { + spk_x++; + } + spk_pos += 2; + last_state = state; + } + if (edge_said > 0) + announce_edge(vc, edge_said); + say_word(vc); +} + +static void spell_word(struct vc_data *vc) +{ + static char const *delay_str[] = { "", ",", ".", ". .", ". . ." }; + u16 *cp = buf; + char *cp1; + char *str_cap = spk_str_caps_stop; + char *last_cap = spk_str_caps_stop; + struct var_t *direct = spk_get_var(DIRECT); + u16 ch; + + if (!get_word(vc)) + return; + while ((ch = *cp)) { + if (cp != buf) + synth_printf(" %s ", delay_str[spk_spell_delay]); + /* FIXME: Non-latin1 considered as lower case */ + if (ch < 0x100 && IS_CHAR(ch, B_CAP)) { + str_cap = spk_str_caps_start; + if (*spk_str_caps_stop) + spk_pitch_shift++; + else /* synth has no pitch */ + last_cap = spk_str_caps_stop; + } else { + str_cap = spk_str_caps_stop; + } + if (str_cap != last_cap) { + synth_printf("%s", str_cap); + last_cap = str_cap; + } + if (ch >= 0x100 || (direct && direct->u.n.value)) { + synth_putwc_s(ch); + } else if (this_speakup_key == SPELL_PHONETIC && + ch <= 0x7f && isalpha(ch)) { + ch &= 0x1f; + cp1 = phonetic[--ch]; + synth_printf("%s", cp1); + } else { + cp1 = spk_characters[ch]; + if (*cp1 == '^') { + synth_printf("%s", spk_msg_get(MSG_CTRL)); + cp1++; + } + synth_printf("%s", cp1); + } + cp++; + } + if (str_cap != spk_str_caps_stop) + synth_printf("%s", spk_str_caps_stop); +} + +static int get_line(struct vc_data *vc) +{ + u_long tmp = spk_pos - (spk_x * 2); + int i = 0; + u_char tmp2; + + spk_old_attr = spk_attr; + spk_attr = get_attributes(vc, (u_short *)spk_pos); + for (i = 0; i < vc->vc_cols; i++) { + buf[i] = get_char(vc, (u_short *)tmp, &tmp2); + tmp += 2; + } + for (--i; i >= 0; i--) + if (buf[i] != SPACE) + break; + return ++i; +} + +static void say_line(struct vc_data *vc) +{ + int i = get_line(vc); + u16 *cp; + u_short saved_punc_mask = spk_punc_mask; + + if (i == 0) { + synth_printf("%s\n", spk_msg_get(MSG_BLANK)); + return; + } + buf[i++] = '\n'; + if (this_speakup_key == SAY_LINE_INDENT) { + cp = buf; + while (*cp == SPACE) + cp++; + synth_printf("%zd, ", (cp - buf) + 1); + } + spk_punc_mask = spk_punc_masks[spk_reading_punc]; + spkup_write(buf, i); + spk_punc_mask = saved_punc_mask; +} + +static void say_prev_line(struct vc_data *vc) +{ + spk_parked |= 0x01; + if (spk_y == 0) { + announce_edge(vc, edge_top); + return; + } + spk_y--; + spk_pos -= vc->vc_size_row; + say_line(vc); +} + +static void say_next_line(struct vc_data *vc) +{ + spk_parked |= 0x01; + if (spk_y == vc->vc_rows - 1) { + announce_edge(vc, edge_bottom); + return; + } + spk_y++; + spk_pos += vc->vc_size_row; + say_line(vc); +} + +static int say_from_to(struct vc_data *vc, u_long from, u_long to, + int read_punc) +{ + int i = 0; + u_char tmp; + u_short saved_punc_mask = spk_punc_mask; + + spk_old_attr = spk_attr; + spk_attr = get_attributes(vc, (u_short *)from); + while (from < to) { + buf[i++] = get_char(vc, (u_short *)from, &tmp); + from += 2; + if (i >= vc->vc_size_row) + break; + } + for (--i; i >= 0; i--) + if (buf[i] != SPACE) + break; + buf[++i] = SPACE; + buf[++i] = '\0'; + if (i < 1) + return i; + if (read_punc) + spk_punc_mask = spk_punc_info[spk_reading_punc].mask; + spkup_write(buf, i); + if (read_punc) + spk_punc_mask = saved_punc_mask; + return i - 1; +} + +static void say_line_from_to(struct vc_data *vc, u_long from, u_long to, + int read_punc) +{ + u_long start = vc->vc_origin + (spk_y * vc->vc_size_row); + u_long end = start + (to * 2); + + start += from * 2; + if (say_from_to(vc, start, end, read_punc) <= 0) + if (cursor_track != read_all_mode) + synth_printf("%s\n", spk_msg_get(MSG_BLANK)); +} + +/* Sentence Reading Commands */ + +static int currsentence; +static int numsentences[2]; +static u16 *sentbufend[2]; +static u16 *sentmarks[2][10]; +static int currbuf; +static int bn; +static u16 sentbuf[2][256]; + +static int say_sentence_num(int num, int prev) +{ + bn = currbuf; + currsentence = num + 1; + if (prev && --bn == -1) + bn = 1; + + if (num > numsentences[bn]) + return 0; + + spkup_write(sentmarks[bn][num], sentbufend[bn] - sentmarks[bn][num]); + return 1; +} + +static int get_sentence_buf(struct vc_data *vc, int read_punc) +{ + u_long start, end; + int i, bn; + u_char tmp; + + currbuf++; + if (currbuf == 2) + currbuf = 0; + bn = currbuf; + start = vc->vc_origin + ((spk_y) * vc->vc_size_row); + end = vc->vc_origin + ((spk_y) * vc->vc_size_row) + vc->vc_cols * 2; + + numsentences[bn] = 0; + sentmarks[bn][0] = &sentbuf[bn][0]; + i = 0; + spk_old_attr = spk_attr; + spk_attr = get_attributes(vc, (u_short *)start); + + while (start < end) { + sentbuf[bn][i] = get_char(vc, (u_short *)start, &tmp); + if (i > 0) { + if (sentbuf[bn][i] == SPACE && + sentbuf[bn][i - 1] == '.' && + numsentences[bn] < 9) { + /* Sentence Marker */ + numsentences[bn]++; + sentmarks[bn][numsentences[bn]] = + &sentbuf[bn][i]; + } + } + i++; + start += 2; + if (i >= vc->vc_size_row) + break; + } + + for (--i; i >= 0; i--) + if (sentbuf[bn][i] != SPACE) + break; + + if (i < 1) + return -1; + + sentbuf[bn][++i] = SPACE; + sentbuf[bn][++i] = '\0'; + + sentbufend[bn] = &sentbuf[bn][i]; + return numsentences[bn]; +} + +static void say_screen_from_to(struct vc_data *vc, u_long from, u_long to) +{ + u_long start = vc->vc_origin, end; + + if (from > 0) + start += from * vc->vc_size_row; + if (to > vc->vc_rows) + to = vc->vc_rows; + end = vc->vc_origin + (to * vc->vc_size_row); + for (from = start; from < end; from = to) { + to = from + vc->vc_size_row; + say_from_to(vc, from, to, 1); + } +} + +static void say_screen(struct vc_data *vc) +{ + say_screen_from_to(vc, 0, vc->vc_rows); +} + +static void speakup_win_say(struct vc_data *vc) +{ + u_long start, end, from, to; + + if (win_start < 2) { + synth_printf("%s\n", spk_msg_get(MSG_NO_WINDOW)); + return; + } + start = vc->vc_origin + (win_top * vc->vc_size_row); + end = vc->vc_origin + (win_bottom * vc->vc_size_row); + while (start <= end) { + from = start + (win_left * 2); + to = start + (win_right * 2); + say_from_to(vc, from, to, 1); + start += vc->vc_size_row; + } +} + +static void top_edge(struct vc_data *vc) +{ + spk_parked |= 0x01; + spk_pos = vc->vc_origin + 2 * spk_x; + spk_y = 0; + say_line(vc); +} + +static void bottom_edge(struct vc_data *vc) +{ + spk_parked |= 0x01; + spk_pos += (vc->vc_rows - spk_y - 1) * vc->vc_size_row; + spk_y = vc->vc_rows - 1; + say_line(vc); +} + +static void left_edge(struct vc_data *vc) +{ + spk_parked |= 0x01; + spk_pos -= spk_x * 2; + spk_x = 0; + say_char(vc); +} + +static void right_edge(struct vc_data *vc) +{ + spk_parked |= 0x01; + spk_pos += (vc->vc_cols - spk_x - 1) * 2; + spk_x = vc->vc_cols - 1; + say_char(vc); +} + +static void say_first_char(struct vc_data *vc) +{ + int i, len = get_line(vc); + u16 ch; + + spk_parked |= 0x01; + if (len == 0) { + synth_printf("%s\n", spk_msg_get(MSG_BLANK)); + return; + } + for (i = 0; i < len; i++) + if (buf[i] != SPACE) + break; + ch = buf[i]; + spk_pos -= (spk_x - i) * 2; + spk_x = i; + synth_printf("%d, ", ++i); + speak_char(ch); +} + +static void say_last_char(struct vc_data *vc) +{ + int len = get_line(vc); + u16 ch; + + spk_parked |= 0x01; + if (len == 0) { + synth_printf("%s\n", spk_msg_get(MSG_BLANK)); + return; + } + ch = buf[--len]; + spk_pos -= (spk_x - len) * 2; + spk_x = len; + synth_printf("%d, ", ++len); + speak_char(ch); +} + +static void say_position(struct vc_data *vc) +{ + synth_printf(spk_msg_get(MSG_POS_INFO), spk_y + 1, spk_x + 1, + vc->vc_num + 1); + synth_printf("\n"); +} + +/* Added by brianb */ +static void say_char_num(struct vc_data *vc) +{ + u_char tmp; + u16 ch = get_char(vc, (u_short *)spk_pos, &tmp); + + synth_printf(spk_msg_get(MSG_CHAR_INFO), ch, ch); +} + +/* these are stub functions to keep keyboard.c happy. */ + +static void say_from_top(struct vc_data *vc) +{ + say_screen_from_to(vc, 0, spk_y); +} + +static void say_to_bottom(struct vc_data *vc) +{ + say_screen_from_to(vc, spk_y, vc->vc_rows); +} + +static void say_from_left(struct vc_data *vc) +{ + say_line_from_to(vc, 0, spk_x, 1); +} + +static void say_to_right(struct vc_data *vc) +{ + say_line_from_to(vc, spk_x, vc->vc_cols, 1); +} + +/* end of stub functions. */ + +static void spkup_write(const u16 *in_buf, int count) +{ + static int rep_count; + static u16 ch = '\0', old_ch = '\0'; + static u_short char_type, last_type; + int in_count = count; + + spk_keydown = 0; + while (count--) { + if (cursor_track == read_all_mode) { + /* Insert Sentence Index */ + if ((in_buf == sentmarks[bn][currsentence]) && + (currsentence <= numsentences[bn])) + synth_insert_next_index(currsentence++); + } + ch = *in_buf++; + if (ch < 0x100) + char_type = spk_chartab[ch]; + else + char_type = ALPHA; + if (ch == old_ch && !(char_type & B_NUM)) { + if (++rep_count > 2) + continue; + } else { + if ((last_type & CH_RPT) && rep_count > 2) { + synth_printf(" "); + synth_printf(spk_msg_get(MSG_REPEAT_DESC), + ++rep_count); + synth_printf(" "); + } + rep_count = 0; + } + if (ch == spk_lastkey) { + rep_count = 0; + if (spk_key_echo == 1 && ch >= MINECHOCHAR) + speak_char(ch); + } else if (char_type & B_ALPHA) { + if ((synth_flags & SF_DEC) && (last_type & PUNC)) + synth_buffer_add(SPACE); + synth_putwc_s(ch); + } else if (char_type & B_NUM) { + rep_count = 0; + synth_putwc_s(ch); + } else if (char_type & spk_punc_mask) { + speak_char(ch); + char_type &= ~PUNC; /* for dec nospell processing */ + } else if (char_type & SYNTH_OK) { + /* these are usually puncts like . and , which synth + * needs for expression. + * suppress multiple to get rid of long pauses and + * clear repeat count + * so if someone has + * repeats on you don't get nothing repeated count + */ + if (ch != old_ch) + synth_putwc_s(ch); + else + rep_count = 0; + } else { +/* send space and record position, if next is num overwrite space */ + if (old_ch != ch) + synth_buffer_add(SPACE); + else + rep_count = 0; + } + old_ch = ch; + last_type = char_type; + } + spk_lastkey = 0; + if (in_count > 2 && rep_count > 2) { + if (last_type & CH_RPT) { + synth_printf(" "); + synth_printf(spk_msg_get(MSG_REPEAT_DESC2), + ++rep_count); + synth_printf(" "); + } + rep_count = 0; + } +} + +static const int NUM_CTL_LABELS = (MSG_CTL_END - MSG_CTL_START + 1); + +static void read_all_doc(struct vc_data *vc); +static void cursor_done(struct timer_list *unused); +static DEFINE_TIMER(cursor_timer, cursor_done); + +static void do_handle_shift(struct vc_data *vc, u_char value, char up_flag) +{ + unsigned long flags; + + if (!synth || up_flag || spk_killed) + return; + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (cursor_track == read_all_mode) { + switch (value) { + case KVAL(K_SHIFT): + del_timer(&cursor_timer); + spk_shut_up &= 0xfe; + spk_do_flush(); + read_all_doc(vc); + break; + case KVAL(K_CTRL): + del_timer(&cursor_timer); + cursor_track = prev_cursor_track; + spk_shut_up &= 0xfe; + spk_do_flush(); + break; + } + } else { + spk_shut_up &= 0xfe; + spk_do_flush(); + } + if (spk_say_ctrl && value < NUM_CTL_LABELS) + synth_printf("%s", spk_msg_get(MSG_CTL_START + value)); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); +} + +static void do_handle_latin(struct vc_data *vc, u_char value, char up_flag) +{ + unsigned long flags; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (up_flag) { + spk_lastkey = 0; + spk_keydown = 0; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return; + } + if (!synth || spk_killed) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return; + } + spk_shut_up &= 0xfe; + spk_lastkey = value; + spk_keydown++; + spk_parked &= 0xfe; + if (spk_key_echo == 2 && value >= MINECHOCHAR) + speak_char(value); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); +} + +int spk_set_key_info(const u_char *key_info, u_char *k_buffer) +{ + int i = 0, states, key_data_len; + const u_char *cp = key_info; + u_char *cp1 = k_buffer; + u_char ch, version, num_keys; + + version = *cp++; + if (version != KEY_MAP_VER) { + pr_debug("version found %d should be %d\n", + version, KEY_MAP_VER); + return -EINVAL; + } + num_keys = *cp; + states = (int)cp[1]; + key_data_len = (states + 1) * (num_keys + 1); + if (key_data_len + SHIFT_TBL_SIZE + 4 >= sizeof(spk_key_buf)) { + pr_debug("too many key_infos (%d over %u)\n", + key_data_len + SHIFT_TBL_SIZE + 4, + (unsigned int)(sizeof(spk_key_buf))); + return -EINVAL; + } + memset(k_buffer, 0, SHIFT_TBL_SIZE); + memset(spk_our_keys, 0, sizeof(spk_our_keys)); + spk_shift_table = k_buffer; + spk_our_keys[0] = spk_shift_table; + cp1 += SHIFT_TBL_SIZE; + memcpy(cp1, cp, key_data_len + 3); + /* get num_keys, states and data */ + cp1 += 2; /* now pointing at shift states */ + for (i = 1; i <= states; i++) { + ch = *cp1++; + if (ch >= SHIFT_TBL_SIZE) { + pr_debug("(%d) not valid shift state (max_allowed = %d)\n", + ch, SHIFT_TBL_SIZE); + return -EINVAL; + } + spk_shift_table[ch] = i; + } + keymap_flags = *cp1++; + while ((ch = *cp1)) { + if (ch >= MAX_KEY) { + pr_debug("(%d), not valid key, (max_allowed = %d)\n", + ch, MAX_KEY); + return -EINVAL; + } + spk_our_keys[ch] = cp1; + cp1 += states + 1; + } + return 0; +} + +static struct var_t spk_vars[] = { + /* bell must be first to set high limit */ + {BELL_POS, .u.n = {NULL, 0, 0, 0, 0, 0, NULL} }, + {SPELL_DELAY, .u.n = {NULL, 0, 0, 4, 0, 0, NULL} }, + {ATTRIB_BLEEP, .u.n = {NULL, 1, 0, 3, 0, 0, NULL} }, + {BLEEPS, .u.n = {NULL, 3, 0, 3, 0, 0, NULL} }, + {BLEEP_TIME, .u.n = {NULL, 30, 1, 200, 0, 0, NULL} }, + {PUNC_LEVEL, .u.n = {NULL, 1, 0, 4, 0, 0, NULL} }, + {READING_PUNC, .u.n = {NULL, 1, 0, 4, 0, 0, NULL} }, + {CURSOR_TIME, .u.n = {NULL, 120, 50, 600, 0, 0, NULL} }, + {SAY_CONTROL, TOGGLE_0}, + {SAY_WORD_CTL, TOGGLE_0}, + {NO_INTERRUPT, TOGGLE_0}, + {KEY_ECHO, .u.n = {NULL, 1, 0, 2, 0, 0, NULL} }, + V_LAST_VAR +}; + +static void toggle_cursoring(struct vc_data *vc) +{ + if (cursor_track == read_all_mode) + cursor_track = prev_cursor_track; + if (++cursor_track >= CT_Max) + cursor_track = 0; + synth_printf("%s\n", spk_msg_get(MSG_CURSOR_MSGS_START + cursor_track)); +} + +void spk_reset_default_chars(void) +{ + int i; + + /* First, free any non-default */ + for (i = 0; i < 256; i++) { + if (spk_characters[i] && + (spk_characters[i] != spk_default_chars[i])) + kfree(spk_characters[i]); + } + + memcpy(spk_characters, spk_default_chars, sizeof(spk_default_chars)); +} + +void spk_reset_default_chartab(void) +{ + memcpy(spk_chartab, default_chartab, sizeof(default_chartab)); +} + +static const struct st_bits_data *pb_edit; + +static int edit_bits(struct vc_data *vc, u_char type, u_char ch, u_short key) +{ + short mask = pb_edit->mask, ch_type = spk_chartab[ch]; + + if (type != KT_LATIN || (ch_type & B_NUM) || ch < SPACE) + return -1; + if (ch == SPACE) { + synth_printf("%s\n", spk_msg_get(MSG_EDIT_DONE)); + spk_special_handler = NULL; + return 1; + } + if (mask < PUNC && !(ch_type & PUNC)) + return -1; + spk_chartab[ch] ^= mask; + speak_char(ch); + synth_printf(" %s\n", + (spk_chartab[ch] & mask) ? spk_msg_get(MSG_ON) : + spk_msg_get(MSG_OFF)); + return 1; +} + +/* Allocation concurrency is protected by the console semaphore */ +static int speakup_allocate(struct vc_data *vc, gfp_t gfp_flags) +{ + int vc_num; + + vc_num = vc->vc_num; + if (!speakup_console[vc_num]) { + speakup_console[vc_num] = kzalloc(sizeof(*speakup_console[0]), + gfp_flags); + if (!speakup_console[vc_num]) + return -ENOMEM; + speakup_date(vc); + } else if (!spk_parked) { + speakup_date(vc); + } + + return 0; +} + +static void speakup_deallocate(struct vc_data *vc) +{ + int vc_num; + + vc_num = vc->vc_num; + kfree(speakup_console[vc_num]); + speakup_console[vc_num] = NULL; +} + +static u_char is_cursor; +static u_long old_cursor_pos, old_cursor_x, old_cursor_y; +static int cursor_con; + +static void reset_highlight_buffers(struct vc_data *); + +static int read_all_key; + +static int in_keyboard_notifier; + +static void start_read_all_timer(struct vc_data *vc, int command); + +enum { + RA_NOTHING, + RA_NEXT_SENT, + RA_PREV_LINE, + RA_NEXT_LINE, + RA_PREV_SENT, + RA_DOWN_ARROW, + RA_TIMER, + RA_FIND_NEXT_SENT, + RA_FIND_PREV_SENT, +}; + +static void kbd_fakekey2(struct vc_data *vc, int command) +{ + del_timer(&cursor_timer); + speakup_fake_down_arrow(); + start_read_all_timer(vc, command); +} + +static void read_all_doc(struct vc_data *vc) +{ + if ((vc->vc_num != fg_console) || !synth || spk_shut_up) + return; + if (!synth_supports_indexing()) + return; + if (cursor_track != read_all_mode) + prev_cursor_track = cursor_track; + cursor_track = read_all_mode; + spk_reset_index_count(0); + if (get_sentence_buf(vc, 0) == -1) { + del_timer(&cursor_timer); + if (!in_keyboard_notifier) + speakup_fake_down_arrow(); + start_read_all_timer(vc, RA_DOWN_ARROW); + } else { + say_sentence_num(0, 0); + synth_insert_next_index(0); + start_read_all_timer(vc, RA_TIMER); + } +} + +static void stop_read_all(struct vc_data *vc) +{ + del_timer(&cursor_timer); + cursor_track = prev_cursor_track; + spk_shut_up &= 0xfe; + spk_do_flush(); +} + +static void start_read_all_timer(struct vc_data *vc, int command) +{ + struct var_t *cursor_timeout; + + cursor_con = vc->vc_num; + read_all_key = command; + cursor_timeout = spk_get_var(CURSOR_TIME); + mod_timer(&cursor_timer, + jiffies + msecs_to_jiffies(cursor_timeout->u.n.value)); +} + +static void handle_cursor_read_all(struct vc_data *vc, int command) +{ + int indcount, sentcount, rv, sn; + + switch (command) { + case RA_NEXT_SENT: + /* Get Current Sentence */ + spk_get_index_count(&indcount, &sentcount); + /*printk("%d %d ", indcount, sentcount); */ + spk_reset_index_count(sentcount + 1); + if (indcount == 1) { + if (!say_sentence_num(sentcount + 1, 0)) { + kbd_fakekey2(vc, RA_FIND_NEXT_SENT); + return; + } + synth_insert_next_index(0); + } else { + sn = 0; + if (!say_sentence_num(sentcount + 1, 1)) { + sn = 1; + spk_reset_index_count(sn); + } else { + synth_insert_next_index(0); + } + if (!say_sentence_num(sn, 0)) { + kbd_fakekey2(vc, RA_FIND_NEXT_SENT); + return; + } + synth_insert_next_index(0); + } + start_read_all_timer(vc, RA_TIMER); + break; + case RA_PREV_SENT: + break; + case RA_NEXT_LINE: + read_all_doc(vc); + break; + case RA_PREV_LINE: + break; + case RA_DOWN_ARROW: + if (get_sentence_buf(vc, 0) == -1) { + kbd_fakekey2(vc, RA_DOWN_ARROW); + } else { + say_sentence_num(0, 0); + synth_insert_next_index(0); + start_read_all_timer(vc, RA_TIMER); + } + break; + case RA_FIND_NEXT_SENT: + rv = get_sentence_buf(vc, 0); + if (rv == -1) + read_all_doc(vc); + if (rv == 0) { + kbd_fakekey2(vc, RA_FIND_NEXT_SENT); + } else { + say_sentence_num(1, 0); + synth_insert_next_index(0); + start_read_all_timer(vc, RA_TIMER); + } + break; + case RA_FIND_PREV_SENT: + break; + case RA_TIMER: + spk_get_index_count(&indcount, &sentcount); + if (indcount < 2) + kbd_fakekey2(vc, RA_DOWN_ARROW); + else + start_read_all_timer(vc, RA_TIMER); + break; + } +} + +static int pre_handle_cursor(struct vc_data *vc, u_char value, char up_flag) +{ + unsigned long flags; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (cursor_track == read_all_mode) { + spk_parked &= 0xfe; + if (!synth || up_flag || spk_shut_up) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return NOTIFY_STOP; + } + del_timer(&cursor_timer); + spk_shut_up &= 0xfe; + spk_do_flush(); + start_read_all_timer(vc, value + 1); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return NOTIFY_STOP; + } + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return NOTIFY_OK; +} + +static void do_handle_cursor(struct vc_data *vc, u_char value, char up_flag) +{ + unsigned long flags; + struct var_t *cursor_timeout; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + spk_parked &= 0xfe; + if (!synth || up_flag || spk_shut_up || cursor_track == CT_Off) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return; + } + spk_shut_up &= 0xfe; + if (spk_no_intr) + spk_do_flush(); +/* the key press flushes if !no_inter but we want to flush on cursor + * moves regardless of no_inter state + */ + is_cursor = value + 1; + old_cursor_pos = vc->vc_pos; + old_cursor_x = vc->vc_x; + old_cursor_y = vc->vc_y; + speakup_console[vc->vc_num]->ht.cy = vc->vc_y; + cursor_con = vc->vc_num; + if (cursor_track == CT_Highlight) + reset_highlight_buffers(vc); + cursor_timeout = spk_get_var(CURSOR_TIME); + mod_timer(&cursor_timer, + jiffies + msecs_to_jiffies(cursor_timeout->u.n.value)); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); +} + +static void update_color_buffer(struct vc_data *vc, const u16 *ic, int len) +{ + int i, bi, hi; + int vc_num = vc->vc_num; + + bi = (vc->vc_attr & 0x70) >> 4; + hi = speakup_console[vc_num]->ht.highsize[bi]; + + i = 0; + if (speakup_console[vc_num]->ht.highsize[bi] == 0) { + speakup_console[vc_num]->ht.rpos[bi] = vc->vc_pos; + speakup_console[vc_num]->ht.rx[bi] = vc->vc_x; + speakup_console[vc_num]->ht.ry[bi] = vc->vc_y; + } + while ((hi < COLOR_BUFFER_SIZE) && (i < len)) { + if (ic[i] > 32) { + speakup_console[vc_num]->ht.highbuf[bi][hi] = ic[i]; + hi++; + } else if ((ic[i] == 32) && (hi != 0)) { + if (speakup_console[vc_num]->ht.highbuf[bi][hi - 1] != + 32) { + speakup_console[vc_num]->ht.highbuf[bi][hi] = + ic[i]; + hi++; + } + } + i++; + } + speakup_console[vc_num]->ht.highsize[bi] = hi; +} + +static void reset_highlight_buffers(struct vc_data *vc) +{ + int i; + int vc_num = vc->vc_num; + + for (i = 0; i < 8; i++) + speakup_console[vc_num]->ht.highsize[i] = 0; +} + +static int count_highlight_color(struct vc_data *vc) +{ + int i, bg; + int cc; + int vc_num = vc->vc_num; + u16 ch; + u16 *start = (u16 *)vc->vc_origin; + + for (i = 0; i < 8; i++) + speakup_console[vc_num]->ht.bgcount[i] = 0; + + for (i = 0; i < vc->vc_rows; i++) { + u16 *end = start + vc->vc_cols * 2; + u16 *ptr; + + for (ptr = start; ptr < end; ptr++) { + ch = get_attributes(vc, ptr); + bg = (ch & 0x70) >> 4; + speakup_console[vc_num]->ht.bgcount[bg]++; + } + start += vc->vc_size_row; + } + + cc = 0; + for (i = 0; i < 8; i++) + if (speakup_console[vc_num]->ht.bgcount[i] > 0) + cc++; + return cc; +} + +static int get_highlight_color(struct vc_data *vc) +{ + int i, j; + unsigned int cptr[8]; + int vc_num = vc->vc_num; + + for (i = 0; i < 8; i++) + cptr[i] = i; + + for (i = 0; i < 7; i++) + for (j = i + 1; j < 8; j++) + if (speakup_console[vc_num]->ht.bgcount[cptr[i]] > + speakup_console[vc_num]->ht.bgcount[cptr[j]]) + swap(cptr[i], cptr[j]); + + for (i = 0; i < 8; i++) + if (speakup_console[vc_num]->ht.bgcount[cptr[i]] != 0) + if (speakup_console[vc_num]->ht.highsize[cptr[i]] > 0) + return cptr[i]; + return -1; +} + +static int speak_highlight(struct vc_data *vc) +{ + int hc, d; + int vc_num = vc->vc_num; + + if (count_highlight_color(vc) == 1) + return 0; + hc = get_highlight_color(vc); + if (hc != -1) { + d = vc->vc_y - speakup_console[vc_num]->ht.cy; + if ((d == 1) || (d == -1)) + if (speakup_console[vc_num]->ht.ry[hc] != vc->vc_y) + return 0; + spk_parked |= 0x01; + spk_do_flush(); + spkup_write(speakup_console[vc_num]->ht.highbuf[hc], + speakup_console[vc_num]->ht.highsize[hc]); + spk_pos = spk_cp = speakup_console[vc_num]->ht.rpos[hc]; + spk_x = spk_cx = speakup_console[vc_num]->ht.rx[hc]; + spk_y = spk_cy = speakup_console[vc_num]->ht.ry[hc]; + return 1; + } + return 0; +} + +static void cursor_done(struct timer_list *unused) +{ + struct vc_data *vc = vc_cons[cursor_con].d; + unsigned long flags; + + del_timer(&cursor_timer); + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (cursor_con != fg_console) { + is_cursor = 0; + goto out; + } + speakup_date(vc); + if (win_enabled) { + if (vc->vc_x >= win_left && vc->vc_x <= win_right && + vc->vc_y >= win_top && vc->vc_y <= win_bottom) { + spk_keydown = 0; + is_cursor = 0; + goto out; + } + } + if (cursor_track == read_all_mode) { + handle_cursor_read_all(vc, read_all_key); + goto out; + } + if (cursor_track == CT_Highlight) { + if (speak_highlight(vc)) { + spk_keydown = 0; + is_cursor = 0; + goto out; + } + } + if (cursor_track == CT_Window) + speakup_win_say(vc); + else if (is_cursor == 1 || is_cursor == 4) + say_line_from_to(vc, 0, vc->vc_cols, 0); + else + say_char(vc); + spk_keydown = 0; + is_cursor = 0; +out: + spin_unlock_irqrestore(&speakup_info.spinlock, flags); +} + +/* called by: vt_notifier_call() */ +static void speakup_bs(struct vc_data *vc) +{ + unsigned long flags; + + if (!speakup_console[vc->vc_num]) + return; + if (!spin_trylock_irqsave(&speakup_info.spinlock, flags)) + /* Speakup output, discard */ + return; + if (!spk_parked) + speakup_date(vc); + if (spk_shut_up || !synth) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return; + } + if (vc->vc_num == fg_console && spk_keydown) { + spk_keydown = 0; + if (!is_cursor) + say_char(vc); + } + spin_unlock_irqrestore(&speakup_info.spinlock, flags); +} + +/* called by: vt_notifier_call() */ +static void speakup_con_write(struct vc_data *vc, u16 *str, int len) +{ + unsigned long flags; + + if ((vc->vc_num != fg_console) || spk_shut_up || !synth) + return; + if (!spin_trylock_irqsave(&speakup_info.spinlock, flags)) + /* Speakup output, discard */ + return; + if (spk_bell_pos && spk_keydown && (vc->vc_x == spk_bell_pos - 1)) + bleep(3); + if ((is_cursor) || (cursor_track == read_all_mode)) { + if (cursor_track == CT_Highlight) + update_color_buffer(vc, str, len); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return; + } + if (win_enabled) { + if (vc->vc_x >= win_left && vc->vc_x <= win_right && + vc->vc_y >= win_top && vc->vc_y <= win_bottom) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return; + } + } + + spkup_write(str, len); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); +} + +static void speakup_con_update(struct vc_data *vc) +{ + unsigned long flags; + + if (!speakup_console[vc->vc_num] || spk_parked) + return; + if (!spin_trylock_irqsave(&speakup_info.spinlock, flags)) + /* Speakup output, discard */ + return; + speakup_date(vc); + if (vc->vc_mode == KD_GRAPHICS && !spk_paused && spk_str_pause[0]) { + synth_printf("%s", spk_str_pause); + spk_paused = true; + } + spin_unlock_irqrestore(&speakup_info.spinlock, flags); +} + +static void do_handle_spec(struct vc_data *vc, u_char value, char up_flag) +{ + unsigned long flags; + int on_off = 2; + char *label; + + if (!synth || up_flag || spk_killed) + return; + spin_lock_irqsave(&speakup_info.spinlock, flags); + spk_shut_up &= 0xfe; + if (spk_no_intr) + spk_do_flush(); + switch (value) { + case KVAL(K_CAPS): + label = spk_msg_get(MSG_KEYNAME_CAPSLOCK); + on_off = vt_get_leds(fg_console, VC_CAPSLOCK); + break; + case KVAL(K_NUM): + label = spk_msg_get(MSG_KEYNAME_NUMLOCK); + on_off = vt_get_leds(fg_console, VC_NUMLOCK); + break; + case KVAL(K_HOLD): + label = spk_msg_get(MSG_KEYNAME_SCROLLLOCK); + on_off = vt_get_leds(fg_console, VC_SCROLLOCK); + if (speakup_console[vc->vc_num]) + speakup_console[vc->vc_num]->tty_stopped = on_off; + break; + default: + spk_parked &= 0xfe; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return; + } + if (on_off < 2) + synth_printf("%s %s\n", + label, spk_msg_get(MSG_STATUS_START + on_off)); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); +} + +static int inc_dec_var(u_char value) +{ + struct st_var_header *p_header; + struct var_t *var_data; + char num_buf[32]; + char *cp = num_buf; + char *pn; + int var_id = (int)value - VAR_START; + int how = (var_id & 1) ? E_INC : E_DEC; + + var_id = var_id / 2 + FIRST_SET_VAR; + p_header = spk_get_var_header(var_id); + if (!p_header) + return -1; + if (p_header->var_type != VAR_NUM) + return -1; + var_data = p_header->data; + if (spk_set_num_var(1, p_header, how) != 0) + return -1; + if (!spk_close_press) { + for (pn = p_header->name; *pn; pn++) { + if (*pn == '_') + *cp = SPACE; + else + *cp++ = *pn; + } + } + snprintf(cp, sizeof(num_buf) - (cp - num_buf), " %d ", + var_data->u.n.value); + synth_printf("%s", num_buf); + return 0; +} + +static void speakup_win_set(struct vc_data *vc) +{ + char info[40]; + + if (win_start > 1) { + synth_printf("%s\n", spk_msg_get(MSG_WINDOW_ALREADY_SET)); + return; + } + if (spk_x < win_left || spk_y < win_top) { + synth_printf("%s\n", spk_msg_get(MSG_END_BEFORE_START)); + return; + } + if (win_start && spk_x == win_left && spk_y == win_top) { + win_left = 0; + win_right = vc->vc_cols - 1; + win_bottom = spk_y; + snprintf(info, sizeof(info), spk_msg_get(MSG_WINDOW_LINE), + (int)win_top + 1); + } else { + if (!win_start) { + win_top = spk_y; + win_left = spk_x; + } else { + win_bottom = spk_y; + win_right = spk_x; + } + snprintf(info, sizeof(info), spk_msg_get(MSG_WINDOW_BOUNDARY), + (win_start) ? + spk_msg_get(MSG_END) : spk_msg_get(MSG_START), + (int)spk_y + 1, (int)spk_x + 1); + } + synth_printf("%s\n", info); + win_start++; +} + +static void speakup_win_clear(struct vc_data *vc) +{ + win_top = 0; + win_bottom = 0; + win_left = 0; + win_right = 0; + win_start = 0; + synth_printf("%s\n", spk_msg_get(MSG_WINDOW_CLEARED)); +} + +static void speakup_win_enable(struct vc_data *vc) +{ + if (win_start < 2) { + synth_printf("%s\n", spk_msg_get(MSG_NO_WINDOW)); + return; + } + win_enabled ^= 1; + if (win_enabled) + synth_printf("%s\n", spk_msg_get(MSG_WINDOW_SILENCED)); + else + synth_printf("%s\n", spk_msg_get(MSG_WINDOW_SILENCE_DISABLED)); +} + +static void speakup_bits(struct vc_data *vc) +{ + int val = this_speakup_key - (FIRST_EDIT_BITS - 1); + + if (spk_special_handler || val < 1 || val > 6) { + synth_printf("%s\n", spk_msg_get(MSG_ERROR)); + return; + } + pb_edit = &spk_punc_info[val]; + synth_printf(spk_msg_get(MSG_EDIT_PROMPT), pb_edit->name); + spk_special_handler = edit_bits; +} + +static int handle_goto(struct vc_data *vc, u_char type, u_char ch, u_short key) +{ + static u_char goto_buf[8]; + static int num; + int maxlen; + char *cp; + u16 wch; + + if (type == KT_SPKUP && ch == SPEAKUP_GOTO) + goto do_goto; + if (type == KT_LATIN && ch == '\n') + goto do_goto; + if (type != 0) + goto oops; + if (ch == 8) { + u16 wch; + + if (num == 0) + return -1; + wch = goto_buf[--num]; + goto_buf[num] = '\0'; + spkup_write(&wch, 1); + return 1; + } + if (ch < '+' || ch > 'y') + goto oops; + wch = ch; + goto_buf[num++] = ch; + goto_buf[num] = '\0'; + spkup_write(&wch, 1); + maxlen = (*goto_buf >= '0') ? 3 : 4; + if ((ch == '+' || ch == '-') && num == 1) + return 1; + if (ch >= '0' && ch <= '9' && num < maxlen) + return 1; + if (num < maxlen - 1 || num > maxlen) + goto oops; + if (ch < 'x' || ch > 'y') { +oops: + if (!spk_killed) + synth_printf(" %s\n", spk_msg_get(MSG_GOTO_CANCELED)); + goto_buf[num = 0] = '\0'; + spk_special_handler = NULL; + return 1; + } + + /* Do not replace with kstrtoul: here we need cp to be updated */ + goto_pos = simple_strtoul(goto_buf, &cp, 10); + + if (*cp == 'x') { + if (*goto_buf < '0') + goto_pos += spk_x; + else if (goto_pos > 0) + goto_pos--; + + if (goto_pos >= vc->vc_cols) + goto_pos = vc->vc_cols - 1; + goto_x = 1; + } else { + if (*goto_buf < '0') + goto_pos += spk_y; + else if (goto_pos > 0) + goto_pos--; + + if (goto_pos >= vc->vc_rows) + goto_pos = vc->vc_rows - 1; + goto_x = 0; + } + goto_buf[num = 0] = '\0'; +do_goto: + spk_special_handler = NULL; + spk_parked |= 0x01; + if (goto_x) { + spk_pos -= spk_x * 2; + spk_x = goto_pos; + spk_pos += goto_pos * 2; + say_word(vc); + } else { + spk_y = goto_pos; + spk_pos = vc->vc_origin + (goto_pos * vc->vc_size_row); + say_line(vc); + } + return 1; +} + +static void speakup_goto(struct vc_data *vc) +{ + if (spk_special_handler) { + synth_printf("%s\n", spk_msg_get(MSG_ERROR)); + return; + } + synth_printf("%s\n", spk_msg_get(MSG_GOTO)); + spk_special_handler = handle_goto; +} + +static void speakup_help(struct vc_data *vc) +{ + spk_handle_help(vc, KT_SPKUP, SPEAKUP_HELP, 0); +} + +static void do_nothing(struct vc_data *vc) +{ + return; /* flush done in do_spkup */ +} + +static u_char key_speakup, spk_key_locked; + +static void speakup_lock(struct vc_data *vc) +{ + if (!spk_key_locked) { + spk_key_locked = 16; + key_speakup = 16; + } else { + spk_key_locked = 0; + key_speakup = 0; + } +} + +typedef void (*spkup_hand) (struct vc_data *); +static spkup_hand spkup_handler[] = { + /* must be ordered same as defines in speakup.h */ + do_nothing, speakup_goto, speech_kill, speakup_shut_up, + speakup_cut, speakup_paste, say_first_char, say_last_char, + say_char, say_prev_char, say_next_char, + say_word, say_prev_word, say_next_word, + say_line, say_prev_line, say_next_line, + top_edge, bottom_edge, left_edge, right_edge, + spell_word, spell_word, say_screen, + say_position, say_attributes, + speakup_off, speakup_parked, say_line, /* this is for indent */ + say_from_top, say_to_bottom, + say_from_left, say_to_right, + say_char_num, speakup_bits, speakup_bits, say_phonetic_char, + speakup_bits, speakup_bits, speakup_bits, + speakup_win_set, speakup_win_clear, speakup_win_enable, speakup_win_say, + speakup_lock, speakup_help, toggle_cursoring, read_all_doc, NULL +}; + +static void do_spkup(struct vc_data *vc, u_char value) +{ + if (spk_killed && value != SPEECH_KILL) + return; + spk_keydown = 0; + spk_lastkey = 0; + spk_shut_up &= 0xfe; + this_speakup_key = value; + if (value < SPKUP_MAX_FUNC && spkup_handler[value]) { + spk_do_flush(); + (*spkup_handler[value]) (vc); + } else { + if (inc_dec_var(value) < 0) + bleep(9); + } +} + +static const char *pad_chars = "0123456789+-*/\015,.?()"; + +static int +speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym, + int up_flag) +{ + unsigned long flags; + int kh; + u_char *key_info; + u_char type = KTYP(keysym), value = KVAL(keysym), new_key = 0; + u_char shift_info, offset; + int ret = 0; + + if (!synth) + return 0; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + tty = vc->port.tty; + if (type >= 0xf0) + type -= 0xf0; + if (type == KT_PAD && + (vt_get_leds(fg_console, VC_NUMLOCK))) { + if (up_flag) { + spk_keydown = 0; + goto out; + } + value = pad_chars[value]; + spk_lastkey = value; + spk_keydown++; + spk_parked &= 0xfe; + goto no_map; + } + if (keycode >= MAX_KEY) + goto no_map; + key_info = spk_our_keys[keycode]; + if (!key_info) + goto no_map; + /* Check valid read all mode keys */ + if ((cursor_track == read_all_mode) && (!up_flag)) { + switch (value) { + case KVAL(K_DOWN): + case KVAL(K_UP): + case KVAL(K_LEFT): + case KVAL(K_RIGHT): + case KVAL(K_PGUP): + case KVAL(K_PGDN): + break; + default: + stop_read_all(vc); + break; + } + } + shift_info = (shift_state & 0x0f) + key_speakup; + offset = spk_shift_table[shift_info]; + if (offset) { + new_key = key_info[offset]; + if (new_key) { + ret = 1; + if (new_key == SPK_KEY) { + if (!spk_key_locked) + key_speakup = (up_flag) ? 0 : 16; + if (up_flag || spk_killed) + goto out; + spk_shut_up &= 0xfe; + spk_do_flush(); + goto out; + } + if (up_flag) + goto out; + if (last_keycode == keycode && + time_after(last_spk_jiffy + MAX_DELAY, jiffies)) { + spk_close_press = 1; + offset = spk_shift_table[shift_info + 32]; + /* double press? */ + if (offset && key_info[offset]) + new_key = key_info[offset]; + } + last_keycode = keycode; + last_spk_jiffy = jiffies; + type = KT_SPKUP; + value = new_key; + } + } +no_map: + if (type == KT_SPKUP && !spk_special_handler) { + do_spkup(vc, new_key); + spk_close_press = 0; + ret = 1; + goto out; + } + if (up_flag || spk_killed || type == KT_SHIFT) + goto out; + spk_shut_up &= 0xfe; + kh = (value == KVAL(K_DOWN)) || + (value == KVAL(K_UP)) || + (value == KVAL(K_LEFT)) || + (value == KVAL(K_RIGHT)); + if ((cursor_track != read_all_mode) || !kh) + if (!spk_no_intr) + spk_do_flush(); + if (spk_special_handler) { + if (type == KT_SPEC && value == 1) { + value = '\n'; + type = KT_LATIN; + } else if (type == KT_LETTER) { + type = KT_LATIN; + } else if (value == 0x7f) { + value = 8; /* make del = backspace */ + } + ret = (*spk_special_handler) (vc, type, value, keycode); + spk_close_press = 0; + if (ret < 0) + bleep(9); + goto out; + } + last_keycode = 0; +out: + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return ret; +} + +static int keyboard_notifier_call(struct notifier_block *nb, + unsigned long code, void *_param) +{ + struct keyboard_notifier_param *param = _param; + struct vc_data *vc = param->vc; + int up = !param->down; + int ret = NOTIFY_OK; + static int keycode; /* to hold the current keycode */ + + in_keyboard_notifier = 1; + + if (vc->vc_mode == KD_GRAPHICS) + goto out; + + /* + * First, determine whether we are handling a fake keypress on + * the current processor. If we are, then return NOTIFY_OK, + * to pass the keystroke up the chain. This prevents us from + * trying to take the Speakup lock while it is held by the + * processor on which the simulated keystroke was generated. + * Also, the simulated keystrokes should be ignored by Speakup. + */ + + if (speakup_fake_key_pressed()) + goto out; + + switch (code) { + case KBD_KEYCODE: + /* speakup requires keycode and keysym currently */ + keycode = param->value; + break; + case KBD_UNBOUND_KEYCODE: + /* not used yet */ + break; + case KBD_UNICODE: + /* not used yet */ + break; + case KBD_KEYSYM: + if (speakup_key(vc, param->shift, keycode, param->value, up)) + ret = NOTIFY_STOP; + else if (KTYP(param->value) == KT_CUR) + ret = pre_handle_cursor(vc, KVAL(param->value), up); + break; + case KBD_POST_KEYSYM:{ + unsigned char type = KTYP(param->value) - 0xf0; + unsigned char val = KVAL(param->value); + + switch (type) { + case KT_SHIFT: + do_handle_shift(vc, val, up); + break; + case KT_LATIN: + case KT_LETTER: + do_handle_latin(vc, val, up); + break; + case KT_CUR: + do_handle_cursor(vc, val, up); + break; + case KT_SPEC: + do_handle_spec(vc, val, up); + break; + } + break; + } + } +out: + in_keyboard_notifier = 0; + return ret; +} + +static int vt_notifier_call(struct notifier_block *nb, + unsigned long code, void *_param) +{ + struct vt_notifier_param *param = _param; + struct vc_data *vc = param->vc; + + switch (code) { + case VT_ALLOCATE: + if (vc->vc_mode == KD_TEXT) + speakup_allocate(vc, GFP_ATOMIC); + break; + case VT_DEALLOCATE: + speakup_deallocate(vc); + break; + case VT_WRITE: + if (param->c == '\b') { + speakup_bs(vc); + } else { + u16 d = param->c; + + speakup_con_write(vc, &d, 1); + } + break; + case VT_UPDATE: + speakup_con_update(vc); + break; + } + return NOTIFY_OK; +} + +/* called by: module_exit() */ +static void __exit speakup_exit(void) +{ + int i; + + unregister_keyboard_notifier(&keyboard_notifier_block); + unregister_vt_notifier(&vt_notifier_block); + speakup_unregister_devsynth(); + speakup_cancel_selection(); + speakup_cancel_paste(); + del_timer_sync(&cursor_timer); + kthread_stop(speakup_task); + speakup_task = NULL; + mutex_lock(&spk_mutex); + synth_release(); + mutex_unlock(&spk_mutex); + spk_ttyio_unregister_ldisc(); + + speakup_kobj_exit(); + + for (i = 0; i < MAX_NR_CONSOLES; i++) + kfree(speakup_console[i]); + + speakup_remove_virtual_keyboard(); + + for (i = 0; i < MAXVARS; i++) + speakup_unregister_var(i); + + for (i = 0; i < 256; i++) { + if (spk_characters[i] != spk_default_chars[i]) + kfree(spk_characters[i]); + } + + spk_free_user_msgs(); +} + +/* call by: module_init() */ +static int __init speakup_init(void) +{ + int i; + long err = 0; + struct vc_data *vc = vc_cons[fg_console].d; + struct var_t *var; + + /* These first few initializations cannot fail. */ + spk_initialize_msgs(); /* Initialize arrays for i18n. */ + spk_reset_default_chars(); + spk_reset_default_chartab(); + spk_strlwr(synth_name); + spk_vars[0].u.n.high = vc->vc_cols; + for (var = spk_vars; var->var_id != MAXVARS; var++) + speakup_register_var(var); + for (var = synth_time_vars; + (var->var_id >= 0) && (var->var_id < MAXVARS); var++) + speakup_register_var(var); + for (i = 1; spk_punc_info[i].mask != 0; i++) + spk_set_mask_bits(NULL, i, 2); + + spk_set_key_info(spk_key_defaults, spk_key_buf); + + /* From here on out, initializations can fail. */ + err = speakup_add_virtual_keyboard(); + if (err) + goto error_virtkeyboard; + + for (i = 0; i < MAX_NR_CONSOLES; i++) + if (vc_cons[i].d) { + err = speakup_allocate(vc_cons[i].d, GFP_KERNEL); + if (err) + goto error_kobjects; + } + + if (spk_quiet_boot) + spk_shut_up |= 0x01; + + err = speakup_kobj_init(); + if (err) + goto error_kobjects; + + spk_ttyio_register_ldisc(); + synth_init(synth_name); + speakup_register_devsynth(); + /* + * register_devsynth might fail, but this error is not fatal. + * /dev/synth is an extra feature; the rest of Speakup + * will work fine without it. + */ + + err = register_keyboard_notifier(&keyboard_notifier_block); + if (err) + goto error_kbdnotifier; + err = register_vt_notifier(&vt_notifier_block); + if (err) + goto error_vtnotifier; + + speakup_task = kthread_create(speakup_thread, NULL, "speakup"); + + if (IS_ERR(speakup_task)) { + err = PTR_ERR(speakup_task); + goto error_task; + } + + set_user_nice(speakup_task, 10); + wake_up_process(speakup_task); + + pr_info("speakup %s: initialized\n", SPEAKUP_VERSION); + pr_info("synth name on entry is: %s\n", synth_name); + goto out; + +error_task: + unregister_vt_notifier(&vt_notifier_block); + +error_vtnotifier: + unregister_keyboard_notifier(&keyboard_notifier_block); + del_timer(&cursor_timer); + +error_kbdnotifier: + speakup_unregister_devsynth(); + mutex_lock(&spk_mutex); + synth_release(); + mutex_unlock(&spk_mutex); + speakup_kobj_exit(); + +error_kobjects: + for (i = 0; i < MAX_NR_CONSOLES; i++) + kfree(speakup_console[i]); + + speakup_remove_virtual_keyboard(); + +error_virtkeyboard: + for (i = 0; i < MAXVARS; i++) + speakup_unregister_var(i); + + for (i = 0; i < 256; i++) { + if (spk_characters[i] != spk_default_chars[i]) + kfree(spk_characters[i]); + } + + spk_free_user_msgs(); + +out: + return err; +} + +module_init(speakup_init); +module_exit(speakup_exit); diff --git a/drivers/accessibility/speakup/selection.c b/drivers/accessibility/speakup/selection.c new file mode 100644 index 000000000000..032f3264fba1 --- /dev/null +++ b/drivers/accessibility/speakup/selection.c @@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0 +#include /* for kmalloc */ +#include +#include +#include +#include /* for dev_warn */ +#include +#include +#include +#include +#include +#include + +#include "speakup.h" + +unsigned short spk_xs, spk_ys, spk_xe, spk_ye; /* our region points */ +struct vc_data *spk_sel_cons; + +struct speakup_selection_work { + struct work_struct work; + struct tiocl_selection sel; + struct tty_struct *tty; +}; + +void speakup_clear_selection(void) +{ + console_lock(); + clear_selection(); + console_unlock(); +} + +static void __speakup_set_selection(struct work_struct *work) +{ + struct speakup_selection_work *ssw = + container_of(work, struct speakup_selection_work, work); + + struct tty_struct *tty; + struct tiocl_selection sel; + + sel = ssw->sel; + + /* this ensures we copy sel before releasing the lock below */ + rmb(); + + /* release the lock by setting tty of the struct to NULL */ + tty = xchg(&ssw->tty, NULL); + + if (spk_sel_cons != vc_cons[fg_console].d) { + spk_sel_cons = vc_cons[fg_console].d; + pr_warn("Selection: mark console not the same as cut\n"); + goto unref; + } + + set_selection_kernel(&sel, tty); + +unref: + tty_kref_put(tty); +} + +static struct speakup_selection_work speakup_sel_work = { + .work = __WORK_INITIALIZER(speakup_sel_work.work, + __speakup_set_selection) +}; + +int speakup_set_selection(struct tty_struct *tty) +{ + /* we get kref here first in order to avoid a subtle race when + * cancelling selection work. getting kref first establishes the + * invariant that if speakup_sel_work.tty is not NULL when + * speakup_cancel_selection() is called, it must be the case that a put + * kref is pending. + */ + tty_kref_get(tty); + if (cmpxchg(&speakup_sel_work.tty, NULL, tty)) { + tty_kref_put(tty); + return -EBUSY; + } + /* now we have the 'lock' by setting tty member of + * speakup_selection_work. wmb() ensures that writes to + * speakup_sel_work don't happen before cmpxchg() above. + */ + wmb(); + + speakup_sel_work.sel.xs = spk_xs + 1; + speakup_sel_work.sel.ys = spk_ys + 1; + speakup_sel_work.sel.xe = spk_xe + 1; + speakup_sel_work.sel.ye = spk_ye + 1; + speakup_sel_work.sel.sel_mode = TIOCL_SELCHAR; + + schedule_work_on(WORK_CPU_UNBOUND, &speakup_sel_work.work); + + return 0; +} + +void speakup_cancel_selection(void) +{ + struct tty_struct *tty; + + cancel_work_sync(&speakup_sel_work.work); + /* setting to null so that if work fails to run and we cancel it, + * we can run it again without getting EBUSY forever from there on. + * we need to use xchg here to avoid race with speakup_set_selection() + */ + tty = xchg(&speakup_sel_work.tty, NULL); + if (tty) + tty_kref_put(tty); +} + +static void __speakup_paste_selection(struct work_struct *work) +{ + struct speakup_selection_work *ssw = + container_of(work, struct speakup_selection_work, work); + struct tty_struct *tty = xchg(&ssw->tty, NULL); + + paste_selection(tty); + tty_kref_put(tty); +} + +static struct speakup_selection_work speakup_paste_work = { + .work = __WORK_INITIALIZER(speakup_paste_work.work, + __speakup_paste_selection) +}; + +int speakup_paste_selection(struct tty_struct *tty) +{ + tty_kref_get(tty); + if (cmpxchg(&speakup_paste_work.tty, NULL, tty)) { + tty_kref_put(tty); + return -EBUSY; + } + + schedule_work_on(WORK_CPU_UNBOUND, &speakup_paste_work.work); + return 0; +} + +void speakup_cancel_paste(void) +{ + struct tty_struct *tty; + + cancel_work_sync(&speakup_paste_work.work); + tty = xchg(&speakup_paste_work.tty, NULL); + if (tty) + tty_kref_put(tty); +} diff --git a/drivers/accessibility/speakup/serialio.c b/drivers/accessibility/speakup/serialio.c new file mode 100644 index 000000000000..177a2988641c --- /dev/null +++ b/drivers/accessibility/speakup/serialio.c @@ -0,0 +1,316 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include + +#include "spk_types.h" +#include "speakup.h" +#include "spk_priv.h" +#include "serialio.h" + +#include +/* WARNING: Do not change this to without testing that + * SERIAL_PORT_DFNS does get defined to the appropriate value. + */ +#include + +#ifndef SERIAL_PORT_DFNS +#define SERIAL_PORT_DFNS +#endif + +static void start_serial_interrupt(int irq); + +static const struct old_serial_port rs_table[] = { + SERIAL_PORT_DFNS +}; + +static const struct old_serial_port *serstate; +static int timeouts; + +static int spk_serial_out(struct spk_synth *in_synth, const char ch); +static void spk_serial_send_xchar(char ch); +static void spk_serial_tiocmset(unsigned int set, unsigned int clear); +static unsigned char spk_serial_in(void); +static unsigned char spk_serial_in_nowait(void); +static void spk_serial_flush_buffer(void); + +struct spk_io_ops spk_serial_io_ops = { + .synth_out = spk_serial_out, + .send_xchar = spk_serial_send_xchar, + .tiocmset = spk_serial_tiocmset, + .synth_in = spk_serial_in, + .synth_in_nowait = spk_serial_in_nowait, + .flush_buffer = spk_serial_flush_buffer, +}; +EXPORT_SYMBOL_GPL(spk_serial_io_ops); + +const struct old_serial_port *spk_serial_init(int index) +{ + int baud = 9600, quot = 0; + unsigned int cval = 0; + int cflag = CREAD | HUPCL | CLOCAL | B9600 | CS8; + const struct old_serial_port *ser; + int err; + + if (index >= ARRAY_SIZE(rs_table)) { + pr_info("no port info for ttyS%d\n", index); + return NULL; + } + ser = rs_table + index; + + /* Divisor, bytesize and parity */ + quot = ser->baud_base / baud; + cval = cflag & (CSIZE | CSTOPB); +#if defined(__powerpc__) || defined(__alpha__) + cval >>= 8; +#else /* !__powerpc__ && !__alpha__ */ + cval >>= 4; +#endif /* !__powerpc__ && !__alpha__ */ + if (cflag & PARENB) + cval |= UART_LCR_PARITY; + if (!(cflag & PARODD)) + cval |= UART_LCR_EPAR; + if (synth_request_region(ser->port, 8)) { + /* try to take it back. */ + pr_info("Ports not available, trying to steal them\n"); + __release_region(&ioport_resource, ser->port, 8); + err = synth_request_region(ser->port, 8); + if (err) { + pr_warn("Unable to allocate port at %x, errno %i", + ser->port, err); + return NULL; + } + } + + /* Disable UART interrupts, set DTR and RTS high + * and set speed. + */ + outb(cval | UART_LCR_DLAB, ser->port + UART_LCR); /* set DLAB */ + outb(quot & 0xff, ser->port + UART_DLL); /* LS of divisor */ + outb(quot >> 8, ser->port + UART_DLM); /* MS of divisor */ + outb(cval, ser->port + UART_LCR); /* reset DLAB */ + + /* Turn off Interrupts */ + outb(0, ser->port + UART_IER); + outb(UART_MCR_DTR | UART_MCR_RTS, ser->port + UART_MCR); + + /* If we read 0xff from the LSR, there is no UART here. */ + if (inb(ser->port + UART_LSR) == 0xff) { + synth_release_region(ser->port, 8); + serstate = NULL; + return NULL; + } + + mdelay(1); + speakup_info.port_tts = ser->port; + serstate = ser; + + start_serial_interrupt(ser->irq); + + return ser; +} + +static irqreturn_t synth_readbuf_handler(int irq, void *dev_id) +{ + unsigned long flags; + int c; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + while (inb_p(speakup_info.port_tts + UART_LSR) & UART_LSR_DR) { + c = inb_p(speakup_info.port_tts + UART_RX); + synth->read_buff_add((u_char)c); + } + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return IRQ_HANDLED; +} + +static void start_serial_interrupt(int irq) +{ + int rv; + + if (!synth->read_buff_add) + return; + + rv = request_irq(irq, synth_readbuf_handler, IRQF_SHARED, + "serial", (void *)synth_readbuf_handler); + + if (rv) + pr_err("Unable to request Speakup serial I R Q\n"); + /* Set MCR */ + outb(UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2, + speakup_info.port_tts + UART_MCR); + /* Turn on Interrupts */ + outb(UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI, + speakup_info.port_tts + UART_IER); + inb(speakup_info.port_tts + UART_LSR); + inb(speakup_info.port_tts + UART_RX); + inb(speakup_info.port_tts + UART_IIR); + inb(speakup_info.port_tts + UART_MSR); + outb(1, speakup_info.port_tts + UART_FCR); /* Turn FIFO On */ +} + +static void spk_serial_send_xchar(char ch) +{ + int timeout = SPK_XMITR_TIMEOUT; + + while (spk_serial_tx_busy()) { + if (!--timeout) + break; + udelay(1); + } + outb(ch, speakup_info.port_tts); +} + +static void spk_serial_tiocmset(unsigned int set, unsigned int clear) +{ + int old = inb(speakup_info.port_tts + UART_MCR); + + outb((old & ~clear) | set, speakup_info.port_tts + UART_MCR); +} + +int spk_serial_synth_probe(struct spk_synth *synth) +{ + const struct old_serial_port *ser; + int failed = 0; + + if ((synth->ser >= SPK_LO_TTY) && (synth->ser <= SPK_HI_TTY)) { + ser = spk_serial_init(synth->ser); + if (!ser) { + failed = -1; + } else { + outb_p(0, ser->port); + mdelay(1); + outb_p('\r', ser->port); + } + } else { + failed = -1; + pr_warn("ttyS%i is an invalid port\n", synth->ser); + } + if (failed) { + pr_info("%s: not found\n", synth->long_name); + return -ENODEV; + } + pr_info("%s: ttyS%i, Driver Version %s\n", + synth->long_name, synth->ser, synth->version); + synth->alive = 1; + return 0; +} +EXPORT_SYMBOL_GPL(spk_serial_synth_probe); + +void spk_stop_serial_interrupt(void) +{ + if (speakup_info.port_tts == 0) + return; + + if (!synth->read_buff_add) + return; + + /* Turn off interrupts */ + outb(0, speakup_info.port_tts + UART_IER); + /* Free IRQ */ + free_irq(serstate->irq, (void *)synth_readbuf_handler); +} +EXPORT_SYMBOL_GPL(spk_stop_serial_interrupt); + +int spk_wait_for_xmitr(struct spk_synth *in_synth) +{ + int tmout = SPK_XMITR_TIMEOUT; + + if ((in_synth->alive) && (timeouts >= NUM_DISABLE_TIMEOUTS)) { + pr_warn("%s: too many timeouts, deactivating speakup\n", + in_synth->long_name); + in_synth->alive = 0; + /* No synth any more, so nobody will restart TTYs, and we thus + * need to do it ourselves. Now that there is no synth we can + * let application flood anyway + */ + speakup_start_ttys(); + timeouts = 0; + return 0; + } + while (spk_serial_tx_busy()) { + if (--tmout == 0) { + pr_warn("%s: timed out (tx busy)\n", + in_synth->long_name); + timeouts++; + return 0; + } + udelay(1); + } + tmout = SPK_CTS_TIMEOUT; + while (!((inb_p(speakup_info.port_tts + UART_MSR)) & UART_MSR_CTS)) { + /* CTS */ + if (--tmout == 0) { + timeouts++; + return 0; + } + udelay(1); + } + timeouts = 0; + return 1; +} + +static unsigned char spk_serial_in(void) +{ + int tmout = SPK_SERIAL_TIMEOUT; + + while (!(inb_p(speakup_info.port_tts + UART_LSR) & UART_LSR_DR)) { + if (--tmout == 0) { + pr_warn("time out while waiting for input.\n"); + return 0xff; + } + udelay(1); + } + return inb_p(speakup_info.port_tts + UART_RX); +} + +static unsigned char spk_serial_in_nowait(void) +{ + unsigned char lsr; + + lsr = inb_p(speakup_info.port_tts + UART_LSR); + if (!(lsr & UART_LSR_DR)) + return 0; + return inb_p(speakup_info.port_tts + UART_RX); +} + +static void spk_serial_flush_buffer(void) +{ + /* TODO: flush the UART 16550 buffer */ +} + +static int spk_serial_out(struct spk_synth *in_synth, const char ch) +{ + if (in_synth->alive && spk_wait_for_xmitr(in_synth)) { + outb_p(ch, speakup_info.port_tts); + return 1; + } + return 0; +} + +const char *spk_serial_synth_immediate(struct spk_synth *synth, + const char *buff) +{ + u_char ch; + + while ((ch = *buff)) { + if (ch == '\n') + ch = synth->procspeech; + if (spk_wait_for_xmitr(synth)) + outb(ch, speakup_info.port_tts); + else + return buff; + buff++; + } + return NULL; +} +EXPORT_SYMBOL_GPL(spk_serial_synth_immediate); + +void spk_serial_release(void) +{ + spk_stop_serial_interrupt(); + if (speakup_info.port_tts == 0) + return; + synth_release_region(speakup_info.port_tts, 8); + speakup_info.port_tts = 0; +} +EXPORT_SYMBOL_GPL(spk_serial_release); diff --git a/drivers/accessibility/speakup/serialio.h b/drivers/accessibility/speakup/serialio.h new file mode 100644 index 000000000000..6f8f86f161bb --- /dev/null +++ b/drivers/accessibility/speakup/serialio.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _SPEAKUP_SERIAL_H +#define _SPEAKUP_SERIAL_H + +#include /* for rs_table, serial constants */ +#include /* for more serial constants */ +#include + +#include "spk_priv.h" + +/* + * this is cut&paste from 8250.h. Get rid of the structure, the definitions + * and this whole broken driver. + */ +struct old_serial_port { + unsigned int uart; /* unused */ + unsigned int baud_base; + unsigned int port; + unsigned int irq; + upf_t flags; /* unused */ +}; + +/* countdown values for serial timeouts in us */ +#define SPK_SERIAL_TIMEOUT SPK_SYNTH_TIMEOUT +/* countdown values transmitter/dsr timeouts in us */ +#define SPK_XMITR_TIMEOUT 100000 +/* countdown values cts timeouts in us */ +#define SPK_CTS_TIMEOUT 100000 +/* check ttyS0 ... ttyS3 */ +#define SPK_LO_TTY 0 +#define SPK_HI_TTY 3 +/* # of timeouts permitted before disable */ +#define NUM_DISABLE_TIMEOUTS 3 +/* buffer timeout in ms */ +#define SPK_TIMEOUT 100 +#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) + +#define spk_serial_tx_busy() \ + ((inb(speakup_info.port_tts + UART_LSR) & BOTH_EMPTY) != BOTH_EMPTY) + +#endif diff --git a/drivers/accessibility/speakup/speakup.h b/drivers/accessibility/speakup/speakup.h new file mode 100644 index 000000000000..74fe49c2c511 --- /dev/null +++ b/drivers/accessibility/speakup/speakup.h @@ -0,0 +1,121 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _SPEAKUP_H +#define _SPEAKUP_H + +#include "spk_types.h" +#include "i18n.h" + +#define SPEAKUP_VERSION "3.1.6" +#define KEY_MAP_VER 119 +#define SHIFT_TBL_SIZE 64 +#define MAX_DESC_LEN 72 + +#define TOGGLE_0 .u.n = {NULL, 0, 0, 1, 0, 0, NULL } +#define TOGGLE_1 .u.n = {NULL, 1, 0, 1, 0, 0, NULL } +#define MAXVARLEN 15 + +#define SYNTH_OK 0x0001 +#define B_ALPHA 0x0002 +#define ALPHA 0x0003 +#define B_CAP 0x0004 +#define A_CAP 0x0007 +#define B_NUM 0x0008 +#define NUM 0x0009 +#define ALPHANUM (B_ALPHA | B_NUM) +#define SOME 0x0010 +#define MOST 0x0020 +#define PUNC 0x0040 +#define A_PUNC 0x0041 +#define B_WDLM 0x0080 +#define WDLM 0x0081 +#define B_EXNUM 0x0100 +#define CH_RPT 0x0200 +#define B_CTL 0x0400 +#define A_CTL (B_CTL + SYNTH_OK) +#define B_SYM 0x0800 +#define B_CAPSYM (B_CAP | B_SYM) + +/* FIXME: u16 */ +#define IS_WDLM(x) (spk_chartab[((u_char)x)] & B_WDLM) +#define IS_CHAR(x, type) (spk_chartab[((u_char)x)] & type) +#define IS_TYPE(x, type) ((spk_chartab[((u_char)x)] & type) == type) + +int speakup_thread(void *data); +void spk_reset_default_chars(void); +void spk_reset_default_chartab(void); +void synth_start(void); +void synth_insert_next_index(int sent_num); +void spk_reset_index_count(int sc); +void spk_get_index_count(int *linecount, int *sentcount); +int spk_set_key_info(const u_char *key_info, u_char *k_buffer); +char *spk_strlwr(char *s); +char *spk_s2uchar(char *start, char *dest); +int speakup_kobj_init(void); +void speakup_kobj_exit(void); +int spk_chartab_get_value(char *keyword); +void speakup_register_var(struct var_t *var); +void speakup_unregister_var(enum var_id_t var_id); +struct st_var_header *spk_get_var_header(enum var_id_t var_id); +struct st_var_header *spk_var_header_by_name(const char *name); +struct punc_var_t *spk_get_punc_var(enum var_id_t var_id); +int spk_set_num_var(int val, struct st_var_header *var, int how); +int spk_set_string_var(const char *page, struct st_var_header *var, int len); +int spk_set_mask_bits(const char *input, const int which, const int how); +extern special_func spk_special_handler; +int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key); +int synth_init(char *name); +void synth_release(void); + +void spk_do_flush(void); +void speakup_start_ttys(void); +void synth_buffer_add(u16 ch); +void synth_buffer_clear(void); +void speakup_clear_selection(void); +int speakup_set_selection(struct tty_struct *tty); +void speakup_cancel_selection(void); +int speakup_paste_selection(struct tty_struct *tty); +void speakup_cancel_paste(void); +void speakup_register_devsynth(void); +void speakup_unregister_devsynth(void); +void synth_write(const char *buf, size_t count); +int synth_supports_indexing(void); + +extern struct vc_data *spk_sel_cons; +extern unsigned short spk_xs, spk_ys, spk_xe, spk_ye; /* our region points */ + +extern wait_queue_head_t speakup_event; +extern struct kobject *speakup_kobj; +extern struct task_struct *speakup_task; +extern const u_char spk_key_defaults[]; + +/* Protect speakup synthesizer list */ +extern struct mutex spk_mutex; +extern struct st_spk_t *speakup_console[]; +extern struct spk_synth *synth; +extern char spk_pitch_buff[]; +extern u_char *spk_our_keys[]; +extern short spk_punc_masks[]; +extern char spk_str_caps_start[], spk_str_caps_stop[], spk_str_pause[]; +extern bool spk_paused; +extern const struct st_bits_data spk_punc_info[]; +extern u_char spk_key_buf[600]; +extern char *spk_characters[]; +extern char *spk_default_chars[]; +extern u_short spk_chartab[]; +extern int spk_no_intr, spk_say_ctrl, spk_say_word_ctl, spk_punc_level; +extern int spk_reading_punc, spk_attrib_bleep, spk_bleeps; +extern int spk_bleep_time, spk_bell_pos; +extern int spk_spell_delay, spk_key_echo; +extern short spk_punc_mask; +extern short spk_pitch_shift, synth_flags; +extern bool spk_quiet_boot; +extern char *synth_name; +extern struct bleep spk_unprocessed_sound; + +/* Prototypes from fakekey.c. */ +int speakup_add_virtual_keyboard(void); +void speakup_remove_virtual_keyboard(void); +void speakup_fake_down_arrow(void); +bool speakup_fake_key_pressed(void); + +#endif diff --git a/drivers/accessibility/speakup/speakup_acnt.h b/drivers/accessibility/speakup/speakup_acnt.h new file mode 100644 index 000000000000..cffa938ae580 --- /dev/null +++ b/drivers/accessibility/speakup/speakup_acnt.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* speakup_acntpc.h - header file for speakups Accent-PC driver. */ + +#define SYNTH_IO_EXTENT 0x02 + +#define SYNTH_CLEAR 0x18 /* stops speech */ + + /* Port Status Flags */ +#define SYNTH_READABLE 0x01 /* mask for bit which is nonzero if a + * byte can be read from the data port + */ +#define SYNTH_WRITABLE 0x02 /* mask for RDY bit, which when set to + * 1, indicates the data port is ready + * to accept a byte of data. + */ +#define SYNTH_QUIET 'S' /* synth is not speaking */ +#define SYNTH_FULL 'F' /* synth is full. */ +#define SYNTH_ALMOST_EMPTY 'M' /* synth has less than 2 seconds of text left */ +#define SYNTH_SPEAKING 's' /* synth is speaking and has a fare way to go */ diff --git a/drivers/accessibility/speakup/speakup_acntpc.c b/drivers/accessibility/speakup/speakup_acntpc.c new file mode 100644 index 000000000000..c94328a5bd4a --- /dev/null +++ b/drivers/accessibility/speakup/speakup_acntpc.c @@ -0,0 +1,319 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * written by: Kirk Reiser + * this version considerably modified by David Borowski, david575@rogers.com + * + * Copyright (C) 1998-99 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + * + * this code is specificly written as a driver for the speakup screenreview + * package and is not a general device driver. + * This driver is for the Aicom Acent PC internal synthesizer. + */ + +#include +#include +#include +#include + +#include "spk_priv.h" +#include "serialio.h" +#include "speakup.h" +#include "speakup_acnt.h" /* local header file for Accent values */ + +#define DRV_VERSION "2.10" +#define PROCSPEECH '\r' + +static int synth_probe(struct spk_synth *synth); +static void accent_release(void); +static const char *synth_immediate(struct spk_synth *synth, const char *buf); +static void do_catch_up(struct spk_synth *synth); +static void synth_flush(struct spk_synth *synth); + +static int synth_port_control; +static int port_forced; +static unsigned int synth_portlist[] = { 0x2a8, 0 }; + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"\033P8" } }, + { CAPS_STOP, .u.s = {"\033P5" } }, + { RATE, .u.n = {"\033R%c", 9, 0, 17, 0, 0, "0123456789abcdefgh" } }, + { PITCH, .u.n = {"\033P%d", 5, 0, 9, 0, 0, NULL } }, + { VOL, .u.n = {"\033A%d", 5, 0, 9, 0, 0, NULL } }, + { TONE, .u.n = {"\033V%d", 5, 0, 9, 0, 0, NULL } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* + * These attributes will appear in /sys/accessibility/speakup/acntpc. + */ +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute tone_attribute = + __ATTR(tone, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &pitch_attribute.attr, + &rate_attribute.attr, + &tone_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_acntpc = { + .name = "acntpc", + .version = DRV_VERSION, + .long_name = "Accent PC", + .init = "\033=X \033Oi\033T2\033=M\033N1\n", + .procspeech = PROCSPEECH, + .clear = SYNTH_CLEAR, + .delay = 500, + .trigger = 50, + .jiffies = 50, + .full = 1000, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = &spk_serial_io_ops, + .probe = synth_probe, + .release = accent_release, + .synth_immediate = synth_immediate, + .catch_up = do_catch_up, + .flush = synth_flush, + .is_alive = spk_synth_is_alive_nop, + .synth_adjust = NULL, + .read_buff_add = NULL, + .get_index = NULL, + .indexing = { + .command = NULL, + .lowindex = 0, + .highindex = 0, + .currindex = 0, + }, + .attributes = { + .attrs = synth_attrs, + .name = "acntpc", + }, +}; + +static inline bool synth_writable(void) +{ + return inb_p(synth_port_control) & SYNTH_WRITABLE; +} + +static inline bool synth_full(void) +{ + return inb_p(speakup_info.port_tts + UART_RX) == 'F'; +} + +static const char *synth_immediate(struct spk_synth *synth, const char *buf) +{ + u_char ch; + + while ((ch = *buf)) { + int timeout = SPK_XMITR_TIMEOUT; + + if (ch == '\n') + ch = PROCSPEECH; + if (synth_full()) + return buf; + while (synth_writable()) { + if (!--timeout) + return buf; + udelay(1); + } + outb_p(ch, speakup_info.port_tts); + buf++; + } + return NULL; +} + +static void do_catch_up(struct spk_synth *synth) +{ + u_char ch; + unsigned long flags; + unsigned long jiff_max; + int timeout; + int delay_time_val; + int jiffy_delta_val; + int full_time_val; + struct var_t *delay_time; + struct var_t *full_time; + struct var_t *jiffy_delta; + + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); + full_time = spk_get_var(FULL); + + spin_lock_irqsave(&speakup_info.spinlock, flags); + jiffy_delta_val = jiffy_delta->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + + jiff_max = jiffies + jiffy_delta_val; + while (!kthread_should_stop()) { + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (speakup_info.flushing) { + speakup_info.flushing = 0; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + synth->flush(synth); + continue; + } + synth_buffer_skip_nonlatin1(); + if (synth_buffer_empty()) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + break; + } + set_current_state(TASK_INTERRUPTIBLE); + full_time_val = full_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (synth_full()) { + schedule_timeout(msecs_to_jiffies(full_time_val)); + continue; + } + set_current_state(TASK_RUNNING); + timeout = SPK_XMITR_TIMEOUT; + while (synth_writable()) { + if (!--timeout) + break; + udelay(1); + } + spin_lock_irqsave(&speakup_info.spinlock, flags); + ch = synth_buffer_getc(); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (ch == '\n') + ch = PROCSPEECH; + outb_p(ch, speakup_info.port_tts); + if (time_after_eq(jiffies, jiff_max) && ch == SPACE) { + timeout = SPK_XMITR_TIMEOUT; + while (synth_writable()) { + if (!--timeout) + break; + udelay(1); + } + outb_p(PROCSPEECH, speakup_info.port_tts); + spin_lock_irqsave(&speakup_info.spinlock, flags); + jiffy_delta_val = jiffy_delta->u.n.value; + delay_time_val = delay_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + schedule_timeout(msecs_to_jiffies(delay_time_val)); + jiff_max = jiffies + jiffy_delta_val; + } + } + timeout = SPK_XMITR_TIMEOUT; + while (synth_writable()) { + if (!--timeout) + break; + udelay(1); + } + outb_p(PROCSPEECH, speakup_info.port_tts); +} + +static void synth_flush(struct spk_synth *synth) +{ + outb_p(SYNTH_CLEAR, speakup_info.port_tts); +} + +static int synth_probe(struct spk_synth *synth) +{ + unsigned int port_val = 0; + int i = 0; + + pr_info("Probing for %s.\n", synth->long_name); + if (port_forced) { + speakup_info.port_tts = port_forced; + pr_info("probe forced to %x by kernel command line\n", + speakup_info.port_tts); + if (synth_request_region(speakup_info.port_tts - 1, + SYNTH_IO_EXTENT)) { + pr_warn("sorry, port already reserved\n"); + return -EBUSY; + } + port_val = inw(speakup_info.port_tts - 1); + synth_port_control = speakup_info.port_tts - 1; + } else { + for (i = 0; synth_portlist[i]; i++) { + if (synth_request_region(synth_portlist[i], + SYNTH_IO_EXTENT)) { + pr_warn + ("request_region: failed with 0x%x, %d\n", + synth_portlist[i], SYNTH_IO_EXTENT); + continue; + } + port_val = inw(synth_portlist[i]) & 0xfffc; + if (port_val == 0x53fc) { + /* 'S' and out&input bits */ + synth_port_control = synth_portlist[i]; + speakup_info.port_tts = synth_port_control + 1; + break; + } + } + } + port_val &= 0xfffc; + if (port_val != 0x53fc) { + /* 'S' and out&input bits */ + pr_info("%s: not found\n", synth->long_name); + synth_release_region(synth_port_control, SYNTH_IO_EXTENT); + synth_port_control = 0; + return -ENODEV; + } + pr_info("%s: %03x-%03x, driver version %s,\n", synth->long_name, + synth_port_control, synth_port_control + SYNTH_IO_EXTENT - 1, + synth->version); + synth->alive = 1; + return 0; +} + +static void accent_release(void) +{ + spk_stop_serial_interrupt(); + if (speakup_info.port_tts) + synth_release_region(speakup_info.port_tts - 1, + SYNTH_IO_EXTENT); + speakup_info.port_tts = 0; +} + +module_param_hw_named(port, port_forced, int, ioport, 0444); +module_param_named(start, synth_acntpc.startup, short, 0444); + +MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing)."); +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_acntpc); + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_AUTHOR("David Borowski"); +MODULE_DESCRIPTION("Speakup support for Accent PC synthesizer"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/drivers/accessibility/speakup/speakup_acntsa.c b/drivers/accessibility/speakup/speakup_acntsa.c new file mode 100644 index 000000000000..3a863dc61286 --- /dev/null +++ b/drivers/accessibility/speakup/speakup_acntsa.c @@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * originally written by: Kirk Reiser + * this version considerably modified by David Borowski, david575@rogers.com + * + * Copyright (C) 1998-99 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + * + * this code is specificly written as a driver for the speakup screenreview + * package and is not a general device driver. + */ + +#include "spk_priv.h" +#include "speakup.h" +#include "speakup_acnt.h" /* local header file for Accent values */ + +#define DRV_VERSION "2.11" +#define PROCSPEECH '\r' + +static int synth_probe(struct spk_synth *synth); + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"\033P8" } }, + { CAPS_STOP, .u.s = {"\033P5" } }, + { RATE, .u.n = {"\033R%c", 9, 0, 17, 0, 0, "0123456789abcdefgh" } }, + { PITCH, .u.n = {"\033P%d", 5, 0, 9, 0, 0, NULL } }, + { VOL, .u.n = {"\033A%d", 9, 0, 9, 0, 0, NULL } }, + { TONE, .u.n = {"\033V%d", 5, 0, 9, 0, 0, NULL } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* + * These attributes will appear in /sys/accessibility/speakup/acntsa. + */ +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute tone_attribute = + __ATTR(tone, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &pitch_attribute.attr, + &rate_attribute.attr, + &tone_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_acntsa = { + .name = "acntsa", + .version = DRV_VERSION, + .long_name = "Accent-SA", + .init = "\033T2\033=M\033Oi\033N1\n", + .procspeech = PROCSPEECH, + .clear = SYNTH_CLEAR, + .delay = 400, + .trigger = 50, + .jiffies = 30, + .full = 40000, + .dev_name = SYNTH_DEFAULT_DEV, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = &spk_ttyio_ops, + .probe = synth_probe, + .release = spk_ttyio_release, + .synth_immediate = spk_ttyio_synth_immediate, + .catch_up = spk_do_catch_up, + .flush = spk_synth_flush, + .is_alive = spk_synth_is_alive_restart, + .synth_adjust = NULL, + .read_buff_add = NULL, + .get_index = NULL, + .indexing = { + .command = NULL, + .lowindex = 0, + .highindex = 0, + .currindex = 0, + }, + .attributes = { + .attrs = synth_attrs, + .name = "acntsa", + }, +}; + +static int synth_probe(struct spk_synth *synth) +{ + int failed; + + failed = spk_ttyio_synth_probe(synth); + if (failed == 0) { + synth->synth_immediate(synth, "\033=R\r"); + mdelay(100); + } + synth->alive = !failed; + return failed; +} + +module_param_named(ser, synth_acntsa.ser, int, 0444); +module_param_named(dev, synth_acntsa.dev_name, charp, 0444); +module_param_named(start, synth_acntsa.startup, short, 0444); + +MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); +MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_acntsa); + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_AUTHOR("David Borowski"); +MODULE_DESCRIPTION("Speakup support for Accent SA synthesizer"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/drivers/accessibility/speakup/speakup_apollo.c b/drivers/accessibility/speakup/speakup_apollo.c new file mode 100644 index 000000000000..0877b4044c28 --- /dev/null +++ b/drivers/accessibility/speakup/speakup_apollo.c @@ -0,0 +1,208 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * originally written by: Kirk Reiser + * this version considerably modified by David Borowski, david575@rogers.com + * + * Copyright (C) 1998-99 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + * + * this code is specificly written as a driver for the speakup screenreview + * package and is not a general device driver. + */ +#include +#include +#include +#include +#include /* for UART_MCR* constants */ + +#include "spk_priv.h" +#include "speakup.h" + +#define DRV_VERSION "2.21" +#define SYNTH_CLEAR 0x18 +#define PROCSPEECH '\r' + +static void do_catch_up(struct spk_synth *synth); + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"cap, " } }, + { CAPS_STOP, .u.s = {"" } }, + { RATE, .u.n = {"@W%d", 6, 1, 9, 0, 0, NULL } }, + { PITCH, .u.n = {"@F%x", 10, 0, 15, 0, 0, NULL } }, + { VOL, .u.n = {"@A%x", 10, 0, 15, 0, 0, NULL } }, + { VOICE, .u.n = {"@V%d", 1, 1, 6, 0, 0, NULL } }, + { LANG, .u.n = {"@=%d,", 1, 1, 4, 0, 0, NULL } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* + * These attributes will appear in /sys/accessibility/speakup/apollo. + */ +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute lang_attribute = + __ATTR(lang, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute voice_attribute = + __ATTR(voice, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &lang_attribute.attr, + &pitch_attribute.attr, + &rate_attribute.attr, + &voice_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_apollo = { + .name = "apollo", + .version = DRV_VERSION, + .long_name = "Apollo", + .init = "@R3@D0@K1\r", + .procspeech = PROCSPEECH, + .clear = SYNTH_CLEAR, + .delay = 500, + .trigger = 50, + .jiffies = 50, + .full = 40000, + .dev_name = SYNTH_DEFAULT_DEV, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = &spk_ttyio_ops, + .probe = spk_ttyio_synth_probe, + .release = spk_ttyio_release, + .synth_immediate = spk_ttyio_synth_immediate, + .catch_up = do_catch_up, + .flush = spk_synth_flush, + .is_alive = spk_synth_is_alive_restart, + .synth_adjust = NULL, + .read_buff_add = NULL, + .get_index = NULL, + .indexing = { + .command = NULL, + .lowindex = 0, + .highindex = 0, + .currindex = 0, + }, + .attributes = { + .attrs = synth_attrs, + .name = "apollo", + }, +}; + +static void do_catch_up(struct spk_synth *synth) +{ + u_char ch; + unsigned long flags; + unsigned long jiff_max; + struct var_t *jiffy_delta; + struct var_t *delay_time; + struct var_t *full_time; + int full_time_val = 0; + int delay_time_val = 0; + int jiffy_delta_val = 0; + + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); + full_time = spk_get_var(FULL); + spin_lock_irqsave(&speakup_info.spinlock, flags); + jiffy_delta_val = jiffy_delta->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + jiff_max = jiffies + jiffy_delta_val; + + while (!kthread_should_stop()) { + spin_lock_irqsave(&speakup_info.spinlock, flags); + jiffy_delta_val = jiffy_delta->u.n.value; + full_time_val = full_time->u.n.value; + delay_time_val = delay_time->u.n.value; + if (speakup_info.flushing) { + speakup_info.flushing = 0; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + synth->flush(synth); + continue; + } + synth_buffer_skip_nonlatin1(); + if (synth_buffer_empty()) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + break; + } + ch = synth_buffer_peek(); + set_current_state(TASK_INTERRUPTIBLE); + full_time_val = full_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (!synth->io_ops->synth_out(synth, ch)) { + synth->io_ops->tiocmset(0, UART_MCR_RTS); + synth->io_ops->tiocmset(UART_MCR_RTS, 0); + schedule_timeout(msecs_to_jiffies(full_time_val)); + continue; + } + if (time_after_eq(jiffies, jiff_max) && (ch == SPACE)) { + spin_lock_irqsave(&speakup_info.spinlock, flags); + jiffy_delta_val = jiffy_delta->u.n.value; + full_time_val = full_time->u.n.value; + delay_time_val = delay_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (synth->io_ops->synth_out(synth, synth->procspeech)) + schedule_timeout(msecs_to_jiffies + (delay_time_val)); + else + schedule_timeout(msecs_to_jiffies + (full_time_val)); + jiff_max = jiffies + jiffy_delta_val; + } + set_current_state(TASK_RUNNING); + spin_lock_irqsave(&speakup_info.spinlock, flags); + synth_buffer_getc(); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + } + synth->io_ops->synth_out(synth, PROCSPEECH); +} + +module_param_named(ser, synth_apollo.ser, int, 0444); +module_param_named(dev, synth_apollo.dev_name, charp, 0444); +module_param_named(start, synth_apollo.startup, short, 0444); + +MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); +MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_apollo); + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_AUTHOR("David Borowski"); +MODULE_DESCRIPTION("Speakup support for Apollo II synthesizer"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/drivers/accessibility/speakup/speakup_audptr.c b/drivers/accessibility/speakup/speakup_audptr.c new file mode 100644 index 000000000000..e6a6a9665d8f --- /dev/null +++ b/drivers/accessibility/speakup/speakup_audptr.c @@ -0,0 +1,171 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * originally written by: Kirk Reiser + * this version considerably modified by David Borowski, david575@rogers.com + * + * Copyright (C) 1998-99 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + * + * specificly written as a driver for the speakup screenreview + * s not a general device driver. + */ +#include "spk_priv.h" +#include "speakup.h" + +#define DRV_VERSION "2.11" +#define SYNTH_CLEAR 0x18 /* flush synth buffer */ +#define PROCSPEECH '\r' /* start synth processing speech char */ + +static int synth_probe(struct spk_synth *synth); +static void synth_flush(struct spk_synth *synth); + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"\x05[f99]" } }, + { CAPS_STOP, .u.s = {"\x05[f80]" } }, + { RATE, .u.n = {"\x05[r%d]", 10, 0, 20, 100, -10, NULL } }, + { PITCH, .u.n = {"\x05[f%d]", 80, 39, 4500, 0, 0, NULL } }, + { VOL, .u.n = {"\x05[g%d]", 21, 0, 40, 0, 0, NULL } }, + { TONE, .u.n = {"\x05[s%d]", 9, 0, 63, 0, 0, NULL } }, + { PUNCT, .u.n = {"\x05[A%c]", 0, 0, 3, 0, 0, "nmsa" } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* + * These attributes will appear in /sys/accessibility/speakup/audptr. + */ +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute punct_attribute = + __ATTR(punct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute tone_attribute = + __ATTR(tone, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &pitch_attribute.attr, + &punct_attribute.attr, + &rate_attribute.attr, + &tone_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_audptr = { + .name = "audptr", + .version = DRV_VERSION, + .long_name = "Audapter", + .init = "\x05[D1]\x05[Ol]", + .procspeech = PROCSPEECH, + .clear = SYNTH_CLEAR, + .delay = 400, + .trigger = 50, + .jiffies = 30, + .full = 18000, + .dev_name = SYNTH_DEFAULT_DEV, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = &spk_ttyio_ops, + .probe = synth_probe, + .release = spk_ttyio_release, + .synth_immediate = spk_ttyio_synth_immediate, + .catch_up = spk_do_catch_up, + .flush = synth_flush, + .is_alive = spk_synth_is_alive_restart, + .synth_adjust = NULL, + .read_buff_add = NULL, + .get_index = NULL, + .indexing = { + .command = NULL, + .lowindex = 0, + .highindex = 0, + .currindex = 0, + }, + .attributes = { + .attrs = synth_attrs, + .name = "audptr", + }, +}; + +static void synth_flush(struct spk_synth *synth) +{ + synth->io_ops->flush_buffer(); + synth->io_ops->send_xchar(SYNTH_CLEAR); + synth->io_ops->synth_out(synth, PROCSPEECH); +} + +static void synth_version(struct spk_synth *synth) +{ + unsigned char test = 0; + char synth_id[40] = ""; + + synth->synth_immediate(synth, "\x05[Q]"); + synth_id[test] = synth->io_ops->synth_in(); + if (synth_id[test] == 'A') { + do { + /* read version string from synth */ + synth_id[++test] = synth->io_ops->synth_in(); + } while (synth_id[test] != '\n' && test < 32); + synth_id[++test] = 0x00; + } + if (synth_id[0] == 'A') + pr_info("%s version: %s", synth->long_name, synth_id); +} + +static int synth_probe(struct spk_synth *synth) +{ + int failed; + + failed = spk_ttyio_synth_probe(synth); + if (failed == 0) + synth_version(synth); + synth->alive = !failed; + return 0; +} + +module_param_named(ser, synth_audptr.ser, int, 0444); +module_param_named(dev, synth_audptr.dev_name, charp, 0444); +module_param_named(start, synth_audptr.startup, short, 0444); + +MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); +MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_audptr); + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_AUTHOR("David Borowski"); +MODULE_DESCRIPTION("Speakup support for Audapter synthesizer"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/drivers/accessibility/speakup/speakup_bns.c b/drivers/accessibility/speakup/speakup_bns.c new file mode 100644 index 000000000000..76dfa3f7c058 --- /dev/null +++ b/drivers/accessibility/speakup/speakup_bns.c @@ -0,0 +1,128 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * originally written by: Kirk Reiser + * this version considerably modified by David Borowski, david575@rogers.com + * + * Copyright (C) 1998-99 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + * + * this code is specificly written as a driver for the speakup screenreview + * package and is not a general device driver. + */ +#include "spk_priv.h" +#include "speakup.h" + +#define DRV_VERSION "2.11" +#define SYNTH_CLEAR 0x18 +#define PROCSPEECH '\r' + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"\x05\x31\x32P" } }, + { CAPS_STOP, .u.s = {"\x05\x38P" } }, + { RATE, .u.n = {"\x05%dE", 8, 1, 16, 0, 0, NULL } }, + { PITCH, .u.n = {"\x05%dP", 8, 0, 16, 0, 0, NULL } }, + { VOL, .u.n = {"\x05%dV", 8, 0, 16, 0, 0, NULL } }, + { TONE, .u.n = {"\x05%dT", 8, 0, 16, 0, 0, NULL } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* + * These attributes will appear in /sys/accessibility/speakup/bns. + */ +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute tone_attribute = + __ATTR(tone, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &pitch_attribute.attr, + &rate_attribute.attr, + &tone_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_bns = { + .name = "bns", + .version = DRV_VERSION, + .long_name = "Braille 'N Speak", + .init = "\x05Z\x05\x43", + .procspeech = PROCSPEECH, + .clear = SYNTH_CLEAR, + .delay = 500, + .trigger = 50, + .jiffies = 50, + .full = 40000, + .dev_name = SYNTH_DEFAULT_DEV, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = &spk_ttyio_ops, + .probe = spk_ttyio_synth_probe, + .release = spk_ttyio_release, + .synth_immediate = spk_ttyio_synth_immediate, + .catch_up = spk_do_catch_up, + .flush = spk_synth_flush, + .is_alive = spk_synth_is_alive_restart, + .synth_adjust = NULL, + .read_buff_add = NULL, + .get_index = NULL, + .indexing = { + .command = NULL, + .lowindex = 0, + .highindex = 0, + .currindex = 0, + }, + .attributes = { + .attrs = synth_attrs, + .name = "bns", + }, +}; + +module_param_named(ser, synth_bns.ser, int, 0444); +module_param_named(dev, synth_bns.dev_name, charp, 0444); +module_param_named(start, synth_bns.startup, short, 0444); + +MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); +MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_bns); + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_AUTHOR("David Borowski"); +MODULE_DESCRIPTION("Speakup support for Braille 'n Speak synthesizers"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/drivers/accessibility/speakup/speakup_decext.c b/drivers/accessibility/speakup/speakup_decext.c new file mode 100644 index 000000000000..7408eb29cf38 --- /dev/null +++ b/drivers/accessibility/speakup/speakup_decext.c @@ -0,0 +1,240 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * originally written by: Kirk Reiser + * this version considerably modified by David Borowski, david575@rogers.com + * + * Copyright (C) 1998-99 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + * + * specificly written as a driver for the speakup screenreview + * s not a general device driver. + */ +#include +#include +#include +#include + +#include "spk_priv.h" +#include "speakup.h" + +#define DRV_VERSION "2.14" +#define SYNTH_CLEAR 0x03 +#define PROCSPEECH 0x0b + +static volatile unsigned char last_char; + +static void read_buff_add(u_char ch) +{ + last_char = ch; +} + +static inline bool synth_full(void) +{ + return last_char == 0x13; +} + +static void do_catch_up(struct spk_synth *synth); +static void synth_flush(struct spk_synth *synth); + +static int in_escape; + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"[:dv ap 222]" } }, + { CAPS_STOP, .u.s = {"[:dv ap 100]" } }, + { RATE, .u.n = {"[:ra %d]", 7, 0, 9, 150, 25, NULL } }, + { PITCH, .u.n = {"[:dv ap %d]", 100, 0, 100, 0, 0, NULL } }, + { INFLECTION, .u.n = {"[:dv pr %d] ", 100, 0, 10000, 0, 0, NULL } }, + { VOL, .u.n = {"[:dv gv %d]", 13, 0, 16, 0, 5, NULL } }, + { PUNCT, .u.n = {"[:pu %c]", 0, 0, 2, 0, 0, "nsa" } }, + { VOICE, .u.n = {"[:n%c]", 0, 0, 9, 0, 0, "phfdburwkv" } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* + * These attributes will appear in /sys/accessibility/speakup/decext. + */ +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute inflection_attribute = + __ATTR(inflection, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute punct_attribute = + __ATTR(punct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute voice_attribute = + __ATTR(voice, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &pitch_attribute.attr, + &inflection_attribute.attr, + &punct_attribute.attr, + &rate_attribute.attr, + &voice_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_decext = { + .name = "decext", + .version = DRV_VERSION, + .long_name = "Dectalk External", + .init = "[:pe -380]", + .procspeech = PROCSPEECH, + .clear = SYNTH_CLEAR, + .delay = 500, + .trigger = 50, + .jiffies = 50, + .full = 40000, + .flags = SF_DEC, + .dev_name = SYNTH_DEFAULT_DEV, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = &spk_ttyio_ops, + .probe = spk_ttyio_synth_probe, + .release = spk_ttyio_release, + .synth_immediate = spk_ttyio_synth_immediate, + .catch_up = do_catch_up, + .flush = synth_flush, + .is_alive = spk_synth_is_alive_restart, + .synth_adjust = NULL, + .read_buff_add = read_buff_add, + .get_index = NULL, + .indexing = { + .command = NULL, + .lowindex = 0, + .highindex = 0, + .currindex = 0, + }, + .attributes = { + .attrs = synth_attrs, + .name = "decext", + }, +}; + +static void do_catch_up(struct spk_synth *synth) +{ + u_char ch; + static u_char last = '\0'; + unsigned long flags; + unsigned long jiff_max; + struct var_t *jiffy_delta; + struct var_t *delay_time; + int jiffy_delta_val = 0; + int delay_time_val = 0; + + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); + + spin_lock_irqsave(&speakup_info.spinlock, flags); + jiffy_delta_val = jiffy_delta->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + jiff_max = jiffies + jiffy_delta_val; + + while (!kthread_should_stop()) { + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (speakup_info.flushing) { + speakup_info.flushing = 0; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + synth->flush(synth); + continue; + } + synth_buffer_skip_nonlatin1(); + if (synth_buffer_empty()) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + break; + } + ch = synth_buffer_peek(); + set_current_state(TASK_INTERRUPTIBLE); + delay_time_val = delay_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (ch == '\n') + ch = 0x0D; + if (synth_full() || !synth->io_ops->synth_out(synth, ch)) { + schedule_timeout(msecs_to_jiffies(delay_time_val)); + continue; + } + set_current_state(TASK_RUNNING); + spin_lock_irqsave(&speakup_info.spinlock, flags); + synth_buffer_getc(); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (ch == '[') { + in_escape = 1; + } else if (ch == ']') { + in_escape = 0; + } else if (ch <= SPACE) { + if (!in_escape && strchr(",.!?;:", last)) + synth->io_ops->synth_out(synth, PROCSPEECH); + if (time_after_eq(jiffies, jiff_max)) { + if (!in_escape) + synth->io_ops->synth_out(synth, + PROCSPEECH); + spin_lock_irqsave(&speakup_info.spinlock, + flags); + jiffy_delta_val = jiffy_delta->u.n.value; + delay_time_val = delay_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, + flags); + schedule_timeout(msecs_to_jiffies + (delay_time_val)); + jiff_max = jiffies + jiffy_delta_val; + } + } + last = ch; + } + if (!in_escape) + synth->io_ops->synth_out(synth, PROCSPEECH); +} + +static void synth_flush(struct spk_synth *synth) +{ + in_escape = 0; + synth->io_ops->flush_buffer(); + synth->synth_immediate(synth, "\033P;10z\033\\"); +} + +module_param_named(ser, synth_decext.ser, int, 0444); +module_param_named(dev, synth_decext.dev_name, charp, 0444); +module_param_named(start, synth_decext.startup, short, 0444); + +MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); +MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_decext); + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_AUTHOR("David Borowski"); +MODULE_DESCRIPTION("Speakup support for DECtalk External synthesizers"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/drivers/accessibility/speakup/speakup_decpc.c b/drivers/accessibility/speakup/speakup_decpc.c new file mode 100644 index 000000000000..96f24c848cc5 --- /dev/null +++ b/drivers/accessibility/speakup/speakup_decpc.c @@ -0,0 +1,495 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * This is the DECtalk PC speakup driver + * + * Some constants from DEC's DOS driver: + * Copyright (c) by Digital Equipment Corp. + * + * 386BSD DECtalk PC driver: + * Copyright (c) 1996 Brian Buhrow + * + * Linux DECtalk PC driver: + * Copyright (c) 1997 Nicolas Pitre + * + * speakup DECtalk PC Internal driver: + * Copyright (c) 2003 David Borowski + * + * All rights reserved. + */ +#include +#include +#include +#include + +#include "spk_priv.h" +#include "speakup.h" + +#define MODULE_init 0x0dec /* module in boot code */ +#define MODULE_self_test 0x8800 /* module in self-test */ +#define MODULE_reset 0xffff /* reinit the whole module */ + +#define MODE_mask 0xf000 /* mode bits in high nibble */ +#define MODE_null 0x0000 +#define MODE_test 0x2000 /* in testing mode */ +#define MODE_status 0x8000 +#define STAT_int 0x0001 /* running in interrupt mode */ +#define STAT_tr_char 0x0002 /* character data to transmit */ +#define STAT_rr_char 0x0004 /* ready to receive char data */ +#define STAT_cmd_ready 0x0008 /* ready to accept commands */ +#define STAT_dma_ready 0x0010 /* dma command ready */ +#define STAT_digitized 0x0020 /* spc in digitized mode */ +#define STAT_new_index 0x0040 /* new last index ready */ +#define STAT_new_status 0x0080 /* new status posted */ +#define STAT_dma_state 0x0100 /* dma state toggle */ +#define STAT_index_valid 0x0200 /* indexs are valid */ +#define STAT_flushing 0x0400 /* flush in progress */ +#define STAT_self_test 0x0800 /* module in self test */ +#define MODE_ready 0xc000 /* module ready for next phase */ +#define READY_boot 0x0000 +#define READY_kernel 0x0001 +#define MODE_error 0xf000 + +#define CMD_mask 0xf000 /* mask for command nibble */ +#define CMD_null 0x0000 /* post status */ +#define CMD_control 0x1000 /* hard control command */ +#define CTRL_mask 0x0F00 /* mask off control nibble */ +#define CTRL_data 0x00FF /* mask to get data byte */ +#define CTRL_null 0x0000 /* null control */ +#define CTRL_vol_up 0x0100 /* increase volume */ +#define CTRL_vol_down 0x0200 /* decrease volume */ +#define CTRL_vol_set 0x0300 /* set volume */ +#define CTRL_pause 0x0400 /* pause spc */ +#define CTRL_resume 0x0500 /* resume spc clock */ +#define CTRL_resume_spc 0x0001 /* resume spc soft pause */ +#define CTRL_flush 0x0600 /* flush all buffers */ +#define CTRL_int_enable 0x0700 /* enable status change ints */ +#define CTRL_buff_free 0x0800 /* buffer remain count */ +#define CTRL_buff_used 0x0900 /* buffer in use */ +#define CTRL_speech 0x0a00 /* immediate speech change */ +#define CTRL_SP_voice 0x0001 /* voice change */ +#define CTRL_SP_rate 0x0002 /* rate change */ +#define CTRL_SP_comma 0x0003 /* comma pause change */ +#define CTRL_SP_period 0x0004 /* period pause change */ +#define CTRL_SP_rate_delta 0x0005 /* delta rate change */ +#define CTRL_SP_get_param 0x0006 /* return the desired parameter */ +#define CTRL_last_index 0x0b00 /* get last index spoken */ +#define CTRL_io_priority 0x0c00 /* change i/o priority */ +#define CTRL_free_mem 0x0d00 /* get free paragraphs on module */ +#define CTRL_get_lang 0x0e00 /* return bitmask of loaded languages */ +#define CMD_test 0x2000 /* self-test request */ +#define TEST_mask 0x0F00 /* isolate test field */ +#define TEST_null 0x0000 /* no test requested */ +#define TEST_isa_int 0x0100 /* assert isa irq */ +#define TEST_echo 0x0200 /* make data in == data out */ +#define TEST_seg 0x0300 /* set peek/poke segment */ +#define TEST_off 0x0400 /* set peek/poke offset */ +#define TEST_peek 0x0500 /* data out == *peek */ +#define TEST_poke 0x0600 /* *peek == data in */ +#define TEST_sub_code 0x00FF /* user defined test sub codes */ +#define CMD_id 0x3000 /* return software id */ +#define ID_null 0x0000 /* null id */ +#define ID_kernel 0x0100 /* kernel code executing */ +#define ID_boot 0x0200 /* boot code executing */ +#define CMD_dma 0x4000 /* force a dma start */ +#define CMD_reset 0x5000 /* reset module status */ +#define CMD_sync 0x6000 /* kernel sync command */ +#define CMD_char_in 0x7000 /* single character send */ +#define CMD_char_out 0x8000 /* single character get */ +#define CHAR_count_1 0x0100 /* one char in cmd_low */ +#define CHAR_count_2 0x0200 /* the second in data_low */ +#define CHAR_count_3 0x0300 /* the third in data_high */ +#define CMD_spc_mode 0x9000 /* change spc mode */ +#define CMD_spc_to_text 0x0100 /* set to text mode */ +#define CMD_spc_to_digit 0x0200 /* set to digital mode */ +#define CMD_spc_rate 0x0400 /* change spc data rate */ +#define CMD_error 0xf000 /* severe error */ + +enum { PRIMARY_DIC = 0, USER_DIC, COMMAND_DIC, ABBREV_DIC }; + +#define DMA_single_in 0x01 +#define DMA_single_out 0x02 +#define DMA_buff_in 0x03 +#define DMA_buff_out 0x04 +#define DMA_control 0x05 +#define DT_MEM_ALLOC 0x03 +#define DT_SET_DIC 0x04 +#define DT_START_TASK 0x05 +#define DT_LOAD_MEM 0x06 +#define DT_READ_MEM 0x07 +#define DT_DIGITAL_IN 0x08 +#define DMA_sync 0x06 +#define DMA_sync_char 0x07 + +#define DRV_VERSION "2.12" +#define PROCSPEECH 0x0b +#define SYNTH_IO_EXTENT 8 + +static int synth_probe(struct spk_synth *synth); +static void dtpc_release(void); +static const char *synth_immediate(struct spk_synth *synth, const char *buf); +static void do_catch_up(struct spk_synth *synth); +static void synth_flush(struct spk_synth *synth); + +static int synth_portlist[] = { 0x340, 0x350, 0x240, 0x250, 0 }; +static int in_escape, is_flushing; +static int dt_stat, dma_state; + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"[:dv ap 200]" } }, + { CAPS_STOP, .u.s = {"[:dv ap 100]" } }, + { RATE, .u.n = {"[:ra %d]", 9, 0, 18, 150, 25, NULL } }, + { PITCH, .u.n = {"[:dv ap %d]", 80, 0, 100, 20, 0, NULL } }, + { INFLECTION, .u.n = {"[:dv pr %d] ", 100, 0, 10000, 0, 0, NULL } }, + { VOL, .u.n = {"[:vo se %d]", 5, 0, 9, 5, 10, NULL } }, + { PUNCT, .u.n = {"[:pu %c]", 0, 0, 2, 0, 0, "nsa" } }, + { VOICE, .u.n = {"[:n%c]", 0, 0, 9, 0, 0, "phfdburwkv" } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* + * These attributes will appear in /sys/accessibility/speakup/decpc. + */ +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute inflection_attribute = + __ATTR(inflection, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute punct_attribute = + __ATTR(punct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute voice_attribute = + __ATTR(voice, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &pitch_attribute.attr, + &inflection_attribute.attr, + &punct_attribute.attr, + &rate_attribute.attr, + &voice_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_dec_pc = { + .name = "decpc", + .version = DRV_VERSION, + .long_name = "Dectalk PC", + .init = "[:pe -380]", + .procspeech = PROCSPEECH, + .delay = 500, + .trigger = 50, + .jiffies = 50, + .full = 1000, + .flags = SF_DEC, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = &spk_serial_io_ops, + .probe = synth_probe, + .release = dtpc_release, + .synth_immediate = synth_immediate, + .catch_up = do_catch_up, + .flush = synth_flush, + .is_alive = spk_synth_is_alive_nop, + .synth_adjust = NULL, + .read_buff_add = NULL, + .get_index = NULL, + .indexing = { + .command = NULL, + .lowindex = 0, + .highindex = 0, + .currindex = 0, + }, + .attributes = { + .attrs = synth_attrs, + .name = "decpc", + }, +}; + +static int dt_getstatus(void) +{ + dt_stat = inb_p(speakup_info.port_tts) | + (inb_p(speakup_info.port_tts + 1) << 8); + return dt_stat; +} + +static void dt_sendcmd(u_int cmd) +{ + outb_p(cmd & 0xFF, speakup_info.port_tts); + outb_p((cmd >> 8) & 0xFF, speakup_info.port_tts + 1); +} + +static int dt_waitbit(int bit) +{ + int timeout = 100; + + while (--timeout > 0) { + if ((dt_getstatus() & bit) == bit) + return 1; + udelay(50); + } + return 0; +} + +static int dt_wait_dma(void) +{ + int timeout = 100, state = dma_state; + + if (!dt_waitbit(STAT_dma_ready)) + return 0; + while (--timeout > 0) { + if ((dt_getstatus() & STAT_dma_state) == state) + return 1; + udelay(50); + } + dma_state = dt_getstatus() & STAT_dma_state; + return 1; +} + +static int dt_ctrl(u_int cmd) +{ + int timeout = 10; + + if (!dt_waitbit(STAT_cmd_ready)) + return -1; + outb_p(0, speakup_info.port_tts + 2); + outb_p(0, speakup_info.port_tts + 3); + dt_getstatus(); + dt_sendcmd(CMD_control | cmd); + outb_p(0, speakup_info.port_tts + 6); + while (dt_getstatus() & STAT_cmd_ready) { + udelay(20); + if (--timeout == 0) + break; + } + dt_sendcmd(CMD_null); + return 0; +} + +static void synth_flush(struct spk_synth *synth) +{ + int timeout = 10; + + if (is_flushing) + return; + is_flushing = 4; + in_escape = 0; + while (dt_ctrl(CTRL_flush)) { + if (--timeout == 0) + break; + udelay(50); + } + for (timeout = 0; timeout < 10; timeout++) { + if (dt_waitbit(STAT_dma_ready)) + break; + udelay(50); + } + outb_p(DMA_sync, speakup_info.port_tts + 4); + outb_p(0, speakup_info.port_tts + 4); + udelay(100); + for (timeout = 0; timeout < 10; timeout++) { + if (!(dt_getstatus() & STAT_flushing)) + break; + udelay(50); + } + dma_state = dt_getstatus() & STAT_dma_state; + dma_state ^= STAT_dma_state; + is_flushing = 0; +} + +static int dt_sendchar(char ch) +{ + if (!dt_wait_dma()) + return -1; + if (!(dt_stat & STAT_rr_char)) + return -2; + outb_p(DMA_single_in, speakup_info.port_tts + 4); + outb_p(ch, speakup_info.port_tts + 4); + dma_state ^= STAT_dma_state; + return 0; +} + +static int testkernel(void) +{ + int status = 0; + + if (dt_getstatus() == 0xffff) { + status = -1; + goto oops; + } + dt_sendcmd(CMD_sync); + if (!dt_waitbit(STAT_cmd_ready)) + status = -2; + else if (dt_stat & 0x8000) + return 0; + else if (dt_stat == 0x0dec) + pr_warn("dec_pc at 0x%x, software not loaded\n", + speakup_info.port_tts); + status = -3; +oops: synth_release_region(speakup_info.port_tts, SYNTH_IO_EXTENT); + speakup_info.port_tts = 0; + return status; +} + +static void do_catch_up(struct spk_synth *synth) +{ + u_char ch; + static u_char last; + unsigned long flags; + unsigned long jiff_max; + struct var_t *jiffy_delta; + struct var_t *delay_time; + int jiffy_delta_val; + int delay_time_val; + + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); + spin_lock_irqsave(&speakup_info.spinlock, flags); + jiffy_delta_val = jiffy_delta->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + jiff_max = jiffies + jiffy_delta_val; + + while (!kthread_should_stop()) { + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (speakup_info.flushing) { + speakup_info.flushing = 0; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + synth->flush(synth); + continue; + } + synth_buffer_skip_nonlatin1(); + if (synth_buffer_empty()) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + break; + } + ch = synth_buffer_peek(); + set_current_state(TASK_INTERRUPTIBLE); + delay_time_val = delay_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (ch == '\n') + ch = 0x0D; + if (dt_sendchar(ch)) { + schedule_timeout(msecs_to_jiffies(delay_time_val)); + continue; + } + set_current_state(TASK_RUNNING); + spin_lock_irqsave(&speakup_info.spinlock, flags); + synth_buffer_getc(); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (ch == '[') { + in_escape = 1; + } else if (ch == ']') { + in_escape = 0; + } else if (ch <= SPACE) { + if (!in_escape && strchr(",.!?;:", last)) + dt_sendchar(PROCSPEECH); + if (time_after_eq(jiffies, jiff_max)) { + if (!in_escape) + dt_sendchar(PROCSPEECH); + spin_lock_irqsave(&speakup_info.spinlock, + flags); + jiffy_delta_val = jiffy_delta->u.n.value; + delay_time_val = delay_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, + flags); + schedule_timeout(msecs_to_jiffies + (delay_time_val)); + jiff_max = jiffies + jiffy_delta_val; + } + } + last = ch; + ch = 0; + } + if (!in_escape) + dt_sendchar(PROCSPEECH); +} + +static const char *synth_immediate(struct spk_synth *synth, const char *buf) +{ + u_char ch; + + while ((ch = *buf)) { + if (ch == '\n') + ch = PROCSPEECH; + if (dt_sendchar(ch)) + return buf; + buf++; + } + return NULL; +} + +static int synth_probe(struct spk_synth *synth) +{ + int i = 0, failed = 0; + + pr_info("Probing for %s.\n", synth->long_name); + for (i = 0; synth_portlist[i]; i++) { + if (synth_request_region(synth_portlist[i], SYNTH_IO_EXTENT)) { + pr_warn("request_region: failed with 0x%x, %d\n", + synth_portlist[i], SYNTH_IO_EXTENT); + continue; + } + speakup_info.port_tts = synth_portlist[i]; + failed = testkernel(); + if (failed == 0) + break; + } + if (failed) { + pr_info("%s: not found\n", synth->long_name); + return -ENODEV; + } + pr_info("%s: %03x-%03x, Driver Version %s,\n", synth->long_name, + speakup_info.port_tts, speakup_info.port_tts + 7, + synth->version); + synth->alive = 1; + return 0; +} + +static void dtpc_release(void) +{ + spk_stop_serial_interrupt(); + if (speakup_info.port_tts) + synth_release_region(speakup_info.port_tts, SYNTH_IO_EXTENT); + speakup_info.port_tts = 0; +} + +module_param_named(start, synth_dec_pc.startup, short, 0444); + +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_dec_pc); + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_AUTHOR("David Borowski"); +MODULE_DESCRIPTION("Speakup support for DECtalk PC synthesizers"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); diff --git a/drivers/accessibility/speakup/speakup_dectlk.c b/drivers/accessibility/speakup/speakup_dectlk.c new file mode 100644 index 000000000000..780214b5ca16 --- /dev/null +++ b/drivers/accessibility/speakup/speakup_dectlk.c @@ -0,0 +1,311 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * originally written by: Kirk Reiser + * this version considerably modified by David Borowski, david575@rogers.com + * + * Copyright (C) 1998-99 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + * + * specificly written as a driver for the speakup screenreview + * s not a general device driver. + */ +#include +#include +#include +#include +#include +#include +#include +#include "speakup.h" +#include "spk_priv.h" + +#define DRV_VERSION "2.20" +#define SYNTH_CLEAR 0x03 +#define PROCSPEECH 0x0b +static int xoff; + +static inline int synth_full(void) +{ + return xoff; +} + +static void do_catch_up(struct spk_synth *synth); +static void synth_flush(struct spk_synth *synth); +static void read_buff_add(u_char c); +static unsigned char get_index(struct spk_synth *synth); + +static int in_escape; +static int is_flushing; + +static spinlock_t flush_lock; +static DECLARE_WAIT_QUEUE_HEAD(flush); + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"[:dv ap 160] " } }, + { CAPS_STOP, .u.s = {"[:dv ap 100 ] " } }, + { RATE, .u.n = {"[:ra %d] ", 180, 75, 650, 0, 0, NULL } }, + { INFLECTION, .u.n = {"[:dv pr %d] ", 100, 0, 10000, 0, 0, NULL } }, + { VOL, .u.n = {"[:dv g5 %d] ", 86, 60, 86, 0, 0, NULL } }, + { PUNCT, .u.n = {"[:pu %c] ", 0, 0, 2, 0, 0, "nsa" } }, + { VOICE, .u.n = {"[:n%c] ", 0, 0, 9, 0, 0, "phfdburwkv" } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* + * These attributes will appear in /sys/accessibility/speakup/dectlk. + */ +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute inflection_attribute = + __ATTR(inflection, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute punct_attribute = + __ATTR(punct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute voice_attribute = + __ATTR(voice, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &pitch_attribute.attr, + &inflection_attribute.attr, + &punct_attribute.attr, + &rate_attribute.attr, + &voice_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static int ap_defaults[] = {122, 89, 155, 110, 208, 240, 200, 106, 306}; +static int g5_defaults[] = {86, 81, 86, 84, 81, 80, 83, 83, 73}; + +static struct spk_synth synth_dectlk = { + .name = "dectlk", + .version = DRV_VERSION, + .long_name = "Dectalk Express", + .init = "[:error sp :name paul :rate 180 :tsr off] ", + .procspeech = PROCSPEECH, + .clear = SYNTH_CLEAR, + .delay = 500, + .trigger = 50, + .jiffies = 50, + .full = 40000, + .dev_name = SYNTH_DEFAULT_DEV, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .default_pitch = ap_defaults, + .default_vol = g5_defaults, + .io_ops = &spk_ttyio_ops, + .probe = spk_ttyio_synth_probe, + .release = spk_ttyio_release, + .synth_immediate = spk_ttyio_synth_immediate, + .catch_up = do_catch_up, + .flush = synth_flush, + .is_alive = spk_synth_is_alive_restart, + .synth_adjust = NULL, + .read_buff_add = read_buff_add, + .get_index = get_index, + .indexing = { + .command = "[:in re %d ] ", + .lowindex = 1, + .highindex = 8, + .currindex = 1, + }, + .attributes = { + .attrs = synth_attrs, + .name = "dectlk", + }, +}; + +static int is_indnum(u_char *ch) +{ + if ((*ch >= '0') && (*ch <= '9')) { + *ch = *ch - '0'; + return 1; + } + return 0; +} + +static u_char lastind; + +static unsigned char get_index(struct spk_synth *synth) +{ + u_char rv; + + rv = lastind; + lastind = 0; + return rv; +} + +static void read_buff_add(u_char c) +{ + static int ind = -1; + + if (c == 0x01) { + unsigned long flags; + + spin_lock_irqsave(&flush_lock, flags); + is_flushing = 0; + wake_up_interruptible(&flush); + spin_unlock_irqrestore(&flush_lock, flags); + } else if (c == 0x13) { + xoff = 1; + } else if (c == 0x11) { + xoff = 0; + } else if (is_indnum(&c)) { + if (ind == -1) + ind = c; + else + ind = ind * 10 + c; + } else if ((c > 31) && (c < 127)) { + if (ind != -1) + lastind = (u_char)ind; + ind = -1; + } +} + +static void do_catch_up(struct spk_synth *synth) +{ + int synth_full_val = 0; + static u_char ch; + static u_char last = '\0'; + unsigned long flags; + unsigned long jiff_max; + unsigned long timeout = msecs_to_jiffies(4000); + DEFINE_WAIT(wait); + struct var_t *jiffy_delta; + struct var_t *delay_time; + int jiffy_delta_val; + int delay_time_val; + + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); + spin_lock_irqsave(&speakup_info.spinlock, flags); + jiffy_delta_val = jiffy_delta->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + jiff_max = jiffies + jiffy_delta_val; + + while (!kthread_should_stop()) { + /* if no ctl-a in 4, send data anyway */ + spin_lock_irqsave(&flush_lock, flags); + while (is_flushing && timeout) { + prepare_to_wait(&flush, &wait, TASK_INTERRUPTIBLE); + spin_unlock_irqrestore(&flush_lock, flags); + timeout = schedule_timeout(timeout); + spin_lock_irqsave(&flush_lock, flags); + } + finish_wait(&flush, &wait); + is_flushing = 0; + spin_unlock_irqrestore(&flush_lock, flags); + + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (speakup_info.flushing) { + speakup_info.flushing = 0; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + synth->flush(synth); + continue; + } + synth_buffer_skip_nonlatin1(); + if (synth_buffer_empty()) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + break; + } + ch = synth_buffer_peek(); + set_current_state(TASK_INTERRUPTIBLE); + delay_time_val = delay_time->u.n.value; + synth_full_val = synth_full(); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (ch == '\n') + ch = 0x0D; + if (synth_full_val || !synth->io_ops->synth_out(synth, ch)) { + schedule_timeout(msecs_to_jiffies(delay_time_val)); + continue; + } + set_current_state(TASK_RUNNING); + spin_lock_irqsave(&speakup_info.spinlock, flags); + synth_buffer_getc(); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (ch == '[') { + in_escape = 1; + } else if (ch == ']') { + in_escape = 0; + } else if (ch <= SPACE) { + if (!in_escape && strchr(",.!?;:", last)) + synth->io_ops->synth_out(synth, PROCSPEECH); + if (time_after_eq(jiffies, jiff_max)) { + if (!in_escape) + synth->io_ops->synth_out(synth, + PROCSPEECH); + spin_lock_irqsave(&speakup_info.spinlock, + flags); + jiffy_delta_val = jiffy_delta->u.n.value; + delay_time_val = delay_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, + flags); + schedule_timeout(msecs_to_jiffies + (delay_time_val)); + jiff_max = jiffies + jiffy_delta_val; + } + } + last = ch; + } + if (!in_escape) + synth->io_ops->synth_out(synth, PROCSPEECH); +} + +static void synth_flush(struct spk_synth *synth) +{ + if (in_escape) + /* if in command output ']' so we don't get an error */ + synth->io_ops->synth_out(synth, ']'); + in_escape = 0; + is_flushing = 1; + synth->io_ops->flush_buffer(); + synth->io_ops->synth_out(synth, SYNTH_CLEAR); +} + +module_param_named(ser, synth_dectlk.ser, int, 0444); +module_param_named(dev, synth_dectlk.dev_name, charp, 0444); +module_param_named(start, synth_dectlk.startup, short, 0444); + +MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); +MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_dectlk); + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_AUTHOR("David Borowski"); +MODULE_DESCRIPTION("Speakup support for DECtalk Express synthesizers"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/drivers/accessibility/speakup/speakup_dtlk.c b/drivers/accessibility/speakup/speakup_dtlk.c new file mode 100644 index 000000000000..dbebed0eeeec --- /dev/null +++ b/drivers/accessibility/speakup/speakup_dtlk.c @@ -0,0 +1,390 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * originally written by: Kirk Reiser + * this version considerably modified by David Borowski, david575@rogers.com + * + * Copyright (C) 1998-99 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + * + * specificly written as a driver for the speakup screenreview + * package it's not a general device driver. + * This driver is for the RC Systems DoubleTalk PC internal synthesizer. + */ +#include +#include +#include +#include + +#include "spk_priv.h" +#include "serialio.h" +#include "speakup_dtlk.h" /* local header file for DoubleTalk values */ +#include "speakup.h" + +#define DRV_VERSION "2.10" +#define PROCSPEECH 0x00 + +static int synth_probe(struct spk_synth *synth); +static void dtlk_release(void); +static const char *synth_immediate(struct spk_synth *synth, const char *buf); +static void do_catch_up(struct spk_synth *synth); +static void synth_flush(struct spk_synth *synth); + +static int synth_lpc; +static int port_forced; +static unsigned int synth_portlist[] = { + 0x25e, 0x29e, 0x2de, 0x31e, 0x35e, 0x39e, 0 +}; + +static u_char synth_status; + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"\x01+35p" } }, + { CAPS_STOP, .u.s = {"\x01-35p" } }, + { RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL } }, + { PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL } }, + { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } }, + { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } }, + { PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL } }, + { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } }, + { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* + * These attributes will appear in /sys/accessibility/speakup/dtlk. + */ +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute freq_attribute = + __ATTR(freq, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute punct_attribute = + __ATTR(punct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute tone_attribute = + __ATTR(tone, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute voice_attribute = + __ATTR(voice, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &freq_attribute.attr, + &pitch_attribute.attr, + &punct_attribute.attr, + &rate_attribute.attr, + &tone_attribute.attr, + &voice_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_dtlk = { + .name = "dtlk", + .version = DRV_VERSION, + .long_name = "DoubleTalk PC", + .init = "\x01@\x01\x31y", + .procspeech = PROCSPEECH, + .clear = SYNTH_CLEAR, + .delay = 500, + .trigger = 30, + .jiffies = 50, + .full = 1000, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = &spk_serial_io_ops, + .probe = synth_probe, + .release = dtlk_release, + .synth_immediate = synth_immediate, + .catch_up = do_catch_up, + .flush = synth_flush, + .is_alive = spk_synth_is_alive_nop, + .synth_adjust = NULL, + .read_buff_add = NULL, + .get_index = spk_synth_get_index, + .indexing = { + .command = "\x01%di", + .lowindex = 1, + .highindex = 5, + .currindex = 1, + }, + .attributes = { + .attrs = synth_attrs, + .name = "dtlk", + }, +}; + +static inline bool synth_readable(void) +{ + synth_status = inb_p(speakup_info.port_tts + UART_RX); + return (synth_status & TTS_READABLE) != 0; +} + +static inline bool synth_writable(void) +{ + synth_status = inb_p(speakup_info.port_tts + UART_RX); + return (synth_status & TTS_WRITABLE) != 0; +} + +static inline bool synth_full(void) +{ + synth_status = inb_p(speakup_info.port_tts + UART_RX); + return (synth_status & TTS_ALMOST_FULL) != 0; +} + +static void spk_out(const char ch) +{ + int timeout = SPK_XMITR_TIMEOUT; + + while (!synth_writable()) { + if (!--timeout) + break; + udelay(1); + } + outb_p(ch, speakup_info.port_tts); + timeout = SPK_XMITR_TIMEOUT; + while (synth_writable()) { + if (!--timeout) + break; + udelay(1); + } +} + +static void do_catch_up(struct spk_synth *synth) +{ + u_char ch; + unsigned long flags; + unsigned long jiff_max; + struct var_t *jiffy_delta; + struct var_t *delay_time; + int jiffy_delta_val; + int delay_time_val; + + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); + spin_lock_irqsave(&speakup_info.spinlock, flags); + jiffy_delta_val = jiffy_delta->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + jiff_max = jiffies + jiffy_delta_val; + while (!kthread_should_stop()) { + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (speakup_info.flushing) { + speakup_info.flushing = 0; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + synth->flush(synth); + continue; + } + synth_buffer_skip_nonlatin1(); + if (synth_buffer_empty()) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + break; + } + set_current_state(TASK_INTERRUPTIBLE); + delay_time_val = delay_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (synth_full()) { + schedule_timeout(msecs_to_jiffies(delay_time_val)); + continue; + } + set_current_state(TASK_RUNNING); + spin_lock_irqsave(&speakup_info.spinlock, flags); + ch = synth_buffer_getc(); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (ch == '\n') + ch = PROCSPEECH; + spk_out(ch); + if (time_after_eq(jiffies, jiff_max) && (ch == SPACE)) { + spk_out(PROCSPEECH); + spin_lock_irqsave(&speakup_info.spinlock, flags); + delay_time_val = delay_time->u.n.value; + jiffy_delta_val = jiffy_delta->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + schedule_timeout(msecs_to_jiffies(delay_time_val)); + jiff_max = jiffies + jiffy_delta_val; + } + } + spk_out(PROCSPEECH); +} + +static const char *synth_immediate(struct spk_synth *synth, const char *buf) +{ + u_char ch; + + while ((ch = (u_char)*buf)) { + if (synth_full()) + return buf; + if (ch == '\n') + ch = PROCSPEECH; + spk_out(ch); + buf++; + } + return NULL; +} + +static void synth_flush(struct spk_synth *synth) +{ + outb_p(SYNTH_CLEAR, speakup_info.port_tts); + while (synth_writable()) + cpu_relax(); +} + +static char synth_read_tts(void) +{ + u_char ch; + + while (!synth_readable()) + cpu_relax(); + ch = synth_status & 0x7f; + outb_p(ch, speakup_info.port_tts); + while (synth_readable()) + cpu_relax(); + return (char)ch; +} + +/* interrogate the DoubleTalk PC and return its settings */ +static struct synth_settings *synth_interrogate(struct spk_synth *synth) +{ + u_char *t; + static char buf[sizeof(struct synth_settings) + 1]; + int total, i; + static struct synth_settings status; + + synth_immediate(synth, "\x18\x01?"); + for (total = 0, i = 0; i < 50; i++) { + buf[total] = synth_read_tts(); + if (total > 2 && buf[total] == 0x7f) + break; + if (total < sizeof(struct synth_settings)) + total++; + } + t = buf; + /* serial number is little endian */ + status.serial_number = t[0] + t[1] * 256; + t += 2; + for (i = 0; *t != '\r'; t++) { + status.rom_version[i] = *t; + if (i < sizeof(status.rom_version) - 1) + i++; + } + status.rom_version[i] = 0; + t++; + status.mode = *t++; + status.punc_level = *t++; + status.formant_freq = *t++; + status.pitch = *t++; + status.speed = *t++; + status.volume = *t++; + status.tone = *t++; + status.expression = *t++; + status.ext_dict_loaded = *t++; + status.ext_dict_status = *t++; + status.free_ram = *t++; + status.articulation = *t++; + status.reverb = *t++; + status.eob = *t++; + return &status; +} + +static int synth_probe(struct spk_synth *synth) +{ + unsigned int port_val = 0; + int i = 0; + struct synth_settings *sp; + + pr_info("Probing for DoubleTalk.\n"); + if (port_forced) { + speakup_info.port_tts = port_forced; + pr_info("probe forced to %x by kernel command line\n", + speakup_info.port_tts); + if ((port_forced & 0xf) != 0xf) + pr_info("warning: port base should probably end with f\n"); + if (synth_request_region(speakup_info.port_tts - 1, + SYNTH_IO_EXTENT)) { + pr_warn("sorry, port already reserved\n"); + return -EBUSY; + } + port_val = inw(speakup_info.port_tts - 1); + synth_lpc = speakup_info.port_tts - 1; + } else { + for (i = 0; synth_portlist[i]; i++) { + if (synth_request_region(synth_portlist[i], + SYNTH_IO_EXTENT)) + continue; + port_val = inw(synth_portlist[i]) & 0xfbff; + if (port_val == 0x107f) { + synth_lpc = synth_portlist[i]; + speakup_info.port_tts = synth_lpc + 1; + break; + } + synth_release_region(synth_portlist[i], + SYNTH_IO_EXTENT); + } + } + port_val &= 0xfbff; + if (port_val != 0x107f) { + pr_info("DoubleTalk PC: not found\n"); + if (synth_lpc) + synth_release_region(synth_lpc, SYNTH_IO_EXTENT); + return -ENODEV; + } + while (inw_p(synth_lpc) != 0x147f) + cpu_relax(); /* wait until it's ready */ + sp = synth_interrogate(synth); + pr_info("%s: %03x-%03x, ROM ver %s, s/n %u, driver: %s\n", + synth->long_name, synth_lpc, synth_lpc + SYNTH_IO_EXTENT - 1, + sp->rom_version, sp->serial_number, synth->version); + synth->alive = 1; + return 0; +} + +static void dtlk_release(void) +{ + spk_stop_serial_interrupt(); + if (speakup_info.port_tts) + synth_release_region(speakup_info.port_tts - 1, + SYNTH_IO_EXTENT); + speakup_info.port_tts = 0; +} + +module_param_hw_named(port, port_forced, int, ioport, 0444); +module_param_named(start, synth_dtlk.startup, short, 0444); + +MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing)."); +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_dtlk); + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_AUTHOR("David Borowski"); +MODULE_DESCRIPTION("Speakup support for DoubleTalk PC synthesizers"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/drivers/accessibility/speakup/speakup_dtlk.h b/drivers/accessibility/speakup/speakup_dtlk.h new file mode 100644 index 000000000000..9c378b58066e --- /dev/null +++ b/drivers/accessibility/speakup/speakup_dtlk.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* speakup_dtlk.h - header file for speakups DoubleTalk driver. */ + +#define SYNTH_IO_EXTENT 0x02 +#define SYNTH_CLEAR 0x18 /* stops speech */ + /* TTS Port Status Flags */ +#define TTS_READABLE 0x80 /* mask for bit which is nonzero if a + * byte can be read from the TTS port + */ +#define TTS_SPEAKING 0x40 /* mask for SYNC bit, which is nonzero + * while DoubleTalk is producing + * output with TTS, PCM or CVSD + * synthesizers or tone generators + * (that is, all but LPC) + */ +#define TTS_SPEAKING2 0x20 /* mask for SYNC2 bit, + * which falls to zero up to 0.4 sec + * before speech stops + */ +#define TTS_WRITABLE 0x10 /* mask for RDY bit, which when set to + * 1, indicates the TTS port is ready + * to accept a byte of data. The RDY + * bit goes zero 2-3 usec after + * writing, and goes 1 again 180-190 + * usec later. + */ +#define TTS_ALMOST_FULL 0x08 /* mask for AF bit: When set to 1, + * indicates that less than 300 bytes + * are available in the TTS input + * buffer. AF is always 0 in the PCM, + * TGN and CVSD modes. + */ +#define TTS_ALMOST_EMPTY 0x04 /* mask for AE bit: When set to 1, + * indicates that less than 300 bytes + * are remaining in DoubleTalk's input + * (TTS or PCM) buffer. AE is always 1 + * in the TGN and CVSD modes. + */ + + /* data returned by Interrogate command */ +struct synth_settings { + u_short serial_number; /* 0-7Fh:0-7Fh */ + u_char rom_version[24]; /* null terminated string */ + u_char mode; /* 0=Character; 1=Phoneme; 2=Text */ + u_char punc_level; /* nB; 0-7 */ + u_char formant_freq; /* nF; 0-9 */ + u_char pitch; /* nP; 0-99 */ + u_char speed; /* nS; 0-9 */ + u_char volume; /* nV; 0-9 */ + u_char tone; /* nX; 0-2 */ + u_char expression; /* nE; 0-9 */ + u_char ext_dict_loaded; /* 1=exception dictionary loaded */ + u_char ext_dict_status; /* 1=exception dictionary enabled */ + u_char free_ram; /* # pages (truncated) remaining for + * text buffer + */ + u_char articulation; /* nA; 0-9 */ + u_char reverb; /* nR; 0-9 */ + u_char eob; /* 7Fh value indicating end of + * parameter block + */ + u_char has_indexing; /* nonzero if indexing is implemented */ +}; diff --git a/drivers/accessibility/speakup/speakup_dummy.c b/drivers/accessibility/speakup/speakup_dummy.c new file mode 100644 index 000000000000..e393438af81b --- /dev/null +++ b/drivers/accessibility/speakup/speakup_dummy.c @@ -0,0 +1,134 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * originally written by: Kirk Reiser + * this version considerably modified by David Borowski, david575@rogers.com + * eventually modified by Samuel Thibault + * + * Copyright (C) 1998-99 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + * Copyright (C) 2007 Samuel Thibault. + * + * specificly written as a driver for the speakup screenreview + * s not a general device driver. + */ +#include "spk_priv.h" +#include "speakup.h" + +#define PROCSPEECH '\n' +#define DRV_VERSION "2.11" +#define SYNTH_CLEAR '!' + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"CAPS_START\n" } }, + { CAPS_STOP, .u.s = {"CAPS_STOP\n" } }, + { PAUSE, .u.s = {"PAUSE\n"} }, + { RATE, .u.n = {"RATE %d\n", 8, 1, 16, 0, 0, NULL } }, + { PITCH, .u.n = {"PITCH %d\n", 8, 0, 16, 0, 0, NULL } }, + { INFLECTION, .u.n = {"INFLECTION %d\n", 8, 0, 16, 0, 0, NULL } }, + { VOL, .u.n = {"VOL %d\n", 8, 0, 16, 0, 0, NULL } }, + { TONE, .u.n = {"TONE %d\n", 8, 0, 16, 0, 0, NULL } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* + * These attributes will appear in /sys/accessibility/speakup/dummy. + */ +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute inflection_attribute = + __ATTR(inflection, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute tone_attribute = + __ATTR(tone, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &pitch_attribute.attr, + &inflection_attribute.attr, + &rate_attribute.attr, + &tone_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_dummy = { + .name = "dummy", + .version = DRV_VERSION, + .long_name = "Dummy", + .init = "Speakup\n", + .procspeech = PROCSPEECH, + .clear = SYNTH_CLEAR, + .delay = 500, + .trigger = 50, + .jiffies = 50, + .full = 40000, + .dev_name = SYNTH_DEFAULT_DEV, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = &spk_ttyio_ops, + .probe = spk_ttyio_synth_probe, + .release = spk_ttyio_release, + .synth_immediate = spk_ttyio_synth_immediate, + .catch_up = spk_do_catch_up_unicode, + .flush = spk_synth_flush, + .is_alive = spk_synth_is_alive_restart, + .synth_adjust = NULL, + .read_buff_add = NULL, + .get_index = NULL, + .indexing = { + .command = NULL, + .lowindex = 0, + .highindex = 0, + .currindex = 0, + }, + .attributes = { + .attrs = synth_attrs, + .name = "dummy", + }, +}; + +module_param_named(ser, synth_dummy.ser, int, 0444); +module_param_named(dev, synth_dummy.dev_name, charp, 0444); +module_param_named(start, synth_dummy.startup, short, 0444); + +MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); +MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_dummy); + +MODULE_AUTHOR("Samuel Thibault "); +MODULE_DESCRIPTION("Speakup support for text console"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/drivers/accessibility/speakup/speakup_keypc.c b/drivers/accessibility/speakup/speakup_keypc.c new file mode 100644 index 000000000000..414827e888fc --- /dev/null +++ b/drivers/accessibility/speakup/speakup_keypc.c @@ -0,0 +1,318 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * written by David Borowski + * + * Copyright (C) 2003 David Borowski. + * + * specificly written as a driver for the speakup screenreview + * package it's not a general device driver. + * This driver is for the Keynote Gold internal synthesizer. + */ +#include +#include +#include +#include +#include + +#include "spk_priv.h" +#include "speakup.h" + +#define DRV_VERSION "2.10" +#define SYNTH_IO_EXTENT 0x04 +#define SWAIT udelay(70) +#define PROCSPEECH 0x1f +#define SYNTH_CLEAR 0x03 + +static int synth_probe(struct spk_synth *synth); +static void keynote_release(void); +static const char *synth_immediate(struct spk_synth *synth, const char *buf); +static void do_catch_up(struct spk_synth *synth); +static void synth_flush(struct spk_synth *synth); + +static int synth_port; +static int port_forced; +static unsigned int synth_portlist[] = { 0x2a8, 0 }; + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"[f130]" } }, + { CAPS_STOP, .u.s = {"[f90]" } }, + { RATE, .u.n = {"\04%c ", 8, 0, 10, 81, -8, NULL } }, + { PITCH, .u.n = {"[f%d]", 5, 0, 9, 40, 10, NULL } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* + * These attributes will appear in /sys/accessibility/speakup/keypc. + */ +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &pitch_attribute.attr, + &rate_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_keypc = { + .name = "keypc", + .version = DRV_VERSION, + .long_name = "Keynote PC", + .init = "[t][n7,1][n8,0]", + .procspeech = PROCSPEECH, + .clear = SYNTH_CLEAR, + .delay = 500, + .trigger = 50, + .jiffies = 50, + .full = 1000, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = &spk_serial_io_ops, + .probe = synth_probe, + .release = keynote_release, + .synth_immediate = synth_immediate, + .catch_up = do_catch_up, + .flush = synth_flush, + .is_alive = spk_synth_is_alive_nop, + .synth_adjust = NULL, + .read_buff_add = NULL, + .get_index = NULL, + .indexing = { + .command = NULL, + .lowindex = 0, + .highindex = 0, + .currindex = 0, + }, + .attributes = { + .attrs = synth_attrs, + .name = "keypc", + }, +}; + +static inline bool synth_writable(void) +{ + return (inb_p(synth_port + UART_RX) & 0x10) != 0; +} + +static inline bool synth_full(void) +{ + return (inb_p(synth_port + UART_RX) & 0x80) == 0; +} + +static char *oops(void) +{ + int s1, s2, s3, s4; + + s1 = inb_p(synth_port); + s2 = inb_p(synth_port + 1); + s3 = inb_p(synth_port + 2); + s4 = inb_p(synth_port + 3); + pr_warn("synth timeout %d %d %d %d\n", s1, s2, s3, s4); + return NULL; +} + +static const char *synth_immediate(struct spk_synth *synth, const char *buf) +{ + u_char ch; + int timeout; + + while ((ch = *buf)) { + if (ch == '\n') + ch = PROCSPEECH; + if (synth_full()) + return buf; + timeout = 1000; + while (synth_writable()) + if (--timeout <= 0) + return oops(); + outb_p(ch, synth_port); + udelay(70); + buf++; + } + return NULL; +} + +static void do_catch_up(struct spk_synth *synth) +{ + u_char ch; + int timeout; + unsigned long flags; + unsigned long jiff_max; + struct var_t *jiffy_delta; + struct var_t *delay_time; + struct var_t *full_time; + int delay_time_val; + int full_time_val; + int jiffy_delta_val; + + jiffy_delta = spk_get_var(JIFFY); + delay_time = spk_get_var(DELAY); + full_time = spk_get_var(FULL); + spin_lock_irqsave(&speakup_info.spinlock, flags); + jiffy_delta_val = jiffy_delta->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + + jiff_max = jiffies + jiffy_delta_val; + while (!kthread_should_stop()) { + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (speakup_info.flushing) { + speakup_info.flushing = 0; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + synth->flush(synth); + continue; + } + synth_buffer_skip_nonlatin1(); + if (synth_buffer_empty()) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + break; + } + set_current_state(TASK_INTERRUPTIBLE); + full_time_val = full_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (synth_full()) { + schedule_timeout(msecs_to_jiffies(full_time_val)); + continue; + } + set_current_state(TASK_RUNNING); + timeout = 1000; + while (synth_writable()) + if (--timeout <= 0) + break; + if (timeout <= 0) { + oops(); + break; + } + spin_lock_irqsave(&speakup_info.spinlock, flags); + ch = synth_buffer_getc(); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (ch == '\n') + ch = PROCSPEECH; + outb_p(ch, synth_port); + SWAIT; + if (time_after_eq(jiffies, jiff_max) && (ch == SPACE)) { + timeout = 1000; + while (synth_writable()) + if (--timeout <= 0) + break; + if (timeout <= 0) { + oops(); + break; + } + outb_p(PROCSPEECH, synth_port); + spin_lock_irqsave(&speakup_info.spinlock, flags); + jiffy_delta_val = jiffy_delta->u.n.value; + delay_time_val = delay_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + schedule_timeout(msecs_to_jiffies(delay_time_val)); + jiff_max = jiffies + jiffy_delta_val; + } + } + timeout = 1000; + while (synth_writable()) + if (--timeout <= 0) + break; + if (timeout <= 0) + oops(); + else + outb_p(PROCSPEECH, synth_port); +} + +static void synth_flush(struct spk_synth *synth) +{ + outb_p(SYNTH_CLEAR, synth_port); +} + +static int synth_probe(struct spk_synth *synth) +{ + unsigned int port_val = 0; + int i = 0; + + pr_info("Probing for %s.\n", synth->long_name); + if (port_forced) { + synth_port = port_forced; + pr_info("probe forced to %x by kernel command line\n", + synth_port); + if (synth_request_region(synth_port - 1, SYNTH_IO_EXTENT)) { + pr_warn("sorry, port already reserved\n"); + return -EBUSY; + } + port_val = inb(synth_port); + } else { + for (i = 0; synth_portlist[i]; i++) { + if (synth_request_region(synth_portlist[i], + SYNTH_IO_EXTENT)) { + pr_warn + ("request_region: failed with 0x%x, %d\n", + synth_portlist[i], SYNTH_IO_EXTENT); + continue; + } + port_val = inb(synth_portlist[i]); + if (port_val == 0x80) { + synth_port = synth_portlist[i]; + break; + } + } + } + if (port_val != 0x80) { + pr_info("%s: not found\n", synth->long_name); + synth_release_region(synth_port, SYNTH_IO_EXTENT); + synth_port = 0; + return -ENODEV; + } + pr_info("%s: %03x-%03x, driver version %s,\n", synth->long_name, + synth_port, synth_port + SYNTH_IO_EXTENT - 1, + synth->version); + synth->alive = 1; + return 0; +} + +static void keynote_release(void) +{ + spk_stop_serial_interrupt(); + if (synth_port) + synth_release_region(synth_port, SYNTH_IO_EXTENT); + synth_port = 0; +} + +module_param_hw_named(port, port_forced, int, ioport, 0444); +module_param_named(start, synth_keypc.startup, short, 0444); + +MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing)."); +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_keypc); + +MODULE_AUTHOR("David Borowski"); +MODULE_DESCRIPTION("Speakup support for Keynote Gold PC synthesizers"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/drivers/accessibility/speakup/speakup_ltlk.c b/drivers/accessibility/speakup/speakup_ltlk.c new file mode 100644 index 000000000000..3c59519a871f --- /dev/null +++ b/drivers/accessibility/speakup/speakup_ltlk.c @@ -0,0 +1,175 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * originally written by: Kirk Reiser + * this version considerably modified by David Borowski, david575@rogers.com + * + * Copyright (C) 1998-99 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + * + * specificly written as a driver for the speakup screenreview + * s not a general device driver. + */ +#include "speakup.h" +#include "spk_priv.h" +#include "speakup_dtlk.h" /* local header file for LiteTalk values */ + +#define DRV_VERSION "2.11" +#define PROCSPEECH 0x0d + +static int synth_probe(struct spk_synth *synth); + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"\x01+35p" } }, + { CAPS_STOP, .u.s = {"\x01-35p" } }, + { RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL } }, + { PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL } }, + { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } }, + { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } }, + { PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL } }, + { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } }, + { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* + * These attributes will appear in /sys/accessibility/speakup/ltlk. + */ +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute freq_attribute = + __ATTR(freq, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute punct_attribute = + __ATTR(punct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute tone_attribute = + __ATTR(tone, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute voice_attribute = + __ATTR(voice, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &freq_attribute.attr, + &pitch_attribute.attr, + &punct_attribute.attr, + &rate_attribute.attr, + &tone_attribute.attr, + &voice_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_ltlk = { + .name = "ltlk", + .version = DRV_VERSION, + .long_name = "LiteTalk", + .init = "\01@\x01\x31y\n\0", + .procspeech = PROCSPEECH, + .clear = SYNTH_CLEAR, + .delay = 500, + .trigger = 50, + .jiffies = 50, + .full = 40000, + .dev_name = SYNTH_DEFAULT_DEV, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = &spk_ttyio_ops, + .probe = synth_probe, + .release = spk_ttyio_release, + .synth_immediate = spk_ttyio_synth_immediate, + .catch_up = spk_do_catch_up, + .flush = spk_synth_flush, + .is_alive = spk_synth_is_alive_restart, + .synth_adjust = NULL, + .read_buff_add = NULL, + .get_index = spk_synth_get_index, + .indexing = { + .command = "\x01%di", + .lowindex = 1, + .highindex = 5, + .currindex = 1, + }, + .attributes = { + .attrs = synth_attrs, + .name = "ltlk", + }, +}; + +/* interrogate the LiteTalk and print its settings */ +static void synth_interrogate(struct spk_synth *synth) +{ + unsigned char *t, i; + unsigned char buf[50], rom_v[20]; + + synth->synth_immediate(synth, "\x18\x01?"); + for (i = 0; i < 50; i++) { + buf[i] = synth->io_ops->synth_in(); + if (i > 2 && buf[i] == 0x7f) + break; + } + t = buf + 2; + for (i = 0; *t != '\r'; t++) { + rom_v[i] = *t; + if (++i >= 19) + break; + } + rom_v[i] = 0; + pr_info("%s: ROM version: %s\n", synth->long_name, rom_v); +} + +static int synth_probe(struct spk_synth *synth) +{ + int failed = 0; + + failed = spk_ttyio_synth_probe(synth); + if (failed == 0) + synth_interrogate(synth); + synth->alive = !failed; + return failed; +} + +module_param_named(ser, synth_ltlk.ser, int, 0444); +module_param_named(dev, synth_ltlk.dev_name, charp, 0444); +module_param_named(start, synth_ltlk.startup, short, 0444); + +MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); +MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_ltlk); + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_AUTHOR("David Borowski"); +MODULE_DESCRIPTION("Speakup support for DoubleTalk LT/LiteTalk synthesizers"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/drivers/accessibility/speakup/speakup_soft.c b/drivers/accessibility/speakup/speakup_soft.c new file mode 100644 index 000000000000..9a7029539f35 --- /dev/null +++ b/drivers/accessibility/speakup/speakup_soft.c @@ -0,0 +1,430 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* speakup_soft.c - speakup driver to register and make available + * a user space device for software synthesizers. written by: Kirk + * Reiser + * + * Copyright (C) 2003 Kirk Reiser. + * + * this code is specificly written as a driver for the speakup screenreview + * package and is not a general device driver. + */ + +#include +#include /* for misc_register, and MISC_DYNAMIC_MINOR */ +#include /* for poll_wait() */ + +/* schedule(), signal_pending(), TASK_INTERRUPTIBLE */ +#include + +#include "spk_priv.h" +#include "speakup.h" + +#define DRV_VERSION "2.6" +#define PROCSPEECH 0x0d +#define CLEAR_SYNTH 0x18 + +static int softsynth_probe(struct spk_synth *synth); +static void softsynth_release(void); +static int softsynth_is_alive(struct spk_synth *synth); +static unsigned char get_index(struct spk_synth *synth); + +static struct miscdevice synth_device, synthu_device; +static int init_pos; +static int misc_registered; + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"\x01+3p" } }, + { CAPS_STOP, .u.s = {"\x01-3p" } }, + { PAUSE, .u.n = {"\x01P" } }, + { RATE, .u.n = {"\x01%ds", 2, 0, 9, 0, 0, NULL } }, + { PITCH, .u.n = {"\x01%dp", 5, 0, 9, 0, 0, NULL } }, + { INFLECTION, .u.n = {"\x01%dr", 5, 0, 9, 0, 0, NULL } }, + { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } }, + { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } }, + { PUNCT, .u.n = {"\x01%db", 0, 0, 2, 0, 0, NULL } }, + { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } }, + { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* These attributes will appear in /sys/accessibility/speakup/soft. */ + +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute freq_attribute = + __ATTR(freq, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute inflection_attribute = + __ATTR(inflection, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute punct_attribute = + __ATTR(punct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute tone_attribute = + __ATTR(tone, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute voice_attribute = + __ATTR(voice, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +/* + * We should uncomment the following definition, when we agree on a + * method of passing a language designation to the software synthesizer. + * static struct kobj_attribute lang_attribute = + * __ATTR(lang, 0644, spk_var_show, spk_var_store); + */ + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &freq_attribute.attr, +/* &lang_attribute.attr, */ + &pitch_attribute.attr, + &inflection_attribute.attr, + &punct_attribute.attr, + &rate_attribute.attr, + &tone_attribute.attr, + &voice_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_soft = { + .name = "soft", + .version = DRV_VERSION, + .long_name = "software synth", + .init = "\01@\x01\x31y\n", + .procspeech = PROCSPEECH, + .delay = 0, + .trigger = 0, + .jiffies = 0, + .full = 0, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = NULL, + .probe = softsynth_probe, + .release = softsynth_release, + .synth_immediate = NULL, + .catch_up = NULL, + .flush = NULL, + .is_alive = softsynth_is_alive, + .synth_adjust = NULL, + .read_buff_add = NULL, + .get_index = get_index, + .indexing = { + .command = "\x01%di", + .lowindex = 1, + .highindex = 5, + .currindex = 1, + }, + .attributes = { + .attrs = synth_attrs, + .name = "soft", + }, +}; + +static char *get_initstring(void) +{ + static char buf[40]; + char *cp; + struct var_t *var; + + memset(buf, 0, sizeof(buf)); + cp = buf; + var = synth_soft.vars; + while (var->var_id != MAXVARS) { + if (var->var_id != CAPS_START && var->var_id != CAPS_STOP && + var->var_id != PAUSE && var->var_id != DIRECT) + cp = cp + sprintf(cp, var->u.n.synth_fmt, + var->u.n.value); + var++; + } + cp = cp + sprintf(cp, "\n"); + return buf; +} + +static int softsynth_open(struct inode *inode, struct file *fp) +{ + unsigned long flags; + /*if ((fp->f_flags & O_ACCMODE) != O_RDONLY) */ + /* return -EPERM; */ + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (synth_soft.alive) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return -EBUSY; + } + synth_soft.alive = 1; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return 0; +} + +static int softsynth_close(struct inode *inode, struct file *fp) +{ + unsigned long flags; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + synth_soft.alive = 0; + init_pos = 0; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + /* Make sure we let applications go before leaving */ + speakup_start_ttys(); + return 0; +} + +static ssize_t softsynthx_read(struct file *fp, char __user *buf, size_t count, + loff_t *pos, int unicode) +{ + int chars_sent = 0; + char __user *cp; + char *init; + size_t bytes_per_ch = unicode ? 3 : 1; + u16 ch; + int empty; + unsigned long flags; + DEFINE_WAIT(wait); + + if (count < bytes_per_ch) + return -EINVAL; + + spin_lock_irqsave(&speakup_info.spinlock, flags); + synth_soft.alive = 1; + while (1) { + prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE); + if (synth_current() == &synth_soft) { + if (!unicode) + synth_buffer_skip_nonlatin1(); + if (!synth_buffer_empty() || speakup_info.flushing) + break; + } + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (fp->f_flags & O_NONBLOCK) { + finish_wait(&speakup_event, &wait); + return -EAGAIN; + } + if (signal_pending(current)) { + finish_wait(&speakup_event, &wait); + return -ERESTARTSYS; + } + schedule(); + spin_lock_irqsave(&speakup_info.spinlock, flags); + } + finish_wait(&speakup_event, &wait); + + cp = buf; + init = get_initstring(); + + /* Keep 3 bytes available for a 16bit UTF-8-encoded character */ + while (chars_sent <= count - bytes_per_ch) { + if (synth_current() != &synth_soft) + break; + if (speakup_info.flushing) { + speakup_info.flushing = 0; + ch = '\x18'; + } else if (init[init_pos]) { + ch = init[init_pos++]; + } else { + if (!unicode) + synth_buffer_skip_nonlatin1(); + if (synth_buffer_empty()) + break; + ch = synth_buffer_getc(); + } + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + + if ((!unicode && ch < 0x100) || (unicode && ch < 0x80)) { + u_char c = ch; + + if (copy_to_user(cp, &c, 1)) + return -EFAULT; + + chars_sent++; + cp++; + } else if (unicode && ch < 0x800) { + u_char s[2] = { + 0xc0 | (ch >> 6), + 0x80 | (ch & 0x3f) + }; + + if (copy_to_user(cp, s, sizeof(s))) + return -EFAULT; + + chars_sent += sizeof(s); + cp += sizeof(s); + } else if (unicode) { + u_char s[3] = { + 0xe0 | (ch >> 12), + 0x80 | ((ch >> 6) & 0x3f), + 0x80 | (ch & 0x3f) + }; + + if (copy_to_user(cp, s, sizeof(s))) + return -EFAULT; + + chars_sent += sizeof(s); + cp += sizeof(s); + } + + spin_lock_irqsave(&speakup_info.spinlock, flags); + } + *pos += chars_sent; + empty = synth_buffer_empty(); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (empty) { + speakup_start_ttys(); + *pos = 0; + } + return chars_sent; +} + +static ssize_t softsynth_read(struct file *fp, char __user *buf, size_t count, + loff_t *pos) +{ + return softsynthx_read(fp, buf, count, pos, 0); +} + +static ssize_t softsynthu_read(struct file *fp, char __user *buf, size_t count, + loff_t *pos) +{ + return softsynthx_read(fp, buf, count, pos, 1); +} + +static int last_index; + +static ssize_t softsynth_write(struct file *fp, const char __user *buf, + size_t count, loff_t *pos) +{ + unsigned long supplied_index = 0; + int converted; + + converted = kstrtoul_from_user(buf, count, 0, &supplied_index); + + if (converted < 0) + return converted; + + last_index = supplied_index; + return count; +} + +static __poll_t softsynth_poll(struct file *fp, struct poll_table_struct *wait) +{ + unsigned long flags; + __poll_t ret = 0; + + poll_wait(fp, &speakup_event, wait); + + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (synth_current() == &synth_soft && + (!synth_buffer_empty() || speakup_info.flushing)) + ret = EPOLLIN | EPOLLRDNORM; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + return ret; +} + +static unsigned char get_index(struct spk_synth *synth) +{ + int rv; + + rv = last_index; + last_index = 0; + return rv; +} + +static const struct file_operations softsynth_fops = { + .owner = THIS_MODULE, + .poll = softsynth_poll, + .read = softsynth_read, + .write = softsynth_write, + .open = softsynth_open, + .release = softsynth_close, +}; + +static const struct file_operations softsynthu_fops = { + .owner = THIS_MODULE, + .poll = softsynth_poll, + .read = softsynthu_read, + .write = softsynth_write, + .open = softsynth_open, + .release = softsynth_close, +}; + +static int softsynth_probe(struct spk_synth *synth) +{ + if (misc_registered != 0) + return 0; + memset(&synth_device, 0, sizeof(synth_device)); + synth_device.minor = MISC_DYNAMIC_MINOR; + synth_device.name = "softsynth"; + synth_device.fops = &softsynth_fops; + if (misc_register(&synth_device)) { + pr_warn("Couldn't initialize miscdevice /dev/softsynth.\n"); + return -ENODEV; + } + + memset(&synthu_device, 0, sizeof(synthu_device)); + synthu_device.minor = MISC_DYNAMIC_MINOR; + synthu_device.name = "softsynthu"; + synthu_device.fops = &softsynthu_fops; + if (misc_register(&synthu_device)) { + pr_warn("Couldn't initialize miscdevice /dev/softsynthu.\n"); + return -ENODEV; + } + + misc_registered = 1; + pr_info("initialized device: /dev/softsynth, node (MAJOR 10, MINOR %d)\n", + synth_device.minor); + pr_info("initialized device: /dev/softsynthu, node (MAJOR 10, MINOR %d)\n", + synthu_device.minor); + return 0; +} + +static void softsynth_release(void) +{ + misc_deregister(&synth_device); + misc_deregister(&synthu_device); + misc_registered = 0; + pr_info("unregistered /dev/softsynth\n"); + pr_info("unregistered /dev/softsynthu\n"); +} + +static int softsynth_is_alive(struct spk_synth *synth) +{ + if (synth_soft.alive) + return 1; + return 0; +} + +module_param_named(start, synth_soft.startup, short, 0444); + +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_soft); + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_DESCRIPTION("Speakup userspace software synthesizer support"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); diff --git a/drivers/accessibility/speakup/speakup_spkout.c b/drivers/accessibility/speakup/speakup_spkout.c new file mode 100644 index 000000000000..6e933bf1de2e --- /dev/null +++ b/drivers/accessibility/speakup/speakup_spkout.c @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * originally written by: Kirk Reiser + * this version considerably modified by David Borowski, david575@rogers.com + * + * Copyright (C) 1998-99 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + * + * specificly written as a driver for the speakup screenreview + * s not a general device driver. + */ +#include "spk_priv.h" +#include "speakup.h" + +#define DRV_VERSION "2.11" +#define SYNTH_CLEAR 0x18 +#define PROCSPEECH '\r' + +static void synth_flush(struct spk_synth *synth); + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"\x05P+" } }, + { CAPS_STOP, .u.s = {"\x05P-" } }, + { RATE, .u.n = {"\x05R%d", 7, 0, 9, 0, 0, NULL } }, + { PITCH, .u.n = {"\x05P%d", 3, 0, 9, 0, 0, NULL } }, + { VOL, .u.n = {"\x05V%d", 9, 0, 9, 0, 0, NULL } }, + { TONE, .u.n = {"\x05T%c", 8, 0, 25, 65, 0, NULL } }, + { PUNCT, .u.n = {"\x05M%c", 0, 0, 3, 0, 0, "nsma" } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* These attributes will appear in /sys/accessibility/speakup/spkout. */ + +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute punct_attribute = + __ATTR(punct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute tone_attribute = + __ATTR(tone, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &pitch_attribute.attr, + &punct_attribute.attr, + &rate_attribute.attr, + &tone_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_spkout = { + .name = "spkout", + .version = DRV_VERSION, + .long_name = "Speakout", + .init = "\005W1\005I2\005C3", + .procspeech = PROCSPEECH, + .clear = SYNTH_CLEAR, + .delay = 500, + .trigger = 50, + .jiffies = 50, + .full = 40000, + .dev_name = SYNTH_DEFAULT_DEV, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = &spk_ttyio_ops, + .probe = spk_ttyio_synth_probe, + .release = spk_ttyio_release, + .synth_immediate = spk_ttyio_synth_immediate, + .catch_up = spk_do_catch_up, + .flush = synth_flush, + .is_alive = spk_synth_is_alive_restart, + .synth_adjust = NULL, + .read_buff_add = NULL, + .get_index = spk_synth_get_index, + .indexing = { + .command = "\x05[%c", + .lowindex = 1, + .highindex = 5, + .currindex = 1, + }, + .attributes = { + .attrs = synth_attrs, + .name = "spkout", + }, +}; + +static void synth_flush(struct spk_synth *synth) +{ + synth->io_ops->flush_buffer(); + synth->io_ops->send_xchar(SYNTH_CLEAR); +} + +module_param_named(ser, synth_spkout.ser, int, 0444); +module_param_named(dev, synth_spkout.dev_name, charp, 0444); +module_param_named(start, synth_spkout.startup, short, 0444); + +MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); +MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_spkout); + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_AUTHOR("David Borowski"); +MODULE_DESCRIPTION("Speakup support for Speak Out synthesizers"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/drivers/accessibility/speakup/speakup_txprt.c b/drivers/accessibility/speakup/speakup_txprt.c new file mode 100644 index 000000000000..a7326f226a5e --- /dev/null +++ b/drivers/accessibility/speakup/speakup_txprt.c @@ -0,0 +1,127 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * originally written by: Kirk Reiser + * this version considerably modified by David Borowski, david575@rogers.com + * + * Copyright (C) 1998-99 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + * + * specificly written as a driver for the speakup screenreview + * s not a general device driver. + */ +#include "spk_priv.h" +#include "speakup.h" + +#define DRV_VERSION "2.11" +#define SYNTH_CLEAR 0x18 +#define PROCSPEECH '\r' /* process speech char */ + +static struct var_t vars[] = { + { CAPS_START, .u.s = {"\x05P8" } }, + { CAPS_STOP, .u.s = {"\x05P5" } }, + { RATE, .u.n = {"\x05R%d", 5, 0, 9, 0, 0, NULL } }, + { PITCH, .u.n = {"\x05P%d", 5, 0, 9, 0, 0, NULL } }, + { VOL, .u.n = {"\x05V%d", 5, 0, 9, 0, 0, NULL } }, + { TONE, .u.n = {"\x05T%c", 12, 0, 25, 61, 0, NULL } }, + { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, + V_LAST_VAR + }; + +/* These attributes will appear in /sys/accessibility/speakup/txprt. */ + +static struct kobj_attribute caps_start_attribute = + __ATTR(caps_start, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute caps_stop_attribute = + __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute pitch_attribute = + __ATTR(pitch, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute rate_attribute = + __ATTR(rate, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute tone_attribute = + __ATTR(tone, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute vol_attribute = + __ATTR(vol, 0644, spk_var_show, spk_var_store); + +static struct kobj_attribute delay_time_attribute = + __ATTR(delay_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute direct_attribute = + __ATTR(direct, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute full_time_attribute = + __ATTR(full_time, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute jiffy_delta_attribute = + __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); +static struct kobj_attribute trigger_time_attribute = + __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); + +/* + * Create a group of attributes so that we can create and destroy them all + * at once. + */ +static struct attribute *synth_attrs[] = { + &caps_start_attribute.attr, + &caps_stop_attribute.attr, + &pitch_attribute.attr, + &rate_attribute.attr, + &tone_attribute.attr, + &vol_attribute.attr, + &delay_time_attribute.attr, + &direct_attribute.attr, + &full_time_attribute.attr, + &jiffy_delta_attribute.attr, + &trigger_time_attribute.attr, + NULL, /* need to NULL terminate the list of attributes */ +}; + +static struct spk_synth synth_txprt = { + .name = "txprt", + .version = DRV_VERSION, + .long_name = "Transport", + .init = "\x05N1", + .procspeech = PROCSPEECH, + .clear = SYNTH_CLEAR, + .delay = 500, + .trigger = 50, + .jiffies = 50, + .full = 40000, + .dev_name = SYNTH_DEFAULT_DEV, + .startup = SYNTH_START, + .checkval = SYNTH_CHECK, + .vars = vars, + .io_ops = &spk_ttyio_ops, + .probe = spk_ttyio_synth_probe, + .release = spk_ttyio_release, + .synth_immediate = spk_ttyio_synth_immediate, + .catch_up = spk_do_catch_up, + .flush = spk_synth_flush, + .is_alive = spk_synth_is_alive_restart, + .synth_adjust = NULL, + .read_buff_add = NULL, + .get_index = NULL, + .indexing = { + .command = NULL, + .lowindex = 0, + .highindex = 0, + .currindex = 0, + }, + .attributes = { + .attrs = synth_attrs, + .name = "txprt", + }, +}; + +module_param_named(ser, synth_txprt.ser, int, 0444); +module_param_named(dev, synth_txprt.dev_name, charp, 0444); +module_param_named(start, synth_txprt.startup, short, 0444); + +MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); +MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); +MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); + +module_spk_synth(synth_txprt); + +MODULE_AUTHOR("Kirk Reiser "); +MODULE_AUTHOR("David Borowski"); +MODULE_DESCRIPTION("Speakup support for Transport synthesizers"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); + diff --git a/drivers/accessibility/speakup/speakupmap.h b/drivers/accessibility/speakup/speakupmap.h new file mode 100644 index 000000000000..c60d7339b89a --- /dev/null +++ b/drivers/accessibility/speakup/speakupmap.h @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + 119, 62, 6, + 0, 16, 20, 17, 32, 48, 0, + 2, 0, 78, 0, 0, 0, 0, + 3, 0, 79, 0, 0, 0, 0, + 4, 0, 76, 0, 0, 0, 0, + 5, 0, 77, 0, 0, 0, 0, + 6, 0, 74, 0, 0, 0, 0, + 7, 0, 75, 0, 0, 0, 0, + 9, 0, 5, 46, 0, 0, 0, + 10, 0, 4, 0, 0, 0, 0, + 11, 0, 0, 1, 0, 0, 0, + 12, 0, 27, 0, 33, 0, 0, + 19, 0, 47, 0, 0, 0, 0, + 21, 0, 29, 17, 0, 0, 0, + 22, 0, 15, 0, 0, 0, 0, + 23, 0, 14, 0, 0, 0, 28, + 24, 0, 16, 0, 0, 0, 0, + 25, 0, 30, 18, 0, 0, 0, + 28, 0, 3, 26, 0, 0, 0, + 35, 0, 31, 0, 0, 0, 0, + 36, 0, 12, 0, 0, 0, 0, + 37, 0, 11, 0, 0, 0, 22, + 38, 0, 13, 0, 0, 0, 0, + 39, 0, 32, 7, 0, 0, 0, + 40, 0, 23, 0, 0, 0, 0, + 44, 0, 44, 0, 0, 0, 0, + 49, 0, 24, 0, 0, 0, 0, + 50, 0, 9, 19, 6, 0, 0, + 51, 0, 8, 0, 0, 0, 36, + 52, 0, 10, 20, 0, 0, 0, + 53, 0, 25, 0, 0, 0, 0, + 55, 46, 1, 0, 0, 0, 0, + 58, 128, 128, 0, 0, 0, 0, + 59, 0, 45, 0, 0, 0, 0, + 60, 0, 40, 0, 0, 0, 0, + 61, 0, 41, 0, 0, 0, 0, + 62, 0, 42, 0, 0, 0, 0, + 63, 0, 34, 0, 0, 0, 0, + 64, 0, 35, 0, 0, 0, 0, + 65, 0, 37, 0, 0, 0, 0, + 66, 0, 38, 0, 0, 0, 0, + 67, 0, 66, 0, 39, 0, 0, + 68, 0, 67, 0, 0, 0, 0, + 71, 15, 19, 0, 0, 0, 0, + 72, 14, 29, 0, 0, 28, 0, + 73, 16, 17, 0, 0, 0, 0, + 74, 27, 33, 0, 0, 0, 0, + 75, 12, 31, 0, 0, 0, 0, + 76, 11, 21, 0, 0, 22, 0, + 77, 13, 32, 0, 0, 0, 0, + 78, 23, 43, 0, 0, 0, 0, + 79, 9, 20, 0, 0, 0, 0, + 80, 8, 30, 0, 0, 36, 0, + 81, 10, 18, 0, 0, 0, 0, + 82, 128, 128, 0, 0, 0, 0, + 83, 24, 25, 0, 0, 0, 0, + 87, 0, 68, 0, 0, 0, 0, + 88, 0, 69, 0, 0, 0, 0, + 96, 3, 26, 0, 0, 0, 0, + 98, 4, 5, 0, 0, 0, 0, + 99, 2, 0, 0, 0, 0, 0, + 104, 0, 6, 0, 0, 0, 0, + 109, 0, 7, 0, 0, 0, 0, + 125, 128, 128, 0, 0, 0, 0, + 0, 119 diff --git a/drivers/accessibility/speakup/speakupmap.map b/drivers/accessibility/speakup/speakupmap.map new file mode 100644 index 000000000000..f10d44cf5d7a --- /dev/null +++ b/drivers/accessibility/speakup/speakupmap.map @@ -0,0 +1,93 @@ +spk key_f9 = punc_level_dec +spk key_f10 = punc_level_inc +spk key_f11 = reading_punc_dec +spk key_f12 = reading_punc_inc +spk key_1 = vol_dec +spk key_2 = vol_inc +spk key_3 = pitch_dec +spk key_4 = pitch_inc +spk key_5 = rate_dec +spk key_6 = rate_inc +key_kpasterisk = toggle_cursoring +ctrl spk key_8 = toggle_cursoring +spk key_kpasterisk = speakup_goto +spk key_f1 = speakup_help +spk key_f2 = set_win +spk key_f3 = clear_win +spk key_f4 = enable_win +spk key_f5 = edit_some +spk key_f6 = edit_most +spk key_f7 = edit_delim +spk key_f8 = edit_repeat +shift spk key_f9 = edit_exnum + key_kp7 = say_prev_line +spk key_kp7 = left_edge + key_kp8 = say_line +double key_kp8 = say_line_indent +spk key_kp8 = say_from_top + key_kp9 = say_next_line +spk key_kp9 = top_edge + key_kpminus = speakup_parked +spk key_kpminus = say_char_num + key_kp4 = say_prev_word +spk key_kp4 = say_from_left + key_kp5 = say_word +double key_kp5 = spell_word +spk key_kp5 = spell_phonetic + key_kp6 = say_next_word +spk key_kp6 = say_to_right + key_kpplus = say_screen +spk key_kpplus = say_win + key_kp1 = say_prev_char +spk key_kp1 = right_edge + key_kp2 = say_char +spk key_kp2 = say_to_bottom +double key_kp2 = say_phonetic_char + key_kp3 = say_next_char +spk key_kp3 = bottom_edge + key_kp0 = spk_key + key_kpdot = say_position +spk key_kpdot = say_attributes +key_kpenter = speakup_quiet +spk key_kpenter = speakup_off +key_sysrq = speech_kill + key_kpslash = speakup_cut +spk key_kpslash = speakup_paste +spk key_pageup = say_first_char +spk key_pagedown = say_last_char +key_capslock = spk_key + spk key_z = spk_lock +key_leftmeta = spk_key +ctrl spk key_0 = speakup_goto +spk key_u = say_prev_line +spk key_i = say_line +double spk key_i = say_line_indent +spk key_o = say_next_line +spk key_minus = speakup_parked +shift spk key_minus = say_char_num +spk key_j = say_prev_word +spk key_k = say_word +double spk key_k = spell_word +spk key_l = say_next_word +spk key_m = say_prev_char +spk key_comma = say_char +double spk key_comma = say_phonetic_char +spk key_dot = say_next_char +spk key_n = say_position + ctrl spk key_m = left_edge + ctrl spk key_y = top_edge + ctrl spk key_dot = right_edge +ctrl spk key_p = bottom_edge +spk key_apostrophe = say_screen +spk key_h = say_from_left +spk key_y = say_from_top +spk key_semicolon = say_to_right +spk key_p = say_to_bottom +spk key_slash = say_attributes + spk key_enter = speakup_quiet + ctrl spk key_enter = speakup_off + spk key_9 = speakup_cut +spk key_8 = speakup_paste +shift spk key_m = say_first_char + ctrl spk key_semicolon = say_last_char +spk key_r = read_all_doc diff --git a/drivers/accessibility/speakup/spk_priv.h b/drivers/accessibility/speakup/spk_priv.h new file mode 100644 index 000000000000..c75b40838794 --- /dev/null +++ b/drivers/accessibility/speakup/spk_priv.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* spk_priv.h + * review functions for the speakup screen review package. + * originally written by: Kirk Reiser and Andy Berdan. + * + * extensively modified by David Borowski. + * + * Copyright (C) 1998 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + */ +#ifndef _SPEAKUP_PRIVATE_H +#define _SPEAKUP_PRIVATE_H + +#include + +#include "spk_types.h" +#include "spk_priv_keyinfo.h" + +#define V_LAST_VAR { MAXVARS } +#define SPACE 0x20 +#define SYNTH_CHECK 20030716 /* today's date ought to do for check value */ +/* synth flags, for odd synths */ +#define SF_DEC 1 /* to fiddle puncs in alpha strings so it doesn't spell */ +#ifdef MODULE +#define SYNTH_START 1 +#else +#define SYNTH_START 0 +#endif + +#define KT_SPKUP 15 +#define SPK_SYNTH_TIMEOUT 100000 /* in micro-seconds */ +#define SYNTH_DEFAULT_DEV "ttyS0" +#define SYNTH_DEFAULT_SER 0 + +const struct old_serial_port *spk_serial_init(int index); +void spk_stop_serial_interrupt(void); +int spk_wait_for_xmitr(struct spk_synth *in_synth); +void spk_serial_release(void); +void spk_ttyio_release(void); +void spk_ttyio_register_ldisc(void); +void spk_ttyio_unregister_ldisc(void); + +void synth_buffer_skip_nonlatin1(void); +u16 synth_buffer_getc(void); +u16 synth_buffer_peek(void); +int synth_buffer_empty(void); +struct var_t *spk_get_var(enum var_id_t var_id); +ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf); +ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count); + +int spk_serial_synth_probe(struct spk_synth *synth); +int spk_ttyio_synth_probe(struct spk_synth *synth); +const char *spk_serial_synth_immediate(struct spk_synth *synth, + const char *buff); +const char *spk_ttyio_synth_immediate(struct spk_synth *synth, + const char *buff); +void spk_do_catch_up(struct spk_synth *synth); +void spk_do_catch_up_unicode(struct spk_synth *synth); +void spk_synth_flush(struct spk_synth *synth); +unsigned char spk_synth_get_index(struct spk_synth *synth); +int spk_synth_is_alive_nop(struct spk_synth *synth); +int spk_synth_is_alive_restart(struct spk_synth *synth); +__printf(1, 2) +void synth_printf(const char *buf, ...); +void synth_putwc(u16 wc); +void synth_putwc_s(u16 wc); +void synth_putws(const u16 *buf); +void synth_putws_s(const u16 *buf); +int synth_request_region(unsigned long start, unsigned long n); +int synth_release_region(unsigned long start, unsigned long n); +int synth_add(struct spk_synth *in_synth); +void synth_remove(struct spk_synth *in_synth); +struct spk_synth *synth_current(void); + +extern struct speakup_info_t speakup_info; + +extern struct var_t synth_time_vars[]; + +extern struct spk_io_ops spk_serial_io_ops; +extern struct spk_io_ops spk_ttyio_ops; + +#endif diff --git a/drivers/accessibility/speakup/spk_priv_keyinfo.h b/drivers/accessibility/speakup/spk_priv_keyinfo.h new file mode 100644 index 000000000000..1f789bd1c678 --- /dev/null +++ b/drivers/accessibility/speakup/spk_priv_keyinfo.h @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* spk_priv.h + * review functions for the speakup screen review package. + * originally written by: Kirk Reiser and Andy Berdan. + * + * extensively modified by David Borowski. + * + * Copyright (C) 1998 Kirk Reiser. + * Copyright (C) 2003 David Borowski. + */ + +#ifndef _SPEAKUP_KEYINFO_H +#define _SPEAKUP_KEYINFO_H + +#define FIRST_SYNTH_VAR RATE +/* 0 is reserved for no remap */ +#define SPEAKUP_GOTO 0x01 +#define SPEECH_KILL 0x02 +#define SPEAKUP_QUIET 0x03 +#define SPEAKUP_CUT 0x04 +#define SPEAKUP_PASTE 0x05 +#define SAY_FIRST_CHAR 0x06 +#define SAY_LAST_CHAR 0x07 +#define SAY_CHAR 0x08 +#define SAY_PREV_CHAR 0x09 +#define SAY_NEXT_CHAR 0x0a +#define SAY_WORD 0x0b +#define SAY_PREV_WORD 0x0c +#define SAY_NEXT_WORD 0x0d +#define SAY_LINE 0x0e +#define SAY_PREV_LINE 0x0f +#define SAY_NEXT_LINE 0x10 +#define TOP_EDGE 0x11 +#define BOTTOM_EDGE 0x12 +#define LEFT_EDGE 0x13 +#define RIGHT_EDGE 0x14 +#define SPELL_PHONETIC 0x15 +#define SPELL_WORD 0x16 +#define SAY_SCREEN 0x17 +#define SAY_POSITION 0x18 +#define SAY_ATTRIBUTES 0x19 +#define SPEAKUP_OFF 0x1a +#define SPEAKUP_PARKED 0x1b +#define SAY_LINE_INDENT 0x1c +#define SAY_FROM_TOP 0x1d +#define SAY_TO_BOTTOM 0x1e +#define SAY_FROM_LEFT 0x1f +#define SAY_TO_RIGHT 0x20 +#define SAY_CHAR_NUM 0x21 +#define EDIT_SOME 0x22 +#define EDIT_MOST 0x23 +#define SAY_PHONETIC_CHAR 0x24 +#define EDIT_DELIM 0x25 +#define EDIT_REPEAT 0x26 +#define EDIT_EXNUM 0x27 +#define SET_WIN 0x28 +#define CLEAR_WIN 0x29 +#define ENABLE_WIN 0x2a +#define SAY_WIN 0x2b +#define SPK_LOCK 0x2c +#define SPEAKUP_HELP 0x2d +#define TOGGLE_CURSORING 0x2e +#define READ_ALL_DOC 0x2f + +/* one greater than the last func handler */ +#define SPKUP_MAX_FUNC 0x30 + +#define SPK_KEY 0x80 +#define FIRST_EDIT_BITS 0x22 +#define FIRST_SET_VAR SPELL_DELAY + +/* increase if adding more than 0x3f functions */ +#define VAR_START 0x40 + +/* keys for setting variables, must be ordered same as the enum for var_ids */ +/* with dec being even and inc being 1 greater */ +#define SPELL_DELAY_DEC (VAR_START + 0) +#define SPELL_DELAY_INC (SPELL_DELAY_DEC + 1) +#define PUNC_LEVEL_DEC (SPELL_DELAY_DEC + 2) +#define PUNC_LEVEL_INC (PUNC_LEVEL_DEC + 1) +#define READING_PUNC_DEC (PUNC_LEVEL_DEC + 2) +#define READING_PUNC_INC (READING_PUNC_DEC + 1) +#define ATTRIB_BLEEP_DEC (READING_PUNC_DEC + 2) +#define ATTRIB_BLEEP_INC (ATTRIB_BLEEP_DEC + 1) +#define BLEEPS_DEC (ATTRIB_BLEEP_DEC + 2) +#define BLEEPS_INC (BLEEPS_DEC + 1) +#define RATE_DEC (BLEEPS_DEC + 2) +#define RATE_INC (RATE_DEC + 1) +#define PITCH_DEC (RATE_DEC + 2) +#define PITCH_INC (PITCH_DEC + 1) +#define VOL_DEC (PITCH_DEC + 2) +#define VOL_INC (VOL_DEC + 1) +#define TONE_DEC (VOL_DEC + 2) +#define TONE_INC (TONE_DEC + 1) +#define PUNCT_DEC (TONE_DEC + 2) +#define PUNCT_INC (PUNCT_DEC + 1) +#define VOICE_DEC (PUNCT_DEC + 2) +#define VOICE_INC (VOICE_DEC + 1) + +#endif diff --git a/drivers/accessibility/speakup/spk_ttyio.c b/drivers/accessibility/speakup/spk_ttyio.c new file mode 100644 index 000000000000..9b95f77f9265 --- /dev/null +++ b/drivers/accessibility/speakup/spk_ttyio.c @@ -0,0 +1,384 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include + +#include "speakup.h" +#include "spk_types.h" +#include "spk_priv.h" + +struct spk_ldisc_data { + char buf; + struct completion completion; + bool buf_free; +}; + +static struct spk_synth *spk_ttyio_synth; +static struct tty_struct *speakup_tty; +/* mutex to protect against speakup_tty disappearing from underneath us while + * we are using it. this can happen when the device physically unplugged, + * while in use. it also serialises access to speakup_tty. + */ +static DEFINE_MUTEX(speakup_tty_mutex); + +static int ser_to_dev(int ser, dev_t *dev_no) +{ + if (ser < 0 || ser > (255 - 64)) { + pr_err("speakup: Invalid ser param. Must be between 0 and 191 inclusive.\n"); + return -EINVAL; + } + + *dev_no = MKDEV(4, (64 + ser)); + return 0; +} + +static int get_dev_to_use(struct spk_synth *synth, dev_t *dev_no) +{ + /* use ser only when dev is not specified */ + if (strcmp(synth->dev_name, SYNTH_DEFAULT_DEV) || + synth->ser == SYNTH_DEFAULT_SER) + return tty_dev_name_to_number(synth->dev_name, dev_no); + + return ser_to_dev(synth->ser, dev_no); +} + +static int spk_ttyio_ldisc_open(struct tty_struct *tty) +{ + struct spk_ldisc_data *ldisc_data; + + if (!tty->ops->write) + return -EOPNOTSUPP; + speakup_tty = tty; + + ldisc_data = kmalloc(sizeof(*ldisc_data), GFP_KERNEL); + if (!ldisc_data) + return -ENOMEM; + + init_completion(&ldisc_data->completion); + ldisc_data->buf_free = true; + speakup_tty->disc_data = ldisc_data; + + return 0; +} + +static void spk_ttyio_ldisc_close(struct tty_struct *tty) +{ + mutex_lock(&speakup_tty_mutex); + kfree(speakup_tty->disc_data); + speakup_tty = NULL; + mutex_unlock(&speakup_tty_mutex); +} + +static int spk_ttyio_receive_buf2(struct tty_struct *tty, + const unsigned char *cp, char *fp, int count) +{ + struct spk_ldisc_data *ldisc_data = tty->disc_data; + + if (spk_ttyio_synth->read_buff_add) { + int i; + + for (i = 0; i < count; i++) + spk_ttyio_synth->read_buff_add(cp[i]); + + return count; + } + + if (!ldisc_data->buf_free) + /* ttyio_in will tty_schedule_flip */ + return 0; + + /* Make sure the consumer has read buf before we have seen + * buf_free == true and overwrite buf + */ + mb(); + + ldisc_data->buf = cp[0]; + ldisc_data->buf_free = false; + complete(&ldisc_data->completion); + + return 1; +} + +static struct tty_ldisc_ops spk_ttyio_ldisc_ops = { + .owner = THIS_MODULE, + .magic = TTY_LDISC_MAGIC, + .name = "speakup_ldisc", + .open = spk_ttyio_ldisc_open, + .close = spk_ttyio_ldisc_close, + .receive_buf2 = spk_ttyio_receive_buf2, +}; + +static int spk_ttyio_out(struct spk_synth *in_synth, const char ch); +static int spk_ttyio_out_unicode(struct spk_synth *in_synth, u16 ch); +static void spk_ttyio_send_xchar(char ch); +static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear); +static unsigned char spk_ttyio_in(void); +static unsigned char spk_ttyio_in_nowait(void); +static void spk_ttyio_flush_buffer(void); + +struct spk_io_ops spk_ttyio_ops = { + .synth_out = spk_ttyio_out, + .synth_out_unicode = spk_ttyio_out_unicode, + .send_xchar = spk_ttyio_send_xchar, + .tiocmset = spk_ttyio_tiocmset, + .synth_in = spk_ttyio_in, + .synth_in_nowait = spk_ttyio_in_nowait, + .flush_buffer = spk_ttyio_flush_buffer, +}; +EXPORT_SYMBOL_GPL(spk_ttyio_ops); + +static inline void get_termios(struct tty_struct *tty, + struct ktermios *out_termios) +{ + down_read(&tty->termios_rwsem); + *out_termios = tty->termios; + up_read(&tty->termios_rwsem); +} + +static int spk_ttyio_initialise_ldisc(struct spk_synth *synth) +{ + int ret = 0; + struct tty_struct *tty; + struct ktermios tmp_termios; + dev_t dev; + + ret = get_dev_to_use(synth, &dev); + if (ret) + return ret; + + tty = tty_kopen(dev); + if (IS_ERR(tty)) + return PTR_ERR(tty); + + if (tty->ops->open) + ret = tty->ops->open(tty, NULL); + else + ret = -ENODEV; + + if (ret) { + tty_unlock(tty); + return ret; + } + + clear_bit(TTY_HUPPED, &tty->flags); + /* ensure hardware flow control is enabled */ + get_termios(tty, &tmp_termios); + if (!(tmp_termios.c_cflag & CRTSCTS)) { + tmp_termios.c_cflag |= CRTSCTS; + tty_set_termios(tty, &tmp_termios); + /* + * check c_cflag to see if it's updated as tty_set_termios + * may not return error even when no tty bits are + * changed by the request. + */ + get_termios(tty, &tmp_termios); + if (!(tmp_termios.c_cflag & CRTSCTS)) + pr_warn("speakup: Failed to set hardware flow control\n"); + } + + tty_unlock(tty); + + ret = tty_set_ldisc(tty, N_SPEAKUP); + if (ret) + pr_err("speakup: Failed to set N_SPEAKUP on tty\n"); + + return ret; +} + +void spk_ttyio_register_ldisc(void) +{ + if (tty_register_ldisc(N_SPEAKUP, &spk_ttyio_ldisc_ops)) + pr_warn("speakup: Error registering line discipline. Most synths won't work.\n"); +} + +void spk_ttyio_unregister_ldisc(void) +{ + if (tty_unregister_ldisc(N_SPEAKUP)) + pr_warn("speakup: Couldn't unregister ldisc\n"); +} + +static int spk_ttyio_out(struct spk_synth *in_synth, const char ch) +{ + mutex_lock(&speakup_tty_mutex); + if (in_synth->alive && speakup_tty && speakup_tty->ops->write) { + int ret = speakup_tty->ops->write(speakup_tty, &ch, 1); + + mutex_unlock(&speakup_tty_mutex); + if (ret == 0) + /* No room */ + return 0; + if (ret < 0) { + pr_warn("%s: I/O error, deactivating speakup\n", + in_synth->long_name); + /* No synth any more, so nobody will restart TTYs, + * and we thus need to do it ourselves. Now that there + * is no synth we can let application flood anyway + */ + in_synth->alive = 0; + speakup_start_ttys(); + return 0; + } + return 1; + } + + mutex_unlock(&speakup_tty_mutex); + return 0; +} + +static int spk_ttyio_out_unicode(struct spk_synth *in_synth, u16 ch) +{ + int ret; + + if (ch < 0x80) { + ret = spk_ttyio_out(in_synth, ch); + } else if (ch < 0x800) { + ret = spk_ttyio_out(in_synth, 0xc0 | (ch >> 6)); + ret &= spk_ttyio_out(in_synth, 0x80 | (ch & 0x3f)); + } else { + ret = spk_ttyio_out(in_synth, 0xe0 | (ch >> 12)); + ret &= spk_ttyio_out(in_synth, 0x80 | ((ch >> 6) & 0x3f)); + ret &= spk_ttyio_out(in_synth, 0x80 | (ch & 0x3f)); + } + return ret; +} + +static int check_tty(struct tty_struct *tty) +{ + if (!tty) { + pr_warn("%s: I/O error, deactivating speakup\n", + spk_ttyio_synth->long_name); + /* No synth any more, so nobody will restart TTYs, and we thus + * need to do it ourselves. Now that there is no synth we can + * let application flood anyway + */ + spk_ttyio_synth->alive = 0; + speakup_start_ttys(); + return 1; + } + + return 0; +} + +static void spk_ttyio_send_xchar(char ch) +{ + mutex_lock(&speakup_tty_mutex); + if (check_tty(speakup_tty)) { + mutex_unlock(&speakup_tty_mutex); + return; + } + + if (speakup_tty->ops->send_xchar) + speakup_tty->ops->send_xchar(speakup_tty, ch); + mutex_unlock(&speakup_tty_mutex); +} + +static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear) +{ + mutex_lock(&speakup_tty_mutex); + if (check_tty(speakup_tty)) { + mutex_unlock(&speakup_tty_mutex); + return; + } + + if (speakup_tty->ops->tiocmset) + speakup_tty->ops->tiocmset(speakup_tty, set, clear); + mutex_unlock(&speakup_tty_mutex); +} + +static unsigned char ttyio_in(int timeout) +{ + struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data; + char rv; + + if (wait_for_completion_timeout(&ldisc_data->completion, + usecs_to_jiffies(timeout)) == 0) { + if (timeout) + pr_warn("spk_ttyio: timeout (%d) while waiting for input\n", + timeout); + return 0xff; + } + + rv = ldisc_data->buf; + /* Make sure we have read buf before we set buf_free to let + * the producer overwrite it + */ + mb(); + ldisc_data->buf_free = true; + /* Let TTY push more characters */ + tty_schedule_flip(speakup_tty->port); + + return rv; +} + +static unsigned char spk_ttyio_in(void) +{ + return ttyio_in(SPK_SYNTH_TIMEOUT); +} + +static unsigned char spk_ttyio_in_nowait(void) +{ + u8 rv = ttyio_in(0); + + return (rv == 0xff) ? 0 : rv; +} + +static void spk_ttyio_flush_buffer(void) +{ + mutex_lock(&speakup_tty_mutex); + if (check_tty(speakup_tty)) { + mutex_unlock(&speakup_tty_mutex); + return; + } + + if (speakup_tty->ops->flush_buffer) + speakup_tty->ops->flush_buffer(speakup_tty); + + mutex_unlock(&speakup_tty_mutex); +} + +int spk_ttyio_synth_probe(struct spk_synth *synth) +{ + int rv = spk_ttyio_initialise_ldisc(synth); + + if (rv) + return rv; + + synth->alive = 1; + spk_ttyio_synth = synth; + + return 0; +} +EXPORT_SYMBOL_GPL(spk_ttyio_synth_probe); + +void spk_ttyio_release(void) +{ + if (!speakup_tty) + return; + + tty_lock(speakup_tty); + + if (speakup_tty->ops->close) + speakup_tty->ops->close(speakup_tty, NULL); + + tty_ldisc_flush(speakup_tty); + tty_unlock(speakup_tty); + tty_kclose(speakup_tty); +} +EXPORT_SYMBOL_GPL(spk_ttyio_release); + +const char *spk_ttyio_synth_immediate(struct spk_synth *synth, const char *buff) +{ + u_char ch; + + while ((ch = *buff)) { + if (ch == '\n') + ch = synth->procspeech; + if (tty_write_room(speakup_tty) < 1 || + !synth->io_ops->synth_out(synth, ch)) + return buff; + buff++; + } + return NULL; +} +EXPORT_SYMBOL_GPL(spk_ttyio_synth_immediate); diff --git a/drivers/accessibility/speakup/spk_types.h b/drivers/accessibility/speakup/spk_types.h new file mode 100644 index 000000000000..d3272c6d199a --- /dev/null +++ b/drivers/accessibility/speakup/spk_types.h @@ -0,0 +1,221 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef SPEAKUP_TYPES_H +#define SPEAKUP_TYPES_H + +/* This file includes all of the typedefs and structs used in speakup. */ + +#include +#include +#include +#include +#include /* for wait_queue */ +#include /* for __init */ +#include +#include +#include +#include +#include /* for inb_p, outb_p, inb, outb, etc... */ +#include + +enum var_type_t { + VAR_NUM = 0, + VAR_TIME, + VAR_STRING, + VAR_PROC +}; + +enum { + E_DEFAULT = 0, + E_SET, + E_INC, + E_DEC, + E_NEW_DEFAULT, +}; + +enum var_id_t { + VERSION = 0, SYNTH, SILENT, SYNTH_DIRECT, + KEYMAP, CHARS, + PUNC_SOME, PUNC_MOST, PUNC_ALL, + DELIM, REPEATS, EXNUMBER, + DELAY, TRIGGER, JIFFY, FULL, /* all timers must be together */ + BLEEP_TIME, CURSOR_TIME, BELL_POS, + SAY_CONTROL, SAY_WORD_CTL, NO_INTERRUPT, KEY_ECHO, + SPELL_DELAY, PUNC_LEVEL, READING_PUNC, + ATTRIB_BLEEP, BLEEPS, + RATE, PITCH, INFLECTION, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG, + DIRECT, PAUSE, + CAPS_START, CAPS_STOP, CHARTAB, + MAXVARS +}; + +typedef int (*special_func)(struct vc_data *vc, u_char type, u_char ch, + u_short key); + +#define COLOR_BUFFER_SIZE 160 + +struct spk_highlight_color_track { + /* Count of each background color */ + unsigned int bgcount[8]; + /* Buffer for characters drawn with each background color */ + u16 highbuf[8][COLOR_BUFFER_SIZE]; + /* Current index into highbuf */ + unsigned int highsize[8]; + /* Reading Position for each color */ + u_long rpos[8], rx[8], ry[8]; + /* Real Cursor Y Position */ + ulong cy; +}; + +struct st_spk_t { + u_long reading_x, cursor_x; + u_long reading_y, cursor_y; + u_long reading_pos, cursor_pos; + u_long go_x, go_pos; + u_long w_top, w_bottom, w_left, w_right; + u_char w_start, w_enabled; + u_char reading_attr, old_attr; + char parked, shut_up; + struct spk_highlight_color_track ht; + int tty_stopped; +}; + +/* now some defines to make these easier to use. */ +#define spk_shut_up (speakup_console[vc->vc_num]->shut_up) +#define spk_killed (speakup_console[vc->vc_num]->shut_up & 0x40) +#define spk_x (speakup_console[vc->vc_num]->reading_x) +#define spk_cx (speakup_console[vc->vc_num]->cursor_x) +#define spk_y (speakup_console[vc->vc_num]->reading_y) +#define spk_cy (speakup_console[vc->vc_num]->cursor_y) +#define spk_pos (speakup_console[vc->vc_num]->reading_pos) +#define spk_cp (speakup_console[vc->vc_num]->cursor_pos) +#define goto_pos (speakup_console[vc->vc_num]->go_pos) +#define goto_x (speakup_console[vc->vc_num]->go_x) +#define win_top (speakup_console[vc->vc_num]->w_top) +#define win_bottom (speakup_console[vc->vc_num]->w_bottom) +#define win_left (speakup_console[vc->vc_num]->w_left) +#define win_right (speakup_console[vc->vc_num]->w_right) +#define win_start (speakup_console[vc->vc_num]->w_start) +#define win_enabled (speakup_console[vc->vc_num]->w_enabled) +#define spk_attr (speakup_console[vc->vc_num]->reading_attr) +#define spk_old_attr (speakup_console[vc->vc_num]->old_attr) +#define spk_parked (speakup_console[vc->vc_num]->parked) + +struct st_var_header { + char *name; + enum var_id_t var_id; + enum var_type_t var_type; + void *p_val; /* ptr to programs variable to store value */ + void *data; /* ptr to the vars data */ +}; + +struct num_var_t { + char *synth_fmt; + int default_val; + int low; + int high; + short offset, multiplier; /* for fiddling rates etc. */ + char *out_str; /* if synth needs char representation of number */ + int value; /* current value */ +}; + +struct punc_var_t { + enum var_id_t var_id; + short value; +}; + +struct string_var_t { + char *default_val; +}; + +struct var_t { + enum var_id_t var_id; + union { + struct num_var_t n; + struct string_var_t s; + } u; +}; + +struct st_bits_data { /* punc, repeats, word delim bits */ + char *name; + char *value; + short mask; +}; + +struct synth_indexing { + char *command; + unsigned char lowindex; + unsigned char highindex; + unsigned char currindex; +}; + +struct spk_synth; + +struct spk_io_ops { + int (*synth_out)(struct spk_synth *synth, const char ch); + int (*synth_out_unicode)(struct spk_synth *synth, u16 ch); + void (*send_xchar)(char ch); + void (*tiocmset)(unsigned int set, unsigned int clear); + unsigned char (*synth_in)(void); + unsigned char (*synth_in_nowait)(void); + void (*flush_buffer)(void); +}; + +struct spk_synth { + struct list_head node; + + const char *name; + const char *version; + const char *long_name; + const char *init; + char procspeech; + char clear; + int delay; + int trigger; + int jiffies; + int full; + int ser; + char *dev_name; + short flags; + short startup; + const int checkval; /* for validating a proper synth module */ + struct var_t *vars; + int *default_pitch; + int *default_vol; + struct spk_io_ops *io_ops; + int (*probe)(struct spk_synth *synth); + void (*release)(void); + const char *(*synth_immediate)(struct spk_synth *synth, + const char *buff); + void (*catch_up)(struct spk_synth *synth); + void (*flush)(struct spk_synth *synth); + int (*is_alive)(struct spk_synth *synth); + int (*synth_adjust)(struct st_var_header *var); + void (*read_buff_add)(u_char c); + unsigned char (*get_index)(struct spk_synth *synth); + struct synth_indexing indexing; + int alive; + struct attribute_group attributes; +}; + +/* + * module_spk_synth() - Helper macro for registering a speakup driver + * @__spk_synth: spk_synth struct + * Helper macro for speakup drivers which do not do anything special in module + * init/exit. This eliminates a lot of boilerplate. Each module may only + * use this macro once, and calling it replaces module_init() and module_exit() + */ +#define module_spk_synth(__spk_synth) \ + module_driver(__spk_synth, synth_add, synth_remove) + +struct speakup_info_t { + spinlock_t spinlock; + int port_tts; + int flushing; +}; + +struct bleep { + short freq; + unsigned long jiffies; + int active; +}; +#endif diff --git a/drivers/accessibility/speakup/synth.c b/drivers/accessibility/speakup/synth.c new file mode 100644 index 000000000000..3568bfb89912 --- /dev/null +++ b/drivers/accessibility/speakup/synth.c @@ -0,0 +1,490 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include /* for isdigit() and friends */ +#include +#include /* for verify_area */ +#include /* for -EBUSY */ +#include /* for check_region, request_region */ +#include +#include /* for loops_per_sec */ +#include +#include +#include /* for copy_from_user */ +#include +#include +#include + +#include "spk_priv.h" +#include "speakup.h" +#include "serialio.h" + +static LIST_HEAD(synths); +struct spk_synth *synth; +char spk_pitch_buff[32] = ""; +static int module_status; +bool spk_quiet_boot; + +struct speakup_info_t speakup_info = { + /* + * This spinlock is used to protect the entire speakup machinery, and + * must be taken at each kernel->speakup transition and released at + * each corresponding speakup->kernel transition. + * + * The progression thread only interferes with the speakup machinery + * through the synth buffer, so only needs to take the lock + * while tinkering with the buffer. + * + * We use spin_lock/trylock_irqsave and spin_unlock_irqrestore with this + * spinlock because speakup needs to disable the keyboard IRQ. + */ + .spinlock = __SPIN_LOCK_UNLOCKED(speakup_info.spinlock), + .flushing = 0, +}; +EXPORT_SYMBOL_GPL(speakup_info); + +static int do_synth_init(struct spk_synth *in_synth); + +/* + * Main loop of the progression thread: keep eating from the buffer + * and push to the serial port, waiting as needed + * + * For devices that have a "full" notification mechanism, the driver can + * adapt the loop the way they prefer. + */ +static void _spk_do_catch_up(struct spk_synth *synth, int unicode) +{ + u16 ch; + unsigned long flags; + unsigned long jiff_max; + struct var_t *delay_time; + struct var_t *full_time; + struct var_t *jiffy_delta; + int jiffy_delta_val; + int delay_time_val; + int full_time_val; + int ret; + + jiffy_delta = spk_get_var(JIFFY); + full_time = spk_get_var(FULL); + delay_time = spk_get_var(DELAY); + + spin_lock_irqsave(&speakup_info.spinlock, flags); + jiffy_delta_val = jiffy_delta->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + + jiff_max = jiffies + jiffy_delta_val; + while (!kthread_should_stop()) { + spin_lock_irqsave(&speakup_info.spinlock, flags); + if (speakup_info.flushing) { + speakup_info.flushing = 0; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + synth->flush(synth); + continue; + } + if (!unicode) + synth_buffer_skip_nonlatin1(); + if (synth_buffer_empty()) { + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + break; + } + ch = synth_buffer_peek(); + set_current_state(TASK_INTERRUPTIBLE); + full_time_val = full_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (ch == '\n') + ch = synth->procspeech; + if (unicode) + ret = synth->io_ops->synth_out_unicode(synth, ch); + else + ret = synth->io_ops->synth_out(synth, ch); + if (!ret) { + schedule_timeout(msecs_to_jiffies(full_time_val)); + continue; + } + if (time_after_eq(jiffies, jiff_max) && (ch == SPACE)) { + spin_lock_irqsave(&speakup_info.spinlock, flags); + jiffy_delta_val = jiffy_delta->u.n.value; + delay_time_val = delay_time->u.n.value; + full_time_val = full_time->u.n.value; + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (synth->io_ops->synth_out(synth, synth->procspeech)) + schedule_timeout( + msecs_to_jiffies(delay_time_val)); + else + schedule_timeout( + msecs_to_jiffies(full_time_val)); + jiff_max = jiffies + jiffy_delta_val; + } + set_current_state(TASK_RUNNING); + spin_lock_irqsave(&speakup_info.spinlock, flags); + synth_buffer_getc(); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + } + synth->io_ops->synth_out(synth, synth->procspeech); +} + +void spk_do_catch_up(struct spk_synth *synth) +{ + _spk_do_catch_up(synth, 0); +} +EXPORT_SYMBOL_GPL(spk_do_catch_up); + +void spk_do_catch_up_unicode(struct spk_synth *synth) +{ + _spk_do_catch_up(synth, 1); +} +EXPORT_SYMBOL_GPL(spk_do_catch_up_unicode); + +void spk_synth_flush(struct spk_synth *synth) +{ + synth->io_ops->flush_buffer(); + synth->io_ops->synth_out(synth, synth->clear); +} +EXPORT_SYMBOL_GPL(spk_synth_flush); + +unsigned char spk_synth_get_index(struct spk_synth *synth) +{ + return synth->io_ops->synth_in_nowait(); +} +EXPORT_SYMBOL_GPL(spk_synth_get_index); + +int spk_synth_is_alive_nop(struct spk_synth *synth) +{ + synth->alive = 1; + return 1; +} +EXPORT_SYMBOL_GPL(spk_synth_is_alive_nop); + +int spk_synth_is_alive_restart(struct spk_synth *synth) +{ + if (synth->alive) + return 1; + if (spk_wait_for_xmitr(synth) > 0) { + /* restart */ + synth->alive = 1; + synth_printf("%s", synth->init); + return 2; /* reenabled */ + } + pr_warn("%s: can't restart synth\n", synth->long_name); + return 0; +} +EXPORT_SYMBOL_GPL(spk_synth_is_alive_restart); + +static void thread_wake_up(struct timer_list *unused) +{ + wake_up_interruptible_all(&speakup_event); +} + +static DEFINE_TIMER(thread_timer, thread_wake_up); + +void synth_start(void) +{ + struct var_t *trigger_time; + + if (!synth->alive) { + synth_buffer_clear(); + return; + } + trigger_time = spk_get_var(TRIGGER); + if (!timer_pending(&thread_timer)) + mod_timer(&thread_timer, jiffies + + msecs_to_jiffies(trigger_time->u.n.value)); +} + +void spk_do_flush(void) +{ + if (!synth) + return; + + speakup_info.flushing = 1; + synth_buffer_clear(); + if (synth->alive) { + if (spk_pitch_shift) { + synth_printf("%s", spk_pitch_buff); + spk_pitch_shift = 0; + } + } + wake_up_interruptible_all(&speakup_event); + wake_up_process(speakup_task); +} + +void synth_write(const char *buf, size_t count) +{ + while (count--) + synth_buffer_add(*buf++); + synth_start(); +} + +void synth_printf(const char *fmt, ...) +{ + va_list args; + unsigned char buf[160], *p; + int r; + + va_start(args, fmt); + r = vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + if (r > sizeof(buf) - 1) + r = sizeof(buf) - 1; + + p = buf; + while (r--) + synth_buffer_add(*p++); + synth_start(); +} +EXPORT_SYMBOL_GPL(synth_printf); + +void synth_putwc(u16 wc) +{ + synth_buffer_add(wc); +} +EXPORT_SYMBOL_GPL(synth_putwc); + +void synth_putwc_s(u16 wc) +{ + synth_buffer_add(wc); + synth_start(); +} +EXPORT_SYMBOL_GPL(synth_putwc_s); + +void synth_putws(const u16 *buf) +{ + const u16 *p; + + for (p = buf; *p; p++) + synth_buffer_add(*p); +} +EXPORT_SYMBOL_GPL(synth_putws); + +void synth_putws_s(const u16 *buf) +{ + synth_putws(buf); + synth_start(); +} +EXPORT_SYMBOL_GPL(synth_putws_s); + +static int index_count; +static int sentence_count; + +void spk_reset_index_count(int sc) +{ + static int first = 1; + + if (first) + first = 0; + else + synth->get_index(synth); + index_count = 0; + sentence_count = sc; +} + +int synth_supports_indexing(void) +{ + if (synth->get_index) + return 1; + return 0; +} + +void synth_insert_next_index(int sent_num) +{ + int out; + + if (synth->alive) { + if (sent_num == 0) { + synth->indexing.currindex++; + index_count++; + if (synth->indexing.currindex > + synth->indexing.highindex) + synth->indexing.currindex = + synth->indexing.lowindex; + } + + out = synth->indexing.currindex * 10 + sent_num; + synth_printf(synth->indexing.command, out, out); + } +} + +void spk_get_index_count(int *linecount, int *sentcount) +{ + int ind = synth->get_index(synth); + + if (ind) { + sentence_count = ind % 10; + + if ((ind / 10) <= synth->indexing.currindex) + index_count = synth->indexing.currindex - (ind / 10); + else + index_count = synth->indexing.currindex + - synth->indexing.lowindex + + synth->indexing.highindex - (ind / 10) + 1; + } + *sentcount = sentence_count; + *linecount = index_count; +} + +static struct resource synth_res; + +int synth_request_region(unsigned long start, unsigned long n) +{ + struct resource *parent = &ioport_resource; + + memset(&synth_res, 0, sizeof(synth_res)); + synth_res.name = synth->name; + synth_res.start = start; + synth_res.end = start + n - 1; + synth_res.flags = IORESOURCE_BUSY; + return request_resource(parent, &synth_res); +} +EXPORT_SYMBOL_GPL(synth_request_region); + +int synth_release_region(unsigned long start, unsigned long n) +{ + return release_resource(&synth_res); +} +EXPORT_SYMBOL_GPL(synth_release_region); + +struct var_t synth_time_vars[] = { + { DELAY, .u.n = {NULL, 100, 100, 2000, 0, 0, NULL } }, + { TRIGGER, .u.n = {NULL, 20, 10, 2000, 0, 0, NULL } }, + { JIFFY, .u.n = {NULL, 50, 20, 200, 0, 0, NULL } }, + { FULL, .u.n = {NULL, 400, 200, 60000, 0, 0, NULL } }, + V_LAST_VAR +}; + +/* called by: speakup_init() */ +int synth_init(char *synth_name) +{ + int ret = 0; + struct spk_synth *tmp, *synth = NULL; + + if (!synth_name) + return 0; + + if (strcmp(synth_name, "none") == 0) { + mutex_lock(&spk_mutex); + synth_release(); + mutex_unlock(&spk_mutex); + return 0; + } + + mutex_lock(&spk_mutex); + /* First, check if we already have it loaded. */ + list_for_each_entry(tmp, &synths, node) { + if (strcmp(tmp->name, synth_name) == 0) + synth = tmp; + } + + /* If we got one, initialize it now. */ + if (synth) + ret = do_synth_init(synth); + else + ret = -ENODEV; + mutex_unlock(&spk_mutex); + + return ret; +} + +/* called by: synth_add() */ +static int do_synth_init(struct spk_synth *in_synth) +{ + struct var_t *var; + + synth_release(); + if (in_synth->checkval != SYNTH_CHECK) + return -EINVAL; + synth = in_synth; + synth->alive = 0; + pr_warn("synth probe\n"); + if (synth->probe(synth) < 0) { + pr_warn("%s: device probe failed\n", in_synth->name); + synth = NULL; + return -ENODEV; + } + synth_time_vars[0].u.n.value = + synth_time_vars[0].u.n.default_val = synth->delay; + synth_time_vars[1].u.n.value = + synth_time_vars[1].u.n.default_val = synth->trigger; + synth_time_vars[2].u.n.value = + synth_time_vars[2].u.n.default_val = synth->jiffies; + synth_time_vars[3].u.n.value = + synth_time_vars[3].u.n.default_val = synth->full; + synth_printf("%s", synth->init); + for (var = synth->vars; + (var->var_id >= 0) && (var->var_id < MAXVARS); var++) + speakup_register_var(var); + if (!spk_quiet_boot) + synth_printf("%s found\n", synth->long_name); + if (synth->attributes.name && + sysfs_create_group(speakup_kobj, &synth->attributes) < 0) + return -ENOMEM; + synth_flags = synth->flags; + wake_up_interruptible_all(&speakup_event); + if (speakup_task) + wake_up_process(speakup_task); + return 0; +} + +void synth_release(void) +{ + struct var_t *var; + unsigned long flags; + + if (!synth) + return; + spin_lock_irqsave(&speakup_info.spinlock, flags); + pr_info("releasing synth %s\n", synth->name); + synth->alive = 0; + del_timer(&thread_timer); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (synth->attributes.name) + sysfs_remove_group(speakup_kobj, &synth->attributes); + for (var = synth->vars; var->var_id != MAXVARS; var++) + speakup_unregister_var(var->var_id); + synth->release(); + synth = NULL; +} + +/* called by: all_driver_init() */ +int synth_add(struct spk_synth *in_synth) +{ + int status = 0; + struct spk_synth *tmp; + + mutex_lock(&spk_mutex); + + list_for_each_entry(tmp, &synths, node) { + if (tmp == in_synth) { + mutex_unlock(&spk_mutex); + return 0; + } + } + + if (in_synth->startup) + status = do_synth_init(in_synth); + + if (!status) + list_add_tail(&in_synth->node, &synths); + + mutex_unlock(&spk_mutex); + return status; +} +EXPORT_SYMBOL_GPL(synth_add); + +void synth_remove(struct spk_synth *in_synth) +{ + mutex_lock(&spk_mutex); + if (synth == in_synth) + synth_release(); + list_del(&in_synth->node); + module_status = 0; + mutex_unlock(&spk_mutex); +} +EXPORT_SYMBOL_GPL(synth_remove); + +struct spk_synth *synth_current(void) +{ + return synth; +} +EXPORT_SYMBOL_GPL(synth_current); + +short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC | B_SYM }; diff --git a/drivers/accessibility/speakup/thread.c b/drivers/accessibility/speakup/thread.c new file mode 100644 index 000000000000..2fc75e60fbac --- /dev/null +++ b/drivers/accessibility/speakup/thread.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include + +#include "spk_types.h" +#include "speakup.h" +#include "spk_priv.h" + +DECLARE_WAIT_QUEUE_HEAD(speakup_event); +EXPORT_SYMBOL_GPL(speakup_event); + +int speakup_thread(void *data) +{ + unsigned long flags; + int should_break; + struct bleep our_sound; + + our_sound.active = 0; + our_sound.freq = 0; + our_sound.jiffies = 0; + + mutex_lock(&spk_mutex); + while (1) { + DEFINE_WAIT(wait); + + while (1) { + spin_lock_irqsave(&speakup_info.spinlock, flags); + our_sound = spk_unprocessed_sound; + spk_unprocessed_sound.active = 0; + prepare_to_wait(&speakup_event, &wait, + TASK_INTERRUPTIBLE); + should_break = kthread_should_stop() || + our_sound.active || + (synth && synth->catch_up && synth->alive && + (speakup_info.flushing || + !synth_buffer_empty())); + spin_unlock_irqrestore(&speakup_info.spinlock, flags); + if (should_break) + break; + mutex_unlock(&spk_mutex); + schedule(); + mutex_lock(&spk_mutex); + } + finish_wait(&speakup_event, &wait); + if (kthread_should_stop()) + break; + + if (our_sound.active) + kd_mksound(our_sound.freq, our_sound.jiffies); + if (synth && synth->catch_up && synth->alive) { + /* + * It is up to the callee to take the lock, so that it + * can sleep whenever it likes + */ + synth->catch_up(synth); + } + + speakup_start_ttys(); + } + mutex_unlock(&spk_mutex); + return 0; +} diff --git a/drivers/accessibility/speakup/varhandlers.c b/drivers/accessibility/speakup/varhandlers.c new file mode 100644 index 000000000000..d7f6bec7ff06 --- /dev/null +++ b/drivers/accessibility/speakup/varhandlers.c @@ -0,0 +1,339 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include "spk_types.h" +#include "spk_priv.h" +#include "speakup.h" + +static struct st_var_header var_headers[] = { + { "version", VERSION, VAR_PROC, NULL, NULL }, + { "synth_name", SYNTH, VAR_PROC, NULL, NULL }, + { "keymap", KEYMAP, VAR_PROC, NULL, NULL }, + { "silent", SILENT, VAR_PROC, NULL, NULL }, + { "punc_some", PUNC_SOME, VAR_PROC, NULL, NULL }, + { "punc_most", PUNC_MOST, VAR_PROC, NULL, NULL }, + { "punc_all", PUNC_ALL, VAR_PROC, NULL, NULL }, + { "delimiters", DELIM, VAR_PROC, NULL, NULL }, + { "repeats", REPEATS, VAR_PROC, NULL, NULL }, + { "ex_num", EXNUMBER, VAR_PROC, NULL, NULL }, + { "characters", CHARS, VAR_PROC, NULL, NULL }, + { "synth_direct", SYNTH_DIRECT, VAR_PROC, NULL, NULL }, + { "caps_start", CAPS_START, VAR_STRING, spk_str_caps_start, NULL }, + { "caps_stop", CAPS_STOP, VAR_STRING, spk_str_caps_stop, NULL }, + { "delay_time", DELAY, VAR_TIME, NULL, NULL }, + { "trigger_time", TRIGGER, VAR_TIME, NULL, NULL }, + { "jiffy_delta", JIFFY, VAR_TIME, NULL, NULL }, + { "full_time", FULL, VAR_TIME, NULL, NULL }, + { "spell_delay", SPELL_DELAY, VAR_NUM, &spk_spell_delay, NULL }, + { "bleeps", BLEEPS, VAR_NUM, &spk_bleeps, NULL }, + { "attrib_bleep", ATTRIB_BLEEP, VAR_NUM, &spk_attrib_bleep, NULL }, + { "bleep_time", BLEEP_TIME, VAR_TIME, &spk_bleep_time, NULL }, + { "cursor_time", CURSOR_TIME, VAR_TIME, NULL, NULL }, + { "punc_level", PUNC_LEVEL, VAR_NUM, &spk_punc_level, NULL }, + { "reading_punc", READING_PUNC, VAR_NUM, &spk_reading_punc, NULL }, + { "say_control", SAY_CONTROL, VAR_NUM, &spk_say_ctrl, NULL }, + { "say_word_ctl", SAY_WORD_CTL, VAR_NUM, &spk_say_word_ctl, NULL }, + { "no_interrupt", NO_INTERRUPT, VAR_NUM, &spk_no_intr, NULL }, + { "key_echo", KEY_ECHO, VAR_NUM, &spk_key_echo, NULL }, + { "bell_pos", BELL_POS, VAR_NUM, &spk_bell_pos, NULL }, + { "rate", RATE, VAR_NUM, NULL, NULL }, + { "pitch", PITCH, VAR_NUM, NULL, NULL }, + { "inflection", INFLECTION, VAR_NUM, NULL, NULL }, + { "vol", VOL, VAR_NUM, NULL, NULL }, + { "tone", TONE, VAR_NUM, NULL, NULL }, + { "punct", PUNCT, VAR_NUM, NULL, NULL }, + { "voice", VOICE, VAR_NUM, NULL, NULL }, + { "freq", FREQUENCY, VAR_NUM, NULL, NULL }, + { "lang", LANG, VAR_NUM, NULL, NULL }, + { "chartab", CHARTAB, VAR_PROC, NULL, NULL }, + { "direct", DIRECT, VAR_NUM, NULL, NULL }, + { "pause", PAUSE, VAR_STRING, spk_str_pause, NULL }, +}; + +static struct st_var_header *var_ptrs[MAXVARS] = { NULL, NULL, NULL }; + +static struct punc_var_t punc_vars[] = { + { PUNC_SOME, 1 }, + { PUNC_MOST, 2 }, + { PUNC_ALL, 3 }, + { DELIM, 4 }, + { REPEATS, 5 }, + { EXNUMBER, 6 }, + { -1, -1 }, +}; + +int spk_chartab_get_value(char *keyword) +{ + int value = 0; + + if (!strcmp(keyword, "ALPHA")) + value = ALPHA; + else if (!strcmp(keyword, "B_CTL")) + value = B_CTL; + else if (!strcmp(keyword, "WDLM")) + value = WDLM; + else if (!strcmp(keyword, "A_PUNC")) + value = A_PUNC; + else if (!strcmp(keyword, "PUNC")) + value = PUNC; + else if (!strcmp(keyword, "NUM")) + value = NUM; + else if (!strcmp(keyword, "A_CAP")) + value = A_CAP; + else if (!strcmp(keyword, "B_CAPSYM")) + value = B_CAPSYM; + else if (!strcmp(keyword, "B_SYM")) + value = B_SYM; + return value; +} + +void speakup_register_var(struct var_t *var) +{ + static char nothing[2] = "\0"; + int i; + struct st_var_header *p_header; + + BUG_ON(!var || var->var_id < 0 || var->var_id >= MAXVARS); + if (!var_ptrs[0]) { + for (i = 0; i < MAXVARS; i++) { + p_header = &var_headers[i]; + var_ptrs[p_header->var_id] = p_header; + p_header->data = NULL; + } + } + p_header = var_ptrs[var->var_id]; + if (p_header->data) + return; + p_header->data = var; + switch (p_header->var_type) { + case VAR_STRING: + spk_set_string_var(nothing, p_header, 0); + break; + case VAR_NUM: + case VAR_TIME: + spk_set_num_var(0, p_header, E_DEFAULT); + break; + default: + break; + } +} + +void speakup_unregister_var(enum var_id_t var_id) +{ + struct st_var_header *p_header; + + BUG_ON(var_id < 0 || var_id >= MAXVARS); + p_header = var_ptrs[var_id]; + p_header->data = NULL; +} + +struct st_var_header *spk_get_var_header(enum var_id_t var_id) +{ + struct st_var_header *p_header; + + if (var_id < 0 || var_id >= MAXVARS) + return NULL; + p_header = var_ptrs[var_id]; + if (!p_header->data) + return NULL; + return p_header; +} + +struct st_var_header *spk_var_header_by_name(const char *name) +{ + int i; + + if (!name) + return NULL; + + for (i = 0; i < MAXVARS; i++) { + if (strcmp(name, var_ptrs[i]->name) == 0) + return var_ptrs[i]; + } + return NULL; +} + +struct var_t *spk_get_var(enum var_id_t var_id) +{ + BUG_ON(var_id < 0 || var_id >= MAXVARS); + BUG_ON(!var_ptrs[var_id]); + return var_ptrs[var_id]->data; +} +EXPORT_SYMBOL_GPL(spk_get_var); + +struct punc_var_t *spk_get_punc_var(enum var_id_t var_id) +{ + struct punc_var_t *rv = NULL; + struct punc_var_t *where; + + where = punc_vars; + while ((where->var_id != -1) && (!rv)) { + if (where->var_id == var_id) + rv = where; + else + where++; + } + return rv; +} + +/* handlers for setting vars */ +int spk_set_num_var(int input, struct st_var_header *var, int how) +{ + int val; + int *p_val = var->p_val; + char buf[32]; + char *cp; + struct var_t *var_data = var->data; + + if (!var_data) + return -ENODATA; + + val = var_data->u.n.value; + switch (how) { + case E_NEW_DEFAULT: + if (input < var_data->u.n.low || input > var_data->u.n.high) + return -ERANGE; + var_data->u.n.default_val = input; + return 0; + case E_DEFAULT: + val = var_data->u.n.default_val; + break; + case E_SET: + val = input; + break; + case E_INC: + val += input; + break; + case E_DEC: + val -= input; + break; + } + + if (val < var_data->u.n.low || val > var_data->u.n.high) + return -ERANGE; + + var_data->u.n.value = val; + if (var->var_type == VAR_TIME && p_val) { + *p_val = msecs_to_jiffies(val); + return 0; + } + if (p_val) + *p_val = val; + if (var->var_id == PUNC_LEVEL) { + spk_punc_mask = spk_punc_masks[val]; + return 0; + } + if (var_data->u.n.multiplier != 0) + val *= var_data->u.n.multiplier; + val += var_data->u.n.offset; + if (var->var_id < FIRST_SYNTH_VAR || !synth) + return 0; + if (synth->synth_adjust) + return synth->synth_adjust(var); + + if (!var_data->u.n.synth_fmt) + return 0; + if (var->var_id == PITCH) + cp = spk_pitch_buff; + else + cp = buf; + if (!var_data->u.n.out_str) + sprintf(cp, var_data->u.n.synth_fmt, (int)val); + else + sprintf(cp, var_data->u.n.synth_fmt, + var_data->u.n.out_str[val]); + synth_printf("%s", cp); + return 0; +} + +int spk_set_string_var(const char *page, struct st_var_header *var, int len) +{ + struct var_t *var_data = var->data; + + if (!var_data) + return -ENODATA; + if (len > MAXVARLEN) + return -E2BIG; + if (!len) { + if (!var_data->u.s.default_val) + return 0; + if (!var->p_val) + var->p_val = var_data->u.s.default_val; + if (var->p_val != var_data->u.s.default_val) + strcpy((char *)var->p_val, var_data->u.s.default_val); + return -ERESTART; + } else if (var->p_val) { + strcpy((char *)var->p_val, page); + } else { + return -E2BIG; + } + return 0; +} + +/* + * spk_set_mask_bits sets or clears the punc/delim/repeat bits, + * if input is null uses the defaults. + * values for how: 0 clears bits of chars supplied, + * 1 clears allk, 2 sets bits for chars + */ +int spk_set_mask_bits(const char *input, const int which, const int how) +{ + u_char *cp; + short mask = spk_punc_info[which].mask; + + if (how & 1) { + for (cp = (u_char *)spk_punc_info[3].value; *cp; cp++) + spk_chartab[*cp] &= ~mask; + } + cp = (u_char *)input; + if (!cp) { + cp = spk_punc_info[which].value; + } else { + for (; *cp; cp++) { + if (*cp < SPACE) + break; + if (mask < PUNC) { + if (!(spk_chartab[*cp] & PUNC)) + break; + } else if (spk_chartab[*cp] & B_NUM) { + break; + } + } + if (*cp) + return -EINVAL; + cp = (u_char *)input; + } + if (how & 2) { + for (; *cp; cp++) + if (*cp > SPACE) + spk_chartab[*cp] |= mask; + } else { + for (; *cp; cp++) + if (*cp > SPACE) + spk_chartab[*cp] &= ~mask; + } + return 0; +} + +char *spk_strlwr(char *s) +{ + char *p; + + if (!s) + return NULL; + + for (p = s; *p; p++) + *p = tolower(*p); + return s; +} + +char *spk_s2uchar(char *start, char *dest) +{ + int val; + + /* Do not replace with kstrtoul: here we need start to be updated */ + val = simple_strtoul(skip_spaces(start), &start, 10); + if (*start == ',') + start++; + *dest = (u_char)val; + return start; +} diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index b3fb4d41e231..e6c831c6cccc 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -56,8 +56,6 @@ source "drivers/staging/sm750fb/Kconfig" source "drivers/staging/emxx_udc/Kconfig" -source "drivers/staging/speakup/Kconfig" - source "drivers/staging/nvec/Kconfig" source "drivers/staging/media/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 3d8c7ea21a10..a3b1fd0622f9 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -20,7 +20,6 @@ obj-$(CONFIG_VME_BUS) += vme/ obj-$(CONFIG_IIO) += iio/ obj-$(CONFIG_FB_SM750) += sm750fb/ obj-$(CONFIG_USB_EMXX) += emxx_udc/ -obj-$(CONFIG_SPEAKUP) += speakup/ obj-$(CONFIG_MFD_NVEC) += nvec/ obj-$(CONFIG_ANDROID) += android/ obj-$(CONFIG_STAGING_BOARD) += board/ diff --git a/drivers/staging/speakup/DefaultKeyAssignments b/drivers/staging/speakup/DefaultKeyAssignments deleted file mode 100644 index 101c803b21fd..000000000000 --- a/drivers/staging/speakup/DefaultKeyAssignments +++ /dev/null @@ -1,46 +0,0 @@ -This file is intended to give you an overview of the default keys used -by speakup for it's review functions. You may change them to be -anything you want but that will take some familiarity with key -mapping. - -We have remapped the insert or zero key on the keypad to act as a -shift key. Well, actually as an altgr key. So in the following list -InsKeyPad-period means hold down the insert key like a shift key and -hit the keypad period. - -KeyPad-8 Say current Line -InsKeyPad-8 say from top of screen to reading cursor. -KeyPad-7 Say Previous Line (UP one line) -KeyPad-9 Say Next Line (down one line) -KeyPad-5 Say Current Word -InsKeyPad-5 Spell Current Word -KeyPad-4 Say Previous Word (left one word) -InsKeyPad-4 say from left edge of line to reading cursor. -KeyPad-6 Say Next Word (right one word) -InsKeyPad-6 Say from reading cursor to right edge of line. -KeyPad-2 Say Current Letter -InsKeyPad-2 say current letter phonetically -KeyPad-1 Say Previous Character (left one letter) -KeyPad-3 Say Next Character (right one letter) -KeyPad-plus Say Entire Screen -InsKeyPad-plus Say from reading cursor line to bottom of screen. -KeyPad-Minus Park reading cursor (toggle) -InsKeyPad-minus Say character hex and decimal value. -KeyPad-period Say Position (current line, position and console) -InsKeyPad-period say colour attributes of current position. -InsKeyPad-9 Move reading cursor to top of screen (insert pgup) -InsKeyPad-3 Move reading cursor to bottom of screen (insert pgdn) -InsKeyPad-7 Move reading cursor to left edge of screen (insert home) -InsKeyPad-1 Move reading cursor to right edge of screen (insert end) -ControlKeyPad-1 Move reading cursor to last character on current line. -KeyPad-Enter Shut Up (until another key is hit) and sync reading cursor -InsKeyPad-Enter Shut Up (until toggled back on). -InsKeyPad-star n go to line (y) or column (x). Where 'n' is any - allowed value for the row or column for your current screen. -KeyPad-/ Mark and Cut screen region. -InsKeyPad-/ Paste screen region into any console. - -Hitting any key while speakup is outputting speech will quiet the -synth until it has caught up with what is being printed on the -console. - diff --git a/drivers/staging/speakup/Kconfig b/drivers/staging/speakup/Kconfig deleted file mode 100644 index 0803c2013cf4..000000000000 --- a/drivers/staging/speakup/Kconfig +++ /dev/null @@ -1,200 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -menu "Speakup console speech" - -config SPEAKUP - depends on VT - tristate "Speakup core" - help - This is the Speakup screen reader. Think of it as a - video console for blind people. If built in to the - kernel, it can speak everything on the text console from - boot up to shutdown. For more information on Speakup, - point your browser at . - There is also a mailing list at the above url that you - can subscribe to. - - Supported synthesizers are accent sa, accent pc, - appollo II., Auddapter, Braille 'n Speak, Dectalk - external (old), Dectalk PC (full length isa board), - Dectalk express, Doubletalk, Doubletalk LT or - Litetalk, Keynote Gold internal PC, software - synthesizers, Speakout, transport, and a dummy module - that can be used with a plain text terminal. - - Speakup can either be built in or compiled as a module - by answering y or m. If you answer y here, then you - must answer either y or m to at least one of the - synthesizer drivers below. If you answer m here, then - the synthesizer drivers below can only be built as - modules. - - These drivers are not standalone drivers, but must be - used in conjunction with Speakup. Think of them as - video cards for blind people. - - - The Dectalk pc driver can only be built as a module, and - requires software to be pre-loaded on to the card before - the module can be loaded. See the decpc choice below - for more details. - - If you are not a blind person, or don't have access to - one of the listed synthesizers, you should say n. - -if SPEAKUP -config SPEAKUP_SYNTH_ACNTSA - tristate "Accent SA synthesizer support" - help - This is the Speakup driver for the Accent SA - synthesizer. You can say y to build it into the kernel, - or m to build it as a module. See the configuration - help on the Speakup choice above for more info. - -config SPEAKUP_SYNTH_ACNTPC - tristate "Accent PC synthesizer support" - depends on ISA || COMPILE_TEST - help - This is the Speakup driver for the accent pc - synthesizer. You can say y to build it into the kernel, - or m to build it as a module. See the configuration - help on the Speakup choice above for more info. - -config SPEAKUP_SYNTH_APOLLO - tristate "Apollo II synthesizer support" - help - This is the Speakup driver for the Apollo II - synthesizer. You can say y to build it into the kernel, - or m to build it as a module. See the configuration - help on the Speakup choice above for more info. - -config SPEAKUP_SYNTH_AUDPTR - tristate "Audapter synthesizer support" - help - This is the Speakup driver for the Audapter synthesizer. - You can say y to build it into the kernel, or m to - build it as a module. See the configuration help on the - Speakup choice above for more info. - -config SPEAKUP_SYNTH_BNS - tristate "Braille 'n' Speak synthesizer support" - help - This is the Speakup driver for the Braille 'n' Speak - synthesizer. You can say y to build it into the kernel, - or m to build it as a module. See the configuration - help on the Speakup choice above for more info. - -config SPEAKUP_SYNTH_DECTLK - tristate "DECtalk Express synthesizer support" - help - - This is the Speakup driver for the DecTalk Express - synthesizer. You can say y to build it into the kernel, - or m to build it as a module. See the configuration - help on the Speakup choice above for more info. - -config SPEAKUP_SYNTH_DECEXT - tristate "DECtalk External (old) synthesizer support" - help - - This is the Speakup driver for the DecTalk External - (old) synthesizer. You can say y to build it into the - kernel, or m to build it as a module. See the - configuration help on the Speakup choice above for more - info. - -config SPEAKUP_SYNTH_DECPC - depends on m - depends on ISA || COMPILE_TEST - tristate "DECtalk PC (big ISA card) synthesizer support" - help - - This is the Speakup driver for the DecTalk PC (full - length ISA) synthesizer. You can say m to build it as - a module. See the configuration help on the Speakup - choice above for more info. - - In order to use the DecTalk PC driver, you must download - the dec_pc.tgz file from linux-speakup.org. It is in - the pub/linux/goodies directory. The dec_pc.tgz file - contains the software which must be pre-loaded on to the - DecTalk PC board in order to use it with this driver. - This driver must be built as a module, and can not be - loaded until the file system is mounted and the DecTalk - PC software has been pre-loaded on to the board. - - See the README file in the dec_pc.tgz file for more - details. - -config SPEAKUP_SYNTH_DTLK - tristate "DoubleTalk PC synthesizer support" - depends on ISA || COMPILE_TEST - help - - This is the Speakup driver for the internal DoubleTalk - PC synthesizer. You can say y to build it into the - kernel, or m to build it as a module. See the - configuration help on the Speakup choice above for more - info. - -config SPEAKUP_SYNTH_KEYPC - tristate "Keynote Gold PC synthesizer support" - depends on ISA || COMPILE_TEST - help - - This is the Speakup driver for the Keynote Gold - PC synthesizer. You can say y to build it into the - kernel, or m to build it as a module. See the - configuration help on the Speakup choice above for more - info. - -config SPEAKUP_SYNTH_LTLK - tristate "DoubleTalk LT/LiteTalk synthesizer support" -help - - This is the Speakup driver for the LiteTalk/DoubleTalk - LT synthesizer. You can say y to build it into the - kernel, or m to build it as a module. See the - configuration help on the Speakup choice above for more - info. - -config SPEAKUP_SYNTH_SOFT - tristate "Userspace software synthesizer support" - help - - This is the software synthesizer device node. It will - register a device /dev/softsynth which midware programs - and speech daemons may open and read to provide kernel - output to software synths such as espeak, festival, - flite and so forth. You can select 'y' or 'm' to have - it built-in to the kernel or loaded as a module. - -config SPEAKUP_SYNTH_SPKOUT - tristate "Speak Out synthesizer support" - help - - This is the Speakup driver for the Speakout synthesizer. - You can say y to build it into the kernel, or m to - build it as a module. See the configuration help on the - Speakup choice above for more info. - -config SPEAKUP_SYNTH_TXPRT - tristate "Transport synthesizer support" - help - - This is the Speakup driver for the Transport - synthesizer. You can say y to build it into the kernel, - or m to build it as a module. See the configuration - help on the Speakup choice above for more info. - -config SPEAKUP_SYNTH_DUMMY - tristate "Dummy synthesizer driver (for testing)" - help - - This is a dummy Speakup driver for plugging a mere serial - terminal. This is handy if you want to test speakup but - don't have the hardware. You can say y to build it into - the kernel, or m to build it as a module. See the - configuration help on the Speakup choice above for more info. - -endif # SPEAKUP -endmenu diff --git a/drivers/staging/speakup/Makefile b/drivers/staging/speakup/Makefile deleted file mode 100644 index 5befb4933b85..000000000000 --- a/drivers/staging/speakup/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_SPEAKUP_SYNTH_ACNTSA) += speakup_acntsa.o -obj-$(CONFIG_SPEAKUP_SYNTH_ACNTPC) += speakup_acntpc.o -obj-$(CONFIG_SPEAKUP_SYNTH_APOLLO) += speakup_apollo.o -obj-$(CONFIG_SPEAKUP_SYNTH_AUDPTR) += speakup_audptr.o -obj-$(CONFIG_SPEAKUP_SYNTH_BNS) += speakup_bns.o -obj-$(CONFIG_SPEAKUP_SYNTH_DECTLK) += speakup_dectlk.o -obj-$(CONFIG_SPEAKUP_SYNTH_DECEXT) += speakup_decext.o -obj-$(CONFIG_SPEAKUP_SYNTH_DECPC) += speakup_decpc.o -obj-$(CONFIG_SPEAKUP_SYNTH_DTLK) += speakup_dtlk.o -obj-$(CONFIG_SPEAKUP_SYNTH_KEYPC) += speakup_keypc.o -obj-$(CONFIG_SPEAKUP_SYNTH_LTLK) += speakup_ltlk.o -obj-$(CONFIG_SPEAKUP_SYNTH_SOFT) += speakup_soft.o -obj-$(CONFIG_SPEAKUP_SYNTH_SPKOUT) += speakup_spkout.o -obj-$(CONFIG_SPEAKUP_SYNTH_TXPRT) += speakup_txprt.o -obj-$(CONFIG_SPEAKUP_SYNTH_DUMMY) += speakup_dummy.o - -obj-$(CONFIG_SPEAKUP) += speakup.o -speakup-y := \ - buffers.o \ - devsynth.o \ - i18n.o \ - fakekey.o \ - main.o \ - keyhelp.o \ - kobjects.o \ - selection.o \ - serialio.o \ - spk_ttyio.o \ - synth.o \ - thread.o \ - varhandlers.o diff --git a/drivers/staging/speakup/TODO b/drivers/staging/speakup/TODO deleted file mode 100644 index d4ca093bf0bd..000000000000 --- a/drivers/staging/speakup/TODO +++ /dev/null @@ -1,22 +0,0 @@ -Speakup project home: http://www.linux-speakup.org - -Mailing List: speakup@linux-speakup.org - -Speakup is a kernel based screen review package for the linux operating -system. It allows blind users to interact with applications on the -linux console by means of synthetic speech. - -Currently, speakup has one issue we know of. - -It seems to only happen on SMP systems. It seems that text in the output buffer -gets garbled because a lock is not set. This bug happens regularly, but no one -has been able to find a situation which produces it consistently. - -Patches, suggestions, corrections, etc, are definitely welcome. - -We prefer that you contact us on the mailing list; however, if you do -not want to subscribe to a mailing list, send your email to all of the -following: - -okash.khawaja@gmail.com, w.d.hubbs@gmail.com, chris@the-brannons.com, -kirk@reisers.ca and samuel.thibault@ens-lyon.org. diff --git a/drivers/staging/speakup/buffers.c b/drivers/staging/speakup/buffers.c deleted file mode 100644 index 1371ced2f5ca..000000000000 --- a/drivers/staging/speakup/buffers.c +++ /dev/null @@ -1,124 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include -#include - -#include "speakup.h" -#include "spk_priv.h" - -#define SYNTH_BUF_SIZE 8192 /* currently 8K bytes */ - -static u16 synth_buffer[SYNTH_BUF_SIZE]; /* guess what this is for! */ -static u16 *buff_in = synth_buffer; -static u16 *buff_out = synth_buffer; -static u16 *buffer_end = synth_buffer + SYNTH_BUF_SIZE - 1; - -/* These try to throttle applications by stopping the TTYs - * Note: we need to make sure that we will restart them eventually, which is - * usually not possible to do from the notifiers. TODO: it should be possible - * starting from linux 2.6.26. - * - * So we only stop when we know alive == 1 (else we discard the data anyway), - * and the alive synth will eventually call start_ttys from the thread context. - */ -void speakup_start_ttys(void) -{ - int i; - - for (i = 0; i < MAX_NR_CONSOLES; i++) { - if (speakup_console[i] && speakup_console[i]->tty_stopped) - continue; - if (vc_cons[i].d && vc_cons[i].d->port.tty) - start_tty(vc_cons[i].d->port.tty); - } -} -EXPORT_SYMBOL_GPL(speakup_start_ttys); - -static void speakup_stop_ttys(void) -{ - int i; - - for (i = 0; i < MAX_NR_CONSOLES; i++) - if (vc_cons[i].d && vc_cons[i].d->port.tty) - stop_tty(vc_cons[i].d->port.tty); -} - -static int synth_buffer_free(void) -{ - int chars_free; - - if (buff_in >= buff_out) - chars_free = SYNTH_BUF_SIZE - (buff_in - buff_out); - else - chars_free = buff_out - buff_in; - return chars_free; -} - -int synth_buffer_empty(void) -{ - return (buff_in == buff_out); -} -EXPORT_SYMBOL_GPL(synth_buffer_empty); - -void synth_buffer_add(u16 ch) -{ - if (!synth->alive) { - /* This makes sure that we won't stop TTYs if there is no synth - * to restart them - */ - return; - } - if (synth_buffer_free() <= 100) { - synth_start(); - speakup_stop_ttys(); - } - if (synth_buffer_free() <= 1) - return; - *buff_in++ = ch; - if (buff_in > buffer_end) - buff_in = synth_buffer; - /* We have written something to the speech synthesis, so we are not - * paused any more. - */ - spk_paused = false; -} - -u16 synth_buffer_getc(void) -{ - u16 ch; - - if (buff_out == buff_in) - return 0; - ch = *buff_out++; - if (buff_out > buffer_end) - buff_out = synth_buffer; - return ch; -} -EXPORT_SYMBOL_GPL(synth_buffer_getc); - -u16 synth_buffer_peek(void) -{ - if (buff_out == buff_in) - return 0; - return *buff_out; -} -EXPORT_SYMBOL_GPL(synth_buffer_peek); - -void synth_buffer_skip_nonlatin1(void) -{ - while (buff_out != buff_in) { - if (*buff_out < 0x100) - return; - buff_out++; - if (buff_out > buffer_end) - buff_out = synth_buffer; - } -} -EXPORT_SYMBOL_GPL(synth_buffer_skip_nonlatin1); - -void synth_buffer_clear(void) -{ - buff_in = synth_buffer; - buff_out = synth_buffer; -} -EXPORT_SYMBOL_GPL(synth_buffer_clear); diff --git a/drivers/staging/speakup/devsynth.c b/drivers/staging/speakup/devsynth.c deleted file mode 100644 index d30571663585..000000000000 --- a/drivers/staging/speakup/devsynth.c +++ /dev/null @@ -1,92 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include /* for misc_register, and MISC_DYNAMIC_MINOR */ -#include -#include - -#include "speakup.h" -#include "spk_priv.h" - -static int misc_registered; -static int dev_opened; - -static ssize_t speakup_file_write(struct file *fp, const char __user *buffer, - size_t nbytes, loff_t *ppos) -{ - size_t count = nbytes; - const char __user *ptr = buffer; - size_t bytes; - unsigned long flags; - u_char buf[256]; - - if (!synth) - return -ENODEV; - while (count > 0) { - bytes = min(count, sizeof(buf)); - if (copy_from_user(buf, ptr, bytes)) - return -EFAULT; - count -= bytes; - ptr += bytes; - spin_lock_irqsave(&speakup_info.spinlock, flags); - synth_write(buf, bytes); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - } - return (ssize_t)nbytes; -} - -static ssize_t speakup_file_read(struct file *fp, char __user *buf, - size_t nbytes, loff_t *ppos) -{ - return 0; -} - -static int speakup_file_open(struct inode *ip, struct file *fp) -{ - if (!synth) - return -ENODEV; - if (xchg(&dev_opened, 1)) - return -EBUSY; - return 0; -} - -static int speakup_file_release(struct inode *ip, struct file *fp) -{ - dev_opened = 0; - return 0; -} - -static const struct file_operations synth_fops = { - .read = speakup_file_read, - .write = speakup_file_write, - .open = speakup_file_open, - .release = speakup_file_release, -}; - -static struct miscdevice synth_device = { - .minor = MISC_DYNAMIC_MINOR, - .name = "synth", - .fops = &synth_fops, -}; - -void speakup_register_devsynth(void) -{ - if (misc_registered != 0) - return; -/* zero it so if register fails, deregister will not ref invalid ptrs */ - if (misc_register(&synth_device)) { - pr_warn("Couldn't initialize miscdevice /dev/synth.\n"); - } else { - pr_info("initialized device: /dev/synth, node (MAJOR %d, MINOR %d)\n", - MISC_MAJOR, synth_device.minor); - misc_registered = 1; - } -} - -void speakup_unregister_devsynth(void) -{ - if (!misc_registered) - return; - pr_info("speakup: unregistering synth device /dev/synth\n"); - misc_deregister(&synth_device); - misc_registered = 0; -} diff --git a/drivers/staging/speakup/fakekey.c b/drivers/staging/speakup/fakekey.c deleted file mode 100644 index cd029968462f..000000000000 --- a/drivers/staging/speakup/fakekey.c +++ /dev/null @@ -1,87 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* fakekey.c - * Functions for simulating keypresses. - * - * Copyright (C) 2010 the Speakup Team - */ -#include -#include -#include -#include -#include - -#include "speakup.h" - -#define PRESSED 1 -#define RELEASED 0 - -static DEFINE_PER_CPU(int, reporting_keystroke); - -static struct input_dev *virt_keyboard; - -int speakup_add_virtual_keyboard(void) -{ - int err; - - virt_keyboard = input_allocate_device(); - - if (!virt_keyboard) - return -ENOMEM; - - virt_keyboard->name = "Speakup"; - virt_keyboard->id.bustype = BUS_VIRTUAL; - virt_keyboard->phys = "speakup/input0"; - virt_keyboard->dev.parent = NULL; - - __set_bit(EV_KEY, virt_keyboard->evbit); - __set_bit(KEY_DOWN, virt_keyboard->keybit); - - err = input_register_device(virt_keyboard); - if (err) { - input_free_device(virt_keyboard); - virt_keyboard = NULL; - } - - return err; -} - -void speakup_remove_virtual_keyboard(void) -{ - if (virt_keyboard) { - input_unregister_device(virt_keyboard); - virt_keyboard = NULL; - } -} - -/* - * Send a simulated down-arrow to the application. - */ -void speakup_fake_down_arrow(void) -{ - unsigned long flags; - - /* disable keyboard interrupts */ - local_irq_save(flags); - /* don't change CPU */ - preempt_disable(); - - __this_cpu_write(reporting_keystroke, true); - input_report_key(virt_keyboard, KEY_DOWN, PRESSED); - input_report_key(virt_keyboard, KEY_DOWN, RELEASED); - input_sync(virt_keyboard); - __this_cpu_write(reporting_keystroke, false); - - /* reenable preemption */ - preempt_enable(); - /* reenable keyboard interrupts */ - local_irq_restore(flags); -} - -/* - * Are we handling a simulated keypress on the current CPU? - * Returns a boolean. - */ -bool speakup_fake_key_pressed(void) -{ - return this_cpu_read(reporting_keystroke); -} diff --git a/drivers/staging/speakup/i18n.c b/drivers/staging/speakup/i18n.c deleted file mode 100644 index ee240d36f947..000000000000 --- a/drivers/staging/speakup/i18n.c +++ /dev/null @@ -1,625 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Internationalization implementation. Includes definitions of English - * string arrays, and the i18n pointer. - */ - -#include /* For kmalloc. */ -#include -#include -#include -#include "speakup.h" -#include "spk_priv.h" - -static char *speakup_msgs[MSG_LAST_INDEX]; -static char *speakup_default_msgs[MSG_LAST_INDEX] = { - [MSG_BLANK] = "blank", - [MSG_IAM_ALIVE] = "I'm aLive!", - [MSG_YOU_KILLED_SPEAKUP] = "You killed speakup!", - [MSG_HEY_THATS_BETTER] = "hey. That's better!", - [MSG_YOU_TURNED_ME_OFF] = "You turned me off!", - [MSG_PARKED] = "parked!", - [MSG_UNPARKED] = "unparked!", - [MSG_MARK] = "mark", - [MSG_CUT] = "cut", - [MSG_MARK_CLEARED] = "mark, cleared", - [MSG_PASTE] = "paste", - [MSG_BRIGHT] = "bright", - [MSG_ON_BLINKING] = "on blinking", - [MSG_OFF] = "off", - [MSG_ON] = "on", - [MSG_NO_WINDOW] = "no window", - [MSG_CURSORING_OFF] = "cursoring off", - [MSG_CURSORING_ON] = "cursoring on", - [MSG_HIGHLIGHT_TRACKING] = "highlight tracking", - [MSG_READ_WINDOW] = "read windo", - [MSG_READ_ALL] = "read all", - [MSG_EDIT_DONE] = "edit done", - [MSG_WINDOW_ALREADY_SET] = "window already set, clear then reset", - [MSG_END_BEFORE_START] = "error end before start", - [MSG_WINDOW_CLEARED] = "window cleared", - [MSG_WINDOW_SILENCED] = "window silenced", - [MSG_WINDOW_SILENCE_DISABLED] = "window silence disabled", - [MSG_ERROR] = "error", - [MSG_GOTO_CANCELED] = "goto canceled", - [MSG_GOTO] = "go to?", - [MSG_LEAVING_HELP] = "leaving help", - [MSG_IS_UNASSIGNED] = "is unassigned", - [MSG_HELP_INFO] = - "press space to exit, up or down to scroll, or a letter to go to a command", - [MSG_EDGE_TOP] = "top,", - [MSG_EDGE_BOTTOM] = "bottom,", - [MSG_EDGE_LEFT] = "left,", - [MSG_EDGE_RIGHT] = "right,", - [MSG_NUMBER] = "number", - [MSG_SPACE] = "space", - [MSG_START] = "start", - [MSG_END] = "end", - [MSG_CTRL] = "control-", - [MSG_DISJUNCTION] = "or", - -/* Messages with embedded format specifiers. */ - [MSG_POS_INFO] = "line %ld, col %ld, t t y %d", - [MSG_CHAR_INFO] = "hex %02x, decimal %d", - [MSG_REPEAT_DESC] = "times %d .", - [MSG_REPEAT_DESC2] = "repeated %d .", - [MSG_WINDOW_LINE] = "window is line %d", - [MSG_WINDOW_BOUNDARY] = "%s at line %d, column %d", - [MSG_EDIT_PROMPT] = "edit %s, press space when done", - [MSG_NO_COMMAND] = "no commands for %c", - [MSG_KEYDESC] = "is %s", - - /* Control keys. */ - /* Most of these duplicate the entries in state names. */ - [MSG_CTL_SHIFT] = "shift", - [MSG_CTL_ALTGR] = "altgr", - [MSG_CTL_CONTROL] = "control", - [MSG_CTL_ALT] = "alt", - [MSG_CTL_LSHIFT] = "l shift", - [MSG_CTL_SPEAKUP] = "speakup", - [MSG_CTL_LCONTROL] = "l control", - [MSG_CTL_RCONTROL] = "r control", - [MSG_CTL_CAPSSHIFT] = "caps shift", - - /* Color names. */ - [MSG_COLOR_BLACK] = "black", - [MSG_COLOR_BLUE] = "blue", - [MSG_COLOR_GREEN] = "green", - [MSG_COLOR_CYAN] = "cyan", - [MSG_COLOR_RED] = "red", - [MSG_COLOR_MAGENTA] = "magenta", - [MSG_COLOR_YELLOW] = "yellow", - [MSG_COLOR_WHITE] = "white", - [MSG_COLOR_GREY] = "grey", - - /* Names of key states. */ - [MSG_STATE_DOUBLE] = "double", - [MSG_STATE_SPEAKUP] = "speakup", - [MSG_STATE_ALT] = "alt", - [MSG_STATE_CONTROL] = "ctrl", - [MSG_STATE_ALTGR] = "altgr", - [MSG_STATE_SHIFT] = "shift", - - /* Key names. */ - [MSG_KEYNAME_ESC] = "escape", - [MSG_KEYNAME_1] = "1", - [MSG_KEYNAME_2] = "2", - [MSG_KEYNAME_3] = "3", - [MSG_KEYNAME_4] = "4", - [MSG_KEYNAME_5] = "5", - [MSG_KEYNAME_6] = "6", - [MSG_KEYNAME_7] = "7", - [MSG_KEYNAME_8] = "8", - [MSG_KEYNAME_9] = "9", - [MSG_KEYNAME_0] = "0", - [MSG_KEYNAME_DASH] = "minus", - [MSG_KEYNAME_EQUAL] = "equal", - [MSG_KEYNAME_BS] = "back space", - [MSG_KEYNAME_TAB] = "tab", - [MSG_KEYNAME_Q] = "q", - [MSG_KEYNAME_W] = "w", - [MSG_KEYNAME_E] = "e", - [MSG_KEYNAME_R] = "r", - [MSG_KEYNAME_T] = "t", - [MSG_KEYNAME_Y] = "y", - [MSG_KEYNAME_U] = "u", - [MSG_KEYNAME_I] = "i", - [MSG_KEYNAME_O] = "o", - [MSG_KEYNAME_P] = "p", - [MSG_KEYNAME_LEFTBRACE] = "left brace", - [MSG_KEYNAME_RIGHTBRACE] = "right brace", - [MSG_KEYNAME_ENTER] = "enter", - [MSG_KEYNAME_LEFTCTRL] = "left control", - [MSG_KEYNAME_A] = "a", - [MSG_KEYNAME_S] = "s", - [MSG_KEYNAME_D] = "d", - [MSG_KEYNAME_F] = "f", - [MSG_KEYNAME_G] = "g", - [MSG_KEYNAME_H] = "h", - [MSG_KEYNAME_J] = "j", - [MSG_KEYNAME_K] = "k", - [MSG_KEYNAME_L] = "l", - [MSG_KEYNAME_SEMICOLON] = "semicolon", - [MSG_KEYNAME_SINGLEQUOTE] = "apostrophe", - [MSG_KEYNAME_GRAVE] = "accent", - [MSG_KEYNAME_LEFTSHFT] = "left shift", - [MSG_KEYNAME_BACKSLASH] = "back slash", - [MSG_KEYNAME_Z] = "z", - [MSG_KEYNAME_X] = "x", - [MSG_KEYNAME_C] = "c", - [MSG_KEYNAME_V] = "v", - [MSG_KEYNAME_B] = "b", - [MSG_KEYNAME_N] = "n", - [MSG_KEYNAME_M] = "m", - [MSG_KEYNAME_COMMA] = "comma", - [MSG_KEYNAME_DOT] = "dot", - [MSG_KEYNAME_SLASH] = "slash", - [MSG_KEYNAME_RIGHTSHFT] = "right shift", - [MSG_KEYNAME_KPSTAR] = "keypad asterisk", - [MSG_KEYNAME_LEFTALT] = "left alt", - [MSG_KEYNAME_SPACE] = "space", - [MSG_KEYNAME_CAPSLOCK] = "caps lock", - [MSG_KEYNAME_F1] = "f1", - [MSG_KEYNAME_F2] = "f2", - [MSG_KEYNAME_F3] = "f3", - [MSG_KEYNAME_F4] = "f4", - [MSG_KEYNAME_F5] = "f5", - [MSG_KEYNAME_F6] = "f6", - [MSG_KEYNAME_F7] = "f7", - [MSG_KEYNAME_F8] = "f8", - [MSG_KEYNAME_F9] = "f9", - [MSG_KEYNAME_F10] = "f10", - [MSG_KEYNAME_NUMLOCK] = "num lock", - [MSG_KEYNAME_SCROLLLOCK] = "scroll lock", - [MSG_KEYNAME_KP7] = "keypad 7", - [MSG_KEYNAME_KP8] = "keypad 8", - [MSG_KEYNAME_KP9] = "keypad 9", - [MSG_KEYNAME_KPMINUS] = "keypad minus", - [MSG_KEYNAME_KP4] = "keypad 4", - [MSG_KEYNAME_KP5] = "keypad 5", - [MSG_KEYNAME_KP6] = "keypad 6", - [MSG_KEYNAME_KPPLUS] = "keypad plus", - [MSG_KEYNAME_KP1] = "keypad 1", - [MSG_KEYNAME_KP2] = "keypad 2", - [MSG_KEYNAME_KP3] = "keypad 3", - [MSG_KEYNAME_KP0] = "keypad 0", - [MSG_KEYNAME_KPDOT] = "keypad dot", - [MSG_KEYNAME_103RD] = "103rd", - [MSG_KEYNAME_F13] = "f13", - [MSG_KEYNAME_102ND] = "102nd", - [MSG_KEYNAME_F11] = "f11", - [MSG_KEYNAME_F12] = "f12", - [MSG_KEYNAME_F14] = "f14", - [MSG_KEYNAME_F15] = "f15", - [MSG_KEYNAME_F16] = "f16", - [MSG_KEYNAME_F17] = "f17", - [MSG_KEYNAME_F18] = "f18", - [MSG_KEYNAME_F19] = "f19", - [MSG_KEYNAME_F20] = "f20", - [MSG_KEYNAME_KPENTER] = "keypad enter", - [MSG_KEYNAME_RIGHTCTRL] = "right control", - [MSG_KEYNAME_KPSLASH] = "keypad slash", - [MSG_KEYNAME_SYSRQ] = "sysrq", - [MSG_KEYNAME_RIGHTALT] = "right alt", - [MSG_KEYNAME_LF] = "line feed", - [MSG_KEYNAME_HOME] = "home", - [MSG_KEYNAME_UP] = "up", - [MSG_KEYNAME_PGUP] = "page up", - [MSG_KEYNAME_LEFT] = "left", - [MSG_KEYNAME_RIGHT] = "right", - [MSG_KEYNAME_END] = "end", - [MSG_KEYNAME_DOWN] = "down", - [MSG_KEYNAME_PGDN] = "page down", - [MSG_KEYNAME_INS] = "insert", - [MSG_KEYNAME_DEL] = "delete", - [MSG_KEYNAME_MACRO] = "macro", - [MSG_KEYNAME_MUTE] = "mute", - [MSG_KEYNAME_VOLDOWN] = "volume down", - [MSG_KEYNAME_VOLUP] = "volume up", - [MSG_KEYNAME_POWER] = "power", - [MSG_KEYNAME_KPEQUAL] = "keypad equal", - [MSG_KEYNAME_KPPLUSDASH] = "keypad plusminus", - [MSG_KEYNAME_PAUSE] = "pause", - [MSG_KEYNAME_F21] = "f21", - [MSG_KEYNAME_F22] = "f22", - [MSG_KEYNAME_F23] = "f23", - [MSG_KEYNAME_F24] = "f24", - [MSG_KEYNAME_KPCOMMA] = "keypad comma", - [MSG_KEYNAME_LEFTMETA] = "left meta", - [MSG_KEYNAME_RIGHTMETA] = "right meta", - [MSG_KEYNAME_COMPOSE] = "compose", - [MSG_KEYNAME_STOP] = "stop", - [MSG_KEYNAME_AGAIN] = "again", - [MSG_KEYNAME_PROPS] = "props", - [MSG_KEYNAME_UNDO] = "undo", - [MSG_KEYNAME_FRONT] = "front", - [MSG_KEYNAME_COPY] = "copy", - [MSG_KEYNAME_OPEN] = "open", - [MSG_KEYNAME_PASTE] = "paste", - [MSG_KEYNAME_FIND] = "find", - [MSG_KEYNAME_CUT] = "cut", - [MSG_KEYNAME_HELP] = "help", - [MSG_KEYNAME_MENU] = "menu", - [MSG_KEYNAME_CALC] = "calc", - [MSG_KEYNAME_SETUP] = "setup", - [MSG_KEYNAME_SLEEP] = "sleep", - [MSG_KEYNAME_WAKEUP] = "wakeup", - [MSG_KEYNAME_FILE] = "file", - [MSG_KEYNAME_SENDFILE] = "send file", - [MSG_KEYNAME_DELFILE] = "delete file", - [MSG_KEYNAME_XFER] = "transfer", - [MSG_KEYNAME_PROG1] = "prog1", - [MSG_KEYNAME_PROG2] = "prog2", - [MSG_KEYNAME_WWW] = "www", - [MSG_KEYNAME_MSDOS] = "msdos", - [MSG_KEYNAME_COFFEE] = "coffee", - [MSG_KEYNAME_DIRECTION] = "direction", - [MSG_KEYNAME_CYCLEWINDOWS] = "cycle windows", - [MSG_KEYNAME_MAIL] = "mail", - [MSG_KEYNAME_BOOKMARKS] = "bookmarks", - [MSG_KEYNAME_COMPUTER] = "computer", - [MSG_KEYNAME_BACK] = "back", - [MSG_KEYNAME_FORWARD] = "forward", - [MSG_KEYNAME_CLOSECD] = "close cd", - [MSG_KEYNAME_EJECTCD] = "eject cd", - [MSG_KEYNAME_EJECTCLOSE] = "eject close cd", - [MSG_KEYNAME_NEXTSONG] = "next song", - [MSG_KEYNAME_PLAYPAUSE] = "play pause", - [MSG_KEYNAME_PREVSONG] = "previous song", - [MSG_KEYNAME_STOPCD] = "stop cd", - [MSG_KEYNAME_RECORD] = "record", - [MSG_KEYNAME_REWIND] = "rewind", - [MSG_KEYNAME_PHONE] = "phone", - [MSG_KEYNAME_ISO] = "iso", - [MSG_KEYNAME_CONFIG] = "config", - [MSG_KEYNAME_HOMEPG] = "home page", - [MSG_KEYNAME_REFRESH] = "refresh", - [MSG_KEYNAME_EXIT] = "exit", - [MSG_KEYNAME_MOVE] = "move", - [MSG_KEYNAME_EDIT] = "edit", - [MSG_KEYNAME_SCROLLUP] = "scroll up", - [MSG_KEYNAME_SCROLLDN] = "scroll down", - [MSG_KEYNAME_KPLEFTPAR] = "keypad left paren", - [MSG_KEYNAME_KPRIGHTPAR] = "keypad right paren", - - /* Function names. */ - [MSG_FUNCNAME_ATTRIB_BLEEP_DEC] = "attribute bleep decrement", - [MSG_FUNCNAME_ATTRIB_BLEEP_INC] = "attribute bleep increment", - [MSG_FUNCNAME_BLEEPS_DEC] = "bleeps decrement", - [MSG_FUNCNAME_BLEEPS_INC] = "bleeps increment", - [MSG_FUNCNAME_CHAR_FIRST] = "character, first", - [MSG_FUNCNAME_CHAR_LAST] = "character, last", - [MSG_FUNCNAME_CHAR_CURRENT] = "character, say current", - [MSG_FUNCNAME_CHAR_HEX_AND_DEC] = "character, say hex and decimal", - [MSG_FUNCNAME_CHAR_NEXT] = "character, say next", - [MSG_FUNCNAME_CHAR_PHONETIC] = "character, say phonetic", - [MSG_FUNCNAME_CHAR_PREVIOUS] = "character, say previous", - [MSG_FUNCNAME_CURSOR_PARK] = "cursor park", - [MSG_FUNCNAME_CUT] = "cut", - [MSG_FUNCNAME_EDIT_DELIM] = "edit delimiters", - [MSG_FUNCNAME_EDIT_EXNUM] = "edit exnum", - [MSG_FUNCNAME_EDIT_MOST] = "edit most", - [MSG_FUNCNAME_EDIT_REPEATS] = "edit repeats", - [MSG_FUNCNAME_EDIT_SOME] = "edit some", - [MSG_FUNCNAME_GOTO] = "go to", - [MSG_FUNCNAME_GOTO_BOTTOM] = "go to bottom edge", - [MSG_FUNCNAME_GOTO_LEFT] = "go to left edge", - [MSG_FUNCNAME_GOTO_RIGHT] = "go to right edge", - [MSG_FUNCNAME_GOTO_TOP] = "go to top edge", - [MSG_FUNCNAME_HELP] = "help", - [MSG_FUNCNAME_LINE_SAY_CURRENT] = "line, say current", - [MSG_FUNCNAME_LINE_SAY_NEXT] = "line, say next", - [MSG_FUNCNAME_LINE_SAY_PREVIOUS] = "line, say previous", - [MSG_FUNCNAME_LINE_SAY_WITH_INDENT] = "line, say with indent", - [MSG_FUNCNAME_PASTE] = "paste", - [MSG_FUNCNAME_PITCH_DEC] = "pitch decrement", - [MSG_FUNCNAME_PITCH_INC] = "pitch increment", - [MSG_FUNCNAME_PUNC_DEC] = "punctuation decrement", - [MSG_FUNCNAME_PUNC_INC] = "punctuation increment", - [MSG_FUNCNAME_PUNC_LEVEL_DEC] = "punc level decrement", - [MSG_FUNCNAME_PUNC_LEVEL_INC] = "punc level increment", - [MSG_FUNCNAME_QUIET] = "quiet", - [MSG_FUNCNAME_RATE_DEC] = "rate decrement", - [MSG_FUNCNAME_RATE_INC] = "rate increment", - [MSG_FUNCNAME_READING_PUNC_DEC] = "reading punctuation decrement", - [MSG_FUNCNAME_READING_PUNC_INC] = "reading punctuation increment", - [MSG_FUNCNAME_SAY_ATTRIBUTES] = "say attributes", - [MSG_FUNCNAME_SAY_FROM_LEFT] = "say from left", - [MSG_FUNCNAME_SAY_FROM_TOP] = "say from top", - [MSG_FUNCNAME_SAY_POSITION] = "say position", - [MSG_FUNCNAME_SAY_SCREEN] = "say screen", - [MSG_FUNCNAME_SAY_TO_BOTTOM] = "say to bottom", - [MSG_FUNCNAME_SAY_TO_RIGHT] = "say to right", - [MSG_FUNCNAME_SPEAKUP] = "speakup", - [MSG_FUNCNAME_SPEAKUP_LOCK] = "speakup lock", - [MSG_FUNCNAME_SPEAKUP_OFF] = "speakup off", - [MSG_FUNCNAME_SPEECH_KILL] = "speech kill", - [MSG_FUNCNAME_SPELL_DELAY_DEC] = "spell delay decrement", - [MSG_FUNCNAME_SPELL_DELAY_INC] = "spell delay increment", - [MSG_FUNCNAME_SPELL_WORD] = "spell word", - [MSG_FUNCNAME_SPELL_WORD_PHONETICALLY] = "spell word phonetically", - [MSG_FUNCNAME_TONE_DEC] = "tone decrement", - [MSG_FUNCNAME_TONE_INC] = "tone increment", - [MSG_FUNCNAME_VOICE_DEC] = "voice decrement", - [MSG_FUNCNAME_VOICE_INC] = "voice increment", - [MSG_FUNCNAME_VOLUME_DEC] = "volume decrement", - [MSG_FUNCNAME_VOLUME_INC] = "volume increment", - [MSG_FUNCNAME_WINDOW_CLEAR] = "window, clear", - [MSG_FUNCNAME_WINDOW_SAY] = "window, say", - [MSG_FUNCNAME_WINDOW_SET] = "window, set", - [MSG_FUNCNAME_WINDOW_SILENCE] = "window, silence", - [MSG_FUNCNAME_WORD_SAY_CURRENT] = "word, say current", - [MSG_FUNCNAME_WORD_SAY_NEXT] = "word, say next", - [MSG_FUNCNAME_WORD_SAY_PREVIOUS] = "word, say previous", -}; - -static struct msg_group_t all_groups[] = { - { - .name = "ctl_keys", - .start = MSG_CTL_START, - .end = MSG_CTL_END, - }, - { - .name = "colors", - .start = MSG_COLORS_START, - .end = MSG_COLORS_END, - }, - { - .name = "formatted", - .start = MSG_FORMATTED_START, - .end = MSG_FORMATTED_END, - }, - { - .name = "function_names", - .start = MSG_FUNCNAMES_START, - .end = MSG_FUNCNAMES_END, - }, - { - .name = "key_names", - .start = MSG_KEYNAMES_START, - .end = MSG_KEYNAMES_END, - }, - { - .name = "announcements", - .start = MSG_ANNOUNCEMENTS_START, - .end = MSG_ANNOUNCEMENTS_END, - }, - { - .name = "states", - .start = MSG_STATES_START, - .end = MSG_STATES_END, - }, -}; - -static const int num_groups = ARRAY_SIZE(all_groups); - -char *spk_msg_get(enum msg_index_t index) -{ - return speakup_msgs[index]; -} - -/* - * Function: next_specifier - * Finds the start of the next format specifier in the argument string. - * Return value: pointer to start of format - * specifier, or NULL if no specifier exists. - */ -static char *next_specifier(char *input) -{ - int found = 0; - char *next_percent = input; - - while (next_percent && !found) { - next_percent = strchr(next_percent, '%'); - if (next_percent) { - /* skip over doubled percent signs */ - while (next_percent[0] == '%' && - next_percent[1] == '%') - next_percent += 2; - if (*next_percent == '%') - found = 1; - else if (*next_percent == '\0') - next_percent = NULL; - } - } - - return next_percent; -} - -/* Skip over 0 or more flags. */ -static char *skip_flags(char *input) -{ - while ((*input != '\0') && strchr(" 0+-#", *input)) - input++; - return input; -} - -/* Skip over width.precision, if it exists. */ -static char *skip_width(char *input) -{ - while (isdigit(*input)) - input++; - if (*input == '.') { - input++; - while (isdigit(*input)) - input++; - } - return input; -} - -/* - * Skip past the end of the conversion part. - * Note that this code only accepts a handful of conversion specifiers: - * c d s x and ld. Not accidental; these are exactly the ones used in - * the default group of formatted messages. - */ -static char *skip_conversion(char *input) -{ - if ((input[0] == 'l') && (input[1] == 'd')) - input += 2; - else if ((*input != '\0') && strchr("cdsx", *input)) - input++; - return input; -} - -/* - * Function: find_specifier_end - * Return a pointer to the end of the format specifier. - */ -static char *find_specifier_end(char *input) -{ - input++; /* Advance over %. */ - input = skip_flags(input); - input = skip_width(input); - input = skip_conversion(input); - return input; -} - -/* - * Function: compare_specifiers - * Compare the format specifiers pointed to by *input1 and *input2. - * Return true if they are the same, false otherwise. - * Advance *input1 and *input2 so that they point to the character following - * the end of the specifier. - */ -static bool compare_specifiers(char **input1, char **input2) -{ - bool same = false; - char *end1 = find_specifier_end(*input1); - char *end2 = find_specifier_end(*input2); - size_t length1 = end1 - *input1; - size_t length2 = end2 - *input2; - - if ((length1 == length2) && !memcmp(*input1, *input2, length1)) - same = true; - - *input1 = end1; - *input2 = end2; - return same; -} - -/* - * Function: fmt_validate - * Check that two format strings contain the same number of format specifiers, - * and that the order of specifiers is the same in both strings. - * Return true if the condition holds, false if it doesn't. - */ -static bool fmt_validate(char *template, char *user) -{ - bool valid = true; - bool still_comparing = true; - char *template_ptr = template; - char *user_ptr = user; - - while (still_comparing && valid) { - template_ptr = next_specifier(template_ptr); - user_ptr = next_specifier(user_ptr); - if (template_ptr && user_ptr) { - /* Both have at least one more specifier. */ - valid = compare_specifiers(&template_ptr, &user_ptr); - } else { - /* No more format specifiers in one or both strings. */ - still_comparing = false; - /* See if one has more specifiers than the other. */ - if (template_ptr || user_ptr) - valid = false; - } - } - return valid; -} - -/* - * Function: msg_set - * Description: Add a user-supplied message to the user_messages array. - * The message text is copied to a memory area allocated with kmalloc. - * If the function fails, then user_messages is untouched. - * Arguments: - * - index: a message number, as found in i18n.h. - * - text: text of message. Not NUL-terminated. - * - length: number of bytes in text. - * Failure conditions: - * -EINVAL - Invalid format specifiers in formatted message or illegal index. - * -ENOMEM - Unable to allocate memory. - */ -ssize_t spk_msg_set(enum msg_index_t index, char *text, size_t length) -{ - char *newstr = NULL; - unsigned long flags; - - if ((index < MSG_FIRST_INDEX) || (index >= MSG_LAST_INDEX)) - return -EINVAL; - - newstr = kmalloc(length + 1, GFP_KERNEL); - if (!newstr) - return -ENOMEM; - - memcpy(newstr, text, length); - newstr[length] = '\0'; - if (index >= MSG_FORMATTED_START && - index <= MSG_FORMATTED_END && - !fmt_validate(speakup_default_msgs[index], newstr)) { - kfree(newstr); - return -EINVAL; - } - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (speakup_msgs[index] != speakup_default_msgs[index]) - kfree(speakup_msgs[index]); - speakup_msgs[index] = newstr; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return 0; -} - -/* - * Find a message group, given its name. Return a pointer to the structure - * if found, or NULL otherwise. - */ -struct msg_group_t *spk_find_msg_group(const char *group_name) -{ - struct msg_group_t *group = NULL; - int i; - - for (i = 0; i < num_groups; i++) { - if (!strcmp(all_groups[i].name, group_name)) { - group = &all_groups[i]; - break; - } - } - return group; -} - -void spk_reset_msg_group(struct msg_group_t *group) -{ - unsigned long flags; - enum msg_index_t i; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - - for (i = group->start; i <= group->end; i++) { - if (speakup_msgs[i] != speakup_default_msgs[i]) - kfree(speakup_msgs[i]); - speakup_msgs[i] = speakup_default_msgs[i]; - } - spin_unlock_irqrestore(&speakup_info.spinlock, flags); -} - -/* Called at initialization time, to establish default messages. */ -void spk_initialize_msgs(void) -{ - memcpy(speakup_msgs, speakup_default_msgs, - sizeof(speakup_default_msgs)); -} - -/* Free user-supplied strings when module is unloaded: */ -void spk_free_user_msgs(void) -{ - enum msg_index_t index; - unsigned long flags; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - for (index = MSG_FIRST_INDEX; index < MSG_LAST_INDEX; index++) { - if (speakup_msgs[index] != speakup_default_msgs[index]) { - kfree(speakup_msgs[index]); - speakup_msgs[index] = speakup_default_msgs[index]; - } - } - spin_unlock_irqrestore(&speakup_info.spinlock, flags); -} diff --git a/drivers/staging/speakup/i18n.h b/drivers/staging/speakup/i18n.h deleted file mode 100644 index 2ec6e659d02b..000000000000 --- a/drivers/staging/speakup/i18n.h +++ /dev/null @@ -1,235 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef I18N_H -#define I18N_H -/* Internationalization declarations */ - -enum msg_index_t { - MSG_FIRST_INDEX, - MSG_ANNOUNCEMENTS_START = MSG_FIRST_INDEX, - MSG_BLANK = MSG_ANNOUNCEMENTS_START, - MSG_IAM_ALIVE, - MSG_YOU_KILLED_SPEAKUP, - MSG_HEY_THATS_BETTER, - MSG_YOU_TURNED_ME_OFF, - MSG_PARKED, - MSG_UNPARKED, - MSG_MARK, - MSG_CUT, - MSG_MARK_CLEARED, - MSG_PASTE, - MSG_BRIGHT, - MSG_ON_BLINKING, - MSG_STATUS_START, - MSG_OFF = MSG_STATUS_START, - MSG_ON, - MSG_NO_WINDOW, - MSG_CURSOR_MSGS_START, - MSG_CURSORING_OFF = MSG_CURSOR_MSGS_START, - MSG_CURSORING_ON, - MSG_HIGHLIGHT_TRACKING, - MSG_READ_WINDOW, - MSG_READ_ALL, - MSG_EDIT_DONE, - MSG_WINDOW_ALREADY_SET, - MSG_END_BEFORE_START, - MSG_WINDOW_CLEARED, - MSG_WINDOW_SILENCED, - MSG_WINDOW_SILENCE_DISABLED, - MSG_ERROR, - MSG_GOTO_CANCELED, - MSG_GOTO, - MSG_LEAVING_HELP, - MSG_IS_UNASSIGNED, - MSG_HELP_INFO, - MSG_EDGE_MSGS_START, - MSG_EDGE_TOP = MSG_EDGE_MSGS_START, - MSG_EDGE_BOTTOM, - MSG_EDGE_LEFT, - MSG_EDGE_RIGHT, - MSG_NUMBER, - MSG_SPACE, - MSG_START, /* A little confusing, given our convention. */ - MSG_END, /* A little confusing, given our convention. */ - MSG_CTRL, - -/* A message containing the single word "or". */ - MSG_DISJUNCTION, - MSG_ANNOUNCEMENTS_END = MSG_DISJUNCTION, - -/* Messages with format specifiers. */ - MSG_FORMATTED_START, - MSG_POS_INFO = MSG_FORMATTED_START, - MSG_CHAR_INFO, - MSG_REPEAT_DESC, - MSG_REPEAT_DESC2, - MSG_WINDOW_LINE, - MSG_WINDOW_BOUNDARY, - MSG_EDIT_PROMPT, - MSG_NO_COMMAND, - MSG_KEYDESC, - MSG_FORMATTED_END = MSG_KEYDESC, - - /* Control keys. */ - MSG_CTL_START, - MSG_CTL_SHIFT = MSG_CTL_START, - MSG_CTL_ALTGR, - MSG_CTL_CONTROL, - MSG_CTL_ALT, - MSG_CTL_LSHIFT, - MSG_CTL_SPEAKUP, - MSG_CTL_LCONTROL, - MSG_CTL_RCONTROL, - MSG_CTL_CAPSSHIFT, - MSG_CTL_END = MSG_CTL_CAPSSHIFT, - - /* Colors. */ - MSG_COLORS_START, - MSG_COLOR_BLACK = MSG_COLORS_START, - MSG_COLOR_BLUE, - MSG_COLOR_GREEN, - MSG_COLOR_CYAN, - MSG_COLOR_RED, - MSG_COLOR_MAGENTA, - MSG_COLOR_YELLOW, - MSG_COLOR_WHITE, - MSG_COLOR_GREY, - MSG_COLORS_END = MSG_COLOR_GREY, - - MSG_STATES_START, - MSG_STATE_DOUBLE = MSG_STATES_START, - MSG_STATE_SPEAKUP, - MSG_STATE_ALT, - MSG_STATE_CONTROL, - MSG_STATE_ALTGR, - MSG_STATE_SHIFT, - MSG_STATES_END = MSG_STATE_SHIFT, - - MSG_KEYNAMES_START, - MSG_KEYNAME_ESC = MSG_KEYNAMES_START, - MSG_KEYNAME_1, MSG_KEYNAME_2, MSG_KEYNAME_3, MSG_KEYNAME_4, - MSG_KEYNAME_5, MSG_KEYNAME_6, MSG_KEYNAME_7, MSG_KEYNAME_8, - MSG_KEYNAME_9, - MSG_KEYNAME_0, MSG_KEYNAME_DASH, MSG_KEYNAME_EQUAL, MSG_KEYNAME_BS, - MSG_KEYNAME_TAB, - MSG_KEYNAME_Q, MSG_KEYNAME_W, MSG_KEYNAME_E, MSG_KEYNAME_R, - MSG_KEYNAME_T, MSG_KEYNAME_Y, MSG_KEYNAME_U, MSG_KEYNAME_I, - MSG_KEYNAME_O, MSG_KEYNAME_P, - MSG_KEYNAME_LEFTBRACE, MSG_KEYNAME_RIGHTBRACE, MSG_KEYNAME_ENTER, - MSG_KEYNAME_LEFTCTRL, MSG_KEYNAME_A, - MSG_KEYNAME_S, MSG_KEYNAME_D, MSG_KEYNAME_F, MSG_KEYNAME_G, - MSG_KEYNAME_H, MSG_KEYNAME_J, MSG_KEYNAME_K, MSG_KEYNAME_L, - MSG_KEYNAME_SEMICOLON, - MSG_KEYNAME_SINGLEQUOTE, MSG_KEYNAME_GRAVE, - MSG_KEYNAME_LEFTSHFT, MSG_KEYNAME_BACKSLASH, MSG_KEYNAME_Z, - MSG_KEYNAME_X, MSG_KEYNAME_C, MSG_KEYNAME_V, MSG_KEYNAME_B, - MSG_KEYNAME_N, MSG_KEYNAME_M, MSG_KEYNAME_COMMA, MSG_KEYNAME_DOT, - MSG_KEYNAME_SLASH, MSG_KEYNAME_RIGHTSHFT, - MSG_KEYNAME_KPSTAR, - MSG_KEYNAME_LEFTALT, MSG_KEYNAME_SPACE, MSG_KEYNAME_CAPSLOCK, - MSG_KEYNAME_F1, MSG_KEYNAME_F2, - MSG_KEYNAME_F3, MSG_KEYNAME_F4, MSG_KEYNAME_F5, MSG_KEYNAME_F6, - MSG_KEYNAME_F7, - MSG_KEYNAME_F8, MSG_KEYNAME_F9, MSG_KEYNAME_F10, MSG_KEYNAME_NUMLOCK, - MSG_KEYNAME_SCROLLLOCK, - MSG_KEYNAME_KP7, MSG_KEYNAME_KP8, MSG_KEYNAME_KP9, MSG_KEYNAME_KPMINUS, - MSG_KEYNAME_KP4, - MSG_KEYNAME_KP5, MSG_KEYNAME_KP6, MSG_KEYNAME_KPPLUS, MSG_KEYNAME_KP1, - MSG_KEYNAME_KP2, - MSG_KEYNAME_KP3, MSG_KEYNAME_KP0, MSG_KEYNAME_KPDOT, MSG_KEYNAME_103RD, - MSG_KEYNAME_F13, - MSG_KEYNAME_102ND, MSG_KEYNAME_F11, MSG_KEYNAME_F12, MSG_KEYNAME_F14, - MSG_KEYNAME_F15, - MSG_KEYNAME_F16, MSG_KEYNAME_F17, MSG_KEYNAME_F18, MSG_KEYNAME_F19, - MSG_KEYNAME_F20, - MSG_KEYNAME_KPENTER, MSG_KEYNAME_RIGHTCTRL, MSG_KEYNAME_KPSLASH, - MSG_KEYNAME_SYSRQ, MSG_KEYNAME_RIGHTALT, - MSG_KEYNAME_LF, MSG_KEYNAME_HOME, MSG_KEYNAME_UP, MSG_KEYNAME_PGUP, - MSG_KEYNAME_LEFT, - MSG_KEYNAME_RIGHT, MSG_KEYNAME_END, MSG_KEYNAME_DOWN, MSG_KEYNAME_PGDN, - MSG_KEYNAME_INS, - MSG_KEYNAME_DEL, MSG_KEYNAME_MACRO, MSG_KEYNAME_MUTE, - MSG_KEYNAME_VOLDOWN, MSG_KEYNAME_VOLUP, - MSG_KEYNAME_POWER, MSG_KEYNAME_KPEQUAL, MSG_KEYNAME_KPPLUSDASH, - MSG_KEYNAME_PAUSE, MSG_KEYNAME_F21, MSG_KEYNAME_F22, MSG_KEYNAME_F23, - MSG_KEYNAME_F24, MSG_KEYNAME_KPCOMMA, MSG_KEYNAME_LEFTMETA, - MSG_KEYNAME_RIGHTMETA, MSG_KEYNAME_COMPOSE, MSG_KEYNAME_STOP, - MSG_KEYNAME_AGAIN, MSG_KEYNAME_PROPS, - MSG_KEYNAME_UNDO, MSG_KEYNAME_FRONT, MSG_KEYNAME_COPY, MSG_KEYNAME_OPEN, - MSG_KEYNAME_PASTE, - MSG_KEYNAME_FIND, MSG_KEYNAME_CUT, MSG_KEYNAME_HELP, MSG_KEYNAME_MENU, - MSG_KEYNAME_CALC, - MSG_KEYNAME_SETUP, MSG_KEYNAME_SLEEP, MSG_KEYNAME_WAKEUP, - MSG_KEYNAME_FILE, MSG_KEYNAME_SENDFILE, - MSG_KEYNAME_DELFILE, MSG_KEYNAME_XFER, MSG_KEYNAME_PROG1, - MSG_KEYNAME_PROG2, MSG_KEYNAME_WWW, - MSG_KEYNAME_MSDOS, MSG_KEYNAME_COFFEE, MSG_KEYNAME_DIRECTION, - MSG_KEYNAME_CYCLEWINDOWS, MSG_KEYNAME_MAIL, - MSG_KEYNAME_BOOKMARKS, MSG_KEYNAME_COMPUTER, MSG_KEYNAME_BACK, - MSG_KEYNAME_FORWARD, MSG_KEYNAME_CLOSECD, - MSG_KEYNAME_EJECTCD, MSG_KEYNAME_EJECTCLOSE, MSG_KEYNAME_NEXTSONG, - MSG_KEYNAME_PLAYPAUSE, MSG_KEYNAME_PREVSONG, - MSG_KEYNAME_STOPCD, MSG_KEYNAME_RECORD, MSG_KEYNAME_REWIND, - MSG_KEYNAME_PHONE, MSG_KEYNAME_ISO, - MSG_KEYNAME_CONFIG, MSG_KEYNAME_HOMEPG, MSG_KEYNAME_REFRESH, - MSG_KEYNAME_EXIT, MSG_KEYNAME_MOVE, - MSG_KEYNAME_EDIT, MSG_KEYNAME_SCROLLUP, MSG_KEYNAME_SCROLLDN, - MSG_KEYNAME_KPLEFTPAR, MSG_KEYNAME_KPRIGHTPAR, - MSG_KEYNAMES_END = MSG_KEYNAME_KPRIGHTPAR, - - MSG_FUNCNAMES_START, - MSG_FUNCNAME_ATTRIB_BLEEP_DEC = MSG_FUNCNAMES_START, - MSG_FUNCNAME_ATTRIB_BLEEP_INC, - MSG_FUNCNAME_BLEEPS_DEC, MSG_FUNCNAME_BLEEPS_INC, - MSG_FUNCNAME_CHAR_FIRST, MSG_FUNCNAME_CHAR_LAST, - MSG_FUNCNAME_CHAR_CURRENT, MSG_FUNCNAME_CHAR_HEX_AND_DEC, - MSG_FUNCNAME_CHAR_NEXT, - MSG_FUNCNAME_CHAR_PHONETIC, MSG_FUNCNAME_CHAR_PREVIOUS, - MSG_FUNCNAME_CURSOR_PARK, MSG_FUNCNAME_CUT, - MSG_FUNCNAME_EDIT_DELIM, MSG_FUNCNAME_EDIT_EXNUM, - MSG_FUNCNAME_EDIT_MOST, MSG_FUNCNAME_EDIT_REPEATS, - MSG_FUNCNAME_EDIT_SOME, - MSG_FUNCNAME_GOTO, MSG_FUNCNAME_GOTO_BOTTOM, MSG_FUNCNAME_GOTO_LEFT, - MSG_FUNCNAME_GOTO_RIGHT, MSG_FUNCNAME_GOTO_TOP, MSG_FUNCNAME_HELP, - MSG_FUNCNAME_LINE_SAY_CURRENT, MSG_FUNCNAME_LINE_SAY_NEXT, - MSG_FUNCNAME_LINE_SAY_PREVIOUS, MSG_FUNCNAME_LINE_SAY_WITH_INDENT, - MSG_FUNCNAME_PASTE, MSG_FUNCNAME_PITCH_DEC, MSG_FUNCNAME_PITCH_INC, - MSG_FUNCNAME_PUNC_DEC, MSG_FUNCNAME_PUNC_INC, - MSG_FUNCNAME_PUNC_LEVEL_DEC, MSG_FUNCNAME_PUNC_LEVEL_INC, - MSG_FUNCNAME_QUIET, - MSG_FUNCNAME_RATE_DEC, MSG_FUNCNAME_RATE_INC, - MSG_FUNCNAME_READING_PUNC_DEC, MSG_FUNCNAME_READING_PUNC_INC, - MSG_FUNCNAME_SAY_ATTRIBUTES, - MSG_FUNCNAME_SAY_FROM_LEFT, MSG_FUNCNAME_SAY_FROM_TOP, - MSG_FUNCNAME_SAY_POSITION, MSG_FUNCNAME_SAY_SCREEN, - MSG_FUNCNAME_SAY_TO_BOTTOM, MSG_FUNCNAME_SAY_TO_RIGHT, - MSG_FUNCNAME_SPEAKUP, MSG_FUNCNAME_SPEAKUP_LOCK, - MSG_FUNCNAME_SPEAKUP_OFF, MSG_FUNCNAME_SPEECH_KILL, - MSG_FUNCNAME_SPELL_DELAY_DEC, MSG_FUNCNAME_SPELL_DELAY_INC, - MSG_FUNCNAME_SPELL_WORD, MSG_FUNCNAME_SPELL_WORD_PHONETICALLY, - MSG_FUNCNAME_TONE_DEC, MSG_FUNCNAME_TONE_INC, - MSG_FUNCNAME_VOICE_DEC, MSG_FUNCNAME_VOICE_INC, - MSG_FUNCNAME_VOLUME_DEC, MSG_FUNCNAME_VOLUME_INC, - MSG_FUNCNAME_WINDOW_CLEAR, MSG_FUNCNAME_WINDOW_SAY, - MSG_FUNCNAME_WINDOW_SET, MSG_FUNCNAME_WINDOW_SILENCE, - MSG_FUNCNAME_WORD_SAY_CURRENT, MSG_FUNCNAME_WORD_SAY_NEXT, - MSG_FUNCNAME_WORD_SAY_PREVIOUS, - MSG_FUNCNAMES_END = MSG_FUNCNAME_WORD_SAY_PREVIOUS, - - /* all valid indices must be above this */ - MSG_LAST_INDEX -}; - -struct msg_group_t { - char *name; - enum msg_index_t start; - enum msg_index_t end; -}; - -char *spk_msg_get(enum msg_index_t index); -ssize_t spk_msg_set(enum msg_index_t index, char *text, size_t length); -struct msg_group_t *spk_find_msg_group(const char *group_name); -void spk_reset_msg_group(struct msg_group_t *group); -void spk_initialize_msgs(void); -void spk_free_user_msgs(void); - -#endif diff --git a/drivers/staging/speakup/keyhelp.c b/drivers/staging/speakup/keyhelp.c deleted file mode 100644 index 822ceac83068..000000000000 --- a/drivers/staging/speakup/keyhelp.c +++ /dev/null @@ -1,209 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* speakup_keyhelp.c - * help module for speakup - * - *written by David Borowski. - * - * Copyright (C) 2003 David Borowski. - */ - -#include -#include "spk_priv.h" -#include "speakup.h" - -#define MAXFUNCS 130 -#define MAXKEYS 256 -static const int num_key_names = MSG_KEYNAMES_END - MSG_KEYNAMES_START + 1; -static u_short key_offsets[MAXFUNCS], key_data[MAXKEYS]; -static u_short masks[] = { 32, 16, 8, 4, 2, 1 }; - -static short letter_offsets[26] = { - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1 }; - -static u_char funcvals[] = { - ATTRIB_BLEEP_DEC, ATTRIB_BLEEP_INC, BLEEPS_DEC, BLEEPS_INC, - SAY_FIRST_CHAR, SAY_LAST_CHAR, SAY_CHAR, SAY_CHAR_NUM, - SAY_NEXT_CHAR, SAY_PHONETIC_CHAR, SAY_PREV_CHAR, SPEAKUP_PARKED, - SPEAKUP_CUT, EDIT_DELIM, EDIT_EXNUM, EDIT_MOST, - EDIT_REPEAT, EDIT_SOME, SPEAKUP_GOTO, BOTTOM_EDGE, - LEFT_EDGE, RIGHT_EDGE, TOP_EDGE, SPEAKUP_HELP, - SAY_LINE, SAY_NEXT_LINE, SAY_PREV_LINE, SAY_LINE_INDENT, - SPEAKUP_PASTE, PITCH_DEC, PITCH_INC, PUNCT_DEC, - PUNCT_INC, PUNC_LEVEL_DEC, PUNC_LEVEL_INC, SPEAKUP_QUIET, - RATE_DEC, RATE_INC, READING_PUNC_DEC, READING_PUNC_INC, - SAY_ATTRIBUTES, SAY_FROM_LEFT, SAY_FROM_TOP, SAY_POSITION, - SAY_SCREEN, SAY_TO_BOTTOM, SAY_TO_RIGHT, SPK_KEY, - SPK_LOCK, SPEAKUP_OFF, SPEECH_KILL, SPELL_DELAY_DEC, - SPELL_DELAY_INC, SPELL_WORD, SPELL_PHONETIC, TONE_DEC, - TONE_INC, VOICE_DEC, VOICE_INC, VOL_DEC, - VOL_INC, CLEAR_WIN, SAY_WIN, SET_WIN, - ENABLE_WIN, SAY_WORD, SAY_NEXT_WORD, SAY_PREV_WORD, 0 -}; - -static u_char *state_tbl; -static int cur_item, nstates; - -static void build_key_data(void) -{ - u_char *kp, counters[MAXFUNCS], ch, ch1; - u_short *p_key, key; - int i, offset = 1; - - nstates = (int)(state_tbl[-1]); - memset(counters, 0, sizeof(counters)); - memset(key_offsets, 0, sizeof(key_offsets)); - kp = state_tbl + nstates + 1; - while (*kp++) { - /* count occurrences of each function */ - for (i = 0; i < nstates; i++, kp++) { - if (!*kp) - continue; - if ((state_tbl[i] & 16) != 0 && *kp == SPK_KEY) - continue; - counters[*kp]++; - } - } - for (i = 0; i < MAXFUNCS; i++) { - if (counters[i] == 0) - continue; - key_offsets[i] = offset; - offset += (counters[i] + 1); - if (offset >= MAXKEYS) - break; - } -/* leave counters set so high keycodes come first. - * this is done so num pad and other extended keys maps are spoken before - * the alpha with speakup type mapping. - */ - kp = state_tbl + nstates + 1; - while ((ch = *kp++)) { - for (i = 0; i < nstates; i++) { - ch1 = *kp++; - if (!ch1) - continue; - if ((state_tbl[i] & 16) != 0 && ch1 == SPK_KEY) - continue; - key = (state_tbl[i] << 8) + ch; - counters[ch1]--; - offset = key_offsets[ch1]; - if (!offset) - continue; - p_key = key_data + offset + counters[ch1]; - *p_key = key; - } - } -} - -static void say_key(int key) -{ - int i, state = key >> 8; - - key &= 0xff; - for (i = 0; i < 6; i++) { - if (state & masks[i]) - synth_printf(" %s", spk_msg_get(MSG_STATES_START + i)); - } - if ((key > 0) && (key <= num_key_names)) - synth_printf(" %s\n", - spk_msg_get(MSG_KEYNAMES_START + (key - 1))); -} - -static int help_init(void) -{ - char start = SPACE; - int i; - int num_funcs = MSG_FUNCNAMES_END - MSG_FUNCNAMES_START + 1; - - state_tbl = spk_our_keys[0] + SHIFT_TBL_SIZE + 2; - for (i = 0; i < num_funcs; i++) { - char *cur_funcname = spk_msg_get(MSG_FUNCNAMES_START + i); - - if (start == *cur_funcname) - continue; - start = *cur_funcname; - letter_offsets[(start & 31) - 1] = i; - } - return 0; -} - -int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key) -{ - int i, n; - char *name; - u_char func, *kp; - u_short *p_keys, val; - - if (letter_offsets[0] == -1) - help_init(); - if (type == KT_LATIN) { - if (ch == SPACE) { - spk_special_handler = NULL; - synth_printf("%s\n", spk_msg_get(MSG_LEAVING_HELP)); - return 1; - } - ch |= 32; /* lower case */ - if (ch < 'a' || ch > 'z') - return -1; - if (letter_offsets[ch - 'a'] == -1) { - synth_printf(spk_msg_get(MSG_NO_COMMAND), ch); - synth_printf("\n"); - return 1; - } - cur_item = letter_offsets[ch - 'a']; - } else if (type == KT_CUR) { - if (ch == 0 && - (MSG_FUNCNAMES_START + cur_item + 1) <= MSG_FUNCNAMES_END) - cur_item++; - else if (ch == 3 && cur_item > 0) - cur_item--; - else - return -1; - } else if (type == KT_SPKUP && ch == SPEAKUP_HELP && - !spk_special_handler) { - spk_special_handler = spk_handle_help; - synth_printf("%s\n", spk_msg_get(MSG_HELP_INFO)); - build_key_data(); /* rebuild each time in case new mapping */ - return 1; - } else { - name = NULL; - if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) { - synth_printf("%s\n", - spk_msg_get(MSG_KEYNAMES_START + key - 1)); - return 1; - } - for (i = 0; funcvals[i] != 0 && !name; i++) { - if (ch == funcvals[i]) - name = spk_msg_get(MSG_FUNCNAMES_START + i); - } - if (!name) - return -1; - kp = spk_our_keys[key] + 1; - for (i = 0; i < nstates; i++) { - if (ch == kp[i]) - break; - } - key += (state_tbl[i] << 8); - say_key(key); - synth_printf(spk_msg_get(MSG_KEYDESC), name); - synth_printf("\n"); - return 1; - } - name = spk_msg_get(MSG_FUNCNAMES_START + cur_item); - func = funcvals[cur_item]; - synth_printf("%s", name); - if (key_offsets[func] == 0) { - synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED)); - return 1; - } - p_keys = key_data + key_offsets[func]; - for (n = 0; p_keys[n]; n++) { - val = p_keys[n]; - if (n > 0) - synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION)); - say_key(val); - } - return 1; -} diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c deleted file mode 100644 index 41ae24ab5d08..000000000000 --- a/drivers/staging/speakup/kobjects.c +++ /dev/null @@ -1,1056 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Speakup kobject implementation - * - * Copyright (C) 2009 William Hubbs - * - * This code is based on kobject-example.c, which came with linux 2.6.x. - * - * Copyright (C) 2004-2007 Greg Kroah-Hartman - * Copyright (C) 2007 Novell Inc. - * - * Released under the GPL version 2 only. - * - */ -#include /* For kmalloc. */ -#include -#include -#include -#include -#include -#include - -#include "speakup.h" -#include "spk_priv.h" - -/* - * This is called when a user reads the characters or chartab sys file. - */ -static ssize_t chars_chartab_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - int i; - int len = 0; - char *cp; - char *buf_pointer = buf; - size_t bufsize = PAGE_SIZE; - unsigned long flags; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - *buf_pointer = '\0'; - for (i = 0; i < 256; i++) { - if (bufsize <= 1) - break; - if (strcmp("characters", attr->attr.name) == 0) { - len = scnprintf(buf_pointer, bufsize, "%d\t%s\n", - i, spk_characters[i]); - } else { /* show chartab entry */ - if (IS_TYPE(i, B_CTL)) - cp = "B_CTL"; - else if (IS_TYPE(i, WDLM)) - cp = "WDLM"; - else if (IS_TYPE(i, A_PUNC)) - cp = "A_PUNC"; - else if (IS_TYPE(i, PUNC)) - cp = "PUNC"; - else if (IS_TYPE(i, NUM)) - cp = "NUM"; - else if (IS_TYPE(i, A_CAP)) - cp = "A_CAP"; - else if (IS_TYPE(i, ALPHA)) - cp = "ALPHA"; - else if (IS_TYPE(i, B_CAPSYM)) - cp = "B_CAPSYM"; - else if (IS_TYPE(i, B_SYM)) - cp = "B_SYM"; - else - cp = "0"; - len = - scnprintf(buf_pointer, bufsize, "%d\t%s\n", i, cp); - } - bufsize -= len; - buf_pointer += len; - } - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return buf_pointer - buf; -} - -/* - * Print informational messages or warnings after updating - * character descriptions or chartab entries. - */ -static void report_char_chartab_status(int reset, int received, int used, - int rejected, int do_characters) -{ - static char const *object_type[] = { - "character class entries", - "character descriptions", - }; - int len; - char buf[80]; - - if (reset) { - pr_info("%s reset to defaults\n", object_type[do_characters]); - } else if (received) { - len = snprintf(buf, sizeof(buf), - " updated %d of %d %s\n", - used, received, object_type[do_characters]); - if (rejected) - snprintf(buf + (len - 1), sizeof(buf) - (len - 1), - " with %d reject%s\n", - rejected, rejected > 1 ? "s" : ""); - pr_info("%s", buf); - } -} - -/* - * This is called when a user changes the characters or chartab parameters. - */ -static ssize_t chars_chartab_store(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, size_t count) -{ - char *cp = (char *)buf; - char *end = cp + count; /* the null at the end of the buffer */ - char *linefeed = NULL; - char keyword[MAX_DESC_LEN + 1]; - char *outptr = NULL; /* Will hold keyword or desc. */ - char *temp = NULL; - char *desc = NULL; - ssize_t retval = count; - unsigned long flags; - unsigned long index = 0; - int charclass = 0; - int received = 0; - int used = 0; - int rejected = 0; - int reset = 0; - int do_characters = !strcmp(attr->attr.name, "characters"); - size_t desc_length = 0; - int i; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - while (cp < end) { - while ((cp < end) && (*cp == ' ' || *cp == '\t')) - cp++; - - if (cp == end) - break; - if ((*cp == '\n') || strchr("dDrR", *cp)) { - reset = 1; - break; - } - received++; - - linefeed = strchr(cp, '\n'); - if (!linefeed) { - rejected++; - break; - } - - if (!isdigit(*cp)) { - rejected++; - cp = linefeed + 1; - continue; - } - - /* - * Do not replace with kstrtoul: - * here we need temp to be updated - */ - index = simple_strtoul(cp, &temp, 10); - if (index > 255) { - rejected++; - cp = linefeed + 1; - continue; - } - - while ((temp < linefeed) && (*temp == ' ' || *temp == '\t')) - temp++; - - desc_length = linefeed - temp; - if (desc_length > MAX_DESC_LEN) { - rejected++; - cp = linefeed + 1; - continue; - } - if (do_characters) { - desc = kmalloc(desc_length + 1, GFP_ATOMIC); - if (!desc) { - retval = -ENOMEM; - reset = 1; /* just reset on error. */ - break; - } - outptr = desc; - } else { - outptr = keyword; - } - - for (i = 0; i < desc_length; i++) - outptr[i] = temp[i]; - outptr[desc_length] = '\0'; - - if (do_characters) { - if (spk_characters[index] != spk_default_chars[index]) - kfree(spk_characters[index]); - spk_characters[index] = desc; - used++; - } else { - charclass = spk_chartab_get_value(keyword); - if (charclass == 0) { - rejected++; - cp = linefeed + 1; - continue; - } - if (charclass != spk_chartab[index]) { - spk_chartab[index] = charclass; - used++; - } - } - cp = linefeed + 1; - } - - if (reset) { - if (do_characters) - spk_reset_default_chars(); - else - spk_reset_default_chartab(); - } - - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - report_char_chartab_status(reset, received, used, rejected, - do_characters); - return retval; -} - -/* - * This is called when a user reads the keymap parameter. - */ -static ssize_t keymap_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) -{ - char *cp = buf; - int i; - int n; - int num_keys; - int nstates; - u_char *cp1; - u_char ch; - unsigned long flags; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - cp1 = spk_key_buf + SHIFT_TBL_SIZE; - num_keys = (int)(*cp1); - nstates = (int)cp1[1]; - cp += sprintf(cp, "%d, %d, %d,\n", KEY_MAP_VER, num_keys, nstates); - cp1 += 2; /* now pointing at shift states */ - /* dump num_keys+1 as first row is shift states + flags, - * each subsequent row is key + states - */ - for (n = 0; n <= num_keys; n++) { - for (i = 0; i <= nstates; i++) { - ch = *cp1++; - cp += sprintf(cp, "%d,", (int)ch); - *cp++ = (i < nstates) ? SPACE : '\n'; - } - } - cp += sprintf(cp, "0, %d\n", KEY_MAP_VER); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return (int)(cp - buf); -} - -/* - * This is called when a user changes the keymap parameter. - */ -static ssize_t keymap_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) -{ - int i; - ssize_t ret = count; - char *in_buff = NULL; - char *cp; - u_char *cp1; - unsigned long flags; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - in_buff = kmemdup(buf, count + 1, GFP_ATOMIC); - if (!in_buff) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return -ENOMEM; - } - if (strchr("dDrR", *in_buff)) { - spk_set_key_info(spk_key_defaults, spk_key_buf); - pr_info("keymap set to default values\n"); - kfree(in_buff); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return count; - } - if (in_buff[count - 1] == '\n') - in_buff[count - 1] = '\0'; - cp = in_buff; - cp1 = (u_char *)in_buff; - for (i = 0; i < 3; i++) { - cp = spk_s2uchar(cp, cp1); - cp1++; - } - i = (int)cp1[-2] + 1; - i *= (int)cp1[-1] + 1; - i += 2; /* 0 and last map ver */ - if (cp1[-3] != KEY_MAP_VER || cp1[-1] > 10 || - i + SHIFT_TBL_SIZE + 4 >= sizeof(spk_key_buf)) { - pr_warn("i %d %d %d %d\n", i, - (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]); - kfree(in_buff); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return -EINVAL; - } - while (--i >= 0) { - cp = spk_s2uchar(cp, cp1); - cp1++; - if (!(*cp)) - break; - } - if (i != 0 || cp1[-1] != KEY_MAP_VER || cp1[-2] != 0) { - ret = -EINVAL; - pr_warn("end %d %d %d %d\n", i, - (int)cp1[-3], (int)cp1[-2], (int)cp1[-1]); - } else { - if (spk_set_key_info(in_buff, spk_key_buf)) { - spk_set_key_info(spk_key_defaults, spk_key_buf); - ret = -EINVAL; - pr_warn("set key failed\n"); - } - } - kfree(in_buff); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return ret; -} - -/* - * This is called when a user changes the value of the silent parameter. - */ -static ssize_t silent_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) -{ - int len; - struct vc_data *vc = vc_cons[fg_console].d; - char ch = 0; - char shut; - unsigned long flags; - - len = strlen(buf); - if (len > 0 && len < 3) { - ch = buf[0]; - if (ch == '\n') - ch = '0'; - } - if (ch < '0' || ch > '7') { - pr_warn("silent value '%c' not in range (0,7)\n", ch); - return -EINVAL; - } - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (ch & 2) { - shut = 1; - spk_do_flush(); - } else { - shut = 0; - } - if (ch & 4) - shut |= 0x40; - if (ch & 1) - spk_shut_up |= shut; - else - spk_shut_up &= ~shut; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return count; -} - -/* - * This is called when a user reads the synth setting. - */ -static ssize_t synth_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) -{ - int rv; - - if (!synth) - rv = sprintf(buf, "%s\n", "none"); - else - rv = sprintf(buf, "%s\n", synth->name); - return rv; -} - -/* - * This is called when a user requests to change synthesizers. - */ -static ssize_t synth_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) -{ - int len; - char new_synth_name[10]; - - len = strlen(buf); - if (len < 2 || len > 9) - return -EINVAL; - memcpy(new_synth_name, buf, len); - if (new_synth_name[len - 1] == '\n') - len--; - new_synth_name[len] = '\0'; - spk_strlwr(new_synth_name); - if (synth && !strcmp(new_synth_name, synth->name)) { - pr_warn("%s already in use\n", new_synth_name); - } else if (synth_init(new_synth_name) != 0) { - pr_warn("failed to init synth %s\n", new_synth_name); - return -ENODEV; - } - return count; -} - -/* - * This is called when text is sent to the synth via the synth_direct file. - */ -static ssize_t synth_direct_store(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, size_t count) -{ - u_char tmp[256]; - int len; - int bytes; - const char *ptr = buf; - unsigned long flags; - - if (!synth) - return -EPERM; - - len = strlen(buf); - spin_lock_irqsave(&speakup_info.spinlock, flags); - while (len > 0) { - bytes = min_t(size_t, len, 250); - strncpy(tmp, ptr, bytes); - tmp[bytes] = '\0'; - string_unescape_any_inplace(tmp); - synth_printf("%s", tmp); - ptr += bytes; - len -= bytes; - } - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return count; -} - -/* - * This function is called when a user reads the version. - */ -static ssize_t version_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) -{ - char *cp; - - cp = buf; - cp += sprintf(cp, "Speakup version %s\n", SPEAKUP_VERSION); - if (synth) - cp += sprintf(cp, "%s synthesizer driver version %s\n", - synth->name, synth->version); - return cp - buf; -} - -/* - * This is called when a user reads the punctuation settings. - */ -static ssize_t punc_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) -{ - int i; - char *cp = buf; - struct st_var_header *p_header; - struct punc_var_t *var; - struct st_bits_data *pb; - short mask; - unsigned long flags; - - p_header = spk_var_header_by_name(attr->attr.name); - if (!p_header) { - pr_warn("p_header is null, attr->attr.name is %s\n", - attr->attr.name); - return -EINVAL; - } - - var = spk_get_punc_var(p_header->var_id); - if (!var) { - pr_warn("var is null, p_header->var_id is %i\n", - p_header->var_id); - return -EINVAL; - } - - spin_lock_irqsave(&speakup_info.spinlock, flags); - pb = (struct st_bits_data *)&spk_punc_info[var->value]; - mask = pb->mask; - for (i = 33; i < 128; i++) { - if (!(spk_chartab[i] & mask)) - continue; - *cp++ = (char)i; - } - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return cp - buf; -} - -/* - * This is called when a user changes the punctuation settings. - */ -static ssize_t punc_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) -{ - int x; - struct st_var_header *p_header; - struct punc_var_t *var; - char punc_buf[100]; - unsigned long flags; - - x = strlen(buf); - if (x < 1 || x > 99) - return -EINVAL; - - p_header = spk_var_header_by_name(attr->attr.name); - if (!p_header) { - pr_warn("p_header is null, attr->attr.name is %s\n", - attr->attr.name); - return -EINVAL; - } - - var = spk_get_punc_var(p_header->var_id); - if (!var) { - pr_warn("var is null, p_header->var_id is %i\n", - p_header->var_id); - return -EINVAL; - } - - memcpy(punc_buf, buf, x); - - while (x && punc_buf[x - 1] == '\n') - x--; - punc_buf[x] = '\0'; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - - if (*punc_buf == 'd' || *punc_buf == 'r') - x = spk_set_mask_bits(NULL, var->value, 3); - else - x = spk_set_mask_bits(punc_buf, var->value, 3); - - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return count; -} - -/* - * This function is called when a user reads one of the variable parameters. - */ -ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) -{ - int rv = 0; - struct st_var_header *param; - struct var_t *var; - char *cp1; - char *cp; - char ch; - unsigned long flags; - - param = spk_var_header_by_name(attr->attr.name); - if (!param) - return -EINVAL; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - var = (struct var_t *)param->data; - switch (param->var_type) { - case VAR_NUM: - case VAR_TIME: - if (var) - rv = sprintf(buf, "%i\n", var->u.n.value); - else - rv = sprintf(buf, "0\n"); - break; - case VAR_STRING: - if (var) { - cp1 = buf; - *cp1++ = '"'; - for (cp = (char *)param->p_val; (ch = *cp); cp++) { - if (ch >= ' ' && ch < '~') - *cp1++ = ch; - else - cp1 += sprintf(cp1, "\\x%02x", ch); - } - *cp1++ = '"'; - *cp1++ = '\n'; - *cp1 = '\0'; - rv = cp1 - buf; - } else { - rv = sprintf(buf, "\"\"\n"); - } - break; - default: - rv = sprintf(buf, "Bad parameter %s, type %i\n", - param->name, param->var_type); - break; - } - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return rv; -} -EXPORT_SYMBOL_GPL(spk_var_show); - -/* - * Used to reset either default_pitch or default_vol. - */ -static inline void spk_reset_default_value(char *header_name, - int *synth_default_value, int idx) -{ - struct st_var_header *param; - - if (synth && synth_default_value) { - param = spk_var_header_by_name(header_name); - if (param) { - spk_set_num_var(synth_default_value[idx], - param, E_NEW_DEFAULT); - spk_set_num_var(0, param, E_DEFAULT); - pr_info("%s reset to default value\n", param->name); - } - } -} - -/* - * This function is called when a user echos a value to one of the - * variable parameters. - */ -ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) -{ - struct st_var_header *param; - int ret; - int len; - char *cp; - struct var_t *var_data; - long value; - unsigned long flags; - - param = spk_var_header_by_name(attr->attr.name); - if (!param) - return -EINVAL; - if (!param->data) - return 0; - ret = 0; - cp = (char *)buf; - string_unescape_any_inplace(cp); - - spin_lock_irqsave(&speakup_info.spinlock, flags); - switch (param->var_type) { - case VAR_NUM: - case VAR_TIME: - if (*cp == 'd' || *cp == 'r' || *cp == '\0') - len = E_DEFAULT; - else if (*cp == '+' || *cp == '-') - len = E_INC; - else - len = E_SET; - if (kstrtol(cp, 10, &value) == 0) - ret = spk_set_num_var(value, param, len); - else - pr_warn("overflow or parsing error has occurred"); - if (ret == -ERANGE) { - var_data = param->data; - pr_warn("value for %s out of range, expect %d to %d\n", - param->name, - var_data->u.n.low, var_data->u.n.high); - } - - /* - * If voice was just changed, we might need to reset our default - * pitch and volume. - */ - if (param->var_id == VOICE && synth && - (ret == 0 || ret == -ERESTART)) { - var_data = param->data; - value = var_data->u.n.value; - spk_reset_default_value("pitch", synth->default_pitch, - value); - spk_reset_default_value("vol", synth->default_vol, - value); - } - break; - case VAR_STRING: - len = strlen(cp); - if ((len >= 1) && (cp[len - 1] == '\n')) - --len; - if ((len >= 2) && (cp[0] == '"') && (cp[len - 1] == '"')) { - ++cp; - len -= 2; - } - cp[len] = '\0'; - ret = spk_set_string_var(cp, param, len); - if (ret == -E2BIG) - pr_warn("value too long for %s\n", - param->name); - break; - default: - pr_warn("%s unknown type %d\n", - param->name, (int)param->var_type); - break; - } - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - - if (ret == -ERESTART) - pr_info("%s reset to default value\n", param->name); - return count; -} -EXPORT_SYMBOL_GPL(spk_var_store); - -/* - * Functions for reading and writing lists of i18n messages. Incomplete. - */ - -static ssize_t message_show_helper(char *buf, enum msg_index_t first, - enum msg_index_t last) -{ - size_t bufsize = PAGE_SIZE; - char *buf_pointer = buf; - int printed; - enum msg_index_t cursor; - int index = 0; - *buf_pointer = '\0'; /* buf_pointer always looking at a NUL byte. */ - - for (cursor = first; cursor <= last; cursor++, index++) { - if (bufsize <= 1) - break; - printed = scnprintf(buf_pointer, bufsize, "%d\t%s\n", - index, spk_msg_get(cursor)); - buf_pointer += printed; - bufsize -= printed; - } - - return buf_pointer - buf; -} - -static void report_msg_status(int reset, int received, int used, - int rejected, char *groupname) -{ - int len; - char buf[160]; - - if (reset) { - pr_info("i18n messages from group %s reset to defaults\n", - groupname); - } else if (received) { - len = snprintf(buf, sizeof(buf), - " updated %d of %d i18n messages from group %s\n", - used, received, groupname); - if (rejected) - snprintf(buf + (len - 1), sizeof(buf) - (len - 1), - " with %d reject%s\n", - rejected, rejected > 1 ? "s" : ""); - pr_info("%s", buf); - } -} - -static ssize_t message_store_helper(const char *buf, size_t count, - struct msg_group_t *group) -{ - char *cp = (char *)buf; - char *end = cp + count; - char *linefeed = NULL; - char *temp = NULL; - ssize_t msg_stored = 0; - ssize_t retval = count; - size_t desc_length = 0; - unsigned long index = 0; - int received = 0; - int used = 0; - int rejected = 0; - int reset = 0; - enum msg_index_t firstmessage = group->start; - enum msg_index_t lastmessage = group->end; - enum msg_index_t curmessage; - - while (cp < end) { - while ((cp < end) && (*cp == ' ' || *cp == '\t')) - cp++; - - if (cp == end) - break; - if (strchr("dDrR", *cp)) { - reset = 1; - break; - } - received++; - - linefeed = strchr(cp, '\n'); - if (!linefeed) { - rejected++; - break; - } - - if (!isdigit(*cp)) { - rejected++; - cp = linefeed + 1; - continue; - } - - /* - * Do not replace with kstrtoul: - * here we need temp to be updated - */ - index = simple_strtoul(cp, &temp, 10); - - while ((temp < linefeed) && (*temp == ' ' || *temp == '\t')) - temp++; - - desc_length = linefeed - temp; - curmessage = firstmessage + index; - - /* - * Note the check (curmessage < firstmessage). It is not - * redundant. Suppose that the user gave us an index - * equal to ULONG_MAX - 1. If firstmessage > 1, then - * firstmessage + index < firstmessage! - */ - - if ((curmessage < firstmessage) || (curmessage > lastmessage)) { - rejected++; - cp = linefeed + 1; - continue; - } - - msg_stored = spk_msg_set(curmessage, temp, desc_length); - if (msg_stored < 0) { - retval = msg_stored; - if (msg_stored == -ENOMEM) - reset = 1; - break; - } - - used++; - - cp = linefeed + 1; - } - - if (reset) - spk_reset_msg_group(group); - - report_msg_status(reset, received, used, rejected, group->name); - return retval; -} - -static ssize_t message_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - ssize_t retval = 0; - struct msg_group_t *group = spk_find_msg_group(attr->attr.name); - unsigned long flags; - - if (WARN_ON(!group)) - return -EINVAL; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - retval = message_show_helper(buf, group->start, group->end); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return retval; -} - -static ssize_t message_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) -{ - struct msg_group_t *group = spk_find_msg_group(attr->attr.name); - - if (WARN_ON(!group)) - return -EINVAL; - - return message_store_helper(buf, count, group); -} - -/* - * Declare the attributes. - */ -static struct kobj_attribute keymap_attribute = - __ATTR_RW(keymap); -static struct kobj_attribute silent_attribute = - __ATTR_WO(silent); -static struct kobj_attribute synth_attribute = - __ATTR_RW(synth); -static struct kobj_attribute synth_direct_attribute = - __ATTR_WO(synth_direct); -static struct kobj_attribute version_attribute = - __ATTR_RO(version); - -static struct kobj_attribute delimiters_attribute = - __ATTR(delimiters, 0644, punc_show, punc_store); -static struct kobj_attribute ex_num_attribute = - __ATTR(ex_num, 0644, punc_show, punc_store); -static struct kobj_attribute punc_all_attribute = - __ATTR(punc_all, 0644, punc_show, punc_store); -static struct kobj_attribute punc_most_attribute = - __ATTR(punc_most, 0644, punc_show, punc_store); -static struct kobj_attribute punc_some_attribute = - __ATTR(punc_some, 0644, punc_show, punc_store); -static struct kobj_attribute repeats_attribute = - __ATTR(repeats, 0644, punc_show, punc_store); - -static struct kobj_attribute attrib_bleep_attribute = - __ATTR(attrib_bleep, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute bell_pos_attribute = - __ATTR(bell_pos, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute bleep_time_attribute = - __ATTR(bleep_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute bleeps_attribute = - __ATTR(bleeps, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute cursor_time_attribute = - __ATTR(cursor_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute key_echo_attribute = - __ATTR(key_echo, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute no_interrupt_attribute = - __ATTR(no_interrupt, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute punc_level_attribute = - __ATTR(punc_level, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute reading_punc_attribute = - __ATTR(reading_punc, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute say_control_attribute = - __ATTR(say_control, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute say_word_ctl_attribute = - __ATTR(say_word_ctl, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute spell_delay_attribute = - __ATTR(spell_delay, 0644, spk_var_show, spk_var_store); - -/* - * These attributes are i18n related. - */ -static struct kobj_attribute announcements_attribute = - __ATTR(announcements, 0644, message_show, message_store); -static struct kobj_attribute characters_attribute = - __ATTR(characters, 0644, chars_chartab_show, - chars_chartab_store); -static struct kobj_attribute chartab_attribute = - __ATTR(chartab, 0644, chars_chartab_show, - chars_chartab_store); -static struct kobj_attribute ctl_keys_attribute = - __ATTR(ctl_keys, 0644, message_show, message_store); -static struct kobj_attribute colors_attribute = - __ATTR(colors, 0644, message_show, message_store); -static struct kobj_attribute formatted_attribute = - __ATTR(formatted, 0644, message_show, message_store); -static struct kobj_attribute function_names_attribute = - __ATTR(function_names, 0644, message_show, message_store); -static struct kobj_attribute key_names_attribute = - __ATTR(key_names, 0644, message_show, message_store); -static struct kobj_attribute states_attribute = - __ATTR(states, 0644, message_show, message_store); - -/* - * Create groups of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *main_attrs[] = { - &keymap_attribute.attr, - &silent_attribute.attr, - &synth_attribute.attr, - &synth_direct_attribute.attr, - &version_attribute.attr, - &delimiters_attribute.attr, - &ex_num_attribute.attr, - &punc_all_attribute.attr, - &punc_most_attribute.attr, - &punc_some_attribute.attr, - &repeats_attribute.attr, - &attrib_bleep_attribute.attr, - &bell_pos_attribute.attr, - &bleep_time_attribute.attr, - &bleeps_attribute.attr, - &cursor_time_attribute.attr, - &key_echo_attribute.attr, - &no_interrupt_attribute.attr, - &punc_level_attribute.attr, - &reading_punc_attribute.attr, - &say_control_attribute.attr, - &say_word_ctl_attribute.attr, - &spell_delay_attribute.attr, - NULL, -}; - -static struct attribute *i18n_attrs[] = { - &announcements_attribute.attr, - &characters_attribute.attr, - &chartab_attribute.attr, - &ctl_keys_attribute.attr, - &colors_attribute.attr, - &formatted_attribute.attr, - &function_names_attribute.attr, - &key_names_attribute.attr, - &states_attribute.attr, - NULL, -}; - -/* - * An unnamed attribute group will put all of the attributes directly in - * the kobject directory. If we specify a name, a subdirectory will be - * created for the attributes with the directory being the name of the - * attribute group. - */ -static const struct attribute_group main_attr_group = { - .attrs = main_attrs, -}; - -static const struct attribute_group i18n_attr_group = { - .attrs = i18n_attrs, - .name = "i18n", -}; - -static struct kobject *accessibility_kobj; -struct kobject *speakup_kobj; - -int speakup_kobj_init(void) -{ - int retval; - - /* - * Create a simple kobject with the name of "accessibility", - * located under /sys/ - * - * As this is a simple directory, no uevent will be sent to - * userspace. That is why this function should not be used for - * any type of dynamic kobjects, where the name and number are - * not known ahead of time. - */ - accessibility_kobj = kobject_create_and_add("accessibility", NULL); - if (!accessibility_kobj) { - retval = -ENOMEM; - goto out; - } - - speakup_kobj = kobject_create_and_add("speakup", accessibility_kobj); - if (!speakup_kobj) { - retval = -ENOMEM; - goto err_acc; - } - - /* Create the files associated with this kobject */ - retval = sysfs_create_group(speakup_kobj, &main_attr_group); - if (retval) - goto err_speakup; - - retval = sysfs_create_group(speakup_kobj, &i18n_attr_group); - if (retval) - goto err_group; - - goto out; - -err_group: - sysfs_remove_group(speakup_kobj, &main_attr_group); -err_speakup: - kobject_put(speakup_kobj); -err_acc: - kobject_put(accessibility_kobj); -out: - return retval; -} - -void speakup_kobj_exit(void) -{ - sysfs_remove_group(speakup_kobj, &i18n_attr_group); - sysfs_remove_group(speakup_kobj, &main_attr_group); - kobject_put(speakup_kobj); - kobject_put(accessibility_kobj); -} diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c deleted file mode 100644 index 02471d932d71..000000000000 --- a/drivers/staging/speakup/main.c +++ /dev/null @@ -1,2460 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* speakup.c - * review functions for the speakup screen review package. - * originally written by: Kirk Reiser and Andy Berdan. - * - * extensively modified by David Borowski. - * - ** Copyright (C) 1998 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - */ - -#include -#include -#include -#include /* __get_free_page() and friends */ -#include -#include -#include -#include -#include -#include -#include /* for KT_SHIFT */ -#include /* for vc_kbd_* and friends */ -#include -#include - -/* speakup_*_selection */ -#include -#include -#include -#include -#include - -#include -#include - -#include /* copy_from|to|user() and others */ - -#include "spk_priv.h" -#include "speakup.h" - -#define MAX_DELAY msecs_to_jiffies(500) -#define MINECHOCHAR SPACE - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_AUTHOR("Daniel Drake "); -MODULE_DESCRIPTION("Speakup console speech"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(SPEAKUP_VERSION); - -char *synth_name; -module_param_named(synth, synth_name, charp, 0444); -module_param_named(quiet, spk_quiet_boot, bool, 0444); - -MODULE_PARM_DESC(synth, "Synth to start if speakup is built in."); -MODULE_PARM_DESC(quiet, "Do not announce when the synthesizer is found."); - -special_func spk_special_handler; - -short spk_pitch_shift, synth_flags; -static u16 buf[256]; -int spk_attrib_bleep, spk_bleeps, spk_bleep_time = 10; -int spk_no_intr, spk_spell_delay; -int spk_key_echo, spk_say_word_ctl; -int spk_say_ctrl, spk_bell_pos; -short spk_punc_mask; -int spk_punc_level, spk_reading_punc; -char spk_str_caps_start[MAXVARLEN + 1] = "\0"; -char spk_str_caps_stop[MAXVARLEN + 1] = "\0"; -char spk_str_pause[MAXVARLEN + 1] = "\0"; -bool spk_paused; -const struct st_bits_data spk_punc_info[] = { - {"none", "", 0}, - {"some", "/$%&@", SOME}, - {"most", "$%&#()=+*/@^<>|\\", MOST}, - {"all", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", PUNC}, - {"delimiters", "", B_WDLM}, - {"repeats", "()", CH_RPT}, - {"extended numeric", "", B_EXNUM}, - {"symbols", "", B_SYM}, - {NULL, NULL} -}; - -static char mark_cut_flag; -#define MAX_KEY 160 -static u_char *spk_shift_table; -u_char *spk_our_keys[MAX_KEY]; -u_char spk_key_buf[600]; -const u_char spk_key_defaults[] = { -#include "speakupmap.h" -}; - -/* Speakup Cursor Track Variables */ -static int cursor_track = 1, prev_cursor_track = 1; - -/* cursor track modes, must be ordered same as cursor_msgs */ -enum { - CT_Off = 0, - CT_On, - CT_Highlight, - CT_Window, - CT_Max -}; - -#define read_all_mode CT_Max - -static struct tty_struct *tty; - -static void spkup_write(const u16 *in_buf, int count); - -static char *phonetic[] = { - "alfa", "bravo", "charlie", "delta", "echo", "foxtrot", "golf", "hotel", - "india", "juliett", "keelo", "leema", "mike", "november", "oscar", - "papa", - "keh beck", "romeo", "sierra", "tango", "uniform", "victer", "whiskey", - "x ray", "yankee", "zulu" -}; - -/* array of 256 char pointers (one for each character description) - * initialized to default_chars and user selectable via - * /proc/speakup/characters - */ -char *spk_characters[256]; - -char *spk_default_chars[256] = { -/*000*/ "null", "^a", "^b", "^c", "^d", "^e", "^f", "^g", -/*008*/ "^h", "^i", "^j", "^k", "^l", "^m", "^n", "^o", -/*016*/ "^p", "^q", "^r", "^s", "^t", "^u", "^v", "^w", -/*024*/ "^x", "^y", "^z", "control", "control", "control", "control", - "control", -/*032*/ "space", "bang!", "quote", "number", "dollar", "percent", "and", - "tick", -/*040*/ "left paren", "right paren", "star", "plus", "comma", "dash", - "dot", - "slash", -/*048*/ "zero", "one", "two", "three", "four", "five", "six", "seven", - "eight", "nine", -/*058*/ "colon", "semmy", "less", "equals", "greater", "question", "at", -/*065*/ "EIGH", "B", "C", "D", "E", "F", "G", -/*072*/ "H", "I", "J", "K", "L", "M", "N", "O", -/*080*/ "P", "Q", "R", "S", "T", "U", "V", "W", "X", -/*089*/ "Y", "ZED", "left bracket", "backslash", "right bracket", - "caret", - "line", -/*096*/ "accent", "a", "b", "c", "d", "e", "f", "g", -/*104*/ "h", "i", "j", "k", "l", "m", "n", "o", -/*112*/ "p", "q", "r", "s", "t", "u", "v", "w", -/*120*/ "x", "y", "zed", "left brace", "bar", "right brace", "tihlduh", -/*127*/ "del", "control", "control", "control", "control", "control", - "control", "control", "control", "control", "control", -/*138*/ "control", "control", "control", "control", "control", - "control", "control", "control", "control", "control", - "control", "control", -/*150*/ "control", "control", "control", "control", "control", - "control", "control", "control", "control", "control", -/*160*/ "nbsp", "inverted bang", -/*162*/ "cents", "pounds", "currency", "yen", "broken bar", "section", -/*168*/ "diaeresis", "copyright", "female ordinal", "double left angle", -/*172*/ "not", "soft hyphen", "registered", "macron", -/*176*/ "degrees", "plus or minus", "super two", "super three", -/*180*/ "acute accent", "micro", "pilcrow", "middle dot", -/*184*/ "cedilla", "super one", "male ordinal", "double right angle", -/*188*/ "one quarter", "one half", "three quarters", - "inverted question", -/*192*/ "A GRAVE", "A ACUTE", "A CIRCUMFLEX", "A TILDE", "A OOMLAUT", - "A RING", -/*198*/ "AE", "C CIDELLA", "E GRAVE", "E ACUTE", "E CIRCUMFLEX", - "E OOMLAUT", -/*204*/ "I GRAVE", "I ACUTE", "I CIRCUMFLEX", "I OOMLAUT", "ETH", - "N TILDE", -/*210*/ "O GRAVE", "O ACUTE", "O CIRCUMFLEX", "O TILDE", "O OOMLAUT", -/*215*/ "multiplied by", "O STROKE", "U GRAVE", "U ACUTE", - "U CIRCUMFLEX", -/*220*/ "U OOMLAUT", "Y ACUTE", "THORN", "sharp s", "a grave", -/*225*/ "a acute", "a circumflex", "a tilde", "a oomlaut", "a ring", -/*230*/ "ae", "c cidella", "e grave", "e acute", -/*234*/ "e circumflex", "e oomlaut", "i grave", "i acute", - "i circumflex", -/*239*/ "i oomlaut", "eth", "n tilde", "o grave", "o acute", - "o circumflex", -/*245*/ "o tilde", "o oomlaut", "divided by", "o stroke", "u grave", - "u acute", -/* 251 */ "u circumflex", "u oomlaut", "y acute", "thorn", "y oomlaut" -}; - -/* array of 256 u_short (one for each character) - * initialized to default_chartab and user selectable via - * /sys/module/speakup/parameters/chartab - */ -u_short spk_chartab[256]; - -static u_short default_chartab[256] = { - B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, /* 0-7 */ - B_CTL, B_CTL, A_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, /* 8-15 */ - B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, /*16-23 */ - B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, B_CTL, /* 24-31 */ - WDLM, A_PUNC, PUNC, PUNC, PUNC, PUNC, PUNC, A_PUNC, /* !"#$%&' */ - PUNC, PUNC, PUNC, PUNC, A_PUNC, A_PUNC, A_PUNC, PUNC, /* ()*+, -./ */ - NUM, NUM, NUM, NUM, NUM, NUM, NUM, NUM, /* 01234567 */ - NUM, NUM, A_PUNC, PUNC, PUNC, PUNC, PUNC, A_PUNC, /* 89:;<=>? */ - PUNC, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, /* @ABCDEFG */ - A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, /* HIJKLMNO */ - A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, /* PQRSTUVW */ - A_CAP, A_CAP, A_CAP, PUNC, PUNC, PUNC, PUNC, PUNC, /* XYZ[\]^_ */ - PUNC, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, /* `abcdefg */ - ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, /* hijklmno */ - ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, /* pqrstuvw */ - ALPHA, ALPHA, ALPHA, PUNC, PUNC, PUNC, PUNC, 0, /* xyz{|}~ */ - B_CAPSYM, B_CAPSYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, /* 128-134 */ - B_SYM, /* 135 */ - B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, /* 136-142 */ - B_CAPSYM, /* 143 */ - B_CAPSYM, B_CAPSYM, B_SYM, B_CAPSYM, B_SYM, B_SYM, B_SYM, /* 144-150 */ - B_SYM, /* 151 */ - B_SYM, B_SYM, B_CAPSYM, B_CAPSYM, B_SYM, B_SYM, B_SYM, /*152-158 */ - B_SYM, /* 159 */ - WDLM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_CAPSYM, /* 160-166 */ - B_SYM, /* 167 */ - B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, /* 168-175 */ - B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, /* 176-183 */ - B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, B_SYM, /* 184-191 */ - A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, /* 192-199 */ - A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, /* 200-207 */ - A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, B_SYM, /* 208-215 */ - A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, A_CAP, ALPHA, /* 216-223 */ - ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, /* 224-231 */ - ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, /* 232-239 */ - ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, B_SYM, /* 240-247 */ - ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA, ALPHA /* 248-255 */ -}; - -struct task_struct *speakup_task; -struct bleep spk_unprocessed_sound; -static int spk_keydown; -static u16 spk_lastkey; -static u_char spk_close_press, keymap_flags; -static u_char last_keycode, this_speakup_key; -static u_long last_spk_jiffy; - -struct st_spk_t *speakup_console[MAX_NR_CONSOLES]; - -DEFINE_MUTEX(spk_mutex); - -static int keyboard_notifier_call(struct notifier_block *, - unsigned long code, void *param); - -static struct notifier_block keyboard_notifier_block = { - .notifier_call = keyboard_notifier_call, -}; - -static int vt_notifier_call(struct notifier_block *, - unsigned long code, void *param); - -static struct notifier_block vt_notifier_block = { - .notifier_call = vt_notifier_call, -}; - -static unsigned char get_attributes(struct vc_data *vc, u16 *pos) -{ - pos = screen_pos(vc, pos - (u16 *)vc->vc_origin, 1); - return (scr_readw(pos) & ~vc->vc_hi_font_mask) >> 8; -} - -static void speakup_date(struct vc_data *vc) -{ - spk_x = spk_cx = vc->vc_x; - spk_y = spk_cy = vc->vc_y; - spk_pos = spk_cp = vc->vc_pos; - spk_old_attr = spk_attr; - spk_attr = get_attributes(vc, (u_short *)spk_pos); -} - -static void bleep(u_short val) -{ - static const short vals[] = { - 350, 370, 392, 414, 440, 466, 491, 523, 554, 587, 619, 659 - }; - short freq; - int time = spk_bleep_time; - - freq = vals[val % 12]; - if (val > 11) - freq *= (1 << (val / 12)); - spk_unprocessed_sound.freq = freq; - spk_unprocessed_sound.jiffies = msecs_to_jiffies(time); - spk_unprocessed_sound.active = 1; - /* We can only have 1 active sound at a time. */ -} - -static void speakup_shut_up(struct vc_data *vc) -{ - if (spk_killed) - return; - spk_shut_up |= 0x01; - spk_parked &= 0xfe; - speakup_date(vc); - if (synth) - spk_do_flush(); -} - -static void speech_kill(struct vc_data *vc) -{ - char val = synth->is_alive(synth); - - if (val == 0) - return; - - /* re-enables synth, if disabled */ - if (val == 2 || spk_killed) { - /* dead */ - spk_shut_up &= ~0x40; - synth_printf("%s\n", spk_msg_get(MSG_IAM_ALIVE)); - } else { - synth_printf("%s\n", spk_msg_get(MSG_YOU_KILLED_SPEAKUP)); - spk_shut_up |= 0x40; - } -} - -static void speakup_off(struct vc_data *vc) -{ - if (spk_shut_up & 0x80) { - spk_shut_up &= 0x7f; - synth_printf("%s\n", spk_msg_get(MSG_HEY_THATS_BETTER)); - } else { - spk_shut_up |= 0x80; - synth_printf("%s\n", spk_msg_get(MSG_YOU_TURNED_ME_OFF)); - } - speakup_date(vc); -} - -static void speakup_parked(struct vc_data *vc) -{ - if (spk_parked & 0x80) { - spk_parked = 0; - synth_printf("%s\n", spk_msg_get(MSG_UNPARKED)); - } else { - spk_parked |= 0x80; - synth_printf("%s\n", spk_msg_get(MSG_PARKED)); - } -} - -static void speakup_cut(struct vc_data *vc) -{ - static const char err_buf[] = "set selection failed"; - int ret; - - if (!mark_cut_flag) { - mark_cut_flag = 1; - spk_xs = (u_short)spk_x; - spk_ys = (u_short)spk_y; - spk_sel_cons = vc; - synth_printf("%s\n", spk_msg_get(MSG_MARK)); - return; - } - spk_xe = (u_short)spk_x; - spk_ye = (u_short)spk_y; - mark_cut_flag = 0; - synth_printf("%s\n", spk_msg_get(MSG_CUT)); - - speakup_clear_selection(); - ret = speakup_set_selection(tty); - - switch (ret) { - case 0: - break; /* no error */ - case -EFAULT: - pr_warn("%sEFAULT\n", err_buf); - break; - case -EINVAL: - pr_warn("%sEINVAL\n", err_buf); - break; - case -ENOMEM: - pr_warn("%sENOMEM\n", err_buf); - break; - } -} - -static void speakup_paste(struct vc_data *vc) -{ - if (mark_cut_flag) { - mark_cut_flag = 0; - synth_printf("%s\n", spk_msg_get(MSG_MARK_CLEARED)); - } else { - synth_printf("%s\n", spk_msg_get(MSG_PASTE)); - speakup_paste_selection(tty); - } -} - -static void say_attributes(struct vc_data *vc) -{ - int fg = spk_attr & 0x0f; - int bg = spk_attr >> 4; - - if (fg > 8) { - synth_printf("%s ", spk_msg_get(MSG_BRIGHT)); - fg -= 8; - } - synth_printf("%s", spk_msg_get(MSG_COLORS_START + fg)); - if (bg > 7) { - synth_printf(" %s ", spk_msg_get(MSG_ON_BLINKING)); - bg -= 8; - } else { - synth_printf(" %s ", spk_msg_get(MSG_ON)); - } - synth_printf("%s\n", spk_msg_get(MSG_COLORS_START + bg)); -} - -enum { - edge_top = 1, - edge_bottom, - edge_left, - edge_right, - edge_quiet -}; - -static void announce_edge(struct vc_data *vc, int msg_id) -{ - if (spk_bleeps & 1) - bleep(spk_y); - if ((spk_bleeps & 2) && (msg_id < edge_quiet)) - synth_printf("%s\n", - spk_msg_get(MSG_EDGE_MSGS_START + msg_id - 1)); -} - -static void speak_char(u16 ch) -{ - char *cp; - struct var_t *direct = spk_get_var(DIRECT); - - if (ch >= 0x100 || (direct && direct->u.n.value)) { - if (ch < 0x100 && IS_CHAR(ch, B_CAP)) { - spk_pitch_shift++; - synth_printf("%s", spk_str_caps_start); - } - synth_putwc_s(ch); - if (ch < 0x100 && IS_CHAR(ch, B_CAP)) - synth_printf("%s", spk_str_caps_stop); - return; - } - - cp = spk_characters[ch]; - if (!cp) { - pr_info("%s: cp == NULL!\n", __func__); - return; - } - if (IS_CHAR(ch, B_CAP)) { - spk_pitch_shift++; - synth_printf("%s %s %s", - spk_str_caps_start, cp, spk_str_caps_stop); - } else { - if (*cp == '^') { - cp++; - synth_printf(" %s%s ", spk_msg_get(MSG_CTRL), cp); - } else { - synth_printf(" %s ", cp); - } - } -} - -static u16 get_char(struct vc_data *vc, u16 *pos, u_char *attribs) -{ - u16 ch = ' '; - - if (vc && pos) { - u16 w; - u16 c; - - pos = screen_pos(vc, pos - (u16 *)vc->vc_origin, 1); - w = scr_readw(pos); - c = w & 0xff; - - if (w & vc->vc_hi_font_mask) { - w &= ~vc->vc_hi_font_mask; - c |= 0x100; - } - - ch = inverse_translate(vc, c, 1); - *attribs = (w & 0xff00) >> 8; - } - return ch; -} - -static void say_char(struct vc_data *vc) -{ - u16 ch; - - spk_old_attr = spk_attr; - ch = get_char(vc, (u_short *)spk_pos, &spk_attr); - if (spk_attr != spk_old_attr) { - if (spk_attrib_bleep & 1) - bleep(spk_y); - if (spk_attrib_bleep & 2) - say_attributes(vc); - } - speak_char(ch); -} - -static void say_phonetic_char(struct vc_data *vc) -{ - u16 ch; - - spk_old_attr = spk_attr; - ch = get_char(vc, (u_short *)spk_pos, &spk_attr); - if (ch <= 0x7f && isalpha(ch)) { - ch &= 0x1f; - synth_printf("%s\n", phonetic[--ch]); - } else { - if (ch < 0x100 && IS_CHAR(ch, B_NUM)) - synth_printf("%s ", spk_msg_get(MSG_NUMBER)); - speak_char(ch); - } -} - -static void say_prev_char(struct vc_data *vc) -{ - spk_parked |= 0x01; - if (spk_x == 0) { - announce_edge(vc, edge_left); - return; - } - spk_x--; - spk_pos -= 2; - say_char(vc); -} - -static void say_next_char(struct vc_data *vc) -{ - spk_parked |= 0x01; - if (spk_x == vc->vc_cols - 1) { - announce_edge(vc, edge_right); - return; - } - spk_x++; - spk_pos += 2; - say_char(vc); -} - -/* get_word - will first check to see if the character under the - * reading cursor is a space and if spk_say_word_ctl is true it will - * return the word space. If spk_say_word_ctl is not set it will check to - * see if there is a word starting on the next position to the right - * and return that word if it exists. If it does not exist it will - * move left to the beginning of any previous word on the line or the - * beginning off the line whichever comes first.. - */ - -static u_long get_word(struct vc_data *vc) -{ - u_long cnt = 0, tmpx = spk_x, tmp_pos = spk_pos; - u16 ch; - u16 attr_ch; - u_char temp; - - spk_old_attr = spk_attr; - ch = get_char(vc, (u_short *)tmp_pos, &temp); - -/* decided to take out the sayword if on a space (mis-information */ - if (spk_say_word_ctl && ch == SPACE) { - *buf = '\0'; - synth_printf("%s\n", spk_msg_get(MSG_SPACE)); - return 0; - } else if (tmpx < vc->vc_cols - 2 && - (ch == SPACE || ch == 0 || (ch < 0x100 && IS_WDLM(ch))) && - get_char(vc, (u_short *)tmp_pos + 1, &temp) > SPACE) { - tmp_pos += 2; - tmpx++; - } else { - while (tmpx > 0) { - ch = get_char(vc, (u_short *)tmp_pos - 1, &temp); - if ((ch == SPACE || ch == 0 || - (ch < 0x100 && IS_WDLM(ch))) && - get_char(vc, (u_short *)tmp_pos, &temp) > SPACE) - break; - tmp_pos -= 2; - tmpx--; - } - } - attr_ch = get_char(vc, (u_short *)tmp_pos, &spk_attr); - buf[cnt++] = attr_ch; - while (tmpx < vc->vc_cols - 1) { - tmp_pos += 2; - tmpx++; - ch = get_char(vc, (u_short *)tmp_pos, &temp); - if (ch == SPACE || ch == 0 || - (buf[cnt - 1] < 0x100 && IS_WDLM(buf[cnt - 1]) && - ch > SPACE)) - break; - buf[cnt++] = ch; - } - buf[cnt] = '\0'; - return cnt; -} - -static void say_word(struct vc_data *vc) -{ - u_long cnt = get_word(vc); - u_short saved_punc_mask = spk_punc_mask; - - if (cnt == 0) - return; - spk_punc_mask = PUNC; - buf[cnt++] = SPACE; - spkup_write(buf, cnt); - spk_punc_mask = saved_punc_mask; -} - -static void say_prev_word(struct vc_data *vc) -{ - u_char temp; - u16 ch; - u_short edge_said = 0, last_state = 0, state = 0; - - spk_parked |= 0x01; - - if (spk_x == 0) { - if (spk_y == 0) { - announce_edge(vc, edge_top); - return; - } - spk_y--; - spk_x = vc->vc_cols; - edge_said = edge_quiet; - } - while (1) { - if (spk_x == 0) { - if (spk_y == 0) { - edge_said = edge_top; - break; - } - if (edge_said != edge_quiet) - edge_said = edge_left; - if (state > 0) - break; - spk_y--; - spk_x = vc->vc_cols - 1; - } else { - spk_x--; - } - spk_pos -= 2; - ch = get_char(vc, (u_short *)spk_pos, &temp); - if (ch == SPACE || ch == 0) - state = 0; - else if (ch < 0x100 && IS_WDLM(ch)) - state = 1; - else - state = 2; - if (state < last_state) { - spk_pos += 2; - spk_x++; - break; - } - last_state = state; - } - if (spk_x == 0 && edge_said == edge_quiet) - edge_said = edge_left; - if (edge_said > 0 && edge_said < edge_quiet) - announce_edge(vc, edge_said); - say_word(vc); -} - -static void say_next_word(struct vc_data *vc) -{ - u_char temp; - u16 ch; - u_short edge_said = 0, last_state = 2, state = 0; - - spk_parked |= 0x01; - if (spk_x == vc->vc_cols - 1 && spk_y == vc->vc_rows - 1) { - announce_edge(vc, edge_bottom); - return; - } - while (1) { - ch = get_char(vc, (u_short *)spk_pos, &temp); - if (ch == SPACE || ch == 0) - state = 0; - else if (ch < 0x100 && IS_WDLM(ch)) - state = 1; - else - state = 2; - if (state > last_state) - break; - if (spk_x >= vc->vc_cols - 1) { - if (spk_y == vc->vc_rows - 1) { - edge_said = edge_bottom; - break; - } - state = 0; - spk_y++; - spk_x = 0; - edge_said = edge_right; - } else { - spk_x++; - } - spk_pos += 2; - last_state = state; - } - if (edge_said > 0) - announce_edge(vc, edge_said); - say_word(vc); -} - -static void spell_word(struct vc_data *vc) -{ - static char const *delay_str[] = { "", ",", ".", ". .", ". . ." }; - u16 *cp = buf; - char *cp1; - char *str_cap = spk_str_caps_stop; - char *last_cap = spk_str_caps_stop; - struct var_t *direct = spk_get_var(DIRECT); - u16 ch; - - if (!get_word(vc)) - return; - while ((ch = *cp)) { - if (cp != buf) - synth_printf(" %s ", delay_str[spk_spell_delay]); - /* FIXME: Non-latin1 considered as lower case */ - if (ch < 0x100 && IS_CHAR(ch, B_CAP)) { - str_cap = spk_str_caps_start; - if (*spk_str_caps_stop) - spk_pitch_shift++; - else /* synth has no pitch */ - last_cap = spk_str_caps_stop; - } else { - str_cap = spk_str_caps_stop; - } - if (str_cap != last_cap) { - synth_printf("%s", str_cap); - last_cap = str_cap; - } - if (ch >= 0x100 || (direct && direct->u.n.value)) { - synth_putwc_s(ch); - } else if (this_speakup_key == SPELL_PHONETIC && - ch <= 0x7f && isalpha(ch)) { - ch &= 0x1f; - cp1 = phonetic[--ch]; - synth_printf("%s", cp1); - } else { - cp1 = spk_characters[ch]; - if (*cp1 == '^') { - synth_printf("%s", spk_msg_get(MSG_CTRL)); - cp1++; - } - synth_printf("%s", cp1); - } - cp++; - } - if (str_cap != spk_str_caps_stop) - synth_printf("%s", spk_str_caps_stop); -} - -static int get_line(struct vc_data *vc) -{ - u_long tmp = spk_pos - (spk_x * 2); - int i = 0; - u_char tmp2; - - spk_old_attr = spk_attr; - spk_attr = get_attributes(vc, (u_short *)spk_pos); - for (i = 0; i < vc->vc_cols; i++) { - buf[i] = get_char(vc, (u_short *)tmp, &tmp2); - tmp += 2; - } - for (--i; i >= 0; i--) - if (buf[i] != SPACE) - break; - return ++i; -} - -static void say_line(struct vc_data *vc) -{ - int i = get_line(vc); - u16 *cp; - u_short saved_punc_mask = spk_punc_mask; - - if (i == 0) { - synth_printf("%s\n", spk_msg_get(MSG_BLANK)); - return; - } - buf[i++] = '\n'; - if (this_speakup_key == SAY_LINE_INDENT) { - cp = buf; - while (*cp == SPACE) - cp++; - synth_printf("%zd, ", (cp - buf) + 1); - } - spk_punc_mask = spk_punc_masks[spk_reading_punc]; - spkup_write(buf, i); - spk_punc_mask = saved_punc_mask; -} - -static void say_prev_line(struct vc_data *vc) -{ - spk_parked |= 0x01; - if (spk_y == 0) { - announce_edge(vc, edge_top); - return; - } - spk_y--; - spk_pos -= vc->vc_size_row; - say_line(vc); -} - -static void say_next_line(struct vc_data *vc) -{ - spk_parked |= 0x01; - if (spk_y == vc->vc_rows - 1) { - announce_edge(vc, edge_bottom); - return; - } - spk_y++; - spk_pos += vc->vc_size_row; - say_line(vc); -} - -static int say_from_to(struct vc_data *vc, u_long from, u_long to, - int read_punc) -{ - int i = 0; - u_char tmp; - u_short saved_punc_mask = spk_punc_mask; - - spk_old_attr = spk_attr; - spk_attr = get_attributes(vc, (u_short *)from); - while (from < to) { - buf[i++] = get_char(vc, (u_short *)from, &tmp); - from += 2; - if (i >= vc->vc_size_row) - break; - } - for (--i; i >= 0; i--) - if (buf[i] != SPACE) - break; - buf[++i] = SPACE; - buf[++i] = '\0'; - if (i < 1) - return i; - if (read_punc) - spk_punc_mask = spk_punc_info[spk_reading_punc].mask; - spkup_write(buf, i); - if (read_punc) - spk_punc_mask = saved_punc_mask; - return i - 1; -} - -static void say_line_from_to(struct vc_data *vc, u_long from, u_long to, - int read_punc) -{ - u_long start = vc->vc_origin + (spk_y * vc->vc_size_row); - u_long end = start + (to * 2); - - start += from * 2; - if (say_from_to(vc, start, end, read_punc) <= 0) - if (cursor_track != read_all_mode) - synth_printf("%s\n", spk_msg_get(MSG_BLANK)); -} - -/* Sentence Reading Commands */ - -static int currsentence; -static int numsentences[2]; -static u16 *sentbufend[2]; -static u16 *sentmarks[2][10]; -static int currbuf; -static int bn; -static u16 sentbuf[2][256]; - -static int say_sentence_num(int num, int prev) -{ - bn = currbuf; - currsentence = num + 1; - if (prev && --bn == -1) - bn = 1; - - if (num > numsentences[bn]) - return 0; - - spkup_write(sentmarks[bn][num], sentbufend[bn] - sentmarks[bn][num]); - return 1; -} - -static int get_sentence_buf(struct vc_data *vc, int read_punc) -{ - u_long start, end; - int i, bn; - u_char tmp; - - currbuf++; - if (currbuf == 2) - currbuf = 0; - bn = currbuf; - start = vc->vc_origin + ((spk_y) * vc->vc_size_row); - end = vc->vc_origin + ((spk_y) * vc->vc_size_row) + vc->vc_cols * 2; - - numsentences[bn] = 0; - sentmarks[bn][0] = &sentbuf[bn][0]; - i = 0; - spk_old_attr = spk_attr; - spk_attr = get_attributes(vc, (u_short *)start); - - while (start < end) { - sentbuf[bn][i] = get_char(vc, (u_short *)start, &tmp); - if (i > 0) { - if (sentbuf[bn][i] == SPACE && - sentbuf[bn][i - 1] == '.' && - numsentences[bn] < 9) { - /* Sentence Marker */ - numsentences[bn]++; - sentmarks[bn][numsentences[bn]] = - &sentbuf[bn][i]; - } - } - i++; - start += 2; - if (i >= vc->vc_size_row) - break; - } - - for (--i; i >= 0; i--) - if (sentbuf[bn][i] != SPACE) - break; - - if (i < 1) - return -1; - - sentbuf[bn][++i] = SPACE; - sentbuf[bn][++i] = '\0'; - - sentbufend[bn] = &sentbuf[bn][i]; - return numsentences[bn]; -} - -static void say_screen_from_to(struct vc_data *vc, u_long from, u_long to) -{ - u_long start = vc->vc_origin, end; - - if (from > 0) - start += from * vc->vc_size_row; - if (to > vc->vc_rows) - to = vc->vc_rows; - end = vc->vc_origin + (to * vc->vc_size_row); - for (from = start; from < end; from = to) { - to = from + vc->vc_size_row; - say_from_to(vc, from, to, 1); - } -} - -static void say_screen(struct vc_data *vc) -{ - say_screen_from_to(vc, 0, vc->vc_rows); -} - -static void speakup_win_say(struct vc_data *vc) -{ - u_long start, end, from, to; - - if (win_start < 2) { - synth_printf("%s\n", spk_msg_get(MSG_NO_WINDOW)); - return; - } - start = vc->vc_origin + (win_top * vc->vc_size_row); - end = vc->vc_origin + (win_bottom * vc->vc_size_row); - while (start <= end) { - from = start + (win_left * 2); - to = start + (win_right * 2); - say_from_to(vc, from, to, 1); - start += vc->vc_size_row; - } -} - -static void top_edge(struct vc_data *vc) -{ - spk_parked |= 0x01; - spk_pos = vc->vc_origin + 2 * spk_x; - spk_y = 0; - say_line(vc); -} - -static void bottom_edge(struct vc_data *vc) -{ - spk_parked |= 0x01; - spk_pos += (vc->vc_rows - spk_y - 1) * vc->vc_size_row; - spk_y = vc->vc_rows - 1; - say_line(vc); -} - -static void left_edge(struct vc_data *vc) -{ - spk_parked |= 0x01; - spk_pos -= spk_x * 2; - spk_x = 0; - say_char(vc); -} - -static void right_edge(struct vc_data *vc) -{ - spk_parked |= 0x01; - spk_pos += (vc->vc_cols - spk_x - 1) * 2; - spk_x = vc->vc_cols - 1; - say_char(vc); -} - -static void say_first_char(struct vc_data *vc) -{ - int i, len = get_line(vc); - u16 ch; - - spk_parked |= 0x01; - if (len == 0) { - synth_printf("%s\n", spk_msg_get(MSG_BLANK)); - return; - } - for (i = 0; i < len; i++) - if (buf[i] != SPACE) - break; - ch = buf[i]; - spk_pos -= (spk_x - i) * 2; - spk_x = i; - synth_printf("%d, ", ++i); - speak_char(ch); -} - -static void say_last_char(struct vc_data *vc) -{ - int len = get_line(vc); - u16 ch; - - spk_parked |= 0x01; - if (len == 0) { - synth_printf("%s\n", spk_msg_get(MSG_BLANK)); - return; - } - ch = buf[--len]; - spk_pos -= (spk_x - len) * 2; - spk_x = len; - synth_printf("%d, ", ++len); - speak_char(ch); -} - -static void say_position(struct vc_data *vc) -{ - synth_printf(spk_msg_get(MSG_POS_INFO), spk_y + 1, spk_x + 1, - vc->vc_num + 1); - synth_printf("\n"); -} - -/* Added by brianb */ -static void say_char_num(struct vc_data *vc) -{ - u_char tmp; - u16 ch = get_char(vc, (u_short *)spk_pos, &tmp); - - synth_printf(spk_msg_get(MSG_CHAR_INFO), ch, ch); -} - -/* these are stub functions to keep keyboard.c happy. */ - -static void say_from_top(struct vc_data *vc) -{ - say_screen_from_to(vc, 0, spk_y); -} - -static void say_to_bottom(struct vc_data *vc) -{ - say_screen_from_to(vc, spk_y, vc->vc_rows); -} - -static void say_from_left(struct vc_data *vc) -{ - say_line_from_to(vc, 0, spk_x, 1); -} - -static void say_to_right(struct vc_data *vc) -{ - say_line_from_to(vc, spk_x, vc->vc_cols, 1); -} - -/* end of stub functions. */ - -static void spkup_write(const u16 *in_buf, int count) -{ - static int rep_count; - static u16 ch = '\0', old_ch = '\0'; - static u_short char_type, last_type; - int in_count = count; - - spk_keydown = 0; - while (count--) { - if (cursor_track == read_all_mode) { - /* Insert Sentence Index */ - if ((in_buf == sentmarks[bn][currsentence]) && - (currsentence <= numsentences[bn])) - synth_insert_next_index(currsentence++); - } - ch = *in_buf++; - if (ch < 0x100) - char_type = spk_chartab[ch]; - else - char_type = ALPHA; - if (ch == old_ch && !(char_type & B_NUM)) { - if (++rep_count > 2) - continue; - } else { - if ((last_type & CH_RPT) && rep_count > 2) { - synth_printf(" "); - synth_printf(spk_msg_get(MSG_REPEAT_DESC), - ++rep_count); - synth_printf(" "); - } - rep_count = 0; - } - if (ch == spk_lastkey) { - rep_count = 0; - if (spk_key_echo == 1 && ch >= MINECHOCHAR) - speak_char(ch); - } else if (char_type & B_ALPHA) { - if ((synth_flags & SF_DEC) && (last_type & PUNC)) - synth_buffer_add(SPACE); - synth_putwc_s(ch); - } else if (char_type & B_NUM) { - rep_count = 0; - synth_putwc_s(ch); - } else if (char_type & spk_punc_mask) { - speak_char(ch); - char_type &= ~PUNC; /* for dec nospell processing */ - } else if (char_type & SYNTH_OK) { - /* these are usually puncts like . and , which synth - * needs for expression. - * suppress multiple to get rid of long pauses and - * clear repeat count - * so if someone has - * repeats on you don't get nothing repeated count - */ - if (ch != old_ch) - synth_putwc_s(ch); - else - rep_count = 0; - } else { -/* send space and record position, if next is num overwrite space */ - if (old_ch != ch) - synth_buffer_add(SPACE); - else - rep_count = 0; - } - old_ch = ch; - last_type = char_type; - } - spk_lastkey = 0; - if (in_count > 2 && rep_count > 2) { - if (last_type & CH_RPT) { - synth_printf(" "); - synth_printf(spk_msg_get(MSG_REPEAT_DESC2), - ++rep_count); - synth_printf(" "); - } - rep_count = 0; - } -} - -static const int NUM_CTL_LABELS = (MSG_CTL_END - MSG_CTL_START + 1); - -static void read_all_doc(struct vc_data *vc); -static void cursor_done(struct timer_list *unused); -static DEFINE_TIMER(cursor_timer, cursor_done); - -static void do_handle_shift(struct vc_data *vc, u_char value, char up_flag) -{ - unsigned long flags; - - if (!synth || up_flag || spk_killed) - return; - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (cursor_track == read_all_mode) { - switch (value) { - case KVAL(K_SHIFT): - del_timer(&cursor_timer); - spk_shut_up &= 0xfe; - spk_do_flush(); - read_all_doc(vc); - break; - case KVAL(K_CTRL): - del_timer(&cursor_timer); - cursor_track = prev_cursor_track; - spk_shut_up &= 0xfe; - spk_do_flush(); - break; - } - } else { - spk_shut_up &= 0xfe; - spk_do_flush(); - } - if (spk_say_ctrl && value < NUM_CTL_LABELS) - synth_printf("%s", spk_msg_get(MSG_CTL_START + value)); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); -} - -static void do_handle_latin(struct vc_data *vc, u_char value, char up_flag) -{ - unsigned long flags; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (up_flag) { - spk_lastkey = 0; - spk_keydown = 0; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return; - } - if (!synth || spk_killed) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return; - } - spk_shut_up &= 0xfe; - spk_lastkey = value; - spk_keydown++; - spk_parked &= 0xfe; - if (spk_key_echo == 2 && value >= MINECHOCHAR) - speak_char(value); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); -} - -int spk_set_key_info(const u_char *key_info, u_char *k_buffer) -{ - int i = 0, states, key_data_len; - const u_char *cp = key_info; - u_char *cp1 = k_buffer; - u_char ch, version, num_keys; - - version = *cp++; - if (version != KEY_MAP_VER) { - pr_debug("version found %d should be %d\n", - version, KEY_MAP_VER); - return -EINVAL; - } - num_keys = *cp; - states = (int)cp[1]; - key_data_len = (states + 1) * (num_keys + 1); - if (key_data_len + SHIFT_TBL_SIZE + 4 >= sizeof(spk_key_buf)) { - pr_debug("too many key_infos (%d over %u)\n", - key_data_len + SHIFT_TBL_SIZE + 4, - (unsigned int)(sizeof(spk_key_buf))); - return -EINVAL; - } - memset(k_buffer, 0, SHIFT_TBL_SIZE); - memset(spk_our_keys, 0, sizeof(spk_our_keys)); - spk_shift_table = k_buffer; - spk_our_keys[0] = spk_shift_table; - cp1 += SHIFT_TBL_SIZE; - memcpy(cp1, cp, key_data_len + 3); - /* get num_keys, states and data */ - cp1 += 2; /* now pointing at shift states */ - for (i = 1; i <= states; i++) { - ch = *cp1++; - if (ch >= SHIFT_TBL_SIZE) { - pr_debug("(%d) not valid shift state (max_allowed = %d)\n", - ch, SHIFT_TBL_SIZE); - return -EINVAL; - } - spk_shift_table[ch] = i; - } - keymap_flags = *cp1++; - while ((ch = *cp1)) { - if (ch >= MAX_KEY) { - pr_debug("(%d), not valid key, (max_allowed = %d)\n", - ch, MAX_KEY); - return -EINVAL; - } - spk_our_keys[ch] = cp1; - cp1 += states + 1; - } - return 0; -} - -static struct var_t spk_vars[] = { - /* bell must be first to set high limit */ - {BELL_POS, .u.n = {NULL, 0, 0, 0, 0, 0, NULL} }, - {SPELL_DELAY, .u.n = {NULL, 0, 0, 4, 0, 0, NULL} }, - {ATTRIB_BLEEP, .u.n = {NULL, 1, 0, 3, 0, 0, NULL} }, - {BLEEPS, .u.n = {NULL, 3, 0, 3, 0, 0, NULL} }, - {BLEEP_TIME, .u.n = {NULL, 30, 1, 200, 0, 0, NULL} }, - {PUNC_LEVEL, .u.n = {NULL, 1, 0, 4, 0, 0, NULL} }, - {READING_PUNC, .u.n = {NULL, 1, 0, 4, 0, 0, NULL} }, - {CURSOR_TIME, .u.n = {NULL, 120, 50, 600, 0, 0, NULL} }, - {SAY_CONTROL, TOGGLE_0}, - {SAY_WORD_CTL, TOGGLE_0}, - {NO_INTERRUPT, TOGGLE_0}, - {KEY_ECHO, .u.n = {NULL, 1, 0, 2, 0, 0, NULL} }, - V_LAST_VAR -}; - -static void toggle_cursoring(struct vc_data *vc) -{ - if (cursor_track == read_all_mode) - cursor_track = prev_cursor_track; - if (++cursor_track >= CT_Max) - cursor_track = 0; - synth_printf("%s\n", spk_msg_get(MSG_CURSOR_MSGS_START + cursor_track)); -} - -void spk_reset_default_chars(void) -{ - int i; - - /* First, free any non-default */ - for (i = 0; i < 256; i++) { - if (spk_characters[i] && - (spk_characters[i] != spk_default_chars[i])) - kfree(spk_characters[i]); - } - - memcpy(spk_characters, spk_default_chars, sizeof(spk_default_chars)); -} - -void spk_reset_default_chartab(void) -{ - memcpy(spk_chartab, default_chartab, sizeof(default_chartab)); -} - -static const struct st_bits_data *pb_edit; - -static int edit_bits(struct vc_data *vc, u_char type, u_char ch, u_short key) -{ - short mask = pb_edit->mask, ch_type = spk_chartab[ch]; - - if (type != KT_LATIN || (ch_type & B_NUM) || ch < SPACE) - return -1; - if (ch == SPACE) { - synth_printf("%s\n", spk_msg_get(MSG_EDIT_DONE)); - spk_special_handler = NULL; - return 1; - } - if (mask < PUNC && !(ch_type & PUNC)) - return -1; - spk_chartab[ch] ^= mask; - speak_char(ch); - synth_printf(" %s\n", - (spk_chartab[ch] & mask) ? spk_msg_get(MSG_ON) : - spk_msg_get(MSG_OFF)); - return 1; -} - -/* Allocation concurrency is protected by the console semaphore */ -static int speakup_allocate(struct vc_data *vc, gfp_t gfp_flags) -{ - int vc_num; - - vc_num = vc->vc_num; - if (!speakup_console[vc_num]) { - speakup_console[vc_num] = kzalloc(sizeof(*speakup_console[0]), - gfp_flags); - if (!speakup_console[vc_num]) - return -ENOMEM; - speakup_date(vc); - } else if (!spk_parked) { - speakup_date(vc); - } - - return 0; -} - -static void speakup_deallocate(struct vc_data *vc) -{ - int vc_num; - - vc_num = vc->vc_num; - kfree(speakup_console[vc_num]); - speakup_console[vc_num] = NULL; -} - -static u_char is_cursor; -static u_long old_cursor_pos, old_cursor_x, old_cursor_y; -static int cursor_con; - -static void reset_highlight_buffers(struct vc_data *); - -static int read_all_key; - -static int in_keyboard_notifier; - -static void start_read_all_timer(struct vc_data *vc, int command); - -enum { - RA_NOTHING, - RA_NEXT_SENT, - RA_PREV_LINE, - RA_NEXT_LINE, - RA_PREV_SENT, - RA_DOWN_ARROW, - RA_TIMER, - RA_FIND_NEXT_SENT, - RA_FIND_PREV_SENT, -}; - -static void kbd_fakekey2(struct vc_data *vc, int command) -{ - del_timer(&cursor_timer); - speakup_fake_down_arrow(); - start_read_all_timer(vc, command); -} - -static void read_all_doc(struct vc_data *vc) -{ - if ((vc->vc_num != fg_console) || !synth || spk_shut_up) - return; - if (!synth_supports_indexing()) - return; - if (cursor_track != read_all_mode) - prev_cursor_track = cursor_track; - cursor_track = read_all_mode; - spk_reset_index_count(0); - if (get_sentence_buf(vc, 0) == -1) { - del_timer(&cursor_timer); - if (!in_keyboard_notifier) - speakup_fake_down_arrow(); - start_read_all_timer(vc, RA_DOWN_ARROW); - } else { - say_sentence_num(0, 0); - synth_insert_next_index(0); - start_read_all_timer(vc, RA_TIMER); - } -} - -static void stop_read_all(struct vc_data *vc) -{ - del_timer(&cursor_timer); - cursor_track = prev_cursor_track; - spk_shut_up &= 0xfe; - spk_do_flush(); -} - -static void start_read_all_timer(struct vc_data *vc, int command) -{ - struct var_t *cursor_timeout; - - cursor_con = vc->vc_num; - read_all_key = command; - cursor_timeout = spk_get_var(CURSOR_TIME); - mod_timer(&cursor_timer, - jiffies + msecs_to_jiffies(cursor_timeout->u.n.value)); -} - -static void handle_cursor_read_all(struct vc_data *vc, int command) -{ - int indcount, sentcount, rv, sn; - - switch (command) { - case RA_NEXT_SENT: - /* Get Current Sentence */ - spk_get_index_count(&indcount, &sentcount); - /*printk("%d %d ", indcount, sentcount); */ - spk_reset_index_count(sentcount + 1); - if (indcount == 1) { - if (!say_sentence_num(sentcount + 1, 0)) { - kbd_fakekey2(vc, RA_FIND_NEXT_SENT); - return; - } - synth_insert_next_index(0); - } else { - sn = 0; - if (!say_sentence_num(sentcount + 1, 1)) { - sn = 1; - spk_reset_index_count(sn); - } else { - synth_insert_next_index(0); - } - if (!say_sentence_num(sn, 0)) { - kbd_fakekey2(vc, RA_FIND_NEXT_SENT); - return; - } - synth_insert_next_index(0); - } - start_read_all_timer(vc, RA_TIMER); - break; - case RA_PREV_SENT: - break; - case RA_NEXT_LINE: - read_all_doc(vc); - break; - case RA_PREV_LINE: - break; - case RA_DOWN_ARROW: - if (get_sentence_buf(vc, 0) == -1) { - kbd_fakekey2(vc, RA_DOWN_ARROW); - } else { - say_sentence_num(0, 0); - synth_insert_next_index(0); - start_read_all_timer(vc, RA_TIMER); - } - break; - case RA_FIND_NEXT_SENT: - rv = get_sentence_buf(vc, 0); - if (rv == -1) - read_all_doc(vc); - if (rv == 0) { - kbd_fakekey2(vc, RA_FIND_NEXT_SENT); - } else { - say_sentence_num(1, 0); - synth_insert_next_index(0); - start_read_all_timer(vc, RA_TIMER); - } - break; - case RA_FIND_PREV_SENT: - break; - case RA_TIMER: - spk_get_index_count(&indcount, &sentcount); - if (indcount < 2) - kbd_fakekey2(vc, RA_DOWN_ARROW); - else - start_read_all_timer(vc, RA_TIMER); - break; - } -} - -static int pre_handle_cursor(struct vc_data *vc, u_char value, char up_flag) -{ - unsigned long flags; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (cursor_track == read_all_mode) { - spk_parked &= 0xfe; - if (!synth || up_flag || spk_shut_up) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return NOTIFY_STOP; - } - del_timer(&cursor_timer); - spk_shut_up &= 0xfe; - spk_do_flush(); - start_read_all_timer(vc, value + 1); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return NOTIFY_STOP; - } - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return NOTIFY_OK; -} - -static void do_handle_cursor(struct vc_data *vc, u_char value, char up_flag) -{ - unsigned long flags; - struct var_t *cursor_timeout; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - spk_parked &= 0xfe; - if (!synth || up_flag || spk_shut_up || cursor_track == CT_Off) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return; - } - spk_shut_up &= 0xfe; - if (spk_no_intr) - spk_do_flush(); -/* the key press flushes if !no_inter but we want to flush on cursor - * moves regardless of no_inter state - */ - is_cursor = value + 1; - old_cursor_pos = vc->vc_pos; - old_cursor_x = vc->vc_x; - old_cursor_y = vc->vc_y; - speakup_console[vc->vc_num]->ht.cy = vc->vc_y; - cursor_con = vc->vc_num; - if (cursor_track == CT_Highlight) - reset_highlight_buffers(vc); - cursor_timeout = spk_get_var(CURSOR_TIME); - mod_timer(&cursor_timer, - jiffies + msecs_to_jiffies(cursor_timeout->u.n.value)); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); -} - -static void update_color_buffer(struct vc_data *vc, const u16 *ic, int len) -{ - int i, bi, hi; - int vc_num = vc->vc_num; - - bi = (vc->vc_attr & 0x70) >> 4; - hi = speakup_console[vc_num]->ht.highsize[bi]; - - i = 0; - if (speakup_console[vc_num]->ht.highsize[bi] == 0) { - speakup_console[vc_num]->ht.rpos[bi] = vc->vc_pos; - speakup_console[vc_num]->ht.rx[bi] = vc->vc_x; - speakup_console[vc_num]->ht.ry[bi] = vc->vc_y; - } - while ((hi < COLOR_BUFFER_SIZE) && (i < len)) { - if (ic[i] > 32) { - speakup_console[vc_num]->ht.highbuf[bi][hi] = ic[i]; - hi++; - } else if ((ic[i] == 32) && (hi != 0)) { - if (speakup_console[vc_num]->ht.highbuf[bi][hi - 1] != - 32) { - speakup_console[vc_num]->ht.highbuf[bi][hi] = - ic[i]; - hi++; - } - } - i++; - } - speakup_console[vc_num]->ht.highsize[bi] = hi; -} - -static void reset_highlight_buffers(struct vc_data *vc) -{ - int i; - int vc_num = vc->vc_num; - - for (i = 0; i < 8; i++) - speakup_console[vc_num]->ht.highsize[i] = 0; -} - -static int count_highlight_color(struct vc_data *vc) -{ - int i, bg; - int cc; - int vc_num = vc->vc_num; - u16 ch; - u16 *start = (u16 *)vc->vc_origin; - - for (i = 0; i < 8; i++) - speakup_console[vc_num]->ht.bgcount[i] = 0; - - for (i = 0; i < vc->vc_rows; i++) { - u16 *end = start + vc->vc_cols * 2; - u16 *ptr; - - for (ptr = start; ptr < end; ptr++) { - ch = get_attributes(vc, ptr); - bg = (ch & 0x70) >> 4; - speakup_console[vc_num]->ht.bgcount[bg]++; - } - start += vc->vc_size_row; - } - - cc = 0; - for (i = 0; i < 8; i++) - if (speakup_console[vc_num]->ht.bgcount[i] > 0) - cc++; - return cc; -} - -static int get_highlight_color(struct vc_data *vc) -{ - int i, j; - unsigned int cptr[8]; - int vc_num = vc->vc_num; - - for (i = 0; i < 8; i++) - cptr[i] = i; - - for (i = 0; i < 7; i++) - for (j = i + 1; j < 8; j++) - if (speakup_console[vc_num]->ht.bgcount[cptr[i]] > - speakup_console[vc_num]->ht.bgcount[cptr[j]]) - swap(cptr[i], cptr[j]); - - for (i = 0; i < 8; i++) - if (speakup_console[vc_num]->ht.bgcount[cptr[i]] != 0) - if (speakup_console[vc_num]->ht.highsize[cptr[i]] > 0) - return cptr[i]; - return -1; -} - -static int speak_highlight(struct vc_data *vc) -{ - int hc, d; - int vc_num = vc->vc_num; - - if (count_highlight_color(vc) == 1) - return 0; - hc = get_highlight_color(vc); - if (hc != -1) { - d = vc->vc_y - speakup_console[vc_num]->ht.cy; - if ((d == 1) || (d == -1)) - if (speakup_console[vc_num]->ht.ry[hc] != vc->vc_y) - return 0; - spk_parked |= 0x01; - spk_do_flush(); - spkup_write(speakup_console[vc_num]->ht.highbuf[hc], - speakup_console[vc_num]->ht.highsize[hc]); - spk_pos = spk_cp = speakup_console[vc_num]->ht.rpos[hc]; - spk_x = spk_cx = speakup_console[vc_num]->ht.rx[hc]; - spk_y = spk_cy = speakup_console[vc_num]->ht.ry[hc]; - return 1; - } - return 0; -} - -static void cursor_done(struct timer_list *unused) -{ - struct vc_data *vc = vc_cons[cursor_con].d; - unsigned long flags; - - del_timer(&cursor_timer); - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (cursor_con != fg_console) { - is_cursor = 0; - goto out; - } - speakup_date(vc); - if (win_enabled) { - if (vc->vc_x >= win_left && vc->vc_x <= win_right && - vc->vc_y >= win_top && vc->vc_y <= win_bottom) { - spk_keydown = 0; - is_cursor = 0; - goto out; - } - } - if (cursor_track == read_all_mode) { - handle_cursor_read_all(vc, read_all_key); - goto out; - } - if (cursor_track == CT_Highlight) { - if (speak_highlight(vc)) { - spk_keydown = 0; - is_cursor = 0; - goto out; - } - } - if (cursor_track == CT_Window) - speakup_win_say(vc); - else if (is_cursor == 1 || is_cursor == 4) - say_line_from_to(vc, 0, vc->vc_cols, 0); - else - say_char(vc); - spk_keydown = 0; - is_cursor = 0; -out: - spin_unlock_irqrestore(&speakup_info.spinlock, flags); -} - -/* called by: vt_notifier_call() */ -static void speakup_bs(struct vc_data *vc) -{ - unsigned long flags; - - if (!speakup_console[vc->vc_num]) - return; - if (!spin_trylock_irqsave(&speakup_info.spinlock, flags)) - /* Speakup output, discard */ - return; - if (!spk_parked) - speakup_date(vc); - if (spk_shut_up || !synth) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return; - } - if (vc->vc_num == fg_console && spk_keydown) { - spk_keydown = 0; - if (!is_cursor) - say_char(vc); - } - spin_unlock_irqrestore(&speakup_info.spinlock, flags); -} - -/* called by: vt_notifier_call() */ -static void speakup_con_write(struct vc_data *vc, u16 *str, int len) -{ - unsigned long flags; - - if ((vc->vc_num != fg_console) || spk_shut_up || !synth) - return; - if (!spin_trylock_irqsave(&speakup_info.spinlock, flags)) - /* Speakup output, discard */ - return; - if (spk_bell_pos && spk_keydown && (vc->vc_x == spk_bell_pos - 1)) - bleep(3); - if ((is_cursor) || (cursor_track == read_all_mode)) { - if (cursor_track == CT_Highlight) - update_color_buffer(vc, str, len); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return; - } - if (win_enabled) { - if (vc->vc_x >= win_left && vc->vc_x <= win_right && - vc->vc_y >= win_top && vc->vc_y <= win_bottom) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return; - } - } - - spkup_write(str, len); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); -} - -static void speakup_con_update(struct vc_data *vc) -{ - unsigned long flags; - - if (!speakup_console[vc->vc_num] || spk_parked) - return; - if (!spin_trylock_irqsave(&speakup_info.spinlock, flags)) - /* Speakup output, discard */ - return; - speakup_date(vc); - if (vc->vc_mode == KD_GRAPHICS && !spk_paused && spk_str_pause[0]) { - synth_printf("%s", spk_str_pause); - spk_paused = true; - } - spin_unlock_irqrestore(&speakup_info.spinlock, flags); -} - -static void do_handle_spec(struct vc_data *vc, u_char value, char up_flag) -{ - unsigned long flags; - int on_off = 2; - char *label; - - if (!synth || up_flag || spk_killed) - return; - spin_lock_irqsave(&speakup_info.spinlock, flags); - spk_shut_up &= 0xfe; - if (spk_no_intr) - spk_do_flush(); - switch (value) { - case KVAL(K_CAPS): - label = spk_msg_get(MSG_KEYNAME_CAPSLOCK); - on_off = vt_get_leds(fg_console, VC_CAPSLOCK); - break; - case KVAL(K_NUM): - label = spk_msg_get(MSG_KEYNAME_NUMLOCK); - on_off = vt_get_leds(fg_console, VC_NUMLOCK); - break; - case KVAL(K_HOLD): - label = spk_msg_get(MSG_KEYNAME_SCROLLLOCK); - on_off = vt_get_leds(fg_console, VC_SCROLLOCK); - if (speakup_console[vc->vc_num]) - speakup_console[vc->vc_num]->tty_stopped = on_off; - break; - default: - spk_parked &= 0xfe; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return; - } - if (on_off < 2) - synth_printf("%s %s\n", - label, spk_msg_get(MSG_STATUS_START + on_off)); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); -} - -static int inc_dec_var(u_char value) -{ - struct st_var_header *p_header; - struct var_t *var_data; - char num_buf[32]; - char *cp = num_buf; - char *pn; - int var_id = (int)value - VAR_START; - int how = (var_id & 1) ? E_INC : E_DEC; - - var_id = var_id / 2 + FIRST_SET_VAR; - p_header = spk_get_var_header(var_id); - if (!p_header) - return -1; - if (p_header->var_type != VAR_NUM) - return -1; - var_data = p_header->data; - if (spk_set_num_var(1, p_header, how) != 0) - return -1; - if (!spk_close_press) { - for (pn = p_header->name; *pn; pn++) { - if (*pn == '_') - *cp = SPACE; - else - *cp++ = *pn; - } - } - snprintf(cp, sizeof(num_buf) - (cp - num_buf), " %d ", - var_data->u.n.value); - synth_printf("%s", num_buf); - return 0; -} - -static void speakup_win_set(struct vc_data *vc) -{ - char info[40]; - - if (win_start > 1) { - synth_printf("%s\n", spk_msg_get(MSG_WINDOW_ALREADY_SET)); - return; - } - if (spk_x < win_left || spk_y < win_top) { - synth_printf("%s\n", spk_msg_get(MSG_END_BEFORE_START)); - return; - } - if (win_start && spk_x == win_left && spk_y == win_top) { - win_left = 0; - win_right = vc->vc_cols - 1; - win_bottom = spk_y; - snprintf(info, sizeof(info), spk_msg_get(MSG_WINDOW_LINE), - (int)win_top + 1); - } else { - if (!win_start) { - win_top = spk_y; - win_left = spk_x; - } else { - win_bottom = spk_y; - win_right = spk_x; - } - snprintf(info, sizeof(info), spk_msg_get(MSG_WINDOW_BOUNDARY), - (win_start) ? - spk_msg_get(MSG_END) : spk_msg_get(MSG_START), - (int)spk_y + 1, (int)spk_x + 1); - } - synth_printf("%s\n", info); - win_start++; -} - -static void speakup_win_clear(struct vc_data *vc) -{ - win_top = 0; - win_bottom = 0; - win_left = 0; - win_right = 0; - win_start = 0; - synth_printf("%s\n", spk_msg_get(MSG_WINDOW_CLEARED)); -} - -static void speakup_win_enable(struct vc_data *vc) -{ - if (win_start < 2) { - synth_printf("%s\n", spk_msg_get(MSG_NO_WINDOW)); - return; - } - win_enabled ^= 1; - if (win_enabled) - synth_printf("%s\n", spk_msg_get(MSG_WINDOW_SILENCED)); - else - synth_printf("%s\n", spk_msg_get(MSG_WINDOW_SILENCE_DISABLED)); -} - -static void speakup_bits(struct vc_data *vc) -{ - int val = this_speakup_key - (FIRST_EDIT_BITS - 1); - - if (spk_special_handler || val < 1 || val > 6) { - synth_printf("%s\n", spk_msg_get(MSG_ERROR)); - return; - } - pb_edit = &spk_punc_info[val]; - synth_printf(spk_msg_get(MSG_EDIT_PROMPT), pb_edit->name); - spk_special_handler = edit_bits; -} - -static int handle_goto(struct vc_data *vc, u_char type, u_char ch, u_short key) -{ - static u_char goto_buf[8]; - static int num; - int maxlen; - char *cp; - u16 wch; - - if (type == KT_SPKUP && ch == SPEAKUP_GOTO) - goto do_goto; - if (type == KT_LATIN && ch == '\n') - goto do_goto; - if (type != 0) - goto oops; - if (ch == 8) { - u16 wch; - - if (num == 0) - return -1; - wch = goto_buf[--num]; - goto_buf[num] = '\0'; - spkup_write(&wch, 1); - return 1; - } - if (ch < '+' || ch > 'y') - goto oops; - wch = ch; - goto_buf[num++] = ch; - goto_buf[num] = '\0'; - spkup_write(&wch, 1); - maxlen = (*goto_buf >= '0') ? 3 : 4; - if ((ch == '+' || ch == '-') && num == 1) - return 1; - if (ch >= '0' && ch <= '9' && num < maxlen) - return 1; - if (num < maxlen - 1 || num > maxlen) - goto oops; - if (ch < 'x' || ch > 'y') { -oops: - if (!spk_killed) - synth_printf(" %s\n", spk_msg_get(MSG_GOTO_CANCELED)); - goto_buf[num = 0] = '\0'; - spk_special_handler = NULL; - return 1; - } - - /* Do not replace with kstrtoul: here we need cp to be updated */ - goto_pos = simple_strtoul(goto_buf, &cp, 10); - - if (*cp == 'x') { - if (*goto_buf < '0') - goto_pos += spk_x; - else if (goto_pos > 0) - goto_pos--; - - if (goto_pos >= vc->vc_cols) - goto_pos = vc->vc_cols - 1; - goto_x = 1; - } else { - if (*goto_buf < '0') - goto_pos += spk_y; - else if (goto_pos > 0) - goto_pos--; - - if (goto_pos >= vc->vc_rows) - goto_pos = vc->vc_rows - 1; - goto_x = 0; - } - goto_buf[num = 0] = '\0'; -do_goto: - spk_special_handler = NULL; - spk_parked |= 0x01; - if (goto_x) { - spk_pos -= spk_x * 2; - spk_x = goto_pos; - spk_pos += goto_pos * 2; - say_word(vc); - } else { - spk_y = goto_pos; - spk_pos = vc->vc_origin + (goto_pos * vc->vc_size_row); - say_line(vc); - } - return 1; -} - -static void speakup_goto(struct vc_data *vc) -{ - if (spk_special_handler) { - synth_printf("%s\n", spk_msg_get(MSG_ERROR)); - return; - } - synth_printf("%s\n", spk_msg_get(MSG_GOTO)); - spk_special_handler = handle_goto; -} - -static void speakup_help(struct vc_data *vc) -{ - spk_handle_help(vc, KT_SPKUP, SPEAKUP_HELP, 0); -} - -static void do_nothing(struct vc_data *vc) -{ - return; /* flush done in do_spkup */ -} - -static u_char key_speakup, spk_key_locked; - -static void speakup_lock(struct vc_data *vc) -{ - if (!spk_key_locked) { - spk_key_locked = 16; - key_speakup = 16; - } else { - spk_key_locked = 0; - key_speakup = 0; - } -} - -typedef void (*spkup_hand) (struct vc_data *); -static spkup_hand spkup_handler[] = { - /* must be ordered same as defines in speakup.h */ - do_nothing, speakup_goto, speech_kill, speakup_shut_up, - speakup_cut, speakup_paste, say_first_char, say_last_char, - say_char, say_prev_char, say_next_char, - say_word, say_prev_word, say_next_word, - say_line, say_prev_line, say_next_line, - top_edge, bottom_edge, left_edge, right_edge, - spell_word, spell_word, say_screen, - say_position, say_attributes, - speakup_off, speakup_parked, say_line, /* this is for indent */ - say_from_top, say_to_bottom, - say_from_left, say_to_right, - say_char_num, speakup_bits, speakup_bits, say_phonetic_char, - speakup_bits, speakup_bits, speakup_bits, - speakup_win_set, speakup_win_clear, speakup_win_enable, speakup_win_say, - speakup_lock, speakup_help, toggle_cursoring, read_all_doc, NULL -}; - -static void do_spkup(struct vc_data *vc, u_char value) -{ - if (spk_killed && value != SPEECH_KILL) - return; - spk_keydown = 0; - spk_lastkey = 0; - spk_shut_up &= 0xfe; - this_speakup_key = value; - if (value < SPKUP_MAX_FUNC && spkup_handler[value]) { - spk_do_flush(); - (*spkup_handler[value]) (vc); - } else { - if (inc_dec_var(value) < 0) - bleep(9); - } -} - -static const char *pad_chars = "0123456789+-*/\015,.?()"; - -static int -speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym, - int up_flag) -{ - unsigned long flags; - int kh; - u_char *key_info; - u_char type = KTYP(keysym), value = KVAL(keysym), new_key = 0; - u_char shift_info, offset; - int ret = 0; - - if (!synth) - return 0; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - tty = vc->port.tty; - if (type >= 0xf0) - type -= 0xf0; - if (type == KT_PAD && - (vt_get_leds(fg_console, VC_NUMLOCK))) { - if (up_flag) { - spk_keydown = 0; - goto out; - } - value = pad_chars[value]; - spk_lastkey = value; - spk_keydown++; - spk_parked &= 0xfe; - goto no_map; - } - if (keycode >= MAX_KEY) - goto no_map; - key_info = spk_our_keys[keycode]; - if (!key_info) - goto no_map; - /* Check valid read all mode keys */ - if ((cursor_track == read_all_mode) && (!up_flag)) { - switch (value) { - case KVAL(K_DOWN): - case KVAL(K_UP): - case KVAL(K_LEFT): - case KVAL(K_RIGHT): - case KVAL(K_PGUP): - case KVAL(K_PGDN): - break; - default: - stop_read_all(vc); - break; - } - } - shift_info = (shift_state & 0x0f) + key_speakup; - offset = spk_shift_table[shift_info]; - if (offset) { - new_key = key_info[offset]; - if (new_key) { - ret = 1; - if (new_key == SPK_KEY) { - if (!spk_key_locked) - key_speakup = (up_flag) ? 0 : 16; - if (up_flag || spk_killed) - goto out; - spk_shut_up &= 0xfe; - spk_do_flush(); - goto out; - } - if (up_flag) - goto out; - if (last_keycode == keycode && - time_after(last_spk_jiffy + MAX_DELAY, jiffies)) { - spk_close_press = 1; - offset = spk_shift_table[shift_info + 32]; - /* double press? */ - if (offset && key_info[offset]) - new_key = key_info[offset]; - } - last_keycode = keycode; - last_spk_jiffy = jiffies; - type = KT_SPKUP; - value = new_key; - } - } -no_map: - if (type == KT_SPKUP && !spk_special_handler) { - do_spkup(vc, new_key); - spk_close_press = 0; - ret = 1; - goto out; - } - if (up_flag || spk_killed || type == KT_SHIFT) - goto out; - spk_shut_up &= 0xfe; - kh = (value == KVAL(K_DOWN)) || - (value == KVAL(K_UP)) || - (value == KVAL(K_LEFT)) || - (value == KVAL(K_RIGHT)); - if ((cursor_track != read_all_mode) || !kh) - if (!spk_no_intr) - spk_do_flush(); - if (spk_special_handler) { - if (type == KT_SPEC && value == 1) { - value = '\n'; - type = KT_LATIN; - } else if (type == KT_LETTER) { - type = KT_LATIN; - } else if (value == 0x7f) { - value = 8; /* make del = backspace */ - } - ret = (*spk_special_handler) (vc, type, value, keycode); - spk_close_press = 0; - if (ret < 0) - bleep(9); - goto out; - } - last_keycode = 0; -out: - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return ret; -} - -static int keyboard_notifier_call(struct notifier_block *nb, - unsigned long code, void *_param) -{ - struct keyboard_notifier_param *param = _param; - struct vc_data *vc = param->vc; - int up = !param->down; - int ret = NOTIFY_OK; - static int keycode; /* to hold the current keycode */ - - in_keyboard_notifier = 1; - - if (vc->vc_mode == KD_GRAPHICS) - goto out; - - /* - * First, determine whether we are handling a fake keypress on - * the current processor. If we are, then return NOTIFY_OK, - * to pass the keystroke up the chain. This prevents us from - * trying to take the Speakup lock while it is held by the - * processor on which the simulated keystroke was generated. - * Also, the simulated keystrokes should be ignored by Speakup. - */ - - if (speakup_fake_key_pressed()) - goto out; - - switch (code) { - case KBD_KEYCODE: - /* speakup requires keycode and keysym currently */ - keycode = param->value; - break; - case KBD_UNBOUND_KEYCODE: - /* not used yet */ - break; - case KBD_UNICODE: - /* not used yet */ - break; - case KBD_KEYSYM: - if (speakup_key(vc, param->shift, keycode, param->value, up)) - ret = NOTIFY_STOP; - else if (KTYP(param->value) == KT_CUR) - ret = pre_handle_cursor(vc, KVAL(param->value), up); - break; - case KBD_POST_KEYSYM:{ - unsigned char type = KTYP(param->value) - 0xf0; - unsigned char val = KVAL(param->value); - - switch (type) { - case KT_SHIFT: - do_handle_shift(vc, val, up); - break; - case KT_LATIN: - case KT_LETTER: - do_handle_latin(vc, val, up); - break; - case KT_CUR: - do_handle_cursor(vc, val, up); - break; - case KT_SPEC: - do_handle_spec(vc, val, up); - break; - } - break; - } - } -out: - in_keyboard_notifier = 0; - return ret; -} - -static int vt_notifier_call(struct notifier_block *nb, - unsigned long code, void *_param) -{ - struct vt_notifier_param *param = _param; - struct vc_data *vc = param->vc; - - switch (code) { - case VT_ALLOCATE: - if (vc->vc_mode == KD_TEXT) - speakup_allocate(vc, GFP_ATOMIC); - break; - case VT_DEALLOCATE: - speakup_deallocate(vc); - break; - case VT_WRITE: - if (param->c == '\b') { - speakup_bs(vc); - } else { - u16 d = param->c; - - speakup_con_write(vc, &d, 1); - } - break; - case VT_UPDATE: - speakup_con_update(vc); - break; - } - return NOTIFY_OK; -} - -/* called by: module_exit() */ -static void __exit speakup_exit(void) -{ - int i; - - unregister_keyboard_notifier(&keyboard_notifier_block); - unregister_vt_notifier(&vt_notifier_block); - speakup_unregister_devsynth(); - speakup_cancel_selection(); - speakup_cancel_paste(); - del_timer_sync(&cursor_timer); - kthread_stop(speakup_task); - speakup_task = NULL; - mutex_lock(&spk_mutex); - synth_release(); - mutex_unlock(&spk_mutex); - spk_ttyio_unregister_ldisc(); - - speakup_kobj_exit(); - - for (i = 0; i < MAX_NR_CONSOLES; i++) - kfree(speakup_console[i]); - - speakup_remove_virtual_keyboard(); - - for (i = 0; i < MAXVARS; i++) - speakup_unregister_var(i); - - for (i = 0; i < 256; i++) { - if (spk_characters[i] != spk_default_chars[i]) - kfree(spk_characters[i]); - } - - spk_free_user_msgs(); -} - -/* call by: module_init() */ -static int __init speakup_init(void) -{ - int i; - long err = 0; - struct vc_data *vc = vc_cons[fg_console].d; - struct var_t *var; - - /* These first few initializations cannot fail. */ - spk_initialize_msgs(); /* Initialize arrays for i18n. */ - spk_reset_default_chars(); - spk_reset_default_chartab(); - spk_strlwr(synth_name); - spk_vars[0].u.n.high = vc->vc_cols; - for (var = spk_vars; var->var_id != MAXVARS; var++) - speakup_register_var(var); - for (var = synth_time_vars; - (var->var_id >= 0) && (var->var_id < MAXVARS); var++) - speakup_register_var(var); - for (i = 1; spk_punc_info[i].mask != 0; i++) - spk_set_mask_bits(NULL, i, 2); - - spk_set_key_info(spk_key_defaults, spk_key_buf); - - /* From here on out, initializations can fail. */ - err = speakup_add_virtual_keyboard(); - if (err) - goto error_virtkeyboard; - - for (i = 0; i < MAX_NR_CONSOLES; i++) - if (vc_cons[i].d) { - err = speakup_allocate(vc_cons[i].d, GFP_KERNEL); - if (err) - goto error_kobjects; - } - - if (spk_quiet_boot) - spk_shut_up |= 0x01; - - err = speakup_kobj_init(); - if (err) - goto error_kobjects; - - spk_ttyio_register_ldisc(); - synth_init(synth_name); - speakup_register_devsynth(); - /* - * register_devsynth might fail, but this error is not fatal. - * /dev/synth is an extra feature; the rest of Speakup - * will work fine without it. - */ - - err = register_keyboard_notifier(&keyboard_notifier_block); - if (err) - goto error_kbdnotifier; - err = register_vt_notifier(&vt_notifier_block); - if (err) - goto error_vtnotifier; - - speakup_task = kthread_create(speakup_thread, NULL, "speakup"); - - if (IS_ERR(speakup_task)) { - err = PTR_ERR(speakup_task); - goto error_task; - } - - set_user_nice(speakup_task, 10); - wake_up_process(speakup_task); - - pr_info("speakup %s: initialized\n", SPEAKUP_VERSION); - pr_info("synth name on entry is: %s\n", synth_name); - goto out; - -error_task: - unregister_vt_notifier(&vt_notifier_block); - -error_vtnotifier: - unregister_keyboard_notifier(&keyboard_notifier_block); - del_timer(&cursor_timer); - -error_kbdnotifier: - speakup_unregister_devsynth(); - mutex_lock(&spk_mutex); - synth_release(); - mutex_unlock(&spk_mutex); - speakup_kobj_exit(); - -error_kobjects: - for (i = 0; i < MAX_NR_CONSOLES; i++) - kfree(speakup_console[i]); - - speakup_remove_virtual_keyboard(); - -error_virtkeyboard: - for (i = 0; i < MAXVARS; i++) - speakup_unregister_var(i); - - for (i = 0; i < 256; i++) { - if (spk_characters[i] != spk_default_chars[i]) - kfree(spk_characters[i]); - } - - spk_free_user_msgs(); - -out: - return err; -} - -module_init(speakup_init); -module_exit(speakup_exit); diff --git a/drivers/staging/speakup/selection.c b/drivers/staging/speakup/selection.c deleted file mode 100644 index 032f3264fba1..000000000000 --- a/drivers/staging/speakup/selection.c +++ /dev/null @@ -1,144 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include /* for kmalloc */ -#include -#include -#include -#include /* for dev_warn */ -#include -#include -#include -#include -#include -#include - -#include "speakup.h" - -unsigned short spk_xs, spk_ys, spk_xe, spk_ye; /* our region points */ -struct vc_data *spk_sel_cons; - -struct speakup_selection_work { - struct work_struct work; - struct tiocl_selection sel; - struct tty_struct *tty; -}; - -void speakup_clear_selection(void) -{ - console_lock(); - clear_selection(); - console_unlock(); -} - -static void __speakup_set_selection(struct work_struct *work) -{ - struct speakup_selection_work *ssw = - container_of(work, struct speakup_selection_work, work); - - struct tty_struct *tty; - struct tiocl_selection sel; - - sel = ssw->sel; - - /* this ensures we copy sel before releasing the lock below */ - rmb(); - - /* release the lock by setting tty of the struct to NULL */ - tty = xchg(&ssw->tty, NULL); - - if (spk_sel_cons != vc_cons[fg_console].d) { - spk_sel_cons = vc_cons[fg_console].d; - pr_warn("Selection: mark console not the same as cut\n"); - goto unref; - } - - set_selection_kernel(&sel, tty); - -unref: - tty_kref_put(tty); -} - -static struct speakup_selection_work speakup_sel_work = { - .work = __WORK_INITIALIZER(speakup_sel_work.work, - __speakup_set_selection) -}; - -int speakup_set_selection(struct tty_struct *tty) -{ - /* we get kref here first in order to avoid a subtle race when - * cancelling selection work. getting kref first establishes the - * invariant that if speakup_sel_work.tty is not NULL when - * speakup_cancel_selection() is called, it must be the case that a put - * kref is pending. - */ - tty_kref_get(tty); - if (cmpxchg(&speakup_sel_work.tty, NULL, tty)) { - tty_kref_put(tty); - return -EBUSY; - } - /* now we have the 'lock' by setting tty member of - * speakup_selection_work. wmb() ensures that writes to - * speakup_sel_work don't happen before cmpxchg() above. - */ - wmb(); - - speakup_sel_work.sel.xs = spk_xs + 1; - speakup_sel_work.sel.ys = spk_ys + 1; - speakup_sel_work.sel.xe = spk_xe + 1; - speakup_sel_work.sel.ye = spk_ye + 1; - speakup_sel_work.sel.sel_mode = TIOCL_SELCHAR; - - schedule_work_on(WORK_CPU_UNBOUND, &speakup_sel_work.work); - - return 0; -} - -void speakup_cancel_selection(void) -{ - struct tty_struct *tty; - - cancel_work_sync(&speakup_sel_work.work); - /* setting to null so that if work fails to run and we cancel it, - * we can run it again without getting EBUSY forever from there on. - * we need to use xchg here to avoid race with speakup_set_selection() - */ - tty = xchg(&speakup_sel_work.tty, NULL); - if (tty) - tty_kref_put(tty); -} - -static void __speakup_paste_selection(struct work_struct *work) -{ - struct speakup_selection_work *ssw = - container_of(work, struct speakup_selection_work, work); - struct tty_struct *tty = xchg(&ssw->tty, NULL); - - paste_selection(tty); - tty_kref_put(tty); -} - -static struct speakup_selection_work speakup_paste_work = { - .work = __WORK_INITIALIZER(speakup_paste_work.work, - __speakup_paste_selection) -}; - -int speakup_paste_selection(struct tty_struct *tty) -{ - tty_kref_get(tty); - if (cmpxchg(&speakup_paste_work.tty, NULL, tty)) { - tty_kref_put(tty); - return -EBUSY; - } - - schedule_work_on(WORK_CPU_UNBOUND, &speakup_paste_work.work); - return 0; -} - -void speakup_cancel_paste(void) -{ - struct tty_struct *tty; - - cancel_work_sync(&speakup_paste_work.work); - tty = xchg(&speakup_paste_work.tty, NULL); - if (tty) - tty_kref_put(tty); -} diff --git a/drivers/staging/speakup/serialio.c b/drivers/staging/speakup/serialio.c deleted file mode 100644 index 177a2988641c..000000000000 --- a/drivers/staging/speakup/serialio.c +++ /dev/null @@ -1,316 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include - -#include "spk_types.h" -#include "speakup.h" -#include "spk_priv.h" -#include "serialio.h" - -#include -/* WARNING: Do not change this to without testing that - * SERIAL_PORT_DFNS does get defined to the appropriate value. - */ -#include - -#ifndef SERIAL_PORT_DFNS -#define SERIAL_PORT_DFNS -#endif - -static void start_serial_interrupt(int irq); - -static const struct old_serial_port rs_table[] = { - SERIAL_PORT_DFNS -}; - -static const struct old_serial_port *serstate; -static int timeouts; - -static int spk_serial_out(struct spk_synth *in_synth, const char ch); -static void spk_serial_send_xchar(char ch); -static void spk_serial_tiocmset(unsigned int set, unsigned int clear); -static unsigned char spk_serial_in(void); -static unsigned char spk_serial_in_nowait(void); -static void spk_serial_flush_buffer(void); - -struct spk_io_ops spk_serial_io_ops = { - .synth_out = spk_serial_out, - .send_xchar = spk_serial_send_xchar, - .tiocmset = spk_serial_tiocmset, - .synth_in = spk_serial_in, - .synth_in_nowait = spk_serial_in_nowait, - .flush_buffer = spk_serial_flush_buffer, -}; -EXPORT_SYMBOL_GPL(spk_serial_io_ops); - -const struct old_serial_port *spk_serial_init(int index) -{ - int baud = 9600, quot = 0; - unsigned int cval = 0; - int cflag = CREAD | HUPCL | CLOCAL | B9600 | CS8; - const struct old_serial_port *ser; - int err; - - if (index >= ARRAY_SIZE(rs_table)) { - pr_info("no port info for ttyS%d\n", index); - return NULL; - } - ser = rs_table + index; - - /* Divisor, bytesize and parity */ - quot = ser->baud_base / baud; - cval = cflag & (CSIZE | CSTOPB); -#if defined(__powerpc__) || defined(__alpha__) - cval >>= 8; -#else /* !__powerpc__ && !__alpha__ */ - cval >>= 4; -#endif /* !__powerpc__ && !__alpha__ */ - if (cflag & PARENB) - cval |= UART_LCR_PARITY; - if (!(cflag & PARODD)) - cval |= UART_LCR_EPAR; - if (synth_request_region(ser->port, 8)) { - /* try to take it back. */ - pr_info("Ports not available, trying to steal them\n"); - __release_region(&ioport_resource, ser->port, 8); - err = synth_request_region(ser->port, 8); - if (err) { - pr_warn("Unable to allocate port at %x, errno %i", - ser->port, err); - return NULL; - } - } - - /* Disable UART interrupts, set DTR and RTS high - * and set speed. - */ - outb(cval | UART_LCR_DLAB, ser->port + UART_LCR); /* set DLAB */ - outb(quot & 0xff, ser->port + UART_DLL); /* LS of divisor */ - outb(quot >> 8, ser->port + UART_DLM); /* MS of divisor */ - outb(cval, ser->port + UART_LCR); /* reset DLAB */ - - /* Turn off Interrupts */ - outb(0, ser->port + UART_IER); - outb(UART_MCR_DTR | UART_MCR_RTS, ser->port + UART_MCR); - - /* If we read 0xff from the LSR, there is no UART here. */ - if (inb(ser->port + UART_LSR) == 0xff) { - synth_release_region(ser->port, 8); - serstate = NULL; - return NULL; - } - - mdelay(1); - speakup_info.port_tts = ser->port; - serstate = ser; - - start_serial_interrupt(ser->irq); - - return ser; -} - -static irqreturn_t synth_readbuf_handler(int irq, void *dev_id) -{ - unsigned long flags; - int c; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - while (inb_p(speakup_info.port_tts + UART_LSR) & UART_LSR_DR) { - c = inb_p(speakup_info.port_tts + UART_RX); - synth->read_buff_add((u_char)c); - } - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return IRQ_HANDLED; -} - -static void start_serial_interrupt(int irq) -{ - int rv; - - if (!synth->read_buff_add) - return; - - rv = request_irq(irq, synth_readbuf_handler, IRQF_SHARED, - "serial", (void *)synth_readbuf_handler); - - if (rv) - pr_err("Unable to request Speakup serial I R Q\n"); - /* Set MCR */ - outb(UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2, - speakup_info.port_tts + UART_MCR); - /* Turn on Interrupts */ - outb(UART_IER_MSI | UART_IER_RLSI | UART_IER_RDI, - speakup_info.port_tts + UART_IER); - inb(speakup_info.port_tts + UART_LSR); - inb(speakup_info.port_tts + UART_RX); - inb(speakup_info.port_tts + UART_IIR); - inb(speakup_info.port_tts + UART_MSR); - outb(1, speakup_info.port_tts + UART_FCR); /* Turn FIFO On */ -} - -static void spk_serial_send_xchar(char ch) -{ - int timeout = SPK_XMITR_TIMEOUT; - - while (spk_serial_tx_busy()) { - if (!--timeout) - break; - udelay(1); - } - outb(ch, speakup_info.port_tts); -} - -static void spk_serial_tiocmset(unsigned int set, unsigned int clear) -{ - int old = inb(speakup_info.port_tts + UART_MCR); - - outb((old & ~clear) | set, speakup_info.port_tts + UART_MCR); -} - -int spk_serial_synth_probe(struct spk_synth *synth) -{ - const struct old_serial_port *ser; - int failed = 0; - - if ((synth->ser >= SPK_LO_TTY) && (synth->ser <= SPK_HI_TTY)) { - ser = spk_serial_init(synth->ser); - if (!ser) { - failed = -1; - } else { - outb_p(0, ser->port); - mdelay(1); - outb_p('\r', ser->port); - } - } else { - failed = -1; - pr_warn("ttyS%i is an invalid port\n", synth->ser); - } - if (failed) { - pr_info("%s: not found\n", synth->long_name); - return -ENODEV; - } - pr_info("%s: ttyS%i, Driver Version %s\n", - synth->long_name, synth->ser, synth->version); - synth->alive = 1; - return 0; -} -EXPORT_SYMBOL_GPL(spk_serial_synth_probe); - -void spk_stop_serial_interrupt(void) -{ - if (speakup_info.port_tts == 0) - return; - - if (!synth->read_buff_add) - return; - - /* Turn off interrupts */ - outb(0, speakup_info.port_tts + UART_IER); - /* Free IRQ */ - free_irq(serstate->irq, (void *)synth_readbuf_handler); -} -EXPORT_SYMBOL_GPL(spk_stop_serial_interrupt); - -int spk_wait_for_xmitr(struct spk_synth *in_synth) -{ - int tmout = SPK_XMITR_TIMEOUT; - - if ((in_synth->alive) && (timeouts >= NUM_DISABLE_TIMEOUTS)) { - pr_warn("%s: too many timeouts, deactivating speakup\n", - in_synth->long_name); - in_synth->alive = 0; - /* No synth any more, so nobody will restart TTYs, and we thus - * need to do it ourselves. Now that there is no synth we can - * let application flood anyway - */ - speakup_start_ttys(); - timeouts = 0; - return 0; - } - while (spk_serial_tx_busy()) { - if (--tmout == 0) { - pr_warn("%s: timed out (tx busy)\n", - in_synth->long_name); - timeouts++; - return 0; - } - udelay(1); - } - tmout = SPK_CTS_TIMEOUT; - while (!((inb_p(speakup_info.port_tts + UART_MSR)) & UART_MSR_CTS)) { - /* CTS */ - if (--tmout == 0) { - timeouts++; - return 0; - } - udelay(1); - } - timeouts = 0; - return 1; -} - -static unsigned char spk_serial_in(void) -{ - int tmout = SPK_SERIAL_TIMEOUT; - - while (!(inb_p(speakup_info.port_tts + UART_LSR) & UART_LSR_DR)) { - if (--tmout == 0) { - pr_warn("time out while waiting for input.\n"); - return 0xff; - } - udelay(1); - } - return inb_p(speakup_info.port_tts + UART_RX); -} - -static unsigned char spk_serial_in_nowait(void) -{ - unsigned char lsr; - - lsr = inb_p(speakup_info.port_tts + UART_LSR); - if (!(lsr & UART_LSR_DR)) - return 0; - return inb_p(speakup_info.port_tts + UART_RX); -} - -static void spk_serial_flush_buffer(void) -{ - /* TODO: flush the UART 16550 buffer */ -} - -static int spk_serial_out(struct spk_synth *in_synth, const char ch) -{ - if (in_synth->alive && spk_wait_for_xmitr(in_synth)) { - outb_p(ch, speakup_info.port_tts); - return 1; - } - return 0; -} - -const char *spk_serial_synth_immediate(struct spk_synth *synth, - const char *buff) -{ - u_char ch; - - while ((ch = *buff)) { - if (ch == '\n') - ch = synth->procspeech; - if (spk_wait_for_xmitr(synth)) - outb(ch, speakup_info.port_tts); - else - return buff; - buff++; - } - return NULL; -} -EXPORT_SYMBOL_GPL(spk_serial_synth_immediate); - -void spk_serial_release(void) -{ - spk_stop_serial_interrupt(); - if (speakup_info.port_tts == 0) - return; - synth_release_region(speakup_info.port_tts, 8); - speakup_info.port_tts = 0; -} -EXPORT_SYMBOL_GPL(spk_serial_release); diff --git a/drivers/staging/speakup/serialio.h b/drivers/staging/speakup/serialio.h deleted file mode 100644 index 6f8f86f161bb..000000000000 --- a/drivers/staging/speakup/serialio.h +++ /dev/null @@ -1,41 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _SPEAKUP_SERIAL_H -#define _SPEAKUP_SERIAL_H - -#include /* for rs_table, serial constants */ -#include /* for more serial constants */ -#include - -#include "spk_priv.h" - -/* - * this is cut&paste from 8250.h. Get rid of the structure, the definitions - * and this whole broken driver. - */ -struct old_serial_port { - unsigned int uart; /* unused */ - unsigned int baud_base; - unsigned int port; - unsigned int irq; - upf_t flags; /* unused */ -}; - -/* countdown values for serial timeouts in us */ -#define SPK_SERIAL_TIMEOUT SPK_SYNTH_TIMEOUT -/* countdown values transmitter/dsr timeouts in us */ -#define SPK_XMITR_TIMEOUT 100000 -/* countdown values cts timeouts in us */ -#define SPK_CTS_TIMEOUT 100000 -/* check ttyS0 ... ttyS3 */ -#define SPK_LO_TTY 0 -#define SPK_HI_TTY 3 -/* # of timeouts permitted before disable */ -#define NUM_DISABLE_TIMEOUTS 3 -/* buffer timeout in ms */ -#define SPK_TIMEOUT 100 -#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) - -#define spk_serial_tx_busy() \ - ((inb(speakup_info.port_tts + UART_LSR) & BOTH_EMPTY) != BOTH_EMPTY) - -#endif diff --git a/drivers/staging/speakup/speakup.h b/drivers/staging/speakup/speakup.h deleted file mode 100644 index 74fe49c2c511..000000000000 --- a/drivers/staging/speakup/speakup.h +++ /dev/null @@ -1,121 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _SPEAKUP_H -#define _SPEAKUP_H - -#include "spk_types.h" -#include "i18n.h" - -#define SPEAKUP_VERSION "3.1.6" -#define KEY_MAP_VER 119 -#define SHIFT_TBL_SIZE 64 -#define MAX_DESC_LEN 72 - -#define TOGGLE_0 .u.n = {NULL, 0, 0, 1, 0, 0, NULL } -#define TOGGLE_1 .u.n = {NULL, 1, 0, 1, 0, 0, NULL } -#define MAXVARLEN 15 - -#define SYNTH_OK 0x0001 -#define B_ALPHA 0x0002 -#define ALPHA 0x0003 -#define B_CAP 0x0004 -#define A_CAP 0x0007 -#define B_NUM 0x0008 -#define NUM 0x0009 -#define ALPHANUM (B_ALPHA | B_NUM) -#define SOME 0x0010 -#define MOST 0x0020 -#define PUNC 0x0040 -#define A_PUNC 0x0041 -#define B_WDLM 0x0080 -#define WDLM 0x0081 -#define B_EXNUM 0x0100 -#define CH_RPT 0x0200 -#define B_CTL 0x0400 -#define A_CTL (B_CTL + SYNTH_OK) -#define B_SYM 0x0800 -#define B_CAPSYM (B_CAP | B_SYM) - -/* FIXME: u16 */ -#define IS_WDLM(x) (spk_chartab[((u_char)x)] & B_WDLM) -#define IS_CHAR(x, type) (spk_chartab[((u_char)x)] & type) -#define IS_TYPE(x, type) ((spk_chartab[((u_char)x)] & type) == type) - -int speakup_thread(void *data); -void spk_reset_default_chars(void); -void spk_reset_default_chartab(void); -void synth_start(void); -void synth_insert_next_index(int sent_num); -void spk_reset_index_count(int sc); -void spk_get_index_count(int *linecount, int *sentcount); -int spk_set_key_info(const u_char *key_info, u_char *k_buffer); -char *spk_strlwr(char *s); -char *spk_s2uchar(char *start, char *dest); -int speakup_kobj_init(void); -void speakup_kobj_exit(void); -int spk_chartab_get_value(char *keyword); -void speakup_register_var(struct var_t *var); -void speakup_unregister_var(enum var_id_t var_id); -struct st_var_header *spk_get_var_header(enum var_id_t var_id); -struct st_var_header *spk_var_header_by_name(const char *name); -struct punc_var_t *spk_get_punc_var(enum var_id_t var_id); -int spk_set_num_var(int val, struct st_var_header *var, int how); -int spk_set_string_var(const char *page, struct st_var_header *var, int len); -int spk_set_mask_bits(const char *input, const int which, const int how); -extern special_func spk_special_handler; -int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key); -int synth_init(char *name); -void synth_release(void); - -void spk_do_flush(void); -void speakup_start_ttys(void); -void synth_buffer_add(u16 ch); -void synth_buffer_clear(void); -void speakup_clear_selection(void); -int speakup_set_selection(struct tty_struct *tty); -void speakup_cancel_selection(void); -int speakup_paste_selection(struct tty_struct *tty); -void speakup_cancel_paste(void); -void speakup_register_devsynth(void); -void speakup_unregister_devsynth(void); -void synth_write(const char *buf, size_t count); -int synth_supports_indexing(void); - -extern struct vc_data *spk_sel_cons; -extern unsigned short spk_xs, spk_ys, spk_xe, spk_ye; /* our region points */ - -extern wait_queue_head_t speakup_event; -extern struct kobject *speakup_kobj; -extern struct task_struct *speakup_task; -extern const u_char spk_key_defaults[]; - -/* Protect speakup synthesizer list */ -extern struct mutex spk_mutex; -extern struct st_spk_t *speakup_console[]; -extern struct spk_synth *synth; -extern char spk_pitch_buff[]; -extern u_char *spk_our_keys[]; -extern short spk_punc_masks[]; -extern char spk_str_caps_start[], spk_str_caps_stop[], spk_str_pause[]; -extern bool spk_paused; -extern const struct st_bits_data spk_punc_info[]; -extern u_char spk_key_buf[600]; -extern char *spk_characters[]; -extern char *spk_default_chars[]; -extern u_short spk_chartab[]; -extern int spk_no_intr, spk_say_ctrl, spk_say_word_ctl, spk_punc_level; -extern int spk_reading_punc, spk_attrib_bleep, spk_bleeps; -extern int spk_bleep_time, spk_bell_pos; -extern int spk_spell_delay, spk_key_echo; -extern short spk_punc_mask; -extern short spk_pitch_shift, synth_flags; -extern bool spk_quiet_boot; -extern char *synth_name; -extern struct bleep spk_unprocessed_sound; - -/* Prototypes from fakekey.c. */ -int speakup_add_virtual_keyboard(void); -void speakup_remove_virtual_keyboard(void); -void speakup_fake_down_arrow(void); -bool speakup_fake_key_pressed(void); - -#endif diff --git a/drivers/staging/speakup/speakup_acnt.h b/drivers/staging/speakup/speakup_acnt.h deleted file mode 100644 index cffa938ae580..000000000000 --- a/drivers/staging/speakup/speakup_acnt.h +++ /dev/null @@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* speakup_acntpc.h - header file for speakups Accent-PC driver. */ - -#define SYNTH_IO_EXTENT 0x02 - -#define SYNTH_CLEAR 0x18 /* stops speech */ - - /* Port Status Flags */ -#define SYNTH_READABLE 0x01 /* mask for bit which is nonzero if a - * byte can be read from the data port - */ -#define SYNTH_WRITABLE 0x02 /* mask for RDY bit, which when set to - * 1, indicates the data port is ready - * to accept a byte of data. - */ -#define SYNTH_QUIET 'S' /* synth is not speaking */ -#define SYNTH_FULL 'F' /* synth is full. */ -#define SYNTH_ALMOST_EMPTY 'M' /* synth has less than 2 seconds of text left */ -#define SYNTH_SPEAKING 's' /* synth is speaking and has a fare way to go */ diff --git a/drivers/staging/speakup/speakup_acntpc.c b/drivers/staging/speakup/speakup_acntpc.c deleted file mode 100644 index c94328a5bd4a..000000000000 --- a/drivers/staging/speakup/speakup_acntpc.c +++ /dev/null @@ -1,319 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * written by: Kirk Reiser - * this version considerably modified by David Borowski, david575@rogers.com - * - * Copyright (C) 1998-99 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - * - * this code is specificly written as a driver for the speakup screenreview - * package and is not a general device driver. - * This driver is for the Aicom Acent PC internal synthesizer. - */ - -#include -#include -#include -#include - -#include "spk_priv.h" -#include "serialio.h" -#include "speakup.h" -#include "speakup_acnt.h" /* local header file for Accent values */ - -#define DRV_VERSION "2.10" -#define PROCSPEECH '\r' - -static int synth_probe(struct spk_synth *synth); -static void accent_release(void); -static const char *synth_immediate(struct spk_synth *synth, const char *buf); -static void do_catch_up(struct spk_synth *synth); -static void synth_flush(struct spk_synth *synth); - -static int synth_port_control; -static int port_forced; -static unsigned int synth_portlist[] = { 0x2a8, 0 }; - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"\033P8" } }, - { CAPS_STOP, .u.s = {"\033P5" } }, - { RATE, .u.n = {"\033R%c", 9, 0, 17, 0, 0, "0123456789abcdefgh" } }, - { PITCH, .u.n = {"\033P%d", 5, 0, 9, 0, 0, NULL } }, - { VOL, .u.n = {"\033A%d", 5, 0, 9, 0, 0, NULL } }, - { TONE, .u.n = {"\033V%d", 5, 0, 9, 0, 0, NULL } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* - * These attributes will appear in /sys/accessibility/speakup/acntpc. - */ -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute tone_attribute = - __ATTR(tone, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &pitch_attribute.attr, - &rate_attribute.attr, - &tone_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_acntpc = { - .name = "acntpc", - .version = DRV_VERSION, - .long_name = "Accent PC", - .init = "\033=X \033Oi\033T2\033=M\033N1\n", - .procspeech = PROCSPEECH, - .clear = SYNTH_CLEAR, - .delay = 500, - .trigger = 50, - .jiffies = 50, - .full = 1000, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = &spk_serial_io_ops, - .probe = synth_probe, - .release = accent_release, - .synth_immediate = synth_immediate, - .catch_up = do_catch_up, - .flush = synth_flush, - .is_alive = spk_synth_is_alive_nop, - .synth_adjust = NULL, - .read_buff_add = NULL, - .get_index = NULL, - .indexing = { - .command = NULL, - .lowindex = 0, - .highindex = 0, - .currindex = 0, - }, - .attributes = { - .attrs = synth_attrs, - .name = "acntpc", - }, -}; - -static inline bool synth_writable(void) -{ - return inb_p(synth_port_control) & SYNTH_WRITABLE; -} - -static inline bool synth_full(void) -{ - return inb_p(speakup_info.port_tts + UART_RX) == 'F'; -} - -static const char *synth_immediate(struct spk_synth *synth, const char *buf) -{ - u_char ch; - - while ((ch = *buf)) { - int timeout = SPK_XMITR_TIMEOUT; - - if (ch == '\n') - ch = PROCSPEECH; - if (synth_full()) - return buf; - while (synth_writable()) { - if (!--timeout) - return buf; - udelay(1); - } - outb_p(ch, speakup_info.port_tts); - buf++; - } - return NULL; -} - -static void do_catch_up(struct spk_synth *synth) -{ - u_char ch; - unsigned long flags; - unsigned long jiff_max; - int timeout; - int delay_time_val; - int jiffy_delta_val; - int full_time_val; - struct var_t *delay_time; - struct var_t *full_time; - struct var_t *jiffy_delta; - - jiffy_delta = spk_get_var(JIFFY); - delay_time = spk_get_var(DELAY); - full_time = spk_get_var(FULL); - - spin_lock_irqsave(&speakup_info.spinlock, flags); - jiffy_delta_val = jiffy_delta->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - - jiff_max = jiffies + jiffy_delta_val; - while (!kthread_should_stop()) { - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (speakup_info.flushing) { - speakup_info.flushing = 0; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - synth->flush(synth); - continue; - } - synth_buffer_skip_nonlatin1(); - if (synth_buffer_empty()) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - break; - } - set_current_state(TASK_INTERRUPTIBLE); - full_time_val = full_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (synth_full()) { - schedule_timeout(msecs_to_jiffies(full_time_val)); - continue; - } - set_current_state(TASK_RUNNING); - timeout = SPK_XMITR_TIMEOUT; - while (synth_writable()) { - if (!--timeout) - break; - udelay(1); - } - spin_lock_irqsave(&speakup_info.spinlock, flags); - ch = synth_buffer_getc(); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (ch == '\n') - ch = PROCSPEECH; - outb_p(ch, speakup_info.port_tts); - if (time_after_eq(jiffies, jiff_max) && ch == SPACE) { - timeout = SPK_XMITR_TIMEOUT; - while (synth_writable()) { - if (!--timeout) - break; - udelay(1); - } - outb_p(PROCSPEECH, speakup_info.port_tts); - spin_lock_irqsave(&speakup_info.spinlock, flags); - jiffy_delta_val = jiffy_delta->u.n.value; - delay_time_val = delay_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - schedule_timeout(msecs_to_jiffies(delay_time_val)); - jiff_max = jiffies + jiffy_delta_val; - } - } - timeout = SPK_XMITR_TIMEOUT; - while (synth_writable()) { - if (!--timeout) - break; - udelay(1); - } - outb_p(PROCSPEECH, speakup_info.port_tts); -} - -static void synth_flush(struct spk_synth *synth) -{ - outb_p(SYNTH_CLEAR, speakup_info.port_tts); -} - -static int synth_probe(struct spk_synth *synth) -{ - unsigned int port_val = 0; - int i = 0; - - pr_info("Probing for %s.\n", synth->long_name); - if (port_forced) { - speakup_info.port_tts = port_forced; - pr_info("probe forced to %x by kernel command line\n", - speakup_info.port_tts); - if (synth_request_region(speakup_info.port_tts - 1, - SYNTH_IO_EXTENT)) { - pr_warn("sorry, port already reserved\n"); - return -EBUSY; - } - port_val = inw(speakup_info.port_tts - 1); - synth_port_control = speakup_info.port_tts - 1; - } else { - for (i = 0; synth_portlist[i]; i++) { - if (synth_request_region(synth_portlist[i], - SYNTH_IO_EXTENT)) { - pr_warn - ("request_region: failed with 0x%x, %d\n", - synth_portlist[i], SYNTH_IO_EXTENT); - continue; - } - port_val = inw(synth_portlist[i]) & 0xfffc; - if (port_val == 0x53fc) { - /* 'S' and out&input bits */ - synth_port_control = synth_portlist[i]; - speakup_info.port_tts = synth_port_control + 1; - break; - } - } - } - port_val &= 0xfffc; - if (port_val != 0x53fc) { - /* 'S' and out&input bits */ - pr_info("%s: not found\n", synth->long_name); - synth_release_region(synth_port_control, SYNTH_IO_EXTENT); - synth_port_control = 0; - return -ENODEV; - } - pr_info("%s: %03x-%03x, driver version %s,\n", synth->long_name, - synth_port_control, synth_port_control + SYNTH_IO_EXTENT - 1, - synth->version); - synth->alive = 1; - return 0; -} - -static void accent_release(void) -{ - spk_stop_serial_interrupt(); - if (speakup_info.port_tts) - synth_release_region(speakup_info.port_tts - 1, - SYNTH_IO_EXTENT); - speakup_info.port_tts = 0; -} - -module_param_hw_named(port, port_forced, int, ioport, 0444); -module_param_named(start, synth_acntpc.startup, short, 0444); - -MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing)."); -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_acntpc); - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_AUTHOR("David Borowski"); -MODULE_DESCRIPTION("Speakup support for Accent PC synthesizer"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/drivers/staging/speakup/speakup_acntsa.c b/drivers/staging/speakup/speakup_acntsa.c deleted file mode 100644 index 3a863dc61286..000000000000 --- a/drivers/staging/speakup/speakup_acntsa.c +++ /dev/null @@ -1,144 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * originally written by: Kirk Reiser - * this version considerably modified by David Borowski, david575@rogers.com - * - * Copyright (C) 1998-99 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - * - * this code is specificly written as a driver for the speakup screenreview - * package and is not a general device driver. - */ - -#include "spk_priv.h" -#include "speakup.h" -#include "speakup_acnt.h" /* local header file for Accent values */ - -#define DRV_VERSION "2.11" -#define PROCSPEECH '\r' - -static int synth_probe(struct spk_synth *synth); - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"\033P8" } }, - { CAPS_STOP, .u.s = {"\033P5" } }, - { RATE, .u.n = {"\033R%c", 9, 0, 17, 0, 0, "0123456789abcdefgh" } }, - { PITCH, .u.n = {"\033P%d", 5, 0, 9, 0, 0, NULL } }, - { VOL, .u.n = {"\033A%d", 9, 0, 9, 0, 0, NULL } }, - { TONE, .u.n = {"\033V%d", 5, 0, 9, 0, 0, NULL } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* - * These attributes will appear in /sys/accessibility/speakup/acntsa. - */ -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute tone_attribute = - __ATTR(tone, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &pitch_attribute.attr, - &rate_attribute.attr, - &tone_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_acntsa = { - .name = "acntsa", - .version = DRV_VERSION, - .long_name = "Accent-SA", - .init = "\033T2\033=M\033Oi\033N1\n", - .procspeech = PROCSPEECH, - .clear = SYNTH_CLEAR, - .delay = 400, - .trigger = 50, - .jiffies = 30, - .full = 40000, - .dev_name = SYNTH_DEFAULT_DEV, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = &spk_ttyio_ops, - .probe = synth_probe, - .release = spk_ttyio_release, - .synth_immediate = spk_ttyio_synth_immediate, - .catch_up = spk_do_catch_up, - .flush = spk_synth_flush, - .is_alive = spk_synth_is_alive_restart, - .synth_adjust = NULL, - .read_buff_add = NULL, - .get_index = NULL, - .indexing = { - .command = NULL, - .lowindex = 0, - .highindex = 0, - .currindex = 0, - }, - .attributes = { - .attrs = synth_attrs, - .name = "acntsa", - }, -}; - -static int synth_probe(struct spk_synth *synth) -{ - int failed; - - failed = spk_ttyio_synth_probe(synth); - if (failed == 0) { - synth->synth_immediate(synth, "\033=R\r"); - mdelay(100); - } - synth->alive = !failed; - return failed; -} - -module_param_named(ser, synth_acntsa.ser, int, 0444); -module_param_named(dev, synth_acntsa.dev_name, charp, 0444); -module_param_named(start, synth_acntsa.startup, short, 0444); - -MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); -MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_acntsa); - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_AUTHOR("David Borowski"); -MODULE_DESCRIPTION("Speakup support for Accent SA synthesizer"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/drivers/staging/speakup/speakup_apollo.c b/drivers/staging/speakup/speakup_apollo.c deleted file mode 100644 index 0877b4044c28..000000000000 --- a/drivers/staging/speakup/speakup_apollo.c +++ /dev/null @@ -1,208 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * originally written by: Kirk Reiser - * this version considerably modified by David Borowski, david575@rogers.com - * - * Copyright (C) 1998-99 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - * - * this code is specificly written as a driver for the speakup screenreview - * package and is not a general device driver. - */ -#include -#include -#include -#include -#include /* for UART_MCR* constants */ - -#include "spk_priv.h" -#include "speakup.h" - -#define DRV_VERSION "2.21" -#define SYNTH_CLEAR 0x18 -#define PROCSPEECH '\r' - -static void do_catch_up(struct spk_synth *synth); - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"cap, " } }, - { CAPS_STOP, .u.s = {"" } }, - { RATE, .u.n = {"@W%d", 6, 1, 9, 0, 0, NULL } }, - { PITCH, .u.n = {"@F%x", 10, 0, 15, 0, 0, NULL } }, - { VOL, .u.n = {"@A%x", 10, 0, 15, 0, 0, NULL } }, - { VOICE, .u.n = {"@V%d", 1, 1, 6, 0, 0, NULL } }, - { LANG, .u.n = {"@=%d,", 1, 1, 4, 0, 0, NULL } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* - * These attributes will appear in /sys/accessibility/speakup/apollo. - */ -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute lang_attribute = - __ATTR(lang, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute voice_attribute = - __ATTR(voice, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &lang_attribute.attr, - &pitch_attribute.attr, - &rate_attribute.attr, - &voice_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_apollo = { - .name = "apollo", - .version = DRV_VERSION, - .long_name = "Apollo", - .init = "@R3@D0@K1\r", - .procspeech = PROCSPEECH, - .clear = SYNTH_CLEAR, - .delay = 500, - .trigger = 50, - .jiffies = 50, - .full = 40000, - .dev_name = SYNTH_DEFAULT_DEV, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = &spk_ttyio_ops, - .probe = spk_ttyio_synth_probe, - .release = spk_ttyio_release, - .synth_immediate = spk_ttyio_synth_immediate, - .catch_up = do_catch_up, - .flush = spk_synth_flush, - .is_alive = spk_synth_is_alive_restart, - .synth_adjust = NULL, - .read_buff_add = NULL, - .get_index = NULL, - .indexing = { - .command = NULL, - .lowindex = 0, - .highindex = 0, - .currindex = 0, - }, - .attributes = { - .attrs = synth_attrs, - .name = "apollo", - }, -}; - -static void do_catch_up(struct spk_synth *synth) -{ - u_char ch; - unsigned long flags; - unsigned long jiff_max; - struct var_t *jiffy_delta; - struct var_t *delay_time; - struct var_t *full_time; - int full_time_val = 0; - int delay_time_val = 0; - int jiffy_delta_val = 0; - - jiffy_delta = spk_get_var(JIFFY); - delay_time = spk_get_var(DELAY); - full_time = spk_get_var(FULL); - spin_lock_irqsave(&speakup_info.spinlock, flags); - jiffy_delta_val = jiffy_delta->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - jiff_max = jiffies + jiffy_delta_val; - - while (!kthread_should_stop()) { - spin_lock_irqsave(&speakup_info.spinlock, flags); - jiffy_delta_val = jiffy_delta->u.n.value; - full_time_val = full_time->u.n.value; - delay_time_val = delay_time->u.n.value; - if (speakup_info.flushing) { - speakup_info.flushing = 0; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - synth->flush(synth); - continue; - } - synth_buffer_skip_nonlatin1(); - if (synth_buffer_empty()) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - break; - } - ch = synth_buffer_peek(); - set_current_state(TASK_INTERRUPTIBLE); - full_time_val = full_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (!synth->io_ops->synth_out(synth, ch)) { - synth->io_ops->tiocmset(0, UART_MCR_RTS); - synth->io_ops->tiocmset(UART_MCR_RTS, 0); - schedule_timeout(msecs_to_jiffies(full_time_val)); - continue; - } - if (time_after_eq(jiffies, jiff_max) && (ch == SPACE)) { - spin_lock_irqsave(&speakup_info.spinlock, flags); - jiffy_delta_val = jiffy_delta->u.n.value; - full_time_val = full_time->u.n.value; - delay_time_val = delay_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (synth->io_ops->synth_out(synth, synth->procspeech)) - schedule_timeout(msecs_to_jiffies - (delay_time_val)); - else - schedule_timeout(msecs_to_jiffies - (full_time_val)); - jiff_max = jiffies + jiffy_delta_val; - } - set_current_state(TASK_RUNNING); - spin_lock_irqsave(&speakup_info.spinlock, flags); - synth_buffer_getc(); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - } - synth->io_ops->synth_out(synth, PROCSPEECH); -} - -module_param_named(ser, synth_apollo.ser, int, 0444); -module_param_named(dev, synth_apollo.dev_name, charp, 0444); -module_param_named(start, synth_apollo.startup, short, 0444); - -MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); -MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_apollo); - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_AUTHOR("David Borowski"); -MODULE_DESCRIPTION("Speakup support for Apollo II synthesizer"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/drivers/staging/speakup/speakup_audptr.c b/drivers/staging/speakup/speakup_audptr.c deleted file mode 100644 index e6a6a9665d8f..000000000000 --- a/drivers/staging/speakup/speakup_audptr.c +++ /dev/null @@ -1,171 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * originally written by: Kirk Reiser - * this version considerably modified by David Borowski, david575@rogers.com - * - * Copyright (C) 1998-99 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - * - * specificly written as a driver for the speakup screenreview - * s not a general device driver. - */ -#include "spk_priv.h" -#include "speakup.h" - -#define DRV_VERSION "2.11" -#define SYNTH_CLEAR 0x18 /* flush synth buffer */ -#define PROCSPEECH '\r' /* start synth processing speech char */ - -static int synth_probe(struct spk_synth *synth); -static void synth_flush(struct spk_synth *synth); - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"\x05[f99]" } }, - { CAPS_STOP, .u.s = {"\x05[f80]" } }, - { RATE, .u.n = {"\x05[r%d]", 10, 0, 20, 100, -10, NULL } }, - { PITCH, .u.n = {"\x05[f%d]", 80, 39, 4500, 0, 0, NULL } }, - { VOL, .u.n = {"\x05[g%d]", 21, 0, 40, 0, 0, NULL } }, - { TONE, .u.n = {"\x05[s%d]", 9, 0, 63, 0, 0, NULL } }, - { PUNCT, .u.n = {"\x05[A%c]", 0, 0, 3, 0, 0, "nmsa" } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* - * These attributes will appear in /sys/accessibility/speakup/audptr. - */ -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute punct_attribute = - __ATTR(punct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute tone_attribute = - __ATTR(tone, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &pitch_attribute.attr, - &punct_attribute.attr, - &rate_attribute.attr, - &tone_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_audptr = { - .name = "audptr", - .version = DRV_VERSION, - .long_name = "Audapter", - .init = "\x05[D1]\x05[Ol]", - .procspeech = PROCSPEECH, - .clear = SYNTH_CLEAR, - .delay = 400, - .trigger = 50, - .jiffies = 30, - .full = 18000, - .dev_name = SYNTH_DEFAULT_DEV, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = &spk_ttyio_ops, - .probe = synth_probe, - .release = spk_ttyio_release, - .synth_immediate = spk_ttyio_synth_immediate, - .catch_up = spk_do_catch_up, - .flush = synth_flush, - .is_alive = spk_synth_is_alive_restart, - .synth_adjust = NULL, - .read_buff_add = NULL, - .get_index = NULL, - .indexing = { - .command = NULL, - .lowindex = 0, - .highindex = 0, - .currindex = 0, - }, - .attributes = { - .attrs = synth_attrs, - .name = "audptr", - }, -}; - -static void synth_flush(struct spk_synth *synth) -{ - synth->io_ops->flush_buffer(); - synth->io_ops->send_xchar(SYNTH_CLEAR); - synth->io_ops->synth_out(synth, PROCSPEECH); -} - -static void synth_version(struct spk_synth *synth) -{ - unsigned char test = 0; - char synth_id[40] = ""; - - synth->synth_immediate(synth, "\x05[Q]"); - synth_id[test] = synth->io_ops->synth_in(); - if (synth_id[test] == 'A') { - do { - /* read version string from synth */ - synth_id[++test] = synth->io_ops->synth_in(); - } while (synth_id[test] != '\n' && test < 32); - synth_id[++test] = 0x00; - } - if (synth_id[0] == 'A') - pr_info("%s version: %s", synth->long_name, synth_id); -} - -static int synth_probe(struct spk_synth *synth) -{ - int failed; - - failed = spk_ttyio_synth_probe(synth); - if (failed == 0) - synth_version(synth); - synth->alive = !failed; - return 0; -} - -module_param_named(ser, synth_audptr.ser, int, 0444); -module_param_named(dev, synth_audptr.dev_name, charp, 0444); -module_param_named(start, synth_audptr.startup, short, 0444); - -MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); -MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_audptr); - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_AUTHOR("David Borowski"); -MODULE_DESCRIPTION("Speakup support for Audapter synthesizer"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/drivers/staging/speakup/speakup_bns.c b/drivers/staging/speakup/speakup_bns.c deleted file mode 100644 index 76dfa3f7c058..000000000000 --- a/drivers/staging/speakup/speakup_bns.c +++ /dev/null @@ -1,128 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * originally written by: Kirk Reiser - * this version considerably modified by David Borowski, david575@rogers.com - * - * Copyright (C) 1998-99 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - * - * this code is specificly written as a driver for the speakup screenreview - * package and is not a general device driver. - */ -#include "spk_priv.h" -#include "speakup.h" - -#define DRV_VERSION "2.11" -#define SYNTH_CLEAR 0x18 -#define PROCSPEECH '\r' - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"\x05\x31\x32P" } }, - { CAPS_STOP, .u.s = {"\x05\x38P" } }, - { RATE, .u.n = {"\x05%dE", 8, 1, 16, 0, 0, NULL } }, - { PITCH, .u.n = {"\x05%dP", 8, 0, 16, 0, 0, NULL } }, - { VOL, .u.n = {"\x05%dV", 8, 0, 16, 0, 0, NULL } }, - { TONE, .u.n = {"\x05%dT", 8, 0, 16, 0, 0, NULL } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* - * These attributes will appear in /sys/accessibility/speakup/bns. - */ -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute tone_attribute = - __ATTR(tone, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &pitch_attribute.attr, - &rate_attribute.attr, - &tone_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_bns = { - .name = "bns", - .version = DRV_VERSION, - .long_name = "Braille 'N Speak", - .init = "\x05Z\x05\x43", - .procspeech = PROCSPEECH, - .clear = SYNTH_CLEAR, - .delay = 500, - .trigger = 50, - .jiffies = 50, - .full = 40000, - .dev_name = SYNTH_DEFAULT_DEV, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = &spk_ttyio_ops, - .probe = spk_ttyio_synth_probe, - .release = spk_ttyio_release, - .synth_immediate = spk_ttyio_synth_immediate, - .catch_up = spk_do_catch_up, - .flush = spk_synth_flush, - .is_alive = spk_synth_is_alive_restart, - .synth_adjust = NULL, - .read_buff_add = NULL, - .get_index = NULL, - .indexing = { - .command = NULL, - .lowindex = 0, - .highindex = 0, - .currindex = 0, - }, - .attributes = { - .attrs = synth_attrs, - .name = "bns", - }, -}; - -module_param_named(ser, synth_bns.ser, int, 0444); -module_param_named(dev, synth_bns.dev_name, charp, 0444); -module_param_named(start, synth_bns.startup, short, 0444); - -MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); -MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_bns); - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_AUTHOR("David Borowski"); -MODULE_DESCRIPTION("Speakup support for Braille 'n Speak synthesizers"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/drivers/staging/speakup/speakup_decext.c b/drivers/staging/speakup/speakup_decext.c deleted file mode 100644 index 7408eb29cf38..000000000000 --- a/drivers/staging/speakup/speakup_decext.c +++ /dev/null @@ -1,240 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * originally written by: Kirk Reiser - * this version considerably modified by David Borowski, david575@rogers.com - * - * Copyright (C) 1998-99 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - * - * specificly written as a driver for the speakup screenreview - * s not a general device driver. - */ -#include -#include -#include -#include - -#include "spk_priv.h" -#include "speakup.h" - -#define DRV_VERSION "2.14" -#define SYNTH_CLEAR 0x03 -#define PROCSPEECH 0x0b - -static volatile unsigned char last_char; - -static void read_buff_add(u_char ch) -{ - last_char = ch; -} - -static inline bool synth_full(void) -{ - return last_char == 0x13; -} - -static void do_catch_up(struct spk_synth *synth); -static void synth_flush(struct spk_synth *synth); - -static int in_escape; - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"[:dv ap 222]" } }, - { CAPS_STOP, .u.s = {"[:dv ap 100]" } }, - { RATE, .u.n = {"[:ra %d]", 7, 0, 9, 150, 25, NULL } }, - { PITCH, .u.n = {"[:dv ap %d]", 100, 0, 100, 0, 0, NULL } }, - { INFLECTION, .u.n = {"[:dv pr %d] ", 100, 0, 10000, 0, 0, NULL } }, - { VOL, .u.n = {"[:dv gv %d]", 13, 0, 16, 0, 5, NULL } }, - { PUNCT, .u.n = {"[:pu %c]", 0, 0, 2, 0, 0, "nsa" } }, - { VOICE, .u.n = {"[:n%c]", 0, 0, 9, 0, 0, "phfdburwkv" } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* - * These attributes will appear in /sys/accessibility/speakup/decext. - */ -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute inflection_attribute = - __ATTR(inflection, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute punct_attribute = - __ATTR(punct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute voice_attribute = - __ATTR(voice, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &pitch_attribute.attr, - &inflection_attribute.attr, - &punct_attribute.attr, - &rate_attribute.attr, - &voice_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_decext = { - .name = "decext", - .version = DRV_VERSION, - .long_name = "Dectalk External", - .init = "[:pe -380]", - .procspeech = PROCSPEECH, - .clear = SYNTH_CLEAR, - .delay = 500, - .trigger = 50, - .jiffies = 50, - .full = 40000, - .flags = SF_DEC, - .dev_name = SYNTH_DEFAULT_DEV, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = &spk_ttyio_ops, - .probe = spk_ttyio_synth_probe, - .release = spk_ttyio_release, - .synth_immediate = spk_ttyio_synth_immediate, - .catch_up = do_catch_up, - .flush = synth_flush, - .is_alive = spk_synth_is_alive_restart, - .synth_adjust = NULL, - .read_buff_add = read_buff_add, - .get_index = NULL, - .indexing = { - .command = NULL, - .lowindex = 0, - .highindex = 0, - .currindex = 0, - }, - .attributes = { - .attrs = synth_attrs, - .name = "decext", - }, -}; - -static void do_catch_up(struct spk_synth *synth) -{ - u_char ch; - static u_char last = '\0'; - unsigned long flags; - unsigned long jiff_max; - struct var_t *jiffy_delta; - struct var_t *delay_time; - int jiffy_delta_val = 0; - int delay_time_val = 0; - - jiffy_delta = spk_get_var(JIFFY); - delay_time = spk_get_var(DELAY); - - spin_lock_irqsave(&speakup_info.spinlock, flags); - jiffy_delta_val = jiffy_delta->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - jiff_max = jiffies + jiffy_delta_val; - - while (!kthread_should_stop()) { - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (speakup_info.flushing) { - speakup_info.flushing = 0; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - synth->flush(synth); - continue; - } - synth_buffer_skip_nonlatin1(); - if (synth_buffer_empty()) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - break; - } - ch = synth_buffer_peek(); - set_current_state(TASK_INTERRUPTIBLE); - delay_time_val = delay_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (ch == '\n') - ch = 0x0D; - if (synth_full() || !synth->io_ops->synth_out(synth, ch)) { - schedule_timeout(msecs_to_jiffies(delay_time_val)); - continue; - } - set_current_state(TASK_RUNNING); - spin_lock_irqsave(&speakup_info.spinlock, flags); - synth_buffer_getc(); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (ch == '[') { - in_escape = 1; - } else if (ch == ']') { - in_escape = 0; - } else if (ch <= SPACE) { - if (!in_escape && strchr(",.!?;:", last)) - synth->io_ops->synth_out(synth, PROCSPEECH); - if (time_after_eq(jiffies, jiff_max)) { - if (!in_escape) - synth->io_ops->synth_out(synth, - PROCSPEECH); - spin_lock_irqsave(&speakup_info.spinlock, - flags); - jiffy_delta_val = jiffy_delta->u.n.value; - delay_time_val = delay_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, - flags); - schedule_timeout(msecs_to_jiffies - (delay_time_val)); - jiff_max = jiffies + jiffy_delta_val; - } - } - last = ch; - } - if (!in_escape) - synth->io_ops->synth_out(synth, PROCSPEECH); -} - -static void synth_flush(struct spk_synth *synth) -{ - in_escape = 0; - synth->io_ops->flush_buffer(); - synth->synth_immediate(synth, "\033P;10z\033\\"); -} - -module_param_named(ser, synth_decext.ser, int, 0444); -module_param_named(dev, synth_decext.dev_name, charp, 0444); -module_param_named(start, synth_decext.startup, short, 0444); - -MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); -MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_decext); - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_AUTHOR("David Borowski"); -MODULE_DESCRIPTION("Speakup support for DECtalk External synthesizers"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/drivers/staging/speakup/speakup_decpc.c b/drivers/staging/speakup/speakup_decpc.c deleted file mode 100644 index 96f24c848cc5..000000000000 --- a/drivers/staging/speakup/speakup_decpc.c +++ /dev/null @@ -1,495 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * This is the DECtalk PC speakup driver - * - * Some constants from DEC's DOS driver: - * Copyright (c) by Digital Equipment Corp. - * - * 386BSD DECtalk PC driver: - * Copyright (c) 1996 Brian Buhrow - * - * Linux DECtalk PC driver: - * Copyright (c) 1997 Nicolas Pitre - * - * speakup DECtalk PC Internal driver: - * Copyright (c) 2003 David Borowski - * - * All rights reserved. - */ -#include -#include -#include -#include - -#include "spk_priv.h" -#include "speakup.h" - -#define MODULE_init 0x0dec /* module in boot code */ -#define MODULE_self_test 0x8800 /* module in self-test */ -#define MODULE_reset 0xffff /* reinit the whole module */ - -#define MODE_mask 0xf000 /* mode bits in high nibble */ -#define MODE_null 0x0000 -#define MODE_test 0x2000 /* in testing mode */ -#define MODE_status 0x8000 -#define STAT_int 0x0001 /* running in interrupt mode */ -#define STAT_tr_char 0x0002 /* character data to transmit */ -#define STAT_rr_char 0x0004 /* ready to receive char data */ -#define STAT_cmd_ready 0x0008 /* ready to accept commands */ -#define STAT_dma_ready 0x0010 /* dma command ready */ -#define STAT_digitized 0x0020 /* spc in digitized mode */ -#define STAT_new_index 0x0040 /* new last index ready */ -#define STAT_new_status 0x0080 /* new status posted */ -#define STAT_dma_state 0x0100 /* dma state toggle */ -#define STAT_index_valid 0x0200 /* indexs are valid */ -#define STAT_flushing 0x0400 /* flush in progress */ -#define STAT_self_test 0x0800 /* module in self test */ -#define MODE_ready 0xc000 /* module ready for next phase */ -#define READY_boot 0x0000 -#define READY_kernel 0x0001 -#define MODE_error 0xf000 - -#define CMD_mask 0xf000 /* mask for command nibble */ -#define CMD_null 0x0000 /* post status */ -#define CMD_control 0x1000 /* hard control command */ -#define CTRL_mask 0x0F00 /* mask off control nibble */ -#define CTRL_data 0x00FF /* mask to get data byte */ -#define CTRL_null 0x0000 /* null control */ -#define CTRL_vol_up 0x0100 /* increase volume */ -#define CTRL_vol_down 0x0200 /* decrease volume */ -#define CTRL_vol_set 0x0300 /* set volume */ -#define CTRL_pause 0x0400 /* pause spc */ -#define CTRL_resume 0x0500 /* resume spc clock */ -#define CTRL_resume_spc 0x0001 /* resume spc soft pause */ -#define CTRL_flush 0x0600 /* flush all buffers */ -#define CTRL_int_enable 0x0700 /* enable status change ints */ -#define CTRL_buff_free 0x0800 /* buffer remain count */ -#define CTRL_buff_used 0x0900 /* buffer in use */ -#define CTRL_speech 0x0a00 /* immediate speech change */ -#define CTRL_SP_voice 0x0001 /* voice change */ -#define CTRL_SP_rate 0x0002 /* rate change */ -#define CTRL_SP_comma 0x0003 /* comma pause change */ -#define CTRL_SP_period 0x0004 /* period pause change */ -#define CTRL_SP_rate_delta 0x0005 /* delta rate change */ -#define CTRL_SP_get_param 0x0006 /* return the desired parameter */ -#define CTRL_last_index 0x0b00 /* get last index spoken */ -#define CTRL_io_priority 0x0c00 /* change i/o priority */ -#define CTRL_free_mem 0x0d00 /* get free paragraphs on module */ -#define CTRL_get_lang 0x0e00 /* return bitmask of loaded languages */ -#define CMD_test 0x2000 /* self-test request */ -#define TEST_mask 0x0F00 /* isolate test field */ -#define TEST_null 0x0000 /* no test requested */ -#define TEST_isa_int 0x0100 /* assert isa irq */ -#define TEST_echo 0x0200 /* make data in == data out */ -#define TEST_seg 0x0300 /* set peek/poke segment */ -#define TEST_off 0x0400 /* set peek/poke offset */ -#define TEST_peek 0x0500 /* data out == *peek */ -#define TEST_poke 0x0600 /* *peek == data in */ -#define TEST_sub_code 0x00FF /* user defined test sub codes */ -#define CMD_id 0x3000 /* return software id */ -#define ID_null 0x0000 /* null id */ -#define ID_kernel 0x0100 /* kernel code executing */ -#define ID_boot 0x0200 /* boot code executing */ -#define CMD_dma 0x4000 /* force a dma start */ -#define CMD_reset 0x5000 /* reset module status */ -#define CMD_sync 0x6000 /* kernel sync command */ -#define CMD_char_in 0x7000 /* single character send */ -#define CMD_char_out 0x8000 /* single character get */ -#define CHAR_count_1 0x0100 /* one char in cmd_low */ -#define CHAR_count_2 0x0200 /* the second in data_low */ -#define CHAR_count_3 0x0300 /* the third in data_high */ -#define CMD_spc_mode 0x9000 /* change spc mode */ -#define CMD_spc_to_text 0x0100 /* set to text mode */ -#define CMD_spc_to_digit 0x0200 /* set to digital mode */ -#define CMD_spc_rate 0x0400 /* change spc data rate */ -#define CMD_error 0xf000 /* severe error */ - -enum { PRIMARY_DIC = 0, USER_DIC, COMMAND_DIC, ABBREV_DIC }; - -#define DMA_single_in 0x01 -#define DMA_single_out 0x02 -#define DMA_buff_in 0x03 -#define DMA_buff_out 0x04 -#define DMA_control 0x05 -#define DT_MEM_ALLOC 0x03 -#define DT_SET_DIC 0x04 -#define DT_START_TASK 0x05 -#define DT_LOAD_MEM 0x06 -#define DT_READ_MEM 0x07 -#define DT_DIGITAL_IN 0x08 -#define DMA_sync 0x06 -#define DMA_sync_char 0x07 - -#define DRV_VERSION "2.12" -#define PROCSPEECH 0x0b -#define SYNTH_IO_EXTENT 8 - -static int synth_probe(struct spk_synth *synth); -static void dtpc_release(void); -static const char *synth_immediate(struct spk_synth *synth, const char *buf); -static void do_catch_up(struct spk_synth *synth); -static void synth_flush(struct spk_synth *synth); - -static int synth_portlist[] = { 0x340, 0x350, 0x240, 0x250, 0 }; -static int in_escape, is_flushing; -static int dt_stat, dma_state; - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"[:dv ap 200]" } }, - { CAPS_STOP, .u.s = {"[:dv ap 100]" } }, - { RATE, .u.n = {"[:ra %d]", 9, 0, 18, 150, 25, NULL } }, - { PITCH, .u.n = {"[:dv ap %d]", 80, 0, 100, 20, 0, NULL } }, - { INFLECTION, .u.n = {"[:dv pr %d] ", 100, 0, 10000, 0, 0, NULL } }, - { VOL, .u.n = {"[:vo se %d]", 5, 0, 9, 5, 10, NULL } }, - { PUNCT, .u.n = {"[:pu %c]", 0, 0, 2, 0, 0, "nsa" } }, - { VOICE, .u.n = {"[:n%c]", 0, 0, 9, 0, 0, "phfdburwkv" } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* - * These attributes will appear in /sys/accessibility/speakup/decpc. - */ -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute inflection_attribute = - __ATTR(inflection, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute punct_attribute = - __ATTR(punct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute voice_attribute = - __ATTR(voice, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &pitch_attribute.attr, - &inflection_attribute.attr, - &punct_attribute.attr, - &rate_attribute.attr, - &voice_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_dec_pc = { - .name = "decpc", - .version = DRV_VERSION, - .long_name = "Dectalk PC", - .init = "[:pe -380]", - .procspeech = PROCSPEECH, - .delay = 500, - .trigger = 50, - .jiffies = 50, - .full = 1000, - .flags = SF_DEC, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = &spk_serial_io_ops, - .probe = synth_probe, - .release = dtpc_release, - .synth_immediate = synth_immediate, - .catch_up = do_catch_up, - .flush = synth_flush, - .is_alive = spk_synth_is_alive_nop, - .synth_adjust = NULL, - .read_buff_add = NULL, - .get_index = NULL, - .indexing = { - .command = NULL, - .lowindex = 0, - .highindex = 0, - .currindex = 0, - }, - .attributes = { - .attrs = synth_attrs, - .name = "decpc", - }, -}; - -static int dt_getstatus(void) -{ - dt_stat = inb_p(speakup_info.port_tts) | - (inb_p(speakup_info.port_tts + 1) << 8); - return dt_stat; -} - -static void dt_sendcmd(u_int cmd) -{ - outb_p(cmd & 0xFF, speakup_info.port_tts); - outb_p((cmd >> 8) & 0xFF, speakup_info.port_tts + 1); -} - -static int dt_waitbit(int bit) -{ - int timeout = 100; - - while (--timeout > 0) { - if ((dt_getstatus() & bit) == bit) - return 1; - udelay(50); - } - return 0; -} - -static int dt_wait_dma(void) -{ - int timeout = 100, state = dma_state; - - if (!dt_waitbit(STAT_dma_ready)) - return 0; - while (--timeout > 0) { - if ((dt_getstatus() & STAT_dma_state) == state) - return 1; - udelay(50); - } - dma_state = dt_getstatus() & STAT_dma_state; - return 1; -} - -static int dt_ctrl(u_int cmd) -{ - int timeout = 10; - - if (!dt_waitbit(STAT_cmd_ready)) - return -1; - outb_p(0, speakup_info.port_tts + 2); - outb_p(0, speakup_info.port_tts + 3); - dt_getstatus(); - dt_sendcmd(CMD_control | cmd); - outb_p(0, speakup_info.port_tts + 6); - while (dt_getstatus() & STAT_cmd_ready) { - udelay(20); - if (--timeout == 0) - break; - } - dt_sendcmd(CMD_null); - return 0; -} - -static void synth_flush(struct spk_synth *synth) -{ - int timeout = 10; - - if (is_flushing) - return; - is_flushing = 4; - in_escape = 0; - while (dt_ctrl(CTRL_flush)) { - if (--timeout == 0) - break; - udelay(50); - } - for (timeout = 0; timeout < 10; timeout++) { - if (dt_waitbit(STAT_dma_ready)) - break; - udelay(50); - } - outb_p(DMA_sync, speakup_info.port_tts + 4); - outb_p(0, speakup_info.port_tts + 4); - udelay(100); - for (timeout = 0; timeout < 10; timeout++) { - if (!(dt_getstatus() & STAT_flushing)) - break; - udelay(50); - } - dma_state = dt_getstatus() & STAT_dma_state; - dma_state ^= STAT_dma_state; - is_flushing = 0; -} - -static int dt_sendchar(char ch) -{ - if (!dt_wait_dma()) - return -1; - if (!(dt_stat & STAT_rr_char)) - return -2; - outb_p(DMA_single_in, speakup_info.port_tts + 4); - outb_p(ch, speakup_info.port_tts + 4); - dma_state ^= STAT_dma_state; - return 0; -} - -static int testkernel(void) -{ - int status = 0; - - if (dt_getstatus() == 0xffff) { - status = -1; - goto oops; - } - dt_sendcmd(CMD_sync); - if (!dt_waitbit(STAT_cmd_ready)) - status = -2; - else if (dt_stat & 0x8000) - return 0; - else if (dt_stat == 0x0dec) - pr_warn("dec_pc at 0x%x, software not loaded\n", - speakup_info.port_tts); - status = -3; -oops: synth_release_region(speakup_info.port_tts, SYNTH_IO_EXTENT); - speakup_info.port_tts = 0; - return status; -} - -static void do_catch_up(struct spk_synth *synth) -{ - u_char ch; - static u_char last; - unsigned long flags; - unsigned long jiff_max; - struct var_t *jiffy_delta; - struct var_t *delay_time; - int jiffy_delta_val; - int delay_time_val; - - jiffy_delta = spk_get_var(JIFFY); - delay_time = spk_get_var(DELAY); - spin_lock_irqsave(&speakup_info.spinlock, flags); - jiffy_delta_val = jiffy_delta->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - jiff_max = jiffies + jiffy_delta_val; - - while (!kthread_should_stop()) { - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (speakup_info.flushing) { - speakup_info.flushing = 0; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - synth->flush(synth); - continue; - } - synth_buffer_skip_nonlatin1(); - if (synth_buffer_empty()) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - break; - } - ch = synth_buffer_peek(); - set_current_state(TASK_INTERRUPTIBLE); - delay_time_val = delay_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (ch == '\n') - ch = 0x0D; - if (dt_sendchar(ch)) { - schedule_timeout(msecs_to_jiffies(delay_time_val)); - continue; - } - set_current_state(TASK_RUNNING); - spin_lock_irqsave(&speakup_info.spinlock, flags); - synth_buffer_getc(); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (ch == '[') { - in_escape = 1; - } else if (ch == ']') { - in_escape = 0; - } else if (ch <= SPACE) { - if (!in_escape && strchr(",.!?;:", last)) - dt_sendchar(PROCSPEECH); - if (time_after_eq(jiffies, jiff_max)) { - if (!in_escape) - dt_sendchar(PROCSPEECH); - spin_lock_irqsave(&speakup_info.spinlock, - flags); - jiffy_delta_val = jiffy_delta->u.n.value; - delay_time_val = delay_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, - flags); - schedule_timeout(msecs_to_jiffies - (delay_time_val)); - jiff_max = jiffies + jiffy_delta_val; - } - } - last = ch; - ch = 0; - } - if (!in_escape) - dt_sendchar(PROCSPEECH); -} - -static const char *synth_immediate(struct spk_synth *synth, const char *buf) -{ - u_char ch; - - while ((ch = *buf)) { - if (ch == '\n') - ch = PROCSPEECH; - if (dt_sendchar(ch)) - return buf; - buf++; - } - return NULL; -} - -static int synth_probe(struct spk_synth *synth) -{ - int i = 0, failed = 0; - - pr_info("Probing for %s.\n", synth->long_name); - for (i = 0; synth_portlist[i]; i++) { - if (synth_request_region(synth_portlist[i], SYNTH_IO_EXTENT)) { - pr_warn("request_region: failed with 0x%x, %d\n", - synth_portlist[i], SYNTH_IO_EXTENT); - continue; - } - speakup_info.port_tts = synth_portlist[i]; - failed = testkernel(); - if (failed == 0) - break; - } - if (failed) { - pr_info("%s: not found\n", synth->long_name); - return -ENODEV; - } - pr_info("%s: %03x-%03x, Driver Version %s,\n", synth->long_name, - speakup_info.port_tts, speakup_info.port_tts + 7, - synth->version); - synth->alive = 1; - return 0; -} - -static void dtpc_release(void) -{ - spk_stop_serial_interrupt(); - if (speakup_info.port_tts) - synth_release_region(speakup_info.port_tts, SYNTH_IO_EXTENT); - speakup_info.port_tts = 0; -} - -module_param_named(start, synth_dec_pc.startup, short, 0444); - -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_dec_pc); - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_AUTHOR("David Borowski"); -MODULE_DESCRIPTION("Speakup support for DECtalk PC synthesizers"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); diff --git a/drivers/staging/speakup/speakup_dectlk.c b/drivers/staging/speakup/speakup_dectlk.c deleted file mode 100644 index 780214b5ca16..000000000000 --- a/drivers/staging/speakup/speakup_dectlk.c +++ /dev/null @@ -1,311 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * originally written by: Kirk Reiser - * this version considerably modified by David Borowski, david575@rogers.com - * - * Copyright (C) 1998-99 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - * - * specificly written as a driver for the speakup screenreview - * s not a general device driver. - */ -#include -#include -#include -#include -#include -#include -#include -#include "speakup.h" -#include "spk_priv.h" - -#define DRV_VERSION "2.20" -#define SYNTH_CLEAR 0x03 -#define PROCSPEECH 0x0b -static int xoff; - -static inline int synth_full(void) -{ - return xoff; -} - -static void do_catch_up(struct spk_synth *synth); -static void synth_flush(struct spk_synth *synth); -static void read_buff_add(u_char c); -static unsigned char get_index(struct spk_synth *synth); - -static int in_escape; -static int is_flushing; - -static spinlock_t flush_lock; -static DECLARE_WAIT_QUEUE_HEAD(flush); - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"[:dv ap 160] " } }, - { CAPS_STOP, .u.s = {"[:dv ap 100 ] " } }, - { RATE, .u.n = {"[:ra %d] ", 180, 75, 650, 0, 0, NULL } }, - { INFLECTION, .u.n = {"[:dv pr %d] ", 100, 0, 10000, 0, 0, NULL } }, - { VOL, .u.n = {"[:dv g5 %d] ", 86, 60, 86, 0, 0, NULL } }, - { PUNCT, .u.n = {"[:pu %c] ", 0, 0, 2, 0, 0, "nsa" } }, - { VOICE, .u.n = {"[:n%c] ", 0, 0, 9, 0, 0, "phfdburwkv" } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* - * These attributes will appear in /sys/accessibility/speakup/dectlk. - */ -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute inflection_attribute = - __ATTR(inflection, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute punct_attribute = - __ATTR(punct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute voice_attribute = - __ATTR(voice, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &pitch_attribute.attr, - &inflection_attribute.attr, - &punct_attribute.attr, - &rate_attribute.attr, - &voice_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static int ap_defaults[] = {122, 89, 155, 110, 208, 240, 200, 106, 306}; -static int g5_defaults[] = {86, 81, 86, 84, 81, 80, 83, 83, 73}; - -static struct spk_synth synth_dectlk = { - .name = "dectlk", - .version = DRV_VERSION, - .long_name = "Dectalk Express", - .init = "[:error sp :name paul :rate 180 :tsr off] ", - .procspeech = PROCSPEECH, - .clear = SYNTH_CLEAR, - .delay = 500, - .trigger = 50, - .jiffies = 50, - .full = 40000, - .dev_name = SYNTH_DEFAULT_DEV, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .default_pitch = ap_defaults, - .default_vol = g5_defaults, - .io_ops = &spk_ttyio_ops, - .probe = spk_ttyio_synth_probe, - .release = spk_ttyio_release, - .synth_immediate = spk_ttyio_synth_immediate, - .catch_up = do_catch_up, - .flush = synth_flush, - .is_alive = spk_synth_is_alive_restart, - .synth_adjust = NULL, - .read_buff_add = read_buff_add, - .get_index = get_index, - .indexing = { - .command = "[:in re %d ] ", - .lowindex = 1, - .highindex = 8, - .currindex = 1, - }, - .attributes = { - .attrs = synth_attrs, - .name = "dectlk", - }, -}; - -static int is_indnum(u_char *ch) -{ - if ((*ch >= '0') && (*ch <= '9')) { - *ch = *ch - '0'; - return 1; - } - return 0; -} - -static u_char lastind; - -static unsigned char get_index(struct spk_synth *synth) -{ - u_char rv; - - rv = lastind; - lastind = 0; - return rv; -} - -static void read_buff_add(u_char c) -{ - static int ind = -1; - - if (c == 0x01) { - unsigned long flags; - - spin_lock_irqsave(&flush_lock, flags); - is_flushing = 0; - wake_up_interruptible(&flush); - spin_unlock_irqrestore(&flush_lock, flags); - } else if (c == 0x13) { - xoff = 1; - } else if (c == 0x11) { - xoff = 0; - } else if (is_indnum(&c)) { - if (ind == -1) - ind = c; - else - ind = ind * 10 + c; - } else if ((c > 31) && (c < 127)) { - if (ind != -1) - lastind = (u_char)ind; - ind = -1; - } -} - -static void do_catch_up(struct spk_synth *synth) -{ - int synth_full_val = 0; - static u_char ch; - static u_char last = '\0'; - unsigned long flags; - unsigned long jiff_max; - unsigned long timeout = msecs_to_jiffies(4000); - DEFINE_WAIT(wait); - struct var_t *jiffy_delta; - struct var_t *delay_time; - int jiffy_delta_val; - int delay_time_val; - - jiffy_delta = spk_get_var(JIFFY); - delay_time = spk_get_var(DELAY); - spin_lock_irqsave(&speakup_info.spinlock, flags); - jiffy_delta_val = jiffy_delta->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - jiff_max = jiffies + jiffy_delta_val; - - while (!kthread_should_stop()) { - /* if no ctl-a in 4, send data anyway */ - spin_lock_irqsave(&flush_lock, flags); - while (is_flushing && timeout) { - prepare_to_wait(&flush, &wait, TASK_INTERRUPTIBLE); - spin_unlock_irqrestore(&flush_lock, flags); - timeout = schedule_timeout(timeout); - spin_lock_irqsave(&flush_lock, flags); - } - finish_wait(&flush, &wait); - is_flushing = 0; - spin_unlock_irqrestore(&flush_lock, flags); - - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (speakup_info.flushing) { - speakup_info.flushing = 0; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - synth->flush(synth); - continue; - } - synth_buffer_skip_nonlatin1(); - if (synth_buffer_empty()) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - break; - } - ch = synth_buffer_peek(); - set_current_state(TASK_INTERRUPTIBLE); - delay_time_val = delay_time->u.n.value; - synth_full_val = synth_full(); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (ch == '\n') - ch = 0x0D; - if (synth_full_val || !synth->io_ops->synth_out(synth, ch)) { - schedule_timeout(msecs_to_jiffies(delay_time_val)); - continue; - } - set_current_state(TASK_RUNNING); - spin_lock_irqsave(&speakup_info.spinlock, flags); - synth_buffer_getc(); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (ch == '[') { - in_escape = 1; - } else if (ch == ']') { - in_escape = 0; - } else if (ch <= SPACE) { - if (!in_escape && strchr(",.!?;:", last)) - synth->io_ops->synth_out(synth, PROCSPEECH); - if (time_after_eq(jiffies, jiff_max)) { - if (!in_escape) - synth->io_ops->synth_out(synth, - PROCSPEECH); - spin_lock_irqsave(&speakup_info.spinlock, - flags); - jiffy_delta_val = jiffy_delta->u.n.value; - delay_time_val = delay_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, - flags); - schedule_timeout(msecs_to_jiffies - (delay_time_val)); - jiff_max = jiffies + jiffy_delta_val; - } - } - last = ch; - } - if (!in_escape) - synth->io_ops->synth_out(synth, PROCSPEECH); -} - -static void synth_flush(struct spk_synth *synth) -{ - if (in_escape) - /* if in command output ']' so we don't get an error */ - synth->io_ops->synth_out(synth, ']'); - in_escape = 0; - is_flushing = 1; - synth->io_ops->flush_buffer(); - synth->io_ops->synth_out(synth, SYNTH_CLEAR); -} - -module_param_named(ser, synth_dectlk.ser, int, 0444); -module_param_named(dev, synth_dectlk.dev_name, charp, 0444); -module_param_named(start, synth_dectlk.startup, short, 0444); - -MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); -MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_dectlk); - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_AUTHOR("David Borowski"); -MODULE_DESCRIPTION("Speakup support for DECtalk Express synthesizers"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/drivers/staging/speakup/speakup_dtlk.c b/drivers/staging/speakup/speakup_dtlk.c deleted file mode 100644 index dbebed0eeeec..000000000000 --- a/drivers/staging/speakup/speakup_dtlk.c +++ /dev/null @@ -1,390 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * originally written by: Kirk Reiser - * this version considerably modified by David Borowski, david575@rogers.com - * - * Copyright (C) 1998-99 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - * - * specificly written as a driver for the speakup screenreview - * package it's not a general device driver. - * This driver is for the RC Systems DoubleTalk PC internal synthesizer. - */ -#include -#include -#include -#include - -#include "spk_priv.h" -#include "serialio.h" -#include "speakup_dtlk.h" /* local header file for DoubleTalk values */ -#include "speakup.h" - -#define DRV_VERSION "2.10" -#define PROCSPEECH 0x00 - -static int synth_probe(struct spk_synth *synth); -static void dtlk_release(void); -static const char *synth_immediate(struct spk_synth *synth, const char *buf); -static void do_catch_up(struct spk_synth *synth); -static void synth_flush(struct spk_synth *synth); - -static int synth_lpc; -static int port_forced; -static unsigned int synth_portlist[] = { - 0x25e, 0x29e, 0x2de, 0x31e, 0x35e, 0x39e, 0 -}; - -static u_char synth_status; - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"\x01+35p" } }, - { CAPS_STOP, .u.s = {"\x01-35p" } }, - { RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL } }, - { PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL } }, - { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } }, - { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } }, - { PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL } }, - { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } }, - { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* - * These attributes will appear in /sys/accessibility/speakup/dtlk. - */ -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute freq_attribute = - __ATTR(freq, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute punct_attribute = - __ATTR(punct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute tone_attribute = - __ATTR(tone, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute voice_attribute = - __ATTR(voice, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &freq_attribute.attr, - &pitch_attribute.attr, - &punct_attribute.attr, - &rate_attribute.attr, - &tone_attribute.attr, - &voice_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_dtlk = { - .name = "dtlk", - .version = DRV_VERSION, - .long_name = "DoubleTalk PC", - .init = "\x01@\x01\x31y", - .procspeech = PROCSPEECH, - .clear = SYNTH_CLEAR, - .delay = 500, - .trigger = 30, - .jiffies = 50, - .full = 1000, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = &spk_serial_io_ops, - .probe = synth_probe, - .release = dtlk_release, - .synth_immediate = synth_immediate, - .catch_up = do_catch_up, - .flush = synth_flush, - .is_alive = spk_synth_is_alive_nop, - .synth_adjust = NULL, - .read_buff_add = NULL, - .get_index = spk_synth_get_index, - .indexing = { - .command = "\x01%di", - .lowindex = 1, - .highindex = 5, - .currindex = 1, - }, - .attributes = { - .attrs = synth_attrs, - .name = "dtlk", - }, -}; - -static inline bool synth_readable(void) -{ - synth_status = inb_p(speakup_info.port_tts + UART_RX); - return (synth_status & TTS_READABLE) != 0; -} - -static inline bool synth_writable(void) -{ - synth_status = inb_p(speakup_info.port_tts + UART_RX); - return (synth_status & TTS_WRITABLE) != 0; -} - -static inline bool synth_full(void) -{ - synth_status = inb_p(speakup_info.port_tts + UART_RX); - return (synth_status & TTS_ALMOST_FULL) != 0; -} - -static void spk_out(const char ch) -{ - int timeout = SPK_XMITR_TIMEOUT; - - while (!synth_writable()) { - if (!--timeout) - break; - udelay(1); - } - outb_p(ch, speakup_info.port_tts); - timeout = SPK_XMITR_TIMEOUT; - while (synth_writable()) { - if (!--timeout) - break; - udelay(1); - } -} - -static void do_catch_up(struct spk_synth *synth) -{ - u_char ch; - unsigned long flags; - unsigned long jiff_max; - struct var_t *jiffy_delta; - struct var_t *delay_time; - int jiffy_delta_val; - int delay_time_val; - - jiffy_delta = spk_get_var(JIFFY); - delay_time = spk_get_var(DELAY); - spin_lock_irqsave(&speakup_info.spinlock, flags); - jiffy_delta_val = jiffy_delta->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - jiff_max = jiffies + jiffy_delta_val; - while (!kthread_should_stop()) { - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (speakup_info.flushing) { - speakup_info.flushing = 0; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - synth->flush(synth); - continue; - } - synth_buffer_skip_nonlatin1(); - if (synth_buffer_empty()) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - break; - } - set_current_state(TASK_INTERRUPTIBLE); - delay_time_val = delay_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (synth_full()) { - schedule_timeout(msecs_to_jiffies(delay_time_val)); - continue; - } - set_current_state(TASK_RUNNING); - spin_lock_irqsave(&speakup_info.spinlock, flags); - ch = synth_buffer_getc(); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (ch == '\n') - ch = PROCSPEECH; - spk_out(ch); - if (time_after_eq(jiffies, jiff_max) && (ch == SPACE)) { - spk_out(PROCSPEECH); - spin_lock_irqsave(&speakup_info.spinlock, flags); - delay_time_val = delay_time->u.n.value; - jiffy_delta_val = jiffy_delta->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - schedule_timeout(msecs_to_jiffies(delay_time_val)); - jiff_max = jiffies + jiffy_delta_val; - } - } - spk_out(PROCSPEECH); -} - -static const char *synth_immediate(struct spk_synth *synth, const char *buf) -{ - u_char ch; - - while ((ch = (u_char)*buf)) { - if (synth_full()) - return buf; - if (ch == '\n') - ch = PROCSPEECH; - spk_out(ch); - buf++; - } - return NULL; -} - -static void synth_flush(struct spk_synth *synth) -{ - outb_p(SYNTH_CLEAR, speakup_info.port_tts); - while (synth_writable()) - cpu_relax(); -} - -static char synth_read_tts(void) -{ - u_char ch; - - while (!synth_readable()) - cpu_relax(); - ch = synth_status & 0x7f; - outb_p(ch, speakup_info.port_tts); - while (synth_readable()) - cpu_relax(); - return (char)ch; -} - -/* interrogate the DoubleTalk PC and return its settings */ -static struct synth_settings *synth_interrogate(struct spk_synth *synth) -{ - u_char *t; - static char buf[sizeof(struct synth_settings) + 1]; - int total, i; - static struct synth_settings status; - - synth_immediate(synth, "\x18\x01?"); - for (total = 0, i = 0; i < 50; i++) { - buf[total] = synth_read_tts(); - if (total > 2 && buf[total] == 0x7f) - break; - if (total < sizeof(struct synth_settings)) - total++; - } - t = buf; - /* serial number is little endian */ - status.serial_number = t[0] + t[1] * 256; - t += 2; - for (i = 0; *t != '\r'; t++) { - status.rom_version[i] = *t; - if (i < sizeof(status.rom_version) - 1) - i++; - } - status.rom_version[i] = 0; - t++; - status.mode = *t++; - status.punc_level = *t++; - status.formant_freq = *t++; - status.pitch = *t++; - status.speed = *t++; - status.volume = *t++; - status.tone = *t++; - status.expression = *t++; - status.ext_dict_loaded = *t++; - status.ext_dict_status = *t++; - status.free_ram = *t++; - status.articulation = *t++; - status.reverb = *t++; - status.eob = *t++; - return &status; -} - -static int synth_probe(struct spk_synth *synth) -{ - unsigned int port_val = 0; - int i = 0; - struct synth_settings *sp; - - pr_info("Probing for DoubleTalk.\n"); - if (port_forced) { - speakup_info.port_tts = port_forced; - pr_info("probe forced to %x by kernel command line\n", - speakup_info.port_tts); - if ((port_forced & 0xf) != 0xf) - pr_info("warning: port base should probably end with f\n"); - if (synth_request_region(speakup_info.port_tts - 1, - SYNTH_IO_EXTENT)) { - pr_warn("sorry, port already reserved\n"); - return -EBUSY; - } - port_val = inw(speakup_info.port_tts - 1); - synth_lpc = speakup_info.port_tts - 1; - } else { - for (i = 0; synth_portlist[i]; i++) { - if (synth_request_region(synth_portlist[i], - SYNTH_IO_EXTENT)) - continue; - port_val = inw(synth_portlist[i]) & 0xfbff; - if (port_val == 0x107f) { - synth_lpc = synth_portlist[i]; - speakup_info.port_tts = synth_lpc + 1; - break; - } - synth_release_region(synth_portlist[i], - SYNTH_IO_EXTENT); - } - } - port_val &= 0xfbff; - if (port_val != 0x107f) { - pr_info("DoubleTalk PC: not found\n"); - if (synth_lpc) - synth_release_region(synth_lpc, SYNTH_IO_EXTENT); - return -ENODEV; - } - while (inw_p(synth_lpc) != 0x147f) - cpu_relax(); /* wait until it's ready */ - sp = synth_interrogate(synth); - pr_info("%s: %03x-%03x, ROM ver %s, s/n %u, driver: %s\n", - synth->long_name, synth_lpc, synth_lpc + SYNTH_IO_EXTENT - 1, - sp->rom_version, sp->serial_number, synth->version); - synth->alive = 1; - return 0; -} - -static void dtlk_release(void) -{ - spk_stop_serial_interrupt(); - if (speakup_info.port_tts) - synth_release_region(speakup_info.port_tts - 1, - SYNTH_IO_EXTENT); - speakup_info.port_tts = 0; -} - -module_param_hw_named(port, port_forced, int, ioport, 0444); -module_param_named(start, synth_dtlk.startup, short, 0444); - -MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing)."); -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_dtlk); - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_AUTHOR("David Borowski"); -MODULE_DESCRIPTION("Speakup support for DoubleTalk PC synthesizers"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/drivers/staging/speakup/speakup_dtlk.h b/drivers/staging/speakup/speakup_dtlk.h deleted file mode 100644 index 9c378b58066e..000000000000 --- a/drivers/staging/speakup/speakup_dtlk.h +++ /dev/null @@ -1,63 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* speakup_dtlk.h - header file for speakups DoubleTalk driver. */ - -#define SYNTH_IO_EXTENT 0x02 -#define SYNTH_CLEAR 0x18 /* stops speech */ - /* TTS Port Status Flags */ -#define TTS_READABLE 0x80 /* mask for bit which is nonzero if a - * byte can be read from the TTS port - */ -#define TTS_SPEAKING 0x40 /* mask for SYNC bit, which is nonzero - * while DoubleTalk is producing - * output with TTS, PCM or CVSD - * synthesizers or tone generators - * (that is, all but LPC) - */ -#define TTS_SPEAKING2 0x20 /* mask for SYNC2 bit, - * which falls to zero up to 0.4 sec - * before speech stops - */ -#define TTS_WRITABLE 0x10 /* mask for RDY bit, which when set to - * 1, indicates the TTS port is ready - * to accept a byte of data. The RDY - * bit goes zero 2-3 usec after - * writing, and goes 1 again 180-190 - * usec later. - */ -#define TTS_ALMOST_FULL 0x08 /* mask for AF bit: When set to 1, - * indicates that less than 300 bytes - * are available in the TTS input - * buffer. AF is always 0 in the PCM, - * TGN and CVSD modes. - */ -#define TTS_ALMOST_EMPTY 0x04 /* mask for AE bit: When set to 1, - * indicates that less than 300 bytes - * are remaining in DoubleTalk's input - * (TTS or PCM) buffer. AE is always 1 - * in the TGN and CVSD modes. - */ - - /* data returned by Interrogate command */ -struct synth_settings { - u_short serial_number; /* 0-7Fh:0-7Fh */ - u_char rom_version[24]; /* null terminated string */ - u_char mode; /* 0=Character; 1=Phoneme; 2=Text */ - u_char punc_level; /* nB; 0-7 */ - u_char formant_freq; /* nF; 0-9 */ - u_char pitch; /* nP; 0-99 */ - u_char speed; /* nS; 0-9 */ - u_char volume; /* nV; 0-9 */ - u_char tone; /* nX; 0-2 */ - u_char expression; /* nE; 0-9 */ - u_char ext_dict_loaded; /* 1=exception dictionary loaded */ - u_char ext_dict_status; /* 1=exception dictionary enabled */ - u_char free_ram; /* # pages (truncated) remaining for - * text buffer - */ - u_char articulation; /* nA; 0-9 */ - u_char reverb; /* nR; 0-9 */ - u_char eob; /* 7Fh value indicating end of - * parameter block - */ - u_char has_indexing; /* nonzero if indexing is implemented */ -}; diff --git a/drivers/staging/speakup/speakup_dummy.c b/drivers/staging/speakup/speakup_dummy.c deleted file mode 100644 index e393438af81b..000000000000 --- a/drivers/staging/speakup/speakup_dummy.c +++ /dev/null @@ -1,134 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * originally written by: Kirk Reiser - * this version considerably modified by David Borowski, david575@rogers.com - * eventually modified by Samuel Thibault - * - * Copyright (C) 1998-99 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - * Copyright (C) 2007 Samuel Thibault. - * - * specificly written as a driver for the speakup screenreview - * s not a general device driver. - */ -#include "spk_priv.h" -#include "speakup.h" - -#define PROCSPEECH '\n' -#define DRV_VERSION "2.11" -#define SYNTH_CLEAR '!' - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"CAPS_START\n" } }, - { CAPS_STOP, .u.s = {"CAPS_STOP\n" } }, - { PAUSE, .u.s = {"PAUSE\n"} }, - { RATE, .u.n = {"RATE %d\n", 8, 1, 16, 0, 0, NULL } }, - { PITCH, .u.n = {"PITCH %d\n", 8, 0, 16, 0, 0, NULL } }, - { INFLECTION, .u.n = {"INFLECTION %d\n", 8, 0, 16, 0, 0, NULL } }, - { VOL, .u.n = {"VOL %d\n", 8, 0, 16, 0, 0, NULL } }, - { TONE, .u.n = {"TONE %d\n", 8, 0, 16, 0, 0, NULL } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* - * These attributes will appear in /sys/accessibility/speakup/dummy. - */ -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute inflection_attribute = - __ATTR(inflection, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute tone_attribute = - __ATTR(tone, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &pitch_attribute.attr, - &inflection_attribute.attr, - &rate_attribute.attr, - &tone_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_dummy = { - .name = "dummy", - .version = DRV_VERSION, - .long_name = "Dummy", - .init = "Speakup\n", - .procspeech = PROCSPEECH, - .clear = SYNTH_CLEAR, - .delay = 500, - .trigger = 50, - .jiffies = 50, - .full = 40000, - .dev_name = SYNTH_DEFAULT_DEV, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = &spk_ttyio_ops, - .probe = spk_ttyio_synth_probe, - .release = spk_ttyio_release, - .synth_immediate = spk_ttyio_synth_immediate, - .catch_up = spk_do_catch_up_unicode, - .flush = spk_synth_flush, - .is_alive = spk_synth_is_alive_restart, - .synth_adjust = NULL, - .read_buff_add = NULL, - .get_index = NULL, - .indexing = { - .command = NULL, - .lowindex = 0, - .highindex = 0, - .currindex = 0, - }, - .attributes = { - .attrs = synth_attrs, - .name = "dummy", - }, -}; - -module_param_named(ser, synth_dummy.ser, int, 0444); -module_param_named(dev, synth_dummy.dev_name, charp, 0444); -module_param_named(start, synth_dummy.startup, short, 0444); - -MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); -MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_dummy); - -MODULE_AUTHOR("Samuel Thibault "); -MODULE_DESCRIPTION("Speakup support for text console"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/drivers/staging/speakup/speakup_keypc.c b/drivers/staging/speakup/speakup_keypc.c deleted file mode 100644 index 414827e888fc..000000000000 --- a/drivers/staging/speakup/speakup_keypc.c +++ /dev/null @@ -1,318 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * written by David Borowski - * - * Copyright (C) 2003 David Borowski. - * - * specificly written as a driver for the speakup screenreview - * package it's not a general device driver. - * This driver is for the Keynote Gold internal synthesizer. - */ -#include -#include -#include -#include -#include - -#include "spk_priv.h" -#include "speakup.h" - -#define DRV_VERSION "2.10" -#define SYNTH_IO_EXTENT 0x04 -#define SWAIT udelay(70) -#define PROCSPEECH 0x1f -#define SYNTH_CLEAR 0x03 - -static int synth_probe(struct spk_synth *synth); -static void keynote_release(void); -static const char *synth_immediate(struct spk_synth *synth, const char *buf); -static void do_catch_up(struct spk_synth *synth); -static void synth_flush(struct spk_synth *synth); - -static int synth_port; -static int port_forced; -static unsigned int synth_portlist[] = { 0x2a8, 0 }; - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"[f130]" } }, - { CAPS_STOP, .u.s = {"[f90]" } }, - { RATE, .u.n = {"\04%c ", 8, 0, 10, 81, -8, NULL } }, - { PITCH, .u.n = {"[f%d]", 5, 0, 9, 40, 10, NULL } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* - * These attributes will appear in /sys/accessibility/speakup/keypc. - */ -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &pitch_attribute.attr, - &rate_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_keypc = { - .name = "keypc", - .version = DRV_VERSION, - .long_name = "Keynote PC", - .init = "[t][n7,1][n8,0]", - .procspeech = PROCSPEECH, - .clear = SYNTH_CLEAR, - .delay = 500, - .trigger = 50, - .jiffies = 50, - .full = 1000, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = &spk_serial_io_ops, - .probe = synth_probe, - .release = keynote_release, - .synth_immediate = synth_immediate, - .catch_up = do_catch_up, - .flush = synth_flush, - .is_alive = spk_synth_is_alive_nop, - .synth_adjust = NULL, - .read_buff_add = NULL, - .get_index = NULL, - .indexing = { - .command = NULL, - .lowindex = 0, - .highindex = 0, - .currindex = 0, - }, - .attributes = { - .attrs = synth_attrs, - .name = "keypc", - }, -}; - -static inline bool synth_writable(void) -{ - return (inb_p(synth_port + UART_RX) & 0x10) != 0; -} - -static inline bool synth_full(void) -{ - return (inb_p(synth_port + UART_RX) & 0x80) == 0; -} - -static char *oops(void) -{ - int s1, s2, s3, s4; - - s1 = inb_p(synth_port); - s2 = inb_p(synth_port + 1); - s3 = inb_p(synth_port + 2); - s4 = inb_p(synth_port + 3); - pr_warn("synth timeout %d %d %d %d\n", s1, s2, s3, s4); - return NULL; -} - -static const char *synth_immediate(struct spk_synth *synth, const char *buf) -{ - u_char ch; - int timeout; - - while ((ch = *buf)) { - if (ch == '\n') - ch = PROCSPEECH; - if (synth_full()) - return buf; - timeout = 1000; - while (synth_writable()) - if (--timeout <= 0) - return oops(); - outb_p(ch, synth_port); - udelay(70); - buf++; - } - return NULL; -} - -static void do_catch_up(struct spk_synth *synth) -{ - u_char ch; - int timeout; - unsigned long flags; - unsigned long jiff_max; - struct var_t *jiffy_delta; - struct var_t *delay_time; - struct var_t *full_time; - int delay_time_val; - int full_time_val; - int jiffy_delta_val; - - jiffy_delta = spk_get_var(JIFFY); - delay_time = spk_get_var(DELAY); - full_time = spk_get_var(FULL); - spin_lock_irqsave(&speakup_info.spinlock, flags); - jiffy_delta_val = jiffy_delta->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - - jiff_max = jiffies + jiffy_delta_val; - while (!kthread_should_stop()) { - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (speakup_info.flushing) { - speakup_info.flushing = 0; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - synth->flush(synth); - continue; - } - synth_buffer_skip_nonlatin1(); - if (synth_buffer_empty()) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - break; - } - set_current_state(TASK_INTERRUPTIBLE); - full_time_val = full_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (synth_full()) { - schedule_timeout(msecs_to_jiffies(full_time_val)); - continue; - } - set_current_state(TASK_RUNNING); - timeout = 1000; - while (synth_writable()) - if (--timeout <= 0) - break; - if (timeout <= 0) { - oops(); - break; - } - spin_lock_irqsave(&speakup_info.spinlock, flags); - ch = synth_buffer_getc(); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (ch == '\n') - ch = PROCSPEECH; - outb_p(ch, synth_port); - SWAIT; - if (time_after_eq(jiffies, jiff_max) && (ch == SPACE)) { - timeout = 1000; - while (synth_writable()) - if (--timeout <= 0) - break; - if (timeout <= 0) { - oops(); - break; - } - outb_p(PROCSPEECH, synth_port); - spin_lock_irqsave(&speakup_info.spinlock, flags); - jiffy_delta_val = jiffy_delta->u.n.value; - delay_time_val = delay_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - schedule_timeout(msecs_to_jiffies(delay_time_val)); - jiff_max = jiffies + jiffy_delta_val; - } - } - timeout = 1000; - while (synth_writable()) - if (--timeout <= 0) - break; - if (timeout <= 0) - oops(); - else - outb_p(PROCSPEECH, synth_port); -} - -static void synth_flush(struct spk_synth *synth) -{ - outb_p(SYNTH_CLEAR, synth_port); -} - -static int synth_probe(struct spk_synth *synth) -{ - unsigned int port_val = 0; - int i = 0; - - pr_info("Probing for %s.\n", synth->long_name); - if (port_forced) { - synth_port = port_forced; - pr_info("probe forced to %x by kernel command line\n", - synth_port); - if (synth_request_region(synth_port - 1, SYNTH_IO_EXTENT)) { - pr_warn("sorry, port already reserved\n"); - return -EBUSY; - } - port_val = inb(synth_port); - } else { - for (i = 0; synth_portlist[i]; i++) { - if (synth_request_region(synth_portlist[i], - SYNTH_IO_EXTENT)) { - pr_warn - ("request_region: failed with 0x%x, %d\n", - synth_portlist[i], SYNTH_IO_EXTENT); - continue; - } - port_val = inb(synth_portlist[i]); - if (port_val == 0x80) { - synth_port = synth_portlist[i]; - break; - } - } - } - if (port_val != 0x80) { - pr_info("%s: not found\n", synth->long_name); - synth_release_region(synth_port, SYNTH_IO_EXTENT); - synth_port = 0; - return -ENODEV; - } - pr_info("%s: %03x-%03x, driver version %s,\n", synth->long_name, - synth_port, synth_port + SYNTH_IO_EXTENT - 1, - synth->version); - synth->alive = 1; - return 0; -} - -static void keynote_release(void) -{ - spk_stop_serial_interrupt(); - if (synth_port) - synth_release_region(synth_port, SYNTH_IO_EXTENT); - synth_port = 0; -} - -module_param_hw_named(port, port_forced, int, ioport, 0444); -module_param_named(start, synth_keypc.startup, short, 0444); - -MODULE_PARM_DESC(port, "Set the port for the synthesizer (override probing)."); -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_keypc); - -MODULE_AUTHOR("David Borowski"); -MODULE_DESCRIPTION("Speakup support for Keynote Gold PC synthesizers"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/drivers/staging/speakup/speakup_ltlk.c b/drivers/staging/speakup/speakup_ltlk.c deleted file mode 100644 index 3c59519a871f..000000000000 --- a/drivers/staging/speakup/speakup_ltlk.c +++ /dev/null @@ -1,175 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * originally written by: Kirk Reiser - * this version considerably modified by David Borowski, david575@rogers.com - * - * Copyright (C) 1998-99 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - * - * specificly written as a driver for the speakup screenreview - * s not a general device driver. - */ -#include "speakup.h" -#include "spk_priv.h" -#include "speakup_dtlk.h" /* local header file for LiteTalk values */ - -#define DRV_VERSION "2.11" -#define PROCSPEECH 0x0d - -static int synth_probe(struct spk_synth *synth); - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"\x01+35p" } }, - { CAPS_STOP, .u.s = {"\x01-35p" } }, - { RATE, .u.n = {"\x01%ds", 8, 0, 9, 0, 0, NULL } }, - { PITCH, .u.n = {"\x01%dp", 50, 0, 99, 0, 0, NULL } }, - { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } }, - { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } }, - { PUNCT, .u.n = {"\x01%db", 7, 0, 15, 0, 0, NULL } }, - { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } }, - { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* - * These attributes will appear in /sys/accessibility/speakup/ltlk. - */ -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute freq_attribute = - __ATTR(freq, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute punct_attribute = - __ATTR(punct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute tone_attribute = - __ATTR(tone, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute voice_attribute = - __ATTR(voice, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &freq_attribute.attr, - &pitch_attribute.attr, - &punct_attribute.attr, - &rate_attribute.attr, - &tone_attribute.attr, - &voice_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_ltlk = { - .name = "ltlk", - .version = DRV_VERSION, - .long_name = "LiteTalk", - .init = "\01@\x01\x31y\n\0", - .procspeech = PROCSPEECH, - .clear = SYNTH_CLEAR, - .delay = 500, - .trigger = 50, - .jiffies = 50, - .full = 40000, - .dev_name = SYNTH_DEFAULT_DEV, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = &spk_ttyio_ops, - .probe = synth_probe, - .release = spk_ttyio_release, - .synth_immediate = spk_ttyio_synth_immediate, - .catch_up = spk_do_catch_up, - .flush = spk_synth_flush, - .is_alive = spk_synth_is_alive_restart, - .synth_adjust = NULL, - .read_buff_add = NULL, - .get_index = spk_synth_get_index, - .indexing = { - .command = "\x01%di", - .lowindex = 1, - .highindex = 5, - .currindex = 1, - }, - .attributes = { - .attrs = synth_attrs, - .name = "ltlk", - }, -}; - -/* interrogate the LiteTalk and print its settings */ -static void synth_interrogate(struct spk_synth *synth) -{ - unsigned char *t, i; - unsigned char buf[50], rom_v[20]; - - synth->synth_immediate(synth, "\x18\x01?"); - for (i = 0; i < 50; i++) { - buf[i] = synth->io_ops->synth_in(); - if (i > 2 && buf[i] == 0x7f) - break; - } - t = buf + 2; - for (i = 0; *t != '\r'; t++) { - rom_v[i] = *t; - if (++i >= 19) - break; - } - rom_v[i] = 0; - pr_info("%s: ROM version: %s\n", synth->long_name, rom_v); -} - -static int synth_probe(struct spk_synth *synth) -{ - int failed = 0; - - failed = spk_ttyio_synth_probe(synth); - if (failed == 0) - synth_interrogate(synth); - synth->alive = !failed; - return failed; -} - -module_param_named(ser, synth_ltlk.ser, int, 0444); -module_param_named(dev, synth_ltlk.dev_name, charp, 0444); -module_param_named(start, synth_ltlk.startup, short, 0444); - -MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); -MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_ltlk); - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_AUTHOR("David Borowski"); -MODULE_DESCRIPTION("Speakup support for DoubleTalk LT/LiteTalk synthesizers"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/drivers/staging/speakup/speakup_soft.c b/drivers/staging/speakup/speakup_soft.c deleted file mode 100644 index 9a7029539f35..000000000000 --- a/drivers/staging/speakup/speakup_soft.c +++ /dev/null @@ -1,430 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* speakup_soft.c - speakup driver to register and make available - * a user space device for software synthesizers. written by: Kirk - * Reiser - * - * Copyright (C) 2003 Kirk Reiser. - * - * this code is specificly written as a driver for the speakup screenreview - * package and is not a general device driver. - */ - -#include -#include /* for misc_register, and MISC_DYNAMIC_MINOR */ -#include /* for poll_wait() */ - -/* schedule(), signal_pending(), TASK_INTERRUPTIBLE */ -#include - -#include "spk_priv.h" -#include "speakup.h" - -#define DRV_VERSION "2.6" -#define PROCSPEECH 0x0d -#define CLEAR_SYNTH 0x18 - -static int softsynth_probe(struct spk_synth *synth); -static void softsynth_release(void); -static int softsynth_is_alive(struct spk_synth *synth); -static unsigned char get_index(struct spk_synth *synth); - -static struct miscdevice synth_device, synthu_device; -static int init_pos; -static int misc_registered; - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"\x01+3p" } }, - { CAPS_STOP, .u.s = {"\x01-3p" } }, - { PAUSE, .u.n = {"\x01P" } }, - { RATE, .u.n = {"\x01%ds", 2, 0, 9, 0, 0, NULL } }, - { PITCH, .u.n = {"\x01%dp", 5, 0, 9, 0, 0, NULL } }, - { INFLECTION, .u.n = {"\x01%dr", 5, 0, 9, 0, 0, NULL } }, - { VOL, .u.n = {"\x01%dv", 5, 0, 9, 0, 0, NULL } }, - { TONE, .u.n = {"\x01%dx", 1, 0, 2, 0, 0, NULL } }, - { PUNCT, .u.n = {"\x01%db", 0, 0, 2, 0, 0, NULL } }, - { VOICE, .u.n = {"\x01%do", 0, 0, 7, 0, 0, NULL } }, - { FREQUENCY, .u.n = {"\x01%df", 5, 0, 9, 0, 0, NULL } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* These attributes will appear in /sys/accessibility/speakup/soft. */ - -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute freq_attribute = - __ATTR(freq, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute inflection_attribute = - __ATTR(inflection, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute punct_attribute = - __ATTR(punct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute tone_attribute = - __ATTR(tone, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute voice_attribute = - __ATTR(voice, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -/* - * We should uncomment the following definition, when we agree on a - * method of passing a language designation to the software synthesizer. - * static struct kobj_attribute lang_attribute = - * __ATTR(lang, 0644, spk_var_show, spk_var_store); - */ - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &freq_attribute.attr, -/* &lang_attribute.attr, */ - &pitch_attribute.attr, - &inflection_attribute.attr, - &punct_attribute.attr, - &rate_attribute.attr, - &tone_attribute.attr, - &voice_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_soft = { - .name = "soft", - .version = DRV_VERSION, - .long_name = "software synth", - .init = "\01@\x01\x31y\n", - .procspeech = PROCSPEECH, - .delay = 0, - .trigger = 0, - .jiffies = 0, - .full = 0, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = NULL, - .probe = softsynth_probe, - .release = softsynth_release, - .synth_immediate = NULL, - .catch_up = NULL, - .flush = NULL, - .is_alive = softsynth_is_alive, - .synth_adjust = NULL, - .read_buff_add = NULL, - .get_index = get_index, - .indexing = { - .command = "\x01%di", - .lowindex = 1, - .highindex = 5, - .currindex = 1, - }, - .attributes = { - .attrs = synth_attrs, - .name = "soft", - }, -}; - -static char *get_initstring(void) -{ - static char buf[40]; - char *cp; - struct var_t *var; - - memset(buf, 0, sizeof(buf)); - cp = buf; - var = synth_soft.vars; - while (var->var_id != MAXVARS) { - if (var->var_id != CAPS_START && var->var_id != CAPS_STOP && - var->var_id != PAUSE && var->var_id != DIRECT) - cp = cp + sprintf(cp, var->u.n.synth_fmt, - var->u.n.value); - var++; - } - cp = cp + sprintf(cp, "\n"); - return buf; -} - -static int softsynth_open(struct inode *inode, struct file *fp) -{ - unsigned long flags; - /*if ((fp->f_flags & O_ACCMODE) != O_RDONLY) */ - /* return -EPERM; */ - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (synth_soft.alive) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return -EBUSY; - } - synth_soft.alive = 1; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return 0; -} - -static int softsynth_close(struct inode *inode, struct file *fp) -{ - unsigned long flags; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - synth_soft.alive = 0; - init_pos = 0; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - /* Make sure we let applications go before leaving */ - speakup_start_ttys(); - return 0; -} - -static ssize_t softsynthx_read(struct file *fp, char __user *buf, size_t count, - loff_t *pos, int unicode) -{ - int chars_sent = 0; - char __user *cp; - char *init; - size_t bytes_per_ch = unicode ? 3 : 1; - u16 ch; - int empty; - unsigned long flags; - DEFINE_WAIT(wait); - - if (count < bytes_per_ch) - return -EINVAL; - - spin_lock_irqsave(&speakup_info.spinlock, flags); - synth_soft.alive = 1; - while (1) { - prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE); - if (synth_current() == &synth_soft) { - if (!unicode) - synth_buffer_skip_nonlatin1(); - if (!synth_buffer_empty() || speakup_info.flushing) - break; - } - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (fp->f_flags & O_NONBLOCK) { - finish_wait(&speakup_event, &wait); - return -EAGAIN; - } - if (signal_pending(current)) { - finish_wait(&speakup_event, &wait); - return -ERESTARTSYS; - } - schedule(); - spin_lock_irqsave(&speakup_info.spinlock, flags); - } - finish_wait(&speakup_event, &wait); - - cp = buf; - init = get_initstring(); - - /* Keep 3 bytes available for a 16bit UTF-8-encoded character */ - while (chars_sent <= count - bytes_per_ch) { - if (synth_current() != &synth_soft) - break; - if (speakup_info.flushing) { - speakup_info.flushing = 0; - ch = '\x18'; - } else if (init[init_pos]) { - ch = init[init_pos++]; - } else { - if (!unicode) - synth_buffer_skip_nonlatin1(); - if (synth_buffer_empty()) - break; - ch = synth_buffer_getc(); - } - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - - if ((!unicode && ch < 0x100) || (unicode && ch < 0x80)) { - u_char c = ch; - - if (copy_to_user(cp, &c, 1)) - return -EFAULT; - - chars_sent++; - cp++; - } else if (unicode && ch < 0x800) { - u_char s[2] = { - 0xc0 | (ch >> 6), - 0x80 | (ch & 0x3f) - }; - - if (copy_to_user(cp, s, sizeof(s))) - return -EFAULT; - - chars_sent += sizeof(s); - cp += sizeof(s); - } else if (unicode) { - u_char s[3] = { - 0xe0 | (ch >> 12), - 0x80 | ((ch >> 6) & 0x3f), - 0x80 | (ch & 0x3f) - }; - - if (copy_to_user(cp, s, sizeof(s))) - return -EFAULT; - - chars_sent += sizeof(s); - cp += sizeof(s); - } - - spin_lock_irqsave(&speakup_info.spinlock, flags); - } - *pos += chars_sent; - empty = synth_buffer_empty(); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (empty) { - speakup_start_ttys(); - *pos = 0; - } - return chars_sent; -} - -static ssize_t softsynth_read(struct file *fp, char __user *buf, size_t count, - loff_t *pos) -{ - return softsynthx_read(fp, buf, count, pos, 0); -} - -static ssize_t softsynthu_read(struct file *fp, char __user *buf, size_t count, - loff_t *pos) -{ - return softsynthx_read(fp, buf, count, pos, 1); -} - -static int last_index; - -static ssize_t softsynth_write(struct file *fp, const char __user *buf, - size_t count, loff_t *pos) -{ - unsigned long supplied_index = 0; - int converted; - - converted = kstrtoul_from_user(buf, count, 0, &supplied_index); - - if (converted < 0) - return converted; - - last_index = supplied_index; - return count; -} - -static __poll_t softsynth_poll(struct file *fp, struct poll_table_struct *wait) -{ - unsigned long flags; - __poll_t ret = 0; - - poll_wait(fp, &speakup_event, wait); - - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (synth_current() == &synth_soft && - (!synth_buffer_empty() || speakup_info.flushing)) - ret = EPOLLIN | EPOLLRDNORM; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - return ret; -} - -static unsigned char get_index(struct spk_synth *synth) -{ - int rv; - - rv = last_index; - last_index = 0; - return rv; -} - -static const struct file_operations softsynth_fops = { - .owner = THIS_MODULE, - .poll = softsynth_poll, - .read = softsynth_read, - .write = softsynth_write, - .open = softsynth_open, - .release = softsynth_close, -}; - -static const struct file_operations softsynthu_fops = { - .owner = THIS_MODULE, - .poll = softsynth_poll, - .read = softsynthu_read, - .write = softsynth_write, - .open = softsynth_open, - .release = softsynth_close, -}; - -static int softsynth_probe(struct spk_synth *synth) -{ - if (misc_registered != 0) - return 0; - memset(&synth_device, 0, sizeof(synth_device)); - synth_device.minor = MISC_DYNAMIC_MINOR; - synth_device.name = "softsynth"; - synth_device.fops = &softsynth_fops; - if (misc_register(&synth_device)) { - pr_warn("Couldn't initialize miscdevice /dev/softsynth.\n"); - return -ENODEV; - } - - memset(&synthu_device, 0, sizeof(synthu_device)); - synthu_device.minor = MISC_DYNAMIC_MINOR; - synthu_device.name = "softsynthu"; - synthu_device.fops = &softsynthu_fops; - if (misc_register(&synthu_device)) { - pr_warn("Couldn't initialize miscdevice /dev/softsynthu.\n"); - return -ENODEV; - } - - misc_registered = 1; - pr_info("initialized device: /dev/softsynth, node (MAJOR 10, MINOR %d)\n", - synth_device.minor); - pr_info("initialized device: /dev/softsynthu, node (MAJOR 10, MINOR %d)\n", - synthu_device.minor); - return 0; -} - -static void softsynth_release(void) -{ - misc_deregister(&synth_device); - misc_deregister(&synthu_device); - misc_registered = 0; - pr_info("unregistered /dev/softsynth\n"); - pr_info("unregistered /dev/softsynthu\n"); -} - -static int softsynth_is_alive(struct spk_synth *synth) -{ - if (synth_soft.alive) - return 1; - return 0; -} - -module_param_named(start, synth_soft.startup, short, 0444); - -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_soft); - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_DESCRIPTION("Speakup userspace software synthesizer support"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); diff --git a/drivers/staging/speakup/speakup_spkout.c b/drivers/staging/speakup/speakup_spkout.c deleted file mode 100644 index 6e933bf1de2e..000000000000 --- a/drivers/staging/speakup/speakup_spkout.c +++ /dev/null @@ -1,139 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * originally written by: Kirk Reiser - * this version considerably modified by David Borowski, david575@rogers.com - * - * Copyright (C) 1998-99 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - * - * specificly written as a driver for the speakup screenreview - * s not a general device driver. - */ -#include "spk_priv.h" -#include "speakup.h" - -#define DRV_VERSION "2.11" -#define SYNTH_CLEAR 0x18 -#define PROCSPEECH '\r' - -static void synth_flush(struct spk_synth *synth); - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"\x05P+" } }, - { CAPS_STOP, .u.s = {"\x05P-" } }, - { RATE, .u.n = {"\x05R%d", 7, 0, 9, 0, 0, NULL } }, - { PITCH, .u.n = {"\x05P%d", 3, 0, 9, 0, 0, NULL } }, - { VOL, .u.n = {"\x05V%d", 9, 0, 9, 0, 0, NULL } }, - { TONE, .u.n = {"\x05T%c", 8, 0, 25, 65, 0, NULL } }, - { PUNCT, .u.n = {"\x05M%c", 0, 0, 3, 0, 0, "nsma" } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* These attributes will appear in /sys/accessibility/speakup/spkout. */ - -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute punct_attribute = - __ATTR(punct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute tone_attribute = - __ATTR(tone, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &pitch_attribute.attr, - &punct_attribute.attr, - &rate_attribute.attr, - &tone_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_spkout = { - .name = "spkout", - .version = DRV_VERSION, - .long_name = "Speakout", - .init = "\005W1\005I2\005C3", - .procspeech = PROCSPEECH, - .clear = SYNTH_CLEAR, - .delay = 500, - .trigger = 50, - .jiffies = 50, - .full = 40000, - .dev_name = SYNTH_DEFAULT_DEV, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = &spk_ttyio_ops, - .probe = spk_ttyio_synth_probe, - .release = spk_ttyio_release, - .synth_immediate = spk_ttyio_synth_immediate, - .catch_up = spk_do_catch_up, - .flush = synth_flush, - .is_alive = spk_synth_is_alive_restart, - .synth_adjust = NULL, - .read_buff_add = NULL, - .get_index = spk_synth_get_index, - .indexing = { - .command = "\x05[%c", - .lowindex = 1, - .highindex = 5, - .currindex = 1, - }, - .attributes = { - .attrs = synth_attrs, - .name = "spkout", - }, -}; - -static void synth_flush(struct spk_synth *synth) -{ - synth->io_ops->flush_buffer(); - synth->io_ops->send_xchar(SYNTH_CLEAR); -} - -module_param_named(ser, synth_spkout.ser, int, 0444); -module_param_named(dev, synth_spkout.dev_name, charp, 0444); -module_param_named(start, synth_spkout.startup, short, 0444); - -MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); -MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_spkout); - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_AUTHOR("David Borowski"); -MODULE_DESCRIPTION("Speakup support for Speak Out synthesizers"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/drivers/staging/speakup/speakup_txprt.c b/drivers/staging/speakup/speakup_txprt.c deleted file mode 100644 index a7326f226a5e..000000000000 --- a/drivers/staging/speakup/speakup_txprt.c +++ /dev/null @@ -1,127 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * originally written by: Kirk Reiser - * this version considerably modified by David Borowski, david575@rogers.com - * - * Copyright (C) 1998-99 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - * - * specificly written as a driver for the speakup screenreview - * s not a general device driver. - */ -#include "spk_priv.h" -#include "speakup.h" - -#define DRV_VERSION "2.11" -#define SYNTH_CLEAR 0x18 -#define PROCSPEECH '\r' /* process speech char */ - -static struct var_t vars[] = { - { CAPS_START, .u.s = {"\x05P8" } }, - { CAPS_STOP, .u.s = {"\x05P5" } }, - { RATE, .u.n = {"\x05R%d", 5, 0, 9, 0, 0, NULL } }, - { PITCH, .u.n = {"\x05P%d", 5, 0, 9, 0, 0, NULL } }, - { VOL, .u.n = {"\x05V%d", 5, 0, 9, 0, 0, NULL } }, - { TONE, .u.n = {"\x05T%c", 12, 0, 25, 61, 0, NULL } }, - { DIRECT, .u.n = {NULL, 0, 0, 1, 0, 0, NULL } }, - V_LAST_VAR - }; - -/* These attributes will appear in /sys/accessibility/speakup/txprt. */ - -static struct kobj_attribute caps_start_attribute = - __ATTR(caps_start, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute caps_stop_attribute = - __ATTR(caps_stop, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute pitch_attribute = - __ATTR(pitch, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute rate_attribute = - __ATTR(rate, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute tone_attribute = - __ATTR(tone, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute vol_attribute = - __ATTR(vol, 0644, spk_var_show, spk_var_store); - -static struct kobj_attribute delay_time_attribute = - __ATTR(delay_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute direct_attribute = - __ATTR(direct, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute full_time_attribute = - __ATTR(full_time, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute jiffy_delta_attribute = - __ATTR(jiffy_delta, 0644, spk_var_show, spk_var_store); -static struct kobj_attribute trigger_time_attribute = - __ATTR(trigger_time, 0644, spk_var_show, spk_var_store); - -/* - * Create a group of attributes so that we can create and destroy them all - * at once. - */ -static struct attribute *synth_attrs[] = { - &caps_start_attribute.attr, - &caps_stop_attribute.attr, - &pitch_attribute.attr, - &rate_attribute.attr, - &tone_attribute.attr, - &vol_attribute.attr, - &delay_time_attribute.attr, - &direct_attribute.attr, - &full_time_attribute.attr, - &jiffy_delta_attribute.attr, - &trigger_time_attribute.attr, - NULL, /* need to NULL terminate the list of attributes */ -}; - -static struct spk_synth synth_txprt = { - .name = "txprt", - .version = DRV_VERSION, - .long_name = "Transport", - .init = "\x05N1", - .procspeech = PROCSPEECH, - .clear = SYNTH_CLEAR, - .delay = 500, - .trigger = 50, - .jiffies = 50, - .full = 40000, - .dev_name = SYNTH_DEFAULT_DEV, - .startup = SYNTH_START, - .checkval = SYNTH_CHECK, - .vars = vars, - .io_ops = &spk_ttyio_ops, - .probe = spk_ttyio_synth_probe, - .release = spk_ttyio_release, - .synth_immediate = spk_ttyio_synth_immediate, - .catch_up = spk_do_catch_up, - .flush = spk_synth_flush, - .is_alive = spk_synth_is_alive_restart, - .synth_adjust = NULL, - .read_buff_add = NULL, - .get_index = NULL, - .indexing = { - .command = NULL, - .lowindex = 0, - .highindex = 0, - .currindex = 0, - }, - .attributes = { - .attrs = synth_attrs, - .name = "txprt", - }, -}; - -module_param_named(ser, synth_txprt.ser, int, 0444); -module_param_named(dev, synth_txprt.dev_name, charp, 0444); -module_param_named(start, synth_txprt.startup, short, 0444); - -MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); -MODULE_PARM_DESC(dev, "Set the device e.g. ttyUSB0, for the synthesizer."); -MODULE_PARM_DESC(start, "Start the synthesizer once it is loaded."); - -module_spk_synth(synth_txprt); - -MODULE_AUTHOR("Kirk Reiser "); -MODULE_AUTHOR("David Borowski"); -MODULE_DESCRIPTION("Speakup support for Transport synthesizers"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(DRV_VERSION); - diff --git a/drivers/staging/speakup/speakupmap.h b/drivers/staging/speakup/speakupmap.h deleted file mode 100644 index c60d7339b89a..000000000000 --- a/drivers/staging/speakup/speakupmap.h +++ /dev/null @@ -1,66 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - 119, 62, 6, - 0, 16, 20, 17, 32, 48, 0, - 2, 0, 78, 0, 0, 0, 0, - 3, 0, 79, 0, 0, 0, 0, - 4, 0, 76, 0, 0, 0, 0, - 5, 0, 77, 0, 0, 0, 0, - 6, 0, 74, 0, 0, 0, 0, - 7, 0, 75, 0, 0, 0, 0, - 9, 0, 5, 46, 0, 0, 0, - 10, 0, 4, 0, 0, 0, 0, - 11, 0, 0, 1, 0, 0, 0, - 12, 0, 27, 0, 33, 0, 0, - 19, 0, 47, 0, 0, 0, 0, - 21, 0, 29, 17, 0, 0, 0, - 22, 0, 15, 0, 0, 0, 0, - 23, 0, 14, 0, 0, 0, 28, - 24, 0, 16, 0, 0, 0, 0, - 25, 0, 30, 18, 0, 0, 0, - 28, 0, 3, 26, 0, 0, 0, - 35, 0, 31, 0, 0, 0, 0, - 36, 0, 12, 0, 0, 0, 0, - 37, 0, 11, 0, 0, 0, 22, - 38, 0, 13, 0, 0, 0, 0, - 39, 0, 32, 7, 0, 0, 0, - 40, 0, 23, 0, 0, 0, 0, - 44, 0, 44, 0, 0, 0, 0, - 49, 0, 24, 0, 0, 0, 0, - 50, 0, 9, 19, 6, 0, 0, - 51, 0, 8, 0, 0, 0, 36, - 52, 0, 10, 20, 0, 0, 0, - 53, 0, 25, 0, 0, 0, 0, - 55, 46, 1, 0, 0, 0, 0, - 58, 128, 128, 0, 0, 0, 0, - 59, 0, 45, 0, 0, 0, 0, - 60, 0, 40, 0, 0, 0, 0, - 61, 0, 41, 0, 0, 0, 0, - 62, 0, 42, 0, 0, 0, 0, - 63, 0, 34, 0, 0, 0, 0, - 64, 0, 35, 0, 0, 0, 0, - 65, 0, 37, 0, 0, 0, 0, - 66, 0, 38, 0, 0, 0, 0, - 67, 0, 66, 0, 39, 0, 0, - 68, 0, 67, 0, 0, 0, 0, - 71, 15, 19, 0, 0, 0, 0, - 72, 14, 29, 0, 0, 28, 0, - 73, 16, 17, 0, 0, 0, 0, - 74, 27, 33, 0, 0, 0, 0, - 75, 12, 31, 0, 0, 0, 0, - 76, 11, 21, 0, 0, 22, 0, - 77, 13, 32, 0, 0, 0, 0, - 78, 23, 43, 0, 0, 0, 0, - 79, 9, 20, 0, 0, 0, 0, - 80, 8, 30, 0, 0, 36, 0, - 81, 10, 18, 0, 0, 0, 0, - 82, 128, 128, 0, 0, 0, 0, - 83, 24, 25, 0, 0, 0, 0, - 87, 0, 68, 0, 0, 0, 0, - 88, 0, 69, 0, 0, 0, 0, - 96, 3, 26, 0, 0, 0, 0, - 98, 4, 5, 0, 0, 0, 0, - 99, 2, 0, 0, 0, 0, 0, - 104, 0, 6, 0, 0, 0, 0, - 109, 0, 7, 0, 0, 0, 0, - 125, 128, 128, 0, 0, 0, 0, - 0, 119 diff --git a/drivers/staging/speakup/speakupmap.map b/drivers/staging/speakup/speakupmap.map deleted file mode 100644 index f10d44cf5d7a..000000000000 --- a/drivers/staging/speakup/speakupmap.map +++ /dev/null @@ -1,93 +0,0 @@ -spk key_f9 = punc_level_dec -spk key_f10 = punc_level_inc -spk key_f11 = reading_punc_dec -spk key_f12 = reading_punc_inc -spk key_1 = vol_dec -spk key_2 = vol_inc -spk key_3 = pitch_dec -spk key_4 = pitch_inc -spk key_5 = rate_dec -spk key_6 = rate_inc -key_kpasterisk = toggle_cursoring -ctrl spk key_8 = toggle_cursoring -spk key_kpasterisk = speakup_goto -spk key_f1 = speakup_help -spk key_f2 = set_win -spk key_f3 = clear_win -spk key_f4 = enable_win -spk key_f5 = edit_some -spk key_f6 = edit_most -spk key_f7 = edit_delim -spk key_f8 = edit_repeat -shift spk key_f9 = edit_exnum - key_kp7 = say_prev_line -spk key_kp7 = left_edge - key_kp8 = say_line -double key_kp8 = say_line_indent -spk key_kp8 = say_from_top - key_kp9 = say_next_line -spk key_kp9 = top_edge - key_kpminus = speakup_parked -spk key_kpminus = say_char_num - key_kp4 = say_prev_word -spk key_kp4 = say_from_left - key_kp5 = say_word -double key_kp5 = spell_word -spk key_kp5 = spell_phonetic - key_kp6 = say_next_word -spk key_kp6 = say_to_right - key_kpplus = say_screen -spk key_kpplus = say_win - key_kp1 = say_prev_char -spk key_kp1 = right_edge - key_kp2 = say_char -spk key_kp2 = say_to_bottom -double key_kp2 = say_phonetic_char - key_kp3 = say_next_char -spk key_kp3 = bottom_edge - key_kp0 = spk_key - key_kpdot = say_position -spk key_kpdot = say_attributes -key_kpenter = speakup_quiet -spk key_kpenter = speakup_off -key_sysrq = speech_kill - key_kpslash = speakup_cut -spk key_kpslash = speakup_paste -spk key_pageup = say_first_char -spk key_pagedown = say_last_char -key_capslock = spk_key - spk key_z = spk_lock -key_leftmeta = spk_key -ctrl spk key_0 = speakup_goto -spk key_u = say_prev_line -spk key_i = say_line -double spk key_i = say_line_indent -spk key_o = say_next_line -spk key_minus = speakup_parked -shift spk key_minus = say_char_num -spk key_j = say_prev_word -spk key_k = say_word -double spk key_k = spell_word -spk key_l = say_next_word -spk key_m = say_prev_char -spk key_comma = say_char -double spk key_comma = say_phonetic_char -spk key_dot = say_next_char -spk key_n = say_position - ctrl spk key_m = left_edge - ctrl spk key_y = top_edge - ctrl spk key_dot = right_edge -ctrl spk key_p = bottom_edge -spk key_apostrophe = say_screen -spk key_h = say_from_left -spk key_y = say_from_top -spk key_semicolon = say_to_right -spk key_p = say_to_bottom -spk key_slash = say_attributes - spk key_enter = speakup_quiet - ctrl spk key_enter = speakup_off - spk key_9 = speakup_cut -spk key_8 = speakup_paste -shift spk key_m = say_first_char - ctrl spk key_semicolon = say_last_char -spk key_r = read_all_doc diff --git a/drivers/staging/speakup/spk_priv.h b/drivers/staging/speakup/spk_priv.h deleted file mode 100644 index c75b40838794..000000000000 --- a/drivers/staging/speakup/spk_priv.h +++ /dev/null @@ -1,84 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* spk_priv.h - * review functions for the speakup screen review package. - * originally written by: Kirk Reiser and Andy Berdan. - * - * extensively modified by David Borowski. - * - * Copyright (C) 1998 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - */ -#ifndef _SPEAKUP_PRIVATE_H -#define _SPEAKUP_PRIVATE_H - -#include - -#include "spk_types.h" -#include "spk_priv_keyinfo.h" - -#define V_LAST_VAR { MAXVARS } -#define SPACE 0x20 -#define SYNTH_CHECK 20030716 /* today's date ought to do for check value */ -/* synth flags, for odd synths */ -#define SF_DEC 1 /* to fiddle puncs in alpha strings so it doesn't spell */ -#ifdef MODULE -#define SYNTH_START 1 -#else -#define SYNTH_START 0 -#endif - -#define KT_SPKUP 15 -#define SPK_SYNTH_TIMEOUT 100000 /* in micro-seconds */ -#define SYNTH_DEFAULT_DEV "ttyS0" -#define SYNTH_DEFAULT_SER 0 - -const struct old_serial_port *spk_serial_init(int index); -void spk_stop_serial_interrupt(void); -int spk_wait_for_xmitr(struct spk_synth *in_synth); -void spk_serial_release(void); -void spk_ttyio_release(void); -void spk_ttyio_register_ldisc(void); -void spk_ttyio_unregister_ldisc(void); - -void synth_buffer_skip_nonlatin1(void); -u16 synth_buffer_getc(void); -u16 synth_buffer_peek(void); -int synth_buffer_empty(void); -struct var_t *spk_get_var(enum var_id_t var_id); -ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf); -ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count); - -int spk_serial_synth_probe(struct spk_synth *synth); -int spk_ttyio_synth_probe(struct spk_synth *synth); -const char *spk_serial_synth_immediate(struct spk_synth *synth, - const char *buff); -const char *spk_ttyio_synth_immediate(struct spk_synth *synth, - const char *buff); -void spk_do_catch_up(struct spk_synth *synth); -void spk_do_catch_up_unicode(struct spk_synth *synth); -void spk_synth_flush(struct spk_synth *synth); -unsigned char spk_synth_get_index(struct spk_synth *synth); -int spk_synth_is_alive_nop(struct spk_synth *synth); -int spk_synth_is_alive_restart(struct spk_synth *synth); -__printf(1, 2) -void synth_printf(const char *buf, ...); -void synth_putwc(u16 wc); -void synth_putwc_s(u16 wc); -void synth_putws(const u16 *buf); -void synth_putws_s(const u16 *buf); -int synth_request_region(unsigned long start, unsigned long n); -int synth_release_region(unsigned long start, unsigned long n); -int synth_add(struct spk_synth *in_synth); -void synth_remove(struct spk_synth *in_synth); -struct spk_synth *synth_current(void); - -extern struct speakup_info_t speakup_info; - -extern struct var_t synth_time_vars[]; - -extern struct spk_io_ops spk_serial_io_ops; -extern struct spk_io_ops spk_ttyio_ops; - -#endif diff --git a/drivers/staging/speakup/spk_priv_keyinfo.h b/drivers/staging/speakup/spk_priv_keyinfo.h deleted file mode 100644 index 1f789bd1c678..000000000000 --- a/drivers/staging/speakup/spk_priv_keyinfo.h +++ /dev/null @@ -1,100 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* spk_priv.h - * review functions for the speakup screen review package. - * originally written by: Kirk Reiser and Andy Berdan. - * - * extensively modified by David Borowski. - * - * Copyright (C) 1998 Kirk Reiser. - * Copyright (C) 2003 David Borowski. - */ - -#ifndef _SPEAKUP_KEYINFO_H -#define _SPEAKUP_KEYINFO_H - -#define FIRST_SYNTH_VAR RATE -/* 0 is reserved for no remap */ -#define SPEAKUP_GOTO 0x01 -#define SPEECH_KILL 0x02 -#define SPEAKUP_QUIET 0x03 -#define SPEAKUP_CUT 0x04 -#define SPEAKUP_PASTE 0x05 -#define SAY_FIRST_CHAR 0x06 -#define SAY_LAST_CHAR 0x07 -#define SAY_CHAR 0x08 -#define SAY_PREV_CHAR 0x09 -#define SAY_NEXT_CHAR 0x0a -#define SAY_WORD 0x0b -#define SAY_PREV_WORD 0x0c -#define SAY_NEXT_WORD 0x0d -#define SAY_LINE 0x0e -#define SAY_PREV_LINE 0x0f -#define SAY_NEXT_LINE 0x10 -#define TOP_EDGE 0x11 -#define BOTTOM_EDGE 0x12 -#define LEFT_EDGE 0x13 -#define RIGHT_EDGE 0x14 -#define SPELL_PHONETIC 0x15 -#define SPELL_WORD 0x16 -#define SAY_SCREEN 0x17 -#define SAY_POSITION 0x18 -#define SAY_ATTRIBUTES 0x19 -#define SPEAKUP_OFF 0x1a -#define SPEAKUP_PARKED 0x1b -#define SAY_LINE_INDENT 0x1c -#define SAY_FROM_TOP 0x1d -#define SAY_TO_BOTTOM 0x1e -#define SAY_FROM_LEFT 0x1f -#define SAY_TO_RIGHT 0x20 -#define SAY_CHAR_NUM 0x21 -#define EDIT_SOME 0x22 -#define EDIT_MOST 0x23 -#define SAY_PHONETIC_CHAR 0x24 -#define EDIT_DELIM 0x25 -#define EDIT_REPEAT 0x26 -#define EDIT_EXNUM 0x27 -#define SET_WIN 0x28 -#define CLEAR_WIN 0x29 -#define ENABLE_WIN 0x2a -#define SAY_WIN 0x2b -#define SPK_LOCK 0x2c -#define SPEAKUP_HELP 0x2d -#define TOGGLE_CURSORING 0x2e -#define READ_ALL_DOC 0x2f - -/* one greater than the last func handler */ -#define SPKUP_MAX_FUNC 0x30 - -#define SPK_KEY 0x80 -#define FIRST_EDIT_BITS 0x22 -#define FIRST_SET_VAR SPELL_DELAY - -/* increase if adding more than 0x3f functions */ -#define VAR_START 0x40 - -/* keys for setting variables, must be ordered same as the enum for var_ids */ -/* with dec being even and inc being 1 greater */ -#define SPELL_DELAY_DEC (VAR_START + 0) -#define SPELL_DELAY_INC (SPELL_DELAY_DEC + 1) -#define PUNC_LEVEL_DEC (SPELL_DELAY_DEC + 2) -#define PUNC_LEVEL_INC (PUNC_LEVEL_DEC + 1) -#define READING_PUNC_DEC (PUNC_LEVEL_DEC + 2) -#define READING_PUNC_INC (READING_PUNC_DEC + 1) -#define ATTRIB_BLEEP_DEC (READING_PUNC_DEC + 2) -#define ATTRIB_BLEEP_INC (ATTRIB_BLEEP_DEC + 1) -#define BLEEPS_DEC (ATTRIB_BLEEP_DEC + 2) -#define BLEEPS_INC (BLEEPS_DEC + 1) -#define RATE_DEC (BLEEPS_DEC + 2) -#define RATE_INC (RATE_DEC + 1) -#define PITCH_DEC (RATE_DEC + 2) -#define PITCH_INC (PITCH_DEC + 1) -#define VOL_DEC (PITCH_DEC + 2) -#define VOL_INC (VOL_DEC + 1) -#define TONE_DEC (VOL_DEC + 2) -#define TONE_INC (TONE_DEC + 1) -#define PUNCT_DEC (TONE_DEC + 2) -#define PUNCT_INC (PUNCT_DEC + 1) -#define VOICE_DEC (PUNCT_DEC + 2) -#define VOICE_INC (VOICE_DEC + 1) - -#endif diff --git a/drivers/staging/speakup/spk_ttyio.c b/drivers/staging/speakup/spk_ttyio.c deleted file mode 100644 index 9b95f77f9265..000000000000 --- a/drivers/staging/speakup/spk_ttyio.c +++ /dev/null @@ -1,384 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include -#include -#include - -#include "speakup.h" -#include "spk_types.h" -#include "spk_priv.h" - -struct spk_ldisc_data { - char buf; - struct completion completion; - bool buf_free; -}; - -static struct spk_synth *spk_ttyio_synth; -static struct tty_struct *speakup_tty; -/* mutex to protect against speakup_tty disappearing from underneath us while - * we are using it. this can happen when the device physically unplugged, - * while in use. it also serialises access to speakup_tty. - */ -static DEFINE_MUTEX(speakup_tty_mutex); - -static int ser_to_dev(int ser, dev_t *dev_no) -{ - if (ser < 0 || ser > (255 - 64)) { - pr_err("speakup: Invalid ser param. Must be between 0 and 191 inclusive.\n"); - return -EINVAL; - } - - *dev_no = MKDEV(4, (64 + ser)); - return 0; -} - -static int get_dev_to_use(struct spk_synth *synth, dev_t *dev_no) -{ - /* use ser only when dev is not specified */ - if (strcmp(synth->dev_name, SYNTH_DEFAULT_DEV) || - synth->ser == SYNTH_DEFAULT_SER) - return tty_dev_name_to_number(synth->dev_name, dev_no); - - return ser_to_dev(synth->ser, dev_no); -} - -static int spk_ttyio_ldisc_open(struct tty_struct *tty) -{ - struct spk_ldisc_data *ldisc_data; - - if (!tty->ops->write) - return -EOPNOTSUPP; - speakup_tty = tty; - - ldisc_data = kmalloc(sizeof(*ldisc_data), GFP_KERNEL); - if (!ldisc_data) - return -ENOMEM; - - init_completion(&ldisc_data->completion); - ldisc_data->buf_free = true; - speakup_tty->disc_data = ldisc_data; - - return 0; -} - -static void spk_ttyio_ldisc_close(struct tty_struct *tty) -{ - mutex_lock(&speakup_tty_mutex); - kfree(speakup_tty->disc_data); - speakup_tty = NULL; - mutex_unlock(&speakup_tty_mutex); -} - -static int spk_ttyio_receive_buf2(struct tty_struct *tty, - const unsigned char *cp, char *fp, int count) -{ - struct spk_ldisc_data *ldisc_data = tty->disc_data; - - if (spk_ttyio_synth->read_buff_add) { - int i; - - for (i = 0; i < count; i++) - spk_ttyio_synth->read_buff_add(cp[i]); - - return count; - } - - if (!ldisc_data->buf_free) - /* ttyio_in will tty_schedule_flip */ - return 0; - - /* Make sure the consumer has read buf before we have seen - * buf_free == true and overwrite buf - */ - mb(); - - ldisc_data->buf = cp[0]; - ldisc_data->buf_free = false; - complete(&ldisc_data->completion); - - return 1; -} - -static struct tty_ldisc_ops spk_ttyio_ldisc_ops = { - .owner = THIS_MODULE, - .magic = TTY_LDISC_MAGIC, - .name = "speakup_ldisc", - .open = spk_ttyio_ldisc_open, - .close = spk_ttyio_ldisc_close, - .receive_buf2 = spk_ttyio_receive_buf2, -}; - -static int spk_ttyio_out(struct spk_synth *in_synth, const char ch); -static int spk_ttyio_out_unicode(struct spk_synth *in_synth, u16 ch); -static void spk_ttyio_send_xchar(char ch); -static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear); -static unsigned char spk_ttyio_in(void); -static unsigned char spk_ttyio_in_nowait(void); -static void spk_ttyio_flush_buffer(void); - -struct spk_io_ops spk_ttyio_ops = { - .synth_out = spk_ttyio_out, - .synth_out_unicode = spk_ttyio_out_unicode, - .send_xchar = spk_ttyio_send_xchar, - .tiocmset = spk_ttyio_tiocmset, - .synth_in = spk_ttyio_in, - .synth_in_nowait = spk_ttyio_in_nowait, - .flush_buffer = spk_ttyio_flush_buffer, -}; -EXPORT_SYMBOL_GPL(spk_ttyio_ops); - -static inline void get_termios(struct tty_struct *tty, - struct ktermios *out_termios) -{ - down_read(&tty->termios_rwsem); - *out_termios = tty->termios; - up_read(&tty->termios_rwsem); -} - -static int spk_ttyio_initialise_ldisc(struct spk_synth *synth) -{ - int ret = 0; - struct tty_struct *tty; - struct ktermios tmp_termios; - dev_t dev; - - ret = get_dev_to_use(synth, &dev); - if (ret) - return ret; - - tty = tty_kopen(dev); - if (IS_ERR(tty)) - return PTR_ERR(tty); - - if (tty->ops->open) - ret = tty->ops->open(tty, NULL); - else - ret = -ENODEV; - - if (ret) { - tty_unlock(tty); - return ret; - } - - clear_bit(TTY_HUPPED, &tty->flags); - /* ensure hardware flow control is enabled */ - get_termios(tty, &tmp_termios); - if (!(tmp_termios.c_cflag & CRTSCTS)) { - tmp_termios.c_cflag |= CRTSCTS; - tty_set_termios(tty, &tmp_termios); - /* - * check c_cflag to see if it's updated as tty_set_termios - * may not return error even when no tty bits are - * changed by the request. - */ - get_termios(tty, &tmp_termios); - if (!(tmp_termios.c_cflag & CRTSCTS)) - pr_warn("speakup: Failed to set hardware flow control\n"); - } - - tty_unlock(tty); - - ret = tty_set_ldisc(tty, N_SPEAKUP); - if (ret) - pr_err("speakup: Failed to set N_SPEAKUP on tty\n"); - - return ret; -} - -void spk_ttyio_register_ldisc(void) -{ - if (tty_register_ldisc(N_SPEAKUP, &spk_ttyio_ldisc_ops)) - pr_warn("speakup: Error registering line discipline. Most synths won't work.\n"); -} - -void spk_ttyio_unregister_ldisc(void) -{ - if (tty_unregister_ldisc(N_SPEAKUP)) - pr_warn("speakup: Couldn't unregister ldisc\n"); -} - -static int spk_ttyio_out(struct spk_synth *in_synth, const char ch) -{ - mutex_lock(&speakup_tty_mutex); - if (in_synth->alive && speakup_tty && speakup_tty->ops->write) { - int ret = speakup_tty->ops->write(speakup_tty, &ch, 1); - - mutex_unlock(&speakup_tty_mutex); - if (ret == 0) - /* No room */ - return 0; - if (ret < 0) { - pr_warn("%s: I/O error, deactivating speakup\n", - in_synth->long_name); - /* No synth any more, so nobody will restart TTYs, - * and we thus need to do it ourselves. Now that there - * is no synth we can let application flood anyway - */ - in_synth->alive = 0; - speakup_start_ttys(); - return 0; - } - return 1; - } - - mutex_unlock(&speakup_tty_mutex); - return 0; -} - -static int spk_ttyio_out_unicode(struct spk_synth *in_synth, u16 ch) -{ - int ret; - - if (ch < 0x80) { - ret = spk_ttyio_out(in_synth, ch); - } else if (ch < 0x800) { - ret = spk_ttyio_out(in_synth, 0xc0 | (ch >> 6)); - ret &= spk_ttyio_out(in_synth, 0x80 | (ch & 0x3f)); - } else { - ret = spk_ttyio_out(in_synth, 0xe0 | (ch >> 12)); - ret &= spk_ttyio_out(in_synth, 0x80 | ((ch >> 6) & 0x3f)); - ret &= spk_ttyio_out(in_synth, 0x80 | (ch & 0x3f)); - } - return ret; -} - -static int check_tty(struct tty_struct *tty) -{ - if (!tty) { - pr_warn("%s: I/O error, deactivating speakup\n", - spk_ttyio_synth->long_name); - /* No synth any more, so nobody will restart TTYs, and we thus - * need to do it ourselves. Now that there is no synth we can - * let application flood anyway - */ - spk_ttyio_synth->alive = 0; - speakup_start_ttys(); - return 1; - } - - return 0; -} - -static void spk_ttyio_send_xchar(char ch) -{ - mutex_lock(&speakup_tty_mutex); - if (check_tty(speakup_tty)) { - mutex_unlock(&speakup_tty_mutex); - return; - } - - if (speakup_tty->ops->send_xchar) - speakup_tty->ops->send_xchar(speakup_tty, ch); - mutex_unlock(&speakup_tty_mutex); -} - -static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear) -{ - mutex_lock(&speakup_tty_mutex); - if (check_tty(speakup_tty)) { - mutex_unlock(&speakup_tty_mutex); - return; - } - - if (speakup_tty->ops->tiocmset) - speakup_tty->ops->tiocmset(speakup_tty, set, clear); - mutex_unlock(&speakup_tty_mutex); -} - -static unsigned char ttyio_in(int timeout) -{ - struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data; - char rv; - - if (wait_for_completion_timeout(&ldisc_data->completion, - usecs_to_jiffies(timeout)) == 0) { - if (timeout) - pr_warn("spk_ttyio: timeout (%d) while waiting for input\n", - timeout); - return 0xff; - } - - rv = ldisc_data->buf; - /* Make sure we have read buf before we set buf_free to let - * the producer overwrite it - */ - mb(); - ldisc_data->buf_free = true; - /* Let TTY push more characters */ - tty_schedule_flip(speakup_tty->port); - - return rv; -} - -static unsigned char spk_ttyio_in(void) -{ - return ttyio_in(SPK_SYNTH_TIMEOUT); -} - -static unsigned char spk_ttyio_in_nowait(void) -{ - u8 rv = ttyio_in(0); - - return (rv == 0xff) ? 0 : rv; -} - -static void spk_ttyio_flush_buffer(void) -{ - mutex_lock(&speakup_tty_mutex); - if (check_tty(speakup_tty)) { - mutex_unlock(&speakup_tty_mutex); - return; - } - - if (speakup_tty->ops->flush_buffer) - speakup_tty->ops->flush_buffer(speakup_tty); - - mutex_unlock(&speakup_tty_mutex); -} - -int spk_ttyio_synth_probe(struct spk_synth *synth) -{ - int rv = spk_ttyio_initialise_ldisc(synth); - - if (rv) - return rv; - - synth->alive = 1; - spk_ttyio_synth = synth; - - return 0; -} -EXPORT_SYMBOL_GPL(spk_ttyio_synth_probe); - -void spk_ttyio_release(void) -{ - if (!speakup_tty) - return; - - tty_lock(speakup_tty); - - if (speakup_tty->ops->close) - speakup_tty->ops->close(speakup_tty, NULL); - - tty_ldisc_flush(speakup_tty); - tty_unlock(speakup_tty); - tty_kclose(speakup_tty); -} -EXPORT_SYMBOL_GPL(spk_ttyio_release); - -const char *spk_ttyio_synth_immediate(struct spk_synth *synth, const char *buff) -{ - u_char ch; - - while ((ch = *buff)) { - if (ch == '\n') - ch = synth->procspeech; - if (tty_write_room(speakup_tty) < 1 || - !synth->io_ops->synth_out(synth, ch)) - return buff; - buff++; - } - return NULL; -} -EXPORT_SYMBOL_GPL(spk_ttyio_synth_immediate); diff --git a/drivers/staging/speakup/spk_types.h b/drivers/staging/speakup/spk_types.h deleted file mode 100644 index d3272c6d199a..000000000000 --- a/drivers/staging/speakup/spk_types.h +++ /dev/null @@ -1,221 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef SPEAKUP_TYPES_H -#define SPEAKUP_TYPES_H - -/* This file includes all of the typedefs and structs used in speakup. */ - -#include -#include -#include -#include -#include /* for wait_queue */ -#include /* for __init */ -#include -#include -#include -#include -#include /* for inb_p, outb_p, inb, outb, etc... */ -#include - -enum var_type_t { - VAR_NUM = 0, - VAR_TIME, - VAR_STRING, - VAR_PROC -}; - -enum { - E_DEFAULT = 0, - E_SET, - E_INC, - E_DEC, - E_NEW_DEFAULT, -}; - -enum var_id_t { - VERSION = 0, SYNTH, SILENT, SYNTH_DIRECT, - KEYMAP, CHARS, - PUNC_SOME, PUNC_MOST, PUNC_ALL, - DELIM, REPEATS, EXNUMBER, - DELAY, TRIGGER, JIFFY, FULL, /* all timers must be together */ - BLEEP_TIME, CURSOR_TIME, BELL_POS, - SAY_CONTROL, SAY_WORD_CTL, NO_INTERRUPT, KEY_ECHO, - SPELL_DELAY, PUNC_LEVEL, READING_PUNC, - ATTRIB_BLEEP, BLEEPS, - RATE, PITCH, INFLECTION, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG, - DIRECT, PAUSE, - CAPS_START, CAPS_STOP, CHARTAB, - MAXVARS -}; - -typedef int (*special_func)(struct vc_data *vc, u_char type, u_char ch, - u_short key); - -#define COLOR_BUFFER_SIZE 160 - -struct spk_highlight_color_track { - /* Count of each background color */ - unsigned int bgcount[8]; - /* Buffer for characters drawn with each background color */ - u16 highbuf[8][COLOR_BUFFER_SIZE]; - /* Current index into highbuf */ - unsigned int highsize[8]; - /* Reading Position for each color */ - u_long rpos[8], rx[8], ry[8]; - /* Real Cursor Y Position */ - ulong cy; -}; - -struct st_spk_t { - u_long reading_x, cursor_x; - u_long reading_y, cursor_y; - u_long reading_pos, cursor_pos; - u_long go_x, go_pos; - u_long w_top, w_bottom, w_left, w_right; - u_char w_start, w_enabled; - u_char reading_attr, old_attr; - char parked, shut_up; - struct spk_highlight_color_track ht; - int tty_stopped; -}; - -/* now some defines to make these easier to use. */ -#define spk_shut_up (speakup_console[vc->vc_num]->shut_up) -#define spk_killed (speakup_console[vc->vc_num]->shut_up & 0x40) -#define spk_x (speakup_console[vc->vc_num]->reading_x) -#define spk_cx (speakup_console[vc->vc_num]->cursor_x) -#define spk_y (speakup_console[vc->vc_num]->reading_y) -#define spk_cy (speakup_console[vc->vc_num]->cursor_y) -#define spk_pos (speakup_console[vc->vc_num]->reading_pos) -#define spk_cp (speakup_console[vc->vc_num]->cursor_pos) -#define goto_pos (speakup_console[vc->vc_num]->go_pos) -#define goto_x (speakup_console[vc->vc_num]->go_x) -#define win_top (speakup_console[vc->vc_num]->w_top) -#define win_bottom (speakup_console[vc->vc_num]->w_bottom) -#define win_left (speakup_console[vc->vc_num]->w_left) -#define win_right (speakup_console[vc->vc_num]->w_right) -#define win_start (speakup_console[vc->vc_num]->w_start) -#define win_enabled (speakup_console[vc->vc_num]->w_enabled) -#define spk_attr (speakup_console[vc->vc_num]->reading_attr) -#define spk_old_attr (speakup_console[vc->vc_num]->old_attr) -#define spk_parked (speakup_console[vc->vc_num]->parked) - -struct st_var_header { - char *name; - enum var_id_t var_id; - enum var_type_t var_type; - void *p_val; /* ptr to programs variable to store value */ - void *data; /* ptr to the vars data */ -}; - -struct num_var_t { - char *synth_fmt; - int default_val; - int low; - int high; - short offset, multiplier; /* for fiddling rates etc. */ - char *out_str; /* if synth needs char representation of number */ - int value; /* current value */ -}; - -struct punc_var_t { - enum var_id_t var_id; - short value; -}; - -struct string_var_t { - char *default_val; -}; - -struct var_t { - enum var_id_t var_id; - union { - struct num_var_t n; - struct string_var_t s; - } u; -}; - -struct st_bits_data { /* punc, repeats, word delim bits */ - char *name; - char *value; - short mask; -}; - -struct synth_indexing { - char *command; - unsigned char lowindex; - unsigned char highindex; - unsigned char currindex; -}; - -struct spk_synth; - -struct spk_io_ops { - int (*synth_out)(struct spk_synth *synth, const char ch); - int (*synth_out_unicode)(struct spk_synth *synth, u16 ch); - void (*send_xchar)(char ch); - void (*tiocmset)(unsigned int set, unsigned int clear); - unsigned char (*synth_in)(void); - unsigned char (*synth_in_nowait)(void); - void (*flush_buffer)(void); -}; - -struct spk_synth { - struct list_head node; - - const char *name; - const char *version; - const char *long_name; - const char *init; - char procspeech; - char clear; - int delay; - int trigger; - int jiffies; - int full; - int ser; - char *dev_name; - short flags; - short startup; - const int checkval; /* for validating a proper synth module */ - struct var_t *vars; - int *default_pitch; - int *default_vol; - struct spk_io_ops *io_ops; - int (*probe)(struct spk_synth *synth); - void (*release)(void); - const char *(*synth_immediate)(struct spk_synth *synth, - const char *buff); - void (*catch_up)(struct spk_synth *synth); - void (*flush)(struct spk_synth *synth); - int (*is_alive)(struct spk_synth *synth); - int (*synth_adjust)(struct st_var_header *var); - void (*read_buff_add)(u_char c); - unsigned char (*get_index)(struct spk_synth *synth); - struct synth_indexing indexing; - int alive; - struct attribute_group attributes; -}; - -/* - * module_spk_synth() - Helper macro for registering a speakup driver - * @__spk_synth: spk_synth struct - * Helper macro for speakup drivers which do not do anything special in module - * init/exit. This eliminates a lot of boilerplate. Each module may only - * use this macro once, and calling it replaces module_init() and module_exit() - */ -#define module_spk_synth(__spk_synth) \ - module_driver(__spk_synth, synth_add, synth_remove) - -struct speakup_info_t { - spinlock_t spinlock; - int port_tts; - int flushing; -}; - -struct bleep { - short freq; - unsigned long jiffies; - int active; -}; -#endif diff --git a/drivers/staging/speakup/spkguide.txt b/drivers/staging/speakup/spkguide.txt deleted file mode 100644 index 3782f6a09e97..000000000000 --- a/drivers/staging/speakup/spkguide.txt +++ /dev/null @@ -1,1575 +0,0 @@ - -The Speakup User's Guide -For Speakup 3.1.2 and Later -By Gene Collins -Updated by others -Last modified on Mon Sep 27 14:26:31 2010 -Document version 1.3 - -Copyright (c) 2005 Gene Collins -Copyright (c) 2008 Samuel Thibault -Copyright (c) 2009, 2010 the Speakup Team - -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.2 or -any later version published by the Free Software Foundation; with no -Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A -copy of the license is included in the section entitled "GNU Free -Documentation License". - -Preface - -The purpose of this document is to familiarize users with the user -interface to Speakup, a Linux Screen Reader. If you need instructions -for installing or obtaining Speakup, visit the web site at -http://linux-speakup.org/. Speakup is a set of patches to the standard -Linux kernel source tree. It can be built as a series of modules, or as -a part of a monolithic kernel. These details are beyond the scope of -this manual, but the user may need to be aware of the module -capabilities, depending on how your system administrator has installed -Speakup. If Speakup is built as a part of a monolithic kernel, and the -user is using a hardware synthesizer, then Speakup will be able to -provide speech access from the time the kernel is loaded, until the time -the system is shutdown. This means that if you have obtained Linux -installation media for a distribution which includes Speakup as a part -of its kernel, you will be able, as a blind person, to install Linux -with speech access unaided by a sighted person. Again, these details -are beyond the scope of this manual, but the user should be aware of -them. See the web site mentioned above for further details. - -1. Starting Speakup - -If your system administrator has installed Speakup to work with your -specific synthesizer by default, then all you need to do to use Speakup -is to boot your system, and Speakup should come up talking. This -assumes of course that your synthesizer is a supported hardware -synthesizer, and that it is either installed in or connected to your -system, and is if necessary powered on. - -It is possible, however, that Speakup may have been compiled into the -kernel with no default synthesizer. It is even possible that your -kernel has been compiled with support for some of the supported -synthesizers and not others. If you find that this is the case, and -your synthesizer is supported but not available, complain to the person -who compiled and installed your kernel. Or better yet, go to the web -site, and learn how to patch Speakup into your own kernel source, and -build and install your own kernel. - -If your kernel has been compiled with Speakup, and has no default -synthesizer set, or you would like to use a different synthesizer than -the default one, then you may issue the following command at the boot -prompt of your boot loader. - -linux speakup.synth=ltlk - -This command would tell Speakup to look for and use a LiteTalk or -DoubleTalk LT at boot up. You may replace the ltlk synthesizer keyword -with the keyword for whatever synthesizer you wish to use. The -speakup.synth parameter will accept the following keywords, provided -that support for the related synthesizers has been built into the -kernel. - -acntsa -- Accent SA -acntpc -- Accent PC -apollo -- Apollo -audptr -- Audapter -bns -- Braille 'n Speak -dectlk -- DecTalk Express (old and new, db9 serial only) -decext -- DecTalk (old) External -dtlk -- DoubleTalk PC -keypc -- Keynote Gold PC -ltlk -- DoubleTalk LT, LiteTalk, or external Tripletalk (db9 serial only) -spkout -- Speak Out -txprt -- Transport -dummy -- Plain text terminal - -Note: Speakup does * NOT * support usb connections! Speakup also does * -NOT * support the internal Tripletalk! - -Speakup does support two other synthesizers, but because they work in -conjunction with other software, they must be loaded as modules after -their related software is loaded, and so are not available at boot up. -These are as follows: - -decpc -- DecTalk PC (not available at boot up) -soft -- One of several software synthesizers (not available at boot up) - -See the sections on loading modules and software synthesizers later in -this manual for further details. It should be noted here that the -speakup.synth boot parameter will have no effect if Speakup has been -compiled as modules. In order for Speakup modules to be loaded during -the boot process, such action must be configured by your system -administrator. This will mean that you will hear some, but not all, of -the bootup messages. - -2. Basic operation - -Once you have booted the system, and if necessary, have supplied the -proper bootup parameter for your synthesizer, Speakup will begin -talking as soon as the kernel is loaded. In fact, it will talk a lot! -It will speak all the boot up messages that the kernel prints on the -screen during the boot process. This is because Speakup is not a -separate screen reader, but is actually built into the operating -system. Since almost all console applications must print text on the -screen using the kernel, and must get their keyboard input through the -kernel, they are automatically handled properly by Speakup. There are a -few exceptions, but we'll come to those later. - -Note: In this guide I will refer to the numeric keypad as the keypad. -This is done because the speakupmap.map file referred to later in this -manual uses the term keypad instead of numeric keypad. Also I'm lazy -and would rather only type one word. So keypad it is. Got it? Good. - -Most of the Speakup review keys are located on the keypad at the far -right of the keyboard. The numlock key should be off, in order for these -to work. If you toggle the numlock on, the keypad will produce numbers, -which is exactly what you want for spreadsheets and such. For the -purposes of this guide, you should have the numlock turned off, which is -its default state at bootup. - -You probably won't want to listen to all the bootup messages every time -you start your system, though it's a good idea to listen to them at -least once, just so you'll know what kind of information is available to -you during the boot process. You can always review these messages after -bootup with the command: - -dmesg | more - -In order to speed the boot process, and to silence the speaking of the -bootup messages, just press the keypad enter key. This key is located -in the bottom right corner of the keypad. Speakup will shut up and stay -that way, until you press another key. - -You can check to see if the boot process has completed by pressing the 8 -key on the keypad, which reads the current line. This also has the -effect of starting Speakup talking again, so you can press keypad enter -to silence it again if the boot process has not completed. - -When the boot process is complete, you will arrive at a "login" prompt. -At this point, you'll need to type in your user id and password, as -provided by your system administrator. You will hear Speakup speak the -letters of your user id as you type it, but not the password. This is -because the password is not displayed on the screen for security -reasons. This has nothing to do with Speakup, it's a Linux security -feature. - -Once you've logged in, you can run any Linux command or program which is -allowed by your user id. Normal users will not be able to run programs -which require root privileges. - -When you are running a program or command, Speakup will automatically -speak new text as it arrives on the screen. You can at any time silence -the speech with keypad enter, or use any of the Speakup review keys. - -Here are some basic Speakup review keys, and a short description of what -they do. - -keypad 1 -- read previous character -keypad 2 -- read current character (pressing keypad 2 twice rapidly will speak - the current character phonetically) -keypad 3 -- read next character -keypad 4 -- read previous word -keypad 5 -- read current word (press twice rapidly to spell the current word) -keypad 6 -- read next word -keypad 7 -- read previous line -keypad 8 -- read current line (press twice rapidly to hear how much the - text on the current line is indented) -keypad 9 -- read next line -keypad period -- speak current cursor position and announce current - virtual console - -It's also worth noting that the insert key on the keypad is mapped -as the speakup key. Instead of pressing and releasing this key, as you -do under DOS or Windows, you hold it like a shift key, and press other -keys in combination with it. For example, repeatedly holding keypad -insert, from now on called speakup, and keypad enter will toggle the -speaking of new text on the screen on and off. This is not the same as -just pressing keypad enter by itself, which just silences the speech -until you hit another key. When you hit speakup plus keypad enter, -Speakup will say, "You turned me off.", or "Hey, that's better." When -Speakup is turned off, no new text on the screen will be spoken. You -can still use the reading controls to review the screen however. - -3. Using the Speakup Help System - -In order to enter the Speakup help system, press and hold the speakup -key (remember that this is the keypad insert key), and press the f1 key. -You will hear the message: - -"Press space to leave help, cursor up or down to scroll, or a letter to -go to commands in list." - -When you press the spacebar to leave the help system, you will hear: - -"Leaving help." - -While you are in the Speakup help system, you can scroll up or down -through the list of available commands using the cursor keys. The list -of commands is arranged in alphabetical order. If you wish to jump to -commands in a specific part of the alphabet, you may press the letter of -the alphabet you wish to jump to. - -You can also just explore by typing keyboard keys. Pressing keys will -cause Speakup to speak the command associated with that key. For -example, if you press the keypad 8 key, you will hear: - -"Keypad 8 is line, say current." - -You'll notice that some commands do not have keys assigned to them. -This is because they are very infrequently used commands, and are also -accessible through the sys system. We'll discuss the sys system later -in this manual. - -You'll also notice that some commands have two keys assigned to them. -This is because Speakup has a built in set of alternative key bindings -for laptop users. The alternate speakup key is the caps lock key. You -can press and hold the caps lock key, while pressing an alternate -speakup command key to activate the command. On most laptops, the -numeric keypad is defined as the keys in the j k l area of the keyboard. - -There is usually a function key which turns this keypad function on and -off, and some other key which controls the numlock state. Toggling the -keypad functionality on and off can become a royal pain. So, Speakup -gives you a simple way to get at an alternative set of key mappings for -your laptop. These are also available by default on desktop systems, -because Speakup does not know whether it is running on a desktop or -laptop. So you may choose which set of Speakup keys to use. Some -system administrators may have chosen to compile Speakup for a desktop -system without this set of alternate key bindings, but these details are -beyond the scope of this manual. To use the caps lock for its normal -purpose, hold the shift key while toggling the caps lock on and off. We -should note here, that holding the caps lock key and pressing the z key -will toggle the alternate j k l keypad on and off. - -4. Keys and Their Assigned Commands - -In this section, we'll go through a list of all the speakup keys and -commands. You can also get a list of commands and assigned keys from -the help system. - -The following list was taken from the speakupmap.map file. Key -assignments are on the left of the equal sign, and the associated -Speakup commands are on the right. The designation "spk" means to press -and hold the speakup key, a.k.a. keypad insert, a.k.a. caps lock, while -pressing the other specified key. - -spk key_f9 = punc_level_dec -spk key_f10 = punc_level_inc -spk key_f11 = reading_punc_dec -spk key_f12 = reading_punc_inc -spk key_1 = vol_dec -spk key_2 = vol_inc -spk key_3 = pitch_dec -spk key_4 = pitch_inc -spk key_5 = rate_dec -spk key_6 = rate_inc -key_kpasterisk = toggle_cursoring -spk key_kpasterisk = speakup_goto -spk key_f1 = speakup_help -spk key_f2 = set_win -spk key_f3 = clear_win -spk key_f4 = enable_win -spk key_f5 = edit_some -spk key_f6 = edit_most -spk key_f7 = edit_delim -spk key_f8 = edit_repeat -shift spk key_f9 = edit_exnum - key_kp7 = say_prev_line -spk key_kp7 = left_edge - key_kp8 = say_line -double key_kp8 = say_line_indent -spk key_kp8 = say_from_top - key_kp9 = say_next_line -spk key_kp9 = top_edge - key_kpminus = speakup_parked -spk key_kpminus = say_char_num - key_kp4 = say_prev_word -spk key_kp4 = say_from_left - key_kp5 = say_word -double key_kp5 = spell_word -spk key_kp5 = spell_phonetic - key_kp6 = say_next_word -spk key_kp6 = say_to_right - key_kpplus = say_screen -spk key_kpplus = say_win - key_kp1 = say_prev_char -spk key_kp1 = right_edge - key_kp2 = say_char -spk key_kp2 = say_to_bottom -double key_kp2 = say_phonetic_char - key_kp3 = say_next_char -spk key_kp3 = bottom_edge - key_kp0 = spk_key - key_kpdot = say_position -spk key_kpdot = say_attributes -key_kpenter = speakup_quiet -spk key_kpenter = speakup_off -key_sysrq = speech_kill - key_kpslash = speakup_cut -spk key_kpslash = speakup_paste -spk key_pageup = say_first_char -spk key_pagedown = say_last_char -key_capslock = spk_key - spk key_z = spk_lock -key_leftmeta = spk_key -ctrl spk key_0 = speakup_goto -spk key_u = say_prev_line -spk key_i = say_line -double spk key_i = say_line_indent -spk key_o = say_next_line -spk key_minus = speakup_parked -shift spk key_minus = say_char_num -spk key_j = say_prev_word -spk key_k = say_word -double spk key_k = spell_word -spk key_l = say_next_word -spk key_m = say_prev_char -spk key_comma = say_char -double spk key_comma = say_phonetic_char -spk key_dot = say_next_char -spk key_n = say_position - ctrl spk key_m = left_edge - ctrl spk key_y = top_edge - ctrl spk key_dot = right_edge -ctrl spk key_p = bottom_edge -spk key_apostrophe = say_screen -spk key_h = say_from_left -spk key_y = say_from_top -spk key_semicolon = say_to_right -spk key_p = say_to_bottom -spk key_slash = say_attributes - spk key_enter = speakup_quiet - ctrl spk key_enter = speakup_off - spk key_9 = speakup_cut -spk key_8 = speakup_paste -shift spk key_m = say_first_char - ctrl spk key_semicolon = say_last_char - -5. The Speakup Sys System - -The Speakup screen reader also creates a speakup subdirectory as a part -of the sys system. - -As a convenience, run as root - -ln -s /sys/accessibility/speakup /speakup - -to directly access speakup parameters from /speakup. -You can see these entries by typing the command: - -ls -1 /speakup/* - -If you issue the above ls command, you will get back something like -this: - -/speakup/attrib_bleep -/speakup/bell_pos -/speakup/bleep_time -/speakup/bleeps -/speakup/cursor_time -/speakup/delimiters -/speakup/ex_num -/speakup/key_echo -/speakup/keymap -/speakup/no_interrupt -/speakup/punc_all -/speakup/punc_level -/speakup/punc_most -/speakup/punc_some -/speakup/reading_punc -/speakup/repeats -/speakup/say_control -/speakup/say_word_ctl -/speakup/silent -/speakup/spell_delay -/speakup/synth -/speakup/synth_direct -/speakup/version - -/speakup/i18n: -announcements -characters -chartab -colors -ctl_keys -formatted -function_names -key_names -states - -/speakup/soft: -caps_start -caps_stop -delay_time -direct -freq -full_time -jiffy_delta -pitch -inflection -punct -rate -tone -trigger_time -voice -vol - -Notice the two subdirectories of /speakup: /speakup/i18n and -/speakup/soft. -The i18n subdirectory is described in a later section. -The files under /speakup/soft represent settings that are specific to the -driver for the software synthesizer. If you use the LiteTalk, your -synthesizer-specific settings would be found in /speakup/ltlk. In other words, -a subdirectory named /speakup/KWD is created to hold parameters specific -to the device whose keyword is KWD. -These parameters include volume, rate, pitch, and others. - -In addition to using the Speakup hot keys to change such things as -volume, pitch, and rate, you can also echo values to the appropriate -entry in the /speakup directory. This is very useful, since it -lets you control Speakup parameters from within a script. How you -would write such scripts is somewhat beyond the scope of this manual, -but I will include a couple of simple examples here to give you a -general idea of what such scripts can do. - -Suppose for example, that you wanted to control both the punctuation -level and the reading punctuation level at the same time. For -simplicity, we'll call them punc0, punc1, punc2, and punc3. The scripts -might look something like this: - -#!/bin/bash -# punc0 -# set punc and reading punc levels to 0 -echo 0 >/speakup/punc_level -echo 0 >/speakup/reading_punc -echo Punctuation level set to 0. - -#!/bin/bash -# punc1 -# set punc and reading punc levels to 1 -echo 1 >/speakup/punc_level -echo 1 >/speakup/reading_punc -echo Punctuation level set to 1. - -#!/bin/bash -# punc2 -# set punc and reading punc levels to 2 -echo 2 >/speakup/punc_level -echo 2 >/speakup/reading_punc -echo Punctuation level set to 2. - -#!/bin/bash -# punc3 -# set punc and reading punc levels to 3 -echo 3 >/speakup/punc_level -echo 3 >/speakup/reading_punc -echo Punctuation level set to 3. - -If you were to store these four small scripts in a directory in your -path, perhaps /usr/local/bin, and set the permissions to 755 with the -chmod command, then you could change the default reading punc and -punctuation levels at the same time by issuing just one command. For -example, if you were to execute the punc3 command at your shell prompt, -then the reading punc and punc level would both get set to 3. - -I should note that the above scripts were written to work with bash, but -regardless of which shell you use, you should be able to do something -similar. - -The Speakup sys system also has another interesting use. You can echo -Speakup parameters into the sys system in a script during system -startup, and speakup will return to your preferred parameters every time -the system is rebooted. - -Most of the Speakup sys parameters can be manipulated by a regular user -on the system. However, there are a few parameters that are dangerous -enough that they should only be manipulated by the root user on your -system. There are even some parameters that are read only, and cannot -be written to at all. For example, the version entry in the Speakup -sys system is read only. This is because there is no reason for a user -to tamper with the version number which is reported by Speakup. Doing -an ls -l on /speakup/version will return this: - --r--r--r-- 1 root root 0 Mar 21 13:46 /speakup/version - -As you can see, the version entry in the Speakup sys system is read -only, is owned by root, and belongs to the root group. Doing a cat of -/speakup/version will display the Speakup version number, like -this: - -cat /speakup/version -Speakup v-2.00 CVS: Thu Oct 21 10:38:21 EDT 2004 -synth dtlk version 1.1 - -The display shows the Speakup version number, along with the version -number of the driver for the current synthesizer. - -Looking at entries in the Speakup sys system can be useful in many -ways. For example, you might wish to know what level your volume is set -at. You could type: - -cat /speakup/KWD/vol -# Replace KWD with the keyword for your synthesizer, E.G., ltlk for LiteTalk. -5 - -The number five which comes back is the level at which the synthesizer -volume is set at. - -All the entries in the Speakup sys system are readable, some are -writable by root only, and some are writable by everyone. Unless you -know what you are doing, you should probably leave the ones that are -writable by root only alone. Most of the names are self explanatory. -Vol for controlling volume, pitch for pitch, inflection for pitch range, rate -for controlling speaking rate, etc. If you find one you aren't sure about, you -can post a query on the Speakup list. - -6. Changing Synthesizers - -It is possible to change to a different synthesizer while speakup is -running. In other words, it is not necessary to reboot the system -in order to use a different synthesizer. You can simply echo the -synthesizer keyword to the /speakup/synth sys entry. -Depending on your situation, you may wish to echo none to the synth -sys entry, to disable speech while one synthesizer is disconnected and -a second one is connected in its place. Then echo the keyword for the -new synthesizer into the synth sys entry in order to start speech -with the newly connected synthesizer. See the list of synthesizer -keywords in section 1 to find the keyword which matches your synth. - -7. Loading modules - -As mentioned earlier, Speakup can either be completely compiled into the -kernel, with the exception of the help module, or it can be compiled as -a series of modules. When compiled as modules, Speakup will only be -able to speak some of the bootup messages if your system administrator -has configured the system to load the modules at boo time. The modules -can be loaded after the file systems have been checked and mounted, or -from an initrd. There is a third possibility. Speakup can be compiled -with some components built into the kernel, and others as modules. As -we'll see in the next section, this is particularly useful when you are -working with software synthesizers. - -If Speakup is completely compiled as modules, then you must use the -modprobe command to load Speakup. You do this by loading the module for -the synthesizer driver you wish to use. The driver modules are all -named speakup_, where is the keyword for the -synthesizer you want. So, in order to load the driver for the DecTalk -Express, you would type the following command: - -modprobe speakup_dectlk - -Issuing this command would load the DecTalk Express driver and all other -related Speakup modules necessary to get Speakup up and running. - -To completely unload Speakup, again presuming that it is entirely built -as modules, you would give the command: - -modprobe -r speakup_dectlk - -The above command assumes you were running a DecTalk Express. If you -were using a different synth, then you would substitute its keyword in -place of dectlk. - -If you have multiple drivers loaded, you need to unload all of them, in -order to completely unload Speakup. -For example, if you have loaded both the dectlk and ltlk drivers, use the -command: -modprobe -r speakup_dectlk speakup_ltlk - -You cannot unload the driver for software synthesizers when a user-space -daemon is using /dev/softsynth. First, kill the daemon. Next, remove -the driver with the command: -modprobe -r speakup_soft - -Now, suppose we have a situation where the main Speakup component -is built into the kernel, and some or all of the drivers are built as -modules. Since the main part of Speakup is compiled into the kernel, a -partial Speakup sys system has been created which we can take advantage -of by simply echoing the synthesizer keyword into the -/speakup/synth sys entry. This will cause the kernel to -automatically load the appropriate driver module, and start Speakup -talking. To switch to another synth, just echo a new keyword to the -synth sys entry. For example, to load the DoubleTalk LT driver, -you would type: - -echo ltlk >/speakup/synth - -You can use the modprobe -r command to unload driver modules, regardless -of whether the main part of Speakup has been built into the kernel or -not. - -8. Using Software Synthesizers - -Using a software synthesizer requires that some other software be -installed and running on your system. For this reason, software -synthesizers are not available for use at bootup, or during a system -installation process. -There are two freely-available solutions for software speech: Espeakup and -Speech Dispatcher. -These are described in subsections 8.1 and 8.2, respectively. - -During the rest of this section, we assume that speakup_soft is either -built in to your kernel, or loaded as a module. - -If your system does not have udev installed , before you can use a -software synthesizer, you must have created the /dev/softsynth device. -If you have not already done so, issue the following commands as root: - -cd /dev -mknod softsynth c 10 26 - -While we are at it, we might just as well create the /dev/synth device, -which can be used to let user space programs send information to your -synthesizer. To create /dev/synth, change to the /dev directory, and -issue the following command as root: - -mknod synth c 10 25 - -of both. - -8.1. Espeakup - -Espeakup is a connector between Speakup and the eSpeak software synthesizer. -Espeakup may already be available as a package for your distribution -of Linux. If it is not packaged, you need to install it manually. -You can find it in the contrib/ subdirectory of the Speakup sources. -The filename is espeakup-$VERSION.tar.bz2, where $VERSION -depends on the current release of Espeakup. The Speakup 3.1.2 source -ships with version 0.71 of Espeakup. -The README file included with the Espeakup sources describes the process -of manual installation. - -Assuming that Espeakup is installed, either by the user or by the distributor, -follow these steps to use it. - -Tell Speakup to use the "soft driver: -echo soft > /speakup/synth - -Finally, start the espeakup program. There are two ways to do it. -Both require root privileges. - -If Espeakup was installed as a package for your Linux distribution, -you probably have a distribution-specific script that controls the operation -of the daemon. Look for a file named espeakup under /etc/init.d or -/etc/rc.d. Execute the following command with root privileges: -/etc/init.d/espeakup start -Replace init.d with rc.d, if your distribution uses scripts located under -/etc/rc.d. -Your distribution will also have a procedure for starting daemons at -boot-time, so it is possible to have software speech as soon as user-space -daemons are started by the bootup scripts. -These procedures are not described in this document. - -If you built Espeakup manually, the "make install" step placed the binary -under /usr/bin. -Run the following command as root: -/usr/bin/espeakup -Espeakup should start speaking. - -8.2. Speech Dispatcher - -For this option, you must have a package called -Speech Dispatcher running on your system, and it must be configured to -work with one of its supported software synthesizers. - -Two open source synthesizers you might use are Flite and Festival. You -might also choose to purchase the Software DecTalk from Fonix Sales Inc. -If you run a google search for Fonix, you'll find their web site. - -You can obtain a copy of Speech Dispatcher from free(b)soft at -http://www.freebsoft.org/. Follow the installation instructions that -come with Speech Dispatcher in order to install and configure Speech -Dispatcher. You can check out the web site for your Linux distribution -in order to get a copy of either Flite or Festival. Your Linux -distribution may also have a precompiled Speech Dispatcher package. - -Once you've installed, configured, and tested Speech Dispatcher with your -chosen software synthesizer, you still need one more piece of software -in order to make things work. You need a package called speechd-up. -You get it from the free(b)soft web site mentioned above. After you've -compiled and installed speechd-up, you are almost ready to begin using -your software synthesizer. - -Now you can begin using your software synthesizer. In order to do so, -echo the soft keyword to the synth sys entry like this: - -echo soft >/speakup/synth - -Next run the speechd_up command like this: - -speechd_up & - -Your synth should now start talking, and you should be able to adjust -the pitch, rate, etc. - -9. Using The DecTalk PC Card - -The DecTalk PC card is an ISA card that is inserted into one of the ISA -slots in your computer. It requires that the DecTalk PC software be -installed on your computer, and that the software be loaded onto the -Dectalk PC card before it can be used. - -You can get the dec_pc.tgz file from the linux-speakup.org site. The -dec_pc.tgz file is in the ~ftp/pub/linux/speakup directory. - -After you have downloaded the dec_pc.tgz file, untar it in your home -directory, and read the Readme file in the newly created dec_pc -directory. - -The easiest way to get the software working is to copy the entire dec_pc -directory into /user/local/lib. To do this, su to root in your home -directory, and issue the command: - -cp dec_pc /usr/local/lib - -You will need to copy the dtload command from the dec_pc directory to a -directory in your path. Either /usr/bin or /usr/local/bin is a good -choice. - -You can now run the dtload command in order to load the DecTalk PC -software onto the card. After you have done this, echo the decpc -keyword to the synth entry in the sys system like this: - -echo decpc >/speakup/synth - -Your DecTalk PC should start talking, and then you can adjust the pitch, -rate, volume, voice, etc. The voice entry in the Speakup sys system -will accept a number from 0 through 7 for the DecTalk PC synthesizer, -which will give you access to some of the DecTalk voices. - -10. Using Cursor Tracking - -In Speakup version 2.0 and later, cursor tracking is turned on by -default. This means that when you are using an editor, Speakup will -automatically speak characters as you move left and right with the -cursor keys, and lines as you move up and down with the cursor keys. -This is the traditional sort of cursor tracking. -Recent versions of Speakup provide two additional ways to control the -text that is spoken when the cursor is moved: -"highlight tracking" and "read window." -They are described later in this section. -Sometimes, these modes get in your way, so you can disable cursor tracking -altogether. - -You may select among the various forms of cursor tracking using the keypad -asterisk key. -Each time you press this key, a new mode is selected, and Speakup speaks -the name of the new mode. The names for the four possible states of cursor -tracking are: "cursoring on", "highlight tracking", "read window", -and "cursoring off." The keypad asterisk key moves through the list of -modes in a circular fashion. - -If highlight tracking is enabled, Speakup tracks highlighted text, -rather than the cursor itself. When you move the cursor with the arrow keys, -Speakup speaks the currently highlighted information. -This is useful when moving through various menus and dialog boxes. -If cursor tracking isn't helping you while navigating a menu, -try highlight tracking. - -With the "read window" variety of cursor tracking, you can limit the text -that Speakup speaks by specifying a window of interest on the screen. -See section 15 for a description of the process of defining windows. -When you move the cursor via the arrow keys, Speakup only speaks -the contents of the window. This is especially helpful when you are hearing -superfluous speech. Consider the following example. - -Suppose that you are at a shell prompt. You use bash, and you want to -explore your command history using the up and down arrow keys. If you -have enabled cursor tracking, you will hear two pieces of information. -Speakup speaks both your shell prompt and the current entry from the -command history. You may not want to hear the prompt repeated -each time you move, so you can silence it by specifying a window. Find -the last line of text on the screen. Clear the current window by pressing -the key combination speakup f3. Use the review cursor to find the first -character that follows your shell prompt. Press speakup + f2 twice, to -define a one-line window. The boundaries of the window are the -character following the shell prompt and the end of the line. Now, cycle -through the cursor tracking modes using keypad asterisk, until Speakup -says "read window." Move through your history using your arrow keys. -You will notice that Speakup no longer speaks the redundant prompt. - -Some folks like to turn cursor tracking off while they are using the -lynx web browser. You definitely want to turn cursor tracking off when -you are using the alsamixer application. Otherwise, you won't be able -to hear your mixer settings while you are using the arrow keys. - -11. Cut and Paste - -One of Speakup's more useful features is the ability to cut and paste -text on the screen. This means that you can capture information from a -program, and paste that captured text into a different place in the -program, or into an entirely different program, which may even be -running on a different console. - -For example, in this manual, we have made references to several web -sites. It would be nice if you could cut and paste these urls into your -web browser. Speakup does this quite nicely. Suppose you wanted to -past the following url into your browser: - -http://linux-speakup.org/ - -Use the speakup review keys to position the reading cursor on the first -character of the above url. When the reading cursor is in position, -press the keypad slash key once. Speakup will say, "mark". Next, -position the reading cursor on the rightmost character of the above -url. Press the keypad slash key once again to actually cut the text -from the screen. Speakup will say, "cut". Although we call this -cutting, Speakup does not actually delete the cut text from the screen. -It makes a copy of the text in a special buffer for later pasting. - -Now that you have the url cut from the screen, you can paste it into -your browser, or even paste the url on a command line as an argument to -your browser. - -Suppose you want to start lynx and go to the Speakup site. - -You can switch to a different console with the alt left and right -arrows, or you can switch to a specific console by typing alt and a -function key. These are not Speakup commands, just standard Linux -console capabilities. - -Once you've changed to an appropriate console, and are at a shell prompt, -type the word lynx, followed by a space. Now press and hold the speakup -key, while you type the keypad slash character. The url will be pasted -onto the command line, just as though you had typed it in. Press the -enter key to execute the command. - -The paste buffer will continue to hold the cut information, until a new -mark and cut operation is carried out. This means you can paste the cut -information as many times as you like before doing another cut -operation. - -You are not limited to cutting and pasting only one line on the screen. -You can also cut and paste rectangular regions of the screen. Just -position the reading cursor at the top left corner of the text to be -cut, mark it with the keypad slash key, then position the reading cursor -at the bottom right corner of the region to be cut, and cut it with the -keypad slash key. - -12. Changing the Pronunciation of Characters - -Through the /speakup/i18n/characters sys entry, Speakup gives you the -ability to change how Speakup pronounces a given character. You could, -for example, change how some punctuation characters are spoken. You can -even change how Speakup will pronounce certain letters. - -You may, for example, wish to change how Speakup pronounces the z -character. The author of Speakup, Kirk Reiser, is Canadian, and thus -believes that the z should be pronounced zed. If you are an American, -you might wish to use the zee pronunciation instead of zed. You can -change the pronunciation of both the upper and lower case z with the -following two commands: - -echo 90 zee >/speakup/characters -echo 122 zee >/speakup/characters - -Let's examine the parts of the two previous commands. They are issued -at the shell prompt, and could be placed in a startup script. - -The word echo tells the shell that you want to have it display the -string of characters that follow the word echo. If you were to just -type: - -echo hello. - -You would get the word hello printed on your screen as soon as you -pressed the enter key. In this case, we are echoing strings that we -want to be redirected into the sys system. - -The numbers 90 and 122 in the above echo commands are the ascii numeric -values for the upper and lower case z, the characters we wish to change. - -The string zee is the pronunciation that we want Speakup to use for the -upper and lower case z. - -The > symbol redirects the output of the echo command to a file, just -like in DOS, or at the Windows command prompt. - -And finally, /speakup/i18n/characters is the file entry in the sys system -where we want the output to be directed. Speakup looks at the numeric -value of the character we want to change, and inserts the pronunciation -string into an internal table. - -You can look at the whole table with the following command: - -cat /speakup/i18n/characters - -Speakup will then print out the entire character pronunciation table. I -won't display it here, but leave you to look at it at your convenience. - -13. Mapping Keys - -Speakup has the capability of allowing you to assign or "map" keys to -internal Speakup commands. This section necessarily assumes you have a -Linux kernel source tree installed, and that it has been patched and -configured with Speakup. How you do this is beyond the scope of this -manual. For this information, visit the Speakup web site at -http://linux-speakup.org/. The reason you'll need the kernel source -tree patched with Speakup is that the genmap utility you'll need for -processing keymaps is in the -/usr/src/linux-/drivers/char/speakup directory. The - in the above directory path is the version number of -the Linux source tree you are working with. - -So ok, you've gone off and gotten your kernel source tree, and patched -and configured it. Now you can start manipulating keymaps. - -You can either use the -/usr/src/linux-/drivers/char/speakup/speakupmap.map file -included with the Speakup source, or you can cut and paste the copy in -section 4 into a separate file. If you use the one in the Speakup -source tree, make sure you make a backup of it before you start making -changes. You have been warned! - -Suppose that you want to swap the key assignments for the Speakup -say_last_char and the Speakup say_first_char commands. The -speakupmap.map lists the key mappings for these two commands as follows: - -spk key_pageup = say_first_char -spk key_pagedown = say_last_char - -You can edit your copy of the speakupmap.map file and swap the command -names on the right side of the = (equals) sign. You did make a backup, -right? The new keymap lines would look like this: - -spk key_pageup = say_last_char -spk key_pagedown = say_first_char - -After you edit your copy of the speakupmap.map file, save it under a new -file name, perhaps newmap.map. Then exit your editor and return to the -shell prompt. - -You are now ready to load your keymap with your swapped key assignments. - Assuming that you saved your new keymap as the file newmap.map, you -would load your keymap into the sys system like this: - -/usr/src/linux-/drivers/char/speakup/genmap newmap.map ->/speakup/keymap - -Remember to substitute your kernel version number for the - in the above command. Also note that although the -above command wrapped onto two lines in this document, you should type -it all on one line. - -Your say first and say last characters should now be swapped. Pressing -speakup pagedown should read you the first non-whitespace character on -the line your reading cursor is in, and pressing speakup pageup should -read you the last character on the line your reading cursor is in. - -You should note that these new mappings will only stay in effect until -you reboot, or until you load another keymap. - -One final warning. If you try to load a partial map, you will quickly -find that all the mappings you didn't include in your file got deleted -from the working map. Be extremely careful, and always make a backup! -You have been warned! - -14. Internationalizing Speakup - -Speakup indicates various conditions to the user by speaking messages. -For instance, when you move to the left edge of the screen with the -review keys, Speakup says, "left." -Prior to version 3.1.0 of Speakup, all of these messages were in English, -and they could not be changed. If you used a non-English synthesizer, -you still heard English messages, such as "left" and "cursoring on." -In version 3.1.0 or higher, one may load translations for the various -messages via the /sys filesystem. - -The directory /speakup/i18n contains several collections of messages. -Each group of messages is stored in its own file. -The following section lists all of these files, along with a brief description -of each. - -14.1. Files Under the i18n Subdirectory - -* announcements: -This file contains various general announcements, most of which cannot -be categorized. You will find messages such as "You killed Speakup", -"I'm alive", "leaving help", "parked", "unparked", and others. -You will also find the names of the screen edges and cursor tracking modes -here. - -* characters: -See section 12 for a description of this file. - -* chartab: -See section 12. Unlike the rest of the files in the i18n subdirectory, -this one does not contain messages to be spoken. - -* colors: -When you use the "say attributes" function, Speakup says the name of the -foreground and background colors. These names come from the i18n/colors -file. - -* ctl_keys: -Here, you will find names of control keys. These are used with Speakup's -say_control feature. - -* formatted: -This group of messages contains embedded formatting codes, to specify -the type and width of displayed data. If you change these, you must -preserve all of the formatting codes, and they must appear in the order -used by the default messages. - -* function_names: -Here, you will find a list of names for Speakup functions. These are used -by the help system. For example, suppose that you have activated help mode, -and you pressed keypad 3. Speakup says: -"keypad 3 is character, say next." -The message "character, say next" names a Speakup function, and it -comes from this function_names file. - -* key_names: -Again, key_names is used by Speakup's help system. In the previous -example, Speakup said that you pressed "keypad 3." -This name came from the key_names file. - -* states: -This file contains names for key states. -Again, these are part of the help system. For instance, if you had pressed -speakup + keypad 3, you would hear: -"speakup keypad 3 is go to bottom edge." -The speakup key is depressed, so the name of the key state is speakup. -This part of the message comes from the states collection. - -14.2. Loading Your Own Messages - -The files under the i18n subdirectory all follow the same format. -They consist of lines, with one message per line. -Each message is represented by a number, followed by the text of the message. -The number is the position of the message in the given collection. -For example, if you view the file /speakup/i18n/colors, you will see the -following list: - -0 black -1 blue -2 green -3 cyan -4 red -5 magenta -6 yellow -7 white -8 grey - -You can change one message, or you can change a whole group. -To load a whole collection of messages from a new source, simply use -the cp command: -cp ~/my_colors /speakup/i18n/colors -You can change an individual message with the echo command, -as shown in the following example. - -The Spanish name for the color blue is azul. -Looking at the colors file, we see that the name "blue" is at position 1 -within the colors group. Let's change blue to azul: -echo '1 azul' > /speakup/i18n/colors -The next time that Speakup says message 1 from the colors group, it will -say "azul", rather than "blue." - -In the future, translations into various languages will be made available, -and most users will just load the files necessary for their language. - -14.3. No Support for Non-Western-European Languages - -As of the current release, Speakup only supports Western European languages. -Support for the extended characters used by languages outside of the Western -European family of languages is a work in progress. - -15. Using Speakup's Windowing Capability - -Speakup has the capability of defining and manipulating windows on the -screen. Speakup uses the term "Window", to mean a user defined area of -the screen. The key strokes for defining and manipulating Speakup -windows are as follows: - -speakup + f2 -- Set the bounds of the window. -Speakup + f3 -- clear the current window definition. -speakup + f4 -- Toggle window silence on and off. -speakup + keypad plus -- Say the currently defined window. - -These capabilities are useful for tracking a certain part of the screen -without rereading the whole screen, or for silencing a part of the -screen that is constantly changing, such as a clock or status line. - -There is no way to save these window settings, and you can only have one -window defined for each virtual console. There is also no way to have -windows automatically defined for specific applications. - -In order to define a window, use the review keys to move your reading -cursor to the beginning of the area you want to define. Then press -speakup + f2. Speakup will tell you that the window starts at the -indicated row and column position. Then move the reading cursor to the -end of the area to be defined as a window, and press speakup + f2 again. - If there is more than one line in the window, Speakup will tell you -that the window ends at the indicated row and column position. If there -is only one line in the window, then Speakup will tell you that the -window is the specified line on the screen. If you are only defining a -one line window, you can just press speakup + f2 twice after placing the -reading cursor on the line you want to define as a window. It is not -necessary to position the reading cursor at the end of the line in order -to define the whole line as a window. - -16. Tools for Controlling Speakup - -The speakup distribution includes extra tools (in the tools directory) -which were written to make speakup easier to use. This section will -briefly describe the use of these tools. - -16.1. Speakupconf - -speakupconf began life as a contribution from Steve Holmes, a member of -the speakup community. We would like to thank him for his work on the -early versions of this project. - -This script may be installed as part of your linux distribution, but if -it isn't, the recommended places to put it are /usr/local/bin or -/usr/bin. This script can be run by any user, so it does not require -root privileges. - -Speakupconf allows you to save and load your Speakup settings. It works -by reading and writing the /sys files described above. - -The directory that speakupconf uses to store your settings depends on -whether it is run from the root account. If you execute speakupconf as -root, it uses the directory /etc/speakup. Otherwise, it uses the directory -~/.speakup, where ~ is your home directory. -Anyone who needs to use Speakup from your console can load his own custom -settings with this script. - -speakupconf takes one required argument: load or save. -Use the command -speakupconf save -to save your Speakup settings, and -speakupconf load -to load them into Speakup. -A second argument may be specified to use an alternate directory to -load or save the speakup parameters. - -16.2. Talkwith - -Charles Hallenbeck, another member of the speakup community, wrote the -initial versions of this script, and we would also like to thank him for -his work on it. - -This script needs root privileges to run, so if it is not installed as -part of your linux distribution, the recommended places to install it -are /usr/local/sbin or /usr/sbin. - -Talkwith allows you to switch synthesizers on the fly. It takes a synthesizer -name as an argument. For instance, -talkwith dectlk -causes Speakup to use the DecTalk Express. If you wish to switch to a -software synthesizer, you must also indicate which daemon you wish to -use. There are two possible choices: -spd and espeakup. spd is an abbreviation for speechd-up. -If you wish to use espeakup for software synthesis, give the command -talkwith soft espeakup -To use speechd-up, type: -talkwith soft spd -Any arguments that follow the name of the daemon are passed to the daemon -when it is invoked. For instance: -talkwith espeakup --default-voice=fr -causes espeakup to use the French voice. -Note that talkwith must always be executed with root privileges. - -Talkwith does not attempt to load your settings after the new -synthesizer is activated. You can use speakupconf to load your settings -if desired. - - GNU Free Documentation License - Version 1.2, November 2002 - - - Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - -0. PREAMBLE - -The purpose of this License is to make a manual, textbook, or other -functional and useful document "free" in the sense of freedom: to -assure everyone the effective freedom to copy and redistribute it, -with or without modifying it, either commercially or noncommercially. -Secondarily, this License preserves for the author and publisher a way -to get credit for their work, while not being considered responsible -for modifications made by others. - -This License is a kind of "copyleft", which means that derivative -works of the document must themselves be free in the same sense. It -complements the GNU General Public License, which is a copyleft -license designed for free software. - -We have designed this License in order to use it for manuals for free -software, because free software needs free documentation: a free -program should come with manuals providing the same freedoms that the -software does. But this License is not limited to software manuals; -it can be used for any textual work, regardless of subject matter or -whether it is published as a printed book. We recommend this License -principally for works whose purpose is instruction or reference. - - -1. APPLICABILITY AND DEFINITIONS - -This License applies to any manual or other work, in any medium, that -contains a notice placed by the copyright holder saying it can be -distributed under the terms of this License. Such a notice grants a -world-wide, royalty-free license, unlimited in duration, to use that -work under the conditions stated herein. The "Document", below, -refers to any such manual or work. Any member of the public is a -licensee, and is addressed as "you". You accept the license if you -copy, modify or distribute the work in a way requiring permission -under copyright law. - -A "Modified Version" of the Document means any work containing the -Document or a portion of it, either copied verbatim, or with -modifications and/or translated into another language. - -A "Secondary Section" is a named appendix or a front-matter section of -the Document that deals exclusively with the relationship of the -publishers or authors of the Document to the Document's overall subject -(or to related matters) and contains nothing that could fall directly -within that overall subject. (Thus, if the Document is in part a -textbook of mathematics, a Secondary Section may not explain any -mathematics.) The relationship could be a matter of historical -connection with the subject or with related matters, or of legal, -commercial, philosophical, ethical or political position regarding -them. - -The "Invariant Sections" are certain Secondary Sections whose titles -are designated, as being those of Invariant Sections, in the notice -that says that the Document is released under this License. If a -section does not fit the above definition of Secondary then it is not -allowed to be designated as Invariant. The Document may contain zero -Invariant Sections. If the Document does not identify any Invariant -Sections then there are none. - -The "Cover Texts" are certain short passages of text that are listed, -as Front-Cover Texts or Back-Cover Texts, in the notice that says that -the Document is released under this License. A Front-Cover Text may -be at most 5 words, and a Back-Cover Text may be at most 25 words. - -A "Transparent" copy of the Document means a machine-readable copy, -represented in a format whose specification is available to the -general public, that is suitable for revising the document -straightforwardly with generic text editors or (for images composed of -pixels) generic paint programs or (for drawings) some widely available -drawing editor, and that is suitable for input to text formatters or -for automatic translation to a variety of formats suitable for input -to text formatters. A copy made in an otherwise Transparent file -format whose markup, or absence of markup, has been arranged to thwart -or discourage subsequent modification by readers is not Transparent. -An image format is not Transparent if used for any substantial amount -of text. A copy that is not "Transparent" is called "Opaque". - -Examples of suitable formats for Transparent copies include plain -ASCII without markup, Texinfo input format, LaTeX input format, SGML -or XML using a publicly available DTD, and standard-conforming simple -HTML, PostScript or PDF designed for human modification. Examples of -transparent image formats include PNG, XCF and JPG. Opaque formats -include proprietary formats that can be read and edited only by -proprietary word processors, SGML or XML for which the DTD and/or -processing tools are not generally available, and the -machine-generated HTML, PostScript or PDF produced by some word -processors for output purposes only. - -The "Title Page" means, for a printed book, the title page itself, -plus such following pages as are needed to hold, legibly, the material -this License requires to appear in the title page. For works in -formats which do not have any title page as such, "Title Page" means -the text near the most prominent appearance of the work's title, -preceding the beginning of the body of the text. - -A section "Entitled XYZ" means a named subunit of the Document whose -title either is precisely XYZ or contains XYZ in parentheses following -text that translates XYZ in another language. (Here XYZ stands for a -specific section name mentioned below, such as "Acknowledgements", -"Dedications", "Endorsements", or "History".) To "Preserve the Title" -of such a section when you modify the Document means that it remains a -section "Entitled XYZ" according to this definition. - -The Document may include Warranty Disclaimers next to the notice which -states that this License applies to the Document. These Warranty -Disclaimers are considered to be included by reference in this -License, but only as regards disclaiming warranties: any other -implication that these Warranty Disclaimers may have is void and has -no effect on the meaning of this License. - - -2. VERBATIM COPYING - -You may copy and distribute the Document in any medium, either -commercially or noncommercially, provided that this License, the -copyright notices, and the license notice saying this License applies -to the Document are reproduced in all copies, and that you add no other -conditions whatsoever to those of this License. You may not use -technical measures to obstruct or control the reading or further -copying of the copies you make or distribute. However, you may accept -compensation in exchange for copies. If you distribute a large enough -number of copies you must also follow the conditions in section 3. - -You may also lend copies, under the same conditions stated above, and -you may publicly display copies. - - -3. COPYING IN QUANTITY - -If you publish printed copies (or copies in media that commonly have -printed covers) of the Document, numbering more than 100, and the -Document's license notice requires Cover Texts, you must enclose the -copies in covers that carry, clearly and legibly, all these Cover -Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on -the back cover. Both covers must also clearly and legibly identify -you as the publisher of these copies. The front cover must present -the full title with all words of the title equally prominent and -visible. You may add other material on the covers in addition. -Copying with changes limited to the covers, as long as they preserve -the title of the Document and satisfy these conditions, can be treated -as verbatim copying in other respects. - -If the required texts for either cover are too voluminous to fit -legibly, you should put the first ones listed (as many as fit -reasonably) on the actual cover, and continue the rest onto adjacent -pages. - -If you publish or distribute Opaque copies of the Document numbering -more than 100, you must either include a machine-readable Transparent -copy along with each Opaque copy, or state in or with each Opaque copy -a computer-network location from which the general network-using -public has access to download using public-standard network protocols -a complete Transparent copy of the Document, free of added material. -If you use the latter option, you must take reasonably prudent steps, -when you begin distribution of Opaque copies in quantity, to ensure -that this Transparent copy will remain thus accessible at the stated -location until at least one year after the last time you distribute an -Opaque copy (directly or through your agents or retailers) of that -edition to the public. - -It is requested, but not required, that you contact the authors of the -Document well before redistributing any large number of copies, to give -them a chance to provide you with an updated version of the Document. - - -4. MODIFICATIONS - -You may copy and distribute a Modified Version of the Document under -the conditions of sections 2 and 3 above, provided that you release -the Modified Version under precisely this License, with the Modified -Version filling the role of the Document, thus licensing distribution -and modification of the Modified Version to whoever possesses a copy -of it. In addition, you must do these things in the Modified Version: - -A. Use in the Title Page (and on the covers, if any) a title distinct - from that of the Document, and from those of previous versions - (which should, if there were any, be listed in the History section - of the Document). You may use the same title as a previous version - if the original publisher of that version gives permission. -B. List on the Title Page, as authors, one or more persons or entities - responsible for authorship of the modifications in the Modified - Version, together with at least five of the principal authors of the - Document (all of its principal authors, if it has fewer than five), - unless they release you from this requirement. -C. State on the Title page the name of the publisher of the - Modified Version, as the publisher. -D. Preserve all the copyright notices of the Document. -E. Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices. -F. Include, immediately after the copyright notices, a license notice - giving the public permission to use the Modified Version under the - terms of this License, in the form shown in the Addendum below. -G. Preserve in that license notice the full lists of Invariant Sections - and required Cover Texts given in the Document's license notice. -H. Include an unaltered copy of this License. -I. Preserve the section Entitled "History", Preserve its Title, and add - to it an item stating at least the title, year, new authors, and - publisher of the Modified Version as given on the Title Page. If - there is no section Entitled "History" in the Document, create one - stating the title, year, authors, and publisher of the Document as - given on its Title Page, then add an item describing the Modified - Version as stated in the previous sentence. -J. Preserve the network location, if any, given in the Document for - public access to a Transparent copy of the Document, and likewise - the network locations given in the Document for previous versions - it was based on. These may be placed in the "History" section. - You may omit a network location for a work that was published at - least four years before the Document itself, or if the original - publisher of the version it refers to gives permission. -K. For any section Entitled "Acknowledgements" or "Dedications", - Preserve the Title of the section, and preserve in the section all - the substance and tone of each of the contributor acknowledgements - and/or dedications given therein. -L. Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section titles. -M. Delete any section Entitled "Endorsements". Such a section - may not be included in the Modified Version. -N. Do not retitle any existing section to be Entitled "Endorsements" - or to conflict in title with any Invariant Section. -O. Preserve any Warranty Disclaimers. - -If the Modified Version includes new front-matter sections or -appendices that qualify as Secondary Sections and contain no material -copied from the Document, you may at your option designate some or all -of these sections as invariant. To do this, add their titles to the -list of Invariant Sections in the Modified Version's license notice. -These titles must be distinct from any other section titles. - -You may add a section Entitled "Endorsements", provided it contains -nothing but endorsements of your Modified Version by various -parties--for example, statements of peer review or that the text has -been approved by an organization as the authoritative definition of a -standard. - -You may add a passage of up to five words as a Front-Cover Text, and a -passage of up to 25 words as a Back-Cover Text, to the end of the list -of Cover Texts in the Modified Version. Only one passage of -Front-Cover Text and one of Back-Cover Text may be added by (or -through arrangements made by) any one entity. If the Document already -includes a cover text for the same cover, previously added by you or -by arrangement made by the same entity you are acting on behalf of, -you may not add another; but you may replace the old one, on explicit -permission from the previous publisher that added the old one. - -The author(s) and publisher(s) of the Document do not by this License -give permission to use their names for publicity for or to assert or -imply endorsement of any Modified Version. - - -5. COMBINING DOCUMENTS - -You may combine the Document with other documents released under this -License, under the terms defined in section 4 above for modified -versions, provided that you include in the combination all of the -Invariant Sections of all of the original documents, unmodified, and -list them all as Invariant Sections of your combined work in its -license notice, and that you preserve all their Warranty Disclaimers. - -The combined work need only contain one copy of this License, and -multiple identical Invariant Sections may be replaced with a single -copy. If there are multiple Invariant Sections with the same name but -different contents, make the title of each such section unique by -adding at the end of it, in parentheses, the name of the original -author or publisher of that section if known, or else a unique number. -Make the same adjustment to the section titles in the list of -Invariant Sections in the license notice of the combined work. - -In the combination, you must combine any sections Entitled "History" -in the various original documents, forming one section Entitled -"History"; likewise combine any sections Entitled "Acknowledgements", -and any sections Entitled "Dedications". You must delete all sections -Entitled "Endorsements". - - -6. COLLECTIONS OF DOCUMENTS - -You may make a collection consisting of the Document and other documents -released under this License, and replace the individual copies of this -License in the various documents with a single copy that is included in -the collection, provided that you follow the rules of this License for -verbatim copying of each of the documents in all other respects. - -You may extract a single document from such a collection, and distribute -it individually under this License, provided you insert a copy of this -License into the extracted document, and follow this License in all -other respects regarding verbatim copying of that document. - - -7. AGGREGATION WITH INDEPENDENT WORKS - -A compilation of the Document or its derivatives with other separate -and independent documents or works, in or on a volume of a storage or -distribution medium, is called an "aggregate" if the copyright -resulting from the compilation is not used to limit the legal rights -of the compilation's users beyond what the individual works permit. -When the Document is included in an aggregate, this License does not -apply to the other works in the aggregate which are not themselves -derivative works of the Document. - -If the Cover Text requirement of section 3 is applicable to these -copies of the Document, then if the Document is less than one half of -the entire aggregate, the Document's Cover Texts may be placed on -covers that bracket the Document within the aggregate, or the -electronic equivalent of covers if the Document is in electronic form. -Otherwise they must appear on printed covers that bracket the whole -aggregate. - - -8. TRANSLATION - -Translation is considered a kind of modification, so you may -distribute translations of the Document under the terms of section 4. -Replacing Invariant Sections with translations requires special -permission from their copyright holders, but you may include -translations of some or all Invariant Sections in addition to the -original versions of these Invariant Sections. You may include a -translation of this License, and all the license notices in the -Document, and any Warranty Disclaimers, provided that you also include -the original English version of this License and the original versions -of those notices and disclaimers. In case of a disagreement between -the translation and the original version of this License or a notice -or disclaimer, the original version will prevail. - -If a section in the Document is Entitled "Acknowledgements", -"Dedications", or "History", the requirement (section 4) to Preserve -its Title (section 1) will typically require changing the actual -title. - - -9. TERMINATION - -You may not copy, modify, sublicense, or distribute the Document except -as expressly provided for under this License. Any other attempt to -copy, modify, sublicense or distribute the Document is void, and will -automatically terminate your rights under this License. However, -parties who have received copies, or rights, from you under this -License will not have their licenses terminated so long as such -parties remain in full compliance. - - -10. FUTURE REVISIONS OF THIS LICENSE - -The Free Software Foundation may publish new, revised versions -of the GNU Free Documentation License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. See -https://www.gnu.org/copyleft/. - -Each version of the License is given a distinguishing version number. -If the Document specifies that a particular numbered version of this -License "or any later version" applies to it, you have the option of -following the terms and conditions either of that specified version or -of any later version that has been published (not as a draft) by the -Free Software Foundation. If the Document does not specify a version -number of this License, you may choose any version ever published (not -as a draft) by the Free Software Foundation. - - -ADDENDUM: How to use this License for your documents - -To use this License in a document you have written, include a copy of -the License in the document and put the following copyright and -license notices just after the title page: - - Copyright (c) YEAR YOUR NAME. - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.2 - or any later version published by the Free Software Foundation; - with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. - A copy of the license is included in the section entitled "GNU - Free Documentation License". - -If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, -replace the "with...Texts." line with this: - - with the Invariant Sections being LIST THEIR TITLES, with the - Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. - -If you have Invariant Sections without Cover Texts, or some other -combination of the three, merge those two alternatives to suit the -situation. - -If your document contains nontrivial examples of program code, we -recommend releasing these examples in parallel under your choice of -free software license, such as the GNU General Public License, -to permit their use in free software. - -The End. diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c deleted file mode 100644 index 3568bfb89912..000000000000 --- a/drivers/staging/speakup/synth.c +++ /dev/null @@ -1,490 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include /* for isdigit() and friends */ -#include -#include /* for verify_area */ -#include /* for -EBUSY */ -#include /* for check_region, request_region */ -#include -#include /* for loops_per_sec */ -#include -#include -#include /* for copy_from_user */ -#include -#include -#include - -#include "spk_priv.h" -#include "speakup.h" -#include "serialio.h" - -static LIST_HEAD(synths); -struct spk_synth *synth; -char spk_pitch_buff[32] = ""; -static int module_status; -bool spk_quiet_boot; - -struct speakup_info_t speakup_info = { - /* - * This spinlock is used to protect the entire speakup machinery, and - * must be taken at each kernel->speakup transition and released at - * each corresponding speakup->kernel transition. - * - * The progression thread only interferes with the speakup machinery - * through the synth buffer, so only needs to take the lock - * while tinkering with the buffer. - * - * We use spin_lock/trylock_irqsave and spin_unlock_irqrestore with this - * spinlock because speakup needs to disable the keyboard IRQ. - */ - .spinlock = __SPIN_LOCK_UNLOCKED(speakup_info.spinlock), - .flushing = 0, -}; -EXPORT_SYMBOL_GPL(speakup_info); - -static int do_synth_init(struct spk_synth *in_synth); - -/* - * Main loop of the progression thread: keep eating from the buffer - * and push to the serial port, waiting as needed - * - * For devices that have a "full" notification mechanism, the driver can - * adapt the loop the way they prefer. - */ -static void _spk_do_catch_up(struct spk_synth *synth, int unicode) -{ - u16 ch; - unsigned long flags; - unsigned long jiff_max; - struct var_t *delay_time; - struct var_t *full_time; - struct var_t *jiffy_delta; - int jiffy_delta_val; - int delay_time_val; - int full_time_val; - int ret; - - jiffy_delta = spk_get_var(JIFFY); - full_time = spk_get_var(FULL); - delay_time = spk_get_var(DELAY); - - spin_lock_irqsave(&speakup_info.spinlock, flags); - jiffy_delta_val = jiffy_delta->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - - jiff_max = jiffies + jiffy_delta_val; - while (!kthread_should_stop()) { - spin_lock_irqsave(&speakup_info.spinlock, flags); - if (speakup_info.flushing) { - speakup_info.flushing = 0; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - synth->flush(synth); - continue; - } - if (!unicode) - synth_buffer_skip_nonlatin1(); - if (synth_buffer_empty()) { - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - break; - } - ch = synth_buffer_peek(); - set_current_state(TASK_INTERRUPTIBLE); - full_time_val = full_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (ch == '\n') - ch = synth->procspeech; - if (unicode) - ret = synth->io_ops->synth_out_unicode(synth, ch); - else - ret = synth->io_ops->synth_out(synth, ch); - if (!ret) { - schedule_timeout(msecs_to_jiffies(full_time_val)); - continue; - } - if (time_after_eq(jiffies, jiff_max) && (ch == SPACE)) { - spin_lock_irqsave(&speakup_info.spinlock, flags); - jiffy_delta_val = jiffy_delta->u.n.value; - delay_time_val = delay_time->u.n.value; - full_time_val = full_time->u.n.value; - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (synth->io_ops->synth_out(synth, synth->procspeech)) - schedule_timeout( - msecs_to_jiffies(delay_time_val)); - else - schedule_timeout( - msecs_to_jiffies(full_time_val)); - jiff_max = jiffies + jiffy_delta_val; - } - set_current_state(TASK_RUNNING); - spin_lock_irqsave(&speakup_info.spinlock, flags); - synth_buffer_getc(); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - } - synth->io_ops->synth_out(synth, synth->procspeech); -} - -void spk_do_catch_up(struct spk_synth *synth) -{ - _spk_do_catch_up(synth, 0); -} -EXPORT_SYMBOL_GPL(spk_do_catch_up); - -void spk_do_catch_up_unicode(struct spk_synth *synth) -{ - _spk_do_catch_up(synth, 1); -} -EXPORT_SYMBOL_GPL(spk_do_catch_up_unicode); - -void spk_synth_flush(struct spk_synth *synth) -{ - synth->io_ops->flush_buffer(); - synth->io_ops->synth_out(synth, synth->clear); -} -EXPORT_SYMBOL_GPL(spk_synth_flush); - -unsigned char spk_synth_get_index(struct spk_synth *synth) -{ - return synth->io_ops->synth_in_nowait(); -} -EXPORT_SYMBOL_GPL(spk_synth_get_index); - -int spk_synth_is_alive_nop(struct spk_synth *synth) -{ - synth->alive = 1; - return 1; -} -EXPORT_SYMBOL_GPL(spk_synth_is_alive_nop); - -int spk_synth_is_alive_restart(struct spk_synth *synth) -{ - if (synth->alive) - return 1; - if (spk_wait_for_xmitr(synth) > 0) { - /* restart */ - synth->alive = 1; - synth_printf("%s", synth->init); - return 2; /* reenabled */ - } - pr_warn("%s: can't restart synth\n", synth->long_name); - return 0; -} -EXPORT_SYMBOL_GPL(spk_synth_is_alive_restart); - -static void thread_wake_up(struct timer_list *unused) -{ - wake_up_interruptible_all(&speakup_event); -} - -static DEFINE_TIMER(thread_timer, thread_wake_up); - -void synth_start(void) -{ - struct var_t *trigger_time; - - if (!synth->alive) { - synth_buffer_clear(); - return; - } - trigger_time = spk_get_var(TRIGGER); - if (!timer_pending(&thread_timer)) - mod_timer(&thread_timer, jiffies + - msecs_to_jiffies(trigger_time->u.n.value)); -} - -void spk_do_flush(void) -{ - if (!synth) - return; - - speakup_info.flushing = 1; - synth_buffer_clear(); - if (synth->alive) { - if (spk_pitch_shift) { - synth_printf("%s", spk_pitch_buff); - spk_pitch_shift = 0; - } - } - wake_up_interruptible_all(&speakup_event); - wake_up_process(speakup_task); -} - -void synth_write(const char *buf, size_t count) -{ - while (count--) - synth_buffer_add(*buf++); - synth_start(); -} - -void synth_printf(const char *fmt, ...) -{ - va_list args; - unsigned char buf[160], *p; - int r; - - va_start(args, fmt); - r = vsnprintf(buf, sizeof(buf), fmt, args); - va_end(args); - if (r > sizeof(buf) - 1) - r = sizeof(buf) - 1; - - p = buf; - while (r--) - synth_buffer_add(*p++); - synth_start(); -} -EXPORT_SYMBOL_GPL(synth_printf); - -void synth_putwc(u16 wc) -{ - synth_buffer_add(wc); -} -EXPORT_SYMBOL_GPL(synth_putwc); - -void synth_putwc_s(u16 wc) -{ - synth_buffer_add(wc); - synth_start(); -} -EXPORT_SYMBOL_GPL(synth_putwc_s); - -void synth_putws(const u16 *buf) -{ - const u16 *p; - - for (p = buf; *p; p++) - synth_buffer_add(*p); -} -EXPORT_SYMBOL_GPL(synth_putws); - -void synth_putws_s(const u16 *buf) -{ - synth_putws(buf); - synth_start(); -} -EXPORT_SYMBOL_GPL(synth_putws_s); - -static int index_count; -static int sentence_count; - -void spk_reset_index_count(int sc) -{ - static int first = 1; - - if (first) - first = 0; - else - synth->get_index(synth); - index_count = 0; - sentence_count = sc; -} - -int synth_supports_indexing(void) -{ - if (synth->get_index) - return 1; - return 0; -} - -void synth_insert_next_index(int sent_num) -{ - int out; - - if (synth->alive) { - if (sent_num == 0) { - synth->indexing.currindex++; - index_count++; - if (synth->indexing.currindex > - synth->indexing.highindex) - synth->indexing.currindex = - synth->indexing.lowindex; - } - - out = synth->indexing.currindex * 10 + sent_num; - synth_printf(synth->indexing.command, out, out); - } -} - -void spk_get_index_count(int *linecount, int *sentcount) -{ - int ind = synth->get_index(synth); - - if (ind) { - sentence_count = ind % 10; - - if ((ind / 10) <= synth->indexing.currindex) - index_count = synth->indexing.currindex - (ind / 10); - else - index_count = synth->indexing.currindex - - synth->indexing.lowindex - + synth->indexing.highindex - (ind / 10) + 1; - } - *sentcount = sentence_count; - *linecount = index_count; -} - -static struct resource synth_res; - -int synth_request_region(unsigned long start, unsigned long n) -{ - struct resource *parent = &ioport_resource; - - memset(&synth_res, 0, sizeof(synth_res)); - synth_res.name = synth->name; - synth_res.start = start; - synth_res.end = start + n - 1; - synth_res.flags = IORESOURCE_BUSY; - return request_resource(parent, &synth_res); -} -EXPORT_SYMBOL_GPL(synth_request_region); - -int synth_release_region(unsigned long start, unsigned long n) -{ - return release_resource(&synth_res); -} -EXPORT_SYMBOL_GPL(synth_release_region); - -struct var_t synth_time_vars[] = { - { DELAY, .u.n = {NULL, 100, 100, 2000, 0, 0, NULL } }, - { TRIGGER, .u.n = {NULL, 20, 10, 2000, 0, 0, NULL } }, - { JIFFY, .u.n = {NULL, 50, 20, 200, 0, 0, NULL } }, - { FULL, .u.n = {NULL, 400, 200, 60000, 0, 0, NULL } }, - V_LAST_VAR -}; - -/* called by: speakup_init() */ -int synth_init(char *synth_name) -{ - int ret = 0; - struct spk_synth *tmp, *synth = NULL; - - if (!synth_name) - return 0; - - if (strcmp(synth_name, "none") == 0) { - mutex_lock(&spk_mutex); - synth_release(); - mutex_unlock(&spk_mutex); - return 0; - } - - mutex_lock(&spk_mutex); - /* First, check if we already have it loaded. */ - list_for_each_entry(tmp, &synths, node) { - if (strcmp(tmp->name, synth_name) == 0) - synth = tmp; - } - - /* If we got one, initialize it now. */ - if (synth) - ret = do_synth_init(synth); - else - ret = -ENODEV; - mutex_unlock(&spk_mutex); - - return ret; -} - -/* called by: synth_add() */ -static int do_synth_init(struct spk_synth *in_synth) -{ - struct var_t *var; - - synth_release(); - if (in_synth->checkval != SYNTH_CHECK) - return -EINVAL; - synth = in_synth; - synth->alive = 0; - pr_warn("synth probe\n"); - if (synth->probe(synth) < 0) { - pr_warn("%s: device probe failed\n", in_synth->name); - synth = NULL; - return -ENODEV; - } - synth_time_vars[0].u.n.value = - synth_time_vars[0].u.n.default_val = synth->delay; - synth_time_vars[1].u.n.value = - synth_time_vars[1].u.n.default_val = synth->trigger; - synth_time_vars[2].u.n.value = - synth_time_vars[2].u.n.default_val = synth->jiffies; - synth_time_vars[3].u.n.value = - synth_time_vars[3].u.n.default_val = synth->full; - synth_printf("%s", synth->init); - for (var = synth->vars; - (var->var_id >= 0) && (var->var_id < MAXVARS); var++) - speakup_register_var(var); - if (!spk_quiet_boot) - synth_printf("%s found\n", synth->long_name); - if (synth->attributes.name && - sysfs_create_group(speakup_kobj, &synth->attributes) < 0) - return -ENOMEM; - synth_flags = synth->flags; - wake_up_interruptible_all(&speakup_event); - if (speakup_task) - wake_up_process(speakup_task); - return 0; -} - -void synth_release(void) -{ - struct var_t *var; - unsigned long flags; - - if (!synth) - return; - spin_lock_irqsave(&speakup_info.spinlock, flags); - pr_info("releasing synth %s\n", synth->name); - synth->alive = 0; - del_timer(&thread_timer); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (synth->attributes.name) - sysfs_remove_group(speakup_kobj, &synth->attributes); - for (var = synth->vars; var->var_id != MAXVARS; var++) - speakup_unregister_var(var->var_id); - synth->release(); - synth = NULL; -} - -/* called by: all_driver_init() */ -int synth_add(struct spk_synth *in_synth) -{ - int status = 0; - struct spk_synth *tmp; - - mutex_lock(&spk_mutex); - - list_for_each_entry(tmp, &synths, node) { - if (tmp == in_synth) { - mutex_unlock(&spk_mutex); - return 0; - } - } - - if (in_synth->startup) - status = do_synth_init(in_synth); - - if (!status) - list_add_tail(&in_synth->node, &synths); - - mutex_unlock(&spk_mutex); - return status; -} -EXPORT_SYMBOL_GPL(synth_add); - -void synth_remove(struct spk_synth *in_synth) -{ - mutex_lock(&spk_mutex); - if (synth == in_synth) - synth_release(); - list_del(&in_synth->node); - module_status = 0; - mutex_unlock(&spk_mutex); -} -EXPORT_SYMBOL_GPL(synth_remove); - -struct spk_synth *synth_current(void) -{ - return synth; -} -EXPORT_SYMBOL_GPL(synth_current); - -short spk_punc_masks[] = { 0, SOME, MOST, PUNC, PUNC | B_SYM }; diff --git a/drivers/staging/speakup/sysfs-driver-speakup b/drivers/staging/speakup/sysfs-driver-speakup deleted file mode 100644 index c6a32c434ce9..000000000000 --- a/drivers/staging/speakup/sysfs-driver-speakup +++ /dev/null @@ -1,375 +0,0 @@ -What: /sys/accessibility/speakup/attrib_bleep -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Beeps the PC speaker when there is an attribute change such as - foreground or background color when using speakup review - commands. One = on, zero = off. - -What: /sys/accessibility/speakup/bell_pos -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This works much like a typewriter bell. If for example 72 is - echoed to bell_pos, it will beep the PC speaker when typing on - a line past character 72. - -What: /sys/accessibility/speakup/bleeps -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This controls whether one hears beeps through the PC speaker - when using speakup's review commands. - TODO: what values does it accept? - -What: /sys/accessibility/speakup/bleep_time -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This controls the duration of the PC speaker beeps speakup - produces. - TODO: What are the units? Jiffies? - -What: /sys/accessibility/speakup/cursor_time -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This controls cursor delay when using arrow keys. When a - connection is very slow, with the default setting, when moving - with the arrows, or backspacing etc. speakup says the incorrect - characters. Set this to a higher value to adjust for the delay - and better synchronisation between cursor position and speech. - -What: /sys/accessibility/speakup/delimiters -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Delimit a word from speakup. - TODO: add more info - -What: /sys/accessibility/speakup/ex_num -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: TODO: - -What: /sys/accessibility/speakup/key_echo -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Controls if speakup speaks keys when they are typed. One = on, - zero = off or don't echo keys. - -What: /sys/accessibility/speakup/keymap -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Speakup keymap remaps keys to Speakup functions. - It uses a binary - format. A special program called genmap is needed to compile a - textual keymap into the binary format which is then loaded into - /sys/accessibility/speakup/keymap. - -What: /sys/accessibility/speakup/no_interrupt -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Controls if typing interrupts output from speakup. With - no_interrupt set to zero, typing on the keyboard will interrupt - speakup if for example - the say screen command is used before the - entire screen is read. - With no_interrupt set to one, if the say - screen command is used, and one then types on the keyboard, - speakup will continue to say the whole screen regardless until - it finishes. - -What: /sys/accessibility/speakup/punc_all -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This is a list of all the punctuation speakup should speak when - punc_level is set to four. - -What: /sys/accessibility/speakup/punc_level -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Controls the level of punctuation spoken as the screen is - displayed, not reviewed. Levels range from zero no punctuation, - to four, all punctuation. One corresponds to punc_some, two - corresponds to punc_most, and three as well as four both - correspond to punc_all. Some hardware synthesizers may have - different levels each corresponding to three and four for - punc_level. Also note that if punc_level is set to zero, and - key_echo is set to one, typed punctuation is still spoken as it - is typed. - -What: /sys/accessibility/speakup/punc_most -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This is a list of all the punctuation speakup should speak when - punc_level is set to two. - -What: /sys/accessibility/speakup/punc_some -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This is a list of all the punctuation speakup should speak when - punc_level is set to one. - -What: /sys/accessibility/speakup/reading_punc -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Almost the same as punc_level, the differences being that - reading_punc controls the level of punctuation when reviewing - the screen with speakup's screen review commands. The other - difference is that reading_punc set to three speaks punc_all, - and reading_punc set to four speaks all punctuation, including - spaces. - -What: /sys/accessibility/speakup/repeats -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: A list of characters speakup repeats. Normally, when there are - more than three characters in a row, speakup - just reads three of - those characters. For example, "......" would be read as dot, - dot, dot. If a . is added to the list of characters in repeats, - "......" would be read as dot, dot, dot, times six. - -What: /sys/accessibility/speakup/say_control -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: If set to one, speakup speaks shift, alt and control when those - keys are pressed. If say_control is set to zero, shift, ctrl, - and alt are not spoken when they are pressed. - -What: /sys/accessibility/speakup/say_word_ctl -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: TODO: - -What: /sys/accessibility/speakup/silent -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: TODO: - -What: /sys/accessibility/speakup/spell_delay -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This controls how fast a word is spelled - when speakup's say word - review command is pressed twice quickly to speak the current - word being reviewed. Zero just speaks the letters one after - another, while values one through four - seem to introduce more of - a pause between the spelling of each letter by speakup. - -What: /sys/accessibility/speakup/synth -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Gets or sets the synthesizer driver currently in use. Reading - synth returns the synthesizer driver currently in use. Writing - synth switches to the given synthesizer driver, provided it is - either built into the kernel, or already loaded as a module. - -What: /sys/accessibility/speakup/synth_direct -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Sends whatever is written to synth_direct - directly to the speech synthesizer in use, bypassing speakup. - This could be used to make the synthesizer speak - a string, or to - send control sequences to the synthesizer to change how the - synthesizer behaves. - -What: /sys/accessibility/speakup/version -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Reading version returns the version of speakup, and the version - of the synthesizer driver currently in use. - -What: /sys/accessibility/speakup/i18n/announcements -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This file contains various general announcements, most of which - cannot be categorized. You will find messages such as "You - killed Speakup", "I'm alive", "leaving help", "parked", - "unparked", and others. You will also find the names of the - screen edges and cursor tracking modes here. - -What: /sys/accessibility/speakup/i18n/chartab -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: TODO - -What: /sys/accessibility/speakup/i18n/ctl_keys -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Here, you will find names of control keys. These are used with - Speakup's say_control feature. - -What: /sys/accessibility/speakup/i18n/function_names -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Here, you will find a list of names for Speakup functions. - These are used by the help system. For example, suppose that - you have activated help mode, and you pressed - keypad 3. Speakup - says: "keypad 3 is character, say next." - The message "character, say next" names a Speakup function, and - it comes from this function_names file. - -What: /sys/accessibility/speakup/i18n/states -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This file contains names for key states. - Again, these are part of the help system. For instance, if you - had pressed speakup + keypad 3, you would hear: - "speakup keypad 3 is go to bottom edge." - The speakup key is depressed, so the name of the key state is - speakup. - This part of the message comes from the states collection. - -What: /sys/accessibility/speakup/i18n/characters -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Through this sys entry, Speakup gives you the ability to change - how Speakup pronounces a given character. You could, for - example, change how some punctuation characters are spoken. You - can even change how Speakup will pronounce certain letters. For - further details see '12. Changing the Pronunciation of - Characters' in Speakup User's Guide (file spkguide.txt in - source). - -What: /sys/accessibility/speakup/i18n/colors -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: When you use the "say attributes" function, Speakup says the - name of the foreground and background colors. These names come - from the i18n/colors file. - -What: /sys/accessibility/speakup/i18n/formatted -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This group of messages contains embedded formatting codes, to - specify the type and width of displayed data. If you change - these, you must preserve all of the formatting codes, and they - must appear in the order used by the default messages. - -What: /sys/accessibility/speakup/i18n/key_names -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Again, key_names is used by Speakup's help system. In the - previous example, Speakup said that you pressed "keypad 3." - This name came from the key_names file. - -What: /sys/accessibility/speakup// -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: In `/sys/accessibility/speakup` is a directory corresponding to - the synthesizer driver currently in use (E.G) `soft` for the - soft driver. This directory contains files which control the - speech synthesizer itself, - as opposed to controlling the speakup - screen reader. The parameters in this directory have the same - names and functions across all - supported synthesizers. The range - of values for freq, pitch, rate, and vol is the same for all - supported synthesizers, with the given range being internally - mapped by the driver to more or less fit the range of values - supported for a given parameter by the individual synthesizer. - Below is a description of values and parameters for soft - synthesizer, which is currently the most commonly used. - -What: /sys/accessibility/speakup/soft/caps_start -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This is the string that is sent to the synthesizer to cause it - to start speaking uppercase letters. For the soft synthesizer - and most others, this causes the pitch of the voice to rise - above the currently set pitch. - -What: /sys/accessibility/speakup/soft/caps_stop -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This is the string sent to the synthesizer to cause it to stop - speaking uppercase letters. In the case of the soft synthesizer - and most others, this returns the pitch of the voice - down to the - currently set pitch. - -What: /sys/accessibility/speakup/soft/delay_time -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: TODO: - -What: /sys/accessibility/speakup/soft/direct -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Controls if punctuation is spoken by speakup, or by the - synthesizer. - For example, speakup speaks ">" as "greater", while - the espeak synthesizer used by the soft driver speaks "greater - than". Zero lets speakup speak the punctuation. One lets the - synthesizer itself speak punctuation. - -What: /sys/accessibility/speakup/soft/freq -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Gets or sets the frequency of the speech synthesizer. Range is - 0-9. - -What: /sys/accessibility/speakup/soft/full_time -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: TODO: - -What: /sys/accessibility/speakup/soft/jiffy_delta -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: This controls how many jiffys the kernel gives to the - synthesizer. Setting this too high can make a system unstable, - or even crash it. - -What: /sys/accessibility/speakup/soft/pitch -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Gets or sets the pitch of the synthesizer. The range is 0-9. - -What: /sys/accessibility/speakup/soft/inflection -KernelVersion: 5.8 -Contact: speakup@linux-speakup.org -Description: Gets or sets the inflection of the synthesizer, i.e. the pitch - range. The range is 0-9. - -What: /sys/accessibility/speakup/soft/punct -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Gets or sets the amount of punctuation spoken by the - synthesizer. The range for the soft driver seems to be 0-2. - TODO: How is this related to speakup's punc_level, or - reading_punc. - -What: /sys/accessibility/speakup/soft/rate -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Gets or sets the rate of the synthesizer. Range is from zero - slowest, to nine fastest. - -What: /sys/accessibility/speakup/soft/tone -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Gets or sets the tone of the speech synthesizer. The range for - the soft driver seems to be 0-2. This seems to make no - difference if using espeak and the espeakup connector. - TODO: does espeakup support different tonalities? - -What: /sys/accessibility/speakup/soft/trigger_time -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: TODO: - -What: /sys/accessibility/speakup/soft/voice -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Gets or sets the voice used by the synthesizer if the - synthesizer can speak in more than one voice. The range for the - soft driver is 0-7. Note that while espeak supports multiple - voices, this parameter will not set the voice when the espeakup - connector is used between speakup and espeak. - -What: /sys/accessibility/speakup/soft/vol -KernelVersion: 2.6 -Contact: speakup@linux-speakup.org -Description: Gets or sets the volume of the speech synthesizer. Range is 0-9, - with zero being the softest, and nine being the loudest. - diff --git a/drivers/staging/speakup/thread.c b/drivers/staging/speakup/thread.c deleted file mode 100644 index 2fc75e60fbac..000000000000 --- a/drivers/staging/speakup/thread.c +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include - -#include "spk_types.h" -#include "speakup.h" -#include "spk_priv.h" - -DECLARE_WAIT_QUEUE_HEAD(speakup_event); -EXPORT_SYMBOL_GPL(speakup_event); - -int speakup_thread(void *data) -{ - unsigned long flags; - int should_break; - struct bleep our_sound; - - our_sound.active = 0; - our_sound.freq = 0; - our_sound.jiffies = 0; - - mutex_lock(&spk_mutex); - while (1) { - DEFINE_WAIT(wait); - - while (1) { - spin_lock_irqsave(&speakup_info.spinlock, flags); - our_sound = spk_unprocessed_sound; - spk_unprocessed_sound.active = 0; - prepare_to_wait(&speakup_event, &wait, - TASK_INTERRUPTIBLE); - should_break = kthread_should_stop() || - our_sound.active || - (synth && synth->catch_up && synth->alive && - (speakup_info.flushing || - !synth_buffer_empty())); - spin_unlock_irqrestore(&speakup_info.spinlock, flags); - if (should_break) - break; - mutex_unlock(&spk_mutex); - schedule(); - mutex_lock(&spk_mutex); - } - finish_wait(&speakup_event, &wait); - if (kthread_should_stop()) - break; - - if (our_sound.active) - kd_mksound(our_sound.freq, our_sound.jiffies); - if (synth && synth->catch_up && synth->alive) { - /* - * It is up to the callee to take the lock, so that it - * can sleep whenever it likes - */ - synth->catch_up(synth); - } - - speakup_start_ttys(); - } - mutex_unlock(&spk_mutex); - return 0; -} diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c deleted file mode 100644 index d7f6bec7ff06..000000000000 --- a/drivers/staging/speakup/varhandlers.c +++ /dev/null @@ -1,339 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include "spk_types.h" -#include "spk_priv.h" -#include "speakup.h" - -static struct st_var_header var_headers[] = { - { "version", VERSION, VAR_PROC, NULL, NULL }, - { "synth_name", SYNTH, VAR_PROC, NULL, NULL }, - { "keymap", KEYMAP, VAR_PROC, NULL, NULL }, - { "silent", SILENT, VAR_PROC, NULL, NULL }, - { "punc_some", PUNC_SOME, VAR_PROC, NULL, NULL }, - { "punc_most", PUNC_MOST, VAR_PROC, NULL, NULL }, - { "punc_all", PUNC_ALL, VAR_PROC, NULL, NULL }, - { "delimiters", DELIM, VAR_PROC, NULL, NULL }, - { "repeats", REPEATS, VAR_PROC, NULL, NULL }, - { "ex_num", EXNUMBER, VAR_PROC, NULL, NULL }, - { "characters", CHARS, VAR_PROC, NULL, NULL }, - { "synth_direct", SYNTH_DIRECT, VAR_PROC, NULL, NULL }, - { "caps_start", CAPS_START, VAR_STRING, spk_str_caps_start, NULL }, - { "caps_stop", CAPS_STOP, VAR_STRING, spk_str_caps_stop, NULL }, - { "delay_time", DELAY, VAR_TIME, NULL, NULL }, - { "trigger_time", TRIGGER, VAR_TIME, NULL, NULL }, - { "jiffy_delta", JIFFY, VAR_TIME, NULL, NULL }, - { "full_time", FULL, VAR_TIME, NULL, NULL }, - { "spell_delay", SPELL_DELAY, VAR_NUM, &spk_spell_delay, NULL }, - { "bleeps", BLEEPS, VAR_NUM, &spk_bleeps, NULL }, - { "attrib_bleep", ATTRIB_BLEEP, VAR_NUM, &spk_attrib_bleep, NULL }, - { "bleep_time", BLEEP_TIME, VAR_TIME, &spk_bleep_time, NULL }, - { "cursor_time", CURSOR_TIME, VAR_TIME, NULL, NULL }, - { "punc_level", PUNC_LEVEL, VAR_NUM, &spk_punc_level, NULL }, - { "reading_punc", READING_PUNC, VAR_NUM, &spk_reading_punc, NULL }, - { "say_control", SAY_CONTROL, VAR_NUM, &spk_say_ctrl, NULL }, - { "say_word_ctl", SAY_WORD_CTL, VAR_NUM, &spk_say_word_ctl, NULL }, - { "no_interrupt", NO_INTERRUPT, VAR_NUM, &spk_no_intr, NULL }, - { "key_echo", KEY_ECHO, VAR_NUM, &spk_key_echo, NULL }, - { "bell_pos", BELL_POS, VAR_NUM, &spk_bell_pos, NULL }, - { "rate", RATE, VAR_NUM, NULL, NULL }, - { "pitch", PITCH, VAR_NUM, NULL, NULL }, - { "inflection", INFLECTION, VAR_NUM, NULL, NULL }, - { "vol", VOL, VAR_NUM, NULL, NULL }, - { "tone", TONE, VAR_NUM, NULL, NULL }, - { "punct", PUNCT, VAR_NUM, NULL, NULL }, - { "voice", VOICE, VAR_NUM, NULL, NULL }, - { "freq", FREQUENCY, VAR_NUM, NULL, NULL }, - { "lang", LANG, VAR_NUM, NULL, NULL }, - { "chartab", CHARTAB, VAR_PROC, NULL, NULL }, - { "direct", DIRECT, VAR_NUM, NULL, NULL }, - { "pause", PAUSE, VAR_STRING, spk_str_pause, NULL }, -}; - -static struct st_var_header *var_ptrs[MAXVARS] = { NULL, NULL, NULL }; - -static struct punc_var_t punc_vars[] = { - { PUNC_SOME, 1 }, - { PUNC_MOST, 2 }, - { PUNC_ALL, 3 }, - { DELIM, 4 }, - { REPEATS, 5 }, - { EXNUMBER, 6 }, - { -1, -1 }, -}; - -int spk_chartab_get_value(char *keyword) -{ - int value = 0; - - if (!strcmp(keyword, "ALPHA")) - value = ALPHA; - else if (!strcmp(keyword, "B_CTL")) - value = B_CTL; - else if (!strcmp(keyword, "WDLM")) - value = WDLM; - else if (!strcmp(keyword, "A_PUNC")) - value = A_PUNC; - else if (!strcmp(keyword, "PUNC")) - value = PUNC; - else if (!strcmp(keyword, "NUM")) - value = NUM; - else if (!strcmp(keyword, "A_CAP")) - value = A_CAP; - else if (!strcmp(keyword, "B_CAPSYM")) - value = B_CAPSYM; - else if (!strcmp(keyword, "B_SYM")) - value = B_SYM; - return value; -} - -void speakup_register_var(struct var_t *var) -{ - static char nothing[2] = "\0"; - int i; - struct st_var_header *p_header; - - BUG_ON(!var || var->var_id < 0 || var->var_id >= MAXVARS); - if (!var_ptrs[0]) { - for (i = 0; i < MAXVARS; i++) { - p_header = &var_headers[i]; - var_ptrs[p_header->var_id] = p_header; - p_header->data = NULL; - } - } - p_header = var_ptrs[var->var_id]; - if (p_header->data) - return; - p_header->data = var; - switch (p_header->var_type) { - case VAR_STRING: - spk_set_string_var(nothing, p_header, 0); - break; - case VAR_NUM: - case VAR_TIME: - spk_set_num_var(0, p_header, E_DEFAULT); - break; - default: - break; - } -} - -void speakup_unregister_var(enum var_id_t var_id) -{ - struct st_var_header *p_header; - - BUG_ON(var_id < 0 || var_id >= MAXVARS); - p_header = var_ptrs[var_id]; - p_header->data = NULL; -} - -struct st_var_header *spk_get_var_header(enum var_id_t var_id) -{ - struct st_var_header *p_header; - - if (var_id < 0 || var_id >= MAXVARS) - return NULL; - p_header = var_ptrs[var_id]; - if (!p_header->data) - return NULL; - return p_header; -} - -struct st_var_header *spk_var_header_by_name(const char *name) -{ - int i; - - if (!name) - return NULL; - - for (i = 0; i < MAXVARS; i++) { - if (strcmp(name, var_ptrs[i]->name) == 0) - return var_ptrs[i]; - } - return NULL; -} - -struct var_t *spk_get_var(enum var_id_t var_id) -{ - BUG_ON(var_id < 0 || var_id >= MAXVARS); - BUG_ON(!var_ptrs[var_id]); - return var_ptrs[var_id]->data; -} -EXPORT_SYMBOL_GPL(spk_get_var); - -struct punc_var_t *spk_get_punc_var(enum var_id_t var_id) -{ - struct punc_var_t *rv = NULL; - struct punc_var_t *where; - - where = punc_vars; - while ((where->var_id != -1) && (!rv)) { - if (where->var_id == var_id) - rv = where; - else - where++; - } - return rv; -} - -/* handlers for setting vars */ -int spk_set_num_var(int input, struct st_var_header *var, int how) -{ - int val; - int *p_val = var->p_val; - char buf[32]; - char *cp; - struct var_t *var_data = var->data; - - if (!var_data) - return -ENODATA; - - val = var_data->u.n.value; - switch (how) { - case E_NEW_DEFAULT: - if (input < var_data->u.n.low || input > var_data->u.n.high) - return -ERANGE; - var_data->u.n.default_val = input; - return 0; - case E_DEFAULT: - val = var_data->u.n.default_val; - break; - case E_SET: - val = input; - break; - case E_INC: - val += input; - break; - case E_DEC: - val -= input; - break; - } - - if (val < var_data->u.n.low || val > var_data->u.n.high) - return -ERANGE; - - var_data->u.n.value = val; - if (var->var_type == VAR_TIME && p_val) { - *p_val = msecs_to_jiffies(val); - return 0; - } - if (p_val) - *p_val = val; - if (var->var_id == PUNC_LEVEL) { - spk_punc_mask = spk_punc_masks[val]; - return 0; - } - if (var_data->u.n.multiplier != 0) - val *= var_data->u.n.multiplier; - val += var_data->u.n.offset; - if (var->var_id < FIRST_SYNTH_VAR || !synth) - return 0; - if (synth->synth_adjust) - return synth->synth_adjust(var); - - if (!var_data->u.n.synth_fmt) - return 0; - if (var->var_id == PITCH) - cp = spk_pitch_buff; - else - cp = buf; - if (!var_data->u.n.out_str) - sprintf(cp, var_data->u.n.synth_fmt, (int)val); - else - sprintf(cp, var_data->u.n.synth_fmt, - var_data->u.n.out_str[val]); - synth_printf("%s", cp); - return 0; -} - -int spk_set_string_var(const char *page, struct st_var_header *var, int len) -{ - struct var_t *var_data = var->data; - - if (!var_data) - return -ENODATA; - if (len > MAXVARLEN) - return -E2BIG; - if (!len) { - if (!var_data->u.s.default_val) - return 0; - if (!var->p_val) - var->p_val = var_data->u.s.default_val; - if (var->p_val != var_data->u.s.default_val) - strcpy((char *)var->p_val, var_data->u.s.default_val); - return -ERESTART; - } else if (var->p_val) { - strcpy((char *)var->p_val, page); - } else { - return -E2BIG; - } - return 0; -} - -/* - * spk_set_mask_bits sets or clears the punc/delim/repeat bits, - * if input is null uses the defaults. - * values for how: 0 clears bits of chars supplied, - * 1 clears allk, 2 sets bits for chars - */ -int spk_set_mask_bits(const char *input, const int which, const int how) -{ - u_char *cp; - short mask = spk_punc_info[which].mask; - - if (how & 1) { - for (cp = (u_char *)spk_punc_info[3].value; *cp; cp++) - spk_chartab[*cp] &= ~mask; - } - cp = (u_char *)input; - if (!cp) { - cp = spk_punc_info[which].value; - } else { - for (; *cp; cp++) { - if (*cp < SPACE) - break; - if (mask < PUNC) { - if (!(spk_chartab[*cp] & PUNC)) - break; - } else if (spk_chartab[*cp] & B_NUM) { - break; - } - } - if (*cp) - return -EINVAL; - cp = (u_char *)input; - } - if (how & 2) { - for (; *cp; cp++) - if (*cp > SPACE) - spk_chartab[*cp] |= mask; - } else { - for (; *cp; cp++) - if (*cp > SPACE) - spk_chartab[*cp] &= ~mask; - } - return 0; -} - -char *spk_strlwr(char *s) -{ - char *p; - - if (!s) - return NULL; - - for (p = s; *p; p++) - *p = tolower(*p); - return s; -} - -char *spk_s2uchar(char *start, char *dest) -{ - int val; - - /* Do not replace with kstrtoul: here we need start to be updated */ - val = simple_strtoul(skip_spaces(start), &start, 10); - if (*start == ',') - start++; - *dest = (u_char)val; - return start; -} -- cgit v1.2.3-58-ga151 From b503aef30e45ad29f8dd7f53e22240ea6e527590 Mon Sep 17 00:00:00 2001 From: Vaibhav Agarwal Date: Thu, 9 Jul 2020 15:57:17 +0530 Subject: staging: greybus: audio: Update snd_jack FW usage as per new APIs snd_soc_jack APIs are modified in recent kernel versions. This patch updates the codec driver to resolve the compilation errors related to jack framework. Signed-off-by: Vaibhav Agarwal Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/896b8e24d990f2bca5aafaebd26e37095042951e.1594290158.git.vaibhav.sr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_codec.c | 54 +++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c index 08746c85dea6..5d3a5e6a8fe6 100644 --- a/drivers/staging/greybus/audio_codec.c +++ b/drivers/staging/greybus/audio_codec.c @@ -709,17 +709,26 @@ static struct snd_soc_dai_driver gbaudio_dai[] = { }; static int gbaudio_init_jack(struct gbaudio_module_info *module, - struct snd_soc_codec *codec) + struct snd_soc_card *card) { int ret; + struct snd_soc_jack_pin *headset, *button; if (!module->jack_mask) return 0; snprintf(module->jack_name, NAME_SIZE, "GB %d Headset Jack", module->dev_id); - ret = snd_soc_jack_new(codec, module->jack_name, module->jack_mask, - &module->headset_jack); + + headset = devm_kzalloc(module->dev, sizeof(*headset), GFP_KERNEL); + if (!headset) + return -ENOMEM; + + headset->pin = module->jack_name; + headset->mask = module->jack_mask; + + ret = snd_soc_card_jack_new(card, module->jack_name, module->jack_mask, + &module->headset_jack, headset, 1); if (ret) { dev_err(module->dev, "Failed to create new jack\n"); return ret; @@ -730,11 +739,21 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, snprintf(module->button_name, NAME_SIZE, "GB %d Button Jack", module->dev_id); - ret = snd_soc_jack_new(codec, module->button_name, module->button_mask, - &module->button_jack); + button = devm_kzalloc(module->dev, sizeof(*button), GFP_KERNEL); + if (!button) { + ret = -ENOMEM; + goto free_headset; + } + + button->pin = module->button_name; + button->mask = module->button_mask; + + ret = snd_soc_card_jack_new(card, module->button_name, + module->button_mask, &module->button_jack, + button, 1); if (ret) { dev_err(module->dev, "Failed to create button jack\n"); - return ret; + goto free_headset; } /* @@ -750,7 +769,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, KEY_MEDIA); if (ret) { dev_err(module->dev, "Failed to set BTN_0\n"); - return ret; + goto free_button; } } @@ -759,7 +778,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, KEY_VOICECOMMAND); if (ret) { dev_err(module->dev, "Failed to set BTN_1\n"); - return ret; + goto free_button; } } @@ -768,7 +787,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, KEY_VOLUMEUP); if (ret) { dev_err(module->dev, "Failed to set BTN_2\n"); - return ret; + goto free_button; } } @@ -777,7 +796,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, KEY_VOLUMEDOWN); if (ret) { dev_err(module->dev, "Failed to set BTN_0\n"); - return ret; + goto free_button; } } @@ -788,6 +807,16 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, */ return 0; + +free_button: + snd_device_free(card->snd_card, module->button_jack.jack); + list_del(&module->button_jack.list); + +free_headset: + snd_device_free(card->snd_card, module->headset_jack.jack); + list_del(&module->headset_jack.list); + + return ret; } int gbaudio_register_module(struct gbaudio_module_info *module) @@ -815,7 +844,7 @@ int gbaudio_register_module(struct gbaudio_module_info *module) return -EINVAL; } - ret = gbaudio_init_jack(module, codec); + ret = gbaudio_init_jack(module, component->card); if (ret) { up_write(&card->controls_rwsem); return ret; @@ -942,7 +971,8 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module) #ifdef CONFIG_SND_JACK /* free jack devices for this module from codec->jack_list */ - list_for_each_entry_safe(jack, next_j, &codec->jack_list, list) { + list_for_each_entry_safe(jack, next_j, &component->card->jack_list, + list) { if (jack == &module->headset_jack) mask = GBCODEC_JACK_MASK; else if (jack == &module->button_jack) -- cgit v1.2.3-58-ga151 From ac40b4d1e409971fe40e69761d0c80ffbbb21938 Mon Sep 17 00:00:00 2001 From: Vaibhav Agarwal Date: Thu, 9 Jul 2020 15:57:18 +0530 Subject: staging: greybus: audio: Maintain jack list within GB Audio module As per the current implementation for GB codec driver, a jack list is maintained for each module. And it expects the list to be populated by the snd_soc_jack structure which would require modifications in mainstream code. However, this is not a necessary requirement and the list can be easily maintained within gbaudio_module_info as well. This patch provides the relevant changes for the same. Signed-off-by: Vaibhav Agarwal Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/4ee030af7a8e203f89a6e513313e36f4e2991e5b.1594290158.git.vaibhav.sr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_codec.c | 74 +++++++++++++++++----------------- drivers/staging/greybus/audio_codec.h | 10 ++++- drivers/staging/greybus/audio_module.c | 15 +++---- 3 files changed, 53 insertions(+), 46 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c index 5d3a5e6a8fe6..6dc4ee2bfb37 100644 --- a/drivers/staging/greybus/audio_codec.c +++ b/drivers/staging/greybus/audio_codec.c @@ -712,6 +712,7 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, struct snd_soc_card *card) { int ret; + struct gbaudio_jack *jack, *n; struct snd_soc_jack_pin *headset, *button; if (!module->jack_mask) @@ -726,14 +727,16 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, headset->pin = module->jack_name; headset->mask = module->jack_mask; - ret = snd_soc_card_jack_new(card, module->jack_name, module->jack_mask, - &module->headset_jack, headset, 1); + &module->headset.jack, headset, 1); if (ret) { dev_err(module->dev, "Failed to create new jack\n"); return ret; } + /* Add to module's jack list */ + list_add(&module->headset.list, &module->jack_list); + if (!module->button_mask) return 0; @@ -742,20 +745,22 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, button = devm_kzalloc(module->dev, sizeof(*button), GFP_KERNEL); if (!button) { ret = -ENOMEM; - goto free_headset; + goto free_jacks; } button->pin = module->button_name; button->mask = module->button_mask; - ret = snd_soc_card_jack_new(card, module->button_name, - module->button_mask, &module->button_jack, + module->button_mask, &module->button.jack, button, 1); if (ret) { dev_err(module->dev, "Failed to create button jack\n"); - goto free_headset; + goto free_jacks; } + /* Add to module's jack list */ + list_add(&module->button.list, &module->jack_list); + /* * Currently, max 4 buttons are supported with following key mapping * BTN_0 = KEY_MEDIA @@ -765,56 +770,54 @@ static int gbaudio_init_jack(struct gbaudio_module_info *module, */ if (module->button_mask & SND_JACK_BTN_0) { - ret = snd_jack_set_key(module->button_jack.jack, SND_JACK_BTN_0, + ret = snd_jack_set_key(module->button.jack.jack, SND_JACK_BTN_0, KEY_MEDIA); if (ret) { dev_err(module->dev, "Failed to set BTN_0\n"); - goto free_button; + goto free_jacks; } } if (module->button_mask & SND_JACK_BTN_1) { - ret = snd_jack_set_key(module->button_jack.jack, SND_JACK_BTN_1, + ret = snd_jack_set_key(module->button.jack.jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); if (ret) { dev_err(module->dev, "Failed to set BTN_1\n"); - goto free_button; + goto free_jacks; } } if (module->button_mask & SND_JACK_BTN_2) { - ret = snd_jack_set_key(module->button_jack.jack, SND_JACK_BTN_2, + ret = snd_jack_set_key(module->button.jack.jack, SND_JACK_BTN_2, KEY_VOLUMEUP); if (ret) { dev_err(module->dev, "Failed to set BTN_2\n"); - goto free_button; + goto free_jacks; } } if (module->button_mask & SND_JACK_BTN_3) { - ret = snd_jack_set_key(module->button_jack.jack, SND_JACK_BTN_3, + ret = snd_jack_set_key(module->button.jack.jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); if (ret) { dev_err(module->dev, "Failed to set BTN_0\n"); - goto free_button; + goto free_jacks; } } /* FIXME * verify if this is really required set_bit(INPUT_PROP_NO_DUMMY_RELEASE, - module->button_jack.jack->input_dev->propbit); + module->button.jack.jack->input_dev->propbit); */ return 0; -free_button: - snd_device_free(card->snd_card, module->button_jack.jack); - list_del(&module->button_jack.list); - -free_headset: - snd_device_free(card->snd_card, module->headset_jack.jack); - list_del(&module->headset_jack.list); +free_jacks: + list_for_each_entry_safe(jack, n, &module->jack_list, list) { + snd_device_free(card->snd_card, jack->jack.jack); + list_del(&jack->list); + } return ret; } @@ -824,7 +827,7 @@ int gbaudio_register_module(struct gbaudio_module_info *module) int ret; struct snd_soc_codec *codec; struct snd_card *card; - struct snd_soc_jack *jack = NULL; + struct gbaudio_jack *jack = NULL; if (!gbcodec) { dev_err(module->dev, "GB Codec not yet probed\n"); @@ -869,11 +872,9 @@ int gbaudio_register_module(struct gbaudio_module_info *module) * register jack devices for this module * from codec->jack_list */ - list_for_each_entry(jack, &codec->jack_list, list) { - if ((jack == &module->headset_jack) || - (jack == &module->button_jack)) - snd_device_register(codec->card->snd_card, - jack->jack); + list_for_each_entry(jack, &module->jack_list, list) { + snd_device_register(codec->card->snd_card, + jack->jack.jack); } #endif } @@ -957,7 +958,7 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module) { struct snd_soc_codec *codec = gbcodec->codec; struct snd_card *card = codec->card->snd_card; - struct snd_soc_jack *jack, *next_j; + struct gbaudio_jack *jack, *n; int mask; dev_dbg(codec->dev, "Unregister %s module\n", module->name); @@ -970,20 +971,19 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module) mutex_unlock(&gbcodec->lock); #ifdef CONFIG_SND_JACK - /* free jack devices for this module from codec->jack_list */ - list_for_each_entry_safe(jack, next_j, &component->card->jack_list, - list) { - if (jack == &module->headset_jack) + /* free jack devices for this module jack_list */ + list_for_each_entry_safe(jack, n, &module->jack_list, list) { + if (jack == &module->headset) mask = GBCODEC_JACK_MASK; - else if (jack == &module->button_jack) + else if (jack == &module->button) mask = GBCODEC_JACK_BUTTON_MASK; else mask = 0; if (mask) { dev_dbg(module->dev, "Report %s removal\n", - jack->jack->id); - snd_soc_jack_report(jack, 0, mask); - snd_device_free(codec->card->snd_card, jack->jack); + jack->jack.jack->id); + snd_soc_jack_report(&jack->jack, 0, mask); + snd_device_free(codec->card->snd_card, jack->jack.jack); list_del(&jack->list); } } diff --git a/drivers/staging/greybus/audio_codec.h b/drivers/staging/greybus/audio_codec.h index cb5d271da1a5..af9195eceb3a 100644 --- a/drivers/staging/greybus/audio_codec.h +++ b/drivers/staging/greybus/audio_codec.h @@ -106,6 +106,11 @@ enum gbaudio_module_state { GBAUDIO_MODULE_ON, }; +struct gbaudio_jack { + struct snd_soc_jack jack; + struct list_head list; +}; + struct gbaudio_module_info { /* module info */ struct device *dev; @@ -130,8 +135,8 @@ struct gbaudio_module_info { int jack_mask; int button_mask; int button_status; - struct snd_soc_jack headset_jack; - struct snd_soc_jack button_jack; + struct gbaudio_jack headset; + struct gbaudio_jack button; /* connection info */ struct gb_connection *mgmt_connection; @@ -155,6 +160,7 @@ struct gbaudio_module_info { struct list_head widget_list; struct list_head ctl_list; struct list_head widget_ctl_list; + struct list_head jack_list; struct gb_audio_topology *topology; }; diff --git a/drivers/staging/greybus/audio_module.c b/drivers/staging/greybus/audio_module.c index 300a2b4f3fc7..16f60256adb2 100644 --- a/drivers/staging/greybus/audio_module.c +++ b/drivers/staging/greybus/audio_module.c @@ -21,8 +21,8 @@ static int gbaudio_request_jack(struct gbaudio_module_info *module, struct gb_audio_jack_event_request *req) { int report; - struct snd_jack *jack = module->headset_jack.jack; - struct snd_jack *btn_jack = module->button_jack.jack; + struct snd_jack *jack = module->headset.jack.jack; + struct snd_jack *btn_jack = module->button.jack.jack; if (!jack) { dev_err_ratelimited(module->dev, @@ -38,11 +38,11 @@ static int gbaudio_request_jack(struct gbaudio_module_info *module, if (req->event == GB_AUDIO_JACK_EVENT_REMOVAL) { module->jack_type = 0; if (btn_jack && module->button_status) { - snd_soc_jack_report(&module->button_jack, 0, + snd_soc_jack_report(&module->button.jack, 0, module->button_mask); module->button_status = 0; } - snd_soc_jack_report(&module->headset_jack, 0, + snd_soc_jack_report(&module->headset.jack, 0, module->jack_mask); return 0; } @@ -61,7 +61,7 @@ static int gbaudio_request_jack(struct gbaudio_module_info *module, module->jack_type, report); module->jack_type = report; - snd_soc_jack_report(&module->headset_jack, report, module->jack_mask); + snd_soc_jack_report(&module->headset.jack, report, module->jack_mask); return 0; } @@ -70,7 +70,7 @@ static int gbaudio_request_button(struct gbaudio_module_info *module, struct gb_audio_button_event_request *req) { int soc_button_id, report; - struct snd_jack *btn_jack = module->button_jack.jack; + struct snd_jack *btn_jack = module->button.jack.jack; if (!btn_jack) { dev_err_ratelimited(module->dev, @@ -124,7 +124,7 @@ static int gbaudio_request_button(struct gbaudio_module_info *module, module->button_status = report; - snd_soc_jack_report(&module->button_jack, report, module->button_mask); + snd_soc_jack_report(&module->button.jack, report, module->button_mask); return 0; } @@ -258,6 +258,7 @@ static int gb_audio_probe(struct gb_bundle *bundle, INIT_LIST_HEAD(&gbmodule->widget_list); INIT_LIST_HEAD(&gbmodule->ctl_list); INIT_LIST_HEAD(&gbmodule->widget_ctl_list); + INIT_LIST_HEAD(&gbmodule->jack_list); gbmodule->dev = dev; snprintf(gbmodule->name, NAME_SIZE, "%s.%s", dev->driver->name, dev_name(dev)); -- cgit v1.2.3-58-ga151 From ce7bd8325dc75c873caa65c88861b3f5a58898bd Mon Sep 17 00:00:00 2001 From: Vaibhav Agarwal Date: Thu, 9 Jul 2020 15:57:19 +0530 Subject: staging: greybus: audio: Resolve compilation errors for GB codec module Due to dependencies on ASoC framework changes, GB dummy codec module compilation is currently disabled. This patch updates codec driver as per the latest ASoC APIs. Signed-off-by: Vaibhav Agarwal Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/dd66a960fca186da055600fe1e622b7a814cb543.1594290158.git.vaibhav.sr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_codec.c | 88 +++++++++++++++++------------------ drivers/staging/greybus/audio_codec.h | 2 +- 2 files changed, 44 insertions(+), 46 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c index 6dc4ee2bfb37..0ecdba27086b 100644 --- a/drivers/staging/greybus/audio_codec.c +++ b/drivers/staging/greybus/audio_codec.c @@ -825,7 +825,7 @@ free_jacks: int gbaudio_register_module(struct gbaudio_module_info *module) { int ret; - struct snd_soc_codec *codec; + struct snd_soc_component *comp; struct snd_card *card; struct gbaudio_jack *jack = NULL; @@ -834,8 +834,8 @@ int gbaudio_register_module(struct gbaudio_module_info *module) return -EAGAIN; } - codec = gbcodec->codec; - card = codec->card->snd_card; + comp = gbcodec->component; + card = comp->card->snd_card; down_write(&card->controls_rwsem); @@ -847,33 +847,33 @@ int gbaudio_register_module(struct gbaudio_module_info *module) return -EINVAL; } - ret = gbaudio_init_jack(module, component->card); + ret = gbaudio_init_jack(module, comp->card); if (ret) { up_write(&card->controls_rwsem); return ret; } if (module->dapm_widgets) - snd_soc_dapm_new_controls(&codec->dapm, module->dapm_widgets, + snd_soc_dapm_new_controls(&comp->dapm, module->dapm_widgets, module->num_dapm_widgets); if (module->controls) - snd_soc_add_codec_controls(codec, module->controls, - module->num_controls); + snd_soc_add_component_controls(comp, module->controls, + module->num_controls); if (module->dapm_routes) - snd_soc_dapm_add_routes(&codec->dapm, module->dapm_routes, + snd_soc_dapm_add_routes(&comp->dapm, module->dapm_routes, module->num_dapm_routes); /* card already instantiated, create widgets here only */ - if (codec->card->instantiated) { - snd_soc_dapm_link_component_dai_widgets(codec->card, - &codec->dapm); + if (comp->card->instantiated) { + snd_soc_dapm_link_component_dai_widgets(comp->card, + &comp->dapm); #ifdef CONFIG_SND_JACK /* * register jack devices for this module * from codec->jack_list */ list_for_each_entry(jack, &module->jack_list, list) { - snd_device_register(codec->card->snd_card, + snd_device_register(comp->card->snd_card, jack->jack.jack); } #endif @@ -883,9 +883,9 @@ int gbaudio_register_module(struct gbaudio_module_info *module) list_add(&module->list, &gbcodec->module_list); mutex_unlock(&gbcodec->lock); - if (codec->card->instantiated) - ret = snd_soc_dapm_new_widgets(&codec->dapm); - dev_dbg(codec->dev, "Registered %s module\n", module->name); + if (comp->card->instantiated) + ret = snd_soc_dapm_new_widgets(comp->card); + dev_dbg(comp->dev, "Registered %s module\n", module->name); up_write(&card->controls_rwsem); return ret; @@ -956,18 +956,18 @@ static void gbaudio_codec_cleanup(struct gbaudio_module_info *module) void gbaudio_unregister_module(struct gbaudio_module_info *module) { - struct snd_soc_codec *codec = gbcodec->codec; - struct snd_card *card = codec->card->snd_card; + struct snd_soc_component *comp = gbcodec->component; + struct snd_card *card = comp->card->snd_card; struct gbaudio_jack *jack, *n; int mask; - dev_dbg(codec->dev, "Unregister %s module\n", module->name); + dev_dbg(comp->dev, "Unregister %s module\n", module->name); down_write(&card->controls_rwsem); mutex_lock(&gbcodec->lock); gbaudio_codec_cleanup(module); list_del(&module->list); - dev_dbg(codec->dev, "Process Unregister %s module\n", module->name); + dev_dbg(comp->dev, "Process Unregister %s module\n", module->name); mutex_unlock(&gbcodec->lock); #ifdef CONFIG_SND_JACK @@ -983,99 +983,97 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module) dev_dbg(module->dev, "Report %s removal\n", jack->jack.jack->id); snd_soc_jack_report(&jack->jack, 0, mask); - snd_device_free(codec->card->snd_card, jack->jack.jack); + snd_device_free(comp->card->snd_card, + jack->jack.jack); list_del(&jack->list); } } #endif if (module->dapm_routes) { - dev_dbg(codec->dev, "Removing %d routes\n", + dev_dbg(comp->dev, "Removing %d routes\n", module->num_dapm_routes); - snd_soc_dapm_del_routes(&codec->dapm, module->dapm_routes, + snd_soc_dapm_del_routes(&comp->dapm, module->dapm_routes, module->num_dapm_routes); } if (module->controls) { - dev_dbg(codec->dev, "Removing %d controls\n", + dev_dbg(comp->dev, "Removing %d controls\n", module->num_controls); - snd_soc_remove_codec_controls(codec, module->controls, + snd_soc_remove_codec_controls(comp, module->controls, module->num_controls); } if (module->dapm_widgets) { - dev_dbg(codec->dev, "Removing %d widgets\n", + dev_dbg(comp->dev, "Removing %d widgets\n", module->num_dapm_widgets); - snd_soc_dapm_free_controls(&codec->dapm, module->dapm_widgets, + snd_soc_dapm_free_controls(&comp->dapm, module->dapm_widgets, module->num_dapm_widgets); } - dev_dbg(codec->dev, "Unregistered %s module\n", module->name); + dev_dbg(comp->dev, "Unregistered %s module\n", module->name); up_write(&card->controls_rwsem); } EXPORT_SYMBOL(gbaudio_unregister_module); /* - * codec driver ops + * component driver ops */ -static int gbcodec_probe(struct snd_soc_codec *codec) +static int gbcodec_probe(struct snd_soc_component *comp) { int i; struct gbaudio_codec_info *info; struct gbaudio_codec_dai *dai; - info = devm_kzalloc(codec->dev, sizeof(*info), GFP_KERNEL); + info = devm_kzalloc(comp->dev, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; - info->dev = codec->dev; + info->dev = comp->dev; INIT_LIST_HEAD(&info->module_list); mutex_init(&info->lock); INIT_LIST_HEAD(&info->dai_list); /* init dai_list used to maintain runtime stream info */ for (i = 0; i < ARRAY_SIZE(gbaudio_dai); i++) { - dai = devm_kzalloc(codec->dev, sizeof(*dai), GFP_KERNEL); + dai = devm_kzalloc(comp->dev, sizeof(*dai), GFP_KERNEL); if (!dai) return -ENOMEM; dai->id = gbaudio_dai[i].id; list_add(&dai->list, &info->dai_list); } - info->codec = codec; - snd_soc_codec_set_drvdata(codec, info); + info->component = comp; + snd_soc_component_set_drvdata(comp, info); gbcodec = info; - device_init_wakeup(codec->dev, 1); + device_init_wakeup(comp->dev, 1); return 0; } -static int gbcodec_remove(struct snd_soc_codec *codec) +static void gbcodec_remove(struct snd_soc_component *comp) { /* Empty function for now */ - return 0; + return; } -static int gbcodec_write(struct snd_soc_codec *codec, unsigned int reg, +static int gbcodec_write(struct snd_soc_component *comp, unsigned int reg, unsigned int value) { return 0; } -static unsigned int gbcodec_read(struct snd_soc_codec *codec, +static unsigned int gbcodec_read(struct snd_soc_component *comp, unsigned int reg) { return 0; } -static struct snd_soc_codec_driver soc_codec_dev_gbaudio = { +static const struct snd_soc_component_driver soc_codec_dev_gbaudio = { .probe = gbcodec_probe, .remove = gbcodec_remove, .read = gbcodec_read, .write = gbcodec_write, - - .idle_bias_off = true, - .ignore_pmdown_time = 1, }; #ifdef CONFIG_PM @@ -1099,13 +1097,13 @@ static const struct dev_pm_ops gbaudio_codec_pm_ops = { static int gbaudio_codec_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_gbaudio, + return devm_snd_soc_register_component(&pdev->dev, + &soc_codec_dev_gbaudio, gbaudio_dai, ARRAY_SIZE(gbaudio_dai)); } static int gbaudio_codec_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); return 0; } diff --git a/drivers/staging/greybus/audio_codec.h b/drivers/staging/greybus/audio_codec.h index af9195eceb3a..ce15e800e607 100644 --- a/drivers/staging/greybus/audio_codec.h +++ b/drivers/staging/greybus/audio_codec.h @@ -66,7 +66,7 @@ struct gbaudio_codec_dai { struct gbaudio_codec_info { struct device *dev; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct list_head module_list; /* to maintain runtime stream params for each DAI */ struct list_head dai_list; -- cgit v1.2.3-58-ga151 From c4bb7dcf143f89c024ad439871f75d4a9f72cbc1 Mon Sep 17 00:00:00 2001 From: Vaibhav Agarwal Date: Thu, 9 Jul 2020 15:57:20 +0530 Subject: staging: greybus: audio: Resolve compilation error in topology parser Fix compilation errors for GB Audio topology parser code with recent kernel versions. Signed-off-by: Vaibhav Agarwal Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/2542330352ae1d01469a616ea45edb461615e072.1594290158.git.vaibhav.sr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_topology.c | 123 ++++++++++++++----------------- 1 file changed, 57 insertions(+), 66 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c index 4ac30accf226..ad88d3127a60 100644 --- a/drivers/staging/greybus/audio_topology.c +++ b/drivers/staging/greybus/audio_topology.c @@ -5,8 +5,8 @@ * Copyright 2015-2016 Linaro Ltd. */ +#include #include "audio_codec.h" -#include "greybus_protocols.h" #define GBAUDIO_INVALID_ID 0xFF @@ -165,15 +165,15 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol, struct gbaudio_ctl_pvt *data; struct gb_audio_ctl_elem_info *info; struct gbaudio_module_info *module; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - struct gbaudio_codec_info *gbcodec = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct gbaudio_codec_info *gbcodec = snd_soc_component_get_drvdata(comp); - dev_dbg(codec->dev, "Entered %s:%s\n", __func__, kcontrol->id.name); + dev_dbg(comp->dev, "Entered %s:%s\n", __func__, kcontrol->id.name); data = (struct gbaudio_ctl_pvt *)kcontrol->private_value; info = (struct gb_audio_ctl_elem_info *)data->info; if (!info) { - dev_err(codec->dev, "NULL info for %s\n", uinfo->id.name); + dev_err(comp->dev, "NULL info for %s\n", uinfo->id.name); return -EINVAL; } @@ -201,7 +201,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol, strlcpy(uinfo->value.enumerated.name, name, NAME_SIZE); break; default: - dev_err(codec->dev, "Invalid type: %d for %s:kcontrol\n", + dev_err(comp->dev, "Invalid type: %d for %s:kcontrol\n", info->type, kcontrol->id.name); break; } @@ -216,11 +216,11 @@ static int gbcodec_mixer_ctl_get(struct snd_kcontrol *kcontrol, struct gbaudio_ctl_pvt *data; struct gb_audio_ctl_elem_value gbvalue; struct gbaudio_module_info *module; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct gbaudio_codec_info *gb = snd_soc_component_get_drvdata(comp); struct gb_bundle *bundle; - dev_dbg(codec->dev, "Entered %s:%s\n", __func__, kcontrol->id.name); + dev_dbg(comp->dev, "Entered %s:%s\n", __func__, kcontrol->id.name); module = find_gb_module(gb, kcontrol->id.name); if (!module) return -EINVAL; @@ -239,7 +239,7 @@ static int gbcodec_mixer_ctl_get(struct snd_kcontrol *kcontrol, gb_pm_runtime_put_autosuspend(bundle); if (ret) { - dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret, + dev_err_ratelimited(comp->dev, "%d:Error in %s for %s\n", ret, __func__, kcontrol->id.name); return ret; } @@ -262,7 +262,7 @@ static int gbcodec_mixer_ctl_get(struct snd_kcontrol *kcontrol, le32_to_cpu(gbvalue.value.enumerated_item[1]); break; default: - dev_err(codec->dev, "Invalid type: %d for %s:kcontrol\n", + dev_err(comp->dev, "Invalid type: %d for %s:kcontrol\n", info->type, kcontrol->id.name); ret = -EINVAL; break; @@ -278,11 +278,11 @@ static int gbcodec_mixer_ctl_put(struct snd_kcontrol *kcontrol, struct gbaudio_ctl_pvt *data; struct gb_audio_ctl_elem_value gbvalue; struct gbaudio_module_info *module; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct gbaudio_codec_info *gb = snd_soc_component_get_drvdata(comp); struct gb_bundle *bundle; - dev_dbg(codec->dev, "Entered %s:%s\n", __func__, kcontrol->id.name); + dev_dbg(comp->dev, "Entered %s:%s\n", __func__, kcontrol->id.name); module = find_gb_module(gb, kcontrol->id.name); if (!module) return -EINVAL; @@ -309,7 +309,7 @@ static int gbcodec_mixer_ctl_put(struct snd_kcontrol *kcontrol, cpu_to_le32(ucontrol->value.enumerated.item[1]); break; default: - dev_err(codec->dev, "Invalid type: %d for %s:kcontrol\n", + dev_err(comp->dev, "Invalid type: %d for %s:kcontrol\n", info->type, kcontrol->id.name); ret = -EINVAL; break; @@ -328,7 +328,7 @@ static int gbcodec_mixer_ctl_put(struct snd_kcontrol *kcontrol, gb_pm_runtime_put_autosuspend(bundle); if (ret) { - dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret, + dev_err_ratelimited(comp->dev, "%d:Error in %s for %s\n", ret, __func__, kcontrol->id.name); } @@ -352,11 +352,7 @@ static int gbcodec_mixer_dapm_ctl_info(struct snd_kcontrol *kcontrol, int platform_max, platform_min; struct gbaudio_ctl_pvt *data; struct gb_audio_ctl_elem_info *info; - struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_widget *widget = wlist->widgets[0]; - struct snd_soc_codec *codec = widget->codec; - dev_dbg(codec->dev, "Entered %s:%s\n", __func__, kcontrol->id.name); data = (struct gbaudio_ctl_pvt *)kcontrol->private_value; info = (struct gb_audio_ctl_elem_info *)data->info; @@ -387,11 +383,11 @@ static int gbcodec_mixer_dapm_ctl_get(struct snd_kcontrol *kcontrol, struct gbaudio_module_info *module; struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; - struct snd_soc_codec *codec = widget->codec; - struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec); + struct device *codec_dev = widget->dapm->dev; + struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev); struct gb_bundle *bundle; - dev_dbg(codec->dev, "Entered %s:%s\n", __func__, kcontrol->id.name); + dev_dbg(codec_dev, "Entered %s:%s\n", __func__, kcontrol->id.name); module = find_gb_module(gb, kcontrol->id.name); if (!module) return -EINVAL; @@ -415,7 +411,7 @@ static int gbcodec_mixer_dapm_ctl_get(struct snd_kcontrol *kcontrol, gb_pm_runtime_put_autosuspend(bundle); if (ret) { - dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret, + dev_err_ratelimited(codec_dev, "%d:Error in %s for %s\n", ret, __func__, kcontrol->id.name); return ret; } @@ -437,11 +433,11 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol, struct gbaudio_module_info *module; struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol); struct snd_soc_dapm_widget *widget = wlist->widgets[0]; - struct snd_soc_codec *codec = widget->codec; - struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec); + struct device *codec_dev = widget->dapm->dev; + struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev); struct gb_bundle *bundle; - dev_dbg(codec->dev, "Entered %s:%s\n", __func__, kcontrol->id.name); + dev_dbg(codec_dev, "Entered %s:%s\n", __func__, kcontrol->id.name); module = find_gb_module(gb, kcontrol->id.name); if (!module) return -EINVAL; @@ -464,11 +460,8 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol, if (gbvalue.value.integer_value[0] != val) { for (wi = 0; wi < wlist->num_widgets; wi++) { widget = wlist->widgets[wi]; - - widget->value = val; - widget->dapm->update = NULL; - snd_soc_dapm_mixer_update_power(widget, kcontrol, - connect); + snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, + connect, NULL); } gbvalue.value.integer_value[0] = cpu_to_le32(ucontrol->value.integer.value[0]); @@ -484,7 +477,7 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol, gb_pm_runtime_put_autosuspend(bundle); if (ret) { - dev_err_ratelimited(codec->dev, + dev_err_ratelimited(codec_dev, "%d:Error in %s for %s\n", ret, __func__, kcontrol->id.name); return ret; @@ -553,11 +546,11 @@ static int gbcodec_enum_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret, ctl_id; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct gbaudio_codec_info *gb = snd_soc_component_get_drvdata(comp); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct gb_audio_ctl_elem_value gbvalue; struct gbaudio_module_info *module; - struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec); struct gb_bundle *bundle; module = find_gb_module(gb, kcontrol->id.name); @@ -580,7 +573,7 @@ static int gbcodec_enum_ctl_get(struct snd_kcontrol *kcontrol, gb_pm_runtime_put_autosuspend(bundle); if (ret) { - dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret, + dev_err_ratelimited(comp->dev, "%d:Error in %s for %s\n", ret, __func__, kcontrol->id.name); return ret; } @@ -598,11 +591,11 @@ static int gbcodec_enum_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret, ctl_id; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *comp = snd_soc_kcontrol_component(kcontrol); + struct gbaudio_codec_info *gb = snd_soc_component_get_drvdata(comp); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct gb_audio_ctl_elem_value gbvalue; struct gbaudio_module_info *module; - struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec); struct gb_bundle *bundle; module = find_gb_module(gb, kcontrol->id.name); @@ -613,13 +606,13 @@ static int gbcodec_enum_ctl_put(struct snd_kcontrol *kcontrol, if (ctl_id < 0) return -EINVAL; - if (ucontrol->value.enumerated.item[0] > e->max - 1) + if (ucontrol->value.enumerated.item[0] > e->items - 1) return -EINVAL; gbvalue.value.enumerated_item[0] = cpu_to_le32(ucontrol->value.enumerated.item[0]); if (e->shift_l != e->shift_r) { - if (ucontrol->value.enumerated.item[1] > e->max - 1) + if (ucontrol->value.enumerated.item[1] > e->items - 1) return -EINVAL; gbvalue.value.enumerated_item[1] = cpu_to_le32(ucontrol->value.enumerated.item[1]); @@ -637,8 +630,8 @@ static int gbcodec_enum_ctl_put(struct snd_kcontrol *kcontrol, gb_pm_runtime_put_autosuspend(bundle); if (ret) { - dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret, - __func__, kcontrol->id.name); + dev_err_ratelimited(comp->dev, "%d:Error in %s for %s\n", + ret, __func__, kcontrol->id.name); } return ret; @@ -659,13 +652,13 @@ static int gbaudio_tplg_create_enum_kctl(struct gbaudio_module_info *gb, gb_enum = &ctl->info.value.enumerated; /* since count=1, and reg is dummy */ - gbe->max = le32_to_cpu(gb_enum->items); + gbe->items = le32_to_cpu(gb_enum->items); gbe->texts = gb_generate_enum_strings(gb, gb_enum); /* debug enum info */ - dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->max, + dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->items, le16_to_cpu(gb_enum->names_length)); - for (i = 0; i < gbe->max; i++) + for (i = 0; i < gbe->items; i++) dev_dbg(gb->dev, "src[%d]: %s\n", i, gbe->texts[i]); *kctl = (struct snd_kcontrol_new) @@ -720,8 +713,8 @@ static int gbcodec_enum_dapm_ctl_get(struct snd_kcontrol *kcontrol, struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct gbaudio_module_info *module; struct gb_audio_ctl_elem_value gbvalue; - struct snd_soc_codec *codec = widget->codec; - struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec); + struct device *codec_dev = widget->dapm->dev; + struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct gb_bundle *bundle; @@ -745,7 +738,7 @@ static int gbcodec_enum_dapm_ctl_get(struct snd_kcontrol *kcontrol, gb_pm_runtime_put_autosuspend(bundle); if (ret) { - dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret, + dev_err_ratelimited(codec_dev, "%d:Error in %s for %s\n", ret, __func__, kcontrol->id.name); return ret; } @@ -768,12 +761,12 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol, struct snd_soc_dapm_widget *widget = wlist->widgets[0]; struct gb_audio_ctl_elem_value gbvalue; struct gbaudio_module_info *module; - struct snd_soc_codec *codec = widget->codec; - struct gbaudio_codec_info *gb = snd_soc_codec_get_drvdata(codec); + struct device *codec_dev = widget->dapm->dev; + struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct gb_bundle *bundle; - if (ucontrol->value.enumerated.item[0] > e->max - 1) + if (ucontrol->value.enumerated.item[0] > e->items - 1) return -EINVAL; module = find_gb_module(gb, kcontrol->id.name); @@ -797,7 +790,7 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol, gb_pm_runtime_put_autosuspend(bundle); if (ret) { - dev_err_ratelimited(codec->dev, "%d:Error in %s for %s\n", ret, + dev_err_ratelimited(codec_dev, "%d:Error in %s for %s\n", ret, __func__, kcontrol->id.name); return ret; } @@ -814,7 +807,7 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol, } if (e->shift_l != e->shift_r) { - if (ucontrol->value.enumerated.item[1] > e->max - 1) + if (ucontrol->value.enumerated.item[1] > e->items - 1) return -EINVAL; val |= ucontrol->value.enumerated.item[1] << e->shift_r; mask |= e->mask << e->shift_r; @@ -837,16 +830,14 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol, gb_pm_runtime_put_autosuspend(bundle); if (ret) { - dev_err_ratelimited(codec->dev, + dev_err_ratelimited(codec_dev, "%d:Error in %s for %s\n", ret, __func__, kcontrol->id.name); } for (wi = 0; wi < wlist->num_widgets; wi++) { widget = wlist->widgets[wi]; - - widget->value = val; - widget->dapm->update = NULL; - snd_soc_dapm_mux_update_power(widget, kcontrol, mux, e); + snd_soc_dapm_mux_update_power(widget->dapm, kcontrol, + val, e, NULL); } } @@ -868,13 +859,13 @@ static int gbaudio_tplg_create_enum_ctl(struct gbaudio_module_info *gb, gb_enum = &ctl->info.value.enumerated; /* since count=1, and reg is dummy */ - gbe->max = le32_to_cpu(gb_enum->items); + gbe->items = le32_to_cpu(gb_enum->items); gbe->texts = gb_generate_enum_strings(gb, gb_enum); /* debug enum info */ - dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->max, + dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->items, le16_to_cpu(gb_enum->names_length)); - for (i = 0; i < gbe->max; i++) + for (i = 0; i < gbe->items; i++) dev_dbg(gb->dev, "src[%d]: %s\n", i, gbe->texts[i]); *kctl = (struct snd_kcontrol_new) @@ -935,12 +926,12 @@ static int gbaudio_widget_event(struct snd_soc_dapm_widget *w, { int wid; int ret; - struct snd_soc_codec *codec = w->codec; - struct gbaudio_codec_info *gbcodec = snd_soc_codec_get_drvdata(codec); + struct device *codec_dev = w->dapm->dev; + struct gbaudio_codec_info *gbcodec = dev_get_drvdata(codec_dev); struct gbaudio_module_info *module; struct gb_bundle *bundle; - dev_dbg(codec->dev, "%s %s %d\n", __func__, w->name, event); + dev_dbg(codec_dev, "%s %s %d\n", __func__, w->name, event); /* Find relevant module */ module = find_gb_module(gbcodec, w->name); @@ -950,7 +941,7 @@ static int gbaudio_widget_event(struct snd_soc_dapm_widget *w, /* map name to widget id */ wid = gbaudio_map_widgetname(module, w->name); if (wid < 0) { - dev_err(codec->dev, "Invalid widget name:%s\n", w->name); + dev_err(codec_dev, "Invalid widget name:%s\n", w->name); return -EINVAL; } @@ -973,7 +964,7 @@ static int gbaudio_widget_event(struct snd_soc_dapm_widget *w, break; } if (ret) - dev_err_ratelimited(codec->dev, + dev_err_ratelimited(codec_dev, "%d: widget, event:%d failed:%d\n", wid, event, ret); -- cgit v1.2.3-58-ga151 From 510e340efe0cbd379cf1ff3490d088c3299749b1 Mon Sep 17 00:00:00 2001 From: Vaibhav Agarwal Date: Thu, 9 Jul 2020 15:57:21 +0530 Subject: staging: greybus: audio: Add helper APIs for dynamic audio modules Greybus Codec driver allows modules to be dynamically added and removed, which further requires updating the DAPM configurations as well. With current snd_soc architecture, dynamic audio modules is not yet supported. This patch provides helper APIs to update DAPM configurations in response to modules which are dynamically added or removed. The source is primarily based on snd_dapm.c Signed-off-by: Vaibhav Agarwal Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/35e1baaae10a3f2162e71be4c2f75a701584f0e6.1594290158.git.vaibhav.sr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/Makefile | 2 +- drivers/staging/greybus/audio_codec.c | 12 +- drivers/staging/greybus/audio_helper.c | 197 +++++++++++++++++++++++++++++++++ drivers/staging/greybus/audio_helper.h | 17 +++ 4 files changed, 223 insertions(+), 5 deletions(-) create mode 100644 drivers/staging/greybus/audio_helper.c create mode 100644 drivers/staging/greybus/audio_helper.h (limited to 'drivers/staging') diff --git a/drivers/staging/greybus/Makefile b/drivers/staging/greybus/Makefile index 627e44f2a983..3b4b6cabff19 100644 --- a/drivers/staging/greybus/Makefile +++ b/drivers/staging/greybus/Makefile @@ -28,7 +28,7 @@ obj-$(CONFIG_GREYBUS_VIBRATOR) += gb-vibrator.o # Greybus Audio is a bunch of modules gb-audio-module-y := audio_module.o audio_topology.o -gb-audio-codec-y := audio_codec.o +gb-audio-codec-y := audio_codec.o audio_helper.o gb-audio-gb-y := audio_gb.o gb-audio-apbridgea-y := audio_apbridgea.o gb-audio-manager-y := audio_manager.o audio_manager_module.o diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c index 0ecdba27086b..74538f8c5fa4 100644 --- a/drivers/staging/greybus/audio_codec.c +++ b/drivers/staging/greybus/audio_codec.c @@ -14,6 +14,7 @@ #include "audio_codec.h" #include "audio_apbridgea.h" #include "audio_manager.h" +#include "audio_helper.h" static struct gbaudio_codec_info *gbcodec; @@ -865,7 +866,7 @@ int gbaudio_register_module(struct gbaudio_module_info *module) /* card already instantiated, create widgets here only */ if (comp->card->instantiated) { - snd_soc_dapm_link_component_dai_widgets(comp->card, + gbaudio_dapm_link_component_dai_widgets(comp->card, &comp->dapm); #ifdef CONFIG_SND_JACK /* @@ -999,13 +1000,16 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module) if (module->controls) { dev_dbg(comp->dev, "Removing %d controls\n", module->num_controls); - snd_soc_remove_codec_controls(comp, module->controls, - module->num_controls); + /* release control semaphore */ + up_write(&card->controls_rwsem); + gbaudio_remove_component_controls(comp, module->controls, + module->num_controls); + down_write(&card->controls_rwsem); } if (module->dapm_widgets) { dev_dbg(comp->dev, "Removing %d widgets\n", module->num_dapm_widgets); - snd_soc_dapm_free_controls(&comp->dapm, module->dapm_widgets, + gbaudio_dapm_free_controls(&comp->dapm, module->dapm_widgets, module->num_dapm_widgets); } diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c new file mode 100644 index 000000000000..faaa39708118 --- /dev/null +++ b/drivers/staging/greybus/audio_helper.c @@ -0,0 +1,197 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Greybus Audio Sound SoC helper APIs + */ + +#include +#include +#include +#include + +#define gbaudio_dapm_for_each_direction(dir) \ + for ((dir) = SND_SOC_DAPM_DIR_IN; (dir) <= SND_SOC_DAPM_DIR_OUT; \ + (dir)++) + +static void gbaudio_dapm_link_dai_widget(struct snd_soc_dapm_widget *dai_w, + struct snd_soc_card *card) +{ + struct snd_soc_dapm_widget *w; + struct snd_soc_dapm_widget *src, *sink; + struct snd_soc_dai *dai = dai_w->priv; + + /* ...find all widgets with the same stream and link them */ + list_for_each_entry(w, &card->widgets, list) { + if (w->dapm != dai_w->dapm) + continue; + + switch (w->id) { + case snd_soc_dapm_dai_in: + case snd_soc_dapm_dai_out: + continue; + default: + break; + } + + if (!w->sname || !strstr(w->sname, dai_w->sname)) + continue; + + /* + * check if widget is already linked, + * if (w->linked) + * return; + */ + + if (dai_w->id == snd_soc_dapm_dai_in) { + src = dai_w; + sink = w; + } else { + src = w; + sink = dai_w; + } + dev_dbg(dai->dev, "%s -> %s\n", src->name, sink->name); + /* Add the DAPM path and set widget's linked status + * snd_soc_dapm_add_path(w->dapm, src, sink, NULL, NULL); + * w->linked = 1; + */ + } +} + +int gbaudio_dapm_link_component_dai_widgets(struct snd_soc_card *card, + struct snd_soc_dapm_context *dapm) +{ + struct snd_soc_dapm_widget *dai_w; + + /* For each DAI widget... */ + list_for_each_entry(dai_w, &card->widgets, list) { + if (dai_w->dapm != dapm) + continue; + switch (dai_w->id) { + case snd_soc_dapm_dai_in: + case snd_soc_dapm_dai_out: + break; + default: + continue; + } + gbaudio_dapm_link_dai_widget(dai_w, card); + } + + return 0; +} + +static void gbaudio_dapm_free_path(struct snd_soc_dapm_path *path) +{ + list_del(&path->list_node[SND_SOC_DAPM_DIR_IN]); + list_del(&path->list_node[SND_SOC_DAPM_DIR_OUT]); + list_del(&path->list_kcontrol); + list_del(&path->list); + kfree(path); +} + +static void gbaudio_dapm_free_widget(struct snd_soc_dapm_widget *w) +{ + struct snd_soc_dapm_path *p, *next_p; + enum snd_soc_dapm_direction dir; + + list_del(&w->list); + /* + * remove source and sink paths associated to this widget. + * While removing the path, remove reference to it from both + * source and sink widgets so that path is removed only once. + */ + gbaudio_dapm_for_each_direction(dir) { + snd_soc_dapm_widget_for_each_path_safe(w, dir, p, next_p) + gbaudio_dapm_free_path(p); + } + + kfree(w->kcontrols); + kfree_const(w->name); + kfree_const(w->sname); + kfree(w); +} + +int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm, + const struct snd_soc_dapm_widget *widget, + int num) +{ + int i; + struct snd_soc_dapm_widget *w, *next_w; +#ifdef CONFIG_DEBUG_FS + struct dentry *parent = dapm->debugfs_dapm; + struct dentry *debugfs_w = NULL; +#endif + + mutex_lock(&dapm->card->dapm_mutex); + for (i = 0; i < num; i++) { + /* below logic can be optimized to identify widget pointer */ + list_for_each_entry_safe(w, next_w, &dapm->card->widgets, + list) { + if (w->dapm != dapm) + continue; + if (!strcmp(w->name, widget->name)) + break; + w = NULL; + } + if (!w) { + dev_err(dapm->dev, "%s: widget not found\n", + widget->name); + return -EINVAL; + } + widget++; +#ifdef CONFIG_DEBUG_FS + if (!parent) + debugfs_w = debugfs_lookup(w->name, parent); + debugfs_remove(debugfs_w); + debugfs_w = NULL; +#endif + gbaudio_dapm_free_widget(w); + } + mutex_unlock(&dapm->card->dapm_mutex); + return 0; +} + +static int gbaudio_remove_controls(struct snd_card *card, struct device *dev, + const struct snd_kcontrol_new *controls, + int num_controls, const char *prefix) +{ + int i, err; + + for (i = 0; i < num_controls; i++) { + const struct snd_kcontrol_new *control = &controls[i]; + struct snd_ctl_elem_id id; + struct snd_kcontrol *kctl; + + if (prefix) + snprintf(id.name, sizeof(id.name), "%s %s", prefix, + control->name); + else + strlcpy(id.name, control->name, sizeof(id.name)); + id.numid = 0; + id.iface = control->iface; + id.device = control->device; + id.subdevice = control->subdevice; + id.index = control->index; + kctl = snd_ctl_find_id(card, &id); + if (!kctl) { + dev_err(dev, "%d: Failed to find %s\n", err, + control->name); + continue; + } + err = snd_ctl_remove(card, kctl); + if (err < 0) { + dev_err(dev, "%d: Failed to remove %s\n", err, + control->name); + continue; + } + } + return 0; +} + +int gbaudio_remove_component_controls(struct snd_soc_component *component, + const struct snd_kcontrol_new *controls, + unsigned int num_controls) +{ + struct snd_card *card = component->card->snd_card; + + return gbaudio_remove_controls(card, component->dev, controls, + num_controls, component->name_prefix); +} diff --git a/drivers/staging/greybus/audio_helper.h b/drivers/staging/greybus/audio_helper.h new file mode 100644 index 000000000000..5cf1c6d7d3ea --- /dev/null +++ b/drivers/staging/greybus/audio_helper.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Greybus Audio Sound SoC helper APIs + */ + +#ifndef __LINUX_GBAUDIO_HELPER_H +#define __LINUX_GBAUDIO_HELPER_H + +int gbaudio_dapm_link_component_dai_widgets(struct snd_soc_card *card, + struct snd_soc_dapm_context *dapm); +int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm, + const struct snd_soc_dapm_widget *widget, + int num); +int gbaudio_remove_component_controls(struct snd_soc_component *component, + const struct snd_kcontrol_new *controls, + unsigned int num_controls); +#endif -- cgit v1.2.3-58-ga151 From c9a57eddb235d53b0a8b9d740e454ef466086fc8 Mon Sep 17 00:00:00 2001 From: Vaibhav Agarwal Date: Thu, 9 Jul 2020 15:57:22 +0530 Subject: staging: greybus: audio: Enable GB codec, audio module compilation. Currently you can't enable the Gey Bus Audio Codec because there is no entry for it in the Kconfig file. Originally the config name was going to be AUDIO_MSM8994 but that's not correct because other types of hardware are supported now. I have chosen the name AUDIO_APB_CODEC instead. Also I had to update the dependencies for GREYBUS_AUDIO to make the compile work. Signed-off-by: Vaibhav Agarwal Reviewed-by: Dan Carpenter Link: https://lore.kernel.org/r/2b50959ccffe5a4372880d27e79ef3be1873372c.1594290158.git.vaibhav.sr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/Kconfig | 14 +++++++++++++- drivers/staging/greybus/Makefile | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/greybus/Kconfig b/drivers/staging/greybus/Kconfig index 9389e7a922fa..927cfa4bc989 100644 --- a/drivers/staging/greybus/Kconfig +++ b/drivers/staging/greybus/Kconfig @@ -3,7 +3,7 @@ if GREYBUS config GREYBUS_AUDIO tristate "Greybus Audio Class driver" - depends on SOUND + depends on SOUND && SND_SOC help Select this option if you have a device that follows the Greybus Audio Class specification. @@ -11,6 +11,18 @@ config GREYBUS_AUDIO To compile this code as a module, chose M here: the module will be called gb-audio.ko +config GREYBUS_AUDIO_APB_CODEC + tristate "Greybus APBridge Audio codec driver" + depends on SND_SOC && GREYBUS_AUDIO + help + Select this option if you have a Toshiba APB device that has I2S + ports and acts as a Greybus "Dummy codec". This device is a + bridge from an APB-I2S port to a Unipro network. + + To compile this code as a module, chose M here: the module + will be called gb-audio-codec.ko + + config GREYBUS_BOOTROM tristate "Greybus Bootrom Class driver" help diff --git a/drivers/staging/greybus/Makefile b/drivers/staging/greybus/Makefile index 3b4b6cabff19..7c5e89622334 100644 --- a/drivers/staging/greybus/Makefile +++ b/drivers/staging/greybus/Makefile @@ -40,8 +40,8 @@ gb-audio-manager-y := audio_manager.o audio_manager_module.o #ccflags-y += -DGB_AUDIO_MANAGER_SYSFS #endif -obj-$(CONFIG_GREYBUS_AUDIO_MSM8994) += gb-audio-codec.o -obj-$(CONFIG_GREYBUS_AUDIO_MSM8994) += gb-audio-module.o +obj-$(CONFIG_GREYBUS_AUDIO_APB_CODEC) += gb-audio-codec.o +obj-$(CONFIG_GREYBUS_AUDIO_APB_CODEC) += gb-audio-module.o obj-$(CONFIG_GREYBUS_AUDIO) += gb-audio-gb.o obj-$(CONFIG_GREYBUS_AUDIO) += gb-audio-apbridgea.o obj-$(CONFIG_GREYBUS_AUDIO) += gb-audio-manager.o -- cgit v1.2.3-58-ga151 From dbc676e722db28ab8cfb6cc857ac49d8808a5be4 Mon Sep 17 00:00:00 2001 From: Vaibhav Agarwal Date: Thu, 9 Jul 2020 15:57:23 +0530 Subject: drivers: staging: audio: Fix the missing header file for helper file This patch fixes the warning reported for missing prototypes due to missing header file. Also, it includes changes to remove unused_but_set_variables. Reported-by: kernel test robot Signed-off-by: Vaibhav Agarwal Link: https://lore.kernel.org/r/6341df9b0b5985047af0bbbc8e136481ac515b25.1594290158.git.vaibhav.sr@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_helper.c | 1 + drivers/staging/greybus/audio_topology.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c index faaa39708118..8b100a71f02e 100644 --- a/drivers/staging/greybus/audio_helper.c +++ b/drivers/staging/greybus/audio_helper.c @@ -7,6 +7,7 @@ #include #include #include +#include "audio_helper.h" #define gbaudio_dapm_for_each_direction(dir) \ for ((dir) = SND_SOC_DAPM_DIR_IN; (dir) <= SND_SOC_DAPM_DIR_OUT; \ diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c index ad88d3127a60..2f9fdbdcd547 100644 --- a/drivers/staging/greybus/audio_topology.c +++ b/drivers/staging/greybus/audio_topology.c @@ -28,14 +28,16 @@ static struct gbaudio_module_info *find_gb_module( struct gbaudio_codec_info *codec, char const *name) { - int dev_id, ret; + int dev_id; char begin[NAME_SIZE]; struct gbaudio_module_info *module; if (!name) return NULL; - ret = sscanf(name, "%s %d", begin, &dev_id); + if (sscanf(name, "%s %d", begin, &dev_id) != 2) + return NULL; + dev_dbg(codec->dev, "%s:Find module#%d\n", __func__, dev_id); mutex_lock(&codec->lock); @@ -377,7 +379,6 @@ static int gbcodec_mixer_dapm_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int ret; - struct gb_audio_ctl_elem_info *info; struct gbaudio_ctl_pvt *data; struct gb_audio_ctl_elem_value gbvalue; struct gbaudio_module_info *module; @@ -393,7 +394,6 @@ static int gbcodec_mixer_dapm_ctl_get(struct snd_kcontrol *kcontrol, return -EINVAL; data = (struct gbaudio_ctl_pvt *)kcontrol->private_value; - info = (struct gb_audio_ctl_elem_info *)data->info; bundle = to_gb_bundle(module->dev); if (data->vcount == 2) -- cgit v1.2.3-58-ga151 From d737e2891a922ae17f56dd5b0662821c6080524a Mon Sep 17 00:00:00 2001 From: Aditya Jain Date: Thu, 30 Jul 2020 00:51:34 +0530 Subject: staging: rtl8723bs: Fix coding style errors Fixing ERROR: "foo * bar" should be "foo *bar" in hal_phy_cfg.h as reported by checkpatch.pl Signed-off-by: Aditya Jain Link: https://lore.kernel.org/r/20200729192136.23828-2-aditya.jainadityajain.jain@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/hal_phy_cfg.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/hal_phy_cfg.h b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h index 419ddb0733aa..7e48abc4c760 100644 --- a/drivers/staging/rtl8723bs/include/hal_phy_cfg.h +++ b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h @@ -42,7 +42,7 @@ u32 Data u32 PHY_QueryRFReg_8723B( -struct adapter * Adapter, +struct adapter *Adapter, u8 eRFPath, u32 RegAddr, u32 BitMask @@ -50,7 +50,7 @@ u32 BitMask void PHY_SetRFReg_8723B( -struct adapter * Adapter, +struct adapter *Adapter, u8 eRFPath, u32 RegAddr, u32 BitMask, @@ -66,7 +66,7 @@ s32 PHY_MACConfig8723B(struct adapter *padapter); void PHY_SetTxPowerIndex( -struct adapter * Adapter, +struct adapter *Adapter, u32 PowerIndex, u8 RFPath, u8 Rate @@ -74,7 +74,7 @@ u8 Rate u8 PHY_GetTxPowerIndex( -struct adapter * padapter, +struct adapter *padapter, u8 RFPath, u8 Rate, enum CHANNEL_WIDTH BandWidth, @@ -83,19 +83,19 @@ u8 Channel void PHY_GetTxPowerLevel8723B( -struct adapter * Adapter, - s32* powerlevel +struct adapter *Adapter, + s32 *powerlevel ); void PHY_SetTxPowerLevel8723B( -struct adapter * Adapter, +struct adapter *Adapter, u8 channel ); void PHY_SetBWMode8723B( -struct adapter * Adapter, +struct adapter *Adapter, enum CHANNEL_WIDTH Bandwidth, /* 20M or 40M */ unsigned char Offset /* Upper, Lower, or Don't care */ ); @@ -108,7 +108,7 @@ u8 channel void PHY_SetSwChnlBWMode8723B( -struct adapter * Adapter, +struct adapter *Adapter, u8 channel, enum CHANNEL_WIDTH Bandwidth, u8 Offset40, -- cgit v1.2.3-58-ga151 From 0b64587a09f32475b3630d18cbaf88be51fb0583 Mon Sep 17 00:00:00 2001 From: Aditya Jain Date: Thu, 30 Jul 2020 00:51:35 +0530 Subject: staging: rtl8723bs: Clean up function declations Clean up multiline function declartions in hal_phy_cfg.h to improve code readablility Signed-off-by: Aditya Jain Link: https://lore.kernel.org/r/20200729192136.23828-3-aditya.jainadityajain.jain@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/hal_phy_cfg.h | 110 +++++++----------------- 1 file changed, 29 insertions(+), 81 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/hal_phy_cfg.h b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h index 7e48abc4c760..0eb3e57f4082 100644 --- a/drivers/staging/rtl8723bs/include/hal_phy_cfg.h +++ b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h @@ -25,37 +25,16 @@ /*------------------------------Define structure End----------------------------*/ /*--------------------------Exported Function prototype---------------------*/ -u32 -PHY_QueryBBReg_8723B( -struct adapter *Adapter, -u32 RegAddr, -u32 BitMask - ); - -void -PHY_SetBBReg_8723B( -struct adapter *Adapter, -u32 RegAddr, -u32 BitMask, -u32 Data - ); - -u32 -PHY_QueryRFReg_8723B( -struct adapter *Adapter, -u8 eRFPath, -u32 RegAddr, -u32 BitMask - ); - -void -PHY_SetRFReg_8723B( -struct adapter *Adapter, -u8 eRFPath, -u32 RegAddr, -u32 BitMask, -u32 Data - ); +u32 PHY_QueryBBReg_8723B(struct adapter *Adapter, u32 RegAddr, u32 BitMask); + +void PHY_SetBBReg_8723B(struct adapter *Adapter, u32 RegAddr, + u32 BitMask, u32 Data); + +u32 PHY_QueryRFReg_8723B(struct adapter *Adapter, u8 eRFPath, + u32 RegAddr, u32 BitMask); + +void PHY_SetRFReg_8723B(struct adapter *Adapter, u8 eRFPath, + u32 RegAddr, u32 BitMask, u32 Data); /* MAC/BB/RF HAL config */ int PHY_BBConfig8723B(struct adapter *Adapter); @@ -64,56 +43,25 @@ int PHY_RFConfig8723B(struct adapter *Adapter); s32 PHY_MACConfig8723B(struct adapter *padapter); -void -PHY_SetTxPowerIndex( -struct adapter *Adapter, -u32 PowerIndex, -u8 RFPath, -u8 Rate - ); - -u8 -PHY_GetTxPowerIndex( -struct adapter *padapter, -u8 RFPath, -u8 Rate, -enum CHANNEL_WIDTH BandWidth, -u8 Channel - ); - -void -PHY_GetTxPowerLevel8723B( -struct adapter *Adapter, - s32 *powerlevel - ); - -void -PHY_SetTxPowerLevel8723B( -struct adapter *Adapter, -u8 channel - ); - -void -PHY_SetBWMode8723B( -struct adapter *Adapter, -enum CHANNEL_WIDTH Bandwidth, /* 20M or 40M */ -unsigned char Offset /* Upper, Lower, or Don't care */ -); - -void -PHY_SwChnl8723B(/* Call after initialization */ -struct adapter *Adapter, -u8 channel - ); - -void -PHY_SetSwChnlBWMode8723B( -struct adapter *Adapter, -u8 channel, -enum CHANNEL_WIDTH Bandwidth, -u8 Offset40, -u8 Offset80 -); +void PHY_SetTxPowerIndex(struct adapter *Adapter, u32 PowerIndex, + u8 RFPath, u8 Rate); + +u8 PHY_GetTxPowerIndex(struct adapter *padapter, u8 RFPath, u8 Rate, + enum CHANNEL_WIDTH BandWidth, u8 Channel); + +void PHY_GetTxPowerLevel8723B(struct adapter *Adapter, s32 *powerlevel); + +void PHY_SetTxPowerLevel8723B(struct adapter *Adapter, u8 channel); + +void PHY_SetBWMode8723B(struct adapter *Adapter, enum CHANNEL_WIDTH Bandwidth, + unsigned char Offset); + +/* Call after initialization */ +void PHY_SwChnl8723B(struct adapter *Adapter, u8 channel); + +void PHY_SetSwChnlBWMode8723B(struct adapter *Adapter, u8 channel, + enum CHANNEL_WIDTH Bandwidth, + u8 Offset40, u8 Offset80); /*--------------------------Exported Function prototype End---------------------*/ -- cgit v1.2.3-58-ga151 From 051d2d09def02ef2508e69b64bb304a02af69c84 Mon Sep 17 00:00:00 2001 From: Aditya Jain Date: Thu, 30 Jul 2020 00:51:36 +0530 Subject: staging: rtl8723bs: Align macro definitions Adjust spacing in macro definitions to align them and improve readbility Signed-off-by: Aditya Jain Link: https://lore.kernel.org/r/20200729192136.23828-4-aditya.jainadityajain.jain@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/hal_phy_cfg.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/hal_phy_cfg.h b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h index 0eb3e57f4082..ed3488a09d79 100644 --- a/drivers/staging/rtl8723bs/include/hal_phy_cfg.h +++ b/drivers/staging/rtl8723bs/include/hal_phy_cfg.h @@ -8,11 +8,11 @@ #define __INC_HAL8723BPHYCFG_H__ /*--------------------------Define Parameters-------------------------------*/ -#define LOOP_LIMIT 5 -#define MAX_STALL_TIME 50 /* us */ +#define LOOP_LIMIT 5 +#define MAX_STALL_TIME 50 /* us */ #define AntennaDiversityValue 0x80 /* Adapter->bSoftwareAntennaDiversity ? 0x00:0x80) */ #define MAX_TXPWR_IDX_NMODE_92S 63 -#define Reset_Cnt_Limit 3 +#define Reset_Cnt_Limit 3 #define MAX_AGGR_NUM 0x07 -- cgit v1.2.3-58-ga151 From 3e1f8882a9f2a792f2627e7aac711d42bc809afe Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Wed, 29 Jul 2020 18:35:57 -0500 Subject: staging: wfx: Use flex_array_size() helper in memcpy() Make use of the flex_array_size() helper to calculate the size of a flexible array member within an enclosing structure. This helper offers defense-in-depth against potential integer overflows, while at the same time makes it explicitly clear that we are dealing with a flexible array member. Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20200729233557.GA17693@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/hif_tx_mib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wfx/hif_tx_mib.c b/drivers/staging/wfx/hif_tx_mib.c index 1689cb42acc0..05f1e1e98af9 100644 --- a/drivers/staging/wfx/hif_tx_mib.c +++ b/drivers/staging/wfx/hif_tx_mib.c @@ -113,7 +113,7 @@ int hif_set_beacon_filter_table(struct wfx_vif *wvif, int tbl_len, if (!val) return -ENOMEM; val->num_of_info_elmts = cpu_to_le32(tbl_len); - memcpy(val->ie_table, tbl, tbl_len * sizeof(*tbl)); + memcpy(val->ie_table, tbl, flex_array_size(val, ie_table, tbl_len)); ret = hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_BEACON_FILTER_TABLE, val, buf_len); kfree(val); -- cgit v1.2.3-58-ga151 From d8a0f85d394a0cc5dec2b290ebcf8ed3cfdc1a70 Mon Sep 17 00:00:00 2001 From: Dhiraj Sharma Date: Tue, 28 Jul 2020 23:56:10 +0530 Subject: staging: qlge: qlge_dbg: removed comment repition Inside function ql_get_dump comment statement had a repition of word "to" which I removed and checkpatch.pl ouputs zero error or warnings now. Signed-off-by: Dhiraj Sharma Link: https://lore.kernel.org/r/20200728182610.2538-1-dhiraj.sharma0024@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_dbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 985a6c341294..a55bf0b3e9dc 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -1298,7 +1298,7 @@ void ql_get_dump(struct ql_adapter *qdev, void *buff) * If the dump has already been taken and is stored * in our internal buffer and if force dump is set then * just start the spool to dump it to the log file - * and also, take a snapshot of the general regs to + * and also, take a snapshot of the general regs * to the user's buffer or else take complete dump * to the user's buffer if force is not set. */ -- cgit v1.2.3-58-ga151 From 536a4f75d48146ddf8beb97eaf454f616b6bf4b2 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 30 Jul 2020 18:23:12 +0300 Subject: staging: ks7010: Use %pM format specifier for MAC addresses Convert to %pM instead of using custom code. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200730152312.39076-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 2666f9e30c15..b10a92ae2067 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -161,7 +161,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info *ap_info) wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL); } netdev_dbg(priv->net_dev, "Link AP\n" - "- bssid=%02X:%02X:%02X:%02X:%02X:%02X\n" + "- bssid=%pM\n" "- essid=%s\n" "- rate_set=%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X\n" "- channel=%d\n" @@ -172,8 +172,7 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info *ap_info) "- rsn.size=%d\n" "- ext_rate_set_size=%d\n" "- rate_set_size=%d\n", - ap->bssid[0], ap->bssid[1], ap->bssid[2], - ap->bssid[3], ap->bssid[4], ap->bssid[5], + ap->bssid, &ap->ssid.body[0], ap->rate_set.body[0], ap->rate_set.body[1], ap->rate_set.body[2], ap->rate_set.body[3], @@ -439,11 +438,7 @@ void hostif_data_indication(struct ks_wlan_private *priv) /* source address check */ if (ether_addr_equal(&priv->eth_addr[0], eth_hdr->h_source)) { netdev_err(priv->net_dev, "invalid : source is own mac address !!\n"); - netdev_err(priv->net_dev, - "eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n", - eth_hdr->h_source[0], eth_hdr->h_source[1], - eth_hdr->h_source[2], eth_hdr->h_source[3], - eth_hdr->h_source[4], eth_hdr->h_source[5]); + netdev_err(priv->net_dev, "eth_hdrernet->h_dest=%pM\n", eth_hdr->h_source); priv->nstats.rx_errors++; return; } -- cgit v1.2.3-58-ga151 From 11c416e3f0ea437661514fa68967a5dba3cdf886 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 30 Jul 2020 18:15:06 +0300 Subject: staging: most: Use %pM format specifier for MAC addresses Convert to %pM instead of using custom code. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200730151506.38827-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/net/net.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c index 830f089f1a88..b6fecb06a0e6 100644 --- a/drivers/staging/most/net/net.c +++ b/drivers/staging/most/net/net.c @@ -564,13 +564,11 @@ static void on_netinfo(struct most_interface *iface, if (m && is_valid_ether_addr(m)) { if (!is_valid_ether_addr(dev->dev_addr)) { - netdev_info(dev, "set mac %02x-%02x-%02x-%02x-%02x-%02x\n", - m[0], m[1], m[2], m[3], m[4], m[5]); + netdev_info(dev, "set mac %pM\n", m); ether_addr_copy(dev->dev_addr, m); netif_dormant_off(dev); } else if (!ether_addr_equal(dev->dev_addr, m)) { - netdev_warn(dev, "reject mac %02x-%02x-%02x-%02x-%02x-%02x\n", - m[0], m[1], m[2], m[3], m[4], m[5]); + netdev_warn(dev, "reject mac %pM\n", m); } } -- cgit v1.2.3-58-ga151 From 97a6f772f36b7f52bcfa56a581bbd2470cffe23d Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Fri, 31 Jul 2020 14:20:58 +0200 Subject: drivers: most: add USB adapter driver This patch adds the USB driver source file most_usb.c and modifies the Makefile and Kconfig accordingly. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1596198058-26541-1-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/most/Kconfig | 11 + drivers/most/Makefile | 2 + drivers/most/most_usb.c | 1170 +++++++++++++++++++++++++++++++++++++ drivers/staging/most/Kconfig | 2 - drivers/staging/most/usb/Kconfig | 13 - drivers/staging/most/usb/Makefile | 4 - drivers/staging/most/usb/usb.c | 1170 ------------------------------------- 7 files changed, 1183 insertions(+), 1189 deletions(-) create mode 100644 drivers/most/most_usb.c delete mode 100644 drivers/staging/most/usb/Kconfig delete mode 100644 drivers/staging/most/usb/Makefile delete mode 100644 drivers/staging/most/usb/usb.c (limited to 'drivers/staging') diff --git a/drivers/most/Kconfig b/drivers/most/Kconfig index 58d7999170a7..60fc0820dad3 100644 --- a/drivers/most/Kconfig +++ b/drivers/most/Kconfig @@ -13,3 +13,14 @@ menuconfig MOST module will be called most_core. If in doubt, say N here. + +if MOST +config MOST_USB_HDM + tristate "USB" + depends on USB + help + Say Y here if you want to connect via USB to network transceiver. + + To compile this driver as a module, choose M here: the + module will be called most_usb. +endif diff --git a/drivers/most/Makefile b/drivers/most/Makefile index e810cd3a47ee..6a3cb9056288 100644 --- a/drivers/most/Makefile +++ b/drivers/most/Makefile @@ -2,3 +2,5 @@ obj-$(CONFIG_MOST) += most_core.o most_core-y := core.o \ configfs.o + +obj-$(CONFIG_MOST_USB_HDM) += most_usb.o diff --git a/drivers/most/most_usb.c b/drivers/most/most_usb.c new file mode 100644 index 000000000000..2640c5b326a4 --- /dev/null +++ b/drivers/most/most_usb.c @@ -0,0 +1,1170 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * usb.c - Hardware dependent module for USB + * + * Copyright (C) 2013-2015 Microchip Technology Germany II GmbH & Co. KG + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define USB_MTU 512 +#define NO_ISOCHRONOUS_URB 0 +#define AV_PACKETS_PER_XACT 2 +#define BUF_CHAIN_SIZE 0xFFFF +#define MAX_NUM_ENDPOINTS 30 +#define MAX_SUFFIX_LEN 10 +#define MAX_STRING_LEN 80 +#define MAX_BUF_SIZE 0xFFFF + +#define USB_VENDOR_ID_SMSC 0x0424 /* VID: SMSC */ +#define USB_DEV_ID_BRDG 0xC001 /* PID: USB Bridge */ +#define USB_DEV_ID_OS81118 0xCF18 /* PID: USB OS81118 */ +#define USB_DEV_ID_OS81119 0xCF19 /* PID: USB OS81119 */ +#define USB_DEV_ID_OS81210 0xCF30 /* PID: USB OS81210 */ +/* DRCI Addresses */ +#define DRCI_REG_NI_STATE 0x0100 +#define DRCI_REG_PACKET_BW 0x0101 +#define DRCI_REG_NODE_ADDR 0x0102 +#define DRCI_REG_NODE_POS 0x0103 +#define DRCI_REG_MEP_FILTER 0x0140 +#define DRCI_REG_HASH_TBL0 0x0141 +#define DRCI_REG_HASH_TBL1 0x0142 +#define DRCI_REG_HASH_TBL2 0x0143 +#define DRCI_REG_HASH_TBL3 0x0144 +#define DRCI_REG_HW_ADDR_HI 0x0145 +#define DRCI_REG_HW_ADDR_MI 0x0146 +#define DRCI_REG_HW_ADDR_LO 0x0147 +#define DRCI_REG_BASE 0x1100 +#define DRCI_COMMAND 0x02 +#define DRCI_READ_REQ 0xA0 +#define DRCI_WRITE_REQ 0xA1 + +/** + * struct most_dci_obj - Direct Communication Interface + * @kobj:position in sysfs + * @usb_device: pointer to the usb device + * @reg_addr: register address for arbitrary DCI access + */ +struct most_dci_obj { + struct device dev; + struct usb_device *usb_device; + u16 reg_addr; +}; + +#define to_dci_obj(p) container_of(p, struct most_dci_obj, dev) + +struct most_dev; + +struct clear_hold_work { + struct work_struct ws; + struct most_dev *mdev; + unsigned int channel; + int pipe; +}; + +#define to_clear_hold_work(w) container_of(w, struct clear_hold_work, ws) + +/** + * struct most_dev - holds all usb interface specific stuff + * @usb_device: pointer to usb device + * @iface: hardware interface + * @cap: channel capabilities + * @conf: channel configuration + * @dci: direct communication interface of hardware + * @ep_address: endpoint address table + * @description: device description + * @suffix: suffix for channel name + * @channel_lock: synchronize channel access + * @padding_active: indicates channel uses padding + * @is_channel_healthy: health status table of each channel + * @busy_urbs: list of anchored items + * @io_mutex: synchronize I/O with disconnect + * @link_stat_timer: timer for link status reports + * @poll_work_obj: work for polling link status + */ +struct most_dev { + struct device dev; + struct usb_device *usb_device; + struct most_interface iface; + struct most_channel_capability *cap; + struct most_channel_config *conf; + struct most_dci_obj *dci; + u8 *ep_address; + char description[MAX_STRING_LEN]; + char suffix[MAX_NUM_ENDPOINTS][MAX_SUFFIX_LEN]; + spinlock_t channel_lock[MAX_NUM_ENDPOINTS]; /* sync channel access */ + bool padding_active[MAX_NUM_ENDPOINTS]; + bool is_channel_healthy[MAX_NUM_ENDPOINTS]; + struct clear_hold_work clear_work[MAX_NUM_ENDPOINTS]; + struct usb_anchor *busy_urbs; + struct mutex io_mutex; + struct timer_list link_stat_timer; + struct work_struct poll_work_obj; + void (*on_netinfo)(struct most_interface *most_iface, + unsigned char link_state, unsigned char *addrs); +}; + +#define to_mdev(d) container_of(d, struct most_dev, iface) +#define to_mdev_from_dev(d) container_of(d, struct most_dev, dev) +#define to_mdev_from_work(w) container_of(w, struct most_dev, poll_work_obj) + +static void wq_clear_halt(struct work_struct *wq_obj); +static void wq_netinfo(struct work_struct *wq_obj); + +/** + * drci_rd_reg - read a DCI register + * @dev: usb device + * @reg: register address + * @buf: buffer to store data + * + * This is reads data from INIC's direct register communication interface + */ +static inline int drci_rd_reg(struct usb_device *dev, u16 reg, u16 *buf) +{ + int retval; + __le16 *dma_buf; + u8 req_type = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE; + + dma_buf = kzalloc(sizeof(*dma_buf), GFP_KERNEL); + if (!dma_buf) + return -ENOMEM; + + retval = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), + DRCI_READ_REQ, req_type, + 0x0000, + reg, dma_buf, sizeof(*dma_buf), 5 * HZ); + *buf = le16_to_cpu(*dma_buf); + kfree(dma_buf); + + if (retval < 0) + return retval; + return 0; +} + +/** + * drci_wr_reg - write a DCI register + * @dev: usb device + * @reg: register address + * @data: data to write + * + * This is writes data to INIC's direct register communication interface + */ +static inline int drci_wr_reg(struct usb_device *dev, u16 reg, u16 data) +{ + return usb_control_msg(dev, + usb_sndctrlpipe(dev, 0), + DRCI_WRITE_REQ, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + data, + reg, + NULL, + 0, + 5 * HZ); +} + +static inline int start_sync_ep(struct usb_device *usb_dev, u16 ep) +{ + return drci_wr_reg(usb_dev, DRCI_REG_BASE + DRCI_COMMAND + ep * 16, 1); +} + +/** + * get_stream_frame_size - calculate frame size of current configuration + * @dev: device structure + * @cfg: channel configuration + */ +static unsigned int get_stream_frame_size(struct device *dev, + struct most_channel_config *cfg) +{ + unsigned int frame_size; + unsigned int sub_size = cfg->subbuffer_size; + + if (!sub_size) { + dev_warn(dev, "Misconfig: Subbuffer size zero.\n"); + return 0; + } + switch (cfg->data_type) { + case MOST_CH_ISOC: + frame_size = AV_PACKETS_PER_XACT * sub_size; + break; + case MOST_CH_SYNC: + if (cfg->packets_per_xact == 0) { + dev_warn(dev, "Misconfig: Packets per XACT zero\n"); + frame_size = 0; + } else if (cfg->packets_per_xact == 0xFF) { + frame_size = (USB_MTU / sub_size) * sub_size; + } else { + frame_size = cfg->packets_per_xact * sub_size; + } + break; + default: + dev_warn(dev, "Query frame size of non-streaming channel\n"); + frame_size = 0; + break; + } + return frame_size; +} + +/** + * hdm_poison_channel - mark buffers of this channel as invalid + * @iface: pointer to the interface + * @channel: channel ID + * + * This unlinks all URBs submitted to the HCD, + * calls the associated completion function of the core and removes + * them from the list. + * + * Returns 0 on success or error code otherwise. + */ +static int hdm_poison_channel(struct most_interface *iface, int channel) +{ + struct most_dev *mdev = to_mdev(iface); + unsigned long flags; + spinlock_t *lock; /* temp. lock */ + + if (channel < 0 || channel >= iface->num_channels) { + dev_warn(&mdev->usb_device->dev, "Channel ID out of range.\n"); + return -ECHRNG; + } + + lock = mdev->channel_lock + channel; + spin_lock_irqsave(lock, flags); + mdev->is_channel_healthy[channel] = false; + spin_unlock_irqrestore(lock, flags); + + cancel_work_sync(&mdev->clear_work[channel].ws); + + mutex_lock(&mdev->io_mutex); + usb_kill_anchored_urbs(&mdev->busy_urbs[channel]); + if (mdev->padding_active[channel]) + mdev->padding_active[channel] = false; + + if (mdev->conf[channel].data_type == MOST_CH_ASYNC) { + del_timer_sync(&mdev->link_stat_timer); + cancel_work_sync(&mdev->poll_work_obj); + } + mutex_unlock(&mdev->io_mutex); + return 0; +} + +/** + * hdm_add_padding - add padding bytes + * @mdev: most device + * @channel: channel ID + * @mbo: buffer object + * + * This inserts the INIC hardware specific padding bytes into a streaming + * channel's buffer + */ +static int hdm_add_padding(struct most_dev *mdev, int channel, struct mbo *mbo) +{ + struct most_channel_config *conf = &mdev->conf[channel]; + unsigned int frame_size = get_stream_frame_size(&mdev->dev, conf); + unsigned int j, num_frames; + + if (!frame_size) + return -EINVAL; + num_frames = mbo->buffer_length / frame_size; + + if (num_frames < 1) { + dev_err(&mdev->usb_device->dev, + "Missed minimal transfer unit.\n"); + return -EINVAL; + } + + for (j = num_frames - 1; j > 0; j--) + memmove(mbo->virt_address + j * USB_MTU, + mbo->virt_address + j * frame_size, + frame_size); + mbo->buffer_length = num_frames * USB_MTU; + return 0; +} + +/** + * hdm_remove_padding - remove padding bytes + * @mdev: most device + * @channel: channel ID + * @mbo: buffer object + * + * This takes the INIC hardware specific padding bytes off a streaming + * channel's buffer. + */ +static int hdm_remove_padding(struct most_dev *mdev, int channel, + struct mbo *mbo) +{ + struct most_channel_config *const conf = &mdev->conf[channel]; + unsigned int frame_size = get_stream_frame_size(&mdev->dev, conf); + unsigned int j, num_frames; + + if (!frame_size) + return -EINVAL; + num_frames = mbo->processed_length / USB_MTU; + + for (j = 1; j < num_frames; j++) + memmove(mbo->virt_address + frame_size * j, + mbo->virt_address + USB_MTU * j, + frame_size); + + mbo->processed_length = frame_size * num_frames; + return 0; +} + +/** + * hdm_write_completion - completion function for submitted Tx URBs + * @urb: the URB that has been completed + * + * This checks the status of the completed URB. In case the URB has been + * unlinked before, it is immediately freed. On any other error the MBO + * transfer flag is set. On success it frees allocated resources and calls + * the completion function. + * + * Context: interrupt! + */ +static void hdm_write_completion(struct urb *urb) +{ + struct mbo *mbo = urb->context; + struct most_dev *mdev = to_mdev(mbo->ifp); + unsigned int channel = mbo->hdm_channel_id; + spinlock_t *lock = mdev->channel_lock + channel; + unsigned long flags; + + spin_lock_irqsave(lock, flags); + + mbo->processed_length = 0; + mbo->status = MBO_E_INVAL; + if (likely(mdev->is_channel_healthy[channel])) { + switch (urb->status) { + case 0: + case -ESHUTDOWN: + mbo->processed_length = urb->actual_length; + mbo->status = MBO_SUCCESS; + break; + case -EPIPE: + dev_warn(&mdev->usb_device->dev, + "Broken pipe on ep%02x\n", + mdev->ep_address[channel]); + mdev->is_channel_healthy[channel] = false; + mdev->clear_work[channel].pipe = urb->pipe; + schedule_work(&mdev->clear_work[channel].ws); + break; + case -ENODEV: + case -EPROTO: + mbo->status = MBO_E_CLOSE; + break; + } + } + + spin_unlock_irqrestore(lock, flags); + + if (likely(mbo->complete)) + mbo->complete(mbo); + usb_free_urb(urb); +} + +/** + * hdm_read_completion - completion function for submitted Rx URBs + * @urb: the URB that has been completed + * + * This checks the status of the completed URB. In case the URB has been + * unlinked before it is immediately freed. On any other error the MBO transfer + * flag is set. On success it frees allocated resources, removes + * padding bytes -if necessary- and calls the completion function. + * + * Context: interrupt! + */ +static void hdm_read_completion(struct urb *urb) +{ + struct mbo *mbo = urb->context; + struct most_dev *mdev = to_mdev(mbo->ifp); + unsigned int channel = mbo->hdm_channel_id; + struct device *dev = &mdev->usb_device->dev; + spinlock_t *lock = mdev->channel_lock + channel; + unsigned long flags; + + spin_lock_irqsave(lock, flags); + + mbo->processed_length = 0; + mbo->status = MBO_E_INVAL; + if (likely(mdev->is_channel_healthy[channel])) { + switch (urb->status) { + case 0: + case -ESHUTDOWN: + mbo->processed_length = urb->actual_length; + mbo->status = MBO_SUCCESS; + if (mdev->padding_active[channel] && + hdm_remove_padding(mdev, channel, mbo)) { + mbo->processed_length = 0; + mbo->status = MBO_E_INVAL; + } + break; + case -EPIPE: + dev_warn(dev, "Broken pipe on ep%02x\n", + mdev->ep_address[channel]); + mdev->is_channel_healthy[channel] = false; + mdev->clear_work[channel].pipe = urb->pipe; + schedule_work(&mdev->clear_work[channel].ws); + break; + case -ENODEV: + case -EPROTO: + mbo->status = MBO_E_CLOSE; + break; + case -EOVERFLOW: + dev_warn(dev, "Babble on ep%02x\n", + mdev->ep_address[channel]); + break; + } + } + + spin_unlock_irqrestore(lock, flags); + + if (likely(mbo->complete)) + mbo->complete(mbo); + usb_free_urb(urb); +} + +/** + * hdm_enqueue - receive a buffer to be used for data transfer + * @iface: interface to enqueue to + * @channel: ID of the channel + * @mbo: pointer to the buffer object + * + * This allocates a new URB and fills it according to the channel + * that is being used for transmission of data. Before the URB is + * submitted it is stored in the private anchor list. + * + * Returns 0 on success. On any error the URB is freed and a error code + * is returned. + * + * Context: Could in _some_ cases be interrupt! + */ +static int hdm_enqueue(struct most_interface *iface, int channel, + struct mbo *mbo) +{ + struct most_dev *mdev = to_mdev(iface); + struct most_channel_config *conf; + int retval = 0; + struct urb *urb; + unsigned long length; + void *virt_address; + + if (!mbo) + return -EINVAL; + if (iface->num_channels <= channel || channel < 0) + return -ECHRNG; + + urb = usb_alloc_urb(NO_ISOCHRONOUS_URB, GFP_KERNEL); + if (!urb) + return -ENOMEM; + + conf = &mdev->conf[channel]; + + mutex_lock(&mdev->io_mutex); + if (!mdev->usb_device) { + retval = -ENODEV; + goto err_free_urb; + } + + if ((conf->direction & MOST_CH_TX) && mdev->padding_active[channel] && + hdm_add_padding(mdev, channel, mbo)) { + retval = -EINVAL; + goto err_free_urb; + } + + urb->transfer_dma = mbo->bus_address; + virt_address = mbo->virt_address; + length = mbo->buffer_length; + + if (conf->direction & MOST_CH_TX) { + usb_fill_bulk_urb(urb, mdev->usb_device, + usb_sndbulkpipe(mdev->usb_device, + mdev->ep_address[channel]), + virt_address, + length, + hdm_write_completion, + mbo); + if (conf->data_type != MOST_CH_ISOC && + conf->data_type != MOST_CH_SYNC) + urb->transfer_flags |= URB_ZERO_PACKET; + } else { + usb_fill_bulk_urb(urb, mdev->usb_device, + usb_rcvbulkpipe(mdev->usb_device, + mdev->ep_address[channel]), + virt_address, + length + conf->extra_len, + hdm_read_completion, + mbo); + } + urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; + + usb_anchor_urb(urb, &mdev->busy_urbs[channel]); + + retval = usb_submit_urb(urb, GFP_KERNEL); + if (retval) { + dev_err(&mdev->usb_device->dev, + "URB submit failed with error %d.\n", retval); + goto err_unanchor_urb; + } + mutex_unlock(&mdev->io_mutex); + return 0; + +err_unanchor_urb: + usb_unanchor_urb(urb); +err_free_urb: + usb_free_urb(urb); + mutex_unlock(&mdev->io_mutex); + return retval; +} + +static void *hdm_dma_alloc(struct mbo *mbo, u32 size) +{ + struct most_dev *mdev = to_mdev(mbo->ifp); + + return usb_alloc_coherent(mdev->usb_device, size, GFP_KERNEL, + &mbo->bus_address); +} + +static void hdm_dma_free(struct mbo *mbo, u32 size) +{ + struct most_dev *mdev = to_mdev(mbo->ifp); + + usb_free_coherent(mdev->usb_device, size, mbo->virt_address, + mbo->bus_address); +} + +/** + * hdm_configure_channel - receive channel configuration from core + * @iface: interface + * @channel: channel ID + * @conf: structure that holds the configuration information + * + * The attached network interface controller (NIC) supports a padding mode + * to avoid short packets on USB, hence increasing the performance due to a + * lower interrupt load. This mode is default for synchronous data and can + * be switched on for isochronous data. In case padding is active the + * driver needs to know the frame size of the payload in order to calculate + * the number of bytes it needs to pad when transmitting or to cut off when + * receiving data. + * + */ +static int hdm_configure_channel(struct most_interface *iface, int channel, + struct most_channel_config *conf) +{ + unsigned int num_frames; + unsigned int frame_size; + struct most_dev *mdev = to_mdev(iface); + struct device *dev = &mdev->usb_device->dev; + + if (!conf) { + dev_err(dev, "Bad config pointer.\n"); + return -EINVAL; + } + if (channel < 0 || channel >= iface->num_channels) { + dev_err(dev, "Channel ID out of range.\n"); + return -EINVAL; + } + + mdev->is_channel_healthy[channel] = true; + mdev->clear_work[channel].channel = channel; + mdev->clear_work[channel].mdev = mdev; + INIT_WORK(&mdev->clear_work[channel].ws, wq_clear_halt); + + if (!conf->num_buffers || !conf->buffer_size) { + dev_err(dev, "Misconfig: buffer size or #buffers zero.\n"); + return -EINVAL; + } + + if (conf->data_type != MOST_CH_SYNC && + !(conf->data_type == MOST_CH_ISOC && + conf->packets_per_xact != 0xFF)) { + mdev->padding_active[channel] = false; + /* + * Since the NIC's padding mode is not going to be + * used, we can skip the frame size calculations and + * move directly on to exit. + */ + goto exit; + } + + mdev->padding_active[channel] = true; + + frame_size = get_stream_frame_size(&mdev->dev, conf); + if (frame_size == 0 || frame_size > USB_MTU) { + dev_warn(dev, "Misconfig: frame size wrong\n"); + return -EINVAL; + } + + num_frames = conf->buffer_size / frame_size; + + if (conf->buffer_size % frame_size) { + u16 old_size = conf->buffer_size; + + conf->buffer_size = num_frames * frame_size; + dev_warn(dev, "%s: fixed buffer size (%d -> %d)\n", + mdev->suffix[channel], old_size, conf->buffer_size); + } + + /* calculate extra length to comply w/ HW padding */ + conf->extra_len = num_frames * (USB_MTU - frame_size); + +exit: + mdev->conf[channel] = *conf; + if (conf->data_type == MOST_CH_ASYNC) { + u16 ep = mdev->ep_address[channel]; + + if (start_sync_ep(mdev->usb_device, ep) < 0) + dev_warn(dev, "sync for ep%02x failed", ep); + } + return 0; +} + +/** + * hdm_request_netinfo - request network information + * @iface: pointer to interface + * @channel: channel ID + * + * This is used as trigger to set up the link status timer that + * polls for the NI state of the INIC every 2 seconds. + * + */ +static void hdm_request_netinfo(struct most_interface *iface, int channel, + void (*on_netinfo)(struct most_interface *, + unsigned char, + unsigned char *)) +{ + struct most_dev *mdev = to_mdev(iface); + + mdev->on_netinfo = on_netinfo; + if (!on_netinfo) + return; + + mdev->link_stat_timer.expires = jiffies + HZ; + mod_timer(&mdev->link_stat_timer, mdev->link_stat_timer.expires); +} + +/** + * link_stat_timer_handler - schedule work obtaining mac address and link status + * @data: pointer to USB device instance + * + * The handler runs in interrupt context. That's why we need to defer the + * tasks to a work queue. + */ +static void link_stat_timer_handler(struct timer_list *t) +{ + struct most_dev *mdev = from_timer(mdev, t, link_stat_timer); + + schedule_work(&mdev->poll_work_obj); + mdev->link_stat_timer.expires = jiffies + (2 * HZ); + add_timer(&mdev->link_stat_timer); +} + +/** + * wq_netinfo - work queue function to deliver latest networking information + * @wq_obj: object that holds data for our deferred work to do + * + * This retrieves the network interface status of the USB INIC + */ +static void wq_netinfo(struct work_struct *wq_obj) +{ + struct most_dev *mdev = to_mdev_from_work(wq_obj); + struct usb_device *usb_device = mdev->usb_device; + struct device *dev = &usb_device->dev; + u16 hi, mi, lo, link; + u8 hw_addr[6]; + + if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_HI, &hi)) { + dev_err(dev, "Vendor request 'hw_addr_hi' failed\n"); + return; + } + + if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_MI, &mi)) { + dev_err(dev, "Vendor request 'hw_addr_mid' failed\n"); + return; + } + + if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_LO, &lo)) { + dev_err(dev, "Vendor request 'hw_addr_low' failed\n"); + return; + } + + if (drci_rd_reg(usb_device, DRCI_REG_NI_STATE, &link)) { + dev_err(dev, "Vendor request 'link status' failed\n"); + return; + } + + hw_addr[0] = hi >> 8; + hw_addr[1] = hi; + hw_addr[2] = mi >> 8; + hw_addr[3] = mi; + hw_addr[4] = lo >> 8; + hw_addr[5] = lo; + + if (mdev->on_netinfo) + mdev->on_netinfo(&mdev->iface, link, hw_addr); +} + +/** + * wq_clear_halt - work queue function + * @wq_obj: work_struct object to execute + * + * This sends a clear_halt to the given USB pipe. + */ +static void wq_clear_halt(struct work_struct *wq_obj) +{ + struct clear_hold_work *clear_work = to_clear_hold_work(wq_obj); + struct most_dev *mdev = clear_work->mdev; + unsigned int channel = clear_work->channel; + int pipe = clear_work->pipe; + int snd_pipe; + int peer; + + mutex_lock(&mdev->io_mutex); + most_stop_enqueue(&mdev->iface, channel); + usb_kill_anchored_urbs(&mdev->busy_urbs[channel]); + if (usb_clear_halt(mdev->usb_device, pipe)) + dev_warn(&mdev->usb_device->dev, "Failed to reset endpoint.\n"); + + /* If the functional Stall condition has been set on an + * asynchronous rx channel, we need to clear the tx channel + * too, since the hardware runs its clean-up sequence on both + * channels, as they are physically one on the network. + * + * The USB interface that exposes the asynchronous channels + * contains always two endpoints, and two only. + */ + if (mdev->conf[channel].data_type == MOST_CH_ASYNC && + mdev->conf[channel].direction == MOST_CH_RX) { + if (channel == 0) + peer = 1; + else + peer = 0; + snd_pipe = usb_sndbulkpipe(mdev->usb_device, + mdev->ep_address[peer]); + usb_clear_halt(mdev->usb_device, snd_pipe); + } + mdev->is_channel_healthy[channel] = true; + most_resume_enqueue(&mdev->iface, channel); + mutex_unlock(&mdev->io_mutex); +} + +/** + * hdm_usb_fops - file operation table for USB driver + */ +static const struct file_operations hdm_usb_fops = { + .owner = THIS_MODULE, +}; + +/** + * usb_device_id - ID table for HCD device probing + */ +static const struct usb_device_id usbid[] = { + { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_BRDG), }, + { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81118), }, + { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81119), }, + { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81210), }, + { } /* Terminating entry */ +}; + +struct regs { + const char *name; + u16 reg; +}; + +static const struct regs ro_regs[] = { + { "ni_state", DRCI_REG_NI_STATE }, + { "packet_bandwidth", DRCI_REG_PACKET_BW }, + { "node_address", DRCI_REG_NODE_ADDR }, + { "node_position", DRCI_REG_NODE_POS }, +}; + +static const struct regs rw_regs[] = { + { "mep_filter", DRCI_REG_MEP_FILTER }, + { "mep_hash0", DRCI_REG_HASH_TBL0 }, + { "mep_hash1", DRCI_REG_HASH_TBL1 }, + { "mep_hash2", DRCI_REG_HASH_TBL2 }, + { "mep_hash3", DRCI_REG_HASH_TBL3 }, + { "mep_eui48_hi", DRCI_REG_HW_ADDR_HI }, + { "mep_eui48_mi", DRCI_REG_HW_ADDR_MI }, + { "mep_eui48_lo", DRCI_REG_HW_ADDR_LO }, +}; + +static int get_stat_reg_addr(const struct regs *regs, int size, + const char *name, u16 *reg_addr) +{ + int i; + + for (i = 0; i < size; i++) { + if (sysfs_streq(name, regs[i].name)) { + *reg_addr = regs[i].reg; + return 0; + } + } + return -EINVAL; +} + +#define get_static_reg_addr(regs, name, reg_addr) \ + get_stat_reg_addr(regs, ARRAY_SIZE(regs), name, reg_addr) + +static ssize_t value_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + const char *name = attr->attr.name; + struct most_dci_obj *dci_obj = to_dci_obj(dev); + u16 val; + u16 reg_addr; + int err; + + if (sysfs_streq(name, "arb_address")) + return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr); + + if (sysfs_streq(name, "arb_value")) + reg_addr = dci_obj->reg_addr; + else if (get_static_reg_addr(ro_regs, name, ®_addr) && + get_static_reg_addr(rw_regs, name, ®_addr)) + return -EINVAL; + + err = drci_rd_reg(dci_obj->usb_device, reg_addr, &val); + if (err < 0) + return err; + + return snprintf(buf, PAGE_SIZE, "%04x\n", val); +} + +static ssize_t value_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + u16 val; + u16 reg_addr; + const char *name = attr->attr.name; + struct most_dci_obj *dci_obj = to_dci_obj(dev); + struct usb_device *usb_dev = dci_obj->usb_device; + int err; + + err = kstrtou16(buf, 16, &val); + if (err) + return err; + + if (sysfs_streq(name, "arb_address")) { + dci_obj->reg_addr = val; + return count; + } + + if (sysfs_streq(name, "arb_value")) + err = drci_wr_reg(usb_dev, dci_obj->reg_addr, val); + else if (sysfs_streq(name, "sync_ep")) + err = start_sync_ep(usb_dev, val); + else if (!get_static_reg_addr(rw_regs, name, ®_addr)) + err = drci_wr_reg(usb_dev, reg_addr, val); + else + return -EINVAL; + + if (err < 0) + return err; + + return count; +} + +static DEVICE_ATTR(ni_state, 0444, value_show, NULL); +static DEVICE_ATTR(packet_bandwidth, 0444, value_show, NULL); +static DEVICE_ATTR(node_address, 0444, value_show, NULL); +static DEVICE_ATTR(node_position, 0444, value_show, NULL); +static DEVICE_ATTR(sync_ep, 0200, NULL, value_store); +static DEVICE_ATTR(mep_filter, 0644, value_show, value_store); +static DEVICE_ATTR(mep_hash0, 0644, value_show, value_store); +static DEVICE_ATTR(mep_hash1, 0644, value_show, value_store); +static DEVICE_ATTR(mep_hash2, 0644, value_show, value_store); +static DEVICE_ATTR(mep_hash3, 0644, value_show, value_store); +static DEVICE_ATTR(mep_eui48_hi, 0644, value_show, value_store); +static DEVICE_ATTR(mep_eui48_mi, 0644, value_show, value_store); +static DEVICE_ATTR(mep_eui48_lo, 0644, value_show, value_store); +static DEVICE_ATTR(arb_address, 0644, value_show, value_store); +static DEVICE_ATTR(arb_value, 0644, value_show, value_store); + +static struct attribute *dci_attrs[] = { + &dev_attr_ni_state.attr, + &dev_attr_packet_bandwidth.attr, + &dev_attr_node_address.attr, + &dev_attr_node_position.attr, + &dev_attr_sync_ep.attr, + &dev_attr_mep_filter.attr, + &dev_attr_mep_hash0.attr, + &dev_attr_mep_hash1.attr, + &dev_attr_mep_hash2.attr, + &dev_attr_mep_hash3.attr, + &dev_attr_mep_eui48_hi.attr, + &dev_attr_mep_eui48_mi.attr, + &dev_attr_mep_eui48_lo.attr, + &dev_attr_arb_address.attr, + &dev_attr_arb_value.attr, + NULL, +}; + +ATTRIBUTE_GROUPS(dci); + +static void release_dci(struct device *dev) +{ + struct most_dci_obj *dci = to_dci_obj(dev); + + put_device(dev->parent); + kfree(dci); +} + +static void release_mdev(struct device *dev) +{ + struct most_dev *mdev = to_mdev_from_dev(dev); + + kfree(mdev); +} +/** + * hdm_probe - probe function of USB device driver + * @interface: Interface of the attached USB device + * @id: Pointer to the USB ID table. + * + * This allocates and initializes the device instance, adds the new + * entry to the internal list, scans the USB descriptors and registers + * the interface with the core. + * Additionally, the DCI objects are created and the hardware is sync'd. + * + * Return 0 on success. In case of an error a negative number is returned. + */ +static int +hdm_probe(struct usb_interface *interface, const struct usb_device_id *id) +{ + struct usb_host_interface *usb_iface_desc = interface->cur_altsetting; + struct usb_device *usb_dev = interface_to_usbdev(interface); + struct device *dev = &usb_dev->dev; + struct most_dev *mdev; + unsigned int i; + unsigned int num_endpoints; + struct most_channel_capability *tmp_cap; + struct usb_endpoint_descriptor *ep_desc; + int ret = -ENOMEM; + + mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); + if (!mdev) + return -ENOMEM; + + usb_set_intfdata(interface, mdev); + num_endpoints = usb_iface_desc->desc.bNumEndpoints; + if (num_endpoints > MAX_NUM_ENDPOINTS) { + kfree(mdev); + return -EINVAL; + } + mutex_init(&mdev->io_mutex); + INIT_WORK(&mdev->poll_work_obj, wq_netinfo); + timer_setup(&mdev->link_stat_timer, link_stat_timer_handler, 0); + + mdev->usb_device = usb_dev; + mdev->link_stat_timer.expires = jiffies + (2 * HZ); + + mdev->iface.mod = hdm_usb_fops.owner; + mdev->iface.dev = &mdev->dev; + mdev->iface.driver_dev = &interface->dev; + mdev->iface.interface = ITYPE_USB; + mdev->iface.configure = hdm_configure_channel; + mdev->iface.request_netinfo = hdm_request_netinfo; + mdev->iface.enqueue = hdm_enqueue; + mdev->iface.poison_channel = hdm_poison_channel; + mdev->iface.dma_alloc = hdm_dma_alloc; + mdev->iface.dma_free = hdm_dma_free; + mdev->iface.description = mdev->description; + mdev->iface.num_channels = num_endpoints; + + snprintf(mdev->description, sizeof(mdev->description), + "%d-%s:%d.%d", + usb_dev->bus->busnum, + usb_dev->devpath, + usb_dev->config->desc.bConfigurationValue, + usb_iface_desc->desc.bInterfaceNumber); + + mdev->dev.init_name = mdev->description; + mdev->dev.parent = &interface->dev; + mdev->dev.release = release_mdev; + mdev->conf = kcalloc(num_endpoints, sizeof(*mdev->conf), GFP_KERNEL); + if (!mdev->conf) + goto err_free_mdev; + + mdev->cap = kcalloc(num_endpoints, sizeof(*mdev->cap), GFP_KERNEL); + if (!mdev->cap) + goto err_free_conf; + + mdev->iface.channel_vector = mdev->cap; + mdev->ep_address = + kcalloc(num_endpoints, sizeof(*mdev->ep_address), GFP_KERNEL); + if (!mdev->ep_address) + goto err_free_cap; + + mdev->busy_urbs = + kcalloc(num_endpoints, sizeof(*mdev->busy_urbs), GFP_KERNEL); + if (!mdev->busy_urbs) + goto err_free_ep_address; + + tmp_cap = mdev->cap; + for (i = 0; i < num_endpoints; i++) { + ep_desc = &usb_iface_desc->endpoint[i].desc; + mdev->ep_address[i] = ep_desc->bEndpointAddress; + mdev->padding_active[i] = false; + mdev->is_channel_healthy[i] = true; + + snprintf(&mdev->suffix[i][0], MAX_SUFFIX_LEN, "ep%02x", + mdev->ep_address[i]); + + tmp_cap->name_suffix = &mdev->suffix[i][0]; + tmp_cap->buffer_size_packet = MAX_BUF_SIZE; + tmp_cap->buffer_size_streaming = MAX_BUF_SIZE; + tmp_cap->num_buffers_packet = BUF_CHAIN_SIZE; + tmp_cap->num_buffers_streaming = BUF_CHAIN_SIZE; + tmp_cap->data_type = MOST_CH_CONTROL | MOST_CH_ASYNC | + MOST_CH_ISOC | MOST_CH_SYNC; + if (usb_endpoint_dir_in(ep_desc)) + tmp_cap->direction = MOST_CH_RX; + else + tmp_cap->direction = MOST_CH_TX; + tmp_cap++; + init_usb_anchor(&mdev->busy_urbs[i]); + spin_lock_init(&mdev->channel_lock[i]); + } + dev_dbg(dev, "claimed gadget: Vendor=%4.4x ProdID=%4.4x Bus=%02x Device=%02x\n", + le16_to_cpu(usb_dev->descriptor.idVendor), + le16_to_cpu(usb_dev->descriptor.idProduct), + usb_dev->bus->busnum, + usb_dev->devnum); + + dev_dbg(dev, "device path: /sys/bus/usb/devices/%d-%s:%d.%d\n", + usb_dev->bus->busnum, + usb_dev->devpath, + usb_dev->config->desc.bConfigurationValue, + usb_iface_desc->desc.bInterfaceNumber); + + ret = most_register_interface(&mdev->iface); + if (ret) + goto err_free_busy_urbs; + + mutex_lock(&mdev->io_mutex); + if (le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81118 || + le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81119 || + le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81210) { + mdev->dci = kzalloc(sizeof(*mdev->dci), GFP_KERNEL); + if (!mdev->dci) { + mutex_unlock(&mdev->io_mutex); + most_deregister_interface(&mdev->iface); + ret = -ENOMEM; + goto err_free_busy_urbs; + } + + mdev->dci->dev.init_name = "dci"; + mdev->dci->dev.parent = get_device(mdev->iface.dev); + mdev->dci->dev.groups = dci_groups; + mdev->dci->dev.release = release_dci; + if (device_register(&mdev->dci->dev)) { + mutex_unlock(&mdev->io_mutex); + most_deregister_interface(&mdev->iface); + ret = -ENOMEM; + goto err_free_dci; + } + mdev->dci->usb_device = mdev->usb_device; + } + mutex_unlock(&mdev->io_mutex); + return 0; +err_free_dci: + put_device(&mdev->dci->dev); +err_free_busy_urbs: + kfree(mdev->busy_urbs); +err_free_ep_address: + kfree(mdev->ep_address); +err_free_cap: + kfree(mdev->cap); +err_free_conf: + kfree(mdev->conf); +err_free_mdev: + put_device(&mdev->dev); + return ret; +} + +/** + * hdm_disconnect - disconnect function of USB device driver + * @interface: Interface of the attached USB device + * + * This deregisters the interface with the core, removes the kernel timer + * and frees resources. + * + * Context: hub kernel thread + */ +static void hdm_disconnect(struct usb_interface *interface) +{ + struct most_dev *mdev = usb_get_intfdata(interface); + + mutex_lock(&mdev->io_mutex); + usb_set_intfdata(interface, NULL); + mdev->usb_device = NULL; + mutex_unlock(&mdev->io_mutex); + + del_timer_sync(&mdev->link_stat_timer); + cancel_work_sync(&mdev->poll_work_obj); + + if (mdev->dci) + device_unregister(&mdev->dci->dev); + most_deregister_interface(&mdev->iface); + + kfree(mdev->busy_urbs); + kfree(mdev->cap); + kfree(mdev->conf); + kfree(mdev->ep_address); + put_device(&mdev->dci->dev); + put_device(&mdev->dev); +} + +static int hdm_suspend(struct usb_interface *interface, pm_message_t message) +{ + struct most_dev *mdev = usb_get_intfdata(interface); + int i; + + mutex_lock(&mdev->io_mutex); + for (i = 0; i < mdev->iface.num_channels; i++) { + most_stop_enqueue(&mdev->iface, i); + usb_kill_anchored_urbs(&mdev->busy_urbs[i]); + } + mutex_unlock(&mdev->io_mutex); + return 0; +} + +static int hdm_resume(struct usb_interface *interface) +{ + struct most_dev *mdev = usb_get_intfdata(interface); + int i; + + mutex_lock(&mdev->io_mutex); + for (i = 0; i < mdev->iface.num_channels; i++) + most_resume_enqueue(&mdev->iface, i); + mutex_unlock(&mdev->io_mutex); + return 0; +} + +static struct usb_driver hdm_usb = { + .name = "hdm_usb", + .id_table = usbid, + .probe = hdm_probe, + .disconnect = hdm_disconnect, + .resume = hdm_resume, + .suspend = hdm_suspend, +}; + +module_usb_driver(hdm_usb); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Christian Gromm "); +MODULE_DESCRIPTION("HDM_4_USB"); diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig index c5a99f750abe..c35fb34fae79 100644 --- a/drivers/staging/most/Kconfig +++ b/drivers/staging/most/Kconfig @@ -30,6 +30,4 @@ source "drivers/staging/most/dim2/Kconfig" source "drivers/staging/most/i2c/Kconfig" -source "drivers/staging/most/usb/Kconfig" - endif diff --git a/drivers/staging/most/usb/Kconfig b/drivers/staging/most/usb/Kconfig deleted file mode 100644 index a47a973dfb1d..000000000000 --- a/drivers/staging/most/usb/Kconfig +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# -# MOST USB configuration -# - -config MOST_USB - tristate "USB" - depends on USB - help - Say Y here if you want to connect via USB to network transceiver. - - To compile this driver as a module, choose M here: the - module will be called most_usb. diff --git a/drivers/staging/most/usb/Makefile b/drivers/staging/most/usb/Makefile deleted file mode 100644 index c2b207339aec..000000000000 --- a/drivers/staging/most/usb/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_MOST_USB) += most_usb.o - -most_usb-objs := usb.o diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c deleted file mode 100644 index 2640c5b326a4..000000000000 --- a/drivers/staging/most/usb/usb.c +++ /dev/null @@ -1,1170 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * usb.c - Hardware dependent module for USB - * - * Copyright (C) 2013-2015 Microchip Technology Germany II GmbH & Co. KG - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define USB_MTU 512 -#define NO_ISOCHRONOUS_URB 0 -#define AV_PACKETS_PER_XACT 2 -#define BUF_CHAIN_SIZE 0xFFFF -#define MAX_NUM_ENDPOINTS 30 -#define MAX_SUFFIX_LEN 10 -#define MAX_STRING_LEN 80 -#define MAX_BUF_SIZE 0xFFFF - -#define USB_VENDOR_ID_SMSC 0x0424 /* VID: SMSC */ -#define USB_DEV_ID_BRDG 0xC001 /* PID: USB Bridge */ -#define USB_DEV_ID_OS81118 0xCF18 /* PID: USB OS81118 */ -#define USB_DEV_ID_OS81119 0xCF19 /* PID: USB OS81119 */ -#define USB_DEV_ID_OS81210 0xCF30 /* PID: USB OS81210 */ -/* DRCI Addresses */ -#define DRCI_REG_NI_STATE 0x0100 -#define DRCI_REG_PACKET_BW 0x0101 -#define DRCI_REG_NODE_ADDR 0x0102 -#define DRCI_REG_NODE_POS 0x0103 -#define DRCI_REG_MEP_FILTER 0x0140 -#define DRCI_REG_HASH_TBL0 0x0141 -#define DRCI_REG_HASH_TBL1 0x0142 -#define DRCI_REG_HASH_TBL2 0x0143 -#define DRCI_REG_HASH_TBL3 0x0144 -#define DRCI_REG_HW_ADDR_HI 0x0145 -#define DRCI_REG_HW_ADDR_MI 0x0146 -#define DRCI_REG_HW_ADDR_LO 0x0147 -#define DRCI_REG_BASE 0x1100 -#define DRCI_COMMAND 0x02 -#define DRCI_READ_REQ 0xA0 -#define DRCI_WRITE_REQ 0xA1 - -/** - * struct most_dci_obj - Direct Communication Interface - * @kobj:position in sysfs - * @usb_device: pointer to the usb device - * @reg_addr: register address for arbitrary DCI access - */ -struct most_dci_obj { - struct device dev; - struct usb_device *usb_device; - u16 reg_addr; -}; - -#define to_dci_obj(p) container_of(p, struct most_dci_obj, dev) - -struct most_dev; - -struct clear_hold_work { - struct work_struct ws; - struct most_dev *mdev; - unsigned int channel; - int pipe; -}; - -#define to_clear_hold_work(w) container_of(w, struct clear_hold_work, ws) - -/** - * struct most_dev - holds all usb interface specific stuff - * @usb_device: pointer to usb device - * @iface: hardware interface - * @cap: channel capabilities - * @conf: channel configuration - * @dci: direct communication interface of hardware - * @ep_address: endpoint address table - * @description: device description - * @suffix: suffix for channel name - * @channel_lock: synchronize channel access - * @padding_active: indicates channel uses padding - * @is_channel_healthy: health status table of each channel - * @busy_urbs: list of anchored items - * @io_mutex: synchronize I/O with disconnect - * @link_stat_timer: timer for link status reports - * @poll_work_obj: work for polling link status - */ -struct most_dev { - struct device dev; - struct usb_device *usb_device; - struct most_interface iface; - struct most_channel_capability *cap; - struct most_channel_config *conf; - struct most_dci_obj *dci; - u8 *ep_address; - char description[MAX_STRING_LEN]; - char suffix[MAX_NUM_ENDPOINTS][MAX_SUFFIX_LEN]; - spinlock_t channel_lock[MAX_NUM_ENDPOINTS]; /* sync channel access */ - bool padding_active[MAX_NUM_ENDPOINTS]; - bool is_channel_healthy[MAX_NUM_ENDPOINTS]; - struct clear_hold_work clear_work[MAX_NUM_ENDPOINTS]; - struct usb_anchor *busy_urbs; - struct mutex io_mutex; - struct timer_list link_stat_timer; - struct work_struct poll_work_obj; - void (*on_netinfo)(struct most_interface *most_iface, - unsigned char link_state, unsigned char *addrs); -}; - -#define to_mdev(d) container_of(d, struct most_dev, iface) -#define to_mdev_from_dev(d) container_of(d, struct most_dev, dev) -#define to_mdev_from_work(w) container_of(w, struct most_dev, poll_work_obj) - -static void wq_clear_halt(struct work_struct *wq_obj); -static void wq_netinfo(struct work_struct *wq_obj); - -/** - * drci_rd_reg - read a DCI register - * @dev: usb device - * @reg: register address - * @buf: buffer to store data - * - * This is reads data from INIC's direct register communication interface - */ -static inline int drci_rd_reg(struct usb_device *dev, u16 reg, u16 *buf) -{ - int retval; - __le16 *dma_buf; - u8 req_type = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE; - - dma_buf = kzalloc(sizeof(*dma_buf), GFP_KERNEL); - if (!dma_buf) - return -ENOMEM; - - retval = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), - DRCI_READ_REQ, req_type, - 0x0000, - reg, dma_buf, sizeof(*dma_buf), 5 * HZ); - *buf = le16_to_cpu(*dma_buf); - kfree(dma_buf); - - if (retval < 0) - return retval; - return 0; -} - -/** - * drci_wr_reg - write a DCI register - * @dev: usb device - * @reg: register address - * @data: data to write - * - * This is writes data to INIC's direct register communication interface - */ -static inline int drci_wr_reg(struct usb_device *dev, u16 reg, u16 data) -{ - return usb_control_msg(dev, - usb_sndctrlpipe(dev, 0), - DRCI_WRITE_REQ, - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - data, - reg, - NULL, - 0, - 5 * HZ); -} - -static inline int start_sync_ep(struct usb_device *usb_dev, u16 ep) -{ - return drci_wr_reg(usb_dev, DRCI_REG_BASE + DRCI_COMMAND + ep * 16, 1); -} - -/** - * get_stream_frame_size - calculate frame size of current configuration - * @dev: device structure - * @cfg: channel configuration - */ -static unsigned int get_stream_frame_size(struct device *dev, - struct most_channel_config *cfg) -{ - unsigned int frame_size; - unsigned int sub_size = cfg->subbuffer_size; - - if (!sub_size) { - dev_warn(dev, "Misconfig: Subbuffer size zero.\n"); - return 0; - } - switch (cfg->data_type) { - case MOST_CH_ISOC: - frame_size = AV_PACKETS_PER_XACT * sub_size; - break; - case MOST_CH_SYNC: - if (cfg->packets_per_xact == 0) { - dev_warn(dev, "Misconfig: Packets per XACT zero\n"); - frame_size = 0; - } else if (cfg->packets_per_xact == 0xFF) { - frame_size = (USB_MTU / sub_size) * sub_size; - } else { - frame_size = cfg->packets_per_xact * sub_size; - } - break; - default: - dev_warn(dev, "Query frame size of non-streaming channel\n"); - frame_size = 0; - break; - } - return frame_size; -} - -/** - * hdm_poison_channel - mark buffers of this channel as invalid - * @iface: pointer to the interface - * @channel: channel ID - * - * This unlinks all URBs submitted to the HCD, - * calls the associated completion function of the core and removes - * them from the list. - * - * Returns 0 on success or error code otherwise. - */ -static int hdm_poison_channel(struct most_interface *iface, int channel) -{ - struct most_dev *mdev = to_mdev(iface); - unsigned long flags; - spinlock_t *lock; /* temp. lock */ - - if (channel < 0 || channel >= iface->num_channels) { - dev_warn(&mdev->usb_device->dev, "Channel ID out of range.\n"); - return -ECHRNG; - } - - lock = mdev->channel_lock + channel; - spin_lock_irqsave(lock, flags); - mdev->is_channel_healthy[channel] = false; - spin_unlock_irqrestore(lock, flags); - - cancel_work_sync(&mdev->clear_work[channel].ws); - - mutex_lock(&mdev->io_mutex); - usb_kill_anchored_urbs(&mdev->busy_urbs[channel]); - if (mdev->padding_active[channel]) - mdev->padding_active[channel] = false; - - if (mdev->conf[channel].data_type == MOST_CH_ASYNC) { - del_timer_sync(&mdev->link_stat_timer); - cancel_work_sync(&mdev->poll_work_obj); - } - mutex_unlock(&mdev->io_mutex); - return 0; -} - -/** - * hdm_add_padding - add padding bytes - * @mdev: most device - * @channel: channel ID - * @mbo: buffer object - * - * This inserts the INIC hardware specific padding bytes into a streaming - * channel's buffer - */ -static int hdm_add_padding(struct most_dev *mdev, int channel, struct mbo *mbo) -{ - struct most_channel_config *conf = &mdev->conf[channel]; - unsigned int frame_size = get_stream_frame_size(&mdev->dev, conf); - unsigned int j, num_frames; - - if (!frame_size) - return -EINVAL; - num_frames = mbo->buffer_length / frame_size; - - if (num_frames < 1) { - dev_err(&mdev->usb_device->dev, - "Missed minimal transfer unit.\n"); - return -EINVAL; - } - - for (j = num_frames - 1; j > 0; j--) - memmove(mbo->virt_address + j * USB_MTU, - mbo->virt_address + j * frame_size, - frame_size); - mbo->buffer_length = num_frames * USB_MTU; - return 0; -} - -/** - * hdm_remove_padding - remove padding bytes - * @mdev: most device - * @channel: channel ID - * @mbo: buffer object - * - * This takes the INIC hardware specific padding bytes off a streaming - * channel's buffer. - */ -static int hdm_remove_padding(struct most_dev *mdev, int channel, - struct mbo *mbo) -{ - struct most_channel_config *const conf = &mdev->conf[channel]; - unsigned int frame_size = get_stream_frame_size(&mdev->dev, conf); - unsigned int j, num_frames; - - if (!frame_size) - return -EINVAL; - num_frames = mbo->processed_length / USB_MTU; - - for (j = 1; j < num_frames; j++) - memmove(mbo->virt_address + frame_size * j, - mbo->virt_address + USB_MTU * j, - frame_size); - - mbo->processed_length = frame_size * num_frames; - return 0; -} - -/** - * hdm_write_completion - completion function for submitted Tx URBs - * @urb: the URB that has been completed - * - * This checks the status of the completed URB. In case the URB has been - * unlinked before, it is immediately freed. On any other error the MBO - * transfer flag is set. On success it frees allocated resources and calls - * the completion function. - * - * Context: interrupt! - */ -static void hdm_write_completion(struct urb *urb) -{ - struct mbo *mbo = urb->context; - struct most_dev *mdev = to_mdev(mbo->ifp); - unsigned int channel = mbo->hdm_channel_id; - spinlock_t *lock = mdev->channel_lock + channel; - unsigned long flags; - - spin_lock_irqsave(lock, flags); - - mbo->processed_length = 0; - mbo->status = MBO_E_INVAL; - if (likely(mdev->is_channel_healthy[channel])) { - switch (urb->status) { - case 0: - case -ESHUTDOWN: - mbo->processed_length = urb->actual_length; - mbo->status = MBO_SUCCESS; - break; - case -EPIPE: - dev_warn(&mdev->usb_device->dev, - "Broken pipe on ep%02x\n", - mdev->ep_address[channel]); - mdev->is_channel_healthy[channel] = false; - mdev->clear_work[channel].pipe = urb->pipe; - schedule_work(&mdev->clear_work[channel].ws); - break; - case -ENODEV: - case -EPROTO: - mbo->status = MBO_E_CLOSE; - break; - } - } - - spin_unlock_irqrestore(lock, flags); - - if (likely(mbo->complete)) - mbo->complete(mbo); - usb_free_urb(urb); -} - -/** - * hdm_read_completion - completion function for submitted Rx URBs - * @urb: the URB that has been completed - * - * This checks the status of the completed URB. In case the URB has been - * unlinked before it is immediately freed. On any other error the MBO transfer - * flag is set. On success it frees allocated resources, removes - * padding bytes -if necessary- and calls the completion function. - * - * Context: interrupt! - */ -static void hdm_read_completion(struct urb *urb) -{ - struct mbo *mbo = urb->context; - struct most_dev *mdev = to_mdev(mbo->ifp); - unsigned int channel = mbo->hdm_channel_id; - struct device *dev = &mdev->usb_device->dev; - spinlock_t *lock = mdev->channel_lock + channel; - unsigned long flags; - - spin_lock_irqsave(lock, flags); - - mbo->processed_length = 0; - mbo->status = MBO_E_INVAL; - if (likely(mdev->is_channel_healthy[channel])) { - switch (urb->status) { - case 0: - case -ESHUTDOWN: - mbo->processed_length = urb->actual_length; - mbo->status = MBO_SUCCESS; - if (mdev->padding_active[channel] && - hdm_remove_padding(mdev, channel, mbo)) { - mbo->processed_length = 0; - mbo->status = MBO_E_INVAL; - } - break; - case -EPIPE: - dev_warn(dev, "Broken pipe on ep%02x\n", - mdev->ep_address[channel]); - mdev->is_channel_healthy[channel] = false; - mdev->clear_work[channel].pipe = urb->pipe; - schedule_work(&mdev->clear_work[channel].ws); - break; - case -ENODEV: - case -EPROTO: - mbo->status = MBO_E_CLOSE; - break; - case -EOVERFLOW: - dev_warn(dev, "Babble on ep%02x\n", - mdev->ep_address[channel]); - break; - } - } - - spin_unlock_irqrestore(lock, flags); - - if (likely(mbo->complete)) - mbo->complete(mbo); - usb_free_urb(urb); -} - -/** - * hdm_enqueue - receive a buffer to be used for data transfer - * @iface: interface to enqueue to - * @channel: ID of the channel - * @mbo: pointer to the buffer object - * - * This allocates a new URB and fills it according to the channel - * that is being used for transmission of data. Before the URB is - * submitted it is stored in the private anchor list. - * - * Returns 0 on success. On any error the URB is freed and a error code - * is returned. - * - * Context: Could in _some_ cases be interrupt! - */ -static int hdm_enqueue(struct most_interface *iface, int channel, - struct mbo *mbo) -{ - struct most_dev *mdev = to_mdev(iface); - struct most_channel_config *conf; - int retval = 0; - struct urb *urb; - unsigned long length; - void *virt_address; - - if (!mbo) - return -EINVAL; - if (iface->num_channels <= channel || channel < 0) - return -ECHRNG; - - urb = usb_alloc_urb(NO_ISOCHRONOUS_URB, GFP_KERNEL); - if (!urb) - return -ENOMEM; - - conf = &mdev->conf[channel]; - - mutex_lock(&mdev->io_mutex); - if (!mdev->usb_device) { - retval = -ENODEV; - goto err_free_urb; - } - - if ((conf->direction & MOST_CH_TX) && mdev->padding_active[channel] && - hdm_add_padding(mdev, channel, mbo)) { - retval = -EINVAL; - goto err_free_urb; - } - - urb->transfer_dma = mbo->bus_address; - virt_address = mbo->virt_address; - length = mbo->buffer_length; - - if (conf->direction & MOST_CH_TX) { - usb_fill_bulk_urb(urb, mdev->usb_device, - usb_sndbulkpipe(mdev->usb_device, - mdev->ep_address[channel]), - virt_address, - length, - hdm_write_completion, - mbo); - if (conf->data_type != MOST_CH_ISOC && - conf->data_type != MOST_CH_SYNC) - urb->transfer_flags |= URB_ZERO_PACKET; - } else { - usb_fill_bulk_urb(urb, mdev->usb_device, - usb_rcvbulkpipe(mdev->usb_device, - mdev->ep_address[channel]), - virt_address, - length + conf->extra_len, - hdm_read_completion, - mbo); - } - urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; - - usb_anchor_urb(urb, &mdev->busy_urbs[channel]); - - retval = usb_submit_urb(urb, GFP_KERNEL); - if (retval) { - dev_err(&mdev->usb_device->dev, - "URB submit failed with error %d.\n", retval); - goto err_unanchor_urb; - } - mutex_unlock(&mdev->io_mutex); - return 0; - -err_unanchor_urb: - usb_unanchor_urb(urb); -err_free_urb: - usb_free_urb(urb); - mutex_unlock(&mdev->io_mutex); - return retval; -} - -static void *hdm_dma_alloc(struct mbo *mbo, u32 size) -{ - struct most_dev *mdev = to_mdev(mbo->ifp); - - return usb_alloc_coherent(mdev->usb_device, size, GFP_KERNEL, - &mbo->bus_address); -} - -static void hdm_dma_free(struct mbo *mbo, u32 size) -{ - struct most_dev *mdev = to_mdev(mbo->ifp); - - usb_free_coherent(mdev->usb_device, size, mbo->virt_address, - mbo->bus_address); -} - -/** - * hdm_configure_channel - receive channel configuration from core - * @iface: interface - * @channel: channel ID - * @conf: structure that holds the configuration information - * - * The attached network interface controller (NIC) supports a padding mode - * to avoid short packets on USB, hence increasing the performance due to a - * lower interrupt load. This mode is default for synchronous data and can - * be switched on for isochronous data. In case padding is active the - * driver needs to know the frame size of the payload in order to calculate - * the number of bytes it needs to pad when transmitting or to cut off when - * receiving data. - * - */ -static int hdm_configure_channel(struct most_interface *iface, int channel, - struct most_channel_config *conf) -{ - unsigned int num_frames; - unsigned int frame_size; - struct most_dev *mdev = to_mdev(iface); - struct device *dev = &mdev->usb_device->dev; - - if (!conf) { - dev_err(dev, "Bad config pointer.\n"); - return -EINVAL; - } - if (channel < 0 || channel >= iface->num_channels) { - dev_err(dev, "Channel ID out of range.\n"); - return -EINVAL; - } - - mdev->is_channel_healthy[channel] = true; - mdev->clear_work[channel].channel = channel; - mdev->clear_work[channel].mdev = mdev; - INIT_WORK(&mdev->clear_work[channel].ws, wq_clear_halt); - - if (!conf->num_buffers || !conf->buffer_size) { - dev_err(dev, "Misconfig: buffer size or #buffers zero.\n"); - return -EINVAL; - } - - if (conf->data_type != MOST_CH_SYNC && - !(conf->data_type == MOST_CH_ISOC && - conf->packets_per_xact != 0xFF)) { - mdev->padding_active[channel] = false; - /* - * Since the NIC's padding mode is not going to be - * used, we can skip the frame size calculations and - * move directly on to exit. - */ - goto exit; - } - - mdev->padding_active[channel] = true; - - frame_size = get_stream_frame_size(&mdev->dev, conf); - if (frame_size == 0 || frame_size > USB_MTU) { - dev_warn(dev, "Misconfig: frame size wrong\n"); - return -EINVAL; - } - - num_frames = conf->buffer_size / frame_size; - - if (conf->buffer_size % frame_size) { - u16 old_size = conf->buffer_size; - - conf->buffer_size = num_frames * frame_size; - dev_warn(dev, "%s: fixed buffer size (%d -> %d)\n", - mdev->suffix[channel], old_size, conf->buffer_size); - } - - /* calculate extra length to comply w/ HW padding */ - conf->extra_len = num_frames * (USB_MTU - frame_size); - -exit: - mdev->conf[channel] = *conf; - if (conf->data_type == MOST_CH_ASYNC) { - u16 ep = mdev->ep_address[channel]; - - if (start_sync_ep(mdev->usb_device, ep) < 0) - dev_warn(dev, "sync for ep%02x failed", ep); - } - return 0; -} - -/** - * hdm_request_netinfo - request network information - * @iface: pointer to interface - * @channel: channel ID - * - * This is used as trigger to set up the link status timer that - * polls for the NI state of the INIC every 2 seconds. - * - */ -static void hdm_request_netinfo(struct most_interface *iface, int channel, - void (*on_netinfo)(struct most_interface *, - unsigned char, - unsigned char *)) -{ - struct most_dev *mdev = to_mdev(iface); - - mdev->on_netinfo = on_netinfo; - if (!on_netinfo) - return; - - mdev->link_stat_timer.expires = jiffies + HZ; - mod_timer(&mdev->link_stat_timer, mdev->link_stat_timer.expires); -} - -/** - * link_stat_timer_handler - schedule work obtaining mac address and link status - * @data: pointer to USB device instance - * - * The handler runs in interrupt context. That's why we need to defer the - * tasks to a work queue. - */ -static void link_stat_timer_handler(struct timer_list *t) -{ - struct most_dev *mdev = from_timer(mdev, t, link_stat_timer); - - schedule_work(&mdev->poll_work_obj); - mdev->link_stat_timer.expires = jiffies + (2 * HZ); - add_timer(&mdev->link_stat_timer); -} - -/** - * wq_netinfo - work queue function to deliver latest networking information - * @wq_obj: object that holds data for our deferred work to do - * - * This retrieves the network interface status of the USB INIC - */ -static void wq_netinfo(struct work_struct *wq_obj) -{ - struct most_dev *mdev = to_mdev_from_work(wq_obj); - struct usb_device *usb_device = mdev->usb_device; - struct device *dev = &usb_device->dev; - u16 hi, mi, lo, link; - u8 hw_addr[6]; - - if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_HI, &hi)) { - dev_err(dev, "Vendor request 'hw_addr_hi' failed\n"); - return; - } - - if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_MI, &mi)) { - dev_err(dev, "Vendor request 'hw_addr_mid' failed\n"); - return; - } - - if (drci_rd_reg(usb_device, DRCI_REG_HW_ADDR_LO, &lo)) { - dev_err(dev, "Vendor request 'hw_addr_low' failed\n"); - return; - } - - if (drci_rd_reg(usb_device, DRCI_REG_NI_STATE, &link)) { - dev_err(dev, "Vendor request 'link status' failed\n"); - return; - } - - hw_addr[0] = hi >> 8; - hw_addr[1] = hi; - hw_addr[2] = mi >> 8; - hw_addr[3] = mi; - hw_addr[4] = lo >> 8; - hw_addr[5] = lo; - - if (mdev->on_netinfo) - mdev->on_netinfo(&mdev->iface, link, hw_addr); -} - -/** - * wq_clear_halt - work queue function - * @wq_obj: work_struct object to execute - * - * This sends a clear_halt to the given USB pipe. - */ -static void wq_clear_halt(struct work_struct *wq_obj) -{ - struct clear_hold_work *clear_work = to_clear_hold_work(wq_obj); - struct most_dev *mdev = clear_work->mdev; - unsigned int channel = clear_work->channel; - int pipe = clear_work->pipe; - int snd_pipe; - int peer; - - mutex_lock(&mdev->io_mutex); - most_stop_enqueue(&mdev->iface, channel); - usb_kill_anchored_urbs(&mdev->busy_urbs[channel]); - if (usb_clear_halt(mdev->usb_device, pipe)) - dev_warn(&mdev->usb_device->dev, "Failed to reset endpoint.\n"); - - /* If the functional Stall condition has been set on an - * asynchronous rx channel, we need to clear the tx channel - * too, since the hardware runs its clean-up sequence on both - * channels, as they are physically one on the network. - * - * The USB interface that exposes the asynchronous channels - * contains always two endpoints, and two only. - */ - if (mdev->conf[channel].data_type == MOST_CH_ASYNC && - mdev->conf[channel].direction == MOST_CH_RX) { - if (channel == 0) - peer = 1; - else - peer = 0; - snd_pipe = usb_sndbulkpipe(mdev->usb_device, - mdev->ep_address[peer]); - usb_clear_halt(mdev->usb_device, snd_pipe); - } - mdev->is_channel_healthy[channel] = true; - most_resume_enqueue(&mdev->iface, channel); - mutex_unlock(&mdev->io_mutex); -} - -/** - * hdm_usb_fops - file operation table for USB driver - */ -static const struct file_operations hdm_usb_fops = { - .owner = THIS_MODULE, -}; - -/** - * usb_device_id - ID table for HCD device probing - */ -static const struct usb_device_id usbid[] = { - { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_BRDG), }, - { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81118), }, - { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81119), }, - { USB_DEVICE(USB_VENDOR_ID_SMSC, USB_DEV_ID_OS81210), }, - { } /* Terminating entry */ -}; - -struct regs { - const char *name; - u16 reg; -}; - -static const struct regs ro_regs[] = { - { "ni_state", DRCI_REG_NI_STATE }, - { "packet_bandwidth", DRCI_REG_PACKET_BW }, - { "node_address", DRCI_REG_NODE_ADDR }, - { "node_position", DRCI_REG_NODE_POS }, -}; - -static const struct regs rw_regs[] = { - { "mep_filter", DRCI_REG_MEP_FILTER }, - { "mep_hash0", DRCI_REG_HASH_TBL0 }, - { "mep_hash1", DRCI_REG_HASH_TBL1 }, - { "mep_hash2", DRCI_REG_HASH_TBL2 }, - { "mep_hash3", DRCI_REG_HASH_TBL3 }, - { "mep_eui48_hi", DRCI_REG_HW_ADDR_HI }, - { "mep_eui48_mi", DRCI_REG_HW_ADDR_MI }, - { "mep_eui48_lo", DRCI_REG_HW_ADDR_LO }, -}; - -static int get_stat_reg_addr(const struct regs *regs, int size, - const char *name, u16 *reg_addr) -{ - int i; - - for (i = 0; i < size; i++) { - if (sysfs_streq(name, regs[i].name)) { - *reg_addr = regs[i].reg; - return 0; - } - } - return -EINVAL; -} - -#define get_static_reg_addr(regs, name, reg_addr) \ - get_stat_reg_addr(regs, ARRAY_SIZE(regs), name, reg_addr) - -static ssize_t value_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - const char *name = attr->attr.name; - struct most_dci_obj *dci_obj = to_dci_obj(dev); - u16 val; - u16 reg_addr; - int err; - - if (sysfs_streq(name, "arb_address")) - return snprintf(buf, PAGE_SIZE, "%04x\n", dci_obj->reg_addr); - - if (sysfs_streq(name, "arb_value")) - reg_addr = dci_obj->reg_addr; - else if (get_static_reg_addr(ro_regs, name, ®_addr) && - get_static_reg_addr(rw_regs, name, ®_addr)) - return -EINVAL; - - err = drci_rd_reg(dci_obj->usb_device, reg_addr, &val); - if (err < 0) - return err; - - return snprintf(buf, PAGE_SIZE, "%04x\n", val); -} - -static ssize_t value_store(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - u16 val; - u16 reg_addr; - const char *name = attr->attr.name; - struct most_dci_obj *dci_obj = to_dci_obj(dev); - struct usb_device *usb_dev = dci_obj->usb_device; - int err; - - err = kstrtou16(buf, 16, &val); - if (err) - return err; - - if (sysfs_streq(name, "arb_address")) { - dci_obj->reg_addr = val; - return count; - } - - if (sysfs_streq(name, "arb_value")) - err = drci_wr_reg(usb_dev, dci_obj->reg_addr, val); - else if (sysfs_streq(name, "sync_ep")) - err = start_sync_ep(usb_dev, val); - else if (!get_static_reg_addr(rw_regs, name, ®_addr)) - err = drci_wr_reg(usb_dev, reg_addr, val); - else - return -EINVAL; - - if (err < 0) - return err; - - return count; -} - -static DEVICE_ATTR(ni_state, 0444, value_show, NULL); -static DEVICE_ATTR(packet_bandwidth, 0444, value_show, NULL); -static DEVICE_ATTR(node_address, 0444, value_show, NULL); -static DEVICE_ATTR(node_position, 0444, value_show, NULL); -static DEVICE_ATTR(sync_ep, 0200, NULL, value_store); -static DEVICE_ATTR(mep_filter, 0644, value_show, value_store); -static DEVICE_ATTR(mep_hash0, 0644, value_show, value_store); -static DEVICE_ATTR(mep_hash1, 0644, value_show, value_store); -static DEVICE_ATTR(mep_hash2, 0644, value_show, value_store); -static DEVICE_ATTR(mep_hash3, 0644, value_show, value_store); -static DEVICE_ATTR(mep_eui48_hi, 0644, value_show, value_store); -static DEVICE_ATTR(mep_eui48_mi, 0644, value_show, value_store); -static DEVICE_ATTR(mep_eui48_lo, 0644, value_show, value_store); -static DEVICE_ATTR(arb_address, 0644, value_show, value_store); -static DEVICE_ATTR(arb_value, 0644, value_show, value_store); - -static struct attribute *dci_attrs[] = { - &dev_attr_ni_state.attr, - &dev_attr_packet_bandwidth.attr, - &dev_attr_node_address.attr, - &dev_attr_node_position.attr, - &dev_attr_sync_ep.attr, - &dev_attr_mep_filter.attr, - &dev_attr_mep_hash0.attr, - &dev_attr_mep_hash1.attr, - &dev_attr_mep_hash2.attr, - &dev_attr_mep_hash3.attr, - &dev_attr_mep_eui48_hi.attr, - &dev_attr_mep_eui48_mi.attr, - &dev_attr_mep_eui48_lo.attr, - &dev_attr_arb_address.attr, - &dev_attr_arb_value.attr, - NULL, -}; - -ATTRIBUTE_GROUPS(dci); - -static void release_dci(struct device *dev) -{ - struct most_dci_obj *dci = to_dci_obj(dev); - - put_device(dev->parent); - kfree(dci); -} - -static void release_mdev(struct device *dev) -{ - struct most_dev *mdev = to_mdev_from_dev(dev); - - kfree(mdev); -} -/** - * hdm_probe - probe function of USB device driver - * @interface: Interface of the attached USB device - * @id: Pointer to the USB ID table. - * - * This allocates and initializes the device instance, adds the new - * entry to the internal list, scans the USB descriptors and registers - * the interface with the core. - * Additionally, the DCI objects are created and the hardware is sync'd. - * - * Return 0 on success. In case of an error a negative number is returned. - */ -static int -hdm_probe(struct usb_interface *interface, const struct usb_device_id *id) -{ - struct usb_host_interface *usb_iface_desc = interface->cur_altsetting; - struct usb_device *usb_dev = interface_to_usbdev(interface); - struct device *dev = &usb_dev->dev; - struct most_dev *mdev; - unsigned int i; - unsigned int num_endpoints; - struct most_channel_capability *tmp_cap; - struct usb_endpoint_descriptor *ep_desc; - int ret = -ENOMEM; - - mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); - if (!mdev) - return -ENOMEM; - - usb_set_intfdata(interface, mdev); - num_endpoints = usb_iface_desc->desc.bNumEndpoints; - if (num_endpoints > MAX_NUM_ENDPOINTS) { - kfree(mdev); - return -EINVAL; - } - mutex_init(&mdev->io_mutex); - INIT_WORK(&mdev->poll_work_obj, wq_netinfo); - timer_setup(&mdev->link_stat_timer, link_stat_timer_handler, 0); - - mdev->usb_device = usb_dev; - mdev->link_stat_timer.expires = jiffies + (2 * HZ); - - mdev->iface.mod = hdm_usb_fops.owner; - mdev->iface.dev = &mdev->dev; - mdev->iface.driver_dev = &interface->dev; - mdev->iface.interface = ITYPE_USB; - mdev->iface.configure = hdm_configure_channel; - mdev->iface.request_netinfo = hdm_request_netinfo; - mdev->iface.enqueue = hdm_enqueue; - mdev->iface.poison_channel = hdm_poison_channel; - mdev->iface.dma_alloc = hdm_dma_alloc; - mdev->iface.dma_free = hdm_dma_free; - mdev->iface.description = mdev->description; - mdev->iface.num_channels = num_endpoints; - - snprintf(mdev->description, sizeof(mdev->description), - "%d-%s:%d.%d", - usb_dev->bus->busnum, - usb_dev->devpath, - usb_dev->config->desc.bConfigurationValue, - usb_iface_desc->desc.bInterfaceNumber); - - mdev->dev.init_name = mdev->description; - mdev->dev.parent = &interface->dev; - mdev->dev.release = release_mdev; - mdev->conf = kcalloc(num_endpoints, sizeof(*mdev->conf), GFP_KERNEL); - if (!mdev->conf) - goto err_free_mdev; - - mdev->cap = kcalloc(num_endpoints, sizeof(*mdev->cap), GFP_KERNEL); - if (!mdev->cap) - goto err_free_conf; - - mdev->iface.channel_vector = mdev->cap; - mdev->ep_address = - kcalloc(num_endpoints, sizeof(*mdev->ep_address), GFP_KERNEL); - if (!mdev->ep_address) - goto err_free_cap; - - mdev->busy_urbs = - kcalloc(num_endpoints, sizeof(*mdev->busy_urbs), GFP_KERNEL); - if (!mdev->busy_urbs) - goto err_free_ep_address; - - tmp_cap = mdev->cap; - for (i = 0; i < num_endpoints; i++) { - ep_desc = &usb_iface_desc->endpoint[i].desc; - mdev->ep_address[i] = ep_desc->bEndpointAddress; - mdev->padding_active[i] = false; - mdev->is_channel_healthy[i] = true; - - snprintf(&mdev->suffix[i][0], MAX_SUFFIX_LEN, "ep%02x", - mdev->ep_address[i]); - - tmp_cap->name_suffix = &mdev->suffix[i][0]; - tmp_cap->buffer_size_packet = MAX_BUF_SIZE; - tmp_cap->buffer_size_streaming = MAX_BUF_SIZE; - tmp_cap->num_buffers_packet = BUF_CHAIN_SIZE; - tmp_cap->num_buffers_streaming = BUF_CHAIN_SIZE; - tmp_cap->data_type = MOST_CH_CONTROL | MOST_CH_ASYNC | - MOST_CH_ISOC | MOST_CH_SYNC; - if (usb_endpoint_dir_in(ep_desc)) - tmp_cap->direction = MOST_CH_RX; - else - tmp_cap->direction = MOST_CH_TX; - tmp_cap++; - init_usb_anchor(&mdev->busy_urbs[i]); - spin_lock_init(&mdev->channel_lock[i]); - } - dev_dbg(dev, "claimed gadget: Vendor=%4.4x ProdID=%4.4x Bus=%02x Device=%02x\n", - le16_to_cpu(usb_dev->descriptor.idVendor), - le16_to_cpu(usb_dev->descriptor.idProduct), - usb_dev->bus->busnum, - usb_dev->devnum); - - dev_dbg(dev, "device path: /sys/bus/usb/devices/%d-%s:%d.%d\n", - usb_dev->bus->busnum, - usb_dev->devpath, - usb_dev->config->desc.bConfigurationValue, - usb_iface_desc->desc.bInterfaceNumber); - - ret = most_register_interface(&mdev->iface); - if (ret) - goto err_free_busy_urbs; - - mutex_lock(&mdev->io_mutex); - if (le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81118 || - le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81119 || - le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81210) { - mdev->dci = kzalloc(sizeof(*mdev->dci), GFP_KERNEL); - if (!mdev->dci) { - mutex_unlock(&mdev->io_mutex); - most_deregister_interface(&mdev->iface); - ret = -ENOMEM; - goto err_free_busy_urbs; - } - - mdev->dci->dev.init_name = "dci"; - mdev->dci->dev.parent = get_device(mdev->iface.dev); - mdev->dci->dev.groups = dci_groups; - mdev->dci->dev.release = release_dci; - if (device_register(&mdev->dci->dev)) { - mutex_unlock(&mdev->io_mutex); - most_deregister_interface(&mdev->iface); - ret = -ENOMEM; - goto err_free_dci; - } - mdev->dci->usb_device = mdev->usb_device; - } - mutex_unlock(&mdev->io_mutex); - return 0; -err_free_dci: - put_device(&mdev->dci->dev); -err_free_busy_urbs: - kfree(mdev->busy_urbs); -err_free_ep_address: - kfree(mdev->ep_address); -err_free_cap: - kfree(mdev->cap); -err_free_conf: - kfree(mdev->conf); -err_free_mdev: - put_device(&mdev->dev); - return ret; -} - -/** - * hdm_disconnect - disconnect function of USB device driver - * @interface: Interface of the attached USB device - * - * This deregisters the interface with the core, removes the kernel timer - * and frees resources. - * - * Context: hub kernel thread - */ -static void hdm_disconnect(struct usb_interface *interface) -{ - struct most_dev *mdev = usb_get_intfdata(interface); - - mutex_lock(&mdev->io_mutex); - usb_set_intfdata(interface, NULL); - mdev->usb_device = NULL; - mutex_unlock(&mdev->io_mutex); - - del_timer_sync(&mdev->link_stat_timer); - cancel_work_sync(&mdev->poll_work_obj); - - if (mdev->dci) - device_unregister(&mdev->dci->dev); - most_deregister_interface(&mdev->iface); - - kfree(mdev->busy_urbs); - kfree(mdev->cap); - kfree(mdev->conf); - kfree(mdev->ep_address); - put_device(&mdev->dci->dev); - put_device(&mdev->dev); -} - -static int hdm_suspend(struct usb_interface *interface, pm_message_t message) -{ - struct most_dev *mdev = usb_get_intfdata(interface); - int i; - - mutex_lock(&mdev->io_mutex); - for (i = 0; i < mdev->iface.num_channels; i++) { - most_stop_enqueue(&mdev->iface, i); - usb_kill_anchored_urbs(&mdev->busy_urbs[i]); - } - mutex_unlock(&mdev->io_mutex); - return 0; -} - -static int hdm_resume(struct usb_interface *interface) -{ - struct most_dev *mdev = usb_get_intfdata(interface); - int i; - - mutex_lock(&mdev->io_mutex); - for (i = 0; i < mdev->iface.num_channels; i++) - most_resume_enqueue(&mdev->iface, i); - mutex_unlock(&mdev->io_mutex); - return 0; -} - -static struct usb_driver hdm_usb = { - .name = "hdm_usb", - .id_table = usbid, - .probe = hdm_probe, - .disconnect = hdm_disconnect, - .resume = hdm_resume, - .suspend = hdm_suspend, -}; - -module_usb_driver(hdm_usb); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Christian Gromm "); -MODULE_DESCRIPTION("HDM_4_USB"); -- cgit v1.2.3-58-ga151 From 3e338d3c95c735dc3265a86016bb4c022ec7cadc Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Thu, 30 Jul 2020 12:26:32 -0700 Subject: staging: android: ashmem: Fix lockdep warning for write operation syzbot report [1] describes a deadlock when write operation against an ashmem fd executed at the time when ashmem is shrinking its cache results in the following lock sequence: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(fs_reclaim); lock(&sb->s_type->i_mutex_key#13); lock(fs_reclaim); lock(&sb->s_type->i_mutex_key#13); kswapd takes fs_reclaim and then inode_lock while generic_perform_write takes inode_lock and then fs_reclaim. However ashmem does not support writing into backing shmem with a write syscall. The only way to change its content is to mmap it and operate on mapped memory. Therefore the race that lockdep is warning about is not valid. Resolve this by introducing a separate lockdep class for the backing shmem inodes. [1]: https://lkml.kernel.org/lkml/0000000000000b5f9d059aa2037f@google.com/ Reported-by: syzbot+7a0d9d0b26efefe61780@syzkaller.appspotmail.com Signed-off-by: Suren Baghdasaryan Cc: stable Reviewed-by: Joel Fernandes (Google) Link: https://lore.kernel.org/r/20200730192632.3088194-1-surenb@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ashmem.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index c05a214191da..10b4be1f3e78 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -95,6 +95,15 @@ static DEFINE_MUTEX(ashmem_mutex); static struct kmem_cache *ashmem_area_cachep __read_mostly; static struct kmem_cache *ashmem_range_cachep __read_mostly; +/* + * A separate lockdep class for the backing shmem inodes to resolve the lockdep + * warning about the race between kswapd taking fs_reclaim before inode_lock + * and write syscall taking inode_lock and then fs_reclaim. + * Note that such race is impossible because ashmem does not support write + * syscalls operating on the backing shmem. + */ +static struct lock_class_key backing_shmem_inode_class; + static inline unsigned long range_size(struct ashmem_range *range) { return range->pgend - range->pgstart + 1; @@ -396,6 +405,7 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) if (!asma->file) { char *name = ASHMEM_NAME_DEF; struct file *vmfile; + struct inode *inode; if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0') name = asma->name; @@ -407,6 +417,8 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) goto out; } vmfile->f_mode |= FMODE_LSEEK; + inode = file_inode(vmfile); + lockdep_set_class(&inode->i_rwsem, &backing_shmem_inode_class); asma->file = vmfile; /* * override mmap operation of the vmfile so that it can't be -- cgit v1.2.3-58-ga151 From d47cecef7116d9c32efb254f7aa91ae5fb2df545 Mon Sep 17 00:00:00 2001 From: Tomer Samara Date: Fri, 31 Jul 2020 21:23:30 +0300 Subject: staging: netlogic: clear alignment style issues Clear checkpatch alignment style issues in xlr_net.c. CHECK: Alignment should match open parenthesis Signed-off-by: Tomer Samara Link: https://lore.kernel.org/r/20200731182330.GA3176@tsnow Signed-off-by: Greg Kroah-Hartman --- drivers/staging/netlogic/xlr_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c index 204fcdfc022f..69ea61faf8fa 100644 --- a/drivers/staging/netlogic/xlr_net.c +++ b/drivers/staging/netlogic/xlr_net.c @@ -355,7 +355,7 @@ static void xlr_stats(struct net_device *ndev, struct rtnl_link_stats64 *stats) stats->rx_missed_errors); stats->tx_aborted_errors = xlr_nae_rdreg(priv->base_addr, - TX_EXCESSIVE_COLLISION_PACKET_COUNTER); + TX_EXCESSIVE_COLLISION_PACKET_COUNTER); stats->tx_carrier_errors = xlr_nae_rdreg(priv->base_addr, TX_DROP_FRAME_COUNTER); stats->tx_fifo_errors = xlr_nae_rdreg(priv->base_addr, -- cgit v1.2.3-58-ga151 From 5df9de5a40b00c965febad655773d6fb9a7961d5 Mon Sep 17 00:00:00 2001 From: Ivan Safonov Date: Sat, 1 Aug 2020 21:02:35 +0300 Subject: staging: r8188eu: replace rtw_netdev_priv define with inline function The function guarantees type checking of arguments and return value. Result of rtw_netdev_priv macro can be assigned to pointer with incompatible type without warning. The function allow compiler to perform this check. Signed-off-by: Ivan Safonov Link: https://lore.kernel.org/r/20200801180235.34116-1-insafonov@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/osdep_service.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 31d897f1d21f..b44d602e954a 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -71,8 +71,11 @@ struct rtw_netdev_priv_indicator { }; struct net_device *rtw_alloc_etherdev_with_old_priv(void *old_priv); -#define rtw_netdev_priv(netdev) \ - (((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv) +static inline struct adapter *rtw_netdev_priv(struct net_device *netdev) +{ + return ((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv; +} + void rtw_free_netdev(struct net_device *netdev); #define FUNC_NDEV_FMT "%s(%s)" -- cgit v1.2.3-58-ga151 From 54c4f6f8de62e6c0be80e7e023437ff0bbae089b Mon Sep 17 00:00:00 2001 From: Tomer Samara Date: Sun, 2 Aug 2020 00:00:56 +0300 Subject: staging: rts5208: clear alignment style issues Clear checkpatch alignment style issues in rtsx_transport.c. CHECK: Alignment should match open parenthesis Signed-off-by: Tomer Samara Link: https://lore.kernel.org/r/20200801210056.GA305272@tsnow Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c index 5f1eefe80f1e..0027bcf638ad 100644 --- a/drivers/staging/rts5208/rtsx_transport.c +++ b/drivers/staging/rts5208/rtsx_transport.c @@ -678,7 +678,7 @@ static int rtsx_transfer_buf(struct rtsx_chip *chip, u8 card, void *buf, /* Wait for TRANS_OK_INT */ timeleft = wait_for_completion_interruptible_timeout(&trans_done, - msecs_to_jiffies(timeout)); + msecs_to_jiffies(timeout)); if (timeleft <= 0) { dev_dbg(rtsx_dev(chip), "Timeout (%s %d)\n", __func__, __LINE__); -- cgit v1.2.3-58-ga151 From 5bbd90550da8f7bdac769b5825597e67183c9411 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 2 Aug 2020 11:21:39 +0200 Subject: staging: most: fix up movement of USB driver When moving the most usb driver out of staging, we forgot to remove the subdirectory out of the staging Makefile as well. Fixes: 97a6f772f36b ("drivers: most: add USB adapter driver") Cc: Christian Gromm Reported-by: Michael Straube Link: https://lore.kernel.org/r/20200802092139.GA140088@kroah.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/Makefile | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/Makefile b/drivers/staging/most/Makefile index a803a98654a8..7c10b84ebac0 100644 --- a/drivers/staging/most/Makefile +++ b/drivers/staging/most/Makefile @@ -6,4 +6,3 @@ obj-$(CONFIG_MOST_SOUND) += sound/ obj-$(CONFIG_MOST_VIDEO) += video/ obj-$(CONFIG_MOST_DIM2) += dim2/ obj-$(CONFIG_MOST_I2C) += i2c/ -obj-$(CONFIG_MOST_USB) += usb/ -- cgit v1.2.3-58-ga151