diff options
487 files changed, 2972 insertions, 3973 deletions
diff --git a/Documentation/devicetree/bindings/iio/adc/mcp320x.txt b/Documentation/devicetree/bindings/iio/adc/mcp320x.txt index bcd3ac8e6e0c..7d64753df949 100644 --- a/Documentation/devicetree/bindings/iio/adc/mcp320x.txt +++ b/Documentation/devicetree/bindings/iio/adc/mcp320x.txt @@ -29,15 +29,29 @@ Required properties: "microchip,mcp3204" "microchip,mcp3208" "microchip,mcp3301" + "microchip,mcp3550-50" + "microchip,mcp3550-60" + "microchip,mcp3551" + "microchip,mcp3553" NOTE: The use of the compatibles with no vendor prefix is deprecated and only listed because old DT use them. + - spi-cpha, spi-cpol (boolean): + Either SPI mode (0,0) or (1,1) must be used, so specify + none or both of spi-cpha, spi-cpol. The MCP3550/1/3 + is more efficient in mode (1,1) as only 3 instead of + 4 bytes need to be read from the ADC, but not all SPI + masters support it. + + - vref-supply: Phandle to the external reference voltage supply. + Examples: spi_controller { mcp3x0x@0 { compatible = "mcp3002"; reg = <0>; spi-max-frequency = <1000000>; + vref-supply = <&vref_reg>; }; }; diff --git a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt index 64dc4843c180..0df9befdaecc 100644 --- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt +++ b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt @@ -12,6 +12,7 @@ for the Thermal Controller which holds a phandle to the AUXADC. Required properties: - compatible: Should be one of: - "mediatek,mt2701-auxadc": For MT2701 family of SoCs + - "mediatek,mt2712-auxadc": For MT2712 family of SoCs - "mediatek,mt7622-auxadc": For MT7622 family of SoCs - "mediatek,mt8173-auxadc": For MT8173 family of SoCs - reg: Address range of the AUXADC unit. diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt index 9ec6f5ce54fc..678c035d9ed6 100644 --- a/Documentation/devicetree/bindings/iio/st-sensors.txt +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt @@ -71,3 +71,5 @@ Pressure sensors: - st,lps25h-press - st,lps331ap-press - st,lps22hb-press +- st,lps33hw +- st,lps35hw diff --git a/arch/arm/configs/pxa_defconfig b/arch/arm/configs/pxa_defconfig index d5e1370ec303..830e817a028a 100644 --- a/arch/arm/configs/pxa_defconfig +++ b/arch/arm/configs/pxa_defconfig @@ -219,7 +219,8 @@ CONFIG_AD525X_DPOT_I2C=m CONFIG_ICS932S401=m CONFIG_APDS9802ALS=m CONFIG_ISL29003=m -CONFIG_TI_DAC7512=m +CONFIG_IIO=m +CONFIG_AD5446=m CONFIG_EEPROM_AT24=m CONFIG_SENSORS_LIS3_SPI=m CONFIG_IDE=m diff --git a/arch/arm/configs/raumfeld_defconfig b/arch/arm/configs/raumfeld_defconfig index e3dc80ead465..77a56c23c6ef 100644 --- a/arch/arm/configs/raumfeld_defconfig +++ b/arch/arm/configs/raumfeld_defconfig @@ -37,7 +37,8 @@ CONFIG_MTD_NAND_PXA3xx=y CONFIG_MTD_UBI=y CONFIG_BLK_DEV_LOOP=y CONFIG_ISL29003=y -CONFIG_TI_DAC7512=y +CONFIG_IIO=y +CONFIG_AD5446=y CONFIG_SCSI=y CONFIG_BLK_DEV_SD=y CONFIG_CHR_DEV_SG=y diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 9ccb5828db98..7251d0e63d74 100644 --- a/drivers/iio/accel/adxl345_core.c +++ b/drivers/iio/accel/adxl345_core.c @@ -95,7 +95,6 @@ static int adxl345_read_raw(struct iio_dev *indio_dev, } static const struct iio_info adxl345_info = { - .driver_module = THIS_MODULE, .read_raw = adxl345_read_raw, }; diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index 3dec972ca672..cb9765a3de60 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -536,7 +536,6 @@ static const struct iio_info bma180_info = { .attrs = &bma180_attrs_group, .read_raw = bma180_read_raw, .write_raw = bma180_write_raw, - .driver_module = THIS_MODULE, }; static const char * const bma180_power_modes[] = { "low_noise", "low_power" }; @@ -700,7 +699,6 @@ static int bma180_trig_try_reen(struct iio_trigger *trig) static const struct iio_trigger_ops bma180_trigger_ops = { .set_trigger_state = bma180_data_rdy_trigger_set_state, .try_reenable = bma180_trig_try_reen, - .owner = THIS_MODULE, }; static int bma180_probe(struct i2c_client *client, diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index 5099f295dd37..e25d91c017ed 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -186,7 +186,6 @@ static int bma220_write_raw(struct iio_dev *indio_dev, } static const struct iio_info bma220_info = { - .driver_module = THIS_MODULE, .read_raw = bma220_read_raw, .write_raw = bma220_write_raw, .attrs = &bma220_attribute_group, diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 807299dd45eb..870f92ef61c2 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -1094,7 +1094,6 @@ static const struct iio_info bmc150_accel_info = { .write_event_value = bmc150_accel_write_event, .write_event_config = bmc150_accel_write_event_config, .read_event_config = bmc150_accel_read_event_config, - .driver_module = THIS_MODULE, }; static const struct iio_info bmc150_accel_info_fifo = { @@ -1108,7 +1107,6 @@ static const struct iio_info bmc150_accel_info_fifo = { .validate_trigger = bmc150_accel_validate_trigger, .hwfifo_set_watermark = bmc150_accel_set_watermark, .hwfifo_flush_to_buffer = bmc150_accel_fifo_flush, - .driver_module = THIS_MODULE, }; static const unsigned long bmc150_accel_scan_masks[] = { @@ -1200,7 +1198,6 @@ static int bmc150_accel_trigger_set_state(struct iio_trigger *trig, static const struct iio_trigger_ops bmc150_accel_trigger_ops = { .set_trigger_state = bmc150_accel_trigger_set_state, .try_reenable = bmc150_accel_trig_try_reen, - .owner = THIS_MODULE, }; static int bmc150_accel_handle_roc_event(struct iio_dev *indio_dev) diff --git a/drivers/iio/accel/da280.c b/drivers/iio/accel/da280.c index ed8343aeac9c..6c214783241c 100644 --- a/drivers/iio/accel/da280.c +++ b/drivers/iio/accel/da280.c @@ -88,7 +88,6 @@ static int da280_read_raw(struct iio_dev *indio_dev, } static const struct iio_info da280_info = { - .driver_module = THIS_MODULE, .read_raw = da280_read_raw, }; diff --git a/drivers/iio/accel/da311.c b/drivers/iio/accel/da311.c index c0c1620d2a2f..aa64bca00955 100644 --- a/drivers/iio/accel/da311.c +++ b/drivers/iio/accel/da311.c @@ -212,7 +212,6 @@ static int da311_read_raw(struct iio_dev *indio_dev, } static const struct iio_info da311_info = { - .driver_module = THIS_MODULE, .read_raw = da311_read_raw, }; diff --git a/drivers/iio/accel/dmard06.c b/drivers/iio/accel/dmard06.c index 656ca8e1927f..d87e2c751475 100644 --- a/drivers/iio/accel/dmard06.c +++ b/drivers/iio/accel/dmard06.c @@ -124,7 +124,6 @@ static int dmard06_read_raw(struct iio_dev *indio_dev, } static const struct iio_info dmard06_info = { - .driver_module = THIS_MODULE, .read_raw = dmard06_read_raw, }; diff --git a/drivers/iio/accel/dmard09.c b/drivers/iio/accel/dmard09.c index d3a28f96565c..16a7e74f5e9a 100644 --- a/drivers/iio/accel/dmard09.c +++ b/drivers/iio/accel/dmard09.c @@ -93,7 +93,6 @@ static int dmard09_read_raw(struct iio_dev *indio_dev, } static const struct iio_info dmard09_info = { - .driver_module = THIS_MODULE, .read_raw = dmard09_read_raw, }; diff --git a/drivers/iio/accel/dmard10.c b/drivers/iio/accel/dmard10.c index b8736cc75656..9518ea00167e 100644 --- a/drivers/iio/accel/dmard10.c +++ b/drivers/iio/accel/dmard10.c @@ -170,7 +170,6 @@ static int dmard10_read_raw(struct iio_dev *indio_dev, } static const struct iio_info dmard10_info = { - .driver_module = THIS_MODULE, .read_raw = dmard10_read_raw, }; diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index 2238a26aba63..c066a3bdbff7 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c @@ -225,7 +225,6 @@ static int accel_3d_write_raw(struct iio_dev *indio_dev, } static const struct iio_info accel_3d_info = { - .driver_module = THIS_MODULE, .read_raw = &accel_3d_read_raw, .write_raw = &accel_3d_write_raw, }; diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index 3f968c46e667..1e0b59f3e221 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -950,7 +950,6 @@ static const struct iio_info kxcjk1013_info = { .write_event_value = kxcjk1013_write_event, .write_event_config = kxcjk1013_write_event_config, .read_event_config = kxcjk1013_read_event_config, - .driver_module = THIS_MODULE, }; static const unsigned long kxcjk1013_scan_masks[] = {0x7, 0}; @@ -1036,7 +1035,6 @@ static int kxcjk1013_data_rdy_trigger_set_state(struct iio_trigger *trig, static const struct iio_trigger_ops kxcjk1013_trigger_ops = { .set_trigger_state = kxcjk1013_data_rdy_trigger_set_state, .try_reenable = kxcjk1013_trig_try_reen, - .owner = THIS_MODULE, }; static irqreturn_t kxcjk1013_event_handler(int irq, void *private) diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index 9af60ac70738..0c0df4fce420 100644 --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c @@ -390,7 +390,6 @@ static const struct iio_info kxsd9_info = { .read_raw = &kxsd9_read_raw, .write_raw = &kxsd9_write_raw, .attrs = &kxsd9_attribute_group, - .driver_module = THIS_MODULE, }; /* Four channels apart from timestamp, scan mask = 0x0f */ diff --git a/drivers/iio/accel/mc3230.c b/drivers/iio/accel/mc3230.c index 4ea2ff623a6d..8b11604eed63 100644 --- a/drivers/iio/accel/mc3230.c +++ b/drivers/iio/accel/mc3230.c @@ -107,7 +107,6 @@ static int mc3230_read_raw(struct iio_dev *indio_dev, } static const struct iio_info mc3230_info = { - .driver_module = THIS_MODULE, .read_raw = mc3230_read_raw, }; diff --git a/drivers/iio/accel/mma7455_core.c b/drivers/iio/accel/mma7455_core.c index 6551085bedd7..da0ceaac46b5 100644 --- a/drivers/iio/accel/mma7455_core.c +++ b/drivers/iio/accel/mma7455_core.c @@ -199,7 +199,6 @@ static const struct iio_info mma7455_info = { .attrs = &mma7455_group, .read_raw = mma7455_read_raw, .write_raw = mma7455_write_raw, - .driver_module = THIS_MODULE, }; #define MMA7455_CHANNEL(axis, idx) { \ diff --git a/drivers/iio/accel/mma7660.c b/drivers/iio/accel/mma7660.c index 42fa57e41bdd..f1a13724efb3 100644 --- a/drivers/iio/accel/mma7660.c +++ b/drivers/iio/accel/mma7660.c @@ -168,7 +168,6 @@ static int mma7660_read_raw(struct iio_dev *indio_dev, } static const struct iio_info mma7660_info = { - .driver_module = THIS_MODULE, .read_raw = mma7660_read_raw, .attrs = &mma7660_attribute_group, }; diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index eb6e3dc789b2..61941692bec5 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -59,7 +59,9 @@ #define MMA8452_FF_MT_THS 0x17 #define MMA8452_FF_MT_THS_MASK 0x7f #define MMA8452_FF_MT_COUNT 0x18 +#define MMA8452_FF_MT_CHAN_SHIFT 3 #define MMA8452_TRANSIENT_CFG 0x1d +#define MMA8452_TRANSIENT_CFG_CHAN(chan) BIT(chan + 1) #define MMA8452_TRANSIENT_CFG_HPF_BYP BIT(0) #define MMA8452_TRANSIENT_CFG_ELE BIT(4) #define MMA8452_TRANSIENT_SRC 0x1e @@ -69,6 +71,7 @@ #define MMA8452_TRANSIENT_THS 0x1f #define MMA8452_TRANSIENT_THS_MASK GENMASK(6, 0) #define MMA8452_TRANSIENT_COUNT 0x20 +#define MMA8452_TRANSIENT_CHAN_SHIFT 1 #define MMA8452_CTRL_REG1 0x2a #define MMA8452_CTRL_ACTIVE BIT(0) #define MMA8452_CTRL_DR_MASK GENMASK(5, 3) @@ -107,6 +110,51 @@ struct mma8452_data { const struct mma_chip_info *chip_info; }; + /** + * struct mma8452_event_regs - chip specific data related to events + * @ev_cfg: event config register address + * @ev_cfg_ele: latch bit in event config register + * @ev_cfg_chan_shift: number of the bit to enable events in X + * direction; in event config register + * @ev_src: event source register address + * @ev_ths: event threshold register address + * @ev_ths_mask: mask for the threshold value + * @ev_count: event count (period) register address + * + * Since not all chips supported by the driver support comparing high pass + * filtered data for events (interrupts), different interrupt sources are + * used for different chips and the relevant registers are included here. + */ +struct mma8452_event_regs { + u8 ev_cfg; + u8 ev_cfg_ele; + u8 ev_cfg_chan_shift; + u8 ev_src; + u8 ev_ths; + u8 ev_ths_mask; + u8 ev_count; +}; + +static const struct mma8452_event_regs ev_regs_accel_falling = { + .ev_cfg = MMA8452_FF_MT_CFG, + .ev_cfg_ele = MMA8452_FF_MT_CFG_ELE, + .ev_cfg_chan_shift = MMA8452_FF_MT_CHAN_SHIFT, + .ev_src = MMA8452_FF_MT_SRC, + .ev_ths = MMA8452_FF_MT_THS, + .ev_ths_mask = MMA8452_FF_MT_THS_MASK, + .ev_count = MMA8452_FF_MT_COUNT +}; + +static const struct mma8452_event_regs ev_regs_accel_rising = { + .ev_cfg = MMA8452_TRANSIENT_CFG, + .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE, + .ev_cfg_chan_shift = MMA8452_TRANSIENT_CHAN_SHIFT, + .ev_src = MMA8452_TRANSIENT_SRC, + .ev_ths = MMA8452_TRANSIENT_THS, + .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK, + .ev_count = MMA8452_TRANSIENT_COUNT, +}; + /** * struct mma_chip_info - chip specific data * @chip_id: WHO_AM_I register's value @@ -116,40 +164,16 @@ struct mma8452_data { * @mma_scales: scale factors for converting register values * to m/s^2; 3 modes: 2g, 4g, 8g; 2 integers * per mode: m/s^2 and micro m/s^2 - * @ev_cfg: event config register address - * @ev_cfg_ele: latch bit in event config register - * @ev_cfg_chan_shift: number of the bit to enable events in X - * direction; in event config register - * @ev_src: event source register address - * @ev_src_xe: bit in event source register that indicates - * an event in X direction - * @ev_src_ye: bit in event source register that indicates - * an event in Y direction - * @ev_src_ze: bit in event source register that indicates - * an event in Z direction - * @ev_ths: event threshold register address - * @ev_ths_mask: mask for the threshold value - * @ev_count: event count (period) register address - * - * Since not all chips supported by the driver support comparing high pass - * filtered data for events (interrupts), different interrupt sources are - * used for different chips and the relevant registers are included here. + * @all_events: all events supported by this chip + * @enabled_events: event flags enabled and handled by this driver */ struct mma_chip_info { u8 chip_id; const struct iio_chan_spec *channels; int num_channels; const int mma_scales[3][2]; - u8 ev_cfg; - u8 ev_cfg_ele; - u8 ev_cfg_chan_shift; - u8 ev_src; - u8 ev_src_xe; - u8 ev_src_ye; - u8 ev_src_ze; - u8 ev_ths; - u8 ev_ths_mask; - u8 ev_count; + int all_events; + int enabled_events; }; enum { @@ -394,11 +418,11 @@ static ssize_t mma8452_show_os_ratio_avail(struct device *dev, } static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(mma8452_show_samp_freq_avail); -static IIO_DEVICE_ATTR(in_accel_scale_available, S_IRUGO, +static IIO_DEVICE_ATTR(in_accel_scale_available, 0444, mma8452_show_scale_avail, NULL, 0); static IIO_DEVICE_ATTR(in_accel_filter_high_pass_3db_frequency_available, - S_IRUGO, mma8452_show_hp_cutoff_avail, NULL, 0); -static IIO_DEVICE_ATTR(in_accel_oversampling_ratio_available, S_IRUGO, + 0444, mma8452_show_hp_cutoff_avail, NULL, 0); +static IIO_DEVICE_ATTR(in_accel_oversampling_ratio_available, 0444, mma8452_show_os_ratio_avail, NULL, 0); static int mma8452_get_samp_freq_index(struct mma8452_data *data, @@ -602,9 +626,8 @@ static int mma8452_set_power_mode(struct mma8452_data *data, u8 mode) static int mma8452_freefall_mode_enabled(struct mma8452_data *data) { int val; - const struct mma_chip_info *chip = data->chip_info; - val = i2c_smbus_read_byte_data(data->client, chip->ev_cfg); + val = i2c_smbus_read_byte_data(data->client, MMA8452_FF_MT_CFG); if (val < 0) return val; @@ -614,29 +637,28 @@ static int mma8452_freefall_mode_enabled(struct mma8452_data *data) static int mma8452_set_freefall_mode(struct mma8452_data *data, bool state) { int val; - const struct mma_chip_info *chip = data->chip_info; if ((state && mma8452_freefall_mode_enabled(data)) || (!state && !(mma8452_freefall_mode_enabled(data)))) return 0; - val = i2c_smbus_read_byte_data(data->client, chip->ev_cfg); + val = i2c_smbus_read_byte_data(data->client, MMA8452_FF_MT_CFG); if (val < 0) return val; if (state) { - val |= BIT(idx_x + chip->ev_cfg_chan_shift); - val |= BIT(idx_y + chip->ev_cfg_chan_shift); - val |= BIT(idx_z + chip->ev_cfg_chan_shift); + val |= BIT(idx_x + MMA8452_FF_MT_CHAN_SHIFT); + val |= BIT(idx_y + MMA8452_FF_MT_CHAN_SHIFT); + val |= BIT(idx_z + MMA8452_FF_MT_CHAN_SHIFT); val &= ~MMA8452_FF_MT_CFG_OAE; } else { - val &= ~BIT(idx_x + chip->ev_cfg_chan_shift); - val &= ~BIT(idx_y + chip->ev_cfg_chan_shift); - val &= ~BIT(idx_z + chip->ev_cfg_chan_shift); + val &= ~BIT(idx_x + MMA8452_FF_MT_CHAN_SHIFT); + val &= ~BIT(idx_y + MMA8452_FF_MT_CHAN_SHIFT); + val &= ~BIT(idx_z + MMA8452_FF_MT_CHAN_SHIFT); val |= MMA8452_FF_MT_CFG_OAE; } - return mma8452_change_config(data, chip->ev_cfg, val); + return mma8452_change_config(data, MMA8452_FF_MT_CFG, val); } static int mma8452_set_hp_filter_frequency(struct mma8452_data *data, @@ -740,6 +762,36 @@ static int mma8452_write_raw(struct iio_dev *indio_dev, return ret; } +static int mma8452_get_event_regs(struct mma8452_data *data, + const struct iio_chan_spec *chan, enum iio_event_direction dir, + const struct mma8452_event_regs **ev_reg) +{ + if (!chan) + return -EINVAL; + + switch (chan->type) { + case IIO_ACCEL: + switch (dir) { + case IIO_EV_DIR_RISING: + if ((data->chip_info->all_events + & MMA8452_INT_TRANS) && + (data->chip_info->enabled_events + & MMA8452_INT_TRANS)) + *ev_reg = &ev_regs_accel_rising; + else + *ev_reg = &ev_regs_accel_falling; + return 0; + case IIO_EV_DIR_FALLING: + *ev_reg = &ev_regs_accel_falling; + return 0; + default: + return -EINVAL; + } + default: + return -EINVAL; + } +} + static int mma8452_read_thresh(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, @@ -749,21 +801,24 @@ static int mma8452_read_thresh(struct iio_dev *indio_dev, { struct mma8452_data *data = iio_priv(indio_dev); int ret, us, power_mode; + const struct mma8452_event_regs *ev_regs; + + ret = mma8452_get_event_regs(data, chan, dir, &ev_regs); + if (ret) + return ret; switch (info) { case IIO_EV_INFO_VALUE: - ret = i2c_smbus_read_byte_data(data->client, - data->chip_info->ev_ths); + ret = i2c_smbus_read_byte_data(data->client, ev_regs->ev_ths); if (ret < 0) return ret; - *val = ret & data->chip_info->ev_ths_mask; + *val = ret & ev_regs->ev_ths_mask; return IIO_VAL_INT; case IIO_EV_INFO_PERIOD: - ret = i2c_smbus_read_byte_data(data->client, - data->chip_info->ev_count); + ret = i2c_smbus_read_byte_data(data->client, ev_regs->ev_count); if (ret < 0) return ret; @@ -809,14 +864,18 @@ static int mma8452_write_thresh(struct iio_dev *indio_dev, { struct mma8452_data *data = iio_priv(indio_dev); int ret, reg, steps; + const struct mma8452_event_regs *ev_regs; + + ret = mma8452_get_event_regs(data, chan, dir, &ev_regs); + if (ret) + return ret; switch (info) { case IIO_EV_INFO_VALUE: - if (val < 0 || val > MMA8452_TRANSIENT_THS_MASK) + if (val < 0 || val > ev_regs->ev_ths_mask) return -EINVAL; - return mma8452_change_config(data, data->chip_info->ev_ths, - val); + return mma8452_change_config(data, ev_regs->ev_ths, val); case IIO_EV_INFO_PERIOD: ret = mma8452_get_power_mode(data); @@ -830,8 +889,7 @@ static int mma8452_write_thresh(struct iio_dev *indio_dev, if (steps < 0 || steps > 0xff) return -EINVAL; - return mma8452_change_config(data, data->chip_info->ev_count, - steps); + return mma8452_change_config(data, ev_regs->ev_count, steps); case IIO_EV_INFO_HIGH_PASS_FILTER_3DB: reg = i2c_smbus_read_byte_data(data->client, @@ -861,23 +919,24 @@ static int mma8452_read_event_config(struct iio_dev *indio_dev, enum iio_event_direction dir) { struct mma8452_data *data = iio_priv(indio_dev); - const struct mma_chip_info *chip = data->chip_info; int ret; + const struct mma8452_event_regs *ev_regs; + + ret = mma8452_get_event_regs(data, chan, dir, &ev_regs); + if (ret) + return ret; switch (dir) { case IIO_EV_DIR_FALLING: return mma8452_freefall_mode_enabled(data); case IIO_EV_DIR_RISING: - if (mma8452_freefall_mode_enabled(data)) - return 0; - ret = i2c_smbus_read_byte_data(data->client, - data->chip_info->ev_cfg); + ev_regs->ev_cfg); if (ret < 0) return ret; return !!(ret & BIT(chan->scan_index + - chip->ev_cfg_chan_shift)); + ev_regs->ev_cfg_chan_shift)); default: return -EINVAL; } @@ -890,8 +949,12 @@ static int mma8452_write_event_config(struct iio_dev *indio_dev, int state) { struct mma8452_data *data = iio_priv(indio_dev); - const struct mma_chip_info *chip = data->chip_info; int val, ret; + const struct mma8452_event_regs *ev_regs; + + ret = mma8452_get_event_regs(data, chan, dir, &ev_regs); + if (ret) + return ret; ret = mma8452_set_runtime_pm_state(data->client, state); if (ret) @@ -901,28 +964,30 @@ static int mma8452_write_event_config(struct iio_dev *indio_dev, case IIO_EV_DIR_FALLING: return mma8452_set_freefall_mode(data, state); case IIO_EV_DIR_RISING: - val = i2c_smbus_read_byte_data(data->client, chip->ev_cfg); + val = i2c_smbus_read_byte_data(data->client, ev_regs->ev_cfg); if (val < 0) return val; if (state) { if (mma8452_freefall_mode_enabled(data)) { - val &= ~BIT(idx_x + chip->ev_cfg_chan_shift); - val &= ~BIT(idx_y + chip->ev_cfg_chan_shift); - val &= ~BIT(idx_z + chip->ev_cfg_chan_shift); + val &= ~BIT(idx_x + ev_regs->ev_cfg_chan_shift); + val &= ~BIT(idx_y + ev_regs->ev_cfg_chan_shift); + val &= ~BIT(idx_z + ev_regs->ev_cfg_chan_shift); val |= MMA8452_FF_MT_CFG_OAE; } - val |= BIT(chan->scan_index + chip->ev_cfg_chan_shift); + val |= BIT(chan->scan_index + + ev_regs->ev_cfg_chan_shift); } else { if (mma8452_freefall_mode_enabled(data)) return 0; - val &= ~BIT(chan->scan_index + chip->ev_cfg_chan_shift); + val &= ~BIT(chan->scan_index + + ev_regs->ev_cfg_chan_shift); } - val |= chip->ev_cfg_ele; + val |= ev_regs->ev_cfg_ele; - return mma8452_change_config(data, chip->ev_cfg, val); + return mma8452_change_config(data, ev_regs->ev_cfg, val); default: return -EINVAL; } @@ -934,35 +999,25 @@ static void mma8452_transient_interrupt(struct iio_dev *indio_dev) s64 ts = iio_get_time_ns(indio_dev); int src; - src = i2c_smbus_read_byte_data(data->client, data->chip_info->ev_src); + src = i2c_smbus_read_byte_data(data->client, MMA8452_TRANSIENT_SRC); if (src < 0) return; - if (mma8452_freefall_mode_enabled(data)) { - iio_push_event(indio_dev, - IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, - IIO_MOD_X_AND_Y_AND_Z, - IIO_EV_TYPE_MAG, - IIO_EV_DIR_FALLING), - ts); - return; - } - - if (src & data->chip_info->ev_src_xe) + if (src & MMA8452_TRANSIENT_SRC_XTRANSE) iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_X, IIO_EV_TYPE_MAG, IIO_EV_DIR_RISING), ts); - if (src & data->chip_info->ev_src_ye) + if (src & MMA8452_TRANSIENT_SRC_YTRANSE) iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Y, IIO_EV_TYPE_MAG, IIO_EV_DIR_RISING), ts); - if (src & data->chip_info->ev_src_ze) + if (src & MMA8452_TRANSIENT_SRC_ZTRANSE) iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, IIO_MOD_Z, IIO_EV_TYPE_MAG, @@ -974,7 +1029,6 @@ static irqreturn_t mma8452_interrupt(int irq, void *p) { struct iio_dev *indio_dev = p; struct mma8452_data *data = iio_priv(indio_dev); - const struct mma_chip_info *chip = data->chip_info; int ret = IRQ_NONE; int src; @@ -982,15 +1036,29 @@ static irqreturn_t mma8452_interrupt(int irq, void *p) if (src < 0) return IRQ_NONE; + if (!(src & data->chip_info->enabled_events)) + return IRQ_NONE; + if (src & MMA8452_INT_DRDY) { iio_trigger_poll_chained(indio_dev->trig); ret = IRQ_HANDLED; } - if ((src & MMA8452_INT_TRANS && - chip->ev_src == MMA8452_TRANSIENT_SRC) || - (src & MMA8452_INT_FF_MT && - chip->ev_src == MMA8452_FF_MT_SRC)) { + if (src & MMA8452_INT_FF_MT) { + if (mma8452_freefall_mode_enabled(data)) { + s64 ts = iio_get_time_ns(indio_dev); + + iio_push_event(indio_dev, + IIO_MOD_EVENT_CODE(IIO_ACCEL, 0, + IIO_MOD_X_AND_Y_AND_Z, + IIO_EV_TYPE_MAG, + IIO_EV_DIR_FALLING), + ts); + } + ret = IRQ_HANDLED; + } + + if (src & MMA8452_INT_TRANS) { mma8452_transient_interrupt(indio_dev); ret = IRQ_HANDLED; } @@ -1020,8 +1088,8 @@ done: } static int mma8452_reg_access_dbg(struct iio_dev *indio_dev, - unsigned reg, unsigned writeval, - unsigned *readval) + unsigned int reg, unsigned int writeval, + unsigned int *readval) { int ret; struct mma8452_data *data = iio_priv(indio_dev); @@ -1222,96 +1290,87 @@ static const struct mma_chip_info mma_chip_info_table[] = { * g * N * 1000000 / 2048 for N = 2, 4, 8 and g=9.80665 */ .mma_scales = { {0, 2394}, {0, 4788}, {0, 9577} }, - .ev_cfg = MMA8452_TRANSIENT_CFG, - .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE, - .ev_cfg_chan_shift = 1, - .ev_src = MMA8452_TRANSIENT_SRC, - .ev_src_xe = MMA8452_TRANSIENT_SRC_XTRANSE, - .ev_src_ye = MMA8452_TRANSIENT_SRC_YTRANSE, - .ev_src_ze = MMA8452_TRANSIENT_SRC_ZTRANSE, - .ev_ths = MMA8452_TRANSIENT_THS, - .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK, - .ev_count = MMA8452_TRANSIENT_COUNT, + /* + * Although we enable the interrupt sources once and for + * all here the event detection itself is not enabled until + * userspace asks for it by mma8452_write_event_config() + */ + .all_events = MMA8452_INT_DRDY | + MMA8452_INT_TRANS | + MMA8452_INT_FF_MT, + .enabled_events = MMA8452_INT_TRANS | + MMA8452_INT_FF_MT, }, [mma8452] = { .chip_id = MMA8452_DEVICE_ID, .channels = mma8452_channels, .num_channels = ARRAY_SIZE(mma8452_channels), .mma_scales = { {0, 9577}, {0, 19154}, {0, 38307} }, - .ev_cfg = MMA8452_TRANSIENT_CFG, - .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE, - .ev_cfg_chan_shift = 1, - .ev_src = MMA8452_TRANSIENT_SRC, - .ev_src_xe = MMA8452_TRANSIENT_SRC_XTRANSE, - .ev_src_ye = MMA8452_TRANSIENT_SRC_YTRANSE, - .ev_src_ze = MMA8452_TRANSIENT_SRC_ZTRANSE, - .ev_ths = MMA8452_TRANSIENT_THS, - .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK, - .ev_count = MMA8452_TRANSIENT_COUNT, + /* + * Although we enable the interrupt sources once and for + * all here the event detection itself is not enabled until + * userspace asks for it by mma8452_write_event_config() + */ + .all_events = MMA8452_INT_DRDY | + MMA8452_INT_TRANS | + MMA8452_INT_FF_MT, + .enabled_events = MMA8452_INT_TRANS | + MMA8452_INT_FF_MT, }, [mma8453] = { .chip_id = MMA8453_DEVICE_ID, .channels = mma8453_channels, .num_channels = ARRAY_SIZE(mma8453_channels), .mma_scales = { {0, 38307}, {0, 76614}, {0, 153228} }, - .ev_cfg = MMA8452_TRANSIENT_CFG, - .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE, - .ev_cfg_chan_shift = 1, - .ev_src = MMA8452_TRANSIENT_SRC, - .ev_src_xe = MMA8452_TRANSIENT_SRC_XTRANSE, - .ev_src_ye = MMA8452_TRANSIENT_SRC_YTRANSE, - .ev_src_ze = MMA8452_TRANSIENT_SRC_ZTRANSE, - .ev_ths = MMA8452_TRANSIENT_THS, - .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK, - .ev_count = MMA8452_TRANSIENT_COUNT, + /* + * Although we enable the interrupt sources once and for + * all here the event detection itself is not enabled until + * userspace asks for it by mma8452_write_event_config() + */ + .all_events = MMA8452_INT_DRDY | + MMA8452_INT_TRANS | + MMA8452_INT_FF_MT, + .enabled_events = MMA8452_INT_TRANS | + MMA8452_INT_FF_MT, }, [mma8652] = { .chip_id = MMA8652_DEVICE_ID, .channels = mma8652_channels, .num_channels = ARRAY_SIZE(mma8652_channels), .mma_scales = { {0, 9577}, {0, 19154}, {0, 38307} }, - .ev_cfg = MMA8452_FF_MT_CFG, - .ev_cfg_ele = MMA8452_FF_MT_CFG_ELE, - .ev_cfg_chan_shift = 3, - .ev_src = MMA8452_FF_MT_SRC, - .ev_src_xe = MMA8452_FF_MT_SRC_XHE, - .ev_src_ye = MMA8452_FF_MT_SRC_YHE, - .ev_src_ze = MMA8452_FF_MT_SRC_ZHE, - .ev_ths = MMA8452_FF_MT_THS, - .ev_ths_mask = MMA8452_FF_MT_THS_MASK, - .ev_count = MMA8452_FF_MT_COUNT, + .all_events = MMA8452_INT_DRDY | + MMA8452_INT_FF_MT, + .enabled_events = MMA8452_INT_FF_MT, }, [mma8653] = { .chip_id = MMA8653_DEVICE_ID, .channels = mma8653_channels, .num_channels = ARRAY_SIZE(mma8653_channels), .mma_scales = { {0, 38307}, {0, 76614}, {0, 153228} }, - .ev_cfg = MMA8452_FF_MT_CFG, - .ev_cfg_ele = MMA8452_FF_MT_CFG_ELE, - .ev_cfg_chan_shift = 3, - .ev_src = MMA8452_FF_MT_SRC, - .ev_src_xe = MMA8452_FF_MT_SRC_XHE, - .ev_src_ye = MMA8452_FF_MT_SRC_YHE, - .ev_src_ze = MMA8452_FF_MT_SRC_ZHE, - .ev_ths = MMA8452_FF_MT_THS, - .ev_ths_mask = MMA8452_FF_MT_THS_MASK, - .ev_count = MMA8452_FF_MT_COUNT, + /* + * Although we enable the interrupt sources once and for + * all here the event detection itself is not enabled until + * userspace asks for it by mma8452_write_event_config() + */ + .all_events = MMA8452_INT_DRDY | + MMA8452_INT_FF_MT, + .enabled_events = MMA8452_INT_FF_MT, }, [fxls8471] = { .chip_id = FXLS8471_DEVICE_ID, .channels = mma8451_channels, .num_channels = ARRAY_SIZE(mma8451_channels), .mma_scales = { {0, 2394}, {0, 4788}, {0, 9577} }, - .ev_cfg = MMA8452_TRANSIENT_CFG, - .ev_cfg_ele = MMA8452_TRANSIENT_CFG_ELE, - .ev_cfg_chan_shift = 1, - .ev_src = MMA8452_TRANSIENT_SRC, - .ev_src_xe = MMA8452_TRANSIENT_SRC_XTRANSE, - .ev_src_ye = MMA8452_TRANSIENT_SRC_YTRANSE, - .ev_src_ze = MMA8452_TRANSIENT_SRC_ZTRANSE, - .ev_ths = MMA8452_TRANSIENT_THS, - .ev_ths_mask = MMA8452_TRANSIENT_THS_MASK, - .ev_count = MMA8452_TRANSIENT_COUNT, + /* + * Although we enable the interrupt sources once and for + * all here the event detection itself is not enabled until + * userspace asks for it by mma8452_write_event_config() + */ + .all_events = MMA8452_INT_DRDY | + MMA8452_INT_TRANS | + MMA8452_INT_FF_MT, + .enabled_events = MMA8452_INT_TRANS | + MMA8452_INT_FF_MT, }, }; @@ -1337,7 +1396,6 @@ static const struct iio_info mma8452_info = { .read_event_config = &mma8452_read_event_config, .write_event_config = &mma8452_write_event_config, .debugfs_reg_access = &mma8452_reg_access_dbg, - .driver_module = THIS_MODULE, }; static const unsigned long mma8452_scan_masks[] = {0x7, 0}; @@ -1368,7 +1426,6 @@ static int mma8452_data_rdy_trigger_set_state(struct iio_trigger *trig, static const struct iio_trigger_ops mma8452_trigger_ops = { .set_trigger_state = mma8452_data_rdy_trigger_set_state, .validate_device = iio_trigger_validate_own_device, - .owner = THIS_MODULE, }; static int mma8452_trigger_setup(struct iio_dev *indio_dev) @@ -1509,16 +1566,6 @@ static int mma8452_probe(struct i2c_client *client, return ret; if (client->irq) { - /* - * Although we enable the interrupt sources once and for - * all here the event detection itself is not enabled until - * userspace asks for it by mma8452_write_event_config() - */ - int supported_interrupts = MMA8452_INT_DRDY | - MMA8452_INT_TRANS | - MMA8452_INT_FF_MT; - int enabled_interrupts = MMA8452_INT_TRANS | - MMA8452_INT_FF_MT; int irq2; irq2 = of_irq_get_byname(client->dev.of_node, "INT2"); @@ -1527,8 +1574,8 @@ static int mma8452_probe(struct i2c_client *client, dev_dbg(&client->dev, "using interrupt line INT2\n"); } else { ret = i2c_smbus_write_byte_data(client, - MMA8452_CTRL_REG5, - supported_interrupts); + MMA8452_CTRL_REG5, + data->chip_info->all_events); if (ret < 0) return ret; @@ -1536,8 +1583,8 @@ static int mma8452_probe(struct i2c_client *client, } ret = i2c_smbus_write_byte_data(client, - MMA8452_CTRL_REG4, - enabled_interrupts); + MMA8452_CTRL_REG4, + data->chip_info->enabled_events); if (ret < 0) return ret; diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c index 1f53f08476f5..da7c21504f38 100644 --- a/drivers/iio/accel/mma9551.c +++ b/drivers/iio/accel/mma9551.c @@ -332,7 +332,6 @@ static const struct iio_chan_spec mma9551_channels[] = { }; static const struct iio_info mma9551_info = { - .driver_module = THIS_MODULE, .read_raw = mma9551_read_raw, .read_event_config = mma9551_read_event_config, .write_event_config = mma9551_write_event_config, diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c index 36bf19733be0..b52a3f182190 100644 --- a/drivers/iio/accel/mma9553.c +++ b/drivers/iio/accel/mma9553.c @@ -987,7 +987,6 @@ static const struct iio_chan_spec mma9553_channels[] = { }; static const struct iio_info mma9553_info = { - .driver_module = THIS_MODULE, .read_raw = mma9553_read_raw, .write_raw = mma9553_write_raw, .read_event_config = mma9553_read_event_config, diff --git a/drivers/iio/accel/mxc4005.c b/drivers/iio/accel/mxc4005.c index c23f47af7256..58099e40d717 100644 --- a/drivers/iio/accel/mxc4005.c +++ b/drivers/iio/accel/mxc4005.c @@ -264,7 +264,6 @@ static int mxc4005_write_raw(struct iio_dev *indio_dev, } static const struct iio_info mxc4005_info = { - .driver_module = THIS_MODULE, .read_raw = mxc4005_read_raw, .write_raw = mxc4005_write_raw, .attrs = &mxc4005_attrs_group, @@ -376,7 +375,6 @@ static int mxc4005_trigger_try_reen(struct iio_trigger *trig) static const struct iio_trigger_ops mxc4005_trigger_ops = { .set_trigger_state = mxc4005_set_trigger_state, .try_reenable = mxc4005_trigger_try_reen, - .owner = THIS_MODULE, }; static int mxc4005_chip_init(struct mxc4005_data *data) diff --git a/drivers/iio/accel/mxc6255.c b/drivers/iio/accel/mxc6255.c index 0abad6948201..ddd50d1781c5 100644 --- a/drivers/iio/accel/mxc6255.c +++ b/drivers/iio/accel/mxc6255.c @@ -78,7 +78,6 @@ static int mxc6255_read_raw(struct iio_dev *indio_dev, } static const struct iio_info mxc6255_info = { - .driver_module = THIS_MODULE, .read_raw = mxc6255_read_raw, }; diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c index 39ab210c44f6..f33dadf7b262 100644 --- a/drivers/iio/accel/sca3000.c +++ b/drivers/iio/accel/sca3000.c @@ -1454,7 +1454,6 @@ static const struct iio_info sca3000_info = { .write_event_value = &sca3000_write_event_value, .read_event_config = &sca3000_read_event_config, .write_event_config = &sca3000_write_event_config, - .driver_module = THIS_MODULE, }; static int sca3000_probe(struct spi_device *spi) diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 752856b3a849..1a2e54ff473a 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -721,7 +721,6 @@ static const struct attribute_group st_accel_attribute_group = { }; static const struct iio_info accel_info = { - .driver_module = THIS_MODULE, .attrs = &st_accel_attribute_group, .read_raw = &st_accel_read_raw, .write_raw = &st_accel_write_raw, @@ -730,7 +729,6 @@ static const struct iio_info accel_info = { #ifdef CONFIG_IIO_TRIGGER static const struct iio_trigger_ops st_accel_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = ST_ACCEL_TRIGGER_SET_STATE, .validate_device = st_sensors_validate_device, }; diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c index e31023dc5f1b..cacc0da2f874 100644 --- a/drivers/iio/accel/stk8312.c +++ b/drivers/iio/accel/stk8312.c @@ -237,7 +237,6 @@ static int stk8312_data_rdy_trigger_set_state(struct iio_trigger *trig, static const struct iio_trigger_ops stk8312_trigger_ops = { .set_trigger_state = stk8312_data_rdy_trigger_set_state, - .owner = THIS_MODULE, }; static int stk8312_set_sample_rate(struct stk8312_data *data, u8 rate) @@ -421,7 +420,6 @@ static int stk8312_write_raw(struct iio_dev *indio_dev, } static const struct iio_info stk8312_info = { - .driver_module = THIS_MODULE, .read_raw = stk8312_read_raw, .write_raw = stk8312_write_raw, .attrs = &stk8312_attribute_group, diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c index 300d955bad00..576b6b140f08 100644 --- a/drivers/iio/accel/stk8ba50.c +++ b/drivers/iio/accel/stk8ba50.c @@ -179,7 +179,6 @@ static int stk8ba50_data_rdy_trigger_set_state(struct iio_trigger *trig, static const struct iio_trigger_ops stk8ba50_trigger_ops = { .set_trigger_state = stk8ba50_data_rdy_trigger_set_state, - .owner = THIS_MODULE, }; static int stk8ba50_set_power(struct stk8ba50_data *data, bool mode) @@ -307,7 +306,6 @@ static int stk8ba50_write_raw(struct iio_dev *indio_dev, } static const struct iio_info stk8ba50_info = { - .driver_module = THIS_MODULE, .read_raw = stk8ba50_read_raw, .write_raw = stk8ba50_write_raw, .attrs = &stk8ba50_attribute_group, diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c index b8d5cfd57ec4..605eb5e7e829 100644 --- a/drivers/iio/adc/ad7266.c +++ b/drivers/iio/adc/ad7266.c @@ -280,7 +280,6 @@ static AD7266_DECLARE_DIFF_CHANNELS_FIXED(u, 'u'); static const struct iio_info ad7266_info = { .read_raw = &ad7266_read_raw, .update_scan_mode = &ad7266_update_scan_mode, - .driver_module = THIS_MODULE, }; static const unsigned long ad7266_available_scan_masks[] = { diff --git a/drivers/iio/adc/ad7291.c b/drivers/iio/adc/ad7291.c index 1d90b02732bb..a862b5d8fb4b 100644 --- a/drivers/iio/adc/ad7291.c +++ b/drivers/iio/adc/ad7291.c @@ -461,7 +461,6 @@ static const struct iio_info ad7291_info = { .write_event_config = &ad7291_write_event_config, .read_event_value = &ad7291_read_event_value, .write_event_value = &ad7291_write_event_value, - .driver_module = THIS_MODULE, }; static int ad7291_probe(struct i2c_client *client, diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index e399bf04c73a..2b20c6c8ec7f 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c @@ -280,7 +280,6 @@ static int ad7298_read_raw(struct iio_dev *indio_dev, static const struct iio_info ad7298_info = { .read_raw = &ad7298_read_raw, .update_scan_mode = ad7298_update_scan_mode, - .driver_module = THIS_MODULE, }; static int ad7298_probe(struct spi_device *spi) diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c index b7ecf9aab90f..b7706bf10ffe 100644 --- a/drivers/iio/adc/ad7476.c +++ b/drivers/iio/adc/ad7476.c @@ -195,7 +195,6 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = { }; static const struct iio_info ad7476_info = { - .driver_module = THIS_MODULE, .read_raw = &ad7476_read_raw, }; diff --git a/drivers/iio/adc/ad7766.c b/drivers/iio/adc/ad7766.c index ce45037295d8..3ae14fc8c649 100644 --- a/drivers/iio/adc/ad7766.c +++ b/drivers/iio/adc/ad7766.c @@ -185,7 +185,6 @@ static const struct iio_buffer_setup_ops ad7766_buffer_setup_ops = { }; static const struct iio_info ad7766_info = { - .driver_module = THIS_MODULE, .read_raw = &ad7766_read_raw, }; @@ -208,7 +207,6 @@ static int ad7766_set_trigger_state(struct iio_trigger *trig, bool enable) } static const struct iio_trigger_ops ad7766_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = ad7766_set_trigger_state, .validate_device = iio_trigger_validate_own_device, }; diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c index 34e353c43ac8..70fbf92f9827 100644 --- a/drivers/iio/adc/ad7791.c +++ b/drivers/iio/adc/ad7791.c @@ -308,13 +308,11 @@ static const struct iio_info ad7791_info = { .read_raw = &ad7791_read_raw, .attrs = &ad7791_attribute_group, .validate_trigger = ad_sd_validate_trigger, - .driver_module = THIS_MODULE, }; static const struct iio_info ad7791_no_filter_info = { .read_raw = &ad7791_read_raw, .validate_trigger = ad_sd_validate_trigger, - .driver_module = THIS_MODULE, }; static int ad7791_setup(struct ad7791_state *st, diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c index 47c3d7f32900..801afb61310b 100644 --- a/drivers/iio/adc/ad7793.c +++ b/drivers/iio/adc/ad7793.c @@ -563,7 +563,6 @@ static const struct iio_info ad7793_info = { .write_raw_get_fmt = &ad7793_write_raw_get_fmt, .attrs = &ad7793_attribute_group, .validate_trigger = ad_sd_validate_trigger, - .driver_module = THIS_MODULE, }; static const struct iio_info ad7797_info = { @@ -572,7 +571,6 @@ static const struct iio_info ad7797_info = { .write_raw_get_fmt = &ad7793_write_raw_get_fmt, .attrs = &ad7793_attribute_group, .validate_trigger = ad_sd_validate_trigger, - .driver_module = THIS_MODULE, }; #define DECLARE_AD7793_CHANNELS(_name, _b, _sb, _s) \ diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c index 7a483bfbd70c..205c0f1761aa 100644 --- a/drivers/iio/adc/ad7887.c +++ b/drivers/iio/adc/ad7887.c @@ -229,7 +229,6 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = { static const struct iio_info ad7887_info = { .read_raw = &ad7887_read_raw, - .driver_module = THIS_MODULE, }; static int ad7887_probe(struct spi_device *spi) diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index 77a675e11ebb..ffb7e089969c 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -262,7 +262,6 @@ static int ad7923_read_raw(struct iio_dev *indio_dev, static const struct iio_info ad7923_info = { .read_raw = &ad7923_read_raw, .update_scan_mode = ad7923_update_scan_mode, - .driver_module = THIS_MODULE, }; static int ad7923_probe(struct spi_device *spi) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index 22426ae4af97..e1da67d5ee22 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -526,13 +526,11 @@ static const struct attribute_group ad799x_event_attrs_group = { static const struct iio_info ad7991_info = { .read_raw = &ad799x_read_raw, - .driver_module = THIS_MODULE, .update_scan_mode = ad799x_update_scan_mode, }; static const struct iio_info ad7993_4_7_8_noirq_info = { .read_raw = &ad799x_read_raw, - .driver_module = THIS_MODULE, .update_scan_mode = ad799x_update_scan_mode, }; @@ -543,7 +541,6 @@ static const struct iio_info ad7993_4_7_8_irq_info = { .write_event_config = &ad799x_write_event_config, .read_event_value = &ad799x_read_event_value, .write_event_value = &ad799x_write_event_value, - .driver_module = THIS_MODULE, .update_scan_mode = ad799x_update_scan_mode, }; diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c index 22c4c17cd996..cf1b048b0665 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c @@ -463,7 +463,6 @@ int ad_sd_validate_trigger(struct iio_dev *indio_dev, struct iio_trigger *trig) EXPORT_SYMBOL_GPL(ad_sd_validate_trigger); static const struct iio_trigger_ops ad_sd_trigger_ops = { - .owner = THIS_MODULE, }; static int ad_sd_probe_trigger(struct iio_dev *indio_dev) diff --git a/drivers/iio/adc/aspeed_adc.c b/drivers/iio/adc/aspeed_adc.c index c02b23d675cb..8a958d5f1905 100644 --- a/drivers/iio/adc/aspeed_adc.c +++ b/drivers/iio/adc/aspeed_adc.c @@ -165,7 +165,6 @@ static int aspeed_adc_reg_access(struct iio_dev *indio_dev, } static const struct iio_info aspeed_adc_iio_info = { - .driver_module = THIS_MODULE, .read_raw = aspeed_adc_read_raw, .write_raw = aspeed_adc_write_raw, .debugfs_reg_access = aspeed_adc_reg_access, diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index bc5b38e3a147..318601bad354 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -338,7 +338,6 @@ static int at91_adc_reenable_trigger(struct iio_trigger *trig) } static const struct iio_trigger_ops at91_adc_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = &at91_adc_configure_trigger, .try_reenable = &at91_adc_reenable_trigger, }; @@ -574,7 +573,6 @@ static int at91_adc_write_raw(struct iio_dev *indio_dev, static const struct iio_info at91_adc_info = { .read_raw = &at91_adc_read_raw, .write_raw = &at91_adc_write_raw, - .driver_module = THIS_MODULE, }; static void at91_adc_hw_init(struct at91_adc_state *st) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 15109728cae7..3836d4222a3e 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -594,7 +594,6 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state) } static const struct iio_trigger_ops at91_adc_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = &at91_adc_configure_trigger, }; @@ -976,7 +975,6 @@ static int at91_adc_probe_pdata(struct at91_adc_state *st, } static const struct iio_info at91_adc_info = { - .driver_module = THIS_MODULE, .read_raw = &at91_adc_read_raw, }; diff --git a/drivers/iio/adc/axp20x_adc.c b/drivers/iio/adc/axp20x_adc.c index 11e177180ea0..a30a97245e91 100644 --- a/drivers/iio/adc/axp20x_adc.c +++ b/drivers/iio/adc/axp20x_adc.c @@ -464,12 +464,10 @@ static int axp20x_write_raw(struct iio_dev *indio_dev, static const struct iio_info axp20x_adc_iio_info = { .read_raw = axp20x_read_raw, .write_raw = axp20x_write_raw, - .driver_module = THIS_MODULE, }; static const struct iio_info axp22x_adc_iio_info = { .read_raw = axp22x_read_raw, - .driver_module = THIS_MODULE, }; static int axp20x_adc_rate(int rate) diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c index 462a99c13e7a..60c9e853dd81 100644 --- a/drivers/iio/adc/axp288_adc.c +++ b/drivers/iio/adc/axp288_adc.c @@ -183,7 +183,6 @@ static int axp288_adc_set_state(struct regmap *regmap) static const struct iio_info axp288_adc_iio_info = { .read_raw = &axp288_adc_read_raw, - .driver_module = THIS_MODULE, }; static int axp288_adc_probe(struct platform_device *pdev) diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c index 7f4f9c4150e3..7af59a4bbd8d 100644 --- a/drivers/iio/adc/bcm_iproc_adc.c +++ b/drivers/iio/adc/bcm_iproc_adc.c @@ -492,7 +492,6 @@ static int iproc_adc_read_raw(struct iio_dev *indio_dev, static const struct iio_info iproc_adc_iio_info = { .read_raw = &iproc_adc_read_raw, - .driver_module = THIS_MODULE, }; #define IPROC_ADC_CHANNEL(_index, _id) { \ diff --git a/drivers/iio/adc/berlin2-adc.c b/drivers/iio/adc/berlin2-adc.c index 71c806ecc722..72d8fa94ab31 100644 --- a/drivers/iio/adc/berlin2-adc.c +++ b/drivers/iio/adc/berlin2-adc.c @@ -277,7 +277,6 @@ static irqreturn_t berlin2_adc_tsen_irq(int irq, void *private) } static const struct iio_info berlin2_adc_info = { - .driver_module = THIS_MODULE, .read_raw = berlin2_adc_read_raw, }; diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c index 91636c0ba5b5..707d8b24b072 100644 --- a/drivers/iio/adc/cc10001_adc.c +++ b/drivers/iio/adc/cc10001_adc.c @@ -262,7 +262,6 @@ static int cc10001_update_scan_mode(struct iio_dev *indio_dev, } static const struct iio_info cc10001_adc_info = { - .driver_module = THIS_MODULE, .read_raw = &cc10001_adc_read_raw, .update_scan_mode = &cc10001_update_scan_mode, }; diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c index 6e419d5a7c14..3576ec73ec23 100644 --- a/drivers/iio/adc/cpcap-adc.c +++ b/drivers/iio/adc/cpcap-adc.c @@ -932,7 +932,6 @@ err_unlock: static const struct iio_info cpcap_adc_info = { .read_raw = &cpcap_adc_read, - .driver_module = THIS_MODULE, }; /* diff --git a/drivers/iio/adc/da9150-gpadc.c b/drivers/iio/adc/da9150-gpadc.c index 3445107e10b7..0a5d9ce79164 100644 --- a/drivers/iio/adc/da9150-gpadc.c +++ b/drivers/iio/adc/da9150-gpadc.c @@ -249,7 +249,6 @@ static int da9150_gpadc_read_raw(struct iio_dev *indio_dev, static const struct iio_info da9150_gpadc_info = { .read_raw = &da9150_gpadc_read_raw, - .driver_module = THIS_MODULE, }; #define DA9150_GPADC_CHANNEL(_id, _hw_id, _type, chan_info, \ diff --git a/drivers/iio/adc/dln2-adc.c b/drivers/iio/adc/dln2-adc.c index ab8d6aed5085..c64c6675cae6 100644 --- a/drivers/iio/adc/dln2-adc.c +++ b/drivers/iio/adc/dln2-adc.c @@ -479,7 +479,6 @@ static const struct iio_info dln2_adc_info = { .read_raw = dln2_adc_read_raw, .write_raw = dln2_adc_write_raw, .update_scan_mode = dln2_update_scan_mode, - .driver_module = THIS_MODULE, }; static irqreturn_t dln2_adc_trigger_h(int irq, void *p) @@ -604,10 +603,6 @@ static void dln2_adc_event(struct platform_device *pdev, u16 echo, iio_trigger_poll(dln2->trig); } -static const struct iio_trigger_ops dln2_adc_trigger_ops = { - .owner = THIS_MODULE, -}; - static int dln2_adc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -665,7 +660,6 @@ static int dln2_adc_probe(struct platform_device *pdev) dev_err(dev, "failed to allocate trigger\n"); return -ENOMEM; } - dln2->trig->ops = &dln2_adc_trigger_ops; iio_trigger_set_drvdata(dln2->trig, dln2); devm_iio_trigger_register(dev, dln2->trig); iio_trigger_set_immutable(indio_dev, dln2->trig); diff --git a/drivers/iio/adc/envelope-detector.c b/drivers/iio/adc/envelope-detector.c index fef15c0d7c9c..4ebda8ab54fe 100644 --- a/drivers/iio/adc/envelope-detector.c +++ b/drivers/iio/adc/envelope-detector.c @@ -322,7 +322,6 @@ static const struct iio_chan_spec envelope_detector_iio_channel = { static const struct iio_info envelope_detector_info = { .read_raw = &envelope_detector_read_raw, - .driver_module = THIS_MODULE, }; static int envelope_detector_probe(struct platform_device *pdev) diff --git a/drivers/iio/adc/ep93xx_adc.c b/drivers/iio/adc/ep93xx_adc.c index a179ac476c6d..81c901507ad2 100644 --- a/drivers/iio/adc/ep93xx_adc.c +++ b/drivers/iio/adc/ep93xx_adc.c @@ -150,7 +150,6 @@ static int ep93xx_read_raw(struct iio_dev *iiodev, } static const struct iio_info ep93xx_adc_info = { - .driver_module = THIS_MODULE, .read_raw = ep93xx_read_raw, }; diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index 6c5a7be9f8c1..f10443f92e4c 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -657,7 +657,6 @@ static int exynos_adc_reg_access(struct iio_dev *indio_dev, static const struct iio_info exynos_adc_iio_info = { .read_raw = &exynos_read_raw, .debugfs_reg_access = &exynos_adc_reg_access, - .driver_module = THIS_MODULE, }; #define ADC_CHANNEL(_index, _id) { \ diff --git a/drivers/iio/adc/hi8435.c b/drivers/iio/adc/hi8435.c index adf7dc712937..6f6c9a348158 100644 --- a/drivers/iio/adc/hi8435.c +++ b/drivers/iio/adc/hi8435.c @@ -408,7 +408,6 @@ static const struct iio_chan_spec hi8435_channels[] = { }; static const struct iio_info hi8435_info = { - .driver_module = THIS_MODULE, .read_raw = hi8435_read_raw, .read_event_config = hi8435_read_event_config, .write_event_config = hi8435_write_event_config, diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c index 27005d84ed73..d10b9f13d557 100644 --- a/drivers/iio/adc/hx711.c +++ b/drivers/iio/adc/hx711.c @@ -374,7 +374,6 @@ static const struct attribute_group hx711_attribute_group = { }; static const struct iio_info hx711_iio_info = { - .driver_module = THIS_MODULE, .read_raw = hx711_read_raw, .write_raw = hx711_write_raw, .write_raw_get_fmt = hx711_write_raw_get_fmt, diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c index 254b29a68b9d..cfab31162845 100644 --- a/drivers/iio/adc/imx7d_adc.c +++ b/drivers/iio/adc/imx7d_adc.c @@ -412,7 +412,6 @@ static int imx7d_adc_reg_access(struct iio_dev *indio_dev, } static const struct iio_info imx7d_adc_iio_info = { - .driver_module = THIS_MODULE, .read_raw = &imx7d_adc_read_raw, .debugfs_reg_access = &imx7d_adc_reg_access, }; diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c index f387b972e4f4..a16f8c6ba744 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -778,7 +778,6 @@ static const struct attribute_group ina226_attribute_group = { }; static const struct iio_info ina219_info = { - .driver_module = THIS_MODULE, .attrs = &ina219_attribute_group, .read_raw = ina2xx_read_raw, .write_raw = ina2xx_write_raw, @@ -786,7 +785,6 @@ static const struct iio_info ina219_info = { }; static const struct iio_info ina226_info = { - .driver_module = THIS_MODULE, .attrs = &ina226_attribute_group, .read_raw = ina2xx_read_raw, .write_raw = ina2xx_write_raw, diff --git a/drivers/iio/adc/lp8788_adc.c b/drivers/iio/adc/lp8788_adc.c index 152cfc8e1c7b..3bc4df916420 100644 --- a/drivers/iio/adc/lp8788_adc.c +++ b/drivers/iio/adc/lp8788_adc.c @@ -125,7 +125,6 @@ static int lp8788_adc_read_raw(struct iio_dev *indio_dev, static const struct iio_info lp8788_adc_info = { .read_raw = &lp8788_adc_read_raw, - .driver_module = THIS_MODULE, }; #define LP8788_CHAN(_id, _type) { \ diff --git a/drivers/iio/adc/lpc18xx_adc.c b/drivers/iio/adc/lpc18xx_adc.c index 3ef18f4b27f0..041dc4a3f66c 100644 --- a/drivers/iio/adc/lpc18xx_adc.c +++ b/drivers/iio/adc/lpc18xx_adc.c @@ -116,7 +116,6 @@ static int lpc18xx_adc_read_raw(struct iio_dev *indio_dev, static const struct iio_info lpc18xx_adc_info = { .read_raw = lpc18xx_adc_read_raw, - .driver_module = THIS_MODULE, }; static int lpc18xx_adc_probe(struct platform_device *pdev) diff --git a/drivers/iio/adc/lpc32xx_adc.c b/drivers/iio/adc/lpc32xx_adc.c index 6a5b9a9bc662..20b36690fa4f 100644 --- a/drivers/iio/adc/lpc32xx_adc.c +++ b/drivers/iio/adc/lpc32xx_adc.c @@ -104,7 +104,6 @@ static int lpc32xx_read_raw(struct iio_dev *indio_dev, static const struct iio_info lpc32xx_adc_iio_info = { .read_raw = &lpc32xx_read_raw, - .driver_module = THIS_MODULE, }; #define LPC32XX_ADC_CHANNEL(_index) { \ diff --git a/drivers/iio/adc/ltc2471.c b/drivers/iio/adc/ltc2471.c index 29b7ed60cdb0..b88102b751cf 100644 --- a/drivers/iio/adc/ltc2471.c +++ b/drivers/iio/adc/ltc2471.c @@ -98,7 +98,6 @@ static const struct iio_chan_spec ltc2473_channel[] = { static const struct iio_info ltc2471_info = { .read_raw = ltc2471_read_raw, - .driver_module = THIS_MODULE, }; static int ltc2471_i2c_probe(struct i2c_client *client, diff --git a/drivers/iio/adc/ltc2485.c b/drivers/iio/adc/ltc2485.c index eab91f12454a..b24c14037fd4 100644 --- a/drivers/iio/adc/ltc2485.c +++ b/drivers/iio/adc/ltc2485.c @@ -90,7 +90,6 @@ static const struct iio_chan_spec ltc2485_channel[] = { static const struct iio_info ltc2485_info = { .read_raw = ltc2485_read_raw, - .driver_module = THIS_MODULE, }; static int ltc2485_probe(struct i2c_client *client, diff --git a/drivers/iio/adc/ltc2497.c b/drivers/iio/adc/ltc2497.c index 5bf8011dcde9..f1f7cdf66fbd 100644 --- a/drivers/iio/adc/ltc2497.c +++ b/drivers/iio/adc/ltc2497.c @@ -186,7 +186,6 @@ static const struct iio_chan_spec ltc2497_channel[] = { static const struct iio_info ltc2497_info = { .read_raw = ltc2497_read_raw, - .driver_module = THIS_MODULE, }; static int ltc2497_probe(struct i2c_client *client, diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c index ebc715927e63..375da6491499 100644 --- a/drivers/iio/adc/max1027.c +++ b/drivers/iio/adc/max1027.c @@ -381,13 +381,11 @@ static irqreturn_t max1027_trigger_handler(int irq, void *private) } static const struct iio_trigger_ops max1027_trigger_ops = { - .owner = THIS_MODULE, .validate_device = &iio_trigger_validate_own_device, .set_trigger_state = &max1027_set_trigger_state, }; static const struct iio_info max1027_info = { - .driver_module = THIS_MODULE, .read_raw = &max1027_read_raw, .validate_trigger = &max1027_validate_trigger, .debugfs_reg_access = &max1027_debugfs_reg_access, diff --git a/drivers/iio/adc/max11100.c b/drivers/iio/adc/max11100.c index 1180bcc22ff1..af59ab2e650c 100644 --- a/drivers/iio/adc/max11100.c +++ b/drivers/iio/adc/max11100.c @@ -100,7 +100,6 @@ static int max11100_read_raw(struct iio_dev *indio_dev, } static const struct iio_info max11100_info = { - .driver_module = THIS_MODULE, .read_raw = max11100_read_raw, }; diff --git a/drivers/iio/adc/max1118.c b/drivers/iio/adc/max1118.c index 2e9648a078c4..49db9e9ae625 100644 --- a/drivers/iio/adc/max1118.c +++ b/drivers/iio/adc/max1118.c @@ -155,7 +155,6 @@ static int max1118_read_raw(struct iio_dev *indio_dev, static const struct iio_info max1118_info = { .read_raw = max1118_read_raw, - .driver_module = THIS_MODULE, }; static irqreturn_t max1118_trigger_handler(int irq, void *p) diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index 80eada4886b3..7f1848dac9bf 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -1029,7 +1029,6 @@ static int max1363_update_scan_mode(struct iio_dev *indio_dev, static const struct iio_info max1238_info = { .read_raw = &max1363_read_raw, - .driver_module = THIS_MODULE, .update_scan_mode = &max1363_update_scan_mode, }; @@ -1040,7 +1039,6 @@ static const struct iio_info max1363_info = { .write_event_config = &max1363_write_event_config, .read_raw = &max1363_read_raw, .update_scan_mode = &max1363_update_scan_mode, - .driver_module = THIS_MODULE, .event_attrs = &max1363_event_attribute_group, }; diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c index b1dd17cbce58..0538ff8c4ac1 100644 --- a/drivers/iio/adc/max9611.c +++ b/drivers/iio/adc/max9611.c @@ -460,7 +460,6 @@ static const struct attribute_group max9611_attribute_group = { }; static const struct iio_info indio_info = { - .driver_module = THIS_MODULE, .read_raw = max9611_read_raw, .attrs = &max9611_attribute_group, }; @@ -573,7 +572,6 @@ static int max9611_probe(struct i2c_client *client, static struct i2c_driver max9611_driver = { .driver = { .name = DRIVER_NAME, - .owner = THIS_MODULE, .of_match_table = max9611_of_table, }, .probe = max9611_probe, diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c index 071dd23a33d9..32859188d653 100644 --- a/drivers/iio/adc/mcp320x.c +++ b/drivers/iio/adc/mcp320x.c @@ -59,6 +59,17 @@ struct mcp320x_chip_info { unsigned int resolution; }; +/** + * struct mcp320x - Microchip SPI ADC instance + * @spi: SPI slave (parent of the IIO device) + * @msg: SPI message to select a channel and receive a value from the ADC + * @transfer: SPI transfers used by @msg + * @reg: regulator generating Vref + * @lock: protects read sequences + * @chip_info: ADC properties + * @tx_buf: buffer for @transfer[0] (not used on single-channel converters) + * @rx_buf: buffer for @transfer[1] + */ struct mcp320x { struct spi_device *spi; struct spi_message msg; @@ -78,10 +89,6 @@ static int mcp320x_channel_to_tx_data(int device_index, int start_bit = 1; switch (device_index) { - case mcp3001: - case mcp3201: - case mcp3301: - return 0; case mcp3002: case mcp3202: return ((start_bit << 4) | (!differential << 3) | @@ -102,20 +109,14 @@ static int mcp320x_adc_conversion(struct mcp320x *adc, u8 channel, { int ret; - adc->rx_buf[0] = 0; - adc->rx_buf[1] = 0; - adc->tx_buf = mcp320x_channel_to_tx_data(device_index, - channel, differential); + memset(&adc->rx_buf, 0, sizeof(adc->rx_buf)); + if (adc->chip_info->num_channels > 1) + adc->tx_buf = mcp320x_channel_to_tx_data(device_index, channel, + differential); - if (device_index != mcp3001 && device_index != mcp3201 && device_index != mcp3301) { - ret = spi_sync(adc->spi, &adc->msg); - if (ret < 0) - return ret; - } else { - ret = spi_read(adc->spi, &adc->rx_buf, sizeof(adc->rx_buf)); - if (ret < 0) - return ret; - } + ret = spi_sync(adc->spi, &adc->msg); + if (ret < 0) + return ret; switch (device_index) { case mcp3001: @@ -248,7 +249,6 @@ static const struct iio_chan_spec mcp3208_channels[] = { static const struct iio_info mcp320x_info = { .read_raw = mcp320x_read_raw, - .driver_module = THIS_MODULE, }; static const struct mcp320x_chip_info mcp320x_chip_infos[] = { @@ -330,9 +330,13 @@ static int mcp320x_probe(struct spi_device *spi) adc->transfer[0].len = sizeof(adc->tx_buf); adc->transfer[1].rx_buf = adc->rx_buf; adc->transfer[1].len = sizeof(adc->rx_buf); - - spi_message_init_with_transfers(&adc->msg, adc->transfer, - ARRAY_SIZE(adc->transfer)); + if (chip_info->num_channels == 1) + /* single-channel converters are rx only (no MOSI pin) */ + spi_message_init_with_transfers(&adc->msg, + &adc->transfer[1], 1); + else + spi_message_init_with_transfers(&adc->msg, adc->transfer, + ARRAY_SIZE(adc->transfer)); adc->reg = devm_regulator_get(&spi->dev, "vref"); if (IS_ERR(adc->reg)) @@ -370,62 +374,25 @@ static int mcp320x_remove(struct spi_device *spi) #if defined(CONFIG_OF) static const struct of_device_id mcp320x_dt_ids[] = { /* NOTE: The use of compatibles with no vendor prefix is deprecated. */ - { - .compatible = "mcp3001", - .data = &mcp320x_chip_infos[mcp3001], - }, { - .compatible = "mcp3002", - .data = &mcp320x_chip_infos[mcp3002], - }, { - .compatible = "mcp3004", - .data = &mcp320x_chip_infos[mcp3004], - }, { - .compatible = "mcp3008", - .data = &mcp320x_chip_infos[mcp3008], - }, { - .compatible = "mcp3201", - .data = &mcp320x_chip_infos[mcp3201], - }, { - .compatible = "mcp3202", - .data = &mcp320x_chip_infos[mcp3202], - }, { - .compatible = "mcp3204", - .data = &mcp320x_chip_infos[mcp3204], - }, { - .compatible = "mcp3208", - .data = &mcp320x_chip_infos[mcp3208], - }, { - .compatible = "mcp3301", - .data = &mcp320x_chip_infos[mcp3301], - }, { - .compatible = "microchip,mcp3001", - .data = &mcp320x_chip_infos[mcp3001], - }, { - .compatible = "microchip,mcp3002", - .data = &mcp320x_chip_infos[mcp3002], - }, { - .compatible = "microchip,mcp3004", - .data = &mcp320x_chip_infos[mcp3004], - }, { - .compatible = "microchip,mcp3008", - .data = &mcp320x_chip_infos[mcp3008], - }, { - .compatible = "microchip,mcp3201", - .data = &mcp320x_chip_infos[mcp3201], - }, { - .compatible = "microchip,mcp3202", - .data = &mcp320x_chip_infos[mcp3202], - }, { - .compatible = "microchip,mcp3204", - .data = &mcp320x_chip_infos[mcp3204], - }, { - .compatible = "microchip,mcp3208", - .data = &mcp320x_chip_infos[mcp3208], - }, { - .compatible = "microchip,mcp3301", - .data = &mcp320x_chip_infos[mcp3301], - }, { - } + { .compatible = "mcp3001" }, + { .compatible = "mcp3002" }, + { .compatible = "mcp3004" }, + { .compatible = "mcp3008" }, + { .compatible = "mcp3201" }, + { .compatible = "mcp3202" }, + { .compatible = "mcp3204" }, + { .compatible = "mcp3208" }, + { .compatible = "mcp3301" }, + { .compatible = "microchip,mcp3001" }, + { .compatible = "microchip,mcp3002" }, + { .compatible = "microchip,mcp3004" }, + { .compatible = "microchip,mcp3008" }, + { .compatible = "microchip,mcp3201" }, + { .compatible = "microchip,mcp3202" }, + { .compatible = "microchip,mcp3204" }, + { .compatible = "microchip,mcp3208" }, + { .compatible = "microchip,mcp3301" }, + { } }; MODULE_DEVICE_TABLE(of, mcp320x_dt_ids); #endif diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c index 63de705086ed..819f26011500 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -327,7 +327,6 @@ static const struct iio_info mcp3422_info = { .write_raw = mcp3422_write_raw, .write_raw_get_fmt = mcp3422_write_raw_get_fmt, .attrs = &mcp3422_attribute_group, - .driver_module = THIS_MODULE, }; static int mcp3422_probe(struct i2c_client *client, diff --git a/drivers/iio/adc/men_z188_adc.c b/drivers/iio/adc/men_z188_adc.c index 8f3606de4eaf..c80261748d8f 100644 --- a/drivers/iio/adc/men_z188_adc.c +++ b/drivers/iio/adc/men_z188_adc.c @@ -80,7 +80,6 @@ static int z188_iio_read_raw(struct iio_dev *iio_dev, static const struct iio_info z188_adc_info = { .read_raw = &z188_iio_read_raw, - .driver_module = THIS_MODULE, }; static void men_z188_config_channels(void __iomem *addr) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 2e8dbb89c8c9..9c6932ffc0af 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -840,7 +840,6 @@ out: static const struct iio_info meson_sar_adc_iio_info = { .read_raw = meson_sar_adc_iio_info_read_raw, - .driver_module = THIS_MODULE, }; static const struct meson_sar_adc_data meson_sar_adc_meson8_data = { diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c index 414cf44bf19d..95d76abb64ec 100644 --- a/drivers/iio/adc/mt6577_auxadc.c +++ b/drivers/iio/adc/mt6577_auxadc.c @@ -180,7 +180,6 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev, } static const struct iio_info mt6577_auxadc_info = { - .driver_module = THIS_MODULE, .read_raw = &mt6577_auxadc_read_raw, }; @@ -306,6 +305,7 @@ static SIMPLE_DEV_PM_OPS(mt6577_auxadc_pm_ops, static const struct of_device_id mt6577_auxadc_of_match[] = { { .compatible = "mediatek,mt2701-auxadc", }, + { .compatible = "mediatek,mt2712-auxadc", }, { .compatible = "mediatek,mt7622-auxadc", }, { .compatible = "mediatek,mt8173-auxadc", }, { } diff --git a/drivers/iio/adc/mxs-lradc-adc.c b/drivers/iio/adc/mxs-lradc-adc.c index d32b34638c2f..c627513d9f0f 100644 --- a/drivers/iio/adc/mxs-lradc-adc.c +++ b/drivers/iio/adc/mxs-lradc-adc.c @@ -382,7 +382,6 @@ static const struct attribute_group mxs_lradc_adc_attribute_group = { }; static const struct iio_info mxs_lradc_adc_iio_info = { - .driver_module = THIS_MODULE, .read_raw = mxs_lradc_adc_read_raw, .write_raw = mxs_lradc_adc_write_raw, .write_raw_get_fmt = mxs_lradc_adc_write_raw_get_fmt, @@ -455,7 +454,6 @@ static int mxs_lradc_adc_configure_trigger(struct iio_trigger *trig, bool state) } static const struct iio_trigger_ops mxs_lradc_adc_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = &mxs_lradc_adc_configure_trigger, }; diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c index 08f446695f97..8997e74a8847 100644 --- a/drivers/iio/adc/nau7802.c +++ b/drivers/iio/adc/nau7802.c @@ -402,7 +402,6 @@ static int nau7802_write_raw_get_fmt(struct iio_dev *indio_dev, } static const struct iio_info nau7802_info = { - .driver_module = THIS_MODULE, .read_raw = &nau7802_read_raw, .write_raw = &nau7802_write_raw, .write_raw_get_fmt = nau7802_write_raw_get_fmt, diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c index 7d61b566e148..69b9affeef1e 100644 --- a/drivers/iio/adc/palmas_gpadc.c +++ b/drivers/iio/adc/palmas_gpadc.c @@ -430,7 +430,6 @@ out: static const struct iio_info palmas_gpadc_iio_info = { .read_raw = palmas_gpadc_read_raw, - .driver_module = THIS_MODULE, }; #define PALMAS_ADC_CHAN_IIO(chan, _type, chan_info) \ diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c index cea8f1fb444a..b093ecddf1a8 100644 --- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c +++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c @@ -728,7 +728,6 @@ static int pm8xxx_of_xlate(struct iio_dev *indio_dev, } static const struct iio_info pm8xxx_xoadc_info = { - .driver_module = THIS_MODULE, .of_xlate = pm8xxx_of_xlate, .read_raw = pm8xxx_read_raw, }; diff --git a/drivers/iio/adc/qcom-spmi-iadc.c b/drivers/iio/adc/qcom-spmi-iadc.c index fabd24edc2a1..3f062cd61aba 100644 --- a/drivers/iio/adc/qcom-spmi-iadc.c +++ b/drivers/iio/adc/qcom-spmi-iadc.c @@ -356,7 +356,6 @@ static int iadc_read_raw(struct iio_dev *indio_dev, static const struct iio_info iadc_info = { .read_raw = iadc_read_raw, - .driver_module = THIS_MODULE, }; static irqreturn_t iadc_isr(int irq, void *dev_id) diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c index 9e600bfd1765..3680e0d47412 100644 --- a/drivers/iio/adc/qcom-spmi-vadc.c +++ b/drivers/iio/adc/qcom-spmi-vadc.c @@ -506,7 +506,6 @@ static int vadc_of_xlate(struct iio_dev *indio_dev, static const struct iio_info vadc_info = { .read_raw = vadc_read_raw, .of_xlate = vadc_of_xlate, - .driver_module = THIS_MODULE, }; struct vadc_channels { diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c index 27a318164619..2cb5397ceeea 100644 --- a/drivers/iio/adc/rcar-gyroadc.c +++ b/drivers/iio/adc/rcar-gyroadc.c @@ -277,7 +277,6 @@ static int rcar_gyroadc_reg_access(struct iio_dev *indio_dev, } static const struct iio_info rcar_gyroadc_iio_info = { - .driver_module = THIS_MODULE, .read_raw = rcar_gyroadc_read_raw, .debugfs_reg_access = rcar_gyroadc_reg_access, }; diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c index 5f612d694b33..1f98566d5b3c 100644 --- a/drivers/iio/adc/rockchip_saradc.c +++ b/drivers/iio/adc/rockchip_saradc.c @@ -125,7 +125,6 @@ static irqreturn_t rockchip_saradc_isr(int irq, void *dev_id) static const struct iio_info rockchip_saradc_iio_info = { .read_raw = rockchip_saradc_read_raw, - .driver_module = THIS_MODULE, }; #define ADC_CHANNEL(_index, _id) { \ diff --git a/drivers/iio/adc/spear_adc.c b/drivers/iio/adc/spear_adc.c index 5dd61f6a57b9..b1da2c46107c 100644 --- a/drivers/iio/adc/spear_adc.c +++ b/drivers/iio/adc/spear_adc.c @@ -254,7 +254,6 @@ static int spear_adc_configure(struct spear_adc_state *st) static const struct iio_info spear_adc_info = { .read_raw = &spear_adc_read_raw, .write_raw = &spear_adc_write_raw, - .driver_module = THIS_MODULE, }; static int spear_adc_probe(struct platform_device *pdev) diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index 4df32cf1650e..8b7c24780a8a 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -1385,7 +1385,6 @@ static const struct iio_info stm32_adc_iio_info = { .update_scan_mode = stm32_adc_update_scan_mode, .debugfs_reg_access = stm32_adc_debugfs_reg_access, .of_xlate = stm32_adc_of_xlate, - .driver_module = THIS_MODULE, }; static unsigned int stm32_adc_dma_residue(struct stm32_adc *adc) diff --git a/drivers/iio/adc/stx104.c b/drivers/iio/adc/stx104.c index 2da741d27540..17b021f33180 100644 --- a/drivers/iio/adc/stx104.c +++ b/drivers/iio/adc/stx104.c @@ -172,7 +172,6 @@ static int stx104_write_raw(struct iio_dev *indio_dev, } static const struct iio_info stx104_info = { - .driver_module = THIS_MODULE, .read_raw = stx104_read_raw, .write_raw = stx104_write_raw }; diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 137f577d9432..a146160d9966 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -352,7 +352,6 @@ static int sun4i_gpadc_read_raw(struct iio_dev *indio_dev, static const struct iio_info sun4i_gpadc_iio_info = { .read_raw = sun4i_gpadc_read_raw, - .driver_module = THIS_MODULE, }; static irqreturn_t sun4i_gpadc_temp_data_irq_handler(int irq, void *dev_id) diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c index 319172cf7da8..405e3779c0c5 100644 --- a/drivers/iio/adc/ti-adc081c.c +++ b/drivers/iio/adc/ti-adc081c.c @@ -124,7 +124,6 @@ static struct adcxx1c_model adcxx1c_models[] = { static const struct iio_info adc081c_info = { .read_raw = adc081c_read_raw, - .driver_module = THIS_MODULE, }; static irqreturn_t adc081c_trigger_handler(int irq, void *p) diff --git a/drivers/iio/adc/ti-adc0832.c b/drivers/iio/adc/ti-adc0832.c index e952e94a14af..188dae705bf7 100644 --- a/drivers/iio/adc/ti-adc0832.c +++ b/drivers/iio/adc/ti-adc0832.c @@ -195,7 +195,6 @@ static int adc0832_read_raw(struct iio_dev *iio, static const struct iio_info adc0832_info = { .read_raw = adc0832_read_raw, - .driver_module = THIS_MODULE, }; static irqreturn_t adc0832_trigger_handler(int irq, void *p) diff --git a/drivers/iio/adc/ti-adc084s021.c b/drivers/iio/adc/ti-adc084s021.c index a355121c11a4..25504640e126 100644 --- a/drivers/iio/adc/ti-adc084s021.c +++ b/drivers/iio/adc/ti-adc084s021.c @@ -186,7 +186,6 @@ static int adc084s021_buffer_postdisable(struct iio_dev *indio_dev) static const struct iio_info adc084s021_info = { .read_raw = adc084s021_read_raw, - .driver_module = THIS_MODULE, }; static const struct iio_buffer_setup_ops adc084s021_buffer_setup_ops = { diff --git a/drivers/iio/adc/ti-adc108s102.c b/drivers/iio/adc/ti-adc108s102.c index de4e5ac98c6e..841203edaac5 100644 --- a/drivers/iio/adc/ti-adc108s102.c +++ b/drivers/iio/adc/ti-adc108s102.c @@ -220,7 +220,6 @@ static int adc108s102_read_raw(struct iio_dev *indio_dev, static const struct iio_info adc108s102_info = { .read_raw = &adc108s102_read_raw, .update_scan_mode = &adc108s102_update_scan_mode, - .driver_module = THIS_MODULE, }; static int adc108s102_probe(struct spi_device *spi) diff --git a/drivers/iio/adc/ti-adc12138.c b/drivers/iio/adc/ti-adc12138.c index 072f03bfe6a0..bf890244789a 100644 --- a/drivers/iio/adc/ti-adc12138.c +++ b/drivers/iio/adc/ti-adc12138.c @@ -277,7 +277,6 @@ static int adc12138_read_raw(struct iio_dev *iio, static const struct iio_info adc12138_info = { .read_raw = adc12138_read_raw, - .driver_module = THIS_MODULE, }; static int adc12138_init(struct adc12138 *adc) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index 89dfbd31be5c..7cf39b3e2416 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -130,7 +130,6 @@ static const struct adc128_configuration adc128_config[] = { static const struct iio_info adc128_info = { .read_raw = adc128_read_raw, - .driver_module = THIS_MODULE, }; static int adc128_probe(struct spi_device *spi) diff --git a/drivers/iio/adc/ti-adc161s626.c b/drivers/iio/adc/ti-adc161s626.c index 4836a0d7aef5..10fa7677ac4b 100644 --- a/drivers/iio/adc/ti-adc161s626.c +++ b/drivers/iio/adc/ti-adc161s626.c @@ -173,7 +173,6 @@ static int ti_adc_read_raw(struct iio_dev *indio_dev, } static const struct iio_info ti_adc_info = { - .driver_module = THIS_MODULE, .read_raw = ti_adc_read_raw, }; diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index e0dc20488335..6a114dcb4a3a 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -332,7 +332,7 @@ static int ads1015_set_power_state(struct ads1015_data *data, bool on) static int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val) { - int ret, pga, dr, conv_time; + int ret, pga, dr, dr_old, conv_time; unsigned int old, mask, cfg; if (chan < 0 || chan >= ADS1015_CHANNELS) @@ -358,17 +358,17 @@ int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val) } cfg = (old & ~mask) | (cfg & mask); - - ret = regmap_write(data->regmap, ADS1015_CFG_REG, cfg); - if (ret) - return ret; - - if (old != cfg || data->conv_invalid) { - int dr_old = (old & ADS1015_CFG_DR_MASK) >> - ADS1015_CFG_DR_SHIFT; - + if (old != cfg) { + ret = regmap_write(data->regmap, ADS1015_CFG_REG, cfg); + if (ret) + return ret; + data->conv_invalid = true; + } + if (data->conv_invalid) { + dr_old = (old & ADS1015_CFG_DR_MASK) >> ADS1015_CFG_DR_SHIFT; conv_time = DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr_old]); conv_time += DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr]); + conv_time += conv_time / 10; /* 10% internal clock inaccuracy */ usleep_range(conv_time, conv_time + 1); data->conv_invalid = false; } @@ -821,7 +821,6 @@ static const struct attribute_group ads1115_attribute_group = { }; static const struct iio_info ads1015_info = { - .driver_module = THIS_MODULE, .read_raw = ads1015_read_raw, .write_raw = ads1015_write_raw, .read_event_value = ads1015_read_event, @@ -832,7 +831,6 @@ static const struct iio_info ads1015_info = { }; static const struct iio_info ads1115_info = { - .driver_module = THIS_MODULE, .read_raw = ads1015_read_raw, .write_raw = ads1015_write_raw, .read_event_value = ads1015_read_event, diff --git a/drivers/iio/adc/ti-ads7950.c b/drivers/iio/adc/ti-ads7950.c index a376190914ad..0225c1b333ab 100644 --- a/drivers/iio/adc/ti-ads7950.c +++ b/drivers/iio/adc/ti-ads7950.c @@ -372,7 +372,6 @@ static int ti_ads7950_read_raw(struct iio_dev *indio_dev, static const struct iio_info ti_ads7950_info = { .read_raw = &ti_ads7950_read_raw, .update_scan_mode = ti_ads7950_update_scan_mode, - .driver_module = THIS_MODULE, }; static int ti_ads7950_probe(struct spi_device *spi) diff --git a/drivers/iio/adc/ti-ads8688.c b/drivers/iio/adc/ti-ads8688.c index 4a163496d9e4..079f133144b0 100644 --- a/drivers/iio/adc/ti-ads8688.c +++ b/drivers/iio/adc/ti-ads8688.c @@ -369,7 +369,6 @@ static const struct iio_info ads8688_info = { .write_raw = &ads8688_write_raw, .write_raw_get_fmt = &ads8688_write_raw_get_fmt, .attrs = &ads8688_attribute_group, - .driver_module = THIS_MODULE, }; static const struct ads8688_chip_info ads8688_chip_info_tbl[] = { @@ -474,7 +473,6 @@ MODULE_DEVICE_TABLE(of, ads8688_of_match); static struct spi_driver ads8688_driver = { .driver = { .name = "ads8688", - .owner = THIS_MODULE, }, .probe = ads8688_probe, .remove = ads8688_remove, diff --git a/drivers/iio/adc/ti-tlc4541.c b/drivers/iio/adc/ti-tlc4541.c index 78d91a069ea4..2290024c89fc 100644 --- a/drivers/iio/adc/ti-tlc4541.c +++ b/drivers/iio/adc/ti-tlc4541.c @@ -157,7 +157,6 @@ static int tlc4541_read_raw(struct iio_dev *indio_dev, static const struct iio_info tlc4541_info = { .read_raw = &tlc4541_read_raw, - .driver_module = THIS_MODULE, }; static int tlc4541_probe(struct spi_device *spi) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 6cbed7eb118a..b3e573cc6f5f 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -533,7 +533,6 @@ err_unlock: static const struct iio_info tiadc_info = { .read_raw = &tiadc_read_raw, - .driver_module = THIS_MODULE, }; static int tiadc_request_dma(struct platform_device *pdev, diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c index e3cfb91bffc6..8c019bb6625f 100644 --- a/drivers/iio/adc/twl4030-madc.c +++ b/drivers/iio/adc/twl4030-madc.c @@ -212,7 +212,6 @@ static int twl4030_madc_read(struct iio_dev *iio_dev, static const struct iio_info twl4030_madc_iio_info = { .read_raw = &twl4030_madc_read, - .driver_module = THIS_MODULE, }; #define TWL4030_ADC_CHANNEL(_channel, _type, _name) { \ diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c index bc0e60b9da45..dc83f8f6c3d3 100644 --- a/drivers/iio/adc/twl6030-gpadc.c +++ b/drivers/iio/adc/twl6030-gpadc.c @@ -843,7 +843,6 @@ static const struct iio_chan_spec twl6032_gpadc_iio_channels[] = { static const struct iio_info twl6030_gpadc_iio_info = { .read_raw = &twl6030_gpadc_read_raw, - .driver_module = THIS_MODULE, }; static const struct twl6030_gpadc_platform_data twl6030_pdata = { diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index c168e0db329a..bbcb7a4d7edf 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -799,7 +799,6 @@ static int vf610_adc_reg_access(struct iio_dev *indio_dev, } static const struct iio_info vf610_adc_iio_info = { - .driver_module = THIS_MODULE, .read_raw = &vf610_read_raw, .write_raw = &vf610_write_raw, .debugfs_reg_access = &vf610_adc_reg_access, diff --git a/drivers/iio/adc/viperboard_adc.c b/drivers/iio/adc/viperboard_adc.c index 3be2e35721cc..53eb5a4136fe 100644 --- a/drivers/iio/adc/viperboard_adc.c +++ b/drivers/iio/adc/viperboard_adc.c @@ -107,7 +107,6 @@ error: static const struct iio_info vprbrd_adc_iio_info = { .read_raw = &vprbrd_iio_read_raw, - .driver_module = THIS_MODULE, }; static int vprbrd_adc_probe(struct platform_device *pdev) diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c index 4a60497a1f19..d4f21d1be6c8 100644 --- a/drivers/iio/adc/xilinx-xadc-core.c +++ b/drivers/iio/adc/xilinx-xadc-core.c @@ -675,7 +675,6 @@ err_out: } static const struct iio_trigger_ops xadc_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = &xadc_trigger_set_state, }; @@ -1028,7 +1027,6 @@ static const struct iio_info xadc_info = { .read_event_value = &xadc_read_event_value, .write_event_value = &xadc_write_event_value, .update_scan_mode = &xadc_update_scan_mode, - .driver_module = THIS_MODULE, }; static const struct of_device_id xadc_of_match_table[] = { diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c index 102c7174da5b..43667866321e 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -117,7 +117,6 @@ static int ad8366_write_raw(struct iio_dev *indio_dev, static const struct iio_info ad8366_info = { .read_raw = &ad8366_read_raw, .write_raw = &ad8366_write_raw, - .driver_module = THIS_MODULE, }; #define AD8366_CHAN(_channel) { \ diff --git a/drivers/iio/chemical/ams-iaq-core.c b/drivers/iio/chemical/ams-iaq-core.c index c948ad2ee9ad..d9e5950ad24a 100644 --- a/drivers/iio/chemical/ams-iaq-core.c +++ b/drivers/iio/chemical/ams-iaq-core.c @@ -141,7 +141,6 @@ err_out: static const struct iio_info ams_iaqcore_info = { .read_raw = ams_iaqcore_read_raw, - .driver_module = THIS_MODULE, }; static int ams_iaqcore_probe(struct i2c_client *client, diff --git a/drivers/iio/chemical/atlas-ph-sensor.c b/drivers/iio/chemical/atlas-ph-sensor.c index ef761a508630..8c4e05580091 100644 --- a/drivers/iio/chemical/atlas-ph-sensor.c +++ b/drivers/iio/chemical/atlas-ph-sensor.c @@ -344,7 +344,6 @@ static int atlas_buffer_predisable(struct iio_dev *indio_dev) } static const struct iio_trigger_ops atlas_interrupt_trigger_ops = { - .owner = THIS_MODULE, }; static const struct iio_buffer_setup_ops atlas_buffer_setup_ops = { @@ -499,7 +498,6 @@ static int atlas_write_raw(struct iio_dev *indio_dev, } static const struct iio_info atlas_info = { - .driver_module = THIS_MODULE, .read_raw = atlas_read_raw, .write_raw = atlas_write_raw, }; diff --git a/drivers/iio/chemical/ccs811.c b/drivers/iio/chemical/ccs811.c index 840a6cbd5f0f..97bce8345c6a 100644 --- a/drivers/iio/chemical/ccs811.c +++ b/drivers/iio/chemical/ccs811.c @@ -22,6 +22,7 @@ #include <linux/i2c.h> #include <linux/iio/iio.h> #include <linux/iio/buffer.h> +#include <linux/iio/trigger.h> #include <linux/iio/triggered_buffer.h> #include <linux/iio/trigger_consumer.h> #include <linux/module.h> @@ -59,6 +60,8 @@ #define CCS811_MODE_IAQ_60SEC 0x30 #define CCS811_MODE_RAW_DATA 0x40 +#define CCS811_MEAS_MODE_INTERRUPT BIT(3) + #define CCS811_VOLTAGE_MASK 0x3FF struct ccs811_reading { @@ -73,6 +76,8 @@ struct ccs811_data { struct i2c_client *client; struct mutex lock; /* Protect readings */ struct ccs811_reading buffer; + struct iio_trigger *drdy_trig; + bool drdy_trig_on; }; static const struct iio_chan_spec ccs811_channels[] = { @@ -193,10 +198,14 @@ static int ccs811_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; mutex_lock(&data->lock); ret = ccs811_get_measurement(data); if (ret < 0) { mutex_unlock(&data->lock); + iio_device_release_direct_mode(indio_dev); return ret; } @@ -228,6 +237,7 @@ static int ccs811_read_raw(struct iio_dev *indio_dev, ret = -EINVAL; } mutex_unlock(&data->lock); + iio_device_release_direct_mode(indio_dev); return ret; @@ -270,7 +280,31 @@ static int ccs811_read_raw(struct iio_dev *indio_dev, static const struct iio_info ccs811_info = { .read_raw = ccs811_read_raw, - .driver_module = THIS_MODULE, +}; + +static int ccs811_set_trigger_state(struct iio_trigger *trig, + bool state) +{ + struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); + struct ccs811_data *data = iio_priv(indio_dev); + int ret; + + ret = i2c_smbus_read_byte_data(data->client, CCS811_MEAS_MODE); + if (ret < 0) + return ret; + + if (state) + ret |= CCS811_MEAS_MODE_INTERRUPT; + else + ret &= ~CCS811_MEAS_MODE_INTERRUPT; + + data->drdy_trig_on = state; + + return i2c_smbus_write_byte_data(data->client, CCS811_MEAS_MODE, ret); +} + +static const struct iio_trigger_ops ccs811_trigger_ops = { + .set_trigger_state = ccs811_set_trigger_state, }; static irqreturn_t ccs811_trigger_handler(int irq, void *p) @@ -298,6 +332,17 @@ err: return IRQ_HANDLED; } +static irqreturn_t ccs811_data_rdy_trigger_poll(int irq, void *private) +{ + struct iio_dev *indio_dev = private; + struct ccs811_data *data = iio_priv(indio_dev); + + if (data->drdy_trig_on) + iio_trigger_poll(data->drdy_trig); + + return IRQ_HANDLED; +} + static int ccs811_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -346,16 +391,48 @@ static int ccs811_probe(struct i2c_client *client, indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; indio_dev->info = &ccs811_info; + indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ccs811_channels; indio_dev->num_channels = ARRAY_SIZE(ccs811_channels); + if (client->irq > 0) { + ret = devm_request_threaded_irq(&client->dev, client->irq, + ccs811_data_rdy_trigger_poll, + NULL, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + "ccs811_irq", indio_dev); + if (ret) { + dev_err(&client->dev, "irq request error %d\n", -ret); + goto err_poweroff; + } + + data->drdy_trig = devm_iio_trigger_alloc(&client->dev, + "%s-dev%d", + indio_dev->name, + indio_dev->id); + if (!data->drdy_trig) { + ret = -ENOMEM; + goto err_poweroff; + } + + data->drdy_trig->dev.parent = &client->dev; + data->drdy_trig->ops = &ccs811_trigger_ops; + iio_trigger_set_drvdata(data->drdy_trig, indio_dev); + indio_dev->trig = data->drdy_trig; + iio_trigger_get(indio_dev->trig); + ret = iio_trigger_register(data->drdy_trig); + if (ret) + goto err_poweroff; + } + ret = iio_triggered_buffer_setup(indio_dev, NULL, ccs811_trigger_handler, NULL); if (ret < 0) { dev_err(&client->dev, "triggered buffer setup failed\n"); - goto err_poweroff; + goto err_trigger_unregister; } ret = iio_device_register(indio_dev); @@ -367,6 +444,9 @@ static int ccs811_probe(struct i2c_client *client, err_buffer_cleanup: iio_triggered_buffer_cleanup(indio_dev); +err_trigger_unregister: + if (data->drdy_trig) + iio_trigger_unregister(data->drdy_trig); err_poweroff: i2c_smbus_write_byte_data(client, CCS811_MEAS_MODE, CCS811_MODE_IDLE); @@ -376,9 +456,12 @@ err_poweroff: static int ccs811_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct ccs811_data *data = iio_priv(indio_dev); iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); + if (data->drdy_trig) + iio_trigger_unregister(data->drdy_trig); return i2c_smbus_write_byte_data(client, CCS811_MEAS_MODE, CCS811_MODE_IDLE); diff --git a/drivers/iio/chemical/vz89x.c b/drivers/iio/chemical/vz89x.c index f75eea6822f2..9c9095ba4227 100644 --- a/drivers/iio/chemical/vz89x.c +++ b/drivers/iio/chemical/vz89x.c @@ -326,7 +326,6 @@ static int vz89x_read_raw(struct iio_dev *indio_dev, static const struct iio_info vz89x_info = { .attrs = &vz89x_attrs_group, .read_raw = vz89x_read_raw, - .driver_module = THIS_MODULE, }; static const struct vz89x_chip_data vz89x_chips[] = { diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c index 38e8783e4b05..ed8063f2da99 100644 --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c @@ -185,7 +185,6 @@ static int cros_ec_sensors_write(struct iio_dev *indio_dev, static const struct iio_info ec_sensors_info = { .read_raw = &cros_ec_sensors_read, .write_raw = &cros_ec_sensors_write, - .driver_module = THIS_MODULE, }; static int cros_ec_sensors_probe(struct platform_device *pdev) diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c index 0e4b379ada45..55dfd6288d18 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c @@ -243,7 +243,6 @@ void hid_sensor_remove_trigger(struct hid_sensor_common *attrb) EXPORT_SYMBOL(hid_sensor_remove_trigger); static const struct iio_trigger_ops hid_sensor_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = &hid_sensor_data_rdy_trigger_set_state, }; diff --git a/drivers/iio/counter/104-quad-8.c b/drivers/iio/counter/104-quad-8.c index ba3d9030cd51..b56985078d8c 100644 --- a/drivers/iio/counter/104-quad-8.c +++ b/drivers/iio/counter/104-quad-8.c @@ -185,7 +185,6 @@ static int quad8_write_raw(struct iio_dev *indio_dev, } static const struct iio_info quad8_info = { - .driver_module = THIS_MODULE, .read_raw = quad8_read_raw, .write_raw = quad8_write_raw }; diff --git a/drivers/iio/counter/stm32-lptimer-cnt.c b/drivers/iio/counter/stm32-lptimer-cnt.c index 1c5909bb1605..81ae5f74216d 100644 --- a/drivers/iio/counter/stm32-lptimer-cnt.c +++ b/drivers/iio/counter/stm32-lptimer-cnt.c @@ -178,7 +178,6 @@ static int stm32_lptim_read_raw(struct iio_dev *indio_dev, static const struct iio_info stm32_lptim_cnt_iio_info = { .read_raw = stm32_lptim_read_raw, .write_raw = stm32_lptim_write_raw, - .driver_module = THIS_MODULE, }; static const char *const stm32_lptim_quadrature_modes[] = { diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig index 25bed2d7d2b9..e74ab4433a9e 100644 --- a/drivers/iio/dac/Kconfig +++ b/drivers/iio/dac/Kconfig @@ -60,7 +60,8 @@ config AD5446 Say yes here to build support for Analog Devices AD5300, AD5301, AD5310, AD5311, AD5320, AD5321, AD5444, AD5446, AD5450, AD5451, AD5452, AD5453, AD5512A, AD5541A, AD5542A, AD5543, AD5553, AD5601, AD5602, AD5611, AD5612, - AD5620, AD5621, AD5622, AD5640, AD5641, AD5660, AD5662 DACs. + AD5620, AD5621, AD5622, AD5640, AD5641, AD5660, AD5662 DACs + as well as Texas Instruments DAC081S101, DAC101S101, DAC121S101. To compile this driver as a module, choose M here: the module will be called ad5446. diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c index 3f9399c27869..bf4fc40ec84d 100644 --- a/drivers/iio/dac/ad5064.c +++ b/drivers/iio/dac/ad5064.c @@ -366,7 +366,6 @@ static int ad5064_write_raw(struct iio_dev *indio_dev, static const struct iio_info ad5064_info = { .read_raw = ad5064_read_raw, .write_raw = ad5064_write_raw, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec_ext_info ad5064_ext_info[] = { diff --git a/drivers/iio/dac/ad5360.c b/drivers/iio/dac/ad5360.c index 8ba0e9c50176..0209316d5566 100644 --- a/drivers/iio/dac/ad5360.c +++ b/drivers/iio/dac/ad5360.c @@ -425,7 +425,6 @@ static const struct iio_info ad5360_info = { .read_raw = ad5360_read_raw, .write_raw = ad5360_write_raw, .attrs = &ad5360_attribute_group, - .driver_module = THIS_MODULE, }; static const char * const ad5360_vref_name[] = { diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c index 97d2c5111f43..845fd1c0fd9d 100644 --- a/drivers/iio/dac/ad5380.c +++ b/drivers/iio/dac/ad5380.c @@ -237,7 +237,6 @@ static int ad5380_read_raw(struct iio_dev *indio_dev, static const struct iio_info ad5380_info = { .read_raw = ad5380_read_raw, .write_raw = ad5380_write_raw, - .driver_module = THIS_MODULE, }; static struct iio_chan_spec_ext_info ad5380_ext_info[] = { diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c index 559061ab1982..8e9633d8de67 100644 --- a/drivers/iio/dac/ad5421.c +++ b/drivers/iio/dac/ad5421.c @@ -465,7 +465,6 @@ static const struct iio_info ad5421_info = { .read_event_config = ad5421_read_event_config, .write_event_config = ad5421_write_event_config, .read_event_value = ad5421_read_event_value, - .driver_module = THIS_MODULE, }; static int ad5421_probe(struct spi_device *spi) diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c index b555552a0d80..fd26a4272fc5 100644 --- a/drivers/iio/dac/ad5446.c +++ b/drivers/iio/dac/ad5446.c @@ -212,7 +212,6 @@ static int ad5446_write_raw(struct iio_dev *indio_dev, static const struct iio_info ad5446_info = { .read_raw = ad5446_read_raw, .write_raw = ad5446_write_raw, - .driver_module = THIS_MODULE, }; static int ad5446_probe(struct device *dev, const char *name, @@ -461,10 +460,22 @@ static const struct spi_device_id ad5446_spi_ids[] = { {"ad5660-2500", ID_AD5660_2500}, {"ad5660-1250", ID_AD5660_1250}, {"ad5662", ID_AD5662}, + {"dac081s101", ID_AD5300}, /* compatible Texas Instruments chips */ + {"dac101s101", ID_AD5310}, + {"dac121s101", ID_AD5320}, + {"dac7512", ID_AD5320}, {} }; MODULE_DEVICE_TABLE(spi, ad5446_spi_ids); +#ifdef CONFIG_OF +static const struct of_device_id ad5446_of_ids[] = { + { .compatible = "ti,dac7512" }, + { } +}; +MODULE_DEVICE_TABLE(of, ad5446_of_ids); +#endif + static int ad5446_spi_probe(struct spi_device *spi) { const struct spi_device_id *id = spi_get_device_id(spi); @@ -481,6 +492,7 @@ static int ad5446_spi_remove(struct spi_device *spi) static struct spi_driver ad5446_spi_driver = { .driver = { .name = "ad5446", + .of_match_table = of_match_ptr(ad5446_of_ids), }, .probe = ad5446_spi_probe, .remove = ad5446_spi_remove, diff --git a/drivers/iio/dac/ad5449.c b/drivers/iio/dac/ad5449.c index 5f3202339420..317a74129932 100644 --- a/drivers/iio/dac/ad5449.c +++ b/drivers/iio/dac/ad5449.c @@ -193,7 +193,6 @@ static int ad5449_write_raw(struct iio_dev *indio_dev, static const struct iio_info ad5449_info = { .read_raw = ad5449_read_raw, .write_raw = ad5449_write_raw, - .driver_module = THIS_MODULE, }; #define AD5449_CHANNEL(chan, bits) { \ diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c index 712d86b4be09..d9037ea59168 100644 --- a/drivers/iio/dac/ad5504.c +++ b/drivers/iio/dac/ad5504.c @@ -232,7 +232,6 @@ static const struct iio_info ad5504_info = { .write_raw = ad5504_write_raw, .read_raw = ad5504_read_raw, .event_attrs = &ad5504_ev_attribute_group, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec_ext_info ad5504_ext_info[] = { diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c index 69bde5909854..9234c6a09a93 100644 --- a/drivers/iio/dac/ad5592r-base.c +++ b/drivers/iio/dac/ad5592r-base.c @@ -474,7 +474,6 @@ static const struct iio_info ad5592r_info = { .read_raw = ad5592r_read_raw, .write_raw = ad5592r_write_raw, .write_raw_get_fmt = ad5592r_write_raw_get_fmt, - .driver_module = THIS_MODULE, }; static ssize_t ad5592r_show_scale_available(struct iio_dev *iio_dev, diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c index 5489ec43b95d..13fdb4dfe356 100644 --- a/drivers/iio/dac/ad5624r_spi.c +++ b/drivers/iio/dac/ad5624r_spi.c @@ -149,7 +149,6 @@ static ssize_t ad5624r_write_dac_powerdown(struct iio_dev *indio_dev, static const struct iio_info ad5624r_info = { .write_raw = ad5624r_write_raw, .read_raw = ad5624r_read_raw, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec_ext_info ad5624r_ext_info[] = { diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index d1d8450c19f6..20254df7f9c7 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -252,7 +252,6 @@ static int ad5686_write_raw(struct iio_dev *indio_dev, static const struct iio_info ad5686_info = { .read_raw = ad5686_read_raw, .write_raw = ad5686_write_raw, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec_ext_info ad5686_ext_info[] = { diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c index 5f7968232564..2d03cc89ba50 100644 --- a/drivers/iio/dac/ad5755.c +++ b/drivers/iio/dac/ad5755.c @@ -417,7 +417,6 @@ static ssize_t ad5755_write_powerdown(struct iio_dev *indio_dev, uintptr_t priv, static const struct iio_info ad5755_info = { .read_raw = ad5755_read_raw, .write_raw = ad5755_write_raw, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec_ext_info ad5755_ext_info[] = { diff --git a/drivers/iio/dac/ad5761.c b/drivers/iio/dac/ad5761.c index d6510d6928b3..05017c8bbd00 100644 --- a/drivers/iio/dac/ad5761.c +++ b/drivers/iio/dac/ad5761.c @@ -251,7 +251,6 @@ static int ad5761_write_raw(struct iio_dev *indio_dev, static const struct iio_info ad5761_info = { .read_raw = &ad5761_read_raw, .write_raw = &ad5761_write_raw, - .driver_module = THIS_MODULE, }; #define AD5761_CHAN(_bits) { \ diff --git a/drivers/iio/dac/ad5764.c b/drivers/iio/dac/ad5764.c index 9a547bbf7d2b..033f20eca616 100644 --- a/drivers/iio/dac/ad5764.c +++ b/drivers/iio/dac/ad5764.c @@ -268,7 +268,6 @@ static int ad5764_read_raw(struct iio_dev *indio_dev, static const struct iio_info ad5764_info = { .read_raw = ad5764_read_raw, .write_raw = ad5764_write_raw, - .driver_module = THIS_MODULE, }; static int ad5764_probe(struct spi_device *spi) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index 33e4ae5c42f8..7569bf6868c2 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -340,7 +340,6 @@ static int ad5791_write_raw(struct iio_dev *indio_dev, static const struct iio_info ad5791_info = { .read_raw = &ad5791_read_raw, .write_raw = &ad5791_write_raw, - .driver_module = THIS_MODULE, }; static int ad5791_probe(struct spi_device *spi) diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c index 4b0f942b8914..8f3bd19b6dc3 100644 --- a/drivers/iio/dac/ad7303.c +++ b/drivers/iio/dac/ad7303.c @@ -161,7 +161,6 @@ static int ad7303_write_raw(struct iio_dev *indio_dev, static const struct iio_info ad7303_info = { .read_raw = ad7303_read_raw, .write_raw = ad7303_write_raw, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec_ext_info ad7303_ext_info[] = { diff --git a/drivers/iio/dac/ad8801.c b/drivers/iio/dac/ad8801.c index f06faa1aec09..aef5808c9865 100644 --- a/drivers/iio/dac/ad8801.c +++ b/drivers/iio/dac/ad8801.c @@ -92,7 +92,6 @@ static int ad8801_read_raw(struct iio_dev *indio_dev, static const struct iio_info ad8801_info = { .read_raw = ad8801_read_raw, .write_raw = ad8801_write_raw, - .driver_module = THIS_MODULE, }; #define AD8801_CHANNEL(chan) { \ diff --git a/drivers/iio/dac/cio-dac.c b/drivers/iio/dac/cio-dac.c index a8dffd938615..6898b0c79013 100644 --- a/drivers/iio/dac/cio-dac.c +++ b/drivers/iio/dac/cio-dac.c @@ -85,7 +85,6 @@ static int cio_dac_write_raw(struct iio_dev *indio_dev, } static const struct iio_info cio_dac_info = { - .driver_module = THIS_MODULE, .read_raw = cio_dac_read_raw, .write_raw = cio_dac_write_raw }; diff --git a/drivers/iio/dac/dpot-dac.c b/drivers/iio/dac/dpot-dac.c index 960a2b430480..aaa2103d7c2b 100644 --- a/drivers/iio/dac/dpot-dac.c +++ b/drivers/iio/dac/dpot-dac.c @@ -128,7 +128,6 @@ static const struct iio_info dpot_dac_info = { .read_raw = dpot_dac_read_raw, .read_avail = dpot_dac_read_avail, .write_raw = dpot_dac_write_raw, - .driver_module = THIS_MODULE, }; static int dpot_dac_channel_max_ohms(struct iio_dev *indio_dev) diff --git a/drivers/iio/dac/lpc18xx_dac.c b/drivers/iio/dac/lpc18xx_dac.c index 55d1456a059d..7036f77fdf23 100644 --- a/drivers/iio/dac/lpc18xx_dac.c +++ b/drivers/iio/dac/lpc18xx_dac.c @@ -103,7 +103,6 @@ static int lpc18xx_dac_write_raw(struct iio_dev *indio_dev, static const struct iio_info lpc18xx_dac_info = { .read_raw = lpc18xx_dac_read_raw, .write_raw = lpc18xx_dac_write_raw, - .driver_module = THIS_MODULE, }; static int lpc18xx_dac_probe(struct platform_device *pdev) diff --git a/drivers/iio/dac/ltc2632.c b/drivers/iio/dac/ltc2632.c index ac5e05f6eb8b..af2ddd0dd341 100644 --- a/drivers/iio/dac/ltc2632.c +++ b/drivers/iio/dac/ltc2632.c @@ -159,7 +159,6 @@ static ssize_t ltc2632_write_dac_powerdown(struct iio_dev *indio_dev, static const struct iio_info ltc2632_info = { .write_raw = ltc2632_write_raw, .read_raw = ltc2632_read_raw, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec_ext_info ltc2632_ext_info[] = { diff --git a/drivers/iio/dac/m62332.c b/drivers/iio/dac/m62332.c index 76e8b044b979..19031943dabe 100644 --- a/drivers/iio/dac/m62332.c +++ b/drivers/iio/dac/m62332.c @@ -174,7 +174,6 @@ static SIMPLE_DEV_PM_OPS(m62332_pm_ops, m62332_suspend, m62332_resume); static const struct iio_info m62332_info = { .read_raw = m62332_read_raw, .write_raw = m62332_write_raw, - .driver_module = THIS_MODULE, }; #define M62332_CHANNEL(chan) { \ diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c index 5507b3970b4b..1d853247a205 100644 --- a/drivers/iio/dac/max517.c +++ b/drivers/iio/dac/max517.c @@ -137,7 +137,6 @@ static SIMPLE_DEV_PM_OPS(max517_pm_ops, max517_suspend, max517_resume); static const struct iio_info max517_info = { .read_raw = max517_read_raw, .write_raw = max517_write_raw, - .driver_module = THIS_MODULE, }; #define MAX517_CHANNEL(chan) { \ diff --git a/drivers/iio/dac/max5821.c b/drivers/iio/dac/max5821.c index 193fac3059a3..d0ecc1fdd8fc 100644 --- a/drivers/iio/dac/max5821.c +++ b/drivers/iio/dac/max5821.c @@ -300,7 +300,6 @@ static SIMPLE_DEV_PM_OPS(max5821_pm_ops, max5821_suspend, max5821_resume); static const struct iio_info max5821_info = { .read_raw = max5821_read_raw, .write_raw = max5821_write_raw, - .driver_module = THIS_MODULE, }; static int max5821_probe(struct i2c_client *client, diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c index 6ab1f23e5a79..afa856d10c26 100644 --- a/drivers/iio/dac/mcp4725.c +++ b/drivers/iio/dac/mcp4725.c @@ -363,7 +363,6 @@ static const struct iio_info mcp4725_info = { .read_raw = mcp4725_read_raw, .write_raw = mcp4725_write_raw, .attrs = &mcp4725_attribute_group, - .driver_module = THIS_MODULE, }; #ifdef CONFIG_OF diff --git a/drivers/iio/dac/mcp4922.c b/drivers/iio/dac/mcp4922.c index 3854d201a5d6..bf9aa3fc0534 100644 --- a/drivers/iio/dac/mcp4922.c +++ b/drivers/iio/dac/mcp4922.c @@ -119,7 +119,6 @@ static const struct iio_chan_spec mcp4922_channels[3][MCP4922_NUM_CHANNELS] = { static const struct iio_info mcp4922_info = { .read_raw = &mcp4922_read_raw, .write_raw = &mcp4922_write_raw, - .driver_module = THIS_MODULE, }; static int mcp4922_probe(struct spi_device *spi) diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c index c1864e8aa851..9ffab02bf9f9 100644 --- a/drivers/iio/dac/stm32-dac.c +++ b/drivers/iio/dac/stm32-dac.c @@ -156,7 +156,6 @@ static const struct iio_info stm32_dac_iio_info = { .read_raw = stm32_dac_read_raw, .write_raw = stm32_dac_write_raw, .debugfs_reg_access = stm32_dac_debugfs_reg_access, - .driver_module = THIS_MODULE, }; static const char * const stm32_dac_powerdown_modes[] = { diff --git a/drivers/iio/dac/vf610_dac.c b/drivers/iio/dac/vf610_dac.c index c4ec7779b394..5dccdd16cab3 100644 --- a/drivers/iio/dac/vf610_dac.c +++ b/drivers/iio/dac/vf610_dac.c @@ -167,7 +167,6 @@ static int vf610_write_raw(struct iio_dev *indio_dev, } static const struct iio_info vf610_dac_iio_info = { - .driver_module = THIS_MODULE, .read_raw = &vf610_read_raw, .write_raw = &vf610_write_raw, }; diff --git a/drivers/iio/dummy/iio_simple_dummy.c b/drivers/iio/dummy/iio_simple_dummy.c index ad3410e528b6..a45d01e9b8e8 100644 --- a/drivers/iio/dummy/iio_simple_dummy.c +++ b/drivers/iio/dummy/iio_simple_dummy.c @@ -519,7 +519,6 @@ static int iio_dummy_write_raw(struct iio_dev *indio_dev, * Device type specific information. */ static const struct iio_info iio_dummy_info = { - .driver_module = THIS_MODULE, .read_raw = &iio_dummy_read_raw, .write_raw = &iio_dummy_write_raw, #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index 99eba524f6dd..ddb6a334ae68 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c @@ -738,7 +738,6 @@ static const struct iio_info ad9523_info = { .write_raw = &ad9523_write_raw, .debugfs_reg_access = &ad9523_reg_access, .attrs = &ad9523_attribute_group, - .driver_module = THIS_MODULE, }; static int ad9523_setup(struct iio_dev *indio_dev) diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c index d2d824b446f5..6d768431d90e 100644 --- a/drivers/iio/frequency/adf4350.c +++ b/drivers/iio/frequency/adf4350.c @@ -374,7 +374,6 @@ static const struct iio_chan_spec adf4350_chan = { static const struct iio_info adf4350_info = { .debugfs_reg_access = &adf4350_reg_access, - .driver_module = THIS_MODULE, }; #ifdef CONFIG_OF diff --git a/drivers/iio/gyro/adis16080.c b/drivers/iio/gyro/adis16080.c index ad31a1372a04..a551ebde4762 100644 --- a/drivers/iio/gyro/adis16080.c +++ b/drivers/iio/gyro/adis16080.c @@ -163,7 +163,6 @@ static const struct iio_chan_spec adis16080_channels[] = { static const struct iio_info adis16080_info = { .read_raw = &adis16080_read_raw, - .driver_module = THIS_MODULE, }; enum { diff --git a/drivers/iio/gyro/adis16130.c b/drivers/iio/gyro/adis16130.c index e5241f41e65e..aea80ab04122 100644 --- a/drivers/iio/gyro/adis16130.c +++ b/drivers/iio/gyro/adis16130.c @@ -137,7 +137,6 @@ static const struct iio_chan_spec adis16130_channels[] = { static const struct iio_info adis16130_info = { .read_raw = &adis16130_read_raw, - .driver_module = THIS_MODULE, }; static int adis16130_probe(struct spi_device *spi) diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c index b04faf93e1bc..90ec4bed62b7 100644 --- a/drivers/iio/gyro/adis16136.c +++ b/drivers/iio/gyro/adis16136.c @@ -398,7 +398,6 @@ static const struct attribute_group adis16136_attribute_group = { }; static const struct iio_info adis16136_info = { - .driver_module = THIS_MODULE, .attrs = &adis16136_attribute_group, .read_raw = &adis16136_read_raw, .write_raw = &adis16136_write_raw, diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c index 7da8825f4791..a8cb1ca349d9 100644 --- a/drivers/iio/gyro/adis16260.c +++ b/drivers/iio/gyro/adis16260.c @@ -321,7 +321,6 @@ static const struct iio_info adis16260_info = { .read_raw = &adis16260_read_raw, .write_raw = &adis16260_write_raw, .update_scan_mode = adis_update_scan_mode, - .driver_module = THIS_MODULE, }; static const char * const adis1620_status_error_msgs[] = { diff --git a/drivers/iio/gyro/adxrs450.c b/drivers/iio/gyro/adxrs450.c index a330d4288bb0..5d39fd008378 100644 --- a/drivers/iio/gyro/adxrs450.c +++ b/drivers/iio/gyro/adxrs450.c @@ -405,7 +405,6 @@ static const struct iio_chan_spec adxrs450_channels[2][2] = { }; static const struct iio_info adxrs450_info = { - .driver_module = THIS_MODULE, .read_raw = &adxrs450_read_raw, .write_raw = &adxrs450_write_raw, }; diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index 821919dd245b..15046172e437 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c @@ -858,7 +858,6 @@ static const struct iio_info bmg160_info = { .write_event_value = bmg160_write_event, .write_event_config = bmg160_write_event_config, .read_event_config = bmg160_read_event_config, - .driver_module = THIS_MODULE, }; static const unsigned long bmg160_accel_scan_masks[] = { @@ -956,7 +955,6 @@ static int bmg160_data_rdy_trigger_set_state(struct iio_trigger *trig, static const struct iio_trigger_ops bmg160_trigger_ops = { .set_trigger_state = bmg160_data_rdy_trigger_set_state, .try_reenable = bmg160_trig_try_reen, - .owner = THIS_MODULE, }; static irqreturn_t bmg160_event_handler(int irq, void *private) diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index c67ce2ac4715..f59995a90387 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c @@ -186,7 +186,6 @@ static int gyro_3d_write_raw(struct iio_dev *indio_dev, } static const struct iio_info gyro_3d_info = { - .driver_module = THIS_MODULE, .read_raw = &gyro_3d_read_raw, .write_raw = &gyro_3d_write_raw, }; diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c index eef50e91f17c..59770e5b6660 100644 --- a/drivers/iio/gyro/itg3200_buffer.c +++ b/drivers/iio/gyro/itg3200_buffer.c @@ -101,7 +101,6 @@ error_ret: } static const struct iio_trigger_ops itg3200_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = &itg3200_data_rdy_trigger_set_state, }; diff --git a/drivers/iio/gyro/itg3200_core.c b/drivers/iio/gyro/itg3200_core.c index cfa2db04a8ab..7adecb562c81 100644 --- a/drivers/iio/gyro/itg3200_core.c +++ b/drivers/iio/gyro/itg3200_core.c @@ -278,7 +278,6 @@ static const struct iio_chan_spec itg3200_channels[] = { static const struct iio_info itg3200_info = { .read_raw = &itg3200_read_raw, .write_raw = &itg3200_write_raw, - .driver_module = THIS_MODULE, }; static const unsigned long itg3200_available_scan_masks[] = { 0xffffffff, 0x0 }; diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c index e0d241a9aa30..77fac81a3adc 100644 --- a/drivers/iio/gyro/mpu3050-core.c +++ b/drivers/iio/gyro/mpu3050-core.c @@ -742,7 +742,6 @@ static const struct attribute_group mpu3050_attribute_group = { }; static const struct iio_info mpu3050_info = { - .driver_module = THIS_MODULE, .read_raw = mpu3050_read_raw, .write_raw = mpu3050_write_raw, .attrs = &mpu3050_attribute_group, @@ -1032,7 +1031,6 @@ static int mpu3050_drdy_trigger_set_state(struct iio_trigger *trig, } static const struct iio_trigger_ops mpu3050_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = mpu3050_drdy_trigger_set_state, }; diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index e366422e8512..4cf85aa01dde 100644 --- a/drivers/iio/gyro/st_gyro_core.c +++ b/drivers/iio/gyro/st_gyro_core.c @@ -326,7 +326,6 @@ static const struct attribute_group st_gyro_attribute_group = { }; static const struct iio_info gyro_info = { - .driver_module = THIS_MODULE, .attrs = &st_gyro_attribute_group, .read_raw = &st_gyro_read_raw, .write_raw = &st_gyro_write_raw, @@ -335,7 +334,6 @@ static const struct iio_info gyro_info = { #ifdef CONFIG_IIO_TRIGGER static const struct iio_trigger_ops st_gyro_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = ST_GYRO_TRIGGER_SET_STATE, .validate_device = st_sensors_validate_device, }; diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index 6bb23a49e81e..a739fff01c6b 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -309,7 +309,6 @@ static const struct iio_info afe4403_iio_info = { .attrs = &afe440x_attribute_group, .read_raw = afe4403_read_raw, .write_raw = afe4403_write_raw, - .driver_module = THIS_MODULE, }; static irqreturn_t afe4403_trigger_handler(int irq, void *private) @@ -354,7 +353,6 @@ err: } static const struct iio_trigger_ops afe4403_trigger_ops = { - .owner = THIS_MODULE, }; #define AFE4403_TIMING_PAIRS \ diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index 964f5231a831..11910922e655 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -328,7 +328,6 @@ static const struct iio_info afe4404_iio_info = { .attrs = &afe440x_attribute_group, .read_raw = afe4404_read_raw, .write_raw = afe4404_write_raw, - .driver_module = THIS_MODULE, }; static irqreturn_t afe4404_trigger_handler(int irq, void *private) @@ -355,7 +354,6 @@ err: } static const struct iio_trigger_ops afe4404_trigger_ops = { - .owner = THIS_MODULE, }; /* Default timings from data-sheet */ diff --git a/drivers/iio/health/max30100.c b/drivers/iio/health/max30100.c index 849d71747f9f..91aef5df24a1 100644 --- a/drivers/iio/health/max30100.c +++ b/drivers/iio/health/max30100.c @@ -420,7 +420,6 @@ static int max30100_read_raw(struct iio_dev *indio_dev, } static const struct iio_info max30100_info = { - .driver_module = THIS_MODULE, .read_raw = max30100_read_raw, }; diff --git a/drivers/iio/health/max30102.c b/drivers/iio/health/max30102.c index 839b875c29b9..203ffb9cad6a 100644 --- a/drivers/iio/health/max30102.c +++ b/drivers/iio/health/max30102.c @@ -381,7 +381,6 @@ static int max30102_read_raw(struct iio_dev *indio_dev, } static const struct iio_info max30102_info = { - .driver_module = THIS_MODULE, .read_raw = max30102_read_raw, }; diff --git a/drivers/iio/humidity/am2315.c b/drivers/iio/humidity/am2315.c index ff96b6d0fdae..7d8669dc6547 100644 --- a/drivers/iio/humidity/am2315.c +++ b/drivers/iio/humidity/am2315.c @@ -215,7 +215,6 @@ static int am2315_read_raw(struct iio_dev *indio_dev, } static const struct iio_info am2315_info = { - .driver_module = THIS_MODULE, .read_raw = am2315_read_raw, }; diff --git a/drivers/iio/humidity/dht11.c b/drivers/iio/humidity/dht11.c index 2a22ad920333..df6bab40d6fa 100644 --- a/drivers/iio/humidity/dht11.c +++ b/drivers/iio/humidity/dht11.c @@ -284,7 +284,6 @@ err: } static const struct iio_info dht11_iio_info = { - .driver_module = THIS_MODULE, .read_raw = dht11_read_raw, }; diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c index 7851bd90ef64..d8438310b6d4 100644 --- a/drivers/iio/humidity/hdc100x.c +++ b/drivers/iio/humidity/hdc100x.c @@ -357,7 +357,6 @@ static const struct iio_info hdc100x_info = { .read_raw = hdc100x_read_raw, .write_raw = hdc100x_write_raw, .attrs = &hdc100x_attribute_group, - .driver_module = THIS_MODULE, }; static int hdc100x_probe(struct i2c_client *client, diff --git a/drivers/iio/humidity/hid-sensor-humidity.c b/drivers/iio/humidity/hid-sensor-humidity.c index 6e09c1acfe51..beab6d6fd6e1 100644 --- a/drivers/iio/humidity/hid-sensor-humidity.c +++ b/drivers/iio/humidity/hid-sensor-humidity.c @@ -125,7 +125,6 @@ static int humidity_write_raw(struct iio_dev *indio_dev, } static const struct iio_info humidity_info = { - .driver_module = THIS_MODULE, .read_raw = &humidity_read_raw, .write_raw = &humidity_write_raw, }; diff --git a/drivers/iio/humidity/hts221_buffer.c b/drivers/iio/humidity/hts221_buffer.c index 9690dfe9a844..e971ea425268 100644 --- a/drivers/iio/humidity/hts221_buffer.c +++ b/drivers/iio/humidity/hts221_buffer.c @@ -47,7 +47,6 @@ static int hts221_trig_set_state(struct iio_trigger *trig, bool state) } static const struct iio_trigger_ops hts221_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = hts221_trig_set_state, }; diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c index 32524a8dc66f..daef177219b6 100644 --- a/drivers/iio/humidity/hts221_core.c +++ b/drivers/iio/humidity/hts221_core.c @@ -573,7 +573,6 @@ static const struct attribute_group hts221_attribute_group = { }; static const struct iio_info hts221_info = { - .driver_module = THIS_MODULE, .attrs = &hts221_attribute_group, .read_raw = hts221_read_raw, .write_raw = hts221_write_raw, diff --git a/drivers/iio/humidity/htu21.c b/drivers/iio/humidity/htu21.c index 2c4b9be85a05..f5a2701ba6dd 100644 --- a/drivers/iio/humidity/htu21.c +++ b/drivers/iio/humidity/htu21.c @@ -175,7 +175,6 @@ static const struct iio_info htu21_info = { .read_raw = htu21_read_raw, .write_raw = htu21_write_raw, .attrs = &htu21_attribute_group, - .driver_module = THIS_MODULE, }; static int htu21_probe(struct i2c_client *client, diff --git a/drivers/iio/humidity/si7005.c b/drivers/iio/humidity/si7005.c index 6297766e93d0..1fd19f035a5d 100644 --- a/drivers/iio/humidity/si7005.c +++ b/drivers/iio/humidity/si7005.c @@ -124,7 +124,6 @@ static const struct iio_chan_spec si7005_channels[] = { static const struct iio_info si7005_info = { .read_raw = si7005_read_raw, - .driver_module = THIS_MODULE, }; static int si7005_probe(struct i2c_client *client, diff --git a/drivers/iio/humidity/si7020.c b/drivers/iio/humidity/si7020.c index 345a7656c5ef..1b2ec8df1a72 100644 --- a/drivers/iio/humidity/si7020.c +++ b/drivers/iio/humidity/si7020.c @@ -108,7 +108,6 @@ static const struct iio_chan_spec si7020_channels[] = { static const struct iio_info si7020_info = { .read_raw = si7020_read_raw, - .driver_module = THIS_MODULE, }; static int si7020_probe(struct i2c_client *client, diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c index 9b697d35dbef..46a569005a13 100644 --- a/drivers/iio/imu/adis16400_core.c +++ b/drivers/iio/imu/adis16400_core.c @@ -833,7 +833,6 @@ static struct adis16400_chip_info adis16400_chips[] = { }; static const struct iio_info adis16400_info = { - .driver_module = THIS_MODULE, .read_raw = &adis16400_read_raw, .write_raw = &adis16400_write_raw, .update_scan_mode = adis16400_update_scan_mode, diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c index 12898424d838..7a33d6bd60e0 100644 --- a/drivers/iio/imu/adis16480.c +++ b/drivers/iio/imu/adis16480.c @@ -720,7 +720,6 @@ static const struct iio_info adis16480_info = { .read_raw = &adis16480_read_raw, .write_raw = &adis16480_write_raw, .update_scan_mode = adis_update_scan_mode, - .driver_module = THIS_MODULE, }; static int adis16480_stop_device(struct iio_dev *indio_dev) diff --git a/drivers/iio/imu/adis_trigger.c b/drivers/iio/imu/adis_trigger.c index f53e9a803a0e..0dd5a381be64 100644 --- a/drivers/iio/imu/adis_trigger.c +++ b/drivers/iio/imu/adis_trigger.c @@ -25,7 +25,6 @@ static int adis_data_rdy_trigger_set_state(struct iio_trigger *trig, } static const struct iio_trigger_ops adis_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = &adis_data_rdy_trigger_set_state, }; diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c index cfd225ed1c8d..c85659ca9507 100644 --- a/drivers/iio/imu/bmi160/bmi160_core.c +++ b/drivers/iio/imu/bmi160/bmi160_core.c @@ -482,7 +482,6 @@ static const struct attribute_group bmi160_attrs_group = { }; static const struct iio_info bmi160_info = { - .driver_module = THIS_MODULE, .read_raw = bmi160_read_raw, .write_raw = bmi160_write_raw, .attrs = &bmi160_attrs_group, diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 44830bce13df..7d64be353403 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -542,7 +542,9 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev, break; default: result = -EINVAL; + break; } + break; default: result = -EINVAL; break; @@ -570,10 +572,12 @@ error_write_raw_unlock: */ static int inv_mpu6050_set_lpf(struct inv_mpu6050_state *st, int rate) { - const int hz[] = {188, 98, 42, 20, 10, 5}; - const int d[] = {INV_MPU6050_FILTER_188HZ, INV_MPU6050_FILTER_98HZ, - INV_MPU6050_FILTER_42HZ, INV_MPU6050_FILTER_20HZ, - INV_MPU6050_FILTER_10HZ, INV_MPU6050_FILTER_5HZ}; + static const int hz[] = {188, 98, 42, 20, 10, 5}; + static const int d[] = { + INV_MPU6050_FILTER_188HZ, INV_MPU6050_FILTER_98HZ, + INV_MPU6050_FILTER_42HZ, INV_MPU6050_FILTER_20HZ, + INV_MPU6050_FILTER_10HZ, INV_MPU6050_FILTER_5HZ + }; int i, h, result; u8 data; @@ -795,7 +799,6 @@ static const struct attribute_group inv_attribute_group = { }; static const struct iio_info mpu_info = { - .driver_module = THIS_MODULE, .read_raw = &inv_mpu6050_read_raw, .write_raw = &inv_mpu6050_write_raw, .write_raw_get_fmt = &inv_write_raw_get_fmt, diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c index 540070f0a230..f963f9fc98c0 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c @@ -114,7 +114,6 @@ static int inv_mpu_data_rdy_trigger_set_state(struct iio_trigger *trig, } static const struct iio_trigger_ops inv_mpu_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = &inv_mpu_data_rdy_trigger_set_state, }; diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c index 2e7dd5754a56..44b3f5397343 100644 --- a/drivers/iio/imu/kmx61.c +++ b/drivers/iio/imu/kmx61.c @@ -1003,7 +1003,6 @@ static int kmx61_mag_validate_trigger(struct iio_dev *indio_dev, } static const struct iio_info kmx61_acc_info = { - .driver_module = THIS_MODULE, .read_raw = kmx61_read_raw, .write_raw = kmx61_write_raw, .attrs = &kmx61_acc_attribute_group, @@ -1015,7 +1014,6 @@ static const struct iio_info kmx61_acc_info = { }; static const struct iio_info kmx61_mag_info = { - .driver_module = THIS_MODULE, .read_raw = kmx61_read_raw, .write_raw = kmx61_write_raw, .attrs = &kmx61_mag_attribute_group, @@ -1087,7 +1085,6 @@ static int kmx61_trig_try_reenable(struct iio_trigger *trig) static const struct iio_trigger_ops kmx61_trigger_ops = { .set_trigger_state = kmx61_data_rdy_trigger_set_state, .try_reenable = kmx61_trig_try_reenable, - .owner = THIS_MODULE, }; static irqreturn_t kmx61_event_handler(int irq, void *private) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index b485540da89e..debf4064f474 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -54,10 +54,6 @@ #define ST_LSM6DSX_REG_BDU_MASK BIT(6) #define ST_LSM6DSX_REG_INT2_ON_INT1_ADDR 0x13 #define ST_LSM6DSX_REG_INT2_ON_INT1_MASK BIT(5) -#define ST_LSM6DSX_REG_ROUNDING_ADDR 0x16 -#define ST_LSM6DSX_REG_ROUNDING_MASK BIT(2) -#define ST_LSM6DSX_REG_LIR_ADDR 0x58 -#define ST_LSM6DSX_REG_LIR_MASK BIT(0) #define ST_LSM6DSX_REG_ACC_ODR_ADDR 0x10 #define ST_LSM6DSX_REG_ACC_ODR_MASK GENMASK(7, 4) @@ -322,7 +318,6 @@ static int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u16 odr, return -EINVAL; *val = st_lsm6dsx_odr_table[sensor->id].odr_avl[i].val; - sensor->odr = odr; return 0; } @@ -449,6 +444,8 @@ static int st_lsm6dsx_write_raw(struct iio_dev *iio_dev, u8 data; err = st_lsm6dsx_check_odr(sensor, val, &data); + if (!err) + sensor->odr = val; break; } default: @@ -530,7 +527,6 @@ static const struct attribute_group st_lsm6dsx_acc_attribute_group = { }; static const struct iio_info st_lsm6dsx_acc_info = { - .driver_module = THIS_MODULE, .attrs = &st_lsm6dsx_acc_attribute_group, .read_raw = st_lsm6dsx_read_raw, .write_raw = st_lsm6dsx_write_raw, @@ -548,7 +544,6 @@ static const struct attribute_group st_lsm6dsx_gyro_attribute_group = { }; static const struct iio_info st_lsm6dsx_gyro_info = { - .driver_module = THIS_MODULE, .attrs = &st_lsm6dsx_gyro_attribute_group, .read_raw = st_lsm6dsx_read_raw, .write_raw = st_lsm6dsx_write_raw, @@ -608,23 +603,12 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw) msleep(200); - /* latch interrupts */ - err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_LIR_ADDR, - ST_LSM6DSX_REG_LIR_MASK, 1); - if (err < 0) - return err; - /* enable Block Data Update */ err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_BDU_ADDR, ST_LSM6DSX_REG_BDU_MASK, 1); if (err < 0) return err; - err = st_lsm6dsx_write_with_mask(hw, ST_LSM6DSX_REG_ROUNDING_ADDR, - ST_LSM6DSX_REG_ROUNDING_MASK, 1); - if (err < 0) - return err; - /* enable FIFO watermak interrupt */ err = st_lsm6dsx_get_drdy_reg(hw, &drdy_int_reg); if (err < 0) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index a47428b4d31b..9c4cfd19b739 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1662,14 +1662,11 @@ static int iio_check_unique_scan_index(struct iio_dev *indio_dev) static const struct iio_buffer_setup_ops noop_ring_setup_ops; -/** - * iio_device_register() - register a device with the IIO subsystem - * @indio_dev: Device structure filled by the device driver - **/ -int iio_device_register(struct iio_dev *indio_dev) +int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod) { int ret; + indio_dev->driver_module = this_mod; /* If the calling driver did not initialize of_node, do it here */ if (!indio_dev->dev.of_node && indio_dev->dev.parent) indio_dev->dev.of_node = indio_dev->dev.parent->of_node; @@ -1715,7 +1712,8 @@ int iio_device_register(struct iio_dev *indio_dev) indio_dev->setup_ops = &noop_ring_setup_ops; cdev_init(&indio_dev->chrdev, &iio_buffer_fileops); - indio_dev->chrdev.owner = indio_dev->info->driver_module; + + indio_dev->chrdev.owner = this_mod; ret = cdev_device_add(&indio_dev->chrdev, &indio_dev->dev); if (ret < 0) @@ -1733,7 +1731,7 @@ error_unreg_debugfs: iio_device_unregister_debugfs(indio_dev); return ret; } -EXPORT_SYMBOL(iio_device_register); +EXPORT_SYMBOL(__iio_device_register); /** * iio_device_unregister() - unregister a device from the IIO subsystem @@ -1765,23 +1763,8 @@ static void devm_iio_device_unreg(struct device *dev, void *res) iio_device_unregister(*(struct iio_dev **)res); } -/** - * devm_iio_device_register - Resource-managed iio_device_register() - * @dev: Device to allocate iio_dev for - * @indio_dev: Device structure filled by the device driver - * - * Managed iio_device_register. The IIO device registered with this - * function is automatically unregistered on driver detach. This function - * calls iio_device_register() internally. Refer to that function for more - * information. - * - * If an iio_dev registered with this function needs to be unregistered - * separately, devm_iio_device_unregister() must be used. - * - * RETURNS: - * 0 on success, negative error number on failure. - */ -int devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev) +int __devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev, + struct module *this_mod) { struct iio_dev **ptr; int ret; @@ -1791,7 +1774,7 @@ int devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev) return -ENOMEM; *ptr = indio_dev; - ret = iio_device_register(indio_dev); + ret = __iio_device_register(indio_dev, this_mod); if (!ret) devres_add(dev, ptr); else @@ -1799,7 +1782,7 @@ int devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev) return ret; } -EXPORT_SYMBOL_GPL(devm_iio_device_register); +EXPORT_SYMBOL_GPL(__devm_iio_device_register); /** * devm_iio_device_unregister - Resource-managed iio_device_unregister() diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 4061fed93f1f..ce66699c7fcc 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -66,13 +66,12 @@ ATTRIBUTE_GROUPS(iio_trig_dev); static struct iio_trigger *__iio_trigger_find_by_name(const char *name); -int iio_trigger_register(struct iio_trigger *trig_info) +int __iio_trigger_register(struct iio_trigger *trig_info, + struct module *this_mod) { int ret; - /* trig_info->ops is required for the module member */ - if (!trig_info->ops) - return -EINVAL; + trig_info->owner = this_mod; trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL); if (trig_info->id < 0) @@ -105,7 +104,7 @@ error_unregister_id: ida_simple_remove(&iio_trigger_ida, trig_info->id); return ret; } -EXPORT_SYMBOL(iio_trigger_register); +EXPORT_SYMBOL(__iio_trigger_register); void iio_trigger_unregister(struct iio_trigger *trig_info) { @@ -206,7 +205,8 @@ EXPORT_SYMBOL(iio_trigger_poll_chained); void iio_trigger_notify_done(struct iio_trigger *trig) { - if (atomic_dec_and_test(&trig->use_count) && trig->ops->try_reenable) + if (atomic_dec_and_test(&trig->use_count) && trig->ops && + trig->ops->try_reenable) if (trig->ops->try_reenable(trig)) /* Missed an interrupt so launch new poll now */ iio_trigger_poll(trig); @@ -250,7 +250,7 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig, = bitmap_empty(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER); /* Prevent the module from being removed whilst attached to a trigger */ - __module_get(pf->indio_dev->info->driver_module); + __module_get(pf->indio_dev->driver_module); /* Get irq number */ pf->irq = iio_trigger_get_irq(trig); @@ -265,7 +265,7 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig, goto out_put_irq; /* Enable trigger in driver */ - if (trig->ops->set_trigger_state && notinuse) { + if (trig->ops && trig->ops->set_trigger_state && notinuse) { ret = trig->ops->set_trigger_state(trig, true); if (ret < 0) goto out_free_irq; @@ -286,7 +286,7 @@ out_free_irq: out_put_irq: iio_trigger_put_irq(trig, pf->irq); out_put_module: - module_put(pf->indio_dev->info->driver_module); + module_put(pf->indio_dev->driver_module); return ret; } @@ -298,7 +298,7 @@ static int iio_trigger_detach_poll_func(struct iio_trigger *trig, = (bitmap_weight(trig->pool, CONFIG_IIO_CONSUMERS_PER_TRIGGER) == 1); - if (trig->ops->set_trigger_state && no_other_users) { + if (trig->ops && trig->ops->set_trigger_state && no_other_users) { ret = trig->ops->set_trigger_state(trig, false); if (ret) return ret; @@ -307,7 +307,7 @@ static int iio_trigger_detach_poll_func(struct iio_trigger *trig, trig->attached_own_device = false; iio_trigger_put_irq(trig, pf->irq); free_irq(pf->irq, pf); - module_put(pf->indio_dev->info->driver_module); + module_put(pf->indio_dev->driver_module); return ret; } @@ -428,7 +428,7 @@ static ssize_t iio_trigger_write_current(struct device *dev, goto out_trigger_put; } - if (trig && trig->ops->validate_device) { + if (trig && trig->ops && trig->ops->validate_device) { ret = trig->ops->validate_device(trig, indio_dev); if (ret) goto out_trigger_put; @@ -663,9 +663,10 @@ static void devm_iio_trigger_unreg(struct device *dev, void *res) } /** - * devm_iio_trigger_register - Resource-managed iio_trigger_register() + * __devm_iio_trigger_register - Resource-managed iio_trigger_register() * @dev: device this trigger was allocated for * @trig_info: trigger to register + * @this_mod: module registering the trigger * * Managed iio_trigger_register(). The IIO trigger registered with this * function is automatically unregistered on driver detach. This function @@ -678,7 +679,9 @@ static void devm_iio_trigger_unreg(struct device *dev, void *res) * RETURNS: * 0 on success, negative error number on failure. */ -int devm_iio_trigger_register(struct device *dev, struct iio_trigger *trig_info) +int __devm_iio_trigger_register(struct device *dev, + struct iio_trigger *trig_info, + struct module *this_mod) { struct iio_trigger **ptr; int ret; @@ -688,7 +691,7 @@ int devm_iio_trigger_register(struct device *dev, struct iio_trigger *trig_info) return -ENOMEM; *ptr = trig_info; - ret = iio_trigger_register(trig_info); + ret = __iio_trigger_register(trig_info, this_mod); if (!ret) devres_add(dev, ptr); else @@ -696,7 +699,7 @@ int devm_iio_trigger_register(struct device *dev, struct iio_trigger *trig_info) return ret; } -EXPORT_SYMBOL_GPL(devm_iio_trigger_register); +EXPORT_SYMBOL_GPL(__devm_iio_trigger_register); /** * devm_iio_trigger_unregister - Resource-managed iio_trigger_unregister() diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c index f0b47c501f4e..c35e2f8df339 100644 --- a/drivers/iio/light/acpi-als.c +++ b/drivers/iio/light/acpi-als.c @@ -171,7 +171,6 @@ static int acpi_als_read_raw(struct iio_dev *indio_dev, } static const struct iio_info acpi_als_info = { - .driver_module = THIS_MODULE, .read_raw = acpi_als_read_raw, }; diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c index 0113fc843a81..e45bb6a277c2 100644 --- a/drivers/iio/light/adjd_s311.c +++ b/drivers/iio/light/adjd_s311.c @@ -245,7 +245,6 @@ static const struct iio_info adjd_s311_info = { .read_raw = adjd_s311_read_raw, .write_raw = adjd_s311_write_raw, .update_scan_mode = adjd_s311_update_scan_mode, - .driver_module = THIS_MODULE, }; static int adjd_s311_probe(struct i2c_client *client, diff --git a/drivers/iio/light/al3320a.c b/drivers/iio/light/al3320a.c index 6aac6513fd41..66623facea9a 100644 --- a/drivers/iio/light/al3320a.c +++ b/drivers/iio/light/al3320a.c @@ -168,7 +168,6 @@ static int al3320a_write_raw(struct iio_dev *indio_dev, } static const struct iio_info al3320a_info = { - .driver_module = THIS_MODULE, .read_raw = al3320a_read_raw, .write_raw = al3320a_write_raw, .attrs = &al3320a_attribute_group, diff --git a/drivers/iio/light/apds9300.c b/drivers/iio/light/apds9300.c index 05eacd1ee40f..5c15736fb93e 100644 --- a/drivers/iio/light/apds9300.c +++ b/drivers/iio/light/apds9300.c @@ -337,12 +337,10 @@ static int apds9300_write_interrupt_config(struct iio_dev *indio_dev, } static const struct iio_info apds9300_info_no_irq = { - .driver_module = THIS_MODULE, .read_raw = apds9300_read_raw, }; static const struct iio_info apds9300_info = { - .driver_module = THIS_MODULE, .read_raw = apds9300_read_raw, .read_event_value = apds9300_read_thresh, .write_event_value = apds9300_write_thresh, diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c index 518a47e9377b..a8fa00e31c39 100644 --- a/drivers/iio/light/apds9960.c +++ b/drivers/iio/light/apds9960.c @@ -744,7 +744,6 @@ static int apds9960_write_event_config(struct iio_dev *indio_dev, } static const struct iio_info apds9960_info = { - .driver_module = THIS_MODULE, .attrs = &apds9960_attribute_group, .read_raw = apds9960_read_raw, .write_raw = apds9960_write_raw, diff --git a/drivers/iio/light/bh1750.c b/drivers/iio/light/bh1750.c index 6c61187e630f..a814828e69f5 100644 --- a/drivers/iio/light/bh1750.c +++ b/drivers/iio/light/bh1750.c @@ -217,7 +217,6 @@ static const struct attribute_group bh1750_attribute_group = { }; static const struct iio_info bh1750_info = { - .driver_module = THIS_MODULE, .attrs = &bh1750_attribute_group, .read_raw = bh1750_read_raw, .write_raw = bh1750_write_raw, diff --git a/drivers/iio/light/bh1780.c b/drivers/iio/light/bh1780.c index b54dcba05a82..036f3bbe323c 100644 --- a/drivers/iio/light/bh1780.c +++ b/drivers/iio/light/bh1780.c @@ -128,7 +128,6 @@ static int bh1780_read_raw(struct iio_dev *indio_dev, } static const struct iio_info bh1780_info = { - .driver_module = THIS_MODULE, .read_raw = bh1780_read_raw, .debugfs_reg_access = bh1780_debugfs_reg_access, }; diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c index d6fd0dace74f..aebf7dd071af 100644 --- a/drivers/iio/light/cm32181.c +++ b/drivers/iio/light/cm32181.c @@ -292,7 +292,6 @@ static const struct attribute_group cm32181_attribute_group = { }; static const struct iio_info cm32181_info = { - .driver_module = THIS_MODULE, .read_raw = &cm32181_read_raw, .write_raw = &cm32181_write_raw, .attrs = &cm32181_attribute_group, diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c index 263e97235ea0..c639cf276ee6 100644 --- a/drivers/iio/light/cm3232.c +++ b/drivers/iio/light/cm3232.c @@ -322,7 +322,6 @@ static const struct attribute_group cm3232_attribute_group = { }; static const struct iio_info cm3232_info = { - .driver_module = THIS_MODULE, .read_raw = &cm3232_read_raw, .write_raw = &cm3232_write_raw, .attrs = &cm3232_attribute_group, diff --git a/drivers/iio/light/cm3323.c b/drivers/iio/light/cm3323.c index d823c112d54b..83b08b6dc60f 100644 --- a/drivers/iio/light/cm3323.c +++ b/drivers/iio/light/cm3323.c @@ -211,7 +211,6 @@ static int cm3323_write_raw(struct iio_dev *indio_dev, } static const struct iio_info cm3323_info = { - .driver_module = THIS_MODULE, .read_raw = cm3323_read_raw, .write_raw = cm3323_write_raw, .attrs = &cm3323_attribute_group, diff --git a/drivers/iio/light/cm3605.c b/drivers/iio/light/cm3605.c index 980624e9ffb5..e454bc6a33c6 100644 --- a/drivers/iio/light/cm3605.c +++ b/drivers/iio/light/cm3605.c @@ -126,7 +126,6 @@ static int cm3605_read_raw(struct iio_dev *indio_dev, } static const struct iio_info cm3605_info = { - .driver_module = THIS_MODULE, .read_raw = cm3605_read_raw, }; diff --git a/drivers/iio/light/cm36651.c b/drivers/iio/light/cm36651.c index 9d66e89c57ef..1dd8ed0121b3 100644 --- a/drivers/iio/light/cm36651.c +++ b/drivers/iio/light/cm36651.c @@ -612,7 +612,6 @@ static const struct attribute_group cm36651_attribute_group = { }; static const struct iio_info cm36651_info = { - .driver_module = THIS_MODULE, .read_raw = &cm36651_read_raw, .write_raw = &cm36651_write_raw, .read_event_value = &cm36651_read_prox_thresh, diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c index 721722376fd0..b2a46b390d5c 100644 --- a/drivers/iio/light/cros_ec_light_prox.c +++ b/drivers/iio/light/cros_ec_light_prox.c @@ -175,7 +175,6 @@ static int cros_ec_light_prox_write(struct iio_dev *indio_dev, static const struct iio_info cros_ec_light_prox_info = { .read_raw = &cros_ec_light_prox_read, .write_raw = &cros_ec_light_prox_write, - .driver_module = THIS_MODULE, }; static int cros_ec_light_prox_probe(struct platform_device *pdev) diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c index 6ada9149f142..44b13fbcd093 100644 --- a/drivers/iio/light/gp2ap020a00f.c +++ b/drivers/iio/light/gp2ap020a00f.c @@ -1384,7 +1384,6 @@ static const struct iio_info gp2ap020a00f_info = { .read_event_config = &gp2ap020a00f_read_event_config, .write_event_value = &gp2ap020a00f_write_event_val, .write_event_config = &gp2ap020a00f_write_event_config, - .driver_module = THIS_MODULE, }; static int gp2ap020a00f_buffer_postenable(struct iio_dev *indio_dev) @@ -1481,7 +1480,6 @@ static const struct iio_buffer_setup_ops gp2ap020a00f_buffer_setup_ops = { }; static const struct iio_trigger_ops gp2ap020a00f_trigger_ops = { - .owner = THIS_MODULE, }; static int gp2ap020a00f_probe(struct i2c_client *client, diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index 059d964772c7..befd693a4a31 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -177,7 +177,6 @@ static int als_write_raw(struct iio_dev *indio_dev, } static const struct iio_info als_info = { - .driver_module = THIS_MODULE, .read_raw = &als_read_raw, .write_raw = &als_write_raw, }; diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c index 73fced8a63b7..45107f7537b5 100644 --- a/drivers/iio/light/hid-sensor-prox.c +++ b/drivers/iio/light/hid-sensor-prox.c @@ -156,7 +156,6 @@ static int prox_write_raw(struct iio_dev *indio_dev, } static const struct iio_info prox_info = { - .driver_module = THIS_MODULE, .read_raw = &prox_read_raw, .write_raw = &prox_write_raw, }; diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c index 61f5924b472d..b45400f8fef4 100644 --- a/drivers/iio/light/isl29018.c +++ b/drivers/iio/light/isl29018.c @@ -624,14 +624,12 @@ static int isl29018_chip_init(struct isl29018_chip *chip) static const struct iio_info isl29018_info = { .attrs = &isl29018_group, - .driver_module = THIS_MODULE, .read_raw = isl29018_read_raw, .write_raw = isl29018_write_raw, }; static const struct iio_info isl29023_info = { .attrs = &isl29023_group, - .driver_module = THIS_MODULE, .read_raw = isl29018_read_raw, .write_raw = isl29018_write_raw, }; diff --git a/drivers/iio/light/isl29028.c b/drivers/iio/light/isl29028.c index 3d09c1fc4dad..f9912ab4f65c 100644 --- a/drivers/iio/light/isl29028.c +++ b/drivers/iio/light/isl29028.c @@ -536,7 +536,6 @@ static const struct iio_chan_spec isl29028_channels[] = { static const struct iio_info isl29028_info = { .attrs = &isl29108_group, - .driver_module = THIS_MODULE, .read_raw = isl29028_read_raw, .write_raw = isl29028_write_raw, }; diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c index 1d2c0c8a1d4f..ed38edcd5efe 100644 --- a/drivers/iio/light/isl29125.c +++ b/drivers/iio/light/isl29125.c @@ -214,7 +214,6 @@ static const struct iio_info isl29125_info = { .read_raw = isl29125_read_raw, .write_raw = isl29125_write_raw, .attrs = &isl29125_attribute_group, - .driver_module = THIS_MODULE, }; static int isl29125_buffer_preenable(struct iio_dev *indio_dev) diff --git a/drivers/iio/light/jsa1212.c b/drivers/iio/light/jsa1212.c index e8a8931b4f50..811505d925b3 100644 --- a/drivers/iio/light/jsa1212.c +++ b/drivers/iio/light/jsa1212.c @@ -271,7 +271,6 @@ static const struct iio_chan_spec jsa1212_channels[] = { }; static const struct iio_info jsa1212_info = { - .driver_module = THIS_MODULE, .read_raw = &jsa1212_read_raw, }; diff --git a/drivers/iio/light/lm3533-als.c b/drivers/iio/light/lm3533-als.c index 0443fd2e8757..36208a3652e9 100644 --- a/drivers/iio/light/lm3533-als.c +++ b/drivers/iio/light/lm3533-als.c @@ -827,7 +827,6 @@ static int lm3533_als_disable(struct lm3533_als *als) static const struct iio_info lm3533_als_info = { .attrs = &lm3533_als_attribute_group, .event_attrs = &lm3533_als_event_attribute_group, - .driver_module = THIS_MODULE, .read_raw = &lm3533_als_read_raw, }; diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 67838edd8b37..830a2d45aa4d 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -1158,7 +1158,6 @@ static const struct iio_info ltr501_info_no_irq = { .read_raw = ltr501_read_raw, .write_raw = ltr501_write_raw, .attrs = <r501_attribute_group, - .driver_module = THIS_MODULE, }; static const struct iio_info ltr501_info = { @@ -1169,14 +1168,12 @@ static const struct iio_info ltr501_info = { .write_event_value = <r501_write_event, .read_event_config = <r501_read_event_config, .write_event_config = <r501_write_event_config, - .driver_module = THIS_MODULE, }; static const struct iio_info ltr301_info_no_irq = { .read_raw = ltr501_read_raw, .write_raw = ltr501_write_raw, .attrs = <r301_attribute_group, - .driver_module = THIS_MODULE, }; static const struct iio_info ltr301_info = { @@ -1187,7 +1184,6 @@ static const struct iio_info ltr301_info = { .write_event_value = <r501_write_event, .read_event_config = <r501_read_event_config, .write_event_config = <r501_write_event_config, - .driver_module = THIS_MODULE, }; static struct ltr501_chip_info ltr501_chip_info_tbl[] = { diff --git a/drivers/iio/light/max44000.c b/drivers/iio/light/max44000.c index 81bd8e8da4a6..bcdb0eb9e537 100644 --- a/drivers/iio/light/max44000.c +++ b/drivers/iio/light/max44000.c @@ -402,7 +402,6 @@ static const struct attribute_group max44000_attribute_group = { }; static const struct iio_info max44000_info = { - .driver_module = THIS_MODULE, .read_raw = max44000_read_raw, .write_raw = max44000_write_raw, .write_raw_get_fmt = max44000_write_raw_get_fmt, diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c index b91ebc3483ce..54d88b60e303 100644 --- a/drivers/iio/light/opt3001.c +++ b/drivers/iio/light/opt3001.c @@ -585,7 +585,6 @@ err: } static const struct iio_info opt3001_info = { - .driver_module = THIS_MODULE, .attrs = &opt3001_attribute_group, .read_raw = opt3001_read_raw, .write_raw = opt3001_write_raw, diff --git a/drivers/iio/light/pa12203001.c b/drivers/iio/light/pa12203001.c index 76a9e12b46bc..30ea1a088dd9 100644 --- a/drivers/iio/light/pa12203001.c +++ b/drivers/iio/light/pa12203001.c @@ -306,7 +306,6 @@ static int pa12203001_write_raw(struct iio_dev *indio_dev, } static const struct iio_info pa12203001_info = { - .driver_module = THIS_MODULE, .read_raw = pa12203001_read_raw, .write_raw = pa12203001_write_raw, .attrs = &pa12203001_attr_group, diff --git a/drivers/iio/light/rpr0521.c b/drivers/iio/light/rpr0521.c index a6efa12613a2..ffe9ce798ea2 100644 --- a/drivers/iio/light/rpr0521.c +++ b/drivers/iio/light/rpr0521.c @@ -538,7 +538,6 @@ static int rpr0521_pxs_drdy_set_state(struct iio_trigger *trigger, static const struct iio_trigger_ops rpr0521_trigger_ops = { .set_trigger_state = rpr0521_pxs_drdy_set_state, - .owner = THIS_MODULE, }; @@ -830,7 +829,6 @@ static int rpr0521_write_raw(struct iio_dev *indio_dev, } static const struct iio_info rpr0521_info = { - .driver_module = THIS_MODULE, .read_raw = rpr0521_read_raw, .write_raw = rpr0521_write_raw, .attrs = &rpr0521_attribute_group, diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c index 096034c126a4..76f16f9c7616 100644 --- a/drivers/iio/light/si1145.c +++ b/drivers/iio/light/si1145.c @@ -989,14 +989,12 @@ static const struct attribute_group si114x_attribute_group = { static const struct iio_info si1132_info = { .read_raw = si1145_read_raw, .write_raw = si1145_write_raw, - .driver_module = THIS_MODULE, .attrs = &si1132_attribute_group, }; static const struct iio_info si114x_info = { .read_raw = si1145_read_raw, .write_raw = si1145_write_raw, - .driver_module = THIS_MODULE, .attrs = &si114x_attribute_group, }; @@ -1237,7 +1235,6 @@ disable: } static const struct iio_trigger_ops si1145_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = si1145_trigger_set_state, }; diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index 45cf8b0a4363..6e2a169da950 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -409,7 +409,6 @@ static int stk3310_write_raw(struct iio_dev *indio_dev, } static const struct iio_info stk3310_info = { - .driver_module = THIS_MODULE, .read_raw = stk3310_read_raw, .write_raw = stk3310_write_raw, .attrs = &stk3310_attribute_group, diff --git a/drivers/iio/light/tcs3414.c b/drivers/iio/light/tcs3414.c index a795afb7667b..205e5659ce6b 100644 --- a/drivers/iio/light/tcs3414.c +++ b/drivers/iio/light/tcs3414.c @@ -241,7 +241,6 @@ static const struct iio_info tcs3414_info = { .read_raw = tcs3414_read_raw, .write_raw = tcs3414_write_raw, .attrs = &tcs3414_attribute_group, - .driver_module = THIS_MODULE, }; static int tcs3414_buffer_preenable(struct iio_dev *indio_dev) diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c index 09e6ca5e332e..e7923b514d7a 100644 --- a/drivers/iio/light/tcs3472.c +++ b/drivers/iio/light/tcs3472.c @@ -13,7 +13,7 @@ * * Datasheet: http://ams.com/eng/content/download/319364/1117183/file/TCS3472_Datasheet_EN_v2.pdf * - * TODO: interrupt support, thresholds, wait time + * TODO: wait time */ #include <linux/module.h> @@ -23,6 +23,7 @@ #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> +#include <linux/iio/events.h> #include <linux/iio/trigger_consumer.h> #include <linux/iio/buffer.h> #include <linux/iio/triggered_buffer.h> @@ -31,12 +32,15 @@ #define TCS3472_COMMAND BIT(7) #define TCS3472_AUTO_INCR BIT(5) +#define TCS3472_SPECIAL_FUNC (BIT(5) | BIT(6)) + +#define TCS3472_INTR_CLEAR (TCS3472_COMMAND | TCS3472_SPECIAL_FUNC | 0x06) #define TCS3472_ENABLE (TCS3472_COMMAND | 0x00) #define TCS3472_ATIME (TCS3472_COMMAND | 0x01) #define TCS3472_WTIME (TCS3472_COMMAND | 0x03) -#define TCS3472_AILT (TCS3472_COMMAND | 0x04) -#define TCS3472_AIHT (TCS3472_COMMAND | 0x06) +#define TCS3472_AILT (TCS3472_COMMAND | TCS3472_AUTO_INCR | 0x04) +#define TCS3472_AIHT (TCS3472_COMMAND | TCS3472_AUTO_INCR | 0x06) #define TCS3472_PERS (TCS3472_COMMAND | 0x0c) #define TCS3472_CONFIG (TCS3472_COMMAND | 0x0d) #define TCS3472_CONTROL (TCS3472_COMMAND | 0x0f) @@ -47,19 +51,42 @@ #define TCS3472_GDATA (TCS3472_COMMAND | TCS3472_AUTO_INCR | 0x18) #define TCS3472_BDATA (TCS3472_COMMAND | TCS3472_AUTO_INCR | 0x1a) +#define TCS3472_STATUS_AINT BIT(4) #define TCS3472_STATUS_AVALID BIT(0) +#define TCS3472_ENABLE_AIEN BIT(4) #define TCS3472_ENABLE_AEN BIT(1) #define TCS3472_ENABLE_PON BIT(0) #define TCS3472_CONTROL_AGAIN_MASK (BIT(0) | BIT(1)) struct tcs3472_data { struct i2c_client *client; + struct mutex lock; + u16 low_thresh; + u16 high_thresh; u8 enable; u8 control; u8 atime; + u8 apers; u16 buffer[8]; /* 4 16-bit channels + 64-bit timestamp */ }; +static const struct iio_event_spec tcs3472_events[] = { + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_RISING, + .mask_separate = BIT(IIO_EV_INFO_VALUE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_FALLING, + .mask_separate = BIT(IIO_EV_INFO_VALUE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_EITHER, + .mask_separate = BIT(IIO_EV_INFO_ENABLE) | + BIT(IIO_EV_INFO_PERIOD), + }, +}; + #define TCS3472_CHANNEL(_color, _si, _addr) { \ .type = IIO_INTENSITY, \ .modified = 1, \ @@ -75,6 +102,8 @@ struct tcs3472_data { .storagebits = 16, \ .endianness = IIO_CPU, \ }, \ + .event_spec = _si ? NULL : tcs3472_events, \ + .num_event_specs = _si ? 0 : ARRAY_SIZE(tcs3472_events), \ } static const int tcs3472_agains[] = { 1, 4, 16, 60 }; @@ -182,6 +211,166 @@ static int tcs3472_write_raw(struct iio_dev *indio_dev, return -EINVAL; } +/* + * Translation from APERS field value to the number of consecutive out-of-range + * clear channel values before an interrupt is generated + */ +static const int tcs3472_intr_pers[] = { + 0, 1, 2, 3, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 +}; + +static int tcs3472_read_event(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, enum iio_event_type type, + enum iio_event_direction dir, enum iio_event_info info, int *val, + int *val2) +{ + struct tcs3472_data *data = iio_priv(indio_dev); + int ret; + unsigned int period; + + mutex_lock(&data->lock); + + switch (info) { + case IIO_EV_INFO_VALUE: + *val = (dir == IIO_EV_DIR_RISING) ? + data->high_thresh : data->low_thresh; + ret = IIO_VAL_INT; + break; + case IIO_EV_INFO_PERIOD: + period = (256 - data->atime) * 2400 * + tcs3472_intr_pers[data->apers]; + *val = period / USEC_PER_SEC; + *val2 = period % USEC_PER_SEC; + ret = IIO_VAL_INT_PLUS_MICRO; + break; + default: + ret = -EINVAL; + break; + } + + mutex_unlock(&data->lock); + + return ret; +} + +static int tcs3472_write_event(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, enum iio_event_type type, + enum iio_event_direction dir, enum iio_event_info info, int val, + int val2) +{ + struct tcs3472_data *data = iio_priv(indio_dev); + int ret; + u8 command; + int period; + int i; + + mutex_lock(&data->lock); + switch (info) { + case IIO_EV_INFO_VALUE: + switch (dir) { + case IIO_EV_DIR_RISING: + command = TCS3472_AIHT; + break; + case IIO_EV_DIR_FALLING: + command = TCS3472_AILT; + break; + default: + ret = -EINVAL; + goto error; + } + ret = i2c_smbus_write_word_data(data->client, command, val); + if (ret) + goto error; + + if (dir == IIO_EV_DIR_RISING) + data->high_thresh = val; + else + data->low_thresh = val; + break; + case IIO_EV_INFO_PERIOD: + period = val * USEC_PER_SEC + val2; + for (i = 1; i < ARRAY_SIZE(tcs3472_intr_pers) - 1; i++) { + if (period <= (256 - data->atime) * 2400 * + tcs3472_intr_pers[i]) + break; + } + ret = i2c_smbus_write_byte_data(data->client, TCS3472_PERS, i); + if (ret) + goto error; + + data->apers = i; + break; + default: + ret = -EINVAL; + break; + } +error: + mutex_unlock(&data->lock); + + return ret; +} + +static int tcs3472_read_event_config(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, enum iio_event_type type, + enum iio_event_direction dir) +{ + struct tcs3472_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->lock); + ret = !!(data->enable & TCS3472_ENABLE_AIEN); + mutex_unlock(&data->lock); + + return ret; +} + +static int tcs3472_write_event_config(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, enum iio_event_type type, + enum iio_event_direction dir, int state) +{ + struct tcs3472_data *data = iio_priv(indio_dev); + int ret = 0; + u8 enable_old; + + mutex_lock(&data->lock); + + enable_old = data->enable; + + if (state) + data->enable |= TCS3472_ENABLE_AIEN; + else + data->enable &= ~TCS3472_ENABLE_AIEN; + + if (enable_old != data->enable) { + ret = i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE, + data->enable); + if (ret) + data->enable = enable_old; + } + mutex_unlock(&data->lock); + + return ret; +} + +static irqreturn_t tcs3472_event_handler(int irq, void *priv) +{ + struct iio_dev *indio_dev = priv; + struct tcs3472_data *data = iio_priv(indio_dev); + int ret; + + ret = i2c_smbus_read_byte_data(data->client, TCS3472_STATUS); + if (ret >= 0 && (ret & TCS3472_STATUS_AINT)) { + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_INTENSITY, 0, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_EITHER), + iio_get_time_ns(indio_dev)); + + i2c_smbus_read_byte_data(data->client, TCS3472_INTR_CLEAR); + } + + return IRQ_HANDLED; +} + static irqreturn_t tcs3472_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; @@ -245,8 +434,11 @@ static const struct attribute_group tcs3472_attribute_group = { static const struct iio_info tcs3472_info = { .read_raw = tcs3472_read_raw, .write_raw = tcs3472_write_raw, + .read_event_value = tcs3472_read_event, + .write_event_value = tcs3472_write_event, + .read_event_config = tcs3472_read_event_config, + .write_event_config = tcs3472_write_event_config, .attrs = &tcs3472_attribute_group, - .driver_module = THIS_MODULE, }; static int tcs3472_probe(struct i2c_client *client, @@ -263,6 +455,7 @@ static int tcs3472_probe(struct i2c_client *client, data = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); data->client = client; + mutex_init(&data->lock); indio_dev->dev.parent = &client->dev; indio_dev->info = &tcs3472_info; @@ -292,12 +485,29 @@ static int tcs3472_probe(struct i2c_client *client, return ret; data->atime = ret; + ret = i2c_smbus_read_word_data(data->client, TCS3472_AILT); + if (ret < 0) + return ret; + data->low_thresh = ret; + + ret = i2c_smbus_read_word_data(data->client, TCS3472_AIHT); + if (ret < 0) + return ret; + data->high_thresh = ret; + + data->apers = 1; + ret = i2c_smbus_write_byte_data(data->client, TCS3472_PERS, + data->apers); + if (ret < 0) + return ret; + ret = i2c_smbus_read_byte_data(data->client, TCS3472_ENABLE); if (ret < 0) return ret; /* enable device */ data->enable = ret | TCS3472_ENABLE_PON | TCS3472_ENABLE_AEN; + data->enable &= ~TCS3472_ENABLE_AIEN; ret = i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE, data->enable); if (ret < 0) @@ -308,12 +518,24 @@ static int tcs3472_probe(struct i2c_client *client, if (ret < 0) return ret; + if (client->irq) { + ret = request_threaded_irq(client->irq, NULL, + tcs3472_event_handler, + IRQF_TRIGGER_FALLING | IRQF_SHARED | + IRQF_ONESHOT, + client->name, indio_dev); + if (ret) + goto buffer_cleanup; + } + ret = iio_device_register(indio_dev); if (ret < 0) - goto buffer_cleanup; + goto free_irq; return 0; +free_irq: + free_irq(client->irq, indio_dev); buffer_cleanup: iio_triggered_buffer_cleanup(indio_dev); return ret; @@ -321,8 +543,19 @@ buffer_cleanup: static int tcs3472_powerdown(struct tcs3472_data *data) { - return i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE, - data->enable & ~(TCS3472_ENABLE_AEN | TCS3472_ENABLE_PON)); + int ret; + u8 enable_mask = TCS3472_ENABLE_AEN | TCS3472_ENABLE_PON; + + mutex_lock(&data->lock); + + ret = i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE, + data->enable & ~enable_mask); + if (!ret) + data->enable &= ~enable_mask; + + mutex_unlock(&data->lock); + + return ret; } static int tcs3472_remove(struct i2c_client *client) @@ -330,6 +563,7 @@ static int tcs3472_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); iio_device_unregister(indio_dev); + free_irq(client->irq, indio_dev); iio_triggered_buffer_cleanup(indio_dev); tcs3472_powerdown(iio_priv(indio_dev)); @@ -348,8 +582,19 @@ static int tcs3472_resume(struct device *dev) { struct tcs3472_data *data = iio_priv(i2c_get_clientdata( to_i2c_client(dev))); - return i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE, - data->enable | (TCS3472_ENABLE_AEN | TCS3472_ENABLE_PON)); + int ret; + u8 enable_mask = TCS3472_ENABLE_AEN | TCS3472_ENABLE_PON; + + mutex_lock(&data->lock); + + ret = i2c_smbus_write_byte_data(data->client, TCS3472_ENABLE, + data->enable | enable_mask); + if (!ret) + data->enable |= enable_mask; + + mutex_unlock(&data->lock); + + return ret; } #endif diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c index 7599693f7fe9..6bbb0b1e6032 100644 --- a/drivers/iio/light/tsl2563.c +++ b/drivers/iio/light/tsl2563.c @@ -697,13 +697,11 @@ static int tsl2563_read_interrupt_config(struct iio_dev *indio_dev, } static const struct iio_info tsl2563_info_no_irq = { - .driver_module = THIS_MODULE, .read_raw = &tsl2563_read_raw, .write_raw = &tsl2563_write_raw, }; static const struct iio_info tsl2563_info = { - .driver_module = THIS_MODULE, .read_raw = &tsl2563_read_raw, .write_raw = &tsl2563_write_raw, .read_event_value = &tsl2563_read_thresh, diff --git a/drivers/iio/light/tsl2583.c b/drivers/iio/light/tsl2583.c index fb711ed4862e..f2e50edaa242 100644 --- a/drivers/iio/light/tsl2583.c +++ b/drivers/iio/light/tsl2583.c @@ -804,7 +804,6 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev, static const struct iio_info tsl2583_info = { .attrs = &tsl2583_attribute_group, - .driver_module = THIS_MODULE, .read_raw = tsl2583_read_raw, .write_raw = tsl2583_write_raw, }; diff --git a/drivers/iio/light/tsl4531.c b/drivers/iio/light/tsl4531.c index cf94ec72b181..06171cb76e23 100644 --- a/drivers/iio/light/tsl4531.c +++ b/drivers/iio/light/tsl4531.c @@ -144,7 +144,6 @@ static const struct iio_info tsl4531_info = { .read_raw = tsl4531_read_raw, .write_raw = tsl4531_write_raw, .attrs = &tsl4531_attribute_group, - .driver_module = THIS_MODULE, }; static int tsl4531_check_id(struct i2c_client *client) diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c index d571ad7291ed..68e52943879a 100644 --- a/drivers/iio/light/us5182d.c +++ b/drivers/iio/light/us5182d.c @@ -714,7 +714,6 @@ err: } static const struct iio_info us5182d_info = { - .driver_module = THIS_MODULE, .read_raw = us5182d_read_raw, .write_raw = us5182d_write_raw, .attrs = &us5182d_attr_group, diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 360b6e98137a..c599a90506ad 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -155,7 +155,6 @@ static int vcnl4000_read_raw(struct iio_dev *indio_dev, static const struct iio_info vcnl4000_info = { .read_raw = vcnl4000_read_raw, - .driver_module = THIS_MODULE, }; static int vcnl4000_probe(struct i2c_client *client, diff --git a/drivers/iio/light/veml6070.c b/drivers/iio/light/veml6070.c index bc1c4cb782cd..f4bf3c5b5eda 100644 --- a/drivers/iio/light/veml6070.c +++ b/drivers/iio/light/veml6070.c @@ -136,7 +136,6 @@ static int veml6070_read_raw(struct iio_dev *indio_dev, static const struct iio_info veml6070_info = { .read_raw = veml6070_read_raw, - .driver_module = THIS_MODULE, }; static int veml6070_probe(struct i2c_client *client, diff --git a/drivers/iio/light/vl6180.c b/drivers/iio/light/vl6180.c index 6e25b724d941..2306967f574f 100644 --- a/drivers/iio/light/vl6180.c +++ b/drivers/iio/light/vl6180.c @@ -429,7 +429,6 @@ static const struct iio_info vl6180_info = { .read_raw = vl6180_read_raw, .write_raw = vl6180_write_raw, .attrs = &vl6180_attribute_group, - .driver_module = THIS_MODULE, }; static int vl6180_init(struct vl6180_data *data) diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c index 0bff76e96950..93be1f4c0f27 100644 --- a/drivers/iio/magnetometer/ak8974.c +++ b/drivers/iio/magnetometer/ak8974.c @@ -658,7 +658,6 @@ static const unsigned long ak8974_scan_masks[] = { 0x7, 0 }; static const struct iio_info ak8974_info = { .read_raw = &ak8974_read_raw, - .driver_module = THIS_MODULE, }; static bool ak8974_writeable_reg(struct device *dev, unsigned int reg) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index 4ff883942f7b..c09329069d0a 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -781,7 +781,6 @@ static const unsigned long ak8975_scan_masks[] = { 0x7, 0 }; static const struct iio_info ak8975_info = { .read_raw = &ak8975_read_raw, - .driver_module = THIS_MODULE, }; #ifdef CONFIG_ACPI diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c index d104fb8d9379..d91cb845e3d6 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -651,7 +651,6 @@ static const struct iio_info bmc150_magn_info = { .attrs = &bmc150_magn_attrs_group, .read_raw = bmc150_magn_read_raw, .write_raw = bmc150_magn_write_raw, - .driver_module = THIS_MODULE, }; static const unsigned long bmc150_magn_scan_masks[] = { @@ -811,7 +810,6 @@ err_unlock: static const struct iio_trigger_ops bmc150_magn_trigger_ops = { .set_trigger_state = bmc150_magn_data_rdy_trigger_set_state, .try_reenable = bmc150_magn_trig_try_reen, - .owner = THIS_MODULE, }; static int bmc150_magn_buffer_preenable(struct iio_dev *indio_dev) diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index 0e791b02ed4a..a1fd9d591818 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c @@ -282,7 +282,6 @@ static int magn_3d_write_raw(struct iio_dev *indio_dev, } static const struct iio_info magn_3d_info = { - .driver_module = THIS_MODULE, .read_raw = &magn_3d_read_raw, .write_raw = &magn_3d_write_raw, }; diff --git a/drivers/iio/magnetometer/hmc5843_core.c b/drivers/iio/magnetometer/hmc5843_core.c index ba3e2a374ee5..ada142fb7aa3 100644 --- a/drivers/iio/magnetometer/hmc5843_core.c +++ b/drivers/iio/magnetometer/hmc5843_core.c @@ -597,7 +597,6 @@ static const struct iio_info hmc5843_info = { .read_raw = &hmc5843_read_raw, .write_raw = &hmc5843_write_raw, .write_raw_get_fmt = &hmc5843_write_raw_get_fmt, - .driver_module = THIS_MODULE, }; static const unsigned long hmc5843_scan_masks[] = {0x7, 0}; diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c index dad8d57f7402..b34ace76d31b 100644 --- a/drivers/iio/magnetometer/mag3110.c +++ b/drivers/iio/magnetometer/mag3110.c @@ -333,7 +333,6 @@ static const struct iio_info mag3110_info = { .attrs = &mag3110_group, .read_raw = &mag3110_read_raw, .write_raw = &mag3110_write_raw, - .driver_module = THIS_MODULE, }; static const unsigned long mag3110_scan_masks[] = {0x7, 0xf, 0}; diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c index 176e14a61558..6b640c6338c9 100644 --- a/drivers/iio/magnetometer/mmc35240.c +++ b/drivers/iio/magnetometer/mmc35240.c @@ -418,7 +418,6 @@ static int mmc35240_write_raw(struct iio_dev *indio_dev, } static const struct iio_info mmc35240_info = { - .driver_module = THIS_MODULE, .read_raw = mmc35240_read_raw, .write_raw = mmc35240_write_raw, .attrs = &mmc35240_attribute_group, diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 08aafba4481c..703de313c418 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -438,7 +438,6 @@ static const struct attribute_group st_magn_attribute_group = { }; static const struct iio_info magn_info = { - .driver_module = THIS_MODULE, .attrs = &st_magn_attribute_group, .read_raw = &st_magn_read_raw, .write_raw = &st_magn_write_raw, @@ -447,7 +446,6 @@ static const struct iio_info magn_info = { #ifdef CONFIG_IIO_TRIGGER static const struct iio_trigger_ops st_magn_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = ST_MAGN_TRIGGER_SET_STATE, .validate_device = st_sensors_validate_device, }; diff --git a/drivers/iio/multiplexer/iio-mux.c b/drivers/iio/multiplexer/iio-mux.c index 37ba007f8dca..60621ccd67e4 100644 --- a/drivers/iio/multiplexer/iio-mux.c +++ b/drivers/iio/multiplexer/iio-mux.c @@ -173,7 +173,6 @@ static const struct iio_info mux_info = { .read_raw = mux_read_raw, .read_avail = mux_read_avail, .write_raw = mux_write_raw, - .driver_module = THIS_MODULE, }; static ssize_t mux_read_ext_info(struct iio_dev *indio_dev, uintptr_t private, @@ -285,6 +284,9 @@ static int mux_configure_channel(struct device *dev, struct mux *mux, child->ext_info_cache = devm_kzalloc(dev, sizeof(*child->ext_info_cache) * num_ext_info, GFP_KERNEL); + if (!child->ext_info_cache) + return -ENOMEM; + for (i = 0; i < num_ext_info; ++i) { child->ext_info_cache[i].size = -1; @@ -309,6 +311,9 @@ static int mux_configure_channel(struct device *dev, struct mux *mux, child->ext_info_cache[i].data = devm_kmemdup(dev, page, ret + 1, GFP_KERNEL); + if (!child->ext_info_cache[i].data) + return -ENOMEM; + child->ext_info_cache[i].data[ret] = 0; child->ext_info_cache[i].size = ret; } diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c index fd1b3696ee42..1e5451d1ff88 100644 --- a/drivers/iio/orientation/hid-sensor-incl-3d.c +++ b/drivers/iio/orientation/hid-sensor-incl-3d.c @@ -186,7 +186,6 @@ static int incl_3d_write_raw(struct iio_dev *indio_dev, } static const struct iio_info incl_3d_info = { - .driver_module = THIS_MODULE, .read_raw = &incl_3d_read_raw, .write_raw = &incl_3d_write_raw, }; diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c index 98fe0c5df380..a69db2002414 100644 --- a/drivers/iio/orientation/hid-sensor-rotation.c +++ b/drivers/iio/orientation/hid-sensor-rotation.c @@ -138,7 +138,6 @@ static int dev_rot_write_raw(struct iio_dev *indio_dev, } static const struct iio_info dev_rot_info = { - .driver_module = THIS_MODULE, .read_raw_multi = &dev_rot_read_raw, .write_raw = &dev_rot_write_raw, }; diff --git a/drivers/iio/potentiometer/ds1803.c b/drivers/iio/potentiometer/ds1803.c index fb9e2a337dc2..9b0ff4ab2f9c 100644 --- a/drivers/iio/potentiometer/ds1803.c +++ b/drivers/iio/potentiometer/ds1803.c @@ -110,7 +110,6 @@ static int ds1803_write_raw(struct iio_dev *indio_dev, static const struct iio_info ds1803_info = { .read_raw = ds1803_read_raw, .write_raw = ds1803_write_raw, - .driver_module = THIS_MODULE, }; static int ds1803_probe(struct i2c_client *client, diff --git a/drivers/iio/potentiometer/max5481.c b/drivers/iio/potentiometer/max5481.c index 926554991244..ffe2761333a2 100644 --- a/drivers/iio/potentiometer/max5481.c +++ b/drivers/iio/potentiometer/max5481.c @@ -119,7 +119,6 @@ static int max5481_write_raw(struct iio_dev *indio_dev, static const struct iio_info max5481_info = { .read_raw = max5481_read_raw, .write_raw = max5481_write_raw, - .driver_module = THIS_MODULE, }; #if defined(CONFIG_OF) @@ -207,7 +206,6 @@ MODULE_DEVICE_TABLE(acpi, max5481_acpi_match); static struct spi_driver max5481_driver = { .driver = { .name = "max5481", - .owner = THIS_MODULE, .of_match_table = of_match_ptr(max5481_match), .acpi_match_table = ACPI_PTR(max5481_acpi_match), }, diff --git a/drivers/iio/potentiometer/max5487.c b/drivers/iio/potentiometer/max5487.c index 6c50939a2e83..5042d3e09b12 100644 --- a/drivers/iio/potentiometer/max5487.c +++ b/drivers/iio/potentiometer/max5487.c @@ -83,7 +83,6 @@ static int max5487_write_raw(struct iio_dev *indio_dev, static const struct iio_info max5487_info = { .read_raw = max5487_read_raw, .write_raw = max5487_write_raw, - .driver_module = THIS_MODULE, }; static int max5487_spi_probe(struct spi_device *spi) @@ -147,7 +146,6 @@ MODULE_DEVICE_TABLE(acpi, max5487_acpi_match); static struct spi_driver max5487_driver = { .driver = { .name = "max5487", - .owner = THIS_MODULE, .acpi_match_table = ACPI_PTR(max5487_acpi_match), }, .id_table = max5487_id, diff --git a/drivers/iio/potentiometer/mcp4131.c b/drivers/iio/potentiometer/mcp4131.c index 4e7e2c6c522c..b3e30db246cc 100644 --- a/drivers/iio/potentiometer/mcp4131.c +++ b/drivers/iio/potentiometer/mcp4131.c @@ -237,7 +237,6 @@ static int mcp4131_write_raw(struct iio_dev *indio_dev, static const struct iio_info mcp4131_info = { .read_raw = mcp4131_read_raw, .write_raw = mcp4131_write_raw, - .driver_module = THIS_MODULE, }; static int mcp4131_probe(struct spi_device *spi) diff --git a/drivers/iio/potentiometer/mcp4531.c b/drivers/iio/potentiometer/mcp4531.c index 314353d7ab59..114ab876fcc6 100644 --- a/drivers/iio/potentiometer/mcp4531.c +++ b/drivers/iio/potentiometer/mcp4531.c @@ -207,7 +207,6 @@ static const struct iio_info mcp4531_info = { .read_raw = mcp4531_read_raw, .read_avail = mcp4531_read_avail, .write_raw = mcp4531_write_raw, - .driver_module = THIS_MODULE, }; #ifdef CONFIG_OF diff --git a/drivers/iio/potentiometer/tpl0102.c b/drivers/iio/potentiometer/tpl0102.c index 7b6b54531ea2..93f9d4a8c9aa 100644 --- a/drivers/iio/potentiometer/tpl0102.c +++ b/drivers/iio/potentiometer/tpl0102.c @@ -106,7 +106,6 @@ static int tpl0102_write_raw(struct iio_dev *indio_dev, static const struct iio_info tpl0102_info = { .read_raw = tpl0102_read_raw, .write_raw = tpl0102_write_raw, - .driver_module = THIS_MODULE, }; static int tpl0102_probe(struct i2c_client *client, diff --git a/drivers/iio/potentiostat/lmp91000.c b/drivers/iio/potentiostat/lmp91000.c index afa8de3418d0..007710991f15 100644 --- a/drivers/iio/potentiostat/lmp91000.c +++ b/drivers/iio/potentiostat/lmp91000.c @@ -207,7 +207,6 @@ static int lmp91000_read_raw(struct iio_dev *indio_dev, } static const struct iio_info lmp91000_info = { - .driver_module = THIS_MODULE, .read_raw = lmp91000_read_raw, }; @@ -283,7 +282,6 @@ static int lmp91000_buffer_cb(const void *val, void *private) } static const struct iio_trigger_ops lmp91000_trigger_ops = { - .owner = THIS_MODULE, }; diff --git a/drivers/iio/pressure/abp060mg.c b/drivers/iio/pressure/abp060mg.c index 43bdd0b9155f..46a220c70d6a 100644 --- a/drivers/iio/pressure/abp060mg.c +++ b/drivers/iio/pressure/abp060mg.c @@ -168,7 +168,6 @@ static int abp060mg_read_raw(struct iio_dev *indio_dev, } static const struct iio_info abp060mg_info = { - .driver_module = THIS_MODULE, .read_raw = abp060mg_read_raw, }; diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index 8f26428804a2..fd1da26a62e4 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -561,7 +561,6 @@ static const struct attribute_group bmp280_attrs_group = { }; static const struct iio_info bmp280_info = { - .driver_module = THIS_MODULE, .read_raw = &bmp280_read_raw, .write_raw = &bmp280_write_raw, .attrs = &bmp280_attrs_group, diff --git a/drivers/iio/pressure/cros_ec_baro.c b/drivers/iio/pressure/cros_ec_baro.c index 48b2a30f57ae..4599fde4dd25 100644 --- a/drivers/iio/pressure/cros_ec_baro.c +++ b/drivers/iio/pressure/cros_ec_baro.c @@ -120,14 +120,12 @@ static int cros_ec_baro_write(struct iio_dev *indio_dev, static const struct iio_info cros_ec_baro_info = { .read_raw = &cros_ec_baro_read, .write_raw = &cros_ec_baro_write, - .driver_module = THIS_MODULE, }; static int cros_ec_baro_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct cros_ec_dev *ec_dev = dev_get_drvdata(dev->parent); - struct cros_ec_device *ec_device; struct iio_dev *indio_dev; struct cros_ec_baro_state *state; struct iio_chan_spec *channel; @@ -137,7 +135,6 @@ static int cros_ec_baro_probe(struct platform_device *pdev) dev_warn(dev, "No CROS EC device found.\n"); return -EINVAL; } - ec_device = ec_dev->ec_dev; indio_dev = devm_iio_device_alloc(dev, sizeof(*state)); if (!indio_dev) diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c index 6848d8c80eff..4c437918f1d2 100644 --- a/drivers/iio/pressure/hid-sensor-press.c +++ b/drivers/iio/pressure/hid-sensor-press.c @@ -160,7 +160,6 @@ static int press_write_raw(struct iio_dev *indio_dev, } static const struct iio_info press_info = { - .driver_module = THIS_MODULE, .read_raw = &press_read_raw, .write_raw = &press_write_raw, }; diff --git a/drivers/iio/pressure/hp03.c b/drivers/iio/pressure/hp03.c index 8c7b3ec3d84a..406934ea6228 100644 --- a/drivers/iio/pressure/hp03.c +++ b/drivers/iio/pressure/hp03.c @@ -208,7 +208,6 @@ static int hp03_read_raw(struct iio_dev *indio_dev, } static const struct iio_info hp03_info = { - .driver_module = THIS_MODULE, .read_raw = &hp03_read_raw, }; diff --git a/drivers/iio/pressure/hp206c.c b/drivers/iio/pressure/hp206c.c index 12f769e86355..c38c19678cf6 100644 --- a/drivers/iio/pressure/hp206c.c +++ b/drivers/iio/pressure/hp206c.c @@ -351,7 +351,6 @@ static const struct iio_info hp206c_info = { .attrs = &hp206c_attribute_group, .read_raw = hp206c_read_raw, .write_raw = hp206c_write_raw, - .driver_module = THIS_MODULE, }; static int hp206c_probe(struct i2c_client *client, diff --git a/drivers/iio/pressure/mpl115.c b/drivers/iio/pressure/mpl115.c index 8f2bce213248..ab4786d0102b 100644 --- a/drivers/iio/pressure/mpl115.c +++ b/drivers/iio/pressure/mpl115.c @@ -144,7 +144,6 @@ static const struct iio_chan_spec mpl115_channels[] = { static const struct iio_info mpl115_info = { .read_raw = &mpl115_read_raw, - .driver_module = THIS_MODULE, }; int mpl115_probe(struct device *dev, const char *name, diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c index 619b963714c7..7537547fb7ee 100644 --- a/drivers/iio/pressure/mpl3115.c +++ b/drivers/iio/pressure/mpl3115.c @@ -218,7 +218,6 @@ static const struct iio_chan_spec mpl3115_channels[] = { static const struct iio_info mpl3115_info = { .read_raw = &mpl3115_read_raw, - .driver_module = THIS_MODULE, }; static int mpl3115_probe(struct i2c_client *client, diff --git a/drivers/iio/pressure/ms5611_core.c b/drivers/iio/pressure/ms5611_core.c index 2a77a2f15752..f950cfde5db9 100644 --- a/drivers/iio/pressure/ms5611_core.c +++ b/drivers/iio/pressure/ms5611_core.c @@ -384,7 +384,6 @@ static const struct iio_info ms5611_info = { .read_raw = &ms5611_read_raw, .write_raw = &ms5611_write_raw, .attrs = &ms5611_attribute_group, - .driver_module = THIS_MODULE, }; static int ms5611_init(struct iio_dev *indio_dev) diff --git a/drivers/iio/pressure/ms5637.c b/drivers/iio/pressure/ms5637.c index c413f8a84a63..e2f73e6dc58f 100644 --- a/drivers/iio/pressure/ms5637.c +++ b/drivers/iio/pressure/ms5637.c @@ -124,7 +124,6 @@ static const struct iio_info ms5637_info = { .read_raw = ms5637_read_raw, .write_raw = ms5637_write_raw, .attrs = &ms5637_attribute_group, - .driver_module = THIS_MODULE, }; static int ms5637_probe(struct i2c_client *client, diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h index 7d995937adba..e67eb0d971bf 100644 --- a/drivers/iio/pressure/st_pressure.h +++ b/drivers/iio/pressure/st_pressure.h @@ -19,6 +19,8 @@ enum st_press_type { LPS25H, LPS331AP, LPS22HB, + LPS33HW, + LPS35HW, ST_PRESS_MAX, }; @@ -26,6 +28,8 @@ enum st_press_type { #define LPS25H_PRESS_DEV_NAME "lps25h" #define LPS331AP_PRESS_DEV_NAME "lps331ap" #define LPS22HB_PRESS_DEV_NAME "lps22hb" +#define LPS33HW_PRESS_DEV_NAME "lps33hw" +#define LPS35HW_PRESS_DEV_NAME "lps35hw" /** * struct st_sensors_platform_data - default press platform data diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 34611a8ea2ce..86120715913b 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -410,6 +410,8 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, .sensors_supported = { [0] = LPS22HB_PRESS_DEV_NAME, + [1] = LPS33HW_PRESS_DEV_NAME, + [2] = LPS35HW_PRESS_DEV_NAME, }, .ch = (struct iio_chan_spec *)st_press_lps22hb_channels, .num_ch = ARRAY_SIZE(st_press_lps22hb_channels), @@ -547,7 +549,6 @@ static const struct attribute_group st_press_attribute_group = { }; static const struct iio_info press_info = { - .driver_module = THIS_MODULE, .attrs = &st_press_attribute_group, .read_raw = &st_press_read_raw, .write_raw = &st_press_write_raw, @@ -556,7 +557,6 @@ static const struct iio_info press_info = { #ifdef CONFIG_IIO_TRIGGER static const struct iio_trigger_ops st_press_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = ST_PRESS_TRIGGER_SET_STATE, .validate_device = st_sensors_validate_device, }; diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c index 7f15e927fa2b..fbb59059e942 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c @@ -37,6 +37,14 @@ static const struct of_device_id st_press_of_match[] = { .compatible = "st,lps22hb-press", .data = LPS22HB_PRESS_DEV_NAME, }, + { + .compatible = "st,lps33hw", + .data = LPS33HW_PRESS_DEV_NAME, + }, + { + .compatible = "st,lps35hw", + .data = LPS35HW_PRESS_DEV_NAME, + }, {}, }; MODULE_DEVICE_TABLE(of, st_press_of_match); @@ -59,6 +67,8 @@ static const struct i2c_device_id st_press_id_table[] = { { LPS25H_PRESS_DEV_NAME, LPS25H }, { LPS331AP_PRESS_DEV_NAME, LPS331AP }, { LPS22HB_PRESS_DEV_NAME, LPS22HB }, + { LPS33HW_PRESS_DEV_NAME, LPS33HW }, + { LPS35HW_PRESS_DEV_NAME, LPS35HW }, {}, }; MODULE_DEVICE_TABLE(i2c, st_press_id_table); diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c index f5ebd36bb4bf..9a3441b128e7 100644 --- a/drivers/iio/pressure/st_pressure_spi.c +++ b/drivers/iio/pressure/st_pressure_spi.c @@ -41,6 +41,14 @@ static const struct of_device_id st_press_of_match[] = { .compatible = "st,lps22hb-press", .data = LPS22HB_PRESS_DEV_NAME, }, + { + .compatible = "st,lps33hw", + .data = LPS33HW_PRESS_DEV_NAME, + }, + { + .compatible = "st,lps35hw", + .data = LPS35HW_PRESS_DEV_NAME, + }, {}, }; MODULE_DEVICE_TABLE(of, st_press_of_match); @@ -83,6 +91,8 @@ static const struct spi_device_id st_press_id_table[] = { { LPS25H_PRESS_DEV_NAME }, { LPS331AP_PRESS_DEV_NAME }, { LPS22HB_PRESS_DEV_NAME }, + { LPS33HW_PRESS_DEV_NAME }, + { LPS35HW_PRESS_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(spi, st_press_id_table); diff --git a/drivers/iio/pressure/t5403.c b/drivers/iio/pressure/t5403.c index 2667e71721f5..92c00f603b1d 100644 --- a/drivers/iio/pressure/t5403.c +++ b/drivers/iio/pressure/t5403.c @@ -209,7 +209,6 @@ static const struct iio_info t5403_info = { .read_raw = &t5403_read_raw, .write_raw = &t5403_write_raw, .attrs = &t5403_attribute_group, - .driver_module = THIS_MODULE, }; static int t5403_probe(struct i2c_client *client, diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c index ebfb1de7377f..78dfbde62028 100644 --- a/drivers/iio/pressure/zpa2326.c +++ b/drivers/iio/pressure/zpa2326.c @@ -1394,7 +1394,6 @@ static int zpa2326_set_trigger_state(struct iio_trigger *trig, bool state) } static const struct iio_trigger_ops zpa2326_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = zpa2326_set_trigger_state, }; @@ -1594,7 +1593,6 @@ static const struct iio_chan_spec zpa2326_channels[] = { }; static const struct iio_info zpa2326_info = { - .driver_module = THIS_MODULE, .attrs = &zpa2326_attribute_group, .read_raw = zpa2326_read_raw, .write_raw = zpa2326_write_raw, diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c index 0eeff29b61be..8c6c8131a539 100644 --- a/drivers/iio/proximity/as3935.c +++ b/drivers/iio/proximity/as3935.c @@ -197,7 +197,6 @@ static int as3935_read_raw(struct iio_dev *indio_dev, } static const struct iio_info as3935_info = { - .driver_module = THIS_MODULE, .attrs = &as3935_attribute_group, .read_raw = &as3935_read_raw, }; @@ -223,7 +222,6 @@ err_read: } static const struct iio_trigger_ops iio_interrupt_trigger_ops = { - .owner = THIS_MODULE, }; static void as3935_event_work(struct work_struct *work) diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c index 36c1ddc251aa..4d56f67b24c6 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -249,7 +249,6 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private) } static const struct iio_info lidar_info = { - .driver_module = THIS_MODULE, .read_raw = lidar_read_raw, }; diff --git a/drivers/iio/proximity/srf04.c b/drivers/iio/proximity/srf04.c index e37667f933b3..09c7b9c095b0 100644 --- a/drivers/iio/proximity/srf04.c +++ b/drivers/iio/proximity/srf04.c @@ -203,7 +203,6 @@ static int srf04_read_raw(struct iio_dev *indio_dev, } static const struct iio_info srf04_iio_info = { - .driver_module = THIS_MODULE, .read_raw = srf04_read_raw, }; diff --git a/drivers/iio/proximity/srf08.c b/drivers/iio/proximity/srf08.c index 9380d545aab1..f2bf783f829a 100644 --- a/drivers/iio/proximity/srf08.c +++ b/drivers/iio/proximity/srf08.c @@ -436,7 +436,6 @@ static const struct iio_chan_spec srf08_channels[] = { static const struct iio_info srf08_info = { .read_raw = srf08_read_raw, .attrs = &srf08_attribute_group, - .driver_module = THIS_MODULE, }; /* @@ -445,7 +444,6 @@ static const struct iio_info srf08_info = { */ static const struct iio_info srf02_info = { .read_raw = srf08_read_raw, - .driver_module = THIS_MODULE, }; static int srf08_probe(struct i2c_client *client, diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c index f42b3a1c75ff..53c5d653e780 100644 --- a/drivers/iio/proximity/sx9500.c +++ b/drivers/iio/proximity/sx9500.c @@ -615,7 +615,6 @@ static const struct attribute_group sx9500_attribute_group = { }; static const struct iio_info sx9500_info = { - .driver_module = THIS_MODULE, .attrs = &sx9500_attribute_group, .read_raw = &sx9500_read_raw, .write_raw = &sx9500_write_raw, @@ -650,7 +649,6 @@ out: static const struct iio_trigger_ops sx9500_trigger_ops = { .set_trigger_state = sx9500_set_trigger_state, - .owner = THIS_MODULE, }; static irqreturn_t sx9500_trigger_handler(int irq, void *private) diff --git a/drivers/iio/temperature/hid-sensor-temperature.c b/drivers/iio/temperature/hid-sensor-temperature.c index c01efeca4002..beaf6fd3e337 100644 --- a/drivers/iio/temperature/hid-sensor-temperature.c +++ b/drivers/iio/temperature/hid-sensor-temperature.c @@ -123,7 +123,6 @@ static int temperature_write_raw(struct iio_dev *indio_dev, } static const struct iio_info temperature_info = { - .driver_module = THIS_MODULE, .read_raw = &temperature_read_raw, .write_raw = &temperature_write_raw, }; diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c index d70e2e53d6a7..e8b7e0b6c8ad 100644 --- a/drivers/iio/temperature/maxim_thermocouple.c +++ b/drivers/iio/temperature/maxim_thermocouple.c @@ -208,7 +208,6 @@ static int maxim_thermocouple_read_raw(struct iio_dev *indio_dev, } static const struct iio_info maxim_thermocouple_info = { - .driver_module = THIS_MODULE, .read_raw = maxim_thermocouple_read_raw, }; diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c index 2077eef4095c..d619e8634a00 100644 --- a/drivers/iio/temperature/mlx90614.c +++ b/drivers/iio/temperature/mlx90614.c @@ -400,7 +400,6 @@ static const struct iio_info mlx90614_info = { .write_raw = mlx90614_write_raw, .write_raw_get_fmt = mlx90614_write_raw_get_fmt, .attrs = &mlx90614_attr_group, - .driver_module = THIS_MODULE, }; #ifdef CONFIG_PM diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c index 18c9b43c02cb..a9b5b7cc7836 100644 --- a/drivers/iio/temperature/tmp006.c +++ b/drivers/iio/temperature/tmp006.c @@ -179,7 +179,6 @@ static const struct iio_info tmp006_info = { .read_raw = tmp006_read_raw, .write_raw = tmp006_write_raw, .attrs = &tmp006_attribute_group, - .driver_module = THIS_MODULE, }; static bool tmp006_check_identification(struct i2c_client *client) diff --git a/drivers/iio/temperature/tmp007.c b/drivers/iio/temperature/tmp007.c index 0615324d054c..0e3f2d432e10 100644 --- a/drivers/iio/temperature/tmp007.c +++ b/drivers/iio/temperature/tmp007.c @@ -426,7 +426,6 @@ static const struct iio_info tmp007_info = { .read_event_value = tmp007_read_thresh, .write_event_value = tmp007_write_thresh, .attrs = &tmp007_attribute_group, - .driver_module = THIS_MODULE, }; static bool tmp007_identify(struct i2c_client *client) diff --git a/drivers/iio/temperature/tsys01.c b/drivers/iio/temperature/tsys01.c index d8aa211d76e4..3799d007c8e7 100644 --- a/drivers/iio/temperature/tsys01.c +++ b/drivers/iio/temperature/tsys01.c @@ -111,7 +111,6 @@ static const struct iio_chan_spec tsys01_channels[] = { static const struct iio_info tsys01_info = { .read_raw = tsys01_read_raw, - .driver_module = THIS_MODULE, }; static bool tsys01_crc_valid(u16 *n_prom) diff --git a/drivers/iio/temperature/tsys02d.c b/drivers/iio/temperature/tsys02d.c index c0a19a000387..9b2e56fa5fd5 100644 --- a/drivers/iio/temperature/tsys02d.c +++ b/drivers/iio/temperature/tsys02d.c @@ -120,7 +120,6 @@ static const struct iio_info tsys02d_info = { .read_raw = tsys02d_read_raw, .write_raw = tsys02d_write_raw, .attrs = &tsys02d_attribute_group, - .driver_module = THIS_MODULE, }; static int tsys02d_probe(struct i2c_client *client, diff --git a/drivers/iio/trigger/iio-trig-hrtimer.c b/drivers/iio/trigger/iio-trig-hrtimer.c index a1cad6cc2e0f..3ee92160053f 100644 --- a/drivers/iio/trigger/iio-trig-hrtimer.c +++ b/drivers/iio/trigger/iio-trig-hrtimer.c @@ -114,7 +114,6 @@ static int iio_trig_hrtimer_set_state(struct iio_trigger *trig, bool state) } static const struct iio_trigger_ops iio_hrtimer_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = iio_trig_hrtimer_set_state, }; diff --git a/drivers/iio/trigger/iio-trig-interrupt.c b/drivers/iio/trigger/iio-trig-interrupt.c index e18f12b74610..171c4ed03543 100644 --- a/drivers/iio/trigger/iio-trig-interrupt.c +++ b/drivers/iio/trigger/iio-trig-interrupt.c @@ -29,7 +29,6 @@ static irqreturn_t iio_interrupt_trigger_poll(int irq, void *private) } static const struct iio_trigger_ops iio_interrupt_trigger_ops = { - .owner = THIS_MODULE, }; static int iio_interrupt_trigger_probe(struct platform_device *pdev) diff --git a/drivers/iio/trigger/iio-trig-loop.c b/drivers/iio/trigger/iio-trig-loop.c index dc6be28f96fe..b4b02dbd6e8a 100644 --- a/drivers/iio/trigger/iio-trig-loop.c +++ b/drivers/iio/trigger/iio-trig-loop.c @@ -74,7 +74,6 @@ static int iio_loop_trigger_set_state(struct iio_trigger *trig, bool state) static const struct iio_trigger_ops iio_loop_trigger_ops = { .set_trigger_state = iio_loop_trigger_set_state, - .owner = THIS_MODULE, }; static struct iio_sw_trigger *iio_trig_loop_probe(const char *name) diff --git a/drivers/iio/trigger/iio-trig-sysfs.c b/drivers/iio/trigger/iio-trig-sysfs.c index 202e8b89caf2..3f0dc9a1a514 100644 --- a/drivers/iio/trigger/iio-trig-sysfs.c +++ b/drivers/iio/trigger/iio-trig-sysfs.c @@ -127,7 +127,6 @@ static const struct attribute_group *iio_sysfs_trigger_attr_groups[] = { }; static const struct iio_trigger_ops iio_sysfs_trigger_ops = { - .owner = THIS_MODULE, }; static int iio_sysfs_trigger_probe(int id) diff --git a/drivers/iio/trigger/stm32-lptimer-trigger.c b/drivers/iio/trigger/stm32-lptimer-trigger.c index 241eae6a4306..de361d879929 100644 --- a/drivers/iio/trigger/stm32-lptimer-trigger.c +++ b/drivers/iio/trigger/stm32-lptimer-trigger.c @@ -37,7 +37,6 @@ static int stm32_lptim_validate_device(struct iio_trigger *trig, } static const struct iio_trigger_ops stm32_lptim_trigger_ops = { - .owner = THIS_MODULE, .validate_device = stm32_lptim_validate_device, }; diff --git a/drivers/iio/trigger/stm32-timer-trigger.c b/drivers/iio/trigger/stm32-timer-trigger.c index eb212f8c8879..b542dc484969 100644 --- a/drivers/iio/trigger/stm32-timer-trigger.c +++ b/drivers/iio/trigger/stm32-timer-trigger.c @@ -355,7 +355,6 @@ static const struct attribute_group *stm32_trigger_attr_groups[] = { }; static const struct iio_trigger_ops timer_trigger_ops = { - .owner = THIS_MODULE, }; static int stm32_setup_iio_triggers(struct stm32_timer_trigger *priv) @@ -493,7 +492,6 @@ static int stm32_counter_validate_trigger(struct iio_dev *indio_dev, } static const struct iio_info stm32_trigger_info = { - .driver_module = THIS_MODULE, .validate_trigger = stm32_counter_validate_trigger, .read_raw = stm32_counter_read_raw, .write_raw = stm32_counter_write_raw diff --git a/drivers/input/touchscreen/tsc2007_iio.c b/drivers/input/touchscreen/tsc2007_iio.c index 27b25a9fce83..e27a956f5f2b 100644 --- a/drivers/input/touchscreen/tsc2007_iio.c +++ b/drivers/input/touchscreen/tsc2007_iio.c @@ -104,7 +104,6 @@ static int tsc2007_read_raw(struct iio_dev *indio_dev, static const struct iio_info tsc2007_iio_info = { .read_raw = tsc2007_read_raw, - .driver_module = THIS_MODULE, }; int tsc2007_iio_configure(struct tsc2007 *ts) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 8136dc7e863d..f1a5c2357b14 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -393,16 +393,6 @@ config SPEAR13XX_PCIE_GADGET entry will be created for that controller. User can use these sysfs node to configure PCIe EP as per his requirements. -config TI_DAC7512 - tristate "Texas Instruments DAC7512" - depends on SPI && SYSFS - help - If you say yes here you get support for the Texas Instruments - DAC7512 16-bit digital-to-analog converter. - - This driver can also be built as a module. If so, the module - will be called ti_dac7512. - config VMWARE_BALLOON tristate "VMware Balloon Driver" depends on VMWARE_VMCI && X86 && HYPERVISOR_GUEST diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index d84819dc2468..9f80b1e9bae1 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -30,7 +30,6 @@ obj-$(CONFIG_ISL29003) += isl29003.o obj-$(CONFIG_ISL29020) += isl29020.o obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o obj-$(CONFIG_DS1682) += ds1682.o -obj-$(CONFIG_TI_DAC7512) += ti_dac7512.o obj-$(CONFIG_C2PORT) += c2port/ obj-$(CONFIG_HMC6352) += hmc6352.o obj-y += eeprom/ diff --git a/drivers/misc/ti_dac7512.c b/drivers/misc/ti_dac7512.c deleted file mode 100644 index f5456fb7d773..000000000000 --- a/drivers/misc/ti_dac7512.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * dac7512.c - Linux kernel module for - * Texas Instruments DAC7512 - * - * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de> - * - * 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <linux/module.h> -#include <linux/spi/spi.h> -#include <linux/of.h> - -static ssize_t dac7512_store_val(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct spi_device *spi = to_spi_device(dev); - unsigned char tmp[2]; - unsigned long val; - int ret; - - ret = kstrtoul(buf, 10, &val); - if (ret) - return ret; - - tmp[0] = val >> 8; - tmp[1] = val & 0xff; - spi_write(spi, tmp, sizeof(tmp)); - return count; -} - -static DEVICE_ATTR(value, S_IWUSR, NULL, dac7512_store_val); - -static struct attribute *dac7512_attributes[] = { - &dev_attr_value.attr, - NULL -}; - -static const struct attribute_group dac7512_attr_group = { - .attrs = dac7512_attributes, -}; - -static int dac7512_probe(struct spi_device *spi) -{ - int ret; - - spi->bits_per_word = 8; - spi->mode = SPI_MODE_0; - ret = spi_setup(spi); - if (ret < 0) - return ret; - - return sysfs_create_group(&spi->dev.kobj, &dac7512_attr_group); -} - -static int dac7512_remove(struct spi_device *spi) -{ - sysfs_remove_group(&spi->dev.kobj, &dac7512_attr_group); - return 0; -} - -static const struct spi_device_id dac7512_id_table[] = { - { "dac7512", 0 }, - { } -}; -MODULE_DEVICE_TABLE(spi, dac7512_id_table); - -#ifdef CONFIG_OF -static const struct of_device_id dac7512_of_match[] = { - { .compatible = "ti,dac7512", }, - { } -}; -MODULE_DEVICE_TABLE(of, dac7512_of_match); -#endif - -static struct spi_driver dac7512_driver = { - .driver = { - .name = "dac7512", - .of_match_table = of_match_ptr(dac7512_of_match), - }, - .probe = dac7512_probe, - .remove = dac7512_remove, - .id_table = dac7512_id_table, -}; - -module_spi_driver(dac7512_driver); - -MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>"); -MODULE_DESCRIPTION("DAC7512 16-bit DAC"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c index bb1dcd7fbdeb..e8d058c5ef21 100644 --- a/drivers/platform/x86/toshiba_acpi.c +++ b/drivers/platform/x86/toshiba_acpi.c @@ -2510,7 +2510,6 @@ static const struct iio_chan_spec toshiba_iio_accel_channels[] = { }; static const struct iio_info toshiba_iio_accel_info = { - .driver_module = THIS_MODULE, .read_raw = &toshiba_iio_accel_read_raw, }; diff --git a/drivers/staging/android/TODO b/drivers/staging/android/TODO index 5f14247392bf..687e0eac85bf 100644 --- a/drivers/staging/android/TODO +++ b/drivers/staging/android/TODO @@ -1,5 +1,4 @@ TODO: - - checkpatch.pl cleanups - sparse fixes - rename files to be not so "generic" - add proper arch dependencies as needed diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h index 621e5f7ceacb..f5f9cd63f8e9 100644 --- a/drivers/staging/android/ion/ion.h +++ b/drivers/staging/android/ion/ion.h @@ -86,6 +86,7 @@ struct ion_buffer { struct sg_table *sg_table; struct list_head attachments; }; + void ion_buffer_destroy(struct ion_buffer *buffer); /** @@ -299,7 +300,6 @@ size_t ion_heap_freelist_shrink(struct ion_heap *heap, */ size_t ion_heap_freelist_size(struct ion_heap *heap); - /** * functions for creating and destroying a heap pool -- allows you * to keep a pool of pre allocated memory to use from your heap. Keeping diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c index 5abe6b24ff8c..ba0954e4d2e5 100644 --- a/drivers/staging/ccree/ssi_aead.c +++ b/drivers/staging/ccree/ssi_aead.c @@ -92,18 +92,17 @@ static inline bool valid_assoclen(struct aead_request *req) static void ssi_aead_exit(struct crypto_aead *tfm) { - struct device *dev = NULL; struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); + struct device *dev = drvdata_to_dev(ctx->drvdata); - SSI_LOG_DEBUG("Clearing context @%p for %s\n", - crypto_aead_ctx(tfm), crypto_tfm_alg_name(&tfm->base)); + dev_dbg(dev, "Clearing context @%p for %s\n", crypto_aead_ctx(tfm), + crypto_tfm_alg_name(&tfm->base)); - dev = &ctx->drvdata->plat_dev->dev; /* Unmap enckey buffer */ if (ctx->enckey) { dma_free_coherent(dev, AES_MAX_KEY_SIZE, ctx->enckey, ctx->enckey_dma_addr); - SSI_LOG_DEBUG("Freed enckey DMA buffer enckey_dma_addr=%pad\n", - ctx->enckey_dma_addr); + dev_dbg(dev, "Freed enckey DMA buffer enckey_dma_addr=%pad\n", + &ctx->enckey_dma_addr); ctx->enckey_dma_addr = 0; ctx->enckey = NULL; } @@ -116,8 +115,8 @@ static void ssi_aead_exit(struct crypto_aead *tfm) xcbc->xcbc_keys, xcbc->xcbc_keys_dma_addr); } - SSI_LOG_DEBUG("Freed xcbc_keys DMA buffer xcbc_keys_dma_addr=%pad\n", - xcbc->xcbc_keys_dma_addr); + dev_dbg(dev, "Freed xcbc_keys DMA buffer xcbc_keys_dma_addr=%pad\n", + &xcbc->xcbc_keys_dma_addr); xcbc->xcbc_keys_dma_addr = 0; xcbc->xcbc_keys = NULL; } else if (ctx->auth_mode != DRV_HASH_NULL) { /* HMAC auth. */ @@ -127,8 +126,8 @@ static void ssi_aead_exit(struct crypto_aead *tfm) dma_free_coherent(dev, 2 * MAX_HMAC_DIGEST_SIZE, hmac->ipad_opad, hmac->ipad_opad_dma_addr); - SSI_LOG_DEBUG("Freed ipad_opad DMA buffer ipad_opad_dma_addr=%pad\n", - hmac->ipad_opad_dma_addr); + dev_dbg(dev, "Freed ipad_opad DMA buffer ipad_opad_dma_addr=%pad\n", + &hmac->ipad_opad_dma_addr); hmac->ipad_opad_dma_addr = 0; hmac->ipad_opad = NULL; } @@ -136,8 +135,8 @@ static void ssi_aead_exit(struct crypto_aead *tfm) dma_free_coherent(dev, MAX_HMAC_BLOCK_SIZE, hmac->padded_authkey, hmac->padded_authkey_dma_addr); - SSI_LOG_DEBUG("Freed padded_authkey DMA buffer padded_authkey_dma_addr=%pad\n", - hmac->padded_authkey_dma_addr); + dev_dbg(dev, "Freed padded_authkey DMA buffer padded_authkey_dma_addr=%pad\n", + &hmac->padded_authkey_dma_addr); hmac->padded_authkey_dma_addr = 0; hmac->padded_authkey = NULL; } @@ -146,29 +145,31 @@ static void ssi_aead_exit(struct crypto_aead *tfm) static int ssi_aead_init(struct crypto_aead *tfm) { - struct device *dev; struct aead_alg *alg = crypto_aead_alg(tfm); struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); struct ssi_crypto_alg *ssi_alg = container_of(alg, struct ssi_crypto_alg, aead_alg); - SSI_LOG_DEBUG("Initializing context @%p for %s\n", ctx, crypto_tfm_alg_name(&tfm->base)); + struct device *dev = drvdata_to_dev(ssi_alg->drvdata); + + dev_dbg(dev, "Initializing context @%p for %s\n", ctx, + crypto_tfm_alg_name(&tfm->base)); /* Initialize modes in instance */ ctx->cipher_mode = ssi_alg->cipher_mode; ctx->flow_mode = ssi_alg->flow_mode; ctx->auth_mode = ssi_alg->auth_mode; ctx->drvdata = ssi_alg->drvdata; - dev = &ctx->drvdata->plat_dev->dev; crypto_aead_set_reqsize(tfm, sizeof(struct aead_req_ctx)); /* Allocate key buffer, cache line aligned */ ctx->enckey = dma_alloc_coherent(dev, AES_MAX_KEY_SIZE, &ctx->enckey_dma_addr, GFP_KERNEL); if (!ctx->enckey) { - SSI_LOG_ERR("Failed allocating key buffer\n"); + dev_err(dev, "Failed allocating key buffer\n"); goto init_failed; } - SSI_LOG_DEBUG("Allocated enckey buffer in context ctx->enckey=@%p\n", ctx->enckey); + dev_dbg(dev, "Allocated enckey buffer in context ctx->enckey=@%p\n", + ctx->enckey); /* Set default authlen value */ @@ -182,7 +183,7 @@ static int ssi_aead_init(struct crypto_aead *tfm) &xcbc->xcbc_keys_dma_addr, GFP_KERNEL); if (!xcbc->xcbc_keys) { - SSI_LOG_ERR("Failed allocating buffer for XCBC keys\n"); + dev_err(dev, "Failed allocating buffer for XCBC keys\n"); goto init_failed; } } else if (ctx->auth_mode != DRV_HASH_NULL) { /* HMAC authentication */ @@ -196,12 +197,12 @@ static int ssi_aead_init(struct crypto_aead *tfm) GFP_KERNEL); if (!hmac->ipad_opad) { - SSI_LOG_ERR("Failed allocating IPAD/OPAD buffer\n"); + dev_err(dev, "Failed allocating IPAD/OPAD buffer\n"); goto init_failed; } - SSI_LOG_DEBUG("Allocated authkey buffer in context ctx->authkey=@%p\n", - hmac->ipad_opad); + dev_dbg(dev, "Allocated authkey buffer in context ctx->authkey=@%p\n", + hmac->ipad_opad); hmac->padded_authkey = dma_alloc_coherent(dev, MAX_HMAC_BLOCK_SIZE, @@ -209,7 +210,7 @@ static int ssi_aead_init(struct crypto_aead *tfm) GFP_KERNEL); if (!hmac->padded_authkey) { - SSI_LOG_ERR("failed to allocate padded_authkey\n"); + dev_err(dev, "failed to allocate padded_authkey\n"); goto init_failed; } } else { @@ -240,8 +241,7 @@ static void ssi_aead_complete(struct device *dev, void *ssi_req, void __iomem *c if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) { if (memcmp(areq_ctx->mac_buf, areq_ctx->icv_virt_addr, ctx->authsize) != 0) { - SSI_LOG_DEBUG("Payload authentication failure, " - "(auth-size=%d, cipher=%d).\n", + dev_dbg(dev, "Payload authentication failure, (auth-size=%d, cipher=%d)\n", ctx->authsize, ctx->cipher_mode); /* In case of payload authentication failure, MUST NOT * revealed the decrypted message --> zero its memory. @@ -252,8 +252,11 @@ static void ssi_aead_complete(struct device *dev, void *ssi_req, void __iomem *c } else { /*ENCRYPT*/ if (unlikely(areq_ctx->is_icv_fragmented)) ssi_buffer_mgr_copy_scatterlist_portion( - areq_ctx->mac_buf, areq_ctx->dst_sgl, areq->cryptlen + areq_ctx->dst_offset, - areq->cryptlen + areq_ctx->dst_offset + ctx->authsize, SSI_SG_FROM_BUF); + dev, areq_ctx->mac_buf, areq_ctx->dst_sgl, + areq->cryptlen + areq_ctx->dst_offset, + (areq->cryptlen + areq_ctx->dst_offset + + ctx->authsize), + SSI_SG_FROM_BUF); /* If an IV was generated, copy it back to the user provided buffer. */ if (areq_ctx->backup_giv) { @@ -377,8 +380,10 @@ static int hmac_setkey(struct cc_hw_desc *desc, struct ssi_aead_ctx *ctx) static int validate_keys_sizes(struct ssi_aead_ctx *ctx) { - SSI_LOG_DEBUG("enc_keylen=%u authkeylen=%u\n", - ctx->enc_keylen, ctx->auth_keylen); + struct device *dev = drvdata_to_dev(ctx->drvdata); + + dev_dbg(dev, "enc_keylen=%u authkeylen=%u\n", + ctx->enc_keylen, ctx->auth_keylen); switch (ctx->auth_mode) { case DRV_HASH_SHA1: @@ -395,22 +400,22 @@ static int validate_keys_sizes(struct ssi_aead_ctx *ctx) return -EINVAL; break; default: - SSI_LOG_ERR("Invalid auth_mode=%d\n", ctx->auth_mode); + dev_err(dev, "Invalid auth_mode=%d\n", ctx->auth_mode); return -EINVAL; } /* Check cipher key size */ if (unlikely(ctx->flow_mode == S_DIN_to_DES)) { if (ctx->enc_keylen != DES3_EDE_KEY_SIZE) { - SSI_LOG_ERR("Invalid cipher(3DES) key size: %u\n", - ctx->enc_keylen); + dev_err(dev, "Invalid cipher(3DES) key size: %u\n", + ctx->enc_keylen); return -EINVAL; } } else { /* Default assumed to be AES ciphers */ if ((ctx->enc_keylen != AES_KEYSIZE_128) && (ctx->enc_keylen != AES_KEYSIZE_192) && (ctx->enc_keylen != AES_KEYSIZE_256)) { - SSI_LOG_ERR("Invalid cipher(AES) key size: %u\n", - ctx->enc_keylen); + dev_err(dev, "Invalid cipher(AES) key size: %u\n", + ctx->enc_keylen); return -EINVAL; } } @@ -426,7 +431,7 @@ ssi_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *key, unsigned int keyl { dma_addr_t key_dma_addr = 0; struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); u32 larval_addr = ssi_ahash_get_larval_digest_sram_addr( ctx->drvdata, ctx->auth_mode); struct ssi_crypto_req ssi_req = {}; @@ -455,8 +460,8 @@ ssi_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *key, unsigned int keyl if (likely(keylen != 0)) { key_dma_addr = dma_map_single(dev, (void *)key, keylen, DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, key_dma_addr))) { - SSI_LOG_ERR("Mapping key va=0x%p len=%u for" - " DMA failed\n", key, keylen); + dev_err(dev, "Mapping key va=0x%p len=%u for DMA failed\n", + key, keylen); return -ENOMEM; } if (keylen > blocksize) { @@ -534,7 +539,7 @@ ssi_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *key, unsigned int keyl rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); if (unlikely(rc != 0)) - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); if (likely(key_dma_addr != 0)) dma_unmap_single(dev, key_dma_addr, keylen, DMA_TO_DEVICE); @@ -551,10 +556,10 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) struct crypto_authenc_key_param *param; struct cc_hw_desc desc[MAX_AEAD_SETKEY_SEQ]; int seq_len = 0, rc = -EINVAL; + struct device *dev = drvdata_to_dev(ctx->drvdata); - SSI_LOG_DEBUG("Setting key in context @%p for %s. key=%p keylen=%u\n", - ctx, crypto_tfm_alg_name(crypto_aead_tfm(tfm)), - key, keylen); + dev_dbg(dev, "Setting key in context @%p for %s. key=%p keylen=%u\n", + ctx, crypto_tfm_alg_name(crypto_aead_tfm(tfm)), key, keylen); /* STAT_PHASE_0: Init and sanity checks */ @@ -622,7 +627,7 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) case DRV_HASH_NULL: /* non-authenc modes, e.g., CCM */ break; /* No auth. key setup */ default: - SSI_LOG_ERR("Unsupported authenc (%d)\n", ctx->auth_mode); + dev_err(dev, "Unsupported authenc (%d)\n", ctx->auth_mode); rc = -ENOTSUPP; goto badkey; } @@ -632,7 +637,7 @@ ssi_aead_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) if (seq_len > 0) { /* For CCM there is no sequence to setup the key */ rc = send_request(ctx->drvdata, &ssi_req, desc, seq_len, 0); if (unlikely(rc != 0)) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); goto setkey_error; } } @@ -651,7 +656,6 @@ setkey_error: static int ssi_rfc4309_ccm_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) { struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); - int rc = 0; if (keylen < 3) return -EINVAL; @@ -659,9 +663,7 @@ static int ssi_rfc4309_ccm_setkey(struct crypto_aead *tfm, const u8 *key, unsign keylen -= 3; memcpy(ctx->ctr_nonce, key + keylen, 3); - rc = ssi_aead_setkey(tfm, key, keylen); - - return rc; + return ssi_aead_setkey(tfm, key, keylen); } #endif /*SSI_CC_HAS_AES_CCM*/ @@ -670,6 +672,7 @@ static int ssi_aead_setauthsize( unsigned int authsize) { struct ssi_aead_ctx *ctx = crypto_aead_ctx(authenc); + struct device *dev = drvdata_to_dev(ctx->drvdata); /* Unsupported auth. sizes */ if ((authsize == 0) || @@ -678,7 +681,7 @@ static int ssi_aead_setauthsize( } ctx->authsize = authsize; - SSI_LOG_DEBUG("authlen=%d\n", ctx->authsize); + dev_dbg(dev, "authlen=%d\n", ctx->authsize); return 0; } @@ -731,10 +734,11 @@ ssi_aead_create_assoc_desc( struct aead_req_ctx *areq_ctx = aead_request_ctx(areq); enum ssi_req_dma_buf_type assoc_dma_type = areq_ctx->assoc_buff_type; unsigned int idx = *seq_size; + struct device *dev = drvdata_to_dev(ctx->drvdata); switch (assoc_dma_type) { case SSI_DMA_BUF_DLLI: - SSI_LOG_DEBUG("ASSOC buffer type DLLI\n"); + dev_dbg(dev, "ASSOC buffer type DLLI\n"); hw_desc_init(&desc[idx]); set_din_type(&desc[idx], DMA_DLLI, sg_dma_address(areq->src), areq->assoclen, NS_BIT); set_flow_mode(&desc[idx], @@ -744,7 +748,7 @@ ssi_aead_create_assoc_desc( set_din_not_last_indication(&desc[idx]); break; case SSI_DMA_BUF_MLLI: - SSI_LOG_DEBUG("ASSOC buffer type MLLI\n"); + dev_dbg(dev, "ASSOC buffer type MLLI\n"); hw_desc_init(&desc[idx]); set_din_type(&desc[idx], DMA_MLLI, areq_ctx->assoc.sram_addr, areq_ctx->assoc.mlli_nents, NS_BIT); @@ -755,7 +759,7 @@ ssi_aead_create_assoc_desc( break; case SSI_DMA_BUF_NULL: default: - SSI_LOG_ERR("Invalid ASSOC buffer type\n"); + dev_err(dev, "Invalid ASSOC buffer type\n"); } *seq_size = (++idx); @@ -772,6 +776,9 @@ ssi_aead_process_authenc_data_desc( struct aead_req_ctx *areq_ctx = aead_request_ctx(areq); enum ssi_req_dma_buf_type data_dma_type = areq_ctx->data_buff_type; unsigned int idx = *seq_size; + struct crypto_aead *tfm = crypto_aead_reqtfm(areq); + struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); + struct device *dev = drvdata_to_dev(ctx->drvdata); switch (data_dma_type) { case SSI_DMA_BUF_DLLI: @@ -783,7 +790,7 @@ ssi_aead_process_authenc_data_desc( unsigned int offset = (direct == DRV_CRYPTO_DIRECTION_ENCRYPT) ? areq_ctx->dst_offset : areq_ctx->src_offset; - SSI_LOG_DEBUG("AUTHENC: SRC/DST buffer type DLLI\n"); + dev_dbg(dev, "AUTHENC: SRC/DST buffer type DLLI\n"); hw_desc_init(&desc[idx]); set_din_type(&desc[idx], DMA_DLLI, (sg_dma_address(cipher) + offset), @@ -810,7 +817,7 @@ ssi_aead_process_authenc_data_desc( } } - SSI_LOG_DEBUG("AUTHENC: SRC/DST buffer type MLLI\n"); + dev_dbg(dev, "AUTHENC: SRC/DST buffer type MLLI\n"); hw_desc_init(&desc[idx]); set_din_type(&desc[idx], DMA_MLLI, mlli_addr, mlli_nents, NS_BIT); @@ -819,7 +826,7 @@ ssi_aead_process_authenc_data_desc( } case SSI_DMA_BUF_NULL: default: - SSI_LOG_ERR("AUTHENC: Invalid SRC/DST buffer type\n"); + dev_err(dev, "AUTHENC: Invalid SRC/DST buffer type\n"); } *seq_size = (++idx); @@ -835,13 +842,16 @@ ssi_aead_process_cipher_data_desc( unsigned int idx = *seq_size; struct aead_req_ctx *areq_ctx = aead_request_ctx(areq); enum ssi_req_dma_buf_type data_dma_type = areq_ctx->data_buff_type; + struct crypto_aead *tfm = crypto_aead_reqtfm(areq); + struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); + struct device *dev = drvdata_to_dev(ctx->drvdata); if (areq_ctx->cryptlen == 0) return; /*null processing*/ switch (data_dma_type) { case SSI_DMA_BUF_DLLI: - SSI_LOG_DEBUG("CIPHER: SRC/DST buffer type DLLI\n"); + dev_dbg(dev, "CIPHER: SRC/DST buffer type DLLI\n"); hw_desc_init(&desc[idx]); set_din_type(&desc[idx], DMA_DLLI, (sg_dma_address(areq_ctx->src_sgl) + @@ -853,7 +863,7 @@ ssi_aead_process_cipher_data_desc( set_flow_mode(&desc[idx], flow_mode); break; case SSI_DMA_BUF_MLLI: - SSI_LOG_DEBUG("CIPHER: SRC/DST buffer type MLLI\n"); + dev_dbg(dev, "CIPHER: SRC/DST buffer type MLLI\n"); hw_desc_init(&desc[idx]); set_din_type(&desc[idx], DMA_MLLI, areq_ctx->src.sram_addr, areq_ctx->src.mlli_nents, NS_BIT); @@ -863,7 +873,7 @@ ssi_aead_process_cipher_data_desc( break; case SSI_DMA_BUF_NULL: default: - SSI_LOG_ERR("CIPHER: Invalid SRC/DST buffer type\n"); + dev_err(dev, "CIPHER: Invalid SRC/DST buffer type\n"); } *seq_size = (++idx); @@ -1178,14 +1188,15 @@ static inline void ssi_aead_load_mlli_to_sram( struct aead_req_ctx *req_ctx = aead_request_ctx(req); struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); + struct device *dev = drvdata_to_dev(ctx->drvdata); if (unlikely( (req_ctx->assoc_buff_type == SSI_DMA_BUF_MLLI) || (req_ctx->data_buff_type == SSI_DMA_BUF_MLLI) || !req_ctx->is_single_pass)) { - SSI_LOG_DEBUG("Copy-to-sram: mlli_dma=%08x, mlli_size=%u\n", - (unsigned int)ctx->drvdata->mlli_sram_addr, - req_ctx->mlli_params.mlli_len); + dev_dbg(dev, "Copy-to-sram: mlli_dma=%08x, mlli_size=%u\n", + (unsigned int)ctx->drvdata->mlli_sram_addr, + req_ctx->mlli_params.mlli_len); /* Copy MLLI table host-to-sram */ hw_desc_init(&desc[*seq_size]); set_din_type(&desc[*seq_size], DMA_DLLI, @@ -1333,6 +1344,7 @@ static int validate_data_size(struct ssi_aead_ctx *ctx, struct aead_request *req) { struct aead_req_ctx *areq_ctx = aead_request_ctx(req); + struct device *dev = drvdata_to_dev(ctx->drvdata); unsigned int assoclen = req->assoclen; unsigned int cipherlen = (direct == DRV_CRYPTO_DIRECTION_DECRYPT) ? (req->cryptlen - ctx->authsize) : req->cryptlen; @@ -1371,7 +1383,7 @@ static int validate_data_size(struct ssi_aead_ctx *ctx, areq_ctx->is_single_pass = false; break; default: - SSI_LOG_ERR("Unexpected flow mode (%d)\n", ctx->flow_mode); + dev_err(dev, "Unexpected flow mode (%d)\n", ctx->flow_mode); goto data_size_err; } @@ -1554,6 +1566,7 @@ static int config_ccm_adata(struct aead_request *req) { struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); + struct device *dev = drvdata_to_dev(ctx->drvdata); struct aead_req_ctx *req_ctx = aead_request_ctx(req); //unsigned int size_of_a = 0, rem_a_size = 0; unsigned int lp = req->iv[0]; @@ -1575,7 +1588,7 @@ static int config_ccm_adata(struct aead_request *req) /* taken from crypto/ccm.c */ /* 2 <= L <= 8, so 1 <= L' <= 7. */ if (l < 2 || l > 8) { - SSI_LOG_ERR("illegal iv value %X\n", req->iv[0]); + dev_err(dev, "illegal iv value %X\n", req->iv[0]); return -EINVAL; } memcpy(b0, req->iv, AES_BLOCK_SIZE); @@ -1588,8 +1601,10 @@ static int config_ccm_adata(struct aead_request *req) *b0 |= 64; /* Enable bit 6 if Adata exists. */ rc = set_msg_len(b0 + 16 - l, cryptlen, l); /* Write L'. */ - if (rc != 0) + if (rc != 0) { + dev_err(dev, "message len overflow detected"); return rc; + } /* END of "taken from crypto/ccm.c" */ /* l(a) - size of associated data. */ @@ -1812,7 +1827,6 @@ static inline int ssi_aead_gcm( unsigned int *seq_size) { struct aead_req_ctx *req_ctx = aead_request_ctx(req); - unsigned int idx = *seq_size; unsigned int cipher_flow_mode; if (req_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) { @@ -1829,7 +1843,6 @@ static inline int ssi_aead_gcm( ssi_aead_create_assoc_desc(req, DIN_HASH, desc, seq_size); ssi_aead_gcm_setup_gctr_desc(req, desc, seq_size); ssi_aead_process_gcm_result_desc(req, desc, seq_size); - idx = *seq_size; return 0; } @@ -1844,7 +1857,6 @@ static inline int ssi_aead_gcm( ssi_aead_process_cipher_data_desc(req, cipher_flow_mode, desc, seq_size); ssi_aead_process_gcm_result_desc(req, desc, seq_size); - idx = *seq_size; return 0; } @@ -1861,13 +1873,13 @@ static inline void ssi_aead_dump_gcm( return; if (title) { - SSI_LOG_DEBUG("----------------------------------------------------------------------------------"); - SSI_LOG_DEBUG("%s\n", title); + dev_dbg(dev, "----------------------------------------------------------------------------------"); + dev_dbg(dev, "%s\n", title); } - SSI_LOG_DEBUG("cipher_mode %d, authsize %d, enc_keylen %d, assoclen %d, cryptlen %d\n", - ctx->cipher_mode, ctx->authsize, ctx->enc_keylen, - req->assoclen, req_ctx->cryptlen); + dev_dbg(dev, "cipher_mode %d, authsize %d, enc_keylen %d, assoclen %d, cryptlen %d\n", + ctx->cipher_mode, ctx->authsize, ctx->enc_keylen, + req->assoclen, req_ctx->cryptlen); if (ctx->enckey) dump_byte_array("mac key", ctx->enckey, 16); @@ -1897,6 +1909,7 @@ static int config_gcm_context(struct aead_request *req) struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); struct aead_req_ctx *req_ctx = aead_request_ctx(req); + struct device *dev = drvdata_to_dev(ctx->drvdata); unsigned int cryptlen = (req_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_ENCRYPT) ? @@ -1904,7 +1917,8 @@ static int config_gcm_context(struct aead_request *req) (req->cryptlen - ctx->authsize); __be32 counter = cpu_to_be32(2); - SSI_LOG_DEBUG("%s() cryptlen = %d, req->assoclen = %d ctx->authsize = %d\n", __func__, cryptlen, req->assoclen, ctx->authsize); + dev_dbg(dev, "%s() cryptlen = %d, req->assoclen = %d ctx->authsize = %d\n", + __func__, cryptlen, req->assoclen, ctx->authsize); memset(req_ctx->hkey, 0, AES_BLOCK_SIZE); @@ -1958,20 +1972,20 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); struct aead_req_ctx *areq_ctx = aead_request_ctx(req); - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); struct ssi_crypto_req ssi_req = {}; - SSI_LOG_DEBUG("%s context=%p req=%p iv=%p src=%p src_ofs=%d dst=%p dst_ofs=%d cryptolen=%d\n", - ((direct == DRV_CRYPTO_DIRECTION_ENCRYPT) ? "Encrypt" : "Decrypt"), - ctx, req, req->iv, sg_virt(req->src), req->src->offset, - sg_virt(req->dst), req->dst->offset, req->cryptlen); + dev_dbg(dev, "%s context=%p req=%p iv=%p src=%p src_ofs=%d dst=%p dst_ofs=%d cryptolen=%d\n", + ((direct == DRV_CRYPTO_DIRECTION_ENCRYPT) ? "Enc" : "Dec"), + ctx, req, req->iv, sg_virt(req->src), req->src->offset, + sg_virt(req->dst), req->dst->offset, req->cryptlen); /* STAT_PHASE_0: Init and sanity checks */ /* Check data length according to mode */ if (unlikely(validate_data_size(ctx, direct, req) != 0)) { - SSI_LOG_ERR("Unsupported crypt/assoc len %d/%d.\n", - req->cryptlen, req->assoclen); + dev_err(dev, "Unsupported crypt/assoc len %d/%d.\n", + req->cryptlen, req->assoclen); crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_BLOCK_LEN); return -EINVAL; } @@ -2017,7 +2031,8 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction if (ctx->cipher_mode == DRV_CIPHER_CCM) { rc = config_ccm_adata(req); if (unlikely(rc != 0)) { - SSI_LOG_ERR("config_ccm_adata() returned with a failure %d!", rc); + dev_dbg(dev, "config_ccm_adata() returned with a failure %d!", + rc); goto exit; } } else { @@ -2031,7 +2046,8 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction if (ctx->cipher_mode == DRV_CIPHER_GCTR) { rc = config_gcm_context(req); if (unlikely(rc != 0)) { - SSI_LOG_ERR("config_gcm_context() returned with a failure %d!", rc); + dev_dbg(dev, "config_gcm_context() returned with a failure %d!", + rc); goto exit; } } @@ -2039,7 +2055,7 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction rc = ssi_buffer_mgr_map_aead_request(ctx->drvdata, req); if (unlikely(rc != 0)) { - SSI_LOG_ERR("map_request() failed\n"); + dev_err(dev, "map_request() failed\n"); goto exit; } @@ -2095,7 +2111,7 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction break; #endif default: - SSI_LOG_ERR("Unsupported authenc (%d)\n", ctx->auth_mode); + dev_err(dev, "Unsupported authenc (%d)\n", ctx->auth_mode); ssi_buffer_mgr_unmap_aead_request(dev, req); rc = -ENOTSUPP; goto exit; @@ -2106,7 +2122,7 @@ static int ssi_aead_process(struct aead_request *req, enum drv_crypto_direction rc = send_request(ctx->drvdata, &ssi_req, desc, seq_len, 1); if (unlikely(rc != -EINPROGRESS)) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); ssi_buffer_mgr_unmap_aead_request(dev, req); } @@ -2139,10 +2155,13 @@ static int ssi_rfc4309_ccm_encrypt(struct aead_request *req) /* Very similar to ssi_aead_encrypt() above. */ struct aead_req_ctx *areq_ctx = aead_request_ctx(req); + struct crypto_aead *tfm = crypto_aead_reqtfm(req); + struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); + struct device *dev = drvdata_to_dev(ctx->drvdata); int rc = -EINVAL; if (!valid_assoclen(req)) { - SSI_LOG_ERR("invalid Assoclen:%u\n", req->assoclen); + dev_err(dev, "invalid Assoclen:%u\n", req->assoclen); goto out; } @@ -2183,13 +2202,14 @@ static int ssi_aead_decrypt(struct aead_request *req) #if SSI_CC_HAS_AES_CCM static int ssi_rfc4309_ccm_decrypt(struct aead_request *req) { - /* Very similar to ssi_aead_decrypt() above. */ - + struct crypto_aead *tfm = crypto_aead_reqtfm(req); + struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); + struct device *dev = drvdata_to_dev(ctx->drvdata); struct aead_req_ctx *areq_ctx = aead_request_ctx(req); int rc = -EINVAL; if (!valid_assoclen(req)) { - SSI_LOG_ERR("invalid Assoclen:%u\n", req->assoclen); + dev_err(dev, "invalid Assoclen:%u\n", req->assoclen); goto out; } @@ -2214,9 +2234,9 @@ out: static int ssi_rfc4106_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) { struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); - int rc = 0; + struct device *dev = drvdata_to_dev(ctx->drvdata); - SSI_LOG_DEBUG("%s() keylen %d, key %p\n", __func__, keylen, key); + dev_dbg(dev, "%s() keylen %d, key %p\n", __func__, keylen, key); if (keylen < 4) return -EINVAL; @@ -2224,17 +2244,15 @@ static int ssi_rfc4106_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsign keylen -= 4; memcpy(ctx->ctr_nonce, key + keylen, 4); - rc = ssi_aead_setkey(tfm, key, keylen); - - return rc; + return ssi_aead_setkey(tfm, key, keylen); } static int ssi_rfc4543_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) { struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); - int rc = 0; + struct device *dev = drvdata_to_dev(ctx->drvdata); - SSI_LOG_DEBUG("%s() keylen %d, key %p\n", __func__, keylen, key); + dev_dbg(dev, "%s() keylen %d, key %p\n", __func__, keylen, key); if (keylen < 4) return -EINVAL; @@ -2242,9 +2260,7 @@ static int ssi_rfc4543_gcm_setkey(struct crypto_aead *tfm, const u8 *key, unsign keylen -= 4; memcpy(ctx->ctr_nonce, key + keylen, 4); - rc = ssi_aead_setkey(tfm, key, keylen); - - return rc; + return ssi_aead_setkey(tfm, key, keylen); } static int ssi_gcm_setauthsize(struct crypto_aead *authenc, @@ -2269,7 +2285,10 @@ static int ssi_gcm_setauthsize(struct crypto_aead *authenc, static int ssi_rfc4106_gcm_setauthsize(struct crypto_aead *authenc, unsigned int authsize) { - SSI_LOG_DEBUG("authsize %d\n", authsize); + struct ssi_aead_ctx *ctx = crypto_aead_ctx(authenc); + struct device *dev = drvdata_to_dev(ctx->drvdata); + + dev_dbg(dev, "authsize %d\n", authsize); switch (authsize) { case 8: @@ -2286,7 +2305,10 @@ static int ssi_rfc4106_gcm_setauthsize(struct crypto_aead *authenc, static int ssi_rfc4543_gcm_setauthsize(struct crypto_aead *authenc, unsigned int authsize) { - SSI_LOG_DEBUG("authsize %d\n", authsize); + struct ssi_aead_ctx *ctx = crypto_aead_ctx(authenc); + struct device *dev = drvdata_to_dev(ctx->drvdata); + + dev_dbg(dev, "authsize %d\n", authsize); if (authsize != 16) return -EINVAL; @@ -2298,11 +2320,14 @@ static int ssi_rfc4106_gcm_encrypt(struct aead_request *req) { /* Very similar to ssi_aead_encrypt() above. */ + struct crypto_aead *tfm = crypto_aead_reqtfm(req); + struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); + struct device *dev = drvdata_to_dev(ctx->drvdata); struct aead_req_ctx *areq_ctx = aead_request_ctx(req); int rc = -EINVAL; if (!valid_assoclen(req)) { - SSI_LOG_ERR("invalid Assoclen:%u\n", req->assoclen); + dev_err(dev, "invalid Assoclen:%u\n", req->assoclen); goto out; } @@ -2350,11 +2375,14 @@ static int ssi_rfc4106_gcm_decrypt(struct aead_request *req) { /* Very similar to ssi_aead_decrypt() above. */ + struct crypto_aead *tfm = crypto_aead_reqtfm(req); + struct ssi_aead_ctx *ctx = crypto_aead_ctx(tfm); + struct device *dev = drvdata_to_dev(ctx->drvdata); struct aead_req_ctx *areq_ctx = aead_request_ctx(req); int rc = -EINVAL; if (!valid_assoclen(req)) { - SSI_LOG_ERR("invalid Assoclen:%u\n", req->assoclen); + dev_err(dev, "invalid Assoclen:%u\n", req->assoclen); goto out; } @@ -2654,16 +2682,17 @@ static struct ssi_alg_template aead_algs[] = { #endif /*SSI_CC_HAS_AES_GCM*/ }; -static struct ssi_crypto_alg *ssi_aead_create_alg(struct ssi_alg_template *template) +static struct ssi_crypto_alg *ssi_aead_create_alg( + struct ssi_alg_template *template, + struct device *dev) { struct ssi_crypto_alg *t_alg; struct aead_alg *alg; t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL); - if (!t_alg) { - SSI_LOG_ERR("failed to allocate t_alg\n"); + if (!t_alg) return ERR_PTR(-ENOMEM); - } + alg = &template->template_aead; snprintf(alg->base.cra_name, CRYPTO_MAX_ALG_NAME, "%s", template->name); @@ -2713,6 +2742,7 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata) struct ssi_crypto_alg *t_alg; int rc = -ENOMEM; int alg; + struct device *dev = drvdata_to_dev(drvdata); aead_handle = kmalloc(sizeof(*aead_handle), GFP_KERNEL); if (!aead_handle) { @@ -2720,36 +2750,36 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata) goto fail0; } + INIT_LIST_HEAD(&aead_handle->aead_list); drvdata->aead_handle = aead_handle; aead_handle->sram_workspace_addr = ssi_sram_mgr_alloc( drvdata, MAX_HMAC_DIGEST_SIZE); if (aead_handle->sram_workspace_addr == NULL_SRAM_ADDR) { - SSI_LOG_ERR("SRAM pool exhausted\n"); + dev_err(dev, "SRAM pool exhausted\n"); rc = -ENOMEM; goto fail1; } - INIT_LIST_HEAD(&aead_handle->aead_list); - /* Linux crypto */ for (alg = 0; alg < ARRAY_SIZE(aead_algs); alg++) { - t_alg = ssi_aead_create_alg(&aead_algs[alg]); + t_alg = ssi_aead_create_alg(&aead_algs[alg], dev); if (IS_ERR(t_alg)) { rc = PTR_ERR(t_alg); - SSI_LOG_ERR("%s alg allocation failed\n", - aead_algs[alg].driver_name); + dev_err(dev, "%s alg allocation failed\n", + aead_algs[alg].driver_name); goto fail1; } t_alg->drvdata = drvdata; rc = crypto_register_aead(&t_alg->aead_alg); if (unlikely(rc != 0)) { - SSI_LOG_ERR("%s alg registration failed\n", - t_alg->aead_alg.base.cra_driver_name); + dev_err(dev, "%s alg registration failed\n", + t_alg->aead_alg.base.cra_driver_name); goto fail2; } else { list_add_tail(&t_alg->entry, &aead_handle->aead_list); - SSI_LOG_DEBUG("Registered %s\n", t_alg->aead_alg.base.cra_driver_name); + dev_dbg(dev, "Registered %s\n", + t_alg->aead_alg.base.cra_driver_name); } } diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 63936091d524..dca3ce84d043 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -33,14 +33,10 @@ #include "ssi_hash.h" #include "ssi_aead.h" -#ifdef CC_DEBUG #define GET_DMA_BUFFER_TYPE(buff_type) ( \ ((buff_type) == SSI_DMA_BUF_NULL) ? "BUF_NULL" : \ ((buff_type) == SSI_DMA_BUF_DLLI) ? "BUF_DLLI" : \ ((buff_type) == SSI_DMA_BUF_MLLI) ? "BUF_MLLI" : "BUF_INVALID") -#else -#define GET_DMA_BUFFER_TYPE(buff_type) -#endif enum dma_buffer_type { DMA_NULL_TYPE = -1, @@ -76,16 +72,12 @@ struct buffer_array { * @lbytes: [OUT] Returns the amount of bytes at the last entry */ static unsigned int ssi_buffer_mgr_get_sgl_nents( - struct scatterlist *sg_list, unsigned int nbytes, u32 *lbytes, bool *is_chained) + struct device *dev, struct scatterlist *sg_list, + unsigned int nbytes, u32 *lbytes, bool *is_chained) { unsigned int nents = 0; while (nbytes != 0) { - if (sg_is_chain(sg_list)) { - SSI_LOG_ERR("Unexpected chained entry " - "in sg (entry =0x%X)\n", nents); - BUG(); - } if (sg_list->length != 0) { nents++; /* get the number of bytes in the last entry */ @@ -98,7 +90,7 @@ static unsigned int ssi_buffer_mgr_get_sgl_nents( *is_chained = true; } } - SSI_LOG_DEBUG("nents %d last bytes %d\n", nents, *lbytes); + dev_dbg(dev, "nents %d last bytes %d\n", nents, *lbytes); return nents; } @@ -134,20 +126,20 @@ void ssi_buffer_mgr_zero_sgl(struct scatterlist *sgl, u32 data_len) * @direct: */ void ssi_buffer_mgr_copy_scatterlist_portion( - u8 *dest, struct scatterlist *sg, - u32 to_skip, u32 end, - enum ssi_sg_cpy_direct direct) + struct device *dev, u8 *dest, + struct scatterlist *sg, u32 to_skip, + u32 end, enum ssi_sg_cpy_direct direct) { u32 nents, lbytes; - nents = ssi_buffer_mgr_get_sgl_nents(sg, end, &lbytes, NULL); + nents = ssi_buffer_mgr_get_sgl_nents(dev, sg, end, &lbytes, NULL); sg_copy_buffer(sg, nents, (void *)dest, (end - to_skip + 1), to_skip, (direct == SSI_SG_TO_BUF)); } static inline int ssi_buffer_mgr_render_buff_to_mlli( - dma_addr_t buff_dma, u32 buff_size, u32 *curr_nents, - u32 **mlli_entry_pp) + struct device *dev, dma_addr_t buff_dma, u32 buff_size, + u32 *curr_nents, u32 **mlli_entry_pp) { u32 *mlli_entry_p = *mlli_entry_pp; u32 new_nents; @@ -161,9 +153,9 @@ static inline int ssi_buffer_mgr_render_buff_to_mlli( while (buff_size > CC_MAX_MLLI_ENTRY_SIZE) { cc_lli_set_addr(mlli_entry_p, buff_dma); cc_lli_set_size(mlli_entry_p, CC_MAX_MLLI_ENTRY_SIZE); - SSI_LOG_DEBUG("entry[%d]: single_buff=0x%08X size=%08X\n", *curr_nents, - mlli_entry_p[LLI_WORD0_OFFSET], - mlli_entry_p[LLI_WORD1_OFFSET]); + dev_dbg(dev, "entry[%d]: single_buff=0x%08X size=%08X\n", + *curr_nents, mlli_entry_p[LLI_WORD0_OFFSET], + mlli_entry_p[LLI_WORD1_OFFSET]); buff_dma += CC_MAX_MLLI_ENTRY_SIZE; buff_size -= CC_MAX_MLLI_ENTRY_SIZE; mlli_entry_p = mlli_entry_p + 2; @@ -172,9 +164,9 @@ static inline int ssi_buffer_mgr_render_buff_to_mlli( /*Last entry */ cc_lli_set_addr(mlli_entry_p, buff_dma); cc_lli_set_size(mlli_entry_p, buff_size); - SSI_LOG_DEBUG("entry[%d]: single_buff=0x%08X size=%08X\n", *curr_nents, - mlli_entry_p[LLI_WORD0_OFFSET], - mlli_entry_p[LLI_WORD1_OFFSET]); + dev_dbg(dev, "entry[%d]: single_buff=0x%08X size=%08X\n", + *curr_nents, mlli_entry_p[LLI_WORD0_OFFSET], + mlli_entry_p[LLI_WORD1_OFFSET]); mlli_entry_p = mlli_entry_p + 2; *mlli_entry_pp = mlli_entry_p; (*curr_nents)++; @@ -182,8 +174,9 @@ static inline int ssi_buffer_mgr_render_buff_to_mlli( } static inline int ssi_buffer_mgr_render_scatterlist_to_mlli( - struct scatterlist *sgl, u32 sgl_data_len, u32 sgl_offset, - u32 *curr_nents, u32 **mlli_entry_pp) + struct device *dev, struct scatterlist *sgl, + u32 sgl_data_len, u32 sgl_offset, u32 *curr_nents, + u32 **mlli_entry_pp) { struct scatterlist *curr_sgl = sgl; u32 *mlli_entry_p = *mlli_entry_pp; @@ -197,8 +190,8 @@ static inline int ssi_buffer_mgr_render_scatterlist_to_mlli( sgl_data_len; sgl_data_len -= entry_data_len; rc = ssi_buffer_mgr_render_buff_to_mlli( - sg_dma_address(curr_sgl) + sgl_offset, entry_data_len, - curr_nents, &mlli_entry_p); + dev, sg_dma_address(curr_sgl) + sgl_offset, + entry_data_len, curr_nents, &mlli_entry_p); if (rc != 0) return rc; @@ -217,14 +210,14 @@ static int ssi_buffer_mgr_generate_mlli( u32 total_nents = 0, prev_total_nents = 0; int rc = 0, i; - SSI_LOG_DEBUG("NUM of SG's = %d\n", sg_data->num_of_buffers); + dev_dbg(dev, "NUM of SG's = %d\n", sg_data->num_of_buffers); /* Allocate memory from the pointed pool */ mlli_params->mlli_virt_addr = dma_pool_alloc( mlli_params->curr_pool, GFP_KERNEL, &mlli_params->mlli_dma_addr); if (unlikely(!mlli_params->mlli_virt_addr)) { - SSI_LOG_ERR("dma_pool_alloc() failed\n"); + dev_err(dev, "dma_pool_alloc() failed\n"); rc = -ENOMEM; goto build_mlli_exit; } @@ -234,12 +227,12 @@ static int ssi_buffer_mgr_generate_mlli( for (i = 0; i < sg_data->num_of_buffers; i++) { if (sg_data->type[i] == DMA_SGL_TYPE) rc = ssi_buffer_mgr_render_scatterlist_to_mlli( - sg_data->entry[i].sgl, - sg_data->total_data_len[i], sg_data->offset[i], &total_nents, - &mlli_p); + dev, sg_data->entry[i].sgl, + sg_data->total_data_len[i], sg_data->offset[i], + &total_nents, &mlli_p); else /*DMA_BUFF_TYPE*/ rc = ssi_buffer_mgr_render_buff_to_mlli( - sg_data->entry[i].buffer_dma, + dev, sg_data->entry[i].buffer_dma, sg_data->total_data_len[i], &total_nents, &mlli_p); if (rc != 0) @@ -259,26 +252,23 @@ static int ssi_buffer_mgr_generate_mlli( /* Set MLLI size for the bypass operation */ mlli_params->mlli_len = (total_nents * LLI_ENTRY_BYTE_SIZE); - SSI_LOG_DEBUG("MLLI params: " - "virt_addr=%pK dma_addr=%pad mlli_len=0x%X\n", - mlli_params->mlli_virt_addr, - mlli_params->mlli_dma_addr, - mlli_params->mlli_len); + dev_dbg(dev, "MLLI params: virt_addr=%pK dma_addr=%pad mlli_len=0x%X\n", + mlli_params->mlli_virt_addr, &mlli_params->mlli_dma_addr, + mlli_params->mlli_len); build_mlli_exit: return rc; } static inline void ssi_buffer_mgr_add_buffer_entry( - struct buffer_array *sgl_data, + struct device *dev, struct buffer_array *sgl_data, dma_addr_t buffer_dma, unsigned int buffer_len, bool is_last_entry, u32 *mlli_nents) { unsigned int index = sgl_data->num_of_buffers; - SSI_LOG_DEBUG("index=%u single_buff=%pad " - "buffer_len=0x%08X is_last=%d\n", - index, buffer_dma, buffer_len, is_last_entry); + dev_dbg(dev, "index=%u single_buff=%pad buffer_len=0x%08X is_last=%d\n", + index, &buffer_dma, buffer_len, is_last_entry); sgl_data->nents[index] = 1; sgl_data->entry[index].buffer_dma = buffer_dma; sgl_data->offset[index] = 0; @@ -292,6 +282,7 @@ static inline void ssi_buffer_mgr_add_buffer_entry( } static inline void ssi_buffer_mgr_add_scatterlist_entry( + struct device *dev, struct buffer_array *sgl_data, unsigned int nents, struct scatterlist *sgl, @@ -302,8 +293,8 @@ static inline void ssi_buffer_mgr_add_scatterlist_entry( { unsigned int index = sgl_data->num_of_buffers; - SSI_LOG_DEBUG("index=%u nents=%u sgl=%pK data_len=0x%08X is_last=%d\n", - index, nents, sgl, data_len, is_last_table); + dev_dbg(dev, "index=%u nents=%u sgl=%pK data_len=0x%08X is_last=%d\n", + index, nents, sgl, data_len, is_last_table); sgl_data->nents[index] = nents; sgl_data->entry[index].sgl = sgl; sgl_data->offset[index] = data_offset; @@ -327,7 +318,7 @@ ssi_buffer_mgr_dma_map_sg(struct device *dev, struct scatterlist *sg, u32 nents, if (!l_sg) break; if (unlikely(dma_map_sg(dev, l_sg, 1, direction) != 1)) { - SSI_LOG_ERR("dma_map_page() sg buffer failed\n"); + dev_err(dev, "dma_map_page() sg buffer failed\n"); goto err; } l_sg = sg_next(l_sg); @@ -356,26 +347,22 @@ static int ssi_buffer_mgr_map_scatterlist( if (sg_is_last(sg)) { /* One entry only case -set to DLLI */ if (unlikely(dma_map_sg(dev, sg, 1, direction) != 1)) { - SSI_LOG_ERR("dma_map_sg() single buffer failed\n"); + dev_err(dev, "dma_map_sg() single buffer failed\n"); return -ENOMEM; } - SSI_LOG_DEBUG("Mapped sg: dma_address=%pad " - "page=%p addr=%pK offset=%u " - "length=%u\n", - sg_dma_address(sg), - sg_page(sg), - sg_virt(sg), - sg->offset, sg->length); + dev_dbg(dev, "Mapped sg: dma_address=%pad page=%p addr=%pK offset=%u length=%u\n", + &sg_dma_address(sg), sg_page(sg), sg_virt(sg), + sg->offset, sg->length); *lbytes = nbytes; *nents = 1; *mapped_nents = 1; } else { /*sg_is_last*/ - *nents = ssi_buffer_mgr_get_sgl_nents(sg, nbytes, lbytes, + *nents = ssi_buffer_mgr_get_sgl_nents(dev, sg, nbytes, lbytes, &is_chained); if (*nents > max_sg_nents) { *nents = 0; - SSI_LOG_ERR("Too many fragments. current %d max %d\n", - *nents, max_sg_nents); + dev_err(dev, "Too many fragments. current %d max %d\n", + *nents, max_sg_nents); return -ENOMEM; } if (!is_chained) { @@ -385,7 +372,7 @@ static int ssi_buffer_mgr_map_scatterlist( *mapped_nents = dma_map_sg(dev, sg, *nents, direction); if (unlikely(*mapped_nents == 0)) { *nents = 0; - SSI_LOG_ERR("dma_map_sg() sg buffer failed\n"); + dev_err(dev, "dma_map_sg() sg buffer failed\n"); return -ENOMEM; } } else { @@ -398,7 +385,7 @@ static int ssi_buffer_mgr_map_scatterlist( direction); if (unlikely(*mapped_nents != *nents)) { *nents = *mapped_nents; - SSI_LOG_ERR("dma_map_sg() sg buffer failed\n"); + dev_err(dev, "dma_map_sg() sg buffer failed\n"); return -ENOMEM; } } @@ -414,26 +401,22 @@ ssi_aead_handle_config_buf(struct device *dev, struct buffer_array *sg_data, unsigned int assoclen) { - SSI_LOG_DEBUG(" handle additional data config set to DLLI\n"); + dev_dbg(dev, " handle additional data config set to DLLI\n"); /* create sg for the current buffer */ sg_init_one(&areq_ctx->ccm_adata_sg, config_data, AES_BLOCK_SIZE + areq_ctx->ccm_hdr_size); if (unlikely(dma_map_sg(dev, &areq_ctx->ccm_adata_sg, 1, DMA_TO_DEVICE) != 1)) { - SSI_LOG_ERR("dma_map_sg() " - "config buffer failed\n"); + dev_err(dev, "dma_map_sg() config buffer failed\n"); return -ENOMEM; } - SSI_LOG_DEBUG("Mapped curr_buff: dma_address=%pad " - "page=%p addr=%pK " - "offset=%u length=%u\n", - sg_dma_address(&areq_ctx->ccm_adata_sg), - sg_page(&areq_ctx->ccm_adata_sg), - sg_virt(&areq_ctx->ccm_adata_sg), - areq_ctx->ccm_adata_sg.offset, - areq_ctx->ccm_adata_sg.length); + dev_dbg(dev, "Mapped curr_buff: dma_address=%pad page=%p addr=%pK offset=%u length=%u\n", + &sg_dma_address(&areq_ctx->ccm_adata_sg), + sg_page(&areq_ctx->ccm_adata_sg), + sg_virt(&areq_ctx->ccm_adata_sg), + areq_ctx->ccm_adata_sg.offset, areq_ctx->ccm_adata_sg.length); /* prepare for case of MLLI */ if (assoclen > 0) { - ssi_buffer_mgr_add_scatterlist_entry(sg_data, 1, + ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, 1, &areq_ctx->ccm_adata_sg, (AES_BLOCK_SIZE + areq_ctx->ccm_hdr_size), 0, false, NULL); @@ -447,28 +430,23 @@ static inline int ssi_ahash_handle_curr_buf(struct device *dev, u32 curr_buff_cnt, struct buffer_array *sg_data) { - SSI_LOG_DEBUG(" handle curr buff %x set to DLLI\n", curr_buff_cnt); + dev_dbg(dev, " handle curr buff %x set to DLLI\n", curr_buff_cnt); /* create sg for the current buffer */ sg_init_one(areq_ctx->buff_sg, curr_buff, curr_buff_cnt); if (unlikely(dma_map_sg(dev, areq_ctx->buff_sg, 1, DMA_TO_DEVICE) != 1)) { - SSI_LOG_ERR("dma_map_sg() " - "src buffer failed\n"); + dev_err(dev, "dma_map_sg() src buffer failed\n"); return -ENOMEM; } - SSI_LOG_DEBUG("Mapped curr_buff: dma_address=%pad " - "page=%p addr=%pK " - "offset=%u length=%u\n", - sg_dma_address(areq_ctx->buff_sg), - sg_page(areq_ctx->buff_sg), - sg_virt(areq_ctx->buff_sg), - areq_ctx->buff_sg->offset, - areq_ctx->buff_sg->length); + dev_dbg(dev, "Mapped curr_buff: dma_address=%pad page=%p addr=%pK offset=%u length=%u\n", + &sg_dma_address(areq_ctx->buff_sg), sg_page(areq_ctx->buff_sg), + sg_virt(areq_ctx->buff_sg), areq_ctx->buff_sg->offset, + areq_ctx->buff_sg->length); areq_ctx->data_dma_buf_type = SSI_DMA_BUF_DLLI; areq_ctx->curr_sg = areq_ctx->buff_sg; areq_ctx->in_nents = 0; /* prepare for case of MLLI */ - ssi_buffer_mgr_add_scatterlist_entry(sg_data, 1, areq_ctx->buff_sg, + ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, 1, areq_ctx->buff_sg, curr_buff_cnt, 0, false, NULL); return 0; } @@ -483,9 +461,8 @@ void ssi_buffer_mgr_unmap_blkcipher_request( struct blkcipher_req_ctx *req_ctx = (struct blkcipher_req_ctx *)ctx; if (likely(req_ctx->gen_ctx.iv_dma_addr != 0)) { - SSI_LOG_DEBUG("Unmapped iv: iv_dma_addr=%pad iv_size=%u\n", - req_ctx->gen_ctx.iv_dma_addr, - ivsize); + dev_dbg(dev, "Unmapped iv: iv_dma_addr=%pad iv_size=%u\n", + &req_ctx->gen_ctx.iv_dma_addr, ivsize); dma_unmap_single(dev, req_ctx->gen_ctx.iv_dma_addr, ivsize, req_ctx->is_giv ? DMA_BIDIRECTIONAL : @@ -499,11 +476,11 @@ void ssi_buffer_mgr_unmap_blkcipher_request( } dma_unmap_sg(dev, src, req_ctx->in_nents, DMA_BIDIRECTIONAL); - SSI_LOG_DEBUG("Unmapped req->src=%pK\n", sg_virt(src)); + dev_dbg(dev, "Unmapped req->src=%pK\n", sg_virt(src)); if (src != dst) { dma_unmap_sg(dev, dst, req_ctx->out_nents, DMA_BIDIRECTIONAL); - SSI_LOG_DEBUG("Unmapped req->dst=%pK\n", sg_virt(dst)); + dev_dbg(dev, "Unmapped req->dst=%pK\n", sg_virt(dst)); } } @@ -519,7 +496,7 @@ int ssi_buffer_mgr_map_blkcipher_request( struct blkcipher_req_ctx *req_ctx = (struct blkcipher_req_ctx *)ctx; struct mlli_params *mlli_params = &req_ctx->mlli_params; struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle; - struct device *dev = &drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(drvdata); struct buffer_array sg_data; u32 dummy = 0; int rc = 0; @@ -539,13 +516,12 @@ int ssi_buffer_mgr_map_blkcipher_request( DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, req_ctx->gen_ctx.iv_dma_addr))) { - SSI_LOG_ERR("Mapping iv %u B at va=%pK " - "for DMA failed\n", ivsize, info); + dev_err(dev, "Mapping iv %u B at va=%pK for DMA failed\n", + ivsize, info); return -ENOMEM; } - SSI_LOG_DEBUG("Mapped iv %u B at va=%pK to dma=%pad\n", - ivsize, info, - req_ctx->gen_ctx.iv_dma_addr); + dev_dbg(dev, "Mapped iv %u B at va=%pK to dma=%pad\n", + ivsize, info, &req_ctx->gen_ctx.iv_dma_addr); } else { req_ctx->gen_ctx.iv_dma_addr = 0; } @@ -567,7 +543,7 @@ int ssi_buffer_mgr_map_blkcipher_request( /* Handle inplace operation */ if (unlikely(req_ctx->dma_buf_type == SSI_DMA_BUF_MLLI)) { req_ctx->out_nents = 0; - ssi_buffer_mgr_add_scatterlist_entry(&sg_data, + ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data, req_ctx->in_nents, src, nbytes, 0, true, @@ -587,12 +563,12 @@ int ssi_buffer_mgr_map_blkcipher_request( req_ctx->dma_buf_type = SSI_DMA_BUF_MLLI; if (unlikely((req_ctx->dma_buf_type == SSI_DMA_BUF_MLLI))) { - ssi_buffer_mgr_add_scatterlist_entry(&sg_data, + ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data, req_ctx->in_nents, src, nbytes, 0, true, &req_ctx->in_mlli_nents); - ssi_buffer_mgr_add_scatterlist_entry(&sg_data, + ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data, req_ctx->out_nents, dst, nbytes, 0, true, @@ -607,8 +583,8 @@ int ssi_buffer_mgr_map_blkcipher_request( goto ablkcipher_exit; } - SSI_LOG_DEBUG("areq_ctx->dma_buf_type = %s\n", - GET_DMA_BUFFER_TYPE(req_ctx->dma_buf_type)); + dev_dbg(dev, "areq_ctx->dma_buf_type = %s\n", + GET_DMA_BUFFER_TYPE(req_ctx->dma_buf_type)); return 0; @@ -674,30 +650,34 @@ void ssi_buffer_mgr_unmap_aead_request( *allocated and should be released */ if (areq_ctx->mlli_params.curr_pool) { - SSI_LOG_DEBUG("free MLLI buffer: dma=%pad virt=%pK\n", - areq_ctx->mlli_params.mlli_dma_addr, - areq_ctx->mlli_params.mlli_virt_addr); + dev_dbg(dev, "free MLLI buffer: dma=%pad virt=%pK\n", + &areq_ctx->mlli_params.mlli_dma_addr, + areq_ctx->mlli_params.mlli_virt_addr); dma_pool_free(areq_ctx->mlli_params.curr_pool, areq_ctx->mlli_params.mlli_virt_addr, areq_ctx->mlli_params.mlli_dma_addr); } - SSI_LOG_DEBUG("Unmapping src sgl: req->src=%pK areq_ctx->src.nents=%u areq_ctx->assoc.nents=%u assoclen:%u cryptlen=%u\n", sg_virt(req->src), areq_ctx->src.nents, areq_ctx->assoc.nents, req->assoclen, req->cryptlen); + dev_dbg(dev, "Unmapping src sgl: req->src=%pK areq_ctx->src.nents=%u areq_ctx->assoc.nents=%u assoclen:%u cryptlen=%u\n", + sg_virt(req->src), areq_ctx->src.nents, areq_ctx->assoc.nents, + req->assoclen, req->cryptlen); size_to_unmap = req->assoclen + req->cryptlen; if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_ENCRYPT) size_to_unmap += areq_ctx->req_authsize; if (areq_ctx->is_gcm4543) size_to_unmap += crypto_aead_ivsize(tfm); - dma_unmap_sg(dev, req->src, ssi_buffer_mgr_get_sgl_nents(req->src, size_to_unmap, &dummy, &chained), DMA_BIDIRECTIONAL); + dma_unmap_sg(dev, req->src, + ssi_buffer_mgr_get_sgl_nents(dev, req->src, size_to_unmap, + &dummy, &chained), + DMA_BIDIRECTIONAL); if (unlikely(req->src != req->dst)) { - SSI_LOG_DEBUG("Unmapping dst sgl: req->dst=%pK\n", - sg_virt(req->dst)); + dev_dbg(dev, "Unmapping dst sgl: req->dst=%pK\n", + sg_virt(req->dst)); dma_unmap_sg(dev, req->dst, - ssi_buffer_mgr_get_sgl_nents(req->dst, + ssi_buffer_mgr_get_sgl_nents(dev, req->dst, size_to_unmap, - &dummy, - &chained), + &dummy, &chained), DMA_BIDIRECTIONAL); } if (drvdata->coherent && @@ -712,13 +692,14 @@ void ssi_buffer_mgr_unmap_aead_request( * data memory overriding that caused by cache coherence problem. */ ssi_buffer_mgr_copy_scatterlist_portion( - areq_ctx->backup_mac, req->src, + dev, areq_ctx->backup_mac, req->src, size_to_skip + req->cryptlen - areq_ctx->req_authsize, size_to_skip + req->cryptlen, SSI_SG_FROM_BUF); } } static inline int ssi_buffer_mgr_get_aead_icv_nents( + struct device *dev, struct scatterlist *sgl, unsigned int sgl_nents, unsigned int authsize, @@ -757,12 +738,12 @@ static inline int ssi_buffer_mgr_get_aead_icv_nents( nents = 2; *is_icv_fragmented = true; } else { - SSI_LOG_ERR("Unsupported num. of ICV fragments (> %d)\n", - MAX_ICV_NENTS_SUPPORTED); + dev_err(dev, "Unsupported num. of ICV fragments (> %d)\n", + MAX_ICV_NENTS_SUPPORTED); nents = -1; /*unsupported*/ } - SSI_LOG_DEBUG("is_frag=%s icv_nents=%u\n", - (*is_icv_fragmented ? "true" : "false"), nents); + dev_dbg(dev, "is_frag=%s icv_nents=%u\n", + (*is_icv_fragmented ? "true" : "false"), nents); return nents; } @@ -775,7 +756,7 @@ static inline int ssi_buffer_mgr_aead_chain_iv( { struct aead_req_ctx *areq_ctx = aead_request_ctx(req); unsigned int hw_iv_size = areq_ctx->hw_iv_size; - struct device *dev = &drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(drvdata); int rc = 0; if (unlikely(!req->iv)) { @@ -786,22 +767,22 @@ static inline int ssi_buffer_mgr_aead_chain_iv( areq_ctx->gen_ctx.iv_dma_addr = dma_map_single(dev, req->iv, hw_iv_size, DMA_BIDIRECTIONAL); if (unlikely(dma_mapping_error(dev, areq_ctx->gen_ctx.iv_dma_addr))) { - SSI_LOG_ERR("Mapping iv %u B at va=%pK for DMA failed\n", - hw_iv_size, req->iv); + dev_err(dev, "Mapping iv %u B at va=%pK for DMA failed\n", + hw_iv_size, req->iv); rc = -ENOMEM; goto chain_iv_exit; } - SSI_LOG_DEBUG("Mapped iv %u B at va=%pK to dma=%pad\n", - hw_iv_size, req->iv, - areq_ctx->gen_ctx.iv_dma_addr); + dev_dbg(dev, "Mapped iv %u B at va=%pK to dma=%pad\n", + hw_iv_size, req->iv, &areq_ctx->gen_ctx.iv_dma_addr); if (do_chain && areq_ctx->plaintext_authenticate_only) { // TODO: what about CTR?? ask Ron struct crypto_aead *tfm = crypto_aead_reqtfm(req); unsigned int iv_size_to_authenc = crypto_aead_ivsize(tfm); unsigned int iv_ofs = GCM_BLOCK_RFC4_IV_OFFSET; /* Chain to given list */ ssi_buffer_mgr_add_buffer_entry( - sg_data, areq_ctx->gen_ctx.iv_dma_addr + iv_ofs, + dev, sg_data, + areq_ctx->gen_ctx.iv_dma_addr + iv_ofs, iv_size_to_authenc, is_last, &areq_ctx->assoc.mlli_nents); areq_ctx->assoc_buff_type = SSI_DMA_BUF_MLLI; @@ -824,6 +805,7 @@ static inline int ssi_buffer_mgr_aead_chain_assoc( struct crypto_aead *tfm = crypto_aead_reqtfm(req); unsigned int sg_index = 0; u32 size_of_assoc = req->assoclen; + struct device *dev = drvdata_to_dev(drvdata); if (areq_ctx->is_gcm4543) size_of_assoc += crypto_aead_ivsize(tfm); @@ -837,9 +819,9 @@ static inline int ssi_buffer_mgr_aead_chain_assoc( areq_ctx->assoc_buff_type = SSI_DMA_BUF_NULL; areq_ctx->assoc.nents = 0; areq_ctx->assoc.mlli_nents = 0; - SSI_LOG_DEBUG("Chain assoc of length 0: buff_type=%s nents=%u\n", - GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type), - areq_ctx->assoc.nents); + dev_dbg(dev, "Chain assoc of length 0: buff_type=%s nents=%u\n", + GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type), + areq_ctx->assoc.nents); goto chain_assoc_exit; } @@ -853,16 +835,16 @@ static inline int ssi_buffer_mgr_aead_chain_assoc( current_sg = sg_next(current_sg); //if have reached the end of the sgl, then this is unexpected if (!current_sg) { - SSI_LOG_ERR("reached end of sg list. unexpected\n"); - BUG(); + dev_err(dev, "reached end of sg list. unexpected\n"); + return -EINVAL; } sg_index += current_sg->length; mapped_nents++; } } if (unlikely(mapped_nents > LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES)) { - SSI_LOG_ERR("Too many fragments. current %d max %d\n", - mapped_nents, LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES); + dev_err(dev, "Too many fragments. current %d max %d\n", + mapped_nents, LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES); return -ENOMEM; } areq_ctx->assoc.nents = mapped_nents; @@ -873,9 +855,9 @@ static inline int ssi_buffer_mgr_aead_chain_assoc( if (areq_ctx->ccm_hdr_size != ccm_header_size_null) { if (unlikely((mapped_nents + 1) > LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES)) { - SSI_LOG_ERR("CCM case.Too many fragments. Current %d max %d\n", - (areq_ctx->assoc.nents + 1), - LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES); + dev_err(dev, "CCM case.Too many fragments. Current %d max %d\n", + (areq_ctx->assoc.nents + 1), + LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES); rc = -ENOMEM; goto chain_assoc_exit; } @@ -889,11 +871,11 @@ static inline int ssi_buffer_mgr_aead_chain_assoc( if (unlikely((do_chain) || (areq_ctx->assoc_buff_type == SSI_DMA_BUF_MLLI))) { - SSI_LOG_DEBUG("Chain assoc: buff_type=%s nents=%u\n", - GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type), - areq_ctx->assoc.nents); + dev_dbg(dev, "Chain assoc: buff_type=%s nents=%u\n", + GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type), + areq_ctx->assoc.nents); ssi_buffer_mgr_add_scatterlist_entry( - sg_data, areq_ctx->assoc.nents, + dev, sg_data, areq_ctx->assoc.nents, req->src, req->assoclen, 0, is_last, &areq_ctx->assoc.mlli_nents); areq_ctx->assoc_buff_type = SSI_DMA_BUF_MLLI; @@ -951,10 +933,11 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( unsigned int authsize = areq_ctx->req_authsize; int rc = 0, icv_nents; struct crypto_aead *tfm = crypto_aead_reqtfm(req); + struct device *dev = drvdata_to_dev(drvdata); if (likely(req->src == req->dst)) { /*INPLACE*/ - ssi_buffer_mgr_add_scatterlist_entry(sg_data, + ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, areq_ctx->src.nents, areq_ctx->src_sgl, areq_ctx->cryptlen, @@ -962,7 +945,8 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( is_last_table, &areq_ctx->src.mlli_nents); - icv_nents = ssi_buffer_mgr_get_aead_icv_nents(areq_ctx->src_sgl, + icv_nents = ssi_buffer_mgr_get_aead_icv_nents(dev, + areq_ctx->src_sgl, areq_ctx->src.nents, authsize, *src_last_bytes, @@ -990,7 +974,8 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( skip += crypto_aead_ivsize(tfm); ssi_buffer_mgr_copy_scatterlist_portion( - areq_ctx->backup_mac, req->src, + dev, areq_ctx->backup_mac, + req->src, (skip + req->cryptlen - areq_ctx->req_authsize), skip + req->cryptlen, @@ -1013,14 +998,14 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( } else if (direct == DRV_CRYPTO_DIRECTION_DECRYPT) { /*NON-INPLACE and DECRYPT*/ - ssi_buffer_mgr_add_scatterlist_entry(sg_data, + ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, areq_ctx->src.nents, areq_ctx->src_sgl, areq_ctx->cryptlen, areq_ctx->src_offset, is_last_table, &areq_ctx->src.mlli_nents); - ssi_buffer_mgr_add_scatterlist_entry(sg_data, + ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, areq_ctx->dst.nents, areq_ctx->dst_sgl, areq_ctx->cryptlen, @@ -1028,7 +1013,8 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( is_last_table, &areq_ctx->dst.mlli_nents); - icv_nents = ssi_buffer_mgr_get_aead_icv_nents(areq_ctx->src_sgl, + icv_nents = ssi_buffer_mgr_get_aead_icv_nents(dev, + areq_ctx->src_sgl, areq_ctx->src.nents, authsize, *src_last_bytes, @@ -1049,9 +1035,9 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( size_to_skip += crypto_aead_ivsize(tfm); ssi_buffer_mgr_copy_scatterlist_portion( - areq_ctx->backup_mac, req->src, - size_to_skip + req->cryptlen - areq_ctx->req_authsize, - size_to_skip + req->cryptlen, SSI_SG_TO_BUF); + dev, areq_ctx->backup_mac, req->src, + size_to_skip + req->cryptlen - areq_ctx->req_authsize, + size_to_skip + req->cryptlen, SSI_SG_TO_BUF); areq_ctx->icv_virt_addr = areq_ctx->backup_mac; } else { /* Contig. ICV */ /*Should hanlde if the sg is not contig.*/ @@ -1065,14 +1051,14 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( } else { /*NON-INPLACE and ENCRYPT*/ - ssi_buffer_mgr_add_scatterlist_entry(sg_data, + ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, areq_ctx->dst.nents, areq_ctx->dst_sgl, areq_ctx->cryptlen, areq_ctx->dst_offset, is_last_table, &areq_ctx->dst.mlli_nents); - ssi_buffer_mgr_add_scatterlist_entry(sg_data, + ssi_buffer_mgr_add_scatterlist_entry(dev, sg_data, areq_ctx->src.nents, areq_ctx->src_sgl, areq_ctx->cryptlen, @@ -1080,7 +1066,8 @@ static inline int ssi_buffer_mgr_prepare_aead_data_mlli( is_last_table, &areq_ctx->src.mlli_nents); - icv_nents = ssi_buffer_mgr_get_aead_icv_nents(areq_ctx->dst_sgl, + icv_nents = ssi_buffer_mgr_get_aead_icv_nents(dev, + areq_ctx->dst_sgl, areq_ctx->dst.nents, authsize, *dst_last_bytes, @@ -1115,7 +1102,7 @@ static inline int ssi_buffer_mgr_aead_chain_data( bool is_last_table, bool do_chain) { struct aead_req_ctx *areq_ctx = aead_request_ctx(req); - struct device *dev = &drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(drvdata); enum drv_crypto_direction direct = areq_ctx->gen_ctx.op_type; unsigned int authsize = areq_ctx->req_authsize; int src_last_bytes = 0, dst_last_bytes = 0; @@ -1134,10 +1121,9 @@ static inline int ssi_buffer_mgr_aead_chain_data( offset = size_to_skip; - if (!sg_data) { - rc = -EINVAL; - goto chain_data_exit; - } + if (!sg_data) + return -EINVAL; + areq_ctx->src_sgl = req->src; areq_ctx->dst_sgl = req->dst; @@ -1145,7 +1131,10 @@ static inline int ssi_buffer_mgr_aead_chain_data( size_for_map += crypto_aead_ivsize(tfm); size_for_map += (direct == DRV_CRYPTO_DIRECTION_ENCRYPT) ? authsize : 0; - src_mapped_nents = ssi_buffer_mgr_get_sgl_nents(req->src, size_for_map, &src_last_bytes, &chained); + src_mapped_nents = ssi_buffer_mgr_get_sgl_nents(dev, req->src, + size_for_map, + &src_last_bytes, + &chained); sg_index = areq_ctx->src_sgl->length; //check where the data starts while (sg_index <= size_to_skip) { @@ -1153,15 +1142,15 @@ static inline int ssi_buffer_mgr_aead_chain_data( areq_ctx->src_sgl = sg_next(areq_ctx->src_sgl); //if have reached the end of the sgl, then this is unexpected if (!areq_ctx->src_sgl) { - SSI_LOG_ERR("reached end of sg list. unexpected\n"); - BUG(); + dev_err(dev, "reached end of sg list. unexpected\n"); + return -EINVAL; } sg_index += areq_ctx->src_sgl->length; src_mapped_nents--; } if (unlikely(src_mapped_nents > LLI_MAX_NUM_OF_DATA_ENTRIES)) { - SSI_LOG_ERR("Too many fragments. current %d max %d\n", - src_mapped_nents, LLI_MAX_NUM_OF_DATA_ENTRIES); + dev_err(dev, "Too many fragments. current %d max %d\n", + src_mapped_nents, LLI_MAX_NUM_OF_DATA_ENTRIES); return -ENOMEM; } @@ -1187,7 +1176,10 @@ static inline int ssi_buffer_mgr_aead_chain_data( } } - dst_mapped_nents = ssi_buffer_mgr_get_sgl_nents(req->dst, size_for_map, &dst_last_bytes, &chained); + dst_mapped_nents = ssi_buffer_mgr_get_sgl_nents(dev, req->dst, + size_for_map, + &dst_last_bytes, + &chained); sg_index = areq_ctx->dst_sgl->length; offset = size_to_skip; @@ -1197,15 +1189,15 @@ static inline int ssi_buffer_mgr_aead_chain_data( areq_ctx->dst_sgl = sg_next(areq_ctx->dst_sgl); //if have reached the end of the sgl, then this is unexpected if (!areq_ctx->dst_sgl) { - SSI_LOG_ERR("reached end of sg list. unexpected\n"); - BUG(); + dev_err(dev, "reached end of sg list. unexpected\n"); + return -EINVAL; } sg_index += areq_ctx->dst_sgl->length; dst_mapped_nents--; } if (unlikely(dst_mapped_nents > LLI_MAX_NUM_OF_DATA_ENTRIES)) { - SSI_LOG_ERR("Too many fragments. current %d max %d\n", - dst_mapped_nents, LLI_MAX_NUM_OF_DATA_ENTRIES); + dev_err(dev, "Too many fragments. current %d max %d\n", + dst_mapped_nents, LLI_MAX_NUM_OF_DATA_ENTRIES); return -ENOMEM; } areq_ctx->dst.nents = dst_mapped_nents; @@ -1285,7 +1277,7 @@ int ssi_buffer_mgr_map_aead_request( { struct aead_req_ctx *areq_ctx = aead_request_ctx(req); struct mlli_params *mlli_params = &areq_ctx->mlli_params; - struct device *dev = &drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(drvdata); struct buffer_array sg_data; unsigned int authsize = areq_ctx->req_authsize; struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle; @@ -1312,7 +1304,7 @@ int ssi_buffer_mgr_map_aead_request( * data memory overriding that caused by cache coherence problem. */ ssi_buffer_mgr_copy_scatterlist_portion( - areq_ctx->backup_mac, req->src, + dev, areq_ctx->backup_mac, req->src, size_to_skip + req->cryptlen - areq_ctx->req_authsize, size_to_skip + req->cryptlen, SSI_SG_TO_BUF); } @@ -1327,8 +1319,8 @@ int ssi_buffer_mgr_map_aead_request( MAX_MAC_SIZE, DMA_BIDIRECTIONAL); if (unlikely(dma_mapping_error(dev, areq_ctx->mac_buf_dma_addr))) { - SSI_LOG_ERR("Mapping mac_buf %u B at va=%pK for DMA failed\n", - MAX_MAC_SIZE, areq_ctx->mac_buf); + dev_err(dev, "Mapping mac_buf %u B at va=%pK for DMA failed\n", + MAX_MAC_SIZE, areq_ctx->mac_buf); rc = -ENOMEM; goto aead_map_failure; } @@ -1340,9 +1332,10 @@ int ssi_buffer_mgr_map_aead_request( DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, areq_ctx->ccm_iv0_dma_addr))) { - SSI_LOG_ERR("Mapping mac_buf %u B at va=%pK " - "for DMA failed\n", AES_BLOCK_SIZE, - (areq_ctx->ccm_config + CCM_CTR_COUNT_0_OFFSET)); + dev_err(dev, "Mapping mac_buf %u B at va=%pK for DMA failed\n", + AES_BLOCK_SIZE, + (areq_ctx->ccm_config + + CCM_CTR_COUNT_0_OFFSET)); areq_ctx->ccm_iv0_dma_addr = 0; rc = -ENOMEM; goto aead_map_failure; @@ -1362,8 +1355,8 @@ int ssi_buffer_mgr_map_aead_request( AES_BLOCK_SIZE, DMA_BIDIRECTIONAL); if (unlikely(dma_mapping_error(dev, areq_ctx->hkey_dma_addr))) { - SSI_LOG_ERR("Mapping hkey %u B at va=%pK for DMA failed\n", - AES_BLOCK_SIZE, areq_ctx->hkey); + dev_err(dev, "Mapping hkey %u B at va=%pK for DMA failed\n", + AES_BLOCK_SIZE, areq_ctx->hkey); rc = -ENOMEM; goto aead_map_failure; } @@ -1373,8 +1366,8 @@ int ssi_buffer_mgr_map_aead_request( AES_BLOCK_SIZE, DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, areq_ctx->gcm_block_len_dma_addr))) { - SSI_LOG_ERR("Mapping gcm_len_block %u B at va=%pK for DMA failed\n", - AES_BLOCK_SIZE, &areq_ctx->gcm_len_block); + dev_err(dev, "Mapping gcm_len_block %u B at va=%pK for DMA failed\n", + AES_BLOCK_SIZE, &areq_ctx->gcm_len_block); rc = -ENOMEM; goto aead_map_failure; } @@ -1385,9 +1378,8 @@ int ssi_buffer_mgr_map_aead_request( DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, areq_ctx->gcm_iv_inc1_dma_addr))) { - SSI_LOG_ERR("Mapping gcm_iv_inc1 %u B at va=%pK " - "for DMA failed\n", AES_BLOCK_SIZE, - (areq_ctx->gcm_iv_inc1)); + dev_err(dev, "Mapping gcm_iv_inc1 %u B at va=%pK for DMA failed\n", + AES_BLOCK_SIZE, (areq_ctx->gcm_iv_inc1)); areq_ctx->gcm_iv_inc1_dma_addr = 0; rc = -ENOMEM; goto aead_map_failure; @@ -1399,9 +1391,8 @@ int ssi_buffer_mgr_map_aead_request( DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, areq_ctx->gcm_iv_inc2_dma_addr))) { - SSI_LOG_ERR("Mapping gcm_iv_inc2 %u B at va=%pK " - "for DMA failed\n", AES_BLOCK_SIZE, - (areq_ctx->gcm_iv_inc2)); + dev_err(dev, "Mapping gcm_iv_inc2 %u B at va=%pK for DMA failed\n", + AES_BLOCK_SIZE, (areq_ctx->gcm_iv_inc2)); areq_ctx->gcm_iv_inc2_dma_addr = 0; rc = -ENOMEM; goto aead_map_failure; @@ -1481,9 +1472,10 @@ int ssi_buffer_mgr_map_aead_request( goto aead_map_failure; ssi_buffer_mgr_update_aead_mlli_nents(drvdata, req); - SSI_LOG_DEBUG("assoc params mn %d\n", areq_ctx->assoc.mlli_nents); - SSI_LOG_DEBUG("src params mn %d\n", areq_ctx->src.mlli_nents); - SSI_LOG_DEBUG("dst params mn %d\n", areq_ctx->dst.mlli_nents); + dev_dbg(dev, "assoc params mn %d\n", + areq_ctx->assoc.mlli_nents); + dev_dbg(dev, "src params mn %d\n", areq_ctx->src.mlli_nents); + dev_dbg(dev, "dst params mn %d\n", areq_ctx->dst.mlli_nents); } return 0; @@ -1496,7 +1488,7 @@ int ssi_buffer_mgr_map_hash_request_final( struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, bool do_update) { struct ahash_req_ctx *areq_ctx = (struct ahash_req_ctx *)ctx; - struct device *dev = &drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(drvdata); u8 *curr_buff = areq_ctx->buff_index ? areq_ctx->buff1 : areq_ctx->buff0; u32 *curr_buff_cnt = areq_ctx->buff_index ? &areq_ctx->buff1_cnt : @@ -1507,11 +1499,8 @@ int ssi_buffer_mgr_map_hash_request_final( u32 dummy = 0; u32 mapped_nents = 0; - SSI_LOG_DEBUG(" final params : curr_buff=%pK " - "curr_buff_cnt=0x%X nbytes = 0x%X " - "src=%pK curr_index=%u\n", - curr_buff, *curr_buff_cnt, nbytes, - src, areq_ctx->buff_index); + dev_dbg(dev, "final params : curr_buff=%pK curr_buff_cnt=0x%X nbytes = 0x%X src=%pK curr_index=%u\n", + curr_buff, *curr_buff_cnt, nbytes, src, areq_ctx->buff_index); /* Init the type of the dma buffer */ areq_ctx->data_dma_buf_type = SSI_DMA_BUF_NULL; mlli_params->curr_pool = NULL; @@ -1557,7 +1546,7 @@ int ssi_buffer_mgr_map_hash_request_final( if (unlikely(areq_ctx->data_dma_buf_type == SSI_DMA_BUF_MLLI)) { mlli_params->curr_pool = buff_mgr->mlli_buffs_pool; /* add the src data to the sg_data */ - ssi_buffer_mgr_add_scatterlist_entry(&sg_data, + ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data, areq_ctx->in_nents, src, nbytes, 0, true, &areq_ctx->mlli_nents); @@ -1568,8 +1557,8 @@ int ssi_buffer_mgr_map_hash_request_final( } /* change the buffer index for the unmap function */ areq_ctx->buff_index = (areq_ctx->buff_index ^ 1); - SSI_LOG_DEBUG("areq_ctx->data_dma_buf_type = %s\n", - GET_DMA_BUFFER_TYPE(areq_ctx->data_dma_buf_type)); + dev_dbg(dev, "areq_ctx->data_dma_buf_type = %s\n", + GET_DMA_BUFFER_TYPE(areq_ctx->data_dma_buf_type)); return 0; fail_unmap_din: @@ -1586,7 +1575,7 @@ int ssi_buffer_mgr_map_hash_request_update( struct ssi_drvdata *drvdata, void *ctx, struct scatterlist *src, unsigned int nbytes, unsigned int block_size) { struct ahash_req_ctx *areq_ctx = (struct ahash_req_ctx *)ctx; - struct device *dev = &drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(drvdata); u8 *curr_buff = areq_ctx->buff_index ? areq_ctx->buff1 : areq_ctx->buff0; u32 *curr_buff_cnt = areq_ctx->buff_index ? &areq_ctx->buff1_cnt : @@ -1604,11 +1593,8 @@ int ssi_buffer_mgr_map_hash_request_update( u32 dummy = 0; u32 mapped_nents = 0; - SSI_LOG_DEBUG(" update params : curr_buff=%pK " - "curr_buff_cnt=0x%X nbytes=0x%X " - "src=%pK curr_index=%u\n", - curr_buff, *curr_buff_cnt, nbytes, - src, areq_ctx->buff_index); + dev_dbg(dev, " update params : curr_buff=%pK curr_buff_cnt=0x%X nbytes=0x%X src=%pK curr_index=%u\n", + curr_buff, *curr_buff_cnt, nbytes, src, areq_ctx->buff_index); /* Init the type of the dma buffer */ areq_ctx->data_dma_buf_type = SSI_DMA_BUF_NULL; mlli_params->curr_pool = NULL; @@ -1617,14 +1603,11 @@ int ssi_buffer_mgr_map_hash_request_update( areq_ctx->in_nents = 0; if (unlikely(total_in_len < block_size)) { - SSI_LOG_DEBUG(" less than one block: curr_buff=%pK " - "*curr_buff_cnt=0x%X copy_to=%pK\n", - curr_buff, *curr_buff_cnt, - &curr_buff[*curr_buff_cnt]); + dev_dbg(dev, " less than one block: curr_buff=%pK *curr_buff_cnt=0x%X copy_to=%pK\n", + curr_buff, *curr_buff_cnt, &curr_buff[*curr_buff_cnt]); areq_ctx->in_nents = - ssi_buffer_mgr_get_sgl_nents(src, - nbytes, - &dummy, NULL); + ssi_buffer_mgr_get_sgl_nents(dev, src, nbytes, &dummy, + NULL); sg_copy_to_buffer(src, areq_ctx->in_nents, &curr_buff[*curr_buff_cnt], nbytes); *curr_buff_cnt += nbytes; @@ -1636,17 +1619,15 @@ int ssi_buffer_mgr_map_hash_request_update( /* update data len */ update_data_len = total_in_len - *next_buff_cnt; - SSI_LOG_DEBUG(" temp length : *next_buff_cnt=0x%X " - "update_data_len=0x%X\n", + dev_dbg(dev, " temp length : *next_buff_cnt=0x%X update_data_len=0x%X\n", *next_buff_cnt, update_data_len); /* Copy the new residue to next buffer */ if (*next_buff_cnt != 0) { - SSI_LOG_DEBUG(" handle residue: next buff %pK skip data %u" - " residue %u\n", next_buff, - (update_data_len - *curr_buff_cnt), - *next_buff_cnt); - ssi_buffer_mgr_copy_scatterlist_portion(next_buff, src, + dev_dbg(dev, " handle residue: next buff %pK skip data %u residue %u\n", + next_buff, (update_data_len - *curr_buff_cnt), + *next_buff_cnt); + ssi_buffer_mgr_copy_scatterlist_portion(dev, next_buff, src, (update_data_len - *curr_buff_cnt), nbytes, SSI_SG_TO_BUF); /* change the buffer index for next operation */ @@ -1688,7 +1669,7 @@ int ssi_buffer_mgr_map_hash_request_update( if (unlikely(areq_ctx->data_dma_buf_type == SSI_DMA_BUF_MLLI)) { mlli_params->curr_pool = buff_mgr->mlli_buffs_pool; /* add the src data to the sg_data */ - ssi_buffer_mgr_add_scatterlist_entry(&sg_data, + ssi_buffer_mgr_add_scatterlist_entry(dev, &sg_data, areq_ctx->in_nents, src, (update_data_len - *curr_buff_cnt), @@ -1725,29 +1706,26 @@ void ssi_buffer_mgr_unmap_hash_request( *allocated and should be released */ if (areq_ctx->mlli_params.curr_pool) { - SSI_LOG_DEBUG("free MLLI buffer: dma=%pad virt=%pK\n", - areq_ctx->mlli_params.mlli_dma_addr, - areq_ctx->mlli_params.mlli_virt_addr); + dev_dbg(dev, "free MLLI buffer: dma=%pad virt=%pK\n", + &areq_ctx->mlli_params.mlli_dma_addr, + areq_ctx->mlli_params.mlli_virt_addr); dma_pool_free(areq_ctx->mlli_params.curr_pool, areq_ctx->mlli_params.mlli_virt_addr, areq_ctx->mlli_params.mlli_dma_addr); } if ((src) && likely(areq_ctx->in_nents != 0)) { - SSI_LOG_DEBUG("Unmapped sg src: virt=%pK dma=%pad len=0x%X\n", - sg_virt(src), - sg_dma_address(src), - sg_dma_len(src)); + dev_dbg(dev, "Unmapped sg src: virt=%pK dma=%pad len=0x%X\n", + sg_virt(src), &sg_dma_address(src), sg_dma_len(src)); dma_unmap_sg(dev, src, areq_ctx->in_nents, DMA_TO_DEVICE); } if (*prev_len != 0) { - SSI_LOG_DEBUG("Unmapped buffer: areq_ctx->buff_sg=%pK" - " dma=%pad len 0x%X\n", - sg_virt(areq_ctx->buff_sg), - sg_dma_address(areq_ctx->buff_sg), - sg_dma_len(areq_ctx->buff_sg)); + dev_dbg(dev, "Unmapped buffer: areq_ctx->buff_sg=%pK dma=%pad len 0x%X\n", + sg_virt(areq_ctx->buff_sg), + &sg_dma_address(areq_ctx->buff_sg), + sg_dma_len(areq_ctx->buff_sg)); dma_unmap_sg(dev, areq_ctx->buff_sg, 1, DMA_TO_DEVICE); if (!do_revert) { /* clean the previous data length for update operation */ @@ -1761,7 +1739,7 @@ void ssi_buffer_mgr_unmap_hash_request( int ssi_buffer_mgr_init(struct ssi_drvdata *drvdata) { struct buff_mgr_handle *buff_mgr_handle; - struct device *dev = &drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(drvdata); buff_mgr_handle = kmalloc(sizeof(*buff_mgr_handle), GFP_KERNEL); if (!buff_mgr_handle) diff --git a/drivers/staging/ccree/ssi_buffer_mgr.h b/drivers/staging/ccree/ssi_buffer_mgr.h index 41f5223730f8..1032f25edcab 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.h +++ b/drivers/staging/ccree/ssi_buffer_mgr.h @@ -80,7 +80,10 @@ int ssi_buffer_mgr_map_hash_request_update(struct ssi_drvdata *drvdata, void *ct void ssi_buffer_mgr_unmap_hash_request(struct device *dev, void *ctx, struct scatterlist *src, bool do_revert); -void ssi_buffer_mgr_copy_scatterlist_portion(u8 *dest, struct scatterlist *sg, u32 to_skip, u32 end, enum ssi_sg_cpy_direct direct); +void ssi_buffer_mgr_copy_scatterlist_portion(struct device *dev, u8 *dest, + struct scatterlist *sg, + u32 to_skip, u32 end, + enum ssi_sg_cpy_direct direct); void ssi_buffer_mgr_zero_sgl(struct scatterlist *sgl, u32 data_len); diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c index 8d31a93fd8b7..78706f5bcfb4 100644 --- a/drivers/staging/ccree/ssi_cipher.c +++ b/drivers/staging/ccree/ssi_cipher.c @@ -181,45 +181,42 @@ static int ssi_blkcipher_init(struct crypto_tfm *tfm) struct crypto_alg *alg = tfm->__crt_alg; struct ssi_crypto_alg *ssi_alg = container_of(alg, struct ssi_crypto_alg, crypto_alg); - struct device *dev; + struct device *dev = drvdata_to_dev(ssi_alg->drvdata); int rc = 0; unsigned int max_key_buf_size = get_max_keysize(tfm); - SSI_LOG_DEBUG("Initializing context @%p for %s\n", - ctx_p, crypto_tfm_alg_name(tfm)); + dev_dbg(dev, "Initializing context @%p for %s\n", ctx_p, + crypto_tfm_alg_name(tfm)); ctx_p->cipher_mode = ssi_alg->cipher_mode; ctx_p->flow_mode = ssi_alg->flow_mode; ctx_p->drvdata = ssi_alg->drvdata; - dev = &ctx_p->drvdata->plat_dev->dev; /* Allocate key buffer, cache line aligned */ ctx_p->user.key = kmalloc(max_key_buf_size, GFP_KERNEL | GFP_DMA); - if (!ctx_p->user.key) { - SSI_LOG_ERR("Allocating key buffer in context failed\n"); - rc = -ENOMEM; - } - SSI_LOG_DEBUG("Allocated key buffer in context. key=@%p\n", - ctx_p->user.key); + if (!ctx_p->user.key) + return -ENOMEM; + + dev_dbg(dev, "Allocated key buffer in context. key=@%p\n", + ctx_p->user.key); /* Map key buffer */ ctx_p->user.key_dma_addr = dma_map_single(dev, (void *)ctx_p->user.key, max_key_buf_size, DMA_TO_DEVICE); if (dma_mapping_error(dev, ctx_p->user.key_dma_addr)) { - SSI_LOG_ERR("Mapping Key %u B at va=%pK for DMA failed\n", - max_key_buf_size, ctx_p->user.key); + dev_err(dev, "Mapping Key %u B at va=%pK for DMA failed\n", + max_key_buf_size, ctx_p->user.key); return -ENOMEM; } - SSI_LOG_DEBUG("Mapped key %u B at va=%pK to dma=%pad\n", - max_key_buf_size, ctx_p->user.key, - ctx_p->user.key_dma_addr); + dev_dbg(dev, "Mapped key %u B at va=%pK to dma=%pad\n", + max_key_buf_size, ctx_p->user.key, &ctx_p->user.key_dma_addr); if (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) { /* Alloc hash tfm for essiv */ ctx_p->shash_tfm = crypto_alloc_shash("sha256-generic", 0, 0); if (IS_ERR(ctx_p->shash_tfm)) { - SSI_LOG_ERR("Error allocating hash tfm for ESSIV.\n"); + dev_err(dev, "Error allocating hash tfm for ESSIV.\n"); return PTR_ERR(ctx_p->shash_tfm); } } @@ -230,11 +227,11 @@ static int ssi_blkcipher_init(struct crypto_tfm *tfm) static void ssi_blkcipher_exit(struct crypto_tfm *tfm) { struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm); - struct device *dev = &ctx_p->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx_p->drvdata); unsigned int max_key_buf_size = get_max_keysize(tfm); - SSI_LOG_DEBUG("Clearing context @%p for %s\n", - crypto_tfm_ctx(tfm), crypto_tfm_alg_name(tfm)); + dev_dbg(dev, "Clearing context @%p for %s\n", + crypto_tfm_ctx(tfm), crypto_tfm_alg_name(tfm)); if (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) { /* Free hash tfm for essiv */ @@ -245,12 +242,12 @@ static void ssi_blkcipher_exit(struct crypto_tfm *tfm) /* Unmap key buffer */ dma_unmap_single(dev, ctx_p->user.key_dma_addr, max_key_buf_size, DMA_TO_DEVICE); - SSI_LOG_DEBUG("Unmapped key buffer key_dma_addr=%pad\n", - ctx_p->user.key_dma_addr); + dev_dbg(dev, "Unmapped key buffer key_dma_addr=%pad\n", + &ctx_p->user.key_dma_addr); /* Free key buffer in context */ kfree(ctx_p->user.key); - SSI_LOG_DEBUG("Free key buffer in context. key=@%p\n", ctx_p->user.key); + dev_dbg(dev, "Free key buffer in context. key=@%p\n", ctx_p->user.key); } struct tdes_keys { @@ -298,16 +295,14 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm, unsigned int keylen) { struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm); - struct device *dev = &ctx_p->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx_p->drvdata); u32 tmp[DES_EXPKEY_WORDS]; unsigned int max_key_buf_size = get_max_keysize(tfm); - SSI_LOG_DEBUG("Setting key in context @%p for %s. keylen=%u\n", - ctx_p, crypto_tfm_alg_name(tfm), keylen); + dev_dbg(dev, "Setting key in context @%p for %s. keylen=%u\n", + ctx_p, crypto_tfm_alg_name(tfm), keylen); dump_byte_array("key", (u8 *)key, keylen); - SSI_LOG_DEBUG("after FIPS check"); - /* STAT_PHASE_0: Init and sanity checks */ #if SSI_CC_HAS_MULTI2 @@ -317,7 +312,7 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm, #endif /*SSI_CC_HAS_MULTI2*/ if (unlikely(validate_keys_sizes(ctx_p, keylen) != 0)) { - SSI_LOG_ERR("Unsupported key size %d.\n", keylen); + dev_err(dev, "Unsupported key size %d.\n", keylen); crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); return -EINVAL; } @@ -327,13 +322,14 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm, struct arm_hw_key_info *hki = (struct arm_hw_key_info *)key; if (unlikely(ctx_p->flow_mode != S_DIN_to_AES)) { - SSI_LOG_ERR("HW key not supported for non-AES flows\n"); + dev_err(dev, "HW key not supported for non-AES flows\n"); return -EINVAL; } ctx_p->hw.key1_slot = hw_key_to_cc_hw_key(hki->hw_key1); if (unlikely(ctx_p->hw.key1_slot == END_OF_KEYS)) { - SSI_LOG_ERR("Unsupported hw key1 number (%d)\n", hki->hw_key1); + dev_err(dev, "Unsupported hw key1 number (%d)\n", + hki->hw_key1); return -EINVAL; } @@ -341,18 +337,20 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm, (ctx_p->cipher_mode == DRV_CIPHER_ESSIV) || (ctx_p->cipher_mode == DRV_CIPHER_BITLOCKER)) { if (unlikely(hki->hw_key1 == hki->hw_key2)) { - SSI_LOG_ERR("Illegal hw key numbers (%d,%d)\n", hki->hw_key1, hki->hw_key2); + dev_err(dev, "Illegal hw key numbers (%d,%d)\n", + hki->hw_key1, hki->hw_key2); return -EINVAL; } ctx_p->hw.key2_slot = hw_key_to_cc_hw_key(hki->hw_key2); if (unlikely(ctx_p->hw.key2_slot == END_OF_KEYS)) { - SSI_LOG_ERR("Unsupported hw key2 number (%d)\n", hki->hw_key2); + dev_err(dev, "Unsupported hw key2 number (%d)\n", + hki->hw_key2); return -EINVAL; } } ctx_p->keylen = keylen; - SSI_LOG_DEBUG("ssi_is_hw_key ret 0"); + dev_dbg(dev, "ssi_is_hw_key ret 0"); return 0; } @@ -362,19 +360,19 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm, if (unlikely(!des_ekey(tmp, key)) && (crypto_tfm_get_flags(tfm) & CRYPTO_TFM_REQ_WEAK_KEY)) { tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; - SSI_LOG_DEBUG("weak DES key"); + dev_dbg(dev, "weak DES key"); return -EINVAL; } } if ((ctx_p->cipher_mode == DRV_CIPHER_XTS) && xts_check_key(tfm, key, keylen) != 0) { - SSI_LOG_DEBUG("weak XTS key"); + dev_dbg(dev, "weak XTS key"); return -EINVAL; } if ((ctx_p->flow_mode == S_DIN_to_DES) && (keylen == DES3_EDE_KEY_SIZE) && ssi_verify_3des_keys(key, keylen) != 0) { - SSI_LOG_DEBUG("weak 3DES key"); + dev_dbg(dev, "weak 3DES key"); return -EINVAL; } @@ -389,7 +387,7 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm, if (ctx_p->key_round_number < CC_MULTI2_MIN_NUM_ROUNDS || ctx_p->key_round_number > CC_MULTI2_MAX_NUM_ROUNDS) { crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); - SSI_LOG_DEBUG("SSI_CC_HAS_MULTI2 einval"); + dev_dbg(dev, "SSI_CC_HAS_MULTI2 einval"); return -EINVAL; #endif /*SSI_CC_HAS_MULTI2*/ } else { @@ -407,7 +405,7 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm, err = crypto_shash_digest(desc, ctx_p->user.key, key_len, ctx_p->user.key + key_len); if (err) { - SSI_LOG_ERR("Failed to hash ESSIV key.\n"); + dev_err(dev, "Failed to hash ESSIV key.\n"); return err; } } @@ -416,7 +414,7 @@ static int ssi_blkcipher_setkey(struct crypto_tfm *tfm, max_key_buf_size, DMA_TO_DEVICE); ctx_p->keylen = keylen; - SSI_LOG_DEBUG("return safely"); + dev_dbg(dev, "return safely"); return 0; } @@ -430,6 +428,7 @@ ssi_blkcipher_create_setup_desc( unsigned int *seq_size) { struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm); + struct device *dev = drvdata_to_dev(ctx_p->drvdata); int cipher_mode = ctx_p->cipher_mode; int flow_mode = ctx_p->flow_mode; int direction = req_ctx->gen_ctx.op_type; @@ -540,8 +539,7 @@ ssi_blkcipher_create_setup_desc( (*seq_size)++; break; default: - SSI_LOG_ERR("Unsupported cipher mode (%d)\n", cipher_mode); - BUG(); + dev_err(dev, "Unsupported cipher mode (%d)\n", cipher_mode); } } @@ -601,6 +599,7 @@ ssi_blkcipher_create_data_desc( unsigned int *seq_size) { struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm); + struct device *dev = drvdata_to_dev(ctx_p->drvdata); unsigned int flow_mode = ctx_p->flow_mode; switch (ctx_p->flow_mode) { @@ -616,15 +615,15 @@ ssi_blkcipher_create_data_desc( break; #endif /*SSI_CC_HAS_MULTI2*/ default: - SSI_LOG_ERR("invalid flow mode, flow_mode = %d\n", flow_mode); + dev_err(dev, "invalid flow mode, flow_mode = %d\n", flow_mode); return; } /* Process */ if (likely(req_ctx->dma_buf_type == SSI_DMA_BUF_DLLI)) { - SSI_LOG_DEBUG(" data params addr %pad length 0x%X\n", - sg_dma_address(src), nbytes); - SSI_LOG_DEBUG(" data params addr %pad length 0x%X\n", - sg_dma_address(dst), nbytes); + dev_dbg(dev, " data params addr %pad length 0x%X\n", + &sg_dma_address(src), nbytes); + dev_dbg(dev, " data params addr %pad length 0x%X\n", + &sg_dma_address(dst), nbytes); hw_desc_init(&desc[*seq_size]); set_din_type(&desc[*seq_size], DMA_DLLI, sg_dma_address(src), nbytes, NS_BIT); @@ -637,9 +636,8 @@ ssi_blkcipher_create_data_desc( (*seq_size)++; } else { /* bypass */ - SSI_LOG_DEBUG(" bypass params addr %pad " - "length 0x%X addr 0x%08X\n", - req_ctx->mlli_params.mlli_dma_addr, + dev_dbg(dev, " bypass params addr %pad length 0x%X addr 0x%08X\n", + &req_ctx->mlli_params.mlli_dma_addr, req_ctx->mlli_params.mlli_len, (unsigned int)ctx_p->drvdata->mlli_sram_addr); hw_desc_init(&desc[*seq_size]); @@ -657,21 +655,18 @@ ssi_blkcipher_create_data_desc( ctx_p->drvdata->mlli_sram_addr, req_ctx->in_mlli_nents, NS_BIT); if (req_ctx->out_nents == 0) { - SSI_LOG_DEBUG(" din/dout params addr 0x%08X " - "addr 0x%08X\n", - (unsigned int)ctx_p->drvdata->mlli_sram_addr, - (unsigned int)ctx_p->drvdata->mlli_sram_addr); + dev_dbg(dev, " din/dout params addr 0x%08X addr 0x%08X\n", + (unsigned int)ctx_p->drvdata->mlli_sram_addr, + (unsigned int)ctx_p->drvdata->mlli_sram_addr); set_dout_mlli(&desc[*seq_size], ctx_p->drvdata->mlli_sram_addr, req_ctx->in_mlli_nents, NS_BIT, (!areq ? 0 : 1)); } else { - SSI_LOG_DEBUG(" din/dout params " - "addr 0x%08X addr 0x%08X\n", + dev_dbg(dev, " din/dout params addr 0x%08X addr 0x%08X\n", (unsigned int)ctx_p->drvdata->mlli_sram_addr, (unsigned int)ctx_p->drvdata->mlli_sram_addr + - (u32)LLI_ENTRY_BYTE_SIZE * - req_ctx->in_nents); + (u32)LLI_ENTRY_BYTE_SIZE * req_ctx->in_nents); set_dout_mlli(&desc[*seq_size], (ctx_p->drvdata->mlli_sram_addr + (LLI_ENTRY_BYTE_SIZE * @@ -697,13 +692,10 @@ static int ssi_blkcipher_complete(struct device *dev, void __iomem *cc_base) { int completion_error = 0; - u32 inflight_counter; struct ablkcipher_request *req = (struct ablkcipher_request *)areq; ssi_buffer_mgr_unmap_blkcipher_request(dev, req_ctx, ivsize, src, dst); - /*Set the inflight couter value to local variable*/ - inflight_counter = ctx_p->drvdata->inflight_counter; /*Decrease the inflight counter*/ if (ctx_p->flow_mode == BYPASS && ctx_p->drvdata->inflight_counter > 0) ctx_p->drvdata->inflight_counter--; @@ -742,20 +734,20 @@ static int ssi_blkcipher_process( enum drv_crypto_direction direction) { struct ssi_ablkcipher_ctx *ctx_p = crypto_tfm_ctx(tfm); - struct device *dev = &ctx_p->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx_p->drvdata); struct cc_hw_desc desc[MAX_ABLKCIPHER_SEQ_LEN]; struct ssi_crypto_req ssi_req = {}; int rc, seq_len = 0, cts_restore_flag = 0; - SSI_LOG_DEBUG("%s areq=%p info=%p nbytes=%d\n", - ((direction == DRV_CRYPTO_DIRECTION_ENCRYPT) ? "Encrypt" : "Decrypt"), - areq, info, nbytes); + dev_dbg(dev, "%s areq=%p info=%p nbytes=%d\n", + ((direction == DRV_CRYPTO_DIRECTION_ENCRYPT) ? + "Encrypt" : "Decrypt"), areq, info, nbytes); /* STAT_PHASE_0: Init and sanity checks */ /* TODO: check data length according to mode */ if (unlikely(validate_data_size(ctx_p, nbytes))) { - SSI_LOG_ERR("Unsupported data size %d.\n", nbytes); + dev_err(dev, "Unsupported data size %d.\n", nbytes); crypto_tfm_set_flags(tfm, CRYPTO_TFM_RES_BAD_BLOCK_LEN); rc = -EINVAL; goto exit_process; @@ -788,7 +780,7 @@ static int ssi_blkcipher_process( rc = ssi_buffer_mgr_map_blkcipher_request(ctx_p->drvdata, req_ctx, ivsize, nbytes, info, src, dst); if (unlikely(rc != 0)) { - SSI_LOG_ERR("map_request() failed\n"); + dev_err(dev, "map_request() failed\n"); goto exit_process; } @@ -1245,16 +1237,15 @@ static struct ssi_alg_template blkcipher_algs[] = { }; static -struct ssi_crypto_alg *ssi_ablkcipher_create_alg(struct ssi_alg_template *template) +struct ssi_crypto_alg *ssi_ablkcipher_create_alg(struct ssi_alg_template + *template, struct device *dev) { struct ssi_crypto_alg *t_alg; struct crypto_alg *alg; t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL); - if (!t_alg) { - SSI_LOG_ERR("failed to allocate t_alg\n"); + if (!t_alg) return ERR_PTR(-ENOMEM); - } alg = &t_alg->crypto_alg; @@ -1285,10 +1276,6 @@ int ssi_ablkcipher_free(struct ssi_drvdata *drvdata) struct ssi_crypto_alg *t_alg, *n; struct ssi_blkcipher_handle *blkcipher_handle = drvdata->blkcipher_handle; - struct device *dev; - - dev = &drvdata->plat_dev->dev; - if (blkcipher_handle) { /* Remove registered algs */ list_for_each_entry_safe(t_alg, n, @@ -1308,6 +1295,7 @@ int ssi_ablkcipher_alloc(struct ssi_drvdata *drvdata) { struct ssi_blkcipher_handle *ablkcipher_handle; struct ssi_crypto_alg *t_alg; + struct device *dev = drvdata_to_dev(drvdata); int rc = -ENOMEM; int alg; @@ -1315,37 +1303,38 @@ int ssi_ablkcipher_alloc(struct ssi_drvdata *drvdata) if (!ablkcipher_handle) return -ENOMEM; - drvdata->blkcipher_handle = ablkcipher_handle; - INIT_LIST_HEAD(&ablkcipher_handle->blkcipher_alg_list); + drvdata->blkcipher_handle = ablkcipher_handle; /* Linux crypto */ - SSI_LOG_DEBUG("Number of algorithms = %zu\n", ARRAY_SIZE(blkcipher_algs)); + dev_dbg(dev, "Number of algorithms = %zu\n", + ARRAY_SIZE(blkcipher_algs)); for (alg = 0; alg < ARRAY_SIZE(blkcipher_algs); alg++) { - SSI_LOG_DEBUG("creating %s\n", blkcipher_algs[alg].driver_name); - t_alg = ssi_ablkcipher_create_alg(&blkcipher_algs[alg]); + dev_dbg(dev, "creating %s\n", blkcipher_algs[alg].driver_name); + t_alg = ssi_ablkcipher_create_alg(&blkcipher_algs[alg], dev); if (IS_ERR(t_alg)) { rc = PTR_ERR(t_alg); - SSI_LOG_ERR("%s alg allocation failed\n", - blkcipher_algs[alg].driver_name); + dev_err(dev, "%s alg allocation failed\n", + blkcipher_algs[alg].driver_name); goto fail0; } t_alg->drvdata = drvdata; - SSI_LOG_DEBUG("registering %s\n", blkcipher_algs[alg].driver_name); + dev_dbg(dev, "registering %s\n", + blkcipher_algs[alg].driver_name); rc = crypto_register_alg(&t_alg->crypto_alg); - SSI_LOG_DEBUG("%s alg registration rc = %x\n", - t_alg->crypto_alg.cra_driver_name, rc); + dev_dbg(dev, "%s alg registration rc = %x\n", + t_alg->crypto_alg.cra_driver_name, rc); if (unlikely(rc != 0)) { - SSI_LOG_ERR("%s alg registration failed\n", - t_alg->crypto_alg.cra_driver_name); + dev_err(dev, "%s alg registration failed\n", + t_alg->crypto_alg.cra_driver_name); kfree(t_alg); goto fail0; } else { list_add_tail(&t_alg->entry, &ablkcipher_handle->blkcipher_alg_list); - SSI_LOG_DEBUG("Registered %s\n", - t_alg->crypto_alg.cra_driver_name); + dev_dbg(dev, "Registered %s\n", + t_alg->crypto_alg.cra_driver_name); } } return 0; diff --git a/drivers/staging/ccree/ssi_cipher.h b/drivers/staging/ccree/ssi_cipher.h index 296b375d5d89..c9a83df4514b 100644 --- a/drivers/staging/ccree/ssi_cipher.h +++ b/drivers/staging/ccree/ssi_cipher.h @@ -27,11 +27,11 @@ #include "ssi_buffer_mgr.h" /* Crypto cipher flags */ -#define CC_CRYPTO_CIPHER_KEY_KFDE0 (1 << 0) -#define CC_CRYPTO_CIPHER_KEY_KFDE1 (1 << 1) -#define CC_CRYPTO_CIPHER_KEY_KFDE2 (1 << 2) -#define CC_CRYPTO_CIPHER_KEY_KFDE3 (1 << 3) -#define CC_CRYPTO_CIPHER_DU_SIZE_512B (1 << 4) +#define CC_CRYPTO_CIPHER_KEY_KFDE0 BIT(0) +#define CC_CRYPTO_CIPHER_KEY_KFDE1 BIT(1) +#define CC_CRYPTO_CIPHER_KEY_KFDE2 BIT(2) +#define CC_CRYPTO_CIPHER_KEY_KFDE3 BIT(3) +#define CC_CRYPTO_CIPHER_DU_SIZE_512B BIT(4) #define CC_CRYPTO_CIPHER_KEY_KFDE_MASK (CC_CRYPTO_CIPHER_KEY_KFDE0 | CC_CRYPTO_CIPHER_KEY_KFDE1 | CC_CRYPTO_CIPHER_KEY_KFDE2 | CC_CRYPTO_CIPHER_KEY_KFDE3) diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 9c6f1200c130..5f03c2596f45 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -74,41 +74,17 @@ #include "ssi_fips.h" #ifdef DX_DUMP_BYTES -void dump_byte_array(const char *name, const u8 *the_array, unsigned long size) +void dump_byte_array(const char *name, const u8 *buf, size_t len) { - int i, line_offset = 0, ret = 0; - const u8 *cur_byte; - char line_buf[80]; + char prefix[NAME_LEN]; - if (!the_array) { - SSI_LOG_ERR("cannot dump array - NULL pointer\n"); + if (!buf) return; - } - ret = snprintf(line_buf, sizeof(line_buf), "%s[%lu]: ", name, size); - if (ret < 0) { - SSI_LOG_ERR("snprintf returned %d . aborting buffer array dump\n", ret); - return; - } - line_offset = ret; - for (i = 0, cur_byte = the_array; - (i < size) && (line_offset < sizeof(line_buf)); i++, cur_byte++) { - ret = snprintf(line_buf + line_offset, - sizeof(line_buf) - line_offset, - "0x%02X ", *cur_byte); - if (ret < 0) { - SSI_LOG_ERR("snprintf returned %d . aborting buffer array dump\n", ret); - return; - } - line_offset += ret; - if (line_offset > 75) { /* Cut before line end */ - SSI_LOG_DEBUG("%s\n", line_buf); - line_offset = 0; - } - } + snprintf(prefix, sizeof(prefix), "%s[%lu]: ", name, len); - if (line_offset > 0) /* Dump remaining line */ - SSI_LOG_DEBUG("%s\n", line_buf); + print_hex_dump(KERN_DEBUG, prefix, DUMP_PREFIX_ADDRESS, 16, 1, len, + false); } #endif @@ -116,6 +92,7 @@ static irqreturn_t cc_isr(int irq, void *dev_id) { struct ssi_drvdata *drvdata = (struct ssi_drvdata *)dev_id; void __iomem *cc_base = drvdata->cc_base; + struct device *dev = drvdata_to_dev(drvdata); u32 irr; u32 imr; @@ -123,9 +100,9 @@ static irqreturn_t cc_isr(int irq, void *dev_id) /* read the interrupt status */ irr = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IRR)); - SSI_LOG_DEBUG("Got IRR=0x%08X\n", irr); + dev_dbg(dev, "Got IRR=0x%08X\n", irr); if (unlikely(irr == 0)) { /* Probably shared interrupt line */ - SSI_LOG_ERR("Got interrupt with empty IRR\n"); + dev_err(dev, "Got interrupt with empty IRR\n"); return IRQ_NONE; } imr = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IMR)); @@ -156,13 +133,15 @@ static irqreturn_t cc_isr(int irq, void *dev_id) /* Read the AXI error ID */ axi_err = CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_MON_ERR)); - SSI_LOG_DEBUG("AXI completion error: axim_mon_err=0x%08X\n", axi_err); + dev_dbg(dev, "AXI completion error: axim_mon_err=0x%08X\n", + axi_err); irr &= ~SSI_AXI_ERR_IRQ_MASK; } if (unlikely(irr != 0)) { - SSI_LOG_DEBUG("IRR includes unknown cause bits (0x%08X)\n", irr); + dev_dbg(dev, "IRR includes unknown cause bits (0x%08X)\n", + irr); /* Just warning */ } @@ -173,19 +152,22 @@ int init_cc_regs(struct ssi_drvdata *drvdata, bool is_probe) { unsigned int val, cache_params; void __iomem *cc_base = drvdata->cc_base; + struct device *dev = drvdata_to_dev(drvdata); /* Unmask all AXI interrupt sources AXI_CFG1 register */ val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CFG)); CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CFG), val & ~SSI_AXI_IRQ_MASK); - SSI_LOG_DEBUG("AXIM_CFG=0x%08X\n", CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CFG))); + dev_dbg(dev, "AXIM_CFG=0x%08X\n", + CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CFG))); /* Clear all pending interrupts */ val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IRR)); - SSI_LOG_DEBUG("IRR=0x%08X\n", val); + dev_dbg(dev, "IRR=0x%08X\n", val); CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_ICR), val); /* Unmask relevant interrupt cause */ - val = (~(SSI_COMP_IRQ_MASK | SSI_AXI_ERR_IRQ_MASK | SSI_GPR0_IRQ_MASK)); + val = (unsigned int)(~(SSI_COMP_IRQ_MASK | SSI_AXI_ERR_IRQ_MASK | + SSI_GPR0_IRQ_MASK)); CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IMR), val); #ifdef DX_HOST_IRQ_TIMER_INIT_VAL_REG_OFFSET @@ -195,8 +177,8 @@ int init_cc_regs(struct ssi_drvdata *drvdata, bool is_probe) DX_IRQ_DELAY); #endif if (CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IRQ_TIMER_INIT_VAL)) > 0) { - SSI_LOG_DEBUG("irq_delay=%d CC cycles\n", - CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IRQ_TIMER_INIT_VAL))); + dev_dbg(dev, "irq_delay=%d CC cycles\n", + CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IRQ_TIMER_INIT_VAL))); } #endif @@ -205,15 +187,15 @@ int init_cc_regs(struct ssi_drvdata *drvdata, bool is_probe) val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CACHE_PARAMS)); if (is_probe) - SSI_LOG_INFO("Cache params previous: 0x%08X\n", val); + dev_info(dev, "Cache params previous: 0x%08X\n", val); CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CACHE_PARAMS), cache_params); val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(CRY_KERNEL, AXIM_CACHE_PARAMS)); if (is_probe) - SSI_LOG_INFO("Cache params current: 0x%08X (expect: 0x%08X)\n", - val, cache_params); + dev_info(dev, "Cache params current: 0x%08X (expect: 0x%08X)\n", + val, cache_params); return 0; } @@ -222,181 +204,159 @@ static int init_cc_resources(struct platform_device *plat_dev) { struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; - bool irq_registered = false; - struct ssi_drvdata *new_drvdata = kzalloc(sizeof(*new_drvdata), - GFP_KERNEL); + struct ssi_drvdata *new_drvdata; struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; u32 signature_val; int rc = 0; - if (unlikely(!new_drvdata)) { - SSI_LOG_ERR("Failed to allocate drvdata"); + new_drvdata = devm_kzalloc(dev, sizeof(*new_drvdata), GFP_KERNEL); + if (!new_drvdata) { rc = -ENOMEM; - goto init_cc_res_err; + goto post_drvdata_err; } + platform_set_drvdata(plat_dev, new_drvdata); + new_drvdata->plat_dev = plat_dev; new_drvdata->clk = of_clk_get(np, 0); new_drvdata->coherent = of_dma_is_coherent(np); - /*Initialize inflight counter used in dx_ablkcipher_secure_complete used for count of BYSPASS blocks operations*/ - new_drvdata->inflight_counter = 0; - - dev_set_drvdata(&plat_dev->dev, new_drvdata); /* Get device resources */ /* First CC registers space */ - new_drvdata->res_mem = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); - if (unlikely(!new_drvdata->res_mem)) { - SSI_LOG_ERR("Failed getting IO memory resource\n"); - rc = -ENODEV; - goto init_cc_res_err; - } - SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n", - new_drvdata->res_mem->name, - new_drvdata->res_mem->start, - new_drvdata->res_mem->end); + req_mem_cc_regs = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); /* Map registers space */ - req_mem_cc_regs = request_mem_region(new_drvdata->res_mem->start, resource_size(new_drvdata->res_mem), "arm_cc7x_regs"); - if (unlikely(!req_mem_cc_regs)) { - SSI_LOG_ERR("Couldn't allocate registers memory region at " - "0x%08X\n", (unsigned int)new_drvdata->res_mem->start); - rc = -EBUSY; - goto init_cc_res_err; - } - cc_base = ioremap(new_drvdata->res_mem->start, resource_size(new_drvdata->res_mem)); - if (unlikely(!cc_base)) { - SSI_LOG_ERR("ioremap[CC](0x%08X,0x%08X) failed\n", - (unsigned int)new_drvdata->res_mem->start, - (unsigned int)resource_size(new_drvdata->res_mem)); - rc = -ENOMEM; - goto init_cc_res_err; + new_drvdata->cc_base = devm_ioremap_resource(dev, req_mem_cc_regs); + if (IS_ERR(new_drvdata->cc_base)) { + dev_err(dev, "Failed to ioremap registers"); + rc = PTR_ERR(new_drvdata->cc_base); + goto post_drvdata_err; } - SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", &new_drvdata->res_mem->start, cc_base); - new_drvdata->cc_base = cc_base; + + dev_dbg(dev, "Got MEM resource (%s): %pR\n", req_mem_cc_regs->name, + req_mem_cc_regs); + dev_dbg(dev, "CC registers mapped from %pa to 0x%p\n", + &req_mem_cc_regs->start, new_drvdata->cc_base); + + cc_base = new_drvdata->cc_base; /* Then IRQ */ - new_drvdata->res_irq = platform_get_resource(plat_dev, IORESOURCE_IRQ, 0); - if (unlikely(!new_drvdata->res_irq)) { - SSI_LOG_ERR("Failed getting IRQ resource\n"); - rc = -ENODEV; - goto init_cc_res_err; - } - rc = request_irq(new_drvdata->res_irq->start, cc_isr, - IRQF_SHARED, "arm_cc7x", new_drvdata); - if (unlikely(rc != 0)) { - SSI_LOG_ERR("Could not register to interrupt %llu\n", - (unsigned long long)new_drvdata->res_irq->start); - goto init_cc_res_err; + new_drvdata->irq = platform_get_irq(plat_dev, 0); + if (new_drvdata->irq < 0) { + dev_err(dev, "Failed getting IRQ resource\n"); + rc = new_drvdata->irq; + goto post_drvdata_err; } - init_completion(&new_drvdata->icache_setup_completion); - irq_registered = true; - SSI_LOG_DEBUG("Registered to IRQ (%s) %llu\n", - new_drvdata->res_irq->name, - (unsigned long long)new_drvdata->res_irq->start); - - new_drvdata->plat_dev = plat_dev; + rc = devm_request_irq(dev, new_drvdata->irq, cc_isr, + IRQF_SHARED, "arm_cc7x", new_drvdata); + if (rc) { + dev_err(dev, "Could not register to interrupt %d\n", + new_drvdata->irq); + goto post_drvdata_err; + } + dev_dbg(dev, "Registered to IRQ: %d\n", new_drvdata->irq); rc = cc_clk_on(new_drvdata); if (rc) - goto init_cc_res_err; + goto post_drvdata_err; - if (!new_drvdata->plat_dev->dev.dma_mask) - new_drvdata->plat_dev->dev.dma_mask = &new_drvdata->plat_dev->dev.coherent_dma_mask; + if (!dev->dma_mask) + dev->dma_mask = &dev->coherent_dma_mask; - if (!new_drvdata->plat_dev->dev.coherent_dma_mask) - new_drvdata->plat_dev->dev.coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN); + if (!dev->coherent_dma_mask) + dev->coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN); /* Verify correct mapping */ signature_val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_SIGNATURE)); if (signature_val != DX_DEV_SIGNATURE) { - SSI_LOG_ERR("Invalid CC signature: SIGNATURE=0x%08X != expected=0x%08X\n", - signature_val, (u32)DX_DEV_SIGNATURE); + dev_err(dev, "Invalid CC signature: SIGNATURE=0x%08X != expected=0x%08X\n", + signature_val, (u32)DX_DEV_SIGNATURE); rc = -EINVAL; - goto init_cc_res_err; + goto post_clk_err; } - SSI_LOG_DEBUG("CC SIGNATURE=0x%08X\n", signature_val); + dev_dbg(dev, "CC SIGNATURE=0x%08X\n", signature_val); /* Display HW versions */ - SSI_LOG(KERN_INFO, "ARM CryptoCell %s Driver: HW version 0x%08X, Driver version %s\n", SSI_DEV_NAME_STR, - CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_VERSION)), DRV_MODULE_VERSION); + dev_info(dev, "ARM CryptoCell %s Driver: HW version 0x%08X, Driver version %s\n", + SSI_DEV_NAME_STR, + CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_VERSION)), + DRV_MODULE_VERSION); rc = init_cc_regs(new_drvdata, true); if (unlikely(rc != 0)) { - SSI_LOG_ERR("init_cc_regs failed\n"); - goto init_cc_res_err; + dev_err(dev, "init_cc_regs failed\n"); + goto post_clk_err; } #ifdef ENABLE_CC_SYSFS - rc = ssi_sysfs_init(&plat_dev->dev.kobj, new_drvdata); + rc = ssi_sysfs_init(&dev->kobj, new_drvdata); if (unlikely(rc != 0)) { - SSI_LOG_ERR("init_stat_db failed\n"); - goto init_cc_res_err; + dev_err(dev, "init_stat_db failed\n"); + goto post_regs_err; } #endif + rc = ssi_fips_init(new_drvdata); + if (unlikely(rc != 0)) { + dev_err(dev, "SSI_FIPS_INIT failed 0x%x\n", rc); + goto post_sysfs_err; + } rc = ssi_sram_mgr_init(new_drvdata); if (unlikely(rc != 0)) { - SSI_LOG_ERR("ssi_sram_mgr_init failed\n"); - goto init_cc_res_err; + dev_err(dev, "ssi_sram_mgr_init failed\n"); + goto post_fips_init_err; } new_drvdata->mlli_sram_addr = ssi_sram_mgr_alloc(new_drvdata, MAX_MLLI_BUFF_SIZE); if (unlikely(new_drvdata->mlli_sram_addr == NULL_SRAM_ADDR)) { - SSI_LOG_ERR("Failed to alloc MLLI Sram buffer\n"); + dev_err(dev, "Failed to alloc MLLI Sram buffer\n"); rc = -ENOMEM; - goto init_cc_res_err; + goto post_sram_mgr_err; } rc = request_mgr_init(new_drvdata); if (unlikely(rc != 0)) { - SSI_LOG_ERR("request_mgr_init failed\n"); - goto init_cc_res_err; + dev_err(dev, "request_mgr_init failed\n"); + goto post_sram_mgr_err; } rc = ssi_buffer_mgr_init(new_drvdata); if (unlikely(rc != 0)) { - SSI_LOG_ERR("buffer_mgr_init failed\n"); - goto init_cc_res_err; + dev_err(dev, "buffer_mgr_init failed\n"); + goto post_req_mgr_err; } rc = ssi_power_mgr_init(new_drvdata); if (unlikely(rc != 0)) { - SSI_LOG_ERR("ssi_power_mgr_init failed\n"); - goto init_cc_res_err; - } - - rc = ssi_fips_init(new_drvdata); - if (unlikely(rc != 0)) { - SSI_LOG_ERR("SSI_FIPS_INIT failed 0x%x\n", rc); - goto init_cc_res_err; + dev_err(dev, "ssi_power_mgr_init failed\n"); + goto post_buf_mgr_err; } rc = ssi_ivgen_init(new_drvdata); if (unlikely(rc != 0)) { - SSI_LOG_ERR("ssi_ivgen_init failed\n"); - goto init_cc_res_err; + dev_err(dev, "ssi_ivgen_init failed\n"); + goto post_power_mgr_err; } /* Allocate crypto algs */ rc = ssi_ablkcipher_alloc(new_drvdata); if (unlikely(rc != 0)) { - SSI_LOG_ERR("ssi_ablkcipher_alloc failed\n"); - goto init_cc_res_err; + dev_err(dev, "ssi_ablkcipher_alloc failed\n"); + goto post_ivgen_err; } /* hash must be allocated before aead since hash exports APIs */ rc = ssi_hash_alloc(new_drvdata); if (unlikely(rc != 0)) { - SSI_LOG_ERR("ssi_hash_alloc failed\n"); - goto init_cc_res_err; + dev_err(dev, "ssi_hash_alloc failed\n"); + goto post_cipher_err; } rc = ssi_aead_alloc(new_drvdata); if (unlikely(rc != 0)) { - SSI_LOG_ERR("ssi_aead_alloc failed\n"); - goto init_cc_res_err; + dev_err(dev, "ssi_aead_alloc failed\n"); + goto post_hash_err; } /* If we got here and FIPS mode is enabled @@ -407,38 +367,32 @@ static int init_cc_resources(struct platform_device *plat_dev) return 0; -init_cc_res_err: - SSI_LOG_ERR("Freeing CC HW resources!\n"); - - if (new_drvdata) { - ssi_aead_free(new_drvdata); - ssi_hash_free(new_drvdata); - ssi_ablkcipher_free(new_drvdata); - ssi_ivgen_fini(new_drvdata); - ssi_power_mgr_fini(new_drvdata); - ssi_buffer_mgr_fini(new_drvdata); - request_mgr_fini(new_drvdata); - ssi_sram_mgr_fini(new_drvdata); - ssi_fips_fini(new_drvdata); +post_hash_err: + ssi_hash_free(new_drvdata); +post_cipher_err: + ssi_ablkcipher_free(new_drvdata); +post_ivgen_err: + ssi_ivgen_fini(new_drvdata); +post_power_mgr_err: + ssi_power_mgr_fini(new_drvdata); +post_buf_mgr_err: + ssi_buffer_mgr_fini(new_drvdata); +post_req_mgr_err: + request_mgr_fini(new_drvdata); +post_sram_mgr_err: + ssi_sram_mgr_fini(new_drvdata); +post_fips_init_err: + ssi_fips_fini(new_drvdata); +post_sysfs_err: #ifdef ENABLE_CC_SYSFS - ssi_sysfs_fini(); + ssi_sysfs_fini(); #endif - - if (req_mem_cc_regs) { - if (irq_registered) { - free_irq(new_drvdata->res_irq->start, new_drvdata); - new_drvdata->res_irq = NULL; - iounmap(cc_base); - new_drvdata->cc_base = NULL; - } - release_mem_region(new_drvdata->res_mem->start, - resource_size(new_drvdata->res_mem)); - new_drvdata->res_mem = NULL; - } - kfree(new_drvdata); - dev_set_drvdata(&plat_dev->dev, NULL); - } - +post_regs_err: + fini_cc_regs(new_drvdata); +post_clk_err: + cc_clk_off(new_drvdata); +post_drvdata_err: + dev_err(dev, "ccree init error occurred!\n"); return rc; } @@ -452,7 +406,7 @@ void fini_cc_regs(struct ssi_drvdata *drvdata) static void cleanup_cc_resources(struct platform_device *plat_dev) { struct ssi_drvdata *drvdata = - (struct ssi_drvdata *)dev_get_drvdata(&plat_dev->dev); + (struct ssi_drvdata *)platform_get_drvdata(plat_dev); ssi_aead_free(drvdata); ssi_hash_free(drvdata); @@ -466,22 +420,8 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - fini_cc_regs(drvdata); cc_clk_off(drvdata); - free_irq(drvdata->res_irq->start, drvdata); - drvdata->res_irq = NULL; - - if (drvdata->cc_base) { - iounmap(drvdata->cc_base); - release_mem_region(drvdata->res_mem->start, - resource_size(drvdata->res_mem)); - drvdata->cc_base = NULL; - drvdata->res_mem = NULL; - } - - kfree(drvdata); - dev_set_drvdata(&plat_dev->dev, NULL); } int cc_clk_on(struct ssi_drvdata *drvdata) @@ -514,18 +454,19 @@ void cc_clk_off(struct ssi_drvdata *drvdata) static int cc7x_probe(struct platform_device *plat_dev) { int rc; + struct device *dev = &plat_dev->dev; #if defined(CONFIG_ARM) && defined(CC_DEBUG) u32 ctr, cacheline_size; asm volatile("mrc p15, 0, %0, c0, c0, 1" : "=r" (ctr)); cacheline_size = 4 << ((ctr >> 16) & 0xf); - SSI_LOG_DEBUG("CP15(L1_CACHE_BYTES) = %u , Kconfig(L1_CACHE_BYTES) = %u\n", - cacheline_size, L1_CACHE_BYTES); + dev_dbg(dev, "CP15(L1_CACHE_BYTES) = %u , Kconfig(L1_CACHE_BYTES) = %u\n", + cacheline_size, L1_CACHE_BYTES); asm volatile("mrc p15, 0, %0, c0, c0, 0" : "=r" (ctr)); - SSI_LOG_DEBUG("Main ID register (MIDR): Implementer 0x%02X, Arch 0x%01X, Part 0x%03X, Rev r%dp%d\n", - (ctr >> 24), (ctr >> 16) & 0xF, (ctr >> 4) & 0xFFF, - (ctr >> 20) & 0xF, ctr & 0xF); + dev_dbg(dev, "Main ID register (MIDR): Implementer 0x%02X, Arch 0x%01X, Part 0x%03X, Rev r%dp%d\n", + (ctr >> 24), (ctr >> 16) & 0xF, (ctr >> 4) & 0xFFF, + (ctr >> 20) & 0xF, ctr & 0xF); #endif /* Map registers space */ @@ -533,18 +474,20 @@ static int cc7x_probe(struct platform_device *plat_dev) if (rc != 0) return rc; - SSI_LOG(KERN_INFO, "ARM cc7x_ree device initialized\n"); + dev_info(dev, "ARM ccree device initialized\n"); return 0; } static int cc7x_remove(struct platform_device *plat_dev) { - SSI_LOG_DEBUG("Releasing cc7x resources...\n"); + struct device *dev = &plat_dev->dev; + + dev_dbg(dev, "Releasing cc7x resources...\n"); cleanup_cc_resources(plat_dev); - SSI_LOG(KERN_INFO, "ARM cc7x_ree device terminated\n"); + dev_info(dev, "ARM ccree device terminated\n"); return 0; } diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index b6ad89ae9bee..488f66541c4c 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -37,6 +37,7 @@ #include <crypto/hash.h> #include <linux/version.h> #include <linux/clk.h> +#include <linux/platform_device.h> /* Registers definitions from shared/hw/ree_include */ #include "dx_reg_base_host.h" @@ -68,12 +69,12 @@ #define SSI_AXI_IRQ_MASK ((1 << DX_AXIM_CFG_BRESPMASK_BIT_SHIFT) | (1 << DX_AXIM_CFG_RRESPMASK_BIT_SHIFT) | \ (1 << DX_AXIM_CFG_INFLTMASK_BIT_SHIFT) | (1 << DX_AXIM_CFG_COMPMASK_BIT_SHIFT)) -#define SSI_AXI_ERR_IRQ_MASK (1 << DX_HOST_IRR_AXI_ERR_INT_BIT_SHIFT) +#define SSI_AXI_ERR_IRQ_MASK BIT(DX_HOST_IRR_AXI_ERR_INT_BIT_SHIFT) -#define SSI_COMP_IRQ_MASK (1 << DX_HOST_IRR_AXIM_COMP_INT_BIT_SHIFT) +#define SSI_COMP_IRQ_MASK BIT(DX_HOST_IRR_AXIM_COMP_INT_BIT_SHIFT) /* TEE FIPS status interrupt */ -#define SSI_GPR0_IRQ_MASK (1 << DX_HOST_IRR_GPR0_BIT_SHIFT) +#define SSI_GPR0_IRQ_MASK BIT(DX_HOST_IRR_GPR0_BIT_SHIFT) #define SSI_CRA_PRIO 3000 @@ -90,19 +91,6 @@ * field in the HW descriptor. The DMA engine +8 that value. */ -/* Logging macros */ -#define SSI_LOG(level, format, ...) \ - printk(level "cc715ree::%s: " format, __func__, ##__VA_ARGS__) -#define SSI_LOG_ERR(format, ...) SSI_LOG(KERN_ERR, format, ##__VA_ARGS__) -#define SSI_LOG_WARNING(format, ...) SSI_LOG(KERN_WARNING, format, ##__VA_ARGS__) -#define SSI_LOG_NOTICE(format, ...) SSI_LOG(KERN_NOTICE, format, ##__VA_ARGS__) -#define SSI_LOG_INFO(format, ...) SSI_LOG(KERN_INFO, format, ##__VA_ARGS__) -#ifdef CC_DEBUG -#define SSI_LOG_DEBUG(format, ...) SSI_LOG(KERN_DEBUG, format, ##__VA_ARGS__) -#else /* Debug log messages are removed at compile time for non-DEBUG config. */ -#define SSI_LOG_DEBUG(format, ...) do {} while (0) -#endif - #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) > (b)) ? (a) : (b)) @@ -128,10 +116,8 @@ struct ssi_crypto_req { * @fw_ver: SeP loaded firmware version */ struct ssi_drvdata { - struct resource *res_mem; - struct resource *res_irq; void __iomem *cc_base; - unsigned int irq; + int irq; u32 irq_mask; u32 fw_ver; /* Calibration time of start/stop @@ -140,7 +126,6 @@ struct ssi_drvdata { u32 monitor_null_cycles; struct platform_device *plat_dev; ssi_sram_addr_t mlli_sram_addr; - struct completion icache_setup_completion; void *buff_mgr_handle; void *hash_handle; void *aead_handle; @@ -187,11 +172,16 @@ struct async_gen_req_ctx { enum drv_crypto_direction op_type; }; +static inline struct device *drvdata_to_dev(struct ssi_drvdata *drvdata) +{ + return &drvdata->plat_dev->dev; +} + #ifdef DX_DUMP_BYTES void dump_byte_array(const char *name, const u8 *the_array, unsigned long size); #else -#define dump_byte_array(name, array, size) do { \ -} while (0); +static inline void dump_byte_array(const char *name, const u8 *the_array, + unsigned long size) {}; #endif int init_cc_regs(struct ssi_drvdata *drvdata, bool is_probe); diff --git a/drivers/staging/ccree/ssi_fips.c b/drivers/staging/ccree/ssi_fips.c index 33d53d64603d..15009a2ec329 100644 --- a/drivers/staging/ccree/ssi_fips.c +++ b/drivers/staging/ccree/ssi_fips.c @@ -76,18 +76,19 @@ void fips_handler(struct ssi_drvdata *drvdata) tasklet_schedule(&fips_handle_ptr->tasklet); } -static inline void tee_fips_error(void) +static inline void tee_fips_error(struct device *dev) { if (fips_enabled) panic("ccree: TEE reported cryptographic error in fips mode!\n"); else - SSI_LOG_ERR("TEE reported error!\n"); + dev_err(dev, "TEE reported error!\n"); } /* Deferred service handler, run as interrupt-fired tasklet */ static void fips_dsr(unsigned long devarg) { struct ssi_drvdata *drvdata = (struct ssi_drvdata *)devarg; + struct device *dev = drvdata_to_dev(drvdata); void __iomem *cc_base = drvdata->cc_base; u32 irq, state, val; @@ -97,7 +98,7 @@ static void fips_dsr(unsigned long devarg) state = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, GPR_HOST)); if (state != (CC_FIPS_SYNC_TEE_STATUS | CC_FIPS_SYNC_MODULE_OK)) - tee_fips_error(); + tee_fips_error(dev); } /* after verifing that there is nothing to do, @@ -111,6 +112,7 @@ static void fips_dsr(unsigned long devarg) int ssi_fips_init(struct ssi_drvdata *p_drvdata) { struct ssi_fips_handle *fips_h; + struct device *dev = drvdata_to_dev(p_drvdata); fips_h = kzalloc(sizeof(*fips_h), GFP_KERNEL); if (!fips_h) @@ -118,11 +120,11 @@ int ssi_fips_init(struct ssi_drvdata *p_drvdata) p_drvdata->fips_handle = fips_h; - SSI_LOG_DEBUG("Initializing fips tasklet\n"); + dev_dbg(dev, "Initializing fips tasklet\n"); tasklet_init(&fips_h->tasklet, fips_dsr, (unsigned long)p_drvdata); if (!cc_get_tee_fips_status(p_drvdata)) - tee_fips_error(); + tee_fips_error(dev); return 0; } diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index 13291aeaf350..d79090ed7f9c 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -134,14 +134,13 @@ static int ssi_hash_map_result(struct device *dev, digestsize, DMA_BIDIRECTIONAL); if (unlikely(dma_mapping_error(dev, state->digest_result_dma_addr))) { - SSI_LOG_ERR("Mapping digest result buffer %u B for DMA failed\n", - digestsize); + dev_err(dev, "Mapping digest result buffer %u B for DMA failed\n", + digestsize); return -ENOMEM; } - SSI_LOG_DEBUG("Mapped digest result buffer %u B " - "at va=%pK to dma=%pad\n", + dev_dbg(dev, "Mapped digest result buffer %u B at va=%pK to dma=%pad\n", digestsize, state->digest_result_buff, - state->digest_result_dma_addr); + &state->digest_result_dma_addr); return 0; } @@ -158,54 +157,50 @@ static int ssi_hash_map_request(struct device *dev, int rc = -ENOMEM; state->buff0 = kzalloc(SSI_MAX_HASH_BLCK_SIZE, GFP_KERNEL | GFP_DMA); - if (!state->buff0) { - SSI_LOG_ERR("Allocating buff0 in context failed\n"); + if (!state->buff0) goto fail0; - } + state->buff1 = kzalloc(SSI_MAX_HASH_BLCK_SIZE, GFP_KERNEL | GFP_DMA); - if (!state->buff1) { - SSI_LOG_ERR("Allocating buff1 in context failed\n"); + if (!state->buff1) goto fail_buff0; - } + state->digest_result_buff = kzalloc(SSI_MAX_HASH_DIGEST_SIZE, GFP_KERNEL | GFP_DMA); - if (!state->digest_result_buff) { - SSI_LOG_ERR("Allocating digest_result_buff in context failed\n"); + if (!state->digest_result_buff) goto fail_buff1; - } + state->digest_buff = kzalloc(ctx->inter_digestsize, GFP_KERNEL | GFP_DMA); - if (!state->digest_buff) { - SSI_LOG_ERR("Allocating digest-buffer in context failed\n"); + if (!state->digest_buff) goto fail_digest_result_buff; - } - SSI_LOG_DEBUG("Allocated digest-buffer in context ctx->digest_buff=@%p\n", state->digest_buff); + dev_dbg(dev, "Allocated digest-buffer in context ctx->digest_buff=@%p\n", + state->digest_buff); if (ctx->hw_mode != DRV_CIPHER_XCBC_MAC) { state->digest_bytes_len = kzalloc(HASH_LEN_SIZE, GFP_KERNEL | GFP_DMA); - if (!state->digest_bytes_len) { - SSI_LOG_ERR("Allocating digest-bytes-len in context failed\n"); + if (!state->digest_bytes_len) goto fail1; - } - SSI_LOG_DEBUG("Allocated digest-bytes-len in context state->>digest_bytes_len=@%p\n", state->digest_bytes_len); + + dev_dbg(dev, "Allocated digest-bytes-len in context state->>digest_bytes_len=@%p\n", + state->digest_bytes_len); } else { state->digest_bytes_len = NULL; } state->opad_digest_buff = kzalloc(ctx->inter_digestsize, GFP_KERNEL | GFP_DMA); - if (!state->opad_digest_buff) { - SSI_LOG_ERR("Allocating opad-digest-buffer in context failed\n"); + if (!state->opad_digest_buff) goto fail2; - } - SSI_LOG_DEBUG("Allocated opad-digest-buffer in context state->digest_bytes_len=@%p\n", state->opad_digest_buff); + + dev_dbg(dev, "Allocated opad-digest-buffer in context state->digest_bytes_len=@%p\n", + state->opad_digest_buff); state->digest_buff_dma_addr = dma_map_single(dev, (void *)state->digest_buff, ctx->inter_digestsize, DMA_BIDIRECTIONAL); if (dma_mapping_error(dev, state->digest_buff_dma_addr)) { - SSI_LOG_ERR("Mapping digest len %d B at va=%pK for DMA failed\n", - ctx->inter_digestsize, state->digest_buff); + dev_err(dev, "Mapping digest len %d B at va=%pK for DMA failed\n", + ctx->inter_digestsize, state->digest_buff); goto fail3; } - SSI_LOG_DEBUG("Mapped digest %d B at va=%pK to dma=%pad\n", - ctx->inter_digestsize, state->digest_buff, - state->digest_buff_dma_addr); + dev_dbg(dev, "Mapped digest %d B at va=%pK to dma=%pad\n", + ctx->inter_digestsize, state->digest_buff, + &state->digest_buff_dma_addr); if (is_hmac) { dma_sync_single_for_cpu(dev, ctx->digest_buff_dma_addr, ctx->inter_digestsize, DMA_BIDIRECTIONAL); @@ -240,7 +235,7 @@ static int ssi_hash_map_request(struct device *dev, rc = send_request(ctx->drvdata, &ssi_req, &desc, 1, 0); if (unlikely(rc != 0)) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); goto fail4; } } @@ -248,13 +243,13 @@ static int ssi_hash_map_request(struct device *dev, if (ctx->hw_mode != DRV_CIPHER_XCBC_MAC) { state->digest_bytes_len_dma_addr = dma_map_single(dev, (void *)state->digest_bytes_len, HASH_LEN_SIZE, DMA_BIDIRECTIONAL); if (dma_mapping_error(dev, state->digest_bytes_len_dma_addr)) { - SSI_LOG_ERR("Mapping digest len %u B at va=%pK for DMA failed\n", - HASH_LEN_SIZE, state->digest_bytes_len); + dev_err(dev, "Mapping digest len %u B at va=%pK for DMA failed\n", + HASH_LEN_SIZE, state->digest_bytes_len); goto fail4; } - SSI_LOG_DEBUG("Mapped digest len %u B at va=%pK to dma=%pad\n", - HASH_LEN_SIZE, state->digest_bytes_len, - state->digest_bytes_len_dma_addr); + dev_dbg(dev, "Mapped digest len %u B at va=%pK to dma=%pad\n", + HASH_LEN_SIZE, state->digest_bytes_len, + &state->digest_bytes_len_dma_addr); } else { state->digest_bytes_len_dma_addr = 0; } @@ -262,14 +257,14 @@ static int ssi_hash_map_request(struct device *dev, if (is_hmac && ctx->hash_mode != DRV_HASH_NULL) { state->opad_digest_dma_addr = dma_map_single(dev, (void *)state->opad_digest_buff, ctx->inter_digestsize, DMA_BIDIRECTIONAL); if (dma_mapping_error(dev, state->opad_digest_dma_addr)) { - SSI_LOG_ERR("Mapping opad digest %d B at va=%pK for DMA failed\n", - ctx->inter_digestsize, - state->opad_digest_buff); + dev_err(dev, "Mapping opad digest %d B at va=%pK for DMA failed\n", + ctx->inter_digestsize, + state->opad_digest_buff); goto fail5; } - SSI_LOG_DEBUG("Mapped opad digest %d B at va=%pK to dma=%pad\n", - ctx->inter_digestsize, state->opad_digest_buff, - state->opad_digest_dma_addr); + dev_dbg(dev, "Mapped opad digest %d B at va=%pK to dma=%pad\n", + ctx->inter_digestsize, state->opad_digest_buff, + &state->opad_digest_dma_addr); } else { state->opad_digest_dma_addr = 0; } @@ -316,22 +311,22 @@ static void ssi_hash_unmap_request(struct device *dev, if (state->digest_buff_dma_addr != 0) { dma_unmap_single(dev, state->digest_buff_dma_addr, ctx->inter_digestsize, DMA_BIDIRECTIONAL); - SSI_LOG_DEBUG("Unmapped digest-buffer: digest_buff_dma_addr=%pad\n", - state->digest_buff_dma_addr); + dev_dbg(dev, "Unmapped digest-buffer: digest_buff_dma_addr=%pad\n", + &state->digest_buff_dma_addr); state->digest_buff_dma_addr = 0; } if (state->digest_bytes_len_dma_addr != 0) { dma_unmap_single(dev, state->digest_bytes_len_dma_addr, HASH_LEN_SIZE, DMA_BIDIRECTIONAL); - SSI_LOG_DEBUG("Unmapped digest-bytes-len buffer: digest_bytes_len_dma_addr=%pad\n", - state->digest_bytes_len_dma_addr); + dev_dbg(dev, "Unmapped digest-bytes-len buffer: digest_bytes_len_dma_addr=%pad\n", + &state->digest_bytes_len_dma_addr); state->digest_bytes_len_dma_addr = 0; } if (state->opad_digest_dma_addr != 0) { dma_unmap_single(dev, state->opad_digest_dma_addr, ctx->inter_digestsize, DMA_BIDIRECTIONAL); - SSI_LOG_DEBUG("Unmapped opad-digest: opad_digest_dma_addr=%pad\n", - state->opad_digest_dma_addr); + dev_dbg(dev, "Unmapped opad-digest: opad_digest_dma_addr=%pad\n", + &state->opad_digest_dma_addr); state->opad_digest_dma_addr = 0; } @@ -352,11 +347,9 @@ static void ssi_hash_unmap_result(struct device *dev, state->digest_result_dma_addr, digestsize, DMA_BIDIRECTIONAL); - SSI_LOG_DEBUG("unmpa digest result buffer " - "va (%pK) pa (%pad) len %u\n", - state->digest_result_buff, - state->digest_result_dma_addr, - digestsize); + dev_dbg(dev, "unmpa digest result buffer va (%pK) pa (%pad) len %u\n", + state->digest_result_buff, + &state->digest_result_dma_addr, digestsize); memcpy(result, state->digest_result_buff, digestsize); @@ -369,7 +362,7 @@ static void ssi_hash_update_complete(struct device *dev, void *ssi_req, void __i struct ahash_request *req = (struct ahash_request *)ssi_req; struct ahash_req_ctx *state = ahash_request_ctx(req); - SSI_LOG_DEBUG("req=%pK\n", req); + dev_dbg(dev, "req=%pK\n", req); ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, false); req->base.complete(&req->base, 0); @@ -383,7 +376,7 @@ static void ssi_hash_digest_complete(struct device *dev, void *ssi_req, void __i struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); u32 digestsize = crypto_ahash_digestsize(tfm); - SSI_LOG_DEBUG("req=%pK\n", req); + dev_dbg(dev, "req=%pK\n", req); ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, false); ssi_hash_unmap_result(dev, state, digestsize, req->result); @@ -399,7 +392,7 @@ static void ssi_hash_complete(struct device *dev, void *ssi_req, void __iomem *c struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); u32 digestsize = crypto_ahash_digestsize(tfm); - SSI_LOG_DEBUG("req=%pK\n", req); + dev_dbg(dev, "req=%pK\n", req); ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, false); ssi_hash_unmap_result(dev, state, digestsize, req->result); @@ -414,7 +407,7 @@ static int ssi_hash_digest(struct ahash_req_ctx *state, unsigned int nbytes, u8 *result, void *async_req) { - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); bool is_hmac = ctx->is_hmac; struct ssi_crypto_req ssi_req = {}; struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; @@ -423,20 +416,21 @@ static int ssi_hash_digest(struct ahash_req_ctx *state, int idx = 0; int rc = 0; - SSI_LOG_DEBUG("===== %s-digest (%d) ====\n", is_hmac ? "hmac" : "hash", nbytes); + dev_dbg(dev, "===== %s-digest (%d) ====\n", is_hmac ? "hmac" : "hash", + nbytes); if (unlikely(ssi_hash_map_request(dev, state, ctx) != 0)) { - SSI_LOG_ERR("map_ahash_source() failed\n"); + dev_err(dev, "map_ahash_source() failed\n"); return -ENOMEM; } if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { - SSI_LOG_ERR("map_ahash_digest() failed\n"); + dev_err(dev, "map_ahash_digest() failed\n"); return -ENOMEM; } if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, src, nbytes, 1) != 0)) { - SSI_LOG_ERR("map_ahash_request_final() failed\n"); + dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } @@ -553,7 +547,7 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE); if (async_req) { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); ssi_hash_unmap_result(dev, state, digestsize, result); ssi_hash_unmap_request(dev, state, ctx); @@ -561,7 +555,7 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE); } else { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); if (rc != 0) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); } else { ssi_buffer_mgr_unmap_hash_request(dev, state, src, false); @@ -579,14 +573,14 @@ static int ssi_hash_update(struct ahash_req_ctx *state, unsigned int nbytes, void *async_req) { - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); struct ssi_crypto_req ssi_req = {}; struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; u32 idx = 0; int rc; - SSI_LOG_DEBUG("===== %s-update (%d) ====\n", ctx->is_hmac ? - "hmac" : "hash", nbytes); + dev_dbg(dev, "===== %s-update (%d) ====\n", ctx->is_hmac ? + "hmac" : "hash", nbytes); if (nbytes == 0) { /* no real updates required */ @@ -596,12 +590,12 @@ static int ssi_hash_update(struct ahash_req_ctx *state, rc = ssi_buffer_mgr_map_hash_request_update(ctx->drvdata, state, src, nbytes, block_size); if (unlikely(rc)) { if (rc == 1) { - SSI_LOG_DEBUG(" data size not require HW update %x\n", - nbytes); + dev_dbg(dev, " data size not require HW update %x\n", + nbytes); /* No hardware updates are required */ return 0; } - SSI_LOG_ERR("map_ahash_request_update() failed\n"); + dev_err(dev, "map_ahash_request_update() failed\n"); return -ENOMEM; } @@ -653,13 +647,13 @@ static int ssi_hash_update(struct ahash_req_ctx *state, if (async_req) { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); } } else { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); if (rc != 0) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); } else { ssi_buffer_mgr_unmap_hash_request(dev, state, src, false); @@ -676,21 +670,22 @@ static int ssi_hash_finup(struct ahash_req_ctx *state, u8 *result, void *async_req) { - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); bool is_hmac = ctx->is_hmac; struct ssi_crypto_req ssi_req = {}; struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; int idx = 0; int rc; - SSI_LOG_DEBUG("===== %s-finup (%d) ====\n", is_hmac ? "hmac" : "hash", nbytes); + dev_dbg(dev, "===== %s-finup (%d) ====\n", is_hmac ? "hmac" : "hash", + nbytes); if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, src, nbytes, 1) != 0)) { - SSI_LOG_ERR("map_ahash_request_final() failed\n"); + dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { - SSI_LOG_ERR("map_ahash_digest() failed\n"); + dev_err(dev, "map_ahash_digest() failed\n"); return -ENOMEM; } @@ -783,14 +778,14 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE); if (async_req) { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); ssi_hash_unmap_result(dev, state, digestsize, result); } } else { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); if (rc != 0) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); ssi_hash_unmap_result(dev, state, digestsize, result); } else { @@ -810,22 +805,23 @@ static int ssi_hash_final(struct ahash_req_ctx *state, u8 *result, void *async_req) { - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); bool is_hmac = ctx->is_hmac; struct ssi_crypto_req ssi_req = {}; struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; int idx = 0; int rc; - SSI_LOG_DEBUG("===== %s-final (%d) ====\n", is_hmac ? "hmac" : "hash", nbytes); + dev_dbg(dev, "===== %s-final (%d) ====\n", is_hmac ? "hmac" : "hash", + nbytes); if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, src, nbytes, 0) != 0)) { - SSI_LOG_ERR("map_ahash_request_final() failed\n"); + dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { - SSI_LOG_ERR("map_ahash_digest() failed\n"); + dev_err(dev, "map_ahash_digest() failed\n"); return -ENOMEM; } @@ -927,14 +923,14 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE); if (async_req) { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); ssi_hash_unmap_result(dev, state, digestsize, result); } } else { rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); if (rc != 0) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); ssi_buffer_mgr_unmap_hash_request(dev, state, src, true); ssi_hash_unmap_result(dev, state, digestsize, result); } else { @@ -948,7 +944,7 @@ ctx->drvdata, ctx->hash_mode), HASH_LEN_SIZE); static int ssi_hash_init(struct ahash_req_ctx *state, struct ssi_hash_ctx *ctx) { - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); state->xcbc_count = 0; @@ -970,10 +966,12 @@ static int ssi_hash_setkey(void *hash, int i, idx = 0, rc = 0; struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; ssi_sram_addr_t larval_addr; - - SSI_LOG_DEBUG("start keylen: %d", keylen); + struct device *dev; ctx = crypto_ahash_ctx(((struct crypto_ahash *)hash)); + dev = drvdata_to_dev(ctx->drvdata); + dev_dbg(dev, "start keylen: %d", keylen); + blocksize = crypto_tfm_alg_blocksize(&((struct crypto_ahash *)hash)->base); digestsize = crypto_ahash_digestsize(((struct crypto_ahash *)hash)); @@ -989,18 +987,16 @@ static int ssi_hash_setkey(void *hash, if (keylen != 0) { ctx->key_params.key_dma_addr = dma_map_single( - &ctx->drvdata->plat_dev->dev, - (void *)key, + dev, (void *)key, keylen, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(&ctx->drvdata->plat_dev->dev, + if (unlikely(dma_mapping_error(dev, ctx->key_params.key_dma_addr))) { - SSI_LOG_ERR("Mapping key va=0x%p len=%u for" - " DMA failed\n", key, keylen); + dev_err(dev, "Mapping key va=0x%p len=%u for DMA failed\n", + key, keylen); return -ENOMEM; } - SSI_LOG_DEBUG("mapping key-buffer: key_dma_addr=%pad " - "keylen=%u\n", ctx->key_params.key_dma_addr, - ctx->key_params.keylen); + dev_dbg(dev, "mapping key-buffer: key_dma_addr=%pad keylen=%u\n", + &ctx->key_params.key_dma_addr, ctx->key_params.keylen); if (keylen > blocksize) { /* Load hash initial state */ @@ -1079,7 +1075,7 @@ static int ssi_hash_setkey(void *hash, rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 0); if (unlikely(rc != 0)) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); goto out; } @@ -1139,12 +1135,10 @@ out: crypto_ahash_set_flags((struct crypto_ahash *)hash, CRYPTO_TFM_RES_BAD_KEY_LEN); if (ctx->key_params.key_dma_addr) { - dma_unmap_single(&ctx->drvdata->plat_dev->dev, - ctx->key_params.key_dma_addr, + dma_unmap_single(dev, ctx->key_params.key_dma_addr, ctx->key_params.keylen, DMA_TO_DEVICE); - SSI_LOG_DEBUG("Unmapped key-buffer: key_dma_addr=%pad keylen=%u\n", - ctx->key_params.key_dma_addr, - ctx->key_params.keylen); + dev_dbg(dev, "Unmapped key-buffer: key_dma_addr=%pad keylen=%u\n", + &ctx->key_params.key_dma_addr, ctx->key_params.keylen); } return rc; } @@ -1154,10 +1148,11 @@ static int ssi_xcbc_setkey(struct crypto_ahash *ahash, { struct ssi_crypto_req ssi_req = {}; struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash); + struct device *dev = drvdata_to_dev(ctx->drvdata); int idx = 0, rc = 0; struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; - SSI_LOG_DEBUG("===== setkey (%d) ====\n", keylen); + dev_dbg(dev, "===== setkey (%d) ====\n", keylen); switch (keylen) { case AES_KEYSIZE_128: @@ -1171,19 +1166,15 @@ static int ssi_xcbc_setkey(struct crypto_ahash *ahash, ctx->key_params.keylen = keylen; ctx->key_params.key_dma_addr = dma_map_single( - &ctx->drvdata->plat_dev->dev, - (void *)key, + dev, (void *)key, keylen, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(&ctx->drvdata->plat_dev->dev, - ctx->key_params.key_dma_addr))) { - SSI_LOG_ERR("Mapping key va=0x%p len=%u for" - " DMA failed\n", key, keylen); + if (unlikely(dma_mapping_error(dev, ctx->key_params.key_dma_addr))) { + dev_err(dev, "Mapping key va=0x%p len=%u for DMA failed\n", + key, keylen); return -ENOMEM; } - SSI_LOG_DEBUG("mapping key-buffer: key_dma_addr=%pad " - "keylen=%u\n", - ctx->key_params.key_dma_addr, - ctx->key_params.keylen); + dev_dbg(dev, "mapping key-buffer: key_dma_addr=%pad keylen=%u\n", + &ctx->key_params.key_dma_addr, ctx->key_params.keylen); ctx->is_hmac = true; /* 1. Load the AES key */ @@ -1226,12 +1217,10 @@ static int ssi_xcbc_setkey(struct crypto_ahash *ahash, if (rc != 0) crypto_ahash_set_flags(ahash, CRYPTO_TFM_RES_BAD_KEY_LEN); - dma_unmap_single(&ctx->drvdata->plat_dev->dev, - ctx->key_params.key_dma_addr, + dma_unmap_single(dev, ctx->key_params.key_dma_addr, ctx->key_params.keylen, DMA_TO_DEVICE); - SSI_LOG_DEBUG("Unmapped key-buffer: key_dma_addr=%pad keylen=%u\n", - ctx->key_params.key_dma_addr, - ctx->key_params.keylen); + dev_dbg(dev, "Unmapped key-buffer: key_dma_addr=%pad keylen=%u\n", + &ctx->key_params.key_dma_addr, ctx->key_params.keylen); return rc; } @@ -1241,8 +1230,9 @@ static int ssi_cmac_setkey(struct crypto_ahash *ahash, const u8 *key, unsigned int keylen) { struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash); + struct device *dev = drvdata_to_dev(ctx->drvdata); - SSI_LOG_DEBUG("===== setkey (%d) ====\n", keylen); + dev_dbg(dev, "===== setkey (%d) ====\n", keylen); ctx->is_hmac = true; @@ -1259,16 +1249,14 @@ static int ssi_cmac_setkey(struct crypto_ahash *ahash, /* STAT_PHASE_1: Copy key to ctx */ - dma_sync_single_for_cpu(&ctx->drvdata->plat_dev->dev, - ctx->opad_tmp_keys_dma_addr, + dma_sync_single_for_cpu(dev, ctx->opad_tmp_keys_dma_addr, keylen, DMA_TO_DEVICE); memcpy(ctx->opad_tmp_keys_buff, key, keylen); if (keylen == 24) memset(ctx->opad_tmp_keys_buff + 24, 0, CC_AES_KEY_SIZE_MAX - 24); - dma_sync_single_for_device(&ctx->drvdata->plat_dev->dev, - ctx->opad_tmp_keys_dma_addr, + dma_sync_single_for_device(dev, ctx->opad_tmp_keys_dma_addr, keylen, DMA_TO_DEVICE); ctx->key_params.keylen = keylen; @@ -1279,23 +1267,21 @@ static int ssi_cmac_setkey(struct crypto_ahash *ahash, static void ssi_hash_free_ctx(struct ssi_hash_ctx *ctx) { - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); if (ctx->digest_buff_dma_addr != 0) { dma_unmap_single(dev, ctx->digest_buff_dma_addr, sizeof(ctx->digest_buff), DMA_BIDIRECTIONAL); - SSI_LOG_DEBUG("Unmapped digest-buffer: " - "digest_buff_dma_addr=%pad\n", - ctx->digest_buff_dma_addr); + dev_dbg(dev, "Unmapped digest-buffer: digest_buff_dma_addr=%pad\n", + &ctx->digest_buff_dma_addr); ctx->digest_buff_dma_addr = 0; } if (ctx->opad_tmp_keys_dma_addr != 0) { dma_unmap_single(dev, ctx->opad_tmp_keys_dma_addr, sizeof(ctx->opad_tmp_keys_buff), DMA_BIDIRECTIONAL); - SSI_LOG_DEBUG("Unmapped opad-digest: " - "opad_tmp_keys_dma_addr=%pad\n", - ctx->opad_tmp_keys_dma_addr); + dev_dbg(dev, "Unmapped opad-digest: opad_tmp_keys_dma_addr=%pad\n", + &ctx->opad_tmp_keys_dma_addr); ctx->opad_tmp_keys_dma_addr = 0; } @@ -1304,30 +1290,30 @@ static void ssi_hash_free_ctx(struct ssi_hash_ctx *ctx) static int ssi_hash_alloc_ctx(struct ssi_hash_ctx *ctx) { - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); ctx->key_params.keylen = 0; ctx->digest_buff_dma_addr = dma_map_single(dev, (void *)ctx->digest_buff, sizeof(ctx->digest_buff), DMA_BIDIRECTIONAL); if (dma_mapping_error(dev, ctx->digest_buff_dma_addr)) { - SSI_LOG_ERR("Mapping digest len %zu B at va=%pK for DMA failed\n", - sizeof(ctx->digest_buff), ctx->digest_buff); + dev_err(dev, "Mapping digest len %zu B at va=%pK for DMA failed\n", + sizeof(ctx->digest_buff), ctx->digest_buff); goto fail; } - SSI_LOG_DEBUG("Mapped digest %zu B at va=%pK to dma=%pad\n", - sizeof(ctx->digest_buff), ctx->digest_buff, - ctx->digest_buff_dma_addr); + dev_dbg(dev, "Mapped digest %zu B at va=%pK to dma=%pad\n", + sizeof(ctx->digest_buff), ctx->digest_buff, + &ctx->digest_buff_dma_addr); ctx->opad_tmp_keys_dma_addr = dma_map_single(dev, (void *)ctx->opad_tmp_keys_buff, sizeof(ctx->opad_tmp_keys_buff), DMA_BIDIRECTIONAL); if (dma_mapping_error(dev, ctx->opad_tmp_keys_dma_addr)) { - SSI_LOG_ERR("Mapping opad digest %zu B at va=%pK for DMA failed\n", - sizeof(ctx->opad_tmp_keys_buff), - ctx->opad_tmp_keys_buff); + dev_err(dev, "Mapping opad digest %zu B at va=%pK for DMA failed\n", + sizeof(ctx->opad_tmp_keys_buff), + ctx->opad_tmp_keys_buff); goto fail; } - SSI_LOG_DEBUG("Mapped opad_tmp_keys %zu B at va=%pK to dma=%pad\n", - sizeof(ctx->opad_tmp_keys_buff), ctx->opad_tmp_keys_buff, - ctx->opad_tmp_keys_dma_addr); + dev_dbg(dev, "Mapped opad_tmp_keys %zu B at va=%pK to dma=%pad\n", + sizeof(ctx->opad_tmp_keys_buff), ctx->opad_tmp_keys_buff, + &ctx->opad_tmp_keys_dma_addr); ctx->is_hmac = false; return 0; @@ -1361,8 +1347,9 @@ static int ssi_ahash_cra_init(struct crypto_tfm *tfm) static void ssi_hash_cra_exit(struct crypto_tfm *tfm) { struct ssi_hash_ctx *ctx = crypto_tfm_ctx(tfm); + struct device *dev = drvdata_to_dev(ctx->drvdata); - SSI_LOG_DEBUG("ssi_hash_cra_exit"); + dev_dbg(dev, "ssi_hash_cra_exit"); ssi_hash_free_ctx(ctx); } @@ -1371,7 +1358,7 @@ static int ssi_mac_update(struct ahash_request *req) struct ahash_req_ctx *state = ahash_request_ctx(req); struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); unsigned int block_size = crypto_tfm_alg_blocksize(&tfm->base); struct ssi_crypto_req ssi_req = {}; struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; @@ -1388,12 +1375,12 @@ static int ssi_mac_update(struct ahash_request *req) rc = ssi_buffer_mgr_map_hash_request_update(ctx->drvdata, state, req->src, req->nbytes, block_size); if (unlikely(rc)) { if (rc == 1) { - SSI_LOG_DEBUG(" data size not require HW update %x\n", - req->nbytes); + dev_dbg(dev, " data size not require HW update %x\n", + req->nbytes); /* No hardware updates are required */ return 0; } - SSI_LOG_ERR("map_ahash_request_update() failed\n"); + dev_err(dev, "map_ahash_request_update() failed\n"); return -ENOMEM; } @@ -1420,7 +1407,7 @@ static int ssi_mac_update(struct ahash_request *req) rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true); } return rc; @@ -1431,7 +1418,7 @@ static int ssi_mac_final(struct ahash_request *req) struct ahash_req_ctx *state = ahash_request_ctx(req); struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); struct ssi_crypto_req ssi_req = {}; struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; int idx = 0; @@ -1451,15 +1438,15 @@ static int ssi_mac_final(struct ahash_request *req) key_len = ctx->key_params.keylen; } - SSI_LOG_DEBUG("===== final xcbc reminder (%d) ====\n", rem_cnt); + dev_dbg(dev, "===== final xcbc reminder (%d) ====\n", rem_cnt); if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, req->src, req->nbytes, 0) != 0)) { - SSI_LOG_ERR("map_ahash_request_final() failed\n"); + dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { - SSI_LOG_ERR("map_ahash_digest() failed\n"); + dev_err(dev, "map_ahash_digest() failed\n"); return -ENOMEM; } @@ -1530,7 +1517,7 @@ static int ssi_mac_final(struct ahash_request *req) rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true); ssi_hash_unmap_result(dev, state, digestsize, req->result); } @@ -1542,7 +1529,7 @@ static int ssi_mac_finup(struct ahash_request *req) struct ahash_req_ctx *state = ahash_request_ctx(req); struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); struct ssi_crypto_req ssi_req = {}; struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; int idx = 0; @@ -1550,18 +1537,18 @@ static int ssi_mac_finup(struct ahash_request *req) u32 key_len = 0; u32 digestsize = crypto_ahash_digestsize(tfm); - SSI_LOG_DEBUG("===== finup xcbc(%d) ====\n", req->nbytes); + dev_dbg(dev, "===== finup xcbc(%d) ====\n", req->nbytes); if (state->xcbc_count > 0 && req->nbytes == 0) { - SSI_LOG_DEBUG("No data to update. Call to fdx_mac_final\n"); + dev_dbg(dev, "No data to update. Call to fdx_mac_final\n"); return ssi_mac_final(req); } if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, req->src, req->nbytes, 1) != 0)) { - SSI_LOG_ERR("map_ahash_request_final() failed\n"); + dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { - SSI_LOG_ERR("map_ahash_digest() failed\n"); + dev_err(dev, "map_ahash_digest() failed\n"); return -ENOMEM; } @@ -1601,7 +1588,7 @@ static int ssi_mac_finup(struct ahash_request *req) rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true); ssi_hash_unmap_result(dev, state, digestsize, req->result); } @@ -1613,7 +1600,7 @@ static int ssi_mac_digest(struct ahash_request *req) struct ahash_req_ctx *state = ahash_request_ctx(req); struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); u32 digestsize = crypto_ahash_digestsize(tfm); struct ssi_crypto_req ssi_req = {}; struct cc_hw_desc desc[SSI_MAX_AHASH_SEQ_LEN]; @@ -1621,19 +1608,19 @@ static int ssi_mac_digest(struct ahash_request *req) int idx = 0; int rc; - SSI_LOG_DEBUG("===== -digest mac (%d) ====\n", req->nbytes); + dev_dbg(dev, "===== -digest mac (%d) ====\n", req->nbytes); if (unlikely(ssi_hash_map_request(dev, state, ctx) != 0)) { - SSI_LOG_ERR("map_ahash_source() failed\n"); + dev_err(dev, "map_ahash_source() failed\n"); return -ENOMEM; } if (unlikely(ssi_hash_map_result(dev, state, digestsize) != 0)) { - SSI_LOG_ERR("map_ahash_digest() failed\n"); + dev_err(dev, "map_ahash_digest() failed\n"); return -ENOMEM; } if (unlikely(ssi_buffer_mgr_map_hash_request_final(ctx->drvdata, state, req->src, req->nbytes, 1) != 0)) { - SSI_LOG_ERR("map_ahash_request_final() failed\n"); + dev_err(dev, "map_ahash_request_final() failed\n"); return -ENOMEM; } @@ -1673,7 +1660,7 @@ static int ssi_mac_digest(struct ahash_request *req) rc = send_request(ctx->drvdata, &ssi_req, desc, idx, 1); if (unlikely(rc != -EINPROGRESS)) { - SSI_LOG_ERR("send_request() failed (rc=%d)\n", rc); + dev_err(dev, "send_request() failed (rc=%d)\n", rc); ssi_buffer_mgr_unmap_hash_request(dev, state, req->src, true); ssi_hash_unmap_result(dev, state, digestsize, req->result); ssi_hash_unmap_request(dev, state, ctx); @@ -1727,8 +1714,9 @@ static int ssi_ahash_init(struct ahash_request *req) struct ahash_req_ctx *state = ahash_request_ctx(req); struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); struct ssi_hash_ctx *ctx = crypto_ahash_ctx(tfm); + struct device *dev = drvdata_to_dev(ctx->drvdata); - SSI_LOG_DEBUG("===== init (%d) ====\n", req->nbytes); + dev_dbg(dev, "===== init (%d) ====\n", req->nbytes); return ssi_hash_init(state, ctx); } @@ -1737,7 +1725,7 @@ static int ssi_ahash_export(struct ahash_request *req, void *out) { struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash); - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); struct ahash_req_ctx *state = ahash_request_ctx(req); u8 *curr_buff = state->buff_index ? state->buff1 : state->buff0; u32 curr_buff_cnt = state->buff_index ? state->buff1_cnt : @@ -1778,7 +1766,7 @@ static int ssi_ahash_import(struct ahash_request *req, const void *in) { struct crypto_ahash *ahash = crypto_ahash_reqtfm(req); struct ssi_hash_ctx *ctx = crypto_ahash_ctx(ahash); - struct device *dev = &ctx->drvdata->plat_dev->dev; + struct device *dev = drvdata_to_dev(ctx->drvdata); struct ahash_req_ctx *state = ahash_request_ctx(req); u32 tmp; int rc; @@ -2054,17 +2042,17 @@ static struct ssi_hash_template driver_hash[] = { }; static struct ssi_hash_alg * -ssi_hash_create_alg(struct ssi_hash_template *template, bool keyed) +ssi_hash_create_alg(struct ssi_hash_template *template, struct device *dev, + bool keyed) { struct ssi_hash_alg *t_crypto_alg; struct crypto_alg *alg; struct ahash_alg *halg; t_crypto_alg = kzalloc(sizeof(*t_crypto_alg), GFP_KERNEL); - if (!t_crypto_alg) { - SSI_LOG_ERR("failed to allocate t_crypto_alg\n"); + if (!t_crypto_alg) return ERR_PTR(-ENOMEM); - } + t_crypto_alg->ahash_alg = template->template_ahash; halg = &t_crypto_alg->ahash_alg; @@ -2107,6 +2095,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) ssi_sram_addr_t sram_buff_ofs = hash_handle->digest_len_sram_addr; unsigned int larval_seq_len = 0; struct cc_hw_desc larval_seq[CC_DIGEST_SIZE_MAX / sizeof(u32)]; + struct device *dev = drvdata_to_dev(drvdata); int rc = 0; #if (DX_DEV_SHA_MAX > 256) int i; @@ -2191,7 +2180,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) } rc = send_request_init(drvdata, larval_seq, larval_seq_len); if (unlikely(rc != 0)) { - SSI_LOG_ERR("send_request() failed (rc = %d)\n", rc); + dev_err(dev, "send_request() failed (rc = %d)\n", rc); goto init_digest_const_err; } larval_seq_len = 0; @@ -2209,7 +2198,7 @@ int ssi_hash_init_sram_digest_consts(struct ssi_drvdata *drvdata) } rc = send_request_init(drvdata, larval_seq, larval_seq_len); if (unlikely(rc != 0)) { - SSI_LOG_ERR("send_request() failed (rc = %d)\n", rc); + dev_err(dev, "send_request() failed (rc = %d)\n", rc); goto init_digest_const_err; } #endif @@ -2223,17 +2212,15 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) struct ssi_hash_handle *hash_handle; ssi_sram_addr_t sram_buff; u32 sram_size_to_alloc; + struct device *dev = drvdata_to_dev(drvdata); int rc = 0; int alg; hash_handle = kzalloc(sizeof(*hash_handle), GFP_KERNEL); - if (!hash_handle) { - SSI_LOG_ERR("kzalloc failed to allocate %zu B\n", - sizeof(*hash_handle)); - rc = -ENOMEM; - goto fail; - } + if (!hash_handle) + return -ENOMEM; + INIT_LIST_HEAD(&hash_handle->hash_list); drvdata->hash_handle = hash_handle; sram_size_to_alloc = sizeof(digest_len_init) + @@ -2249,7 +2236,7 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) sram_buff = ssi_sram_mgr_alloc(drvdata, sram_size_to_alloc); if (sram_buff == NULL_SRAM_ADDR) { - SSI_LOG_ERR("SRAM pool exhausted\n"); + dev_err(dev, "SRAM pool exhausted\n"); rc = -ENOMEM; goto fail; } @@ -2260,31 +2247,29 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) /*must be set before the alg registration as it is being used there*/ rc = ssi_hash_init_sram_digest_consts(drvdata); if (unlikely(rc != 0)) { - SSI_LOG_ERR("Init digest CONST failed (rc=%d)\n", rc); + dev_err(dev, "Init digest CONST failed (rc=%d)\n", rc); goto fail; } - INIT_LIST_HEAD(&hash_handle->hash_list); - /* ahash registration */ for (alg = 0; alg < ARRAY_SIZE(driver_hash); alg++) { struct ssi_hash_alg *t_alg; int hw_mode = driver_hash[alg].hw_mode; /* register hmac version */ - t_alg = ssi_hash_create_alg(&driver_hash[alg], true); + t_alg = ssi_hash_create_alg(&driver_hash[alg], dev, true); if (IS_ERR(t_alg)) { rc = PTR_ERR(t_alg); - SSI_LOG_ERR("%s alg allocation failed\n", - driver_hash[alg].driver_name); + dev_err(dev, "%s alg allocation failed\n", + driver_hash[alg].driver_name); goto fail; } t_alg->drvdata = drvdata; rc = crypto_register_ahash(&t_alg->ahash_alg); if (unlikely(rc)) { - SSI_LOG_ERR("%s alg registration failed\n", - driver_hash[alg].driver_name); + dev_err(dev, "%s alg registration failed\n", + driver_hash[alg].driver_name); kfree(t_alg); goto fail; } else { @@ -2297,19 +2282,19 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) continue; /* register hash version */ - t_alg = ssi_hash_create_alg(&driver_hash[alg], false); + t_alg = ssi_hash_create_alg(&driver_hash[alg], dev, false); if (IS_ERR(t_alg)) { rc = PTR_ERR(t_alg); - SSI_LOG_ERR("%s alg allocation failed\n", - driver_hash[alg].driver_name); + dev_err(dev, "%s alg allocation failed\n", + driver_hash[alg].driver_name); goto fail; } t_alg->drvdata = drvdata; rc = crypto_register_ahash(&t_alg->ahash_alg); if (unlikely(rc)) { - SSI_LOG_ERR("%s alg registration failed\n", - driver_hash[alg].driver_name); + dev_err(dev, "%s alg registration failed\n", + driver_hash[alg].driver_name); kfree(t_alg); goto fail; } else { @@ -2443,6 +2428,7 @@ static void ssi_hash_create_data_desc(struct ahash_req_ctx *areq_ctx, unsigned int *seq_size) { unsigned int idx = *seq_size; + struct device *dev = drvdata_to_dev(ctx->drvdata); if (likely(areq_ctx->data_dma_buf_type == SSI_DMA_BUF_DLLI)) { hw_desc_init(&desc[idx]); @@ -2453,7 +2439,7 @@ static void ssi_hash_create_data_desc(struct ahash_req_ctx *areq_ctx, idx++; } else { if (areq_ctx->data_dma_buf_type == SSI_DMA_BUF_NULL) { - SSI_LOG_DEBUG(" NULL mode\n"); + dev_dbg(dev, " NULL mode\n"); /* nothing to build */ return; } @@ -2493,6 +2479,7 @@ ssi_sram_addr_t ssi_ahash_get_larval_digest_sram_addr(void *drvdata, u32 mode) { struct ssi_drvdata *_drvdata = (struct ssi_drvdata *)drvdata; struct ssi_hash_handle *hash_handle = _drvdata->hash_handle; + struct device *dev = drvdata_to_dev(_drvdata); switch (mode) { case DRV_HASH_NULL: @@ -2527,7 +2514,7 @@ ssi_sram_addr_t ssi_ahash_get_larval_digest_sram_addr(void *drvdata, u32 mode) sizeof(sha384_init)); #endif default: - SSI_LOG_ERR("Invalid hash mode (%d)\n", mode); + dev_err(dev, "Invalid hash mode (%d)\n", mode); } /*This is valid wrong value to avoid kernel crash*/ diff --git a/drivers/staging/ccree/ssi_ivgen.c b/drivers/staging/ccree/ssi_ivgen.c index b01e03231947..3f082f41ae8f 100644 --- a/drivers/staging/ccree/ssi_ivgen.c +++ b/drivers/staging/ccree/ssi_ivgen.c @@ -193,12 +193,9 @@ int ssi_ivgen_init(struct ssi_drvdata *drvdata) /* Allocate "this" context */ drvdata->ivgen_handle = kzalloc(sizeof(*drvdata->ivgen_handle), GFP_KERNEL); - if (!drvdata->ivgen_handle) { - SSI_LOG_ERR("Not enough memory to allocate IVGEN context " - "(%zu B)\n", sizeof(*drvdata->ivgen_handle)); - rc = -ENOMEM; - goto out; - } + if (!drvdata->ivgen_handle) + return -ENOMEM; + ivgen_ctx = drvdata->ivgen_handle; /* Allocate pool's header for intial enc. key/IV */ @@ -206,15 +203,15 @@ int ssi_ivgen_init(struct ssi_drvdata *drvdata) &ivgen_ctx->pool_meta_dma, GFP_KERNEL); if (!ivgen_ctx->pool_meta) { - SSI_LOG_ERR("Not enough memory to allocate DMA of pool_meta " - "(%u B)\n", SSI_IVPOOL_META_SIZE); + dev_err(device, "Not enough memory to allocate DMA of pool_meta (%u B)\n", + SSI_IVPOOL_META_SIZE); rc = -ENOMEM; goto out; } /* Allocate IV pool in SRAM */ ivgen_ctx->pool = ssi_sram_mgr_alloc(drvdata, SSI_IVPOOL_SIZE); if (ivgen_ctx->pool == NULL_SRAM_ADDR) { - SSI_LOG_ERR("SRAM pool exhausted\n"); + dev_err(device, "SRAM pool exhausted\n"); rc = -ENOMEM; goto out; } @@ -248,6 +245,7 @@ int ssi_ivgen_getiv( { struct ssi_ivgen_ctx *ivgen_ctx = drvdata->ivgen_handle; unsigned int idx = *iv_seq_len; + struct device *dev = drvdata_to_dev(drvdata); unsigned int t; if ((iv_out_size != CC_AES_IV_SIZE) && @@ -291,7 +289,7 @@ int ssi_ivgen_getiv( ivgen_ctx->next_iv_ofs += iv_out_size; if ((SSI_IVPOOL_SIZE - ivgen_ctx->next_iv_ofs) < CC_AES_IV_SIZE) { - SSI_LOG_DEBUG("Pool exhausted, regenerating iv-pool\n"); + dev_dbg(dev, "Pool exhausted, regenerating iv-pool\n"); /* pool is drained -regenerate it! */ return ssi_ivgen_generate_pool(ivgen_ctx, iv_seq, iv_seq_len); } diff --git a/drivers/staging/ccree/ssi_pm.c b/drivers/staging/ccree/ssi_pm.c index 31325e6cd4b4..11bbdbeec22e 100644 --- a/drivers/staging/ccree/ssi_pm.c +++ b/drivers/staging/ccree/ssi_pm.c @@ -40,11 +40,12 @@ int ssi_power_mgr_runtime_suspend(struct device *dev) (struct ssi_drvdata *)dev_get_drvdata(dev); int rc; - SSI_LOG_DEBUG("set HOST_POWER_DOWN_EN\n"); + dev_dbg(dev, "set HOST_POWER_DOWN_EN\n"); WRITE_REGISTER(drvdata->cc_base + CC_REG_OFFSET(HOST_RGF, HOST_POWER_DOWN_EN), POWER_DOWN_ENABLE); rc = ssi_request_mgr_runtime_suspend_queue(drvdata); if (rc != 0) { - SSI_LOG_ERR("ssi_request_mgr_runtime_suspend_queue (%x)\n", rc); + dev_err(dev, "ssi_request_mgr_runtime_suspend_queue (%x)\n", + rc); return rc; } fini_cc_regs(drvdata); @@ -58,24 +59,24 @@ int ssi_power_mgr_runtime_resume(struct device *dev) struct ssi_drvdata *drvdata = (struct ssi_drvdata *)dev_get_drvdata(dev); - SSI_LOG_DEBUG("unset HOST_POWER_DOWN_EN\n"); + dev_dbg(dev, "unset HOST_POWER_DOWN_EN\n"); WRITE_REGISTER(drvdata->cc_base + CC_REG_OFFSET(HOST_RGF, HOST_POWER_DOWN_EN), POWER_DOWN_DISABLE); rc = cc_clk_on(drvdata); if (rc) { - SSI_LOG_ERR("failed getting clock back on. We're toast.\n"); + dev_err(dev, "failed getting clock back on. We're toast.\n"); return rc; } rc = init_cc_regs(drvdata, false); if (rc != 0) { - SSI_LOG_ERR("init_cc_regs (%x)\n", rc); + dev_err(dev, "init_cc_regs (%x)\n", rc); return rc; } rc = ssi_request_mgr_runtime_resume_queue(drvdata); if (rc != 0) { - SSI_LOG_ERR("ssi_request_mgr_runtime_resume_queue (%x)\n", rc); + dev_err(dev, "ssi_request_mgr_runtime_resume_queue (%x)\n", rc); return rc; } @@ -109,7 +110,8 @@ int ssi_power_mgr_runtime_put_suspend(struct device *dev) rc = pm_runtime_put_autosuspend(dev); } else { /* Something wrong happens*/ - BUG(); + dev_err(dev, "request to suspend already suspended queue"); + rc = -EBUSY; } return rc; } @@ -120,16 +122,17 @@ int ssi_power_mgr_init(struct ssi_drvdata *drvdata) { int rc = 0; #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) - struct platform_device *plat_dev = drvdata->plat_dev; + struct device *dev = drvdata_to_dev(drvdata); + /* must be before the enabling to avoid resdundent suspending */ - pm_runtime_set_autosuspend_delay(&plat_dev->dev, SSI_SUSPEND_TIMEOUT); - pm_runtime_use_autosuspend(&plat_dev->dev); + pm_runtime_set_autosuspend_delay(dev, SSI_SUSPEND_TIMEOUT); + pm_runtime_use_autosuspend(dev); /* activate the PM module */ - rc = pm_runtime_set_active(&plat_dev->dev); + rc = pm_runtime_set_active(dev); if (rc != 0) return rc; /* enable the PM module*/ - pm_runtime_enable(&plat_dev->dev); + pm_runtime_enable(dev); #endif return rc; } @@ -137,8 +140,6 @@ int ssi_power_mgr_init(struct ssi_drvdata *drvdata) void ssi_power_mgr_fini(struct ssi_drvdata *drvdata) { #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) - struct platform_device *plat_dev = drvdata->plat_dev; - - pm_runtime_disable(&plat_dev->dev); + pm_runtime_disable(drvdata_to_dev(drvdata)); #endif } diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index e5c2f92857f6..2e0df57bc06f 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c @@ -49,7 +49,6 @@ struct ssi_request_mgr_handle { dma_addr_t dummy_comp_buff_dma; struct cc_hw_desc monitor_desc; - volatile unsigned long monitor_lock; #ifdef COMP_IN_WQ struct workqueue_struct *workq; struct delayed_work compwork; @@ -69,19 +68,19 @@ static void comp_work_handler(struct work_struct *work); void request_mgr_fini(struct ssi_drvdata *drvdata) { struct ssi_request_mgr_handle *req_mgr_h = drvdata->request_mgr_handle; + struct device *dev = drvdata_to_dev(drvdata); if (!req_mgr_h) return; /* Not allocated */ if (req_mgr_h->dummy_comp_buff_dma != 0) { - dma_free_coherent(&drvdata->plat_dev->dev, - sizeof(u32), req_mgr_h->dummy_comp_buff, + dma_free_coherent(dev, sizeof(u32), req_mgr_h->dummy_comp_buff, req_mgr_h->dummy_comp_buff_dma); } - SSI_LOG_DEBUG("max_used_hw_slots=%d\n", (req_mgr_h->hw_queue_size - + dev_dbg(dev, "max_used_hw_slots=%d\n", (req_mgr_h->hw_queue_size - req_mgr_h->min_free_hw_slots)); - SSI_LOG_DEBUG("max_used_sw_slots=%d\n", req_mgr_h->max_used_sw_slots); + dev_dbg(dev, "max_used_sw_slots=%d\n", req_mgr_h->max_used_sw_slots); #ifdef COMP_IN_WQ flush_workqueue(req_mgr_h->workq); @@ -98,6 +97,7 @@ void request_mgr_fini(struct ssi_drvdata *drvdata) int request_mgr_init(struct ssi_drvdata *drvdata) { struct ssi_request_mgr_handle *req_mgr_h; + struct device *dev = drvdata_to_dev(drvdata); int rc = 0; req_mgr_h = kzalloc(sizeof(*req_mgr_h), GFP_KERNEL); @@ -110,24 +110,24 @@ int request_mgr_init(struct ssi_drvdata *drvdata) spin_lock_init(&req_mgr_h->hw_lock); #ifdef COMP_IN_WQ - SSI_LOG_DEBUG("Initializing completion workqueue\n"); + dev_dbg(dev, "Initializing completion workqueue\n"); req_mgr_h->workq = create_singlethread_workqueue("arm_cc7x_wq"); if (unlikely(!req_mgr_h->workq)) { - SSI_LOG_ERR("Failed creating work queue\n"); + dev_err(dev, "Failed creating work queue\n"); rc = -ENOMEM; goto req_mgr_init_err; } INIT_DELAYED_WORK(&req_mgr_h->compwork, comp_work_handler); #else - SSI_LOG_DEBUG("Initializing completion tasklet\n"); + dev_dbg(dev, "Initializing completion tasklet\n"); tasklet_init(&req_mgr_h->comptask, comp_handler, (unsigned long)drvdata); #endif req_mgr_h->hw_queue_size = READ_REGISTER(drvdata->cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_SRAM_SIZE)); - SSI_LOG_DEBUG("hw_queue_size=0x%08X\n", req_mgr_h->hw_queue_size); + dev_dbg(dev, "hw_queue_size=0x%08X\n", req_mgr_h->hw_queue_size); if (req_mgr_h->hw_queue_size < MIN_HW_QUEUE_SIZE) { - SSI_LOG_ERR("Invalid HW queue size = %u (Min. required is %u)\n", - req_mgr_h->hw_queue_size, MIN_HW_QUEUE_SIZE); + dev_err(dev, "Invalid HW queue size = %u (Min. required is %u)\n", + req_mgr_h->hw_queue_size, MIN_HW_QUEUE_SIZE); rc = -ENOMEM; goto req_mgr_init_err; } @@ -135,13 +135,12 @@ int request_mgr_init(struct ssi_drvdata *drvdata) req_mgr_h->max_used_sw_slots = 0; /* Allocate DMA word for "dummy" completion descriptor use */ - req_mgr_h->dummy_comp_buff = dma_alloc_coherent(&drvdata->plat_dev->dev, - sizeof(u32), + req_mgr_h->dummy_comp_buff = dma_alloc_coherent(dev, sizeof(u32), &req_mgr_h->dummy_comp_buff_dma, GFP_KERNEL); if (!req_mgr_h->dummy_comp_buff) { - SSI_LOG_ERR("Not enough memory to allocate DMA (%zu) dropped " - "buffer\n", sizeof(u32)); + dev_err(dev, "Not enough memory to allocate DMA (%zu) dropped buffer\n", + sizeof(u32)); rc = -ENOMEM; goto req_mgr_init_err; } @@ -176,9 +175,9 @@ static inline void enqueue_seq( wmb(); writel_relaxed(seq[i].word[5], (volatile void __iomem *)(cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_WORD0))); #ifdef DX_DUMP_DESCS - SSI_LOG_DEBUG("desc[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n", i, - seq[i].word[0], seq[i].word[1], seq[i].word[2], - seq[i].word[3], seq[i].word[4], seq[i].word[5]); + dev_dbg(dev, "desc[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n", + i, seq[i].word[0], seq[i].word[1], seq[i].word[2], + seq[i].word[3], seq[i].word[4], seq[i].word[5]); #endif } } @@ -198,6 +197,7 @@ static void request_mgr_complete(struct device *dev, void *dx_compl_h, void __io } static inline int request_mgr_queues_status_check( + struct device *dev, struct ssi_request_mgr_handle *req_mgr_h, void __iomem *cc_base, unsigned int total_seq_len) @@ -211,8 +211,8 @@ static inline int request_mgr_queues_status_check( if (unlikely(((req_mgr_h->req_queue_head + 1) & (MAX_REQUEST_QUEUE_SIZE - 1)) == req_mgr_h->req_queue_tail)) { - SSI_LOG_ERR("SW FIFO is full. req_queue_head=%d sw_fifo_len=%d\n", - req_mgr_h->req_queue_head, MAX_REQUEST_QUEUE_SIZE); + dev_err(dev, "SW FIFO is full. req_queue_head=%d sw_fifo_len=%d\n", + req_mgr_h->req_queue_head, MAX_REQUEST_QUEUE_SIZE); return -EBUSY; } @@ -234,16 +234,13 @@ static inline int request_mgr_queues_status_check( return 0; } - SSI_LOG_DEBUG("HW FIFO is full. q_free_slots=%d total_seq_len=%d\n", - req_mgr_h->q_free_slots, total_seq_len); + dev_dbg(dev, "HW FIFO is full. q_free_slots=%d total_seq_len=%d\n", + req_mgr_h->q_free_slots, total_seq_len); } /* No room in the HW queue try again later */ - SSI_LOG_DEBUG("HW FIFO full, timeout. req_queue_head=%d " - "sw_fifo_len=%d q_free_slots=%d total_seq_len=%d\n", - req_mgr_h->req_queue_head, - MAX_REQUEST_QUEUE_SIZE, - req_mgr_h->q_free_slots, - total_seq_len); + dev_dbg(dev, "HW FIFO full, timeout. req_queue_head=%d sw_fifo_len=%d q_free_slots=%d total_seq_len=%d\n", + req_mgr_h->req_queue_head, MAX_REQUEST_QUEUE_SIZE, + req_mgr_h->q_free_slots, total_seq_len); return -EAGAIN; } @@ -270,6 +267,7 @@ int send_request( unsigned int iv_seq_len = 0; unsigned int total_seq_len = len; /*initial sequence length*/ struct cc_hw_desc iv_seq[SSI_IVPOOL_SEQ_LEN]; + struct device *dev = drvdata_to_dev(drvdata); int rc; unsigned int max_required_seq_len = (total_seq_len + ((ssi_req->ivgen_dma_addr_len == 0) ? 0 : @@ -277,9 +275,9 @@ int send_request( ((is_dout == 0) ? 1 : 0)); #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) - rc = ssi_power_mgr_runtime_get(&drvdata->plat_dev->dev); + rc = ssi_power_mgr_runtime_get(dev); if (rc != 0) { - SSI_LOG_ERR("ssi_power_mgr_runtime_get returned %x\n", rc); + dev_err(dev, "ssi_power_mgr_runtime_get returned %x\n", rc); return rc; } #endif @@ -291,7 +289,7 @@ int send_request( * in case iv gen add the max size and in case of no dout add 1 * for the internal completion descriptor */ - rc = request_mgr_queues_status_check(req_mgr_h, cc_base, + rc = request_mgr_queues_status_check(dev, req_mgr_h, cc_base, max_required_seq_len); if (likely(rc == 0)) /* There is enough place in the queue */ @@ -304,7 +302,7 @@ int send_request( * (SW queue is full) */ #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) - ssi_power_mgr_runtime_put_suspend(&drvdata->plat_dev->dev); + ssi_power_mgr_runtime_put_suspend(dev); #endif return rc; } @@ -324,12 +322,12 @@ int send_request( } if (ssi_req->ivgen_dma_addr_len > 0) { - SSI_LOG_DEBUG("Acquire IV from pool into %d DMA addresses %pad, %pad, %pad, IV-size=%u\n", - ssi_req->ivgen_dma_addr_len, - ssi_req->ivgen_dma_addr[0], - ssi_req->ivgen_dma_addr[1], - ssi_req->ivgen_dma_addr[2], - ssi_req->ivgen_size); + dev_dbg(dev, "Acquire IV from pool into %d DMA addresses %pad, %pad, %pad, IV-size=%u\n", + ssi_req->ivgen_dma_addr_len, + &ssi_req->ivgen_dma_addr[0], + &ssi_req->ivgen_dma_addr[1], + &ssi_req->ivgen_dma_addr[2], + ssi_req->ivgen_size); /* Acquire IV from pool */ rc = ssi_ivgen_getiv(drvdata, ssi_req->ivgen_dma_addr, @@ -337,10 +335,10 @@ int send_request( ssi_req->ivgen_size, iv_seq, &iv_seq_len); if (unlikely(rc != 0)) { - SSI_LOG_ERR("Failed to generate IV (rc=%d)\n", rc); + dev_err(dev, "Failed to generate IV (rc=%d)\n", rc); spin_unlock_bh(&req_mgr_h->hw_lock); #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) - ssi_power_mgr_runtime_put_suspend(&drvdata->plat_dev->dev); + ssi_power_mgr_runtime_put_suspend(dev); #endif return rc; } @@ -357,7 +355,7 @@ int send_request( req_mgr_h->req_queue_head = (req_mgr_h->req_queue_head + 1) & (MAX_REQUEST_QUEUE_SIZE - 1); /* TODO: Use circ_buf.h ? */ - SSI_LOG_DEBUG("Enqueue request head=%u\n", req_mgr_h->req_queue_head); + dev_dbg(dev, "Enqueue request head=%u\n", req_mgr_h->req_queue_head); #ifdef FLUSH_CACHE_ALL flush_cache_all(); @@ -369,11 +367,16 @@ int send_request( enqueue_seq(cc_base, &req_mgr_h->compl_desc, (is_dout ? 0 : 1)); if (unlikely(req_mgr_h->q_free_slots < total_seq_len)) { - /*This means that there was a problem with the resume*/ - BUG(); + /* This situation should never occur. Maybe indicating problem + * with resuming power. Set the free slot count to 0 and hope + * for the best. + */ + dev_err(dev, "HW free slot count mismatch."); + req_mgr_h->q_free_slots = 0; + } else { + /* Update the free slots in HW queue */ + req_mgr_h->q_free_slots -= total_seq_len; } - /* Update the free slots in HW queue */ - req_mgr_h->q_free_slots -= total_seq_len; spin_unlock_bh(&req_mgr_h->hw_lock); @@ -383,10 +386,9 @@ int send_request( */ wait_for_completion(&ssi_req->seq_compl); return 0; - } else { - /* Operation still in process */ - return -EINPROGRESS; } + /* Operation still in process */ + return -EINPROGRESS; } /*! @@ -403,13 +405,15 @@ int send_request( int send_request_init( struct ssi_drvdata *drvdata, struct cc_hw_desc *desc, unsigned int len) { + struct device *dev = drvdata_to_dev(drvdata); void __iomem *cc_base = drvdata->cc_base; struct ssi_request_mgr_handle *req_mgr_h = drvdata->request_mgr_handle; unsigned int total_seq_len = len; /*initial sequence length*/ int rc = 0; /* Wait for space in HW and SW FIFO. Poll for as much as FIFO_TIMEOUT. */ - rc = request_mgr_queues_status_check(req_mgr_h, cc_base, total_seq_len); + rc = request_mgr_queues_status_check(dev, req_mgr_h, cc_base, + total_seq_len); if (unlikely(rc != 0)) return rc; @@ -448,7 +452,7 @@ static void comp_work_handler(struct work_struct *work) static void proc_completions(struct ssi_drvdata *drvdata) { struct ssi_crypto_req *ssi_req; - struct platform_device *plat_dev = drvdata->plat_dev; + struct device *dev = drvdata_to_dev(drvdata); struct ssi_request_mgr_handle *request_mgr_handle = drvdata->request_mgr_handle; #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) @@ -460,8 +464,13 @@ static void proc_completions(struct ssi_drvdata *drvdata) /* Dequeue request */ if (unlikely(request_mgr_handle->req_queue_head == request_mgr_handle->req_queue_tail)) { - SSI_LOG_ERR("Request queue is empty req_queue_head==req_queue_tail==%u\n", request_mgr_handle->req_queue_head); - BUG(); + /* We are supposed to handle a completion but our + * queue is empty. This is not normal. Return and + * hope for the best. + */ + dev_err(dev, "Request queue is empty head == tail %u\n", + request_mgr_handle->req_queue_head); + break; } ssi_req = &request_mgr_handle->req_queue[request_mgr_handle->req_queue_tail]; @@ -476,21 +485,25 @@ static void proc_completions(struct ssi_drvdata *drvdata) u32 axi_err; int i; - SSI_LOG_INFO("Delay\n"); + dev_info(dev, "Delay\n"); for (i = 0; i < 1000000; i++) axi_err = READ_REGISTER(drvdata->cc_base + CC_REG_OFFSET(CRY_KERNEL, AXIM_MON_ERR)); } #endif /* COMPLETION_DELAY */ if (likely(ssi_req->user_cb)) - ssi_req->user_cb(&plat_dev->dev, ssi_req->user_arg, drvdata->cc_base); + ssi_req->user_cb(dev, ssi_req->user_arg, + drvdata->cc_base); request_mgr_handle->req_queue_tail = (request_mgr_handle->req_queue_tail + 1) & (MAX_REQUEST_QUEUE_SIZE - 1); - SSI_LOG_DEBUG("Dequeue request tail=%u\n", request_mgr_handle->req_queue_tail); - SSI_LOG_DEBUG("Request completed. axi_completed=%d\n", request_mgr_handle->axi_completed); + dev_dbg(dev, "Dequeue request tail=%u\n", + request_mgr_handle->req_queue_tail); + dev_dbg(dev, "Request completed. axi_completed=%d\n", + request_mgr_handle->axi_completed); #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP) - rc = ssi_power_mgr_runtime_put_suspend(&plat_dev->dev); + rc = ssi_power_mgr_runtime_put_suspend(dev); if (rc != 0) - SSI_LOG_ERR("Failed to set runtime suspension %d\n", rc); + dev_err(dev, "Failed to set runtime suspension %d\n", + rc); #endif } } diff --git a/drivers/staging/ccree/ssi_sram_mgr.c b/drivers/staging/ccree/ssi_sram_mgr.c index f11116afe89a..07260d168c91 100644 --- a/drivers/staging/ccree/ssi_sram_mgr.c +++ b/drivers/staging/ccree/ssi_sram_mgr.c @@ -50,28 +50,14 @@ void ssi_sram_mgr_fini(struct ssi_drvdata *drvdata) */ int ssi_sram_mgr_init(struct ssi_drvdata *drvdata) { - struct ssi_sram_mgr_ctx *smgr_ctx; - int rc; - /* Allocate "this" context */ - drvdata->sram_mgr_handle = kzalloc( - sizeof(struct ssi_sram_mgr_ctx), GFP_KERNEL); - if (!drvdata->sram_mgr_handle) { - SSI_LOG_ERR("Not enough memory to allocate SRAM_MGR ctx (%zu)\n", - sizeof(struct ssi_sram_mgr_ctx)); - rc = -ENOMEM; - goto out; - } - smgr_ctx = drvdata->sram_mgr_handle; + drvdata->sram_mgr_handle = kzalloc(sizeof(struct ssi_sram_mgr_ctx), + GFP_KERNEL); - /* Pool starts at start of SRAM */ - smgr_ctx->sram_free_offset = 0; + if (!drvdata->sram_mgr_handle) + return -ENOMEM; return 0; - -out: - ssi_sram_mgr_fini(drvdata); - return rc; } /*! @@ -86,22 +72,23 @@ out: ssi_sram_addr_t ssi_sram_mgr_alloc(struct ssi_drvdata *drvdata, u32 size) { struct ssi_sram_mgr_ctx *smgr_ctx = drvdata->sram_mgr_handle; + struct device *dev = drvdata_to_dev(drvdata); ssi_sram_addr_t p; if (unlikely((size & 0x3) != 0)) { - SSI_LOG_ERR("Requested buffer size (%u) is not multiple of 4", - size); + dev_err(dev, "Requested buffer size (%u) is not multiple of 4", + size); return NULL_SRAM_ADDR; } if (unlikely(size > (SSI_CC_SRAM_SIZE - smgr_ctx->sram_free_offset))) { - SSI_LOG_ERR("Not enough space to allocate %u B (at offset %llu)\n", - size, smgr_ctx->sram_free_offset); + dev_err(dev, "Not enough space to allocate %u B (at offset %llu)\n", + size, smgr_ctx->sram_free_offset); return NULL_SRAM_ADDR; } p = smgr_ctx->sram_free_offset; smgr_ctx->sram_free_offset += size; - SSI_LOG_DEBUG("Allocated %u B @ %u\n", size, (unsigned int)p); + dev_dbg(dev, "Allocated %u B @ %u\n", size, (unsigned int)p); return p; } diff --git a/drivers/staging/ccree/ssi_sysfs.c b/drivers/staging/ccree/ssi_sysfs.c index 0655658bba4d..c3c817ab7885 100644 --- a/drivers/staging/ccree/ssi_sysfs.c +++ b/drivers/staging/ccree/ssi_sysfs.c @@ -24,260 +24,6 @@ static struct ssi_drvdata *sys_get_drvdata(void); -#ifdef CC_CYCLE_COUNT - -#include <asm/timex.h> - -struct stat_item { - unsigned int min; - unsigned int max; - cycles_t sum; - unsigned int count; -}; - -struct stat_name { - const char *op_type_name; - const char *stat_phase_name[MAX_STAT_PHASES]; -}; - -static struct stat_name stat_name_db[MAX_STAT_OP_TYPES] = { - { - /* STAT_OP_TYPE_NULL */ - .op_type_name = "NULL", - .stat_phase_name = {NULL}, - }, - { - .op_type_name = "Encode", - .stat_phase_name[STAT_PHASE_0] = "Init and sanity checks", - .stat_phase_name[STAT_PHASE_1] = "Map buffers", - .stat_phase_name[STAT_PHASE_2] = "Create sequence", - .stat_phase_name[STAT_PHASE_3] = "Send Request", - .stat_phase_name[STAT_PHASE_4] = "HW-Q push", - .stat_phase_name[STAT_PHASE_5] = "Sequence completion", - .stat_phase_name[STAT_PHASE_6] = "HW cycles", - }, - { .op_type_name = "Decode", - .stat_phase_name[STAT_PHASE_0] = "Init and sanity checks", - .stat_phase_name[STAT_PHASE_1] = "Map buffers", - .stat_phase_name[STAT_PHASE_2] = "Create sequence", - .stat_phase_name[STAT_PHASE_3] = "Send Request", - .stat_phase_name[STAT_PHASE_4] = "HW-Q push", - .stat_phase_name[STAT_PHASE_5] = "Sequence completion", - .stat_phase_name[STAT_PHASE_6] = "HW cycles", - }, - { .op_type_name = "Setkey", - .stat_phase_name[STAT_PHASE_0] = "Init and sanity checks", - .stat_phase_name[STAT_PHASE_1] = "Copy key to ctx", - .stat_phase_name[STAT_PHASE_2] = "Create sequence", - .stat_phase_name[STAT_PHASE_3] = "Send Request", - .stat_phase_name[STAT_PHASE_4] = "HW-Q push", - .stat_phase_name[STAT_PHASE_5] = "Sequence completion", - .stat_phase_name[STAT_PHASE_6] = "HW cycles", - }, - { - .op_type_name = "Generic", - .stat_phase_name[STAT_PHASE_0] = "Interrupt", - .stat_phase_name[STAT_PHASE_1] = "ISR-to-Tasklet", - .stat_phase_name[STAT_PHASE_2] = "Tasklet start-to-end", - .stat_phase_name[STAT_PHASE_3] = "Tasklet:user_cb()", - .stat_phase_name[STAT_PHASE_4] = "Tasklet:dx_X_complete() - w/o X_complete()", - .stat_phase_name[STAT_PHASE_5] = "", - .stat_phase_name[STAT_PHASE_6] = "HW cycles", - } -}; - -/* - * Structure used to create a directory - * and its attributes in sysfs. - */ -struct sys_dir { - struct kobject *sys_dir_kobj; - struct attribute_group sys_dir_attr_group; - struct attribute **sys_dir_attr_list; - u32 num_of_attrs; - struct ssi_drvdata *drvdata; /* Associated driver context */ -}; - -/* top level directory structures */ -struct sys_dir sys_top_dir; - -static DEFINE_SPINLOCK(stat_lock); - -/* List of DBs */ -static struct stat_item stat_host_db[MAX_STAT_OP_TYPES][MAX_STAT_PHASES]; -static struct stat_item stat_cc_db[MAX_STAT_OP_TYPES][MAX_STAT_PHASES]; - -static void init_db(struct stat_item item[MAX_STAT_OP_TYPES][MAX_STAT_PHASES]) -{ - unsigned int i, j; - - /* Clear db */ - for (i = 0; i < MAX_STAT_OP_TYPES; i++) { - for (j = 0; j < MAX_STAT_PHASES; j++) { - item[i][j].min = 0xFFFFFFFF; - item[i][j].max = 0; - item[i][j].sum = 0; - item[i][j].count = 0; - } - } -} - -static void update_db(struct stat_item *item, unsigned int result) -{ - item->count++; - item->sum += result; - if (result < item->min) - item->min = result; - if (result > item->max) - item->max = result; -} - -static void display_db(struct stat_item item[MAX_STAT_OP_TYPES][MAX_STAT_PHASES]) -{ - unsigned int i, j; - u64 avg; - - for (i = STAT_OP_TYPE_ENCODE; i < MAX_STAT_OP_TYPES; i++) { - for (j = 0; j < MAX_STAT_PHASES; j++) { - if (item[i][j].count > 0) { - avg = (u64)item[i][j].sum; - do_div(avg, item[i][j].count); - SSI_LOG_ERR("%s, %s: min=%d avg=%d max=%d sum=%lld count=%d\n", - stat_name_db[i].op_type_name, - stat_name_db[i].stat_phase_name[j], - item[i][j].min, (int)avg, - item[i][j].max, - (long long)item[i][j].sum, - item[i][j].count); - } - } - } -} - -/************************************** - * Attributes show functions section * - **************************************/ - -static ssize_t ssi_sys_stats_host_db_clear(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, size_t count) -{ - init_db(stat_host_db); - return count; -} - -static ssize_t ssi_sys_stats_cc_db_clear(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, size_t count) -{ - init_db(stat_cc_db); - return count; -} - -static ssize_t ssi_sys_stat_host_db_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - int i, j; - char line[512]; - u32 min_cyc, max_cyc; - u64 avg; - ssize_t buf_len, tmp_len = 0; - - buf_len = scnprintf(buf, PAGE_SIZE, - "phase\t\t\t\t\t\t\tmin[cy]\tavg[cy]\tmax[cy]\t#samples\n"); - if (buf_len < 0)/* scnprintf shouldn't return negative value according to its implementation*/ - return buf_len; - for (i = STAT_OP_TYPE_ENCODE; i < MAX_STAT_OP_TYPES; i++) { - for (j = 0; j < MAX_STAT_PHASES - 1; j++) { - if (stat_host_db[i][j].count > 0) { - avg = (u64)stat_host_db[i][j].sum; - do_div(avg, stat_host_db[i][j].count); - min_cyc = stat_host_db[i][j].min; - max_cyc = stat_host_db[i][j].max; - } else { - avg = min_cyc = max_cyc = 0; - } - tmp_len = scnprintf(line, 512, - "%s::%s\t\t\t\t\t%6u\t%6u\t%6u\t%7u\n", - stat_name_db[i].op_type_name, - stat_name_db[i].stat_phase_name[j], - min_cyc, (unsigned int)avg, max_cyc, - stat_host_db[i][j].count); - if (tmp_len < 0)/* scnprintf shouldn't return negative value according to its implementation*/ - return buf_len; - if (buf_len + tmp_len >= PAGE_SIZE) - return buf_len; - buf_len += tmp_len; - strncat(buf, line, 512); - } - } - return buf_len; -} - -static ssize_t ssi_sys_stat_cc_db_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - int i; - char line[256]; - u32 min_cyc, max_cyc; - u64 avg; - ssize_t buf_len, tmp_len = 0; - - buf_len = scnprintf(buf, PAGE_SIZE, - "phase\tmin[cy]\tavg[cy]\tmax[cy]\t#samples\n"); - if (buf_len < 0)/* scnprintf shouldn't return negative value according to its implementation*/ - return buf_len; - for (i = STAT_OP_TYPE_ENCODE; i < MAX_STAT_OP_TYPES; i++) { - if (stat_cc_db[i][STAT_PHASE_6].count > 0) { - avg = (u64)stat_cc_db[i][STAT_PHASE_6].sum; - do_div(avg, stat_cc_db[i][STAT_PHASE_6].count); - min_cyc = stat_cc_db[i][STAT_PHASE_6].min; - max_cyc = stat_cc_db[i][STAT_PHASE_6].max; - } else { - avg = min_cyc = max_cyc = 0; - } - tmp_len = scnprintf(line, 256, "%s\t%6u\t%6u\t%6u\t%7u\n", - stat_name_db[i].op_type_name, min_cyc, - (unsigned int)avg, max_cyc, - stat_cc_db[i][STAT_PHASE_6].count); - - if (tmp_len < 0)/* scnprintf shouldn't return negative value according to its implementation*/ - return buf_len; - - if (buf_len + tmp_len >= PAGE_SIZE) - return buf_len; - buf_len += tmp_len; - strncat(buf, line, 256); - } - return buf_len; -} - -void update_host_stat(unsigned int op_type, unsigned int phase, cycles_t result) -{ - unsigned long flags; - - spin_lock_irqsave(&stat_lock, flags); - update_db(&stat_host_db[op_type][phase], (unsigned int)result); - spin_unlock_irqrestore(&stat_lock, flags); -} - -void update_cc_stat( - unsigned int op_type, - unsigned int phase, - unsigned int elapsed_cycles) -{ - update_db(&stat_cc_db[op_type][phase], elapsed_cycles); -} - -void display_all_stat_db(void) -{ - SSI_LOG_ERR("\n======= CYCLE COUNT STATS =======\n"); - display_db(stat_host_db); - SSI_LOG_ERR("\n======= CC HW CYCLE COUNT STATS =======\n"); - display_db(stat_cc_db); -} -#endif /*CC_CYCLE_COUNT*/ - static ssize_t ssi_sys_regdump_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -304,12 +50,6 @@ static ssize_t ssi_sys_help_show(struct kobject *kobj, { char *help_str[] = { "cat reg_dump ", "Print several of CC register values", - #if defined CC_CYCLE_COUNT - "cat stats_host ", "Print host statistics", - "echo <number> > stats_host", "Clear host statistics database", - "cat stats_cc ", "Print CC statistics", - "echo <number> > stats_cc ", "Clear CC statistics database", - #endif }; int i = 0, offset = 0; @@ -376,7 +116,7 @@ static int sys_init_dir(struct sys_dir *sys_dir, struct ssi_drvdata *drvdata, return -ENOMEM; /* allocate memory for directory's attributes list */ sys_dir->sys_dir_attr_list = - kzalloc(sizeof(struct attribute *) * (num_of_attrs + 1), + kcalloc(num_of_attrs + 1, sizeof(struct attribute *), GFP_KERNEL); if (!(sys_dir->sys_dir_attr_list)) { @@ -413,14 +153,9 @@ static void sys_free_dir(struct sys_dir *sys_dir) int ssi_sysfs_init(struct kobject *sys_dev_obj, struct ssi_drvdata *drvdata) { int retval; + struct device *dev = drvdata_to_dev(drvdata); -#if defined CC_CYCLE_COUNT - /* Init. statistics */ - init_db(stat_host_db); - init_db(stat_cc_db); -#endif - - SSI_LOG_ERR("setup sysfs under %s\n", sys_dev_obj->name); + dev_info(dev, "setup sysfs under %s\n", sys_dev_obj->name); /* Initialize top directory */ retval = sys_init_dir(&sys_top_dir, drvdata, sys_dev_obj, "cc_info", diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 5d157951f63f..2b2a446af3f5 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -934,6 +934,9 @@ static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan) { struct das16_private_struct *devpriv = dev->private; + setup_timer(&devpriv->timer, das16_timer_interrupt, + (unsigned long)dev); + /* only DMA channels 3 and 1 are valid */ if (!(dma_chan == 1 || dma_chan == 3)) return; @@ -941,10 +944,6 @@ static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan) /* DMA uses two buffers */ devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan, DAS16_DMA_SIZE, COMEDI_ISADMA_READ); - if (devpriv->dma) { - setup_timer(&devpriv->timer, das16_timer_interrupt, - (unsigned long)dev); - } } static void das16_free_dma(struct comedi_device *dev) @@ -952,8 +951,7 @@ static void das16_free_dma(struct comedi_device *dev) struct das16_private_struct *devpriv = dev->private; if (devpriv) { - if (devpriv->timer.data) - del_timer_sync(&devpriv->timer); + del_timer_sync(&devpriv->timer); comedi_isadma_free(devpriv->dma); } } diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index 764d6fe0d030..efdb11a5e27f 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -104,7 +104,6 @@ struct board_ops { * struct dgnc_board - Per board information. * @boardnum: Board number (0 - 32). * - * @type: Type of board. * @name: Product name. * @pdev: Pointer to the pci_dev structure. * @bd_flags: Board flags. @@ -140,13 +139,9 @@ struct board_ops { * @dpastatus: Board status as defined by DPA. * @bd_dividend: Board/UART's specific dividend. * @bd_ops: Pointer to board operations structure. - * @proc_entry_pointer: Proc/<board> entry - * @dgnc_board_table: Proc/<board> entry */ struct dgnc_board { int boardnum; - - int type; char *name; struct pci_dev *pdev; unsigned long bd_flags; @@ -200,10 +195,6 @@ struct dgnc_board { uint bd_dividend; struct board_ops *bd_ops; - - struct proc_dir_entry *proc_entry_pointer; - struct dgnc_proc_entry *dgnc_board_table; - }; /* Unit flag definitions for un_flags. */ @@ -233,7 +224,6 @@ struct device; */ struct un_t { struct channel_t *un_ch; - ulong un_time; uint un_type; uint un_open_count; struct tty_struct *un_tty; @@ -321,8 +311,6 @@ struct un_t { * @ch_err_overrun: Count of overruns on channel. * @ch_xon_sends: Count of xons transmitted. * @ch_xoff_sends: Count of xoffs transmitted. - * @proc_entry_pointer: Proc/<board>/<channel> entry. - * @dgnc_channel_table: Proc/<board>/<channel> entry. */ struct channel_t { struct dgnc_board *ch_bd; @@ -391,10 +379,6 @@ struct channel_t { ulong ch_xon_sends; ulong ch_xoff_sends; - - struct proc_dir_entry *proc_entry_pointer; - struct dgnc_proc_entry *dgnc_channel_table; - }; extern uint dgnc_major; /* Our driver/mgmt major */ diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index 1943e66fec57..0ae229c3aaaa 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -1182,7 +1182,6 @@ static int neo_drain(struct tty_struct *tty, uint seconds) unsigned long flags; struct channel_t *ch; struct un_t *un; - int rc = 0; if (!tty) return -ENXIO; @@ -1199,12 +1198,10 @@ static int neo_drain(struct tty_struct *tty, uint seconds) un->un_flags |= UN_EMPTY; spin_unlock_irqrestore(&ch->ch_lock, flags); - rc = wait_event_interruptible_timeout(un->un_flags_wait, - ((un->un_flags & UN_EMPTY) == 0), - msecs_to_jiffies(seconds * 1000)); - - /* If ret is non-zero, user ctrl-c'ed us */ - return rc; + /* If returned value is non-zero, user ctrl-c'ed us */ + return wait_event_interruptible_timeout(un->un_flags_wait, + ((un->un_flags & UN_EMPTY) == 0), + msecs_to_jiffies(seconds * 1000)); } /* diff --git a/drivers/staging/fbtft/fb_ra8875.c b/drivers/staging/fbtft/fb_ra8875.c index a899614ce829..6d1cad85957b 100644 --- a/drivers/staging/fbtft/fb_ra8875.c +++ b/drivers/staging/fbtft/fb_ra8875.c @@ -253,7 +253,7 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...) static int write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len) { u16 *vmem16; - __be16 *txbuf16 = par->txbuf.buf; + __be16 *txbuf16; size_t remain; size_t to_copy; size_t tx_array_size; @@ -267,10 +267,10 @@ static int write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len) remain = len / 2; vmem16 = (u16 *)(par->info->screen_buffer + offset); tx_array_size = par->txbuf.len / 2; - txbuf16 = par->txbuf.buf + 1; - tx_array_size -= 2; - *(u8 *)(par->txbuf.buf) = 0x00; - startbyte_size = 1; + txbuf16 = par->txbuf.buf + 1; + tx_array_size -= 2; + *(u8 *)(par->txbuf.buf) = 0x00; + startbyte_size = 1; while (remain) { to_copy = min(tx_array_size, remain); diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c index f8096828f5b7..a609ec82daf3 100644 --- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c @@ -76,7 +76,7 @@ static inline struct dpaa2_io *service_select_by_cpu(struct dpaa2_io *d, if (d) return d; - if (unlikely(cpu >= num_possible_cpus())) + if (cpu != DPAA2_IO_ANY_CPU && cpu >= num_possible_cpus()) return NULL; /* @@ -121,7 +121,7 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc) return NULL; /* check if CPU is out of range (-1 means any cpu) */ - if (desc->cpu >= num_possible_cpus()) { + if (desc->cpu != DPAA2_IO_ANY_CPU && desc->cpu >= num_possible_cpus()) { kfree(obj); return NULL; } diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-msi.c b/drivers/staging/fsl-mc/bus/fsl-mc-msi.c index 038da4d1ebd0..f74a6f1764bb 100644 --- a/drivers/staging/fsl-mc/bus/fsl-mc-msi.c +++ b/drivers/staging/fsl-mc/bus/fsl-mc-msi.c @@ -137,7 +137,7 @@ static void fsl_mc_msi_update_chip_ops(struct msi_domain_info *info) { struct irq_chip *chip = info->chip; - if (WARN_ON((!chip))) + if (WARN_ON(!chip)) return; /* diff --git a/drivers/staging/fsl-mc/include/dpaa2-io.h b/drivers/staging/fsl-mc/include/dpaa2-io.h index c5646096c5d4..afc2d060d077 100644 --- a/drivers/staging/fsl-mc/include/dpaa2-io.h +++ b/drivers/staging/fsl-mc/include/dpaa2-io.h @@ -54,6 +54,8 @@ struct device; * for dequeue. */ +#define DPAA2_IO_ANY_CPU -1 + /** * struct dpaa2_io_desc - The DPIO descriptor * @receives_notifications: Use notificaton mode. Non-zero if the DPIO @@ -91,8 +93,8 @@ irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj); * @cb: The callback to be invoked when the notification arrives * @is_cdan: Zero for FQDAN, non-zero for CDAN * @id: FQID or channel ID, needed for rearm - * @desired_cpu: The cpu on which the notifications will show up. -1 means - * any CPU. + * @desired_cpu: The cpu on which the notifications will show up. Use + * DPAA2_IO_ANY_CPU if don't care * @dpio_id: The dpio index * @qman64: The 64-bit context value shows up in the FQDAN/CDAN. * @node: The list node diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c index 3f4148c92308..d7da475f9d33 100644 --- a/drivers/staging/greybus/light.c +++ b/drivers/staging/greybus/light.c @@ -925,6 +925,8 @@ static void __gb_lights_led_unregister(struct gb_channel *channel) return; led_classdev_unregister(cdev); + kfree(cdev->name); + cdev->name = NULL; channel->led = NULL; } @@ -998,11 +1000,7 @@ static int gb_lights_channel_config(struct gb_light *light, light->has_flash = true; - ret = gb_lights_channel_flash_config(channel); - if (ret < 0) - return ret; - - return ret; + return gb_lights_channel_flash_config(channel); } static int gb_lights_light_config(struct gb_lights *glights, u8 id) diff --git a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c index bcbdc7340b55..fa8b27e091a2 100644 --- a/drivers/staging/gs_fpgaboot/gs_fpgaboot.c +++ b/drivers/staging/gs_fpgaboot/gs_fpgaboot.c @@ -106,7 +106,7 @@ static int readmagic_bitstream(u8 *bitdata, int *offset) read_bitstream(bitdata, buf, offset, 13); r = memcmp(buf, bits_magic, 13); if (r) { - pr_err("error: corrupted header"); + pr_err("error: corrupted header\n"); return -EINVAL; } pr_info("bitstream file magic number Ok\n"); diff --git a/drivers/staging/iio/Documentation/device.txt b/drivers/staging/iio/Documentation/device.txt index 54ef0deed28f..ec42544a46aa 100644 --- a/drivers/staging/iio/Documentation/device.txt +++ b/drivers/staging/iio/Documentation/device.txt @@ -26,9 +26,6 @@ Then fill in the following: pointer to a structure with elements that tend to be fixed for large sets of different parts supported by a given driver. This contains: - * info->driver_module: - Set to THIS_MODULE. Used to ensure correct ownership - of various resources allocate by the core. * info->event_attrs: Attributes used to enable / disable hardware events. * info->attrs: diff --git a/drivers/staging/iio/Documentation/trigger.txt b/drivers/staging/iio/Documentation/trigger.txt index 7c0e505e4f04..299a1add98bf 100644 --- a/drivers/staging/iio/Documentation/trigger.txt +++ b/drivers/staging/iio/Documentation/trigger.txt @@ -10,10 +10,6 @@ struct iio_trig *trig = iio_trigger_alloc("<trigger format string>", ...); allocates a trigger structure. The key elements to then fill in within a driver are: -trig->owner - Typically set to THIS_MODULE. Used to ensure correct - ownership of core allocated resources. - trig->set_trigger_state: Function that enables / disables the underlying source of the trigger. diff --git a/drivers/staging/iio/accel/adis16201.c b/drivers/staging/iio/accel/adis16201.c index fbc240663621..2ebd27536216 100644 --- a/drivers/staging/iio/accel/adis16201.c +++ b/drivers/staging/iio/accel/adis16201.c @@ -284,7 +284,6 @@ static const struct iio_info adis16201_info = { .read_raw = adis16201_read_raw, .write_raw = adis16201_write_raw, .update_scan_mode = adis_update_scan_mode, - .driver_module = THIS_MODULE, }; static const char * const adis16201_status_error_msgs[] = { diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index 4e3fa7592d3f..b3e4571340ab 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -232,7 +232,6 @@ static const struct iio_info adis16203_info = { .read_raw = adis16203_read_raw, .write_raw = adis16203_write_raw, .update_scan_mode = adis_update_scan_mode, - .driver_module = THIS_MODULE, }; static const char * const adis16203_status_error_msgs[] = { diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index 8485c024e3f5..7fcef9a2590a 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -285,7 +285,6 @@ static const struct iio_info adis16209_info = { .read_raw = adis16209_read_raw, .write_raw = adis16209_write_raw, .update_scan_mode = adis_update_scan_mode, - .driver_module = THIS_MODULE, }; static const char * const adis16209_status_error_msgs[] = { diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c index 109cd94b5ac3..fff6d99089cc 100644 --- a/drivers/staging/iio/accel/adis16240.c +++ b/drivers/staging/iio/accel/adis16240.c @@ -361,7 +361,6 @@ static const struct iio_info adis16240_info = { .read_raw = adis16240_read_raw, .write_raw = adis16240_write_raw, .update_scan_mode = adis_update_scan_mode, - .driver_module = THIS_MODULE, }; static const char * const adis16240_status_error_msgs[] = { diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c index 6150d2780e22..1617628c34f9 100644 --- a/drivers/staging/iio/adc/ad7192.c +++ b/drivers/staging/iio/adc/ad7192.c @@ -567,7 +567,6 @@ static const struct iio_info ad7192_info = { .write_raw_get_fmt = ad7192_write_raw_get_fmt, .attrs = &ad7192_attribute_group, .validate_trigger = ad_sd_validate_trigger, - .driver_module = THIS_MODULE, }; static const struct iio_info ad7195_info = { @@ -576,7 +575,6 @@ static const struct iio_info ad7195_info = { .write_raw_get_fmt = ad7192_write_raw_get_fmt, .attrs = &ad7195_attribute_group, .validate_trigger = ad_sd_validate_trigger, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec ad7192_channels[] = { diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index f85dde9805e0..b736275c10f5 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -828,7 +828,6 @@ static const struct iio_info ad7280_info = { .read_raw = ad7280_read_raw, .event_attrs = &ad7280_event_attrs_group, .attrs = &ad7280_attrs_group, - .driver_module = THIS_MODULE, }; static const struct ad7280_platform_data ad7793_default_pdata = { diff --git a/drivers/staging/iio/adc/ad7606.c b/drivers/staging/iio/adc/ad7606.c index 18f5f139117e..25b9fcd5e3a4 100644 --- a/drivers/staging/iio/adc/ad7606.c +++ b/drivers/staging/iio/adc/ad7606.c @@ -373,26 +373,22 @@ static irqreturn_t ad7606_interrupt(int irq, void *dev_id) }; static const struct iio_info ad7606_info_no_os_or_range = { - .driver_module = THIS_MODULE, .read_raw = &ad7606_read_raw, }; static const struct iio_info ad7606_info_os_and_range = { - .driver_module = THIS_MODULE, .read_raw = &ad7606_read_raw, .write_raw = &ad7606_write_raw, .attrs = &ad7606_attribute_group_os_and_range, }; static const struct iio_info ad7606_info_os = { - .driver_module = THIS_MODULE, .read_raw = &ad7606_read_raw, .write_raw = &ad7606_write_raw, .attrs = &ad7606_attribute_group_os, }; static const struct iio_info ad7606_info_range = { - .driver_module = THIS_MODULE, .read_raw = &ad7606_read_raw, .write_raw = &ad7606_write_raw, .attrs = &ad7606_attribute_group_range, diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index dec3ba6eba8a..a7797af579b9 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -155,7 +155,6 @@ static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { static const struct iio_info ad7780_info = { .read_raw = ad7780_read_raw, - .driver_module = THIS_MODULE, }; static int ad7780_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 17d280581e24..bfe180a475ee 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -335,7 +335,6 @@ static const struct attribute_group ad7816_event_attribute_group = { static const struct iio_info ad7816_info = { .attrs = &ad7816_attribute_group, .event_attrs = &ad7816_event_attribute_group, - .driver_module = THIS_MODULE, }; /* diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index b2bce26499f5..2d33632c00e8 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2087,13 +2087,11 @@ EXPORT_SYMBOL_GPL(adt7316_pm_ops); static const struct iio_info adt7316_info = { .attrs = &adt7316_attribute_group, .event_attrs = &adt7316_event_attribute_group, - .driver_module = THIS_MODULE, }; static const struct iio_info adt7516_info = { .attrs = &adt7516_attribute_group, .event_attrs = &adt7516_event_attribute_group, - .driver_module = THIS_MODULE, }; /* diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index a6f249e9c1e1..2fe916c48848 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -569,7 +569,6 @@ static const struct attribute_group ad7150_event_attribute_group = { static const struct iio_info ad7150_info = { .event_attrs = &ad7150_event_attribute_group, - .driver_module = THIS_MODULE, .read_raw = &ad7150_read_raw, .read_event_config = &ad7150_read_event_config, .write_event_config = &ad7150_write_event_config, diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c index ff10d1f0a7e4..61377ca444de 100644 --- a/drivers/staging/iio/cdc/ad7152.c +++ b/drivers/staging/iio/cdc/ad7152.c @@ -441,7 +441,6 @@ static const struct iio_info ad7152_info = { .read_raw = ad7152_read_raw, .write_raw = ad7152_write_raw, .write_raw_get_fmt = ad7152_write_raw_get_fmt, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec ad7152_channels[] = { diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index cdcb4fccf3fe..a124853a05f0 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -667,7 +667,6 @@ static const struct iio_info ad7746_info = { .attrs = &ad7746_attribute_group, .read_raw = ad7746_read_raw, .write_raw = ad7746_write_raw, - .driver_module = THIS_MODULE, }; /* diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c index 6da46ede7ee0..c73eff1f8d73 100644 --- a/drivers/staging/iio/frequency/ad9832.c +++ b/drivers/staging/iio/frequency/ad9832.c @@ -290,7 +290,6 @@ static const struct attribute_group ad9832_attribute_group = { static const struct iio_info ad9832_info = { .attrs = &ad9832_attribute_group, - .driver_module = THIS_MODULE, }; static int ad9832_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c index 995acdd7c942..4c6d4043903e 100644 --- a/drivers/staging/iio/frequency/ad9834.c +++ b/drivers/staging/iio/frequency/ad9834.c @@ -381,12 +381,10 @@ static const struct attribute_group ad9833_attribute_group = { static const struct iio_info ad9834_info = { .attrs = &ad9834_attribute_group, - .driver_module = THIS_MODULE, }; static const struct iio_info ad9833_info = { .attrs = &ad9833_attribute_group, - .driver_module = THIS_MODULE, }; static int ad9834_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c index 967524583d8a..4e7630caf7d3 100644 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ b/drivers/staging/iio/gyro/adis16060_core.c @@ -103,7 +103,6 @@ static int adis16060_read_raw(struct iio_dev *indio_dev, static const struct iio_info adis16060_info = { .read_raw = adis16060_read_raw, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec adis16060_channels[] = { diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 3d539eeb0e26..2b28fb9c0048 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -575,7 +575,6 @@ out: static const struct iio_info ad5933_info = { .read_raw = ad5933_read_raw, .attrs = &ad5933_attribute_group, - .driver_module = THIS_MODULE, }; static int ad5933_ring_preenable(struct iio_dev *indio_dev) diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c index 786e93f16ce9..d9defc8ece83 100644 --- a/drivers/staging/iio/light/tsl2x7x.c +++ b/drivers/staging/iio/light/tsl2x7x.c @@ -192,25 +192,25 @@ struct tsl2X7X_chip { }; /* Different devices require different coefficents */ -static const struct tsl2x7x_lux tsl2x71_lux_table[] = { +static const struct tsl2x7x_lux tsl2x71_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = { { 14461, 611, 1211 }, { 18540, 352, 623 }, { 0, 0, 0 }, }; -static const struct tsl2x7x_lux tmd2x71_lux_table[] = { +static const struct tsl2x7x_lux tmd2x71_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = { { 11635, 115, 256 }, { 15536, 87, 179 }, { 0, 0, 0 }, }; -static const struct tsl2x7x_lux tsl2x72_lux_table[] = { +static const struct tsl2x7x_lux tsl2x72_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = { { 14013, 466, 917 }, { 18222, 310, 552 }, { 0, 0, 0 }, }; -static const struct tsl2x7x_lux tmd2x72_lux_table[] = { +static const struct tsl2x7x_lux tmd2x72_lux_table[TSL2X7X_DEF_LUX_TABLE_SZ] = { { 13218, 130, 262 }, { 17592, 92, 169 }, { 0, 0, 0 }, @@ -530,7 +530,7 @@ static void tsl2x7x_defaults(struct tsl2X7X_chip *chip) else memcpy(chip->tsl2x7x_device_lux, (struct tsl2x7x_lux *)tsl2x7x_default_lux_table_group[chip->id], - MAX_DEFAULT_TABLE_BYTES); + TSL2X7X_DEFAULT_TABLE_BYTES); } /** @@ -1113,7 +1113,7 @@ static ssize_t in_illuminance0_lux_table_show(struct device *dev, int i = 0; int offset = 0; - while (i < (TSL2X7X_MAX_LUX_TABLE_SIZE * 3)) { + while (i < TSL2X7X_MAX_LUX_TABLE_SIZE) { offset += snprintf(buf + offset, PAGE_SIZE, "%u,%u,%u,", chip->tsl2x7x_device_lux[i].ratio, chip->tsl2x7x_device_lux[i].ch0, @@ -1654,7 +1654,6 @@ static const struct iio_info tsl2X7X_device_info[] = { [ALS] = { .attrs = &tsl2X7X_device_attr_group_tbl[ALS], .event_attrs = &tsl2X7X_event_attr_group_tbl[ALS], - .driver_module = THIS_MODULE, .read_raw = &tsl2x7x_read_raw, .write_raw = &tsl2x7x_write_raw, .read_event_value = &tsl2x7x_read_event_value, @@ -1665,7 +1664,6 @@ static const struct iio_info tsl2X7X_device_info[] = { [PRX] = { .attrs = &tsl2X7X_device_attr_group_tbl[PRX], .event_attrs = &tsl2X7X_event_attr_group_tbl[PRX], - .driver_module = THIS_MODULE, .read_raw = &tsl2x7x_read_raw, .write_raw = &tsl2x7x_write_raw, .read_event_value = &tsl2x7x_read_event_value, @@ -1676,7 +1674,6 @@ static const struct iio_info tsl2X7X_device_info[] = { [ALSPRX] = { .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX], .event_attrs = &tsl2X7X_event_attr_group_tbl[ALSPRX], - .driver_module = THIS_MODULE, .read_raw = &tsl2x7x_read_raw, .write_raw = &tsl2x7x_write_raw, .read_event_value = &tsl2x7x_read_event_value, @@ -1687,7 +1684,6 @@ static const struct iio_info tsl2X7X_device_info[] = { [PRX2] = { .attrs = &tsl2X7X_device_attr_group_tbl[PRX2], .event_attrs = &tsl2X7X_event_attr_group_tbl[PRX], - .driver_module = THIS_MODULE, .read_raw = &tsl2x7x_read_raw, .write_raw = &tsl2x7x_write_raw, .read_event_value = &tsl2x7x_read_event_value, @@ -1698,7 +1694,6 @@ static const struct iio_info tsl2X7X_device_info[] = { [ALSPRX2] = { .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX2], .event_attrs = &tsl2X7X_event_attr_group_tbl[ALSPRX], - .driver_module = THIS_MODULE, .read_raw = &tsl2x7x_read_raw, .write_raw = &tsl2x7x_write_raw, .read_event_value = &tsl2x7x_read_event_value, @@ -1982,7 +1977,7 @@ static int tsl2x7x_remove(struct i2c_client *client) return 0; } -static struct i2c_device_id tsl2x7x_idtable[] = { +static const struct i2c_device_id tsl2x7x_idtable[] = { { "tsl2571", tsl2571 }, { "tsl2671", tsl2671 }, { "tmd2671", tmd2671 }, diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h index ecae92211216..a216c6943a84 100644 --- a/drivers/staging/iio/light/tsl2x7x.h +++ b/drivers/staging/iio/light/tsl2x7x.h @@ -23,10 +23,6 @@ #define __TSL2X7X_H #include <linux/pm.h> -/* Max number of segments allowable in LUX table */ -#define TSL2X7X_MAX_LUX_TABLE_SIZE 9 -#define MAX_DEFAULT_TABLE_BYTES (sizeof(int) * TSL2X7X_MAX_LUX_TABLE_SIZE) - struct iio_dev; struct tsl2x7x_lux { @@ -35,6 +31,13 @@ struct tsl2x7x_lux { unsigned int ch1; }; +/* Max number of segments allowable in LUX table */ +#define TSL2X7X_MAX_LUX_TABLE_SIZE 9 +/* The default LUX tables all have 3 elements. */ +#define TSL2X7X_DEF_LUX_TABLE_SZ 3 +#define TSL2X7X_DEFAULT_TABLE_BYTES (sizeof(struct tsl2x7x_lux) * \ + TSL2X7X_DEF_LUX_TABLE_SZ) + /** * struct tsl2x7x_default_settings - power on defaults unless * overridden by platform data. diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index ce26abdeab92..b704b24b34db 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c @@ -81,10 +81,12 @@ * @tx: transmit buffer * @rx: receive buffer * @buf_lock: mutex to protect tx and rx + * @lock: protect sensor data **/ struct ade7753_state { struct spi_device *us; struct mutex buf_lock; + struct mutex lock; /* protect sensor data */ u8 tx[ADE7753_MAX_TX] ____cacheline_aligned; u8 rx[ADE7753_MAX_RX]; }; @@ -483,7 +485,7 @@ static ssize_t ade7753_write_frequency(struct device *dev, if (!val) return -EINVAL; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); t = 27900 / val; if (t > 0) @@ -504,7 +506,7 @@ static ssize_t ade7753_write_frequency(struct device *dev, ret = ade7753_spi_write_reg_16(dev, ADE7753_MODE, reg); out: - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret ? ret : len; } @@ -561,7 +563,6 @@ static const struct attribute_group ade7753_attribute_group = { static const struct iio_info ade7753_info = { .attrs = &ade7753_attribute_group, - .driver_module = THIS_MODULE, }; static int ade7753_probe(struct spi_device *spi) @@ -580,6 +581,7 @@ static int ade7753_probe(struct spi_device *spi) st = iio_priv(indio_dev); st->us = spi; mutex_init(&st->buf_lock); + mutex_init(&st->lock); indio_dev->name = spi->dev.driver->name; indio_dev->dev.parent = &spi->dev; diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index be0df3fe4230..3a1e342d75fb 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c @@ -601,7 +601,6 @@ static const struct attribute_group ade7754_attribute_group = { static const struct iio_info ade7754_info = { .attrs = &ade7754_attribute_group, - .driver_module = THIS_MODULE, }; static int ade7754_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 40498af4dc46..7b7ffe5ed186 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -827,7 +827,6 @@ static const struct iio_info ade7758_info = { .attrs = &ade7758_attribute_group, .read_raw = &ade7758_read_raw, .write_raw = &ade7758_write_raw, - .driver_module = THIS_MODULE, }; static int ade7758_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/meter/ade7758_trigger.c b/drivers/staging/iio/meter/ade7758_trigger.c index 5b35a7f08f4f..1f0d1a0cf889 100644 --- a/drivers/staging/iio/meter/ade7758_trigger.c +++ b/drivers/staging/iio/meter/ade7758_trigger.c @@ -53,7 +53,6 @@ static int ade7758_trig_try_reen(struct iio_trigger *trig) } static const struct iio_trigger_ops ade7758_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = &ade7758_data_rdy_trigger_set_state, .try_reenable = &ade7758_trig_try_reen, }; diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index 1691760339da..cd75f60aded3 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c @@ -60,7 +60,7 @@ /** * struct ade7759_state - device instance specific data * @us: actual spi_device - * @buf_lock: mutex to protect tx and rx + * @buf_lock: mutex to protect tx and rx and write frequency * @tx: transmit buffer * @rx: receive buffer **/ @@ -89,19 +89,30 @@ static int ade7759_spi_write_reg_8(struct device *dev, return ret; } -static int ade7759_spi_write_reg_16(struct device *dev, +/*Unlocked version of ade7759_spi_write_reg_16 function */ +static int __ade7759_spi_write_reg_16(struct device *dev, u8 reg_address, u16 value) { - int ret; struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct ade7759_state *st = iio_priv(indio_dev); - mutex_lock(&st->buf_lock); st->tx[0] = ADE7759_WRITE_REG(reg_address); st->tx[1] = (value >> 8) & 0xFF; st->tx[2] = value & 0xFF; - ret = spi_write(st->us, st->tx, 3); + return spi_write(st->us, st->tx, 3); +} + +static int ade7759_spi_write_reg_16(struct device *dev, + u8 reg_address, + u16 value) +{ + int ret; + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct ade7759_state *st = iio_priv(indio_dev); + + mutex_lock(&st->buf_lock); + ret = __ade7759_spi_write_reg_16(dev, reg_address, value); mutex_unlock(&st->buf_lock); return ret; @@ -429,7 +440,7 @@ static ssize_t ade7759_write_frequency(struct device *dev, if (!val) return -EINVAL; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->buf_lock); t = 27900 / val; if (t > 0) @@ -447,10 +458,10 @@ static ssize_t ade7759_write_frequency(struct device *dev, reg &= ~(3 << 13); reg |= t << 13; - ret = ade7759_spi_write_reg_16(dev, ADE7759_MODE, reg); + ret = __ade7759_spi_write_reg_16(dev, ADE7759_MODE, reg); out: - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->buf_lock); return ret ? ret : len; } @@ -493,7 +504,6 @@ static const struct attribute_group ade7759_attribute_group = { static const struct iio_info ade7759_info = { .attrs = &ade7759_attribute_group, - .driver_module = THIS_MODULE, }; static int ade7759_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/meter/ade7854.c b/drivers/staging/iio/meter/ade7854.c index 70612da64a8b..90d07cdca4b8 100644 --- a/drivers/staging/iio/meter/ade7854.c +++ b/drivers/staging/iio/meter/ade7854.c @@ -530,7 +530,6 @@ static const struct attribute_group ade7854_attribute_group = { static const struct iio_info ade7854_info = { .attrs = &ade7854_attribute_group, - .driver_module = THIS_MODULE, }; int ade7854_probe(struct iio_dev *indio_dev, struct device *dev) diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index a37e199225f4..aa62c64e9bc4 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c @@ -98,7 +98,6 @@ static const struct iio_chan_spec ad2s1200_channels[] = { static const struct iio_info ad2s1200_info = { .read_raw = ad2s1200_read_raw, - .driver_module = THIS_MODULE, }; static int ad2s1200_probe(struct spi_device *spi) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 3e00df74b18c..f8baab061eba 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -638,7 +638,6 @@ error_ret: static const struct iio_info ad2s1210_info = { .read_raw = ad2s1210_read_raw, .attrs = &ad2s1210_attribute_group, - .driver_module = THIS_MODULE, }; static int ad2s1210_setup_gpios(struct ad2s1210_state *st) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index b2270908f26f..59586947a936 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -48,7 +48,6 @@ error_ret: static const struct iio_info ad2s90_info = { .read_raw = ad2s90_read_raw, - .driver_module = THIS_MODULE, }; static const struct iio_chan_spec ad2s90_chan = { diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c index 4e0b4eedb53d..d80dcf82eba9 100644 --- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c +++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c @@ -172,7 +172,6 @@ static int iio_bfin_tmr_get_number(int irq) } static const struct iio_trigger_ops iio_bfin_tmr_trigger_ops = { - .owner = THIS_MODULE, .set_trigger_state = iio_bfin_tmr_set_state, }; diff --git a/drivers/staging/irda/drivers/ali-ircc.c b/drivers/staging/irda/drivers/ali-ircc.c index 35f198d83701..589cd01797f4 100644 --- a/drivers/staging/irda/drivers/ali-ircc.c +++ b/drivers/staging/irda/drivers/ali-ircc.c @@ -1876,8 +1876,7 @@ static int ali_ircc_dma_receive_complete(struct ali_ircc_cb *self) self->stamp = ktime_get(); skb = dev_alloc_skb(len+1); - if (skb == NULL) - { + if (!skb) { self->netdev->stats.rx_dropped++; return FALSE; diff --git a/drivers/staging/irda/drivers/au1k_ir.c b/drivers/staging/irda/drivers/au1k_ir.c index be4ea6aa57a9..73e3e4b041bf 100644 --- a/drivers/staging/irda/drivers/au1k_ir.c +++ b/drivers/staging/irda/drivers/au1k_ir.c @@ -290,8 +290,7 @@ static int au1k_irda_set_speed(struct net_device *dev, int speed) while (irda_read(aup, IR_STATUS) & (IR_RX_STATUS | IR_TX_STATUS)) { msleep(20); if (!timeout--) { - printk(KERN_ERR "%s: rx/tx disable timeout\n", - dev->name); + netdev_err(dev, "rx/tx disable timeout\n"); break; } } @@ -349,7 +348,7 @@ static int au1k_irda_set_speed(struct net_device *dev, int speed) IR_RX_ENABLE); break; default: - printk(KERN_ERR "%s unsupported speed %x\n", dev->name, speed); + netdev_err(dev, "unsupported speed %x\n", speed); ret = -EINVAL; break; } @@ -361,18 +360,18 @@ static int au1k_irda_set_speed(struct net_device *dev, int speed) irda_write(aup, IR_RING_PROMPT, 0); if (control & (1 << 14)) { - printk(KERN_ERR "%s: configuration error\n", dev->name); + netdev_err(dev, "configuration error\n"); } else { if (control & (1 << 11)) - printk(KERN_DEBUG "%s Valid SIR config\n", dev->name); + netdev_debug(dev, "Valid SIR config\n"); if (control & (1 << 12)) - printk(KERN_DEBUG "%s Valid MIR config\n", dev->name); + netdev_debug(dev, "Valid MIR config\n"); if (control & (1 << 13)) - printk(KERN_DEBUG "%s Valid FIR config\n", dev->name); + netdev_debug(dev, "Valid FIR config\n"); if (control & (1 << 10)) - printk(KERN_DEBUG "%s TX enabled\n", dev->name); + netdev_debug(dev, "TX enabled\n"); if (control & (1 << 9)) - printk(KERN_DEBUG "%s RX enabled\n", dev->name); + netdev_debug(dev, "RX enabled\n"); } return ret; @@ -584,23 +583,21 @@ static int au1k_irda_start(struct net_device *dev) retval = au1k_init(dev); if (retval) { - printk(KERN_ERR "%s: error in au1k_init\n", dev->name); + netdev_err(dev, "error in au1k_init\n"); return retval; } retval = request_irq(aup->irq_tx, &au1k_irda_interrupt, 0, dev->name, dev); if (retval) { - printk(KERN_ERR "%s: unable to get IRQ %d\n", - dev->name, dev->irq); + netdev_err(dev, "unable to get IRQ %d\n", dev->irq); return retval; } retval = request_irq(aup->irq_rx, &au1k_irda_interrupt, 0, dev->name, dev); if (retval) { free_irq(aup->irq_tx, dev); - printk(KERN_ERR "%s: unable to get IRQ %d\n", - dev->name, dev->irq); + netdev_err(dev, "unable to get IRQ %d\n", dev->irq); return retval; } @@ -673,12 +670,12 @@ static int au1k_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev) flags = ptxd->flags; if (flags & AU_OWN) { - printk(KERN_DEBUG "%s: tx_full\n", dev->name); + netdev_debug(dev, "tx_full\n"); netif_stop_queue(dev); aup->tx_full = 1; return 1; } else if (((aup->tx_head + 1) & (NUM_IR_DESC - 1)) == aup->tx_tail) { - printk(KERN_DEBUG "%s: tx_full\n", dev->name); + netdev_debug(dev, "tx_full\n"); netif_stop_queue(dev); aup->tx_full = 1; return 1; @@ -688,7 +685,7 @@ static int au1k_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev) #if 0 if (irda_read(aup, IR_RX_BYTE_CNT) != 0) { - printk(KERN_DEBUG "tx warning: rx byte cnt %x\n", + netdev_debug(dev, "tx warning: rx byte cnt %x\n", irda_read(aup, IR_RX_BYTE_CNT)); } #endif @@ -726,7 +723,7 @@ static void au1k_tx_timeout(struct net_device *dev) u32 speed; struct au1k_private *aup = netdev_priv(dev); - printk(KERN_ERR "%s: tx timeout\n", dev->name); + netdev_err(dev, "tx timeout\n"); speed = aup->speed; aup->speed = 0; au1k_irda_set_speed(dev, speed); @@ -751,8 +748,7 @@ static int au1k_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd) ret = au1k_irda_set_speed(dev, rq->ifr_baudrate); else { - printk(KERN_ERR "%s ioctl: !netif_running\n", - dev->name); + netdev_err(dev, "ioctl: !netif_running\n"); ret = 0; } } @@ -868,7 +864,7 @@ out3: out2: kfree(aup->rx_buff.head); out1: - printk(KERN_ERR "au1k_irda_net_init() failed. Returns %d\n", retval); + netdev_err(dev, "au1k_irda_net_init() failed. Returns %d\n"); return retval; } @@ -934,7 +930,7 @@ static int au1k_irda_probe(struct platform_device *pdev) platform_set_drvdata(pdev, dev); - printk(KERN_INFO "IrDA: Registered device %s\n", dev->name); + netdev_info(dev, "IrDA: Registered device\n"); return 0; out4: diff --git a/drivers/staging/irda/drivers/irda-usb.c b/drivers/staging/irda/drivers/irda-usb.c index 723e49bc4baa..82bfc051e1de 100644 --- a/drivers/staging/irda/drivers/irda-usb.c +++ b/drivers/staging/irda/drivers/irda-usb.c @@ -334,9 +334,9 @@ static void irda_usb_change_speed_xbofs(struct irda_usb_cb *self) urb->transfer_flags = 0; /* Irq disabled -> GFP_ATOMIC */ - if ((ret = usb_submit_urb(urb, GFP_ATOMIC))) { + ret = usb_submit_urb(urb, GFP_ATOMIC); + if (ret) net_warn_ratelimited("%s(), failed Speed URB\n", __func__); - } } /*------------------------------------------------------------------*/ diff --git a/drivers/staging/irda/drivers/mcs7780.c b/drivers/staging/irda/drivers/mcs7780.c index c3f0b254b344..d52e9f4b9770 100644 --- a/drivers/staging/irda/drivers/mcs7780.c +++ b/drivers/staging/irda/drivers/mcs7780.c @@ -605,19 +605,22 @@ static int mcs_speed_change(struct mcs_cb *mcs) if (mcs->new_speed <= 115200) { rval &= ~MCS_FIR; - if ((rst = (mcs->speed > 115200))) + rst = mcs->speed > 115200; + if (rst) mcs_set_reg(mcs, MCS_MINRXPW_REG, 0); } else if (mcs->new_speed <= 1152000) { rval &= ~MCS_FIR; - if ((rst = !(mcs->speed == 576000 || mcs->speed == 1152000))) + rst = !(mcs->speed == 576000 || mcs->speed == 1152000); + if (rst) mcs_set_reg(mcs, MCS_MINRXPW_REG, 5); } else { rval |= MCS_FIR; - if ((rst = (mcs->speed != 4000000))) + rst = mcs->speed != 4000000; + if (rst) mcs_set_reg(mcs, MCS_MINRXPW_REG, 5); } diff --git a/drivers/staging/irda/drivers/vlsi_ir.c b/drivers/staging/irda/drivers/vlsi_ir.c index 6638784c082e..3dff3c55ddf5 100644 --- a/drivers/staging/irda/drivers/vlsi_ir.c +++ b/drivers/staging/irda/drivers/vlsi_ir.c @@ -170,10 +170,10 @@ static void vlsi_proc_pdev(struct seq_file *seq, struct pci_dev *pdev) seq_printf(seq, "pci-power-state: %u\n", (unsigned) pdev->current_state); seq_printf(seq, "resources: irq=%u / io=0x%04x / dma_mask=0x%016Lx\n", pdev->irq, (unsigned)pci_resource_start(pdev, 0), (unsigned long long)pdev->dma_mask); - seq_printf(seq, "hw registers: "); + seq_puts(seq, "hw registers: "); for (i = 0; i < 0x20; i++) seq_printf(seq, "%02x", (unsigned)inb((iobase+i))); - seq_printf(seq, "\n"); + seq_putc(seq, '\n'); } static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev) @@ -193,7 +193,7 @@ static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev) if (!netif_running(ndev)) return; - seq_printf(seq, "\nhw-state:\n"); + seq_puts(seq, "\nhw-state:\n"); pci_read_config_byte(idev->pdev, VLSI_PCI_IRMISC, &byte); seq_printf(seq, "IRMISC:%s%s%s uart%s", (byte&IRMISC_IRRAIL) ? " irrail" : "", @@ -274,7 +274,7 @@ static void vlsi_proc_ndev(struct seq_file *seq, struct net_device *ndev) word = inw(iobase+VLSI_PIO_RCVBCNT) & RCVBCNT_MASK; seq_printf(seq, "RCVBCNT: rx-fifo filling level = %u\n", word); - seq_printf(seq, "\nsw-state:\n"); + seq_puts(seq, "\nsw-state:\n"); seq_printf(seq, "IrPHY setup: %d baud - %s encoding\n", idev->baud, (idev->mode==IFF_SIR)?"SIR":((idev->mode==IFF_MIR)?"MIR":"FIR")); sec = div_s64_rem(ktime_us_delta(ktime_get(), idev->last_rx), @@ -305,10 +305,10 @@ static void vlsi_proc_ring(struct seq_file *seq, struct vlsi_ring *r) t = atomic_read(&r->tail) & r->mask; seq_printf(seq, "head = %d / tail = %d ", h, t); if (h == t) - seq_printf(seq, "(empty)\n"); + seq_puts(seq, "(empty)\n"); else { if (((t+1)&r->mask) == h) - seq_printf(seq, "(full)\n"); + seq_puts(seq, "(full)\n"); else seq_printf(seq, "(level = %d)\n", ((unsigned)(t-h) & r->mask)); rd = &r->rd[h]; @@ -355,13 +355,13 @@ static int vlsi_seq_show(struct seq_file *seq, void *v) seq_printf(seq, "\nPCI controller down - resume_ok = %d\n", idev->resume_ok); if (netif_running(ndev) && idev->rx_ring && idev->tx_ring) { - seq_printf(seq, "\n--------- RX ring -----------\n\n"); + seq_puts(seq, "\n--------- RX ring -----------\n\n"); vlsi_proc_ring(seq, idev->rx_ring); - seq_printf(seq, "\n--------- TX ring -----------\n\n"); + seq_puts(seq, "\n--------- TX ring -----------\n\n"); vlsi_proc_ring(seq, idev->tx_ring); } } - seq_printf(seq, "\n"); + seq_putc(seq, '\n'); spin_unlock_irqrestore(&idev->lock, flags); return 0; diff --git a/drivers/staging/irda/include/net/irda/qos.h b/drivers/staging/irda/include/net/irda/qos.h index 05a5a249956f..a0315b50ac27 100644 --- a/drivers/staging/irda/include/net/irda/qos.h +++ b/drivers/staging/irda/include/net/irda/qos.h @@ -58,23 +58,23 @@ #define IR_16000000 0x02 /* Quality of Service information */ -typedef struct { +struct qos_value { __u32 value; __u16 bits; /* LSB is first byte, MSB is second byte */ -} qos_value_t; +}; struct qos_info { magic_t magic; - qos_value_t baud_rate; /* IR_11520O | ... */ - qos_value_t max_turn_time; - qos_value_t data_size; - qos_value_t window_size; - qos_value_t additional_bofs; - qos_value_t min_turn_time; - qos_value_t link_disc_time; + struct qos_value baud_rate; /* IR_11520O | ... */ + struct qos_value max_turn_time; + struct qos_value data_size; + struct qos_value window_size; + struct qos_value additional_bofs; + struct qos_value min_turn_time; + struct qos_value link_disc_time; - qos_value_t power; + struct qos_value power; }; extern int sysctl_max_baud_rate; diff --git a/drivers/staging/irda/net/discovery.c b/drivers/staging/irda/net/discovery.c index 364d70aed068..1e54954a4081 100644 --- a/drivers/staging/irda/net/discovery.c +++ b/drivers/staging/irda/net/discovery.c @@ -179,7 +179,7 @@ void irlmp_expire_discoveries(hashbin_t *log, __u32 saddr, int force) /* Create the client specific buffer */ n = HASHBIN_GET_SIZE(log); buffer = kmalloc(n * sizeof(struct irda_device_info), GFP_ATOMIC); - if (buffer == NULL) { + if (!buffer) { spin_unlock_irqrestore(&log->hb_spinlock, flags); return; } @@ -291,7 +291,7 @@ struct irda_device_info *irlmp_copy_discoveries(hashbin_t *log, int *pn, /* Create the client specific buffer */ n = HASHBIN_GET_SIZE(log); buffer = kmalloc(n * sizeof(struct irda_device_info), GFP_ATOMIC); - if (buffer == NULL) { + if (!buffer) { spin_unlock_irqrestore(&log->hb_spinlock, flags); return NULL; } diff --git a/drivers/staging/irda/net/irda_device.c b/drivers/staging/irda/net/irda_device.c index 890b90d055d5..d33de8a8762a 100644 --- a/drivers/staging/irda/net/irda_device.c +++ b/drivers/staging/irda/net/irda_device.c @@ -54,29 +54,30 @@ static void __irda_task_delete(struct irda_task *task); -static hashbin_t *dongles = NULL; -static hashbin_t *tasks = NULL; +static hashbin_t *dongles; +static hashbin_t *tasks; static void irda_task_timer_expired(void *data); -int __init irda_device_init( void) +int __init irda_device_init(void) { dongles = hashbin_new(HB_NOLOCK); - if (dongles == NULL) { + if (!dongles) { net_warn_ratelimited("IrDA: Can't allocate dongles hashbin!\n"); return -ENOMEM; } spin_lock_init(&dongles->hb_spinlock); tasks = hashbin_new(HB_LOCK); - if (tasks == NULL) { + if (!tasks) { net_warn_ratelimited("IrDA: Can't allocate tasks hashbin!\n"); hashbin_delete(dongles, NULL); return -ENOMEM; } /* We no longer initialise the driver ourselves here, we let - * the system do it for us... - Jean II */ + * the system do it for us... - Jean II + */ return 0; } @@ -84,6 +85,7 @@ int __init irda_device_init( void) static void leftover_dongle(void *arg) { struct dongle_reg *reg = arg; + net_warn_ratelimited("IrDA: Dongle type %x not unregistered\n", reg->type); } @@ -107,7 +109,7 @@ void irda_device_set_media_busy(struct net_device *dev, int status) pr_debug("%s(%s)\n", __func__, status ? "TRUE" : "FALSE"); - self = (struct irlap_cb *) dev->atalk_ptr; + self = (struct irlap_cb *)dev->atalk_ptr; /* Some drivers may enable the receive interrupt before calling * irlap_open(), or they may disable the receive interrupt @@ -115,7 +117,8 @@ void irda_device_set_media_busy(struct net_device *dev, int status) * The IrDA stack is protected from this in irlap_driver_rcv(). * However, the driver calls directly the wrapper, that calls * us directly. Make sure we protect ourselves. - * Jean II */ + * Jean II + */ if (!self || self->magic != LAP_MAGIC) return; @@ -133,7 +136,6 @@ void irda_device_set_media_busy(struct net_device *dev, int status) } EXPORT_SYMBOL(irda_device_set_media_busy); - /* * Function irda_device_is_receiving (dev) * @@ -169,7 +171,7 @@ static void __irda_task_delete(struct irda_task *task) static void irda_task_delete(struct irda_task *task) { /* Unregister task */ - hashbin_remove(tasks, (long) task, NULL); + hashbin_remove(tasks, (long)task, NULL); __irda_task_delete(task); } @@ -231,7 +233,7 @@ static int irda_task_kick(struct irda_task *task) } irda_task_delete(task); } else if (timeout > 0) { - irda_start_timer(&task->timer, timeout, (void *) task, + irda_start_timer(&task->timer, timeout, (void *)task, irda_task_timer_expired); finished = FALSE; } else { @@ -280,8 +282,8 @@ static void irda_device_setup(struct net_device *dev) /* * Funciton alloc_irdadev - * Allocates and sets up an IRDA device in a manner similar to - * alloc_etherdev. + * Allocates and sets up an IRDA device in a manner similar to + * alloc_etherdev. */ struct net_device *alloc_irdadev(int sizeof_priv) { diff --git a/drivers/staging/irda/net/irqueue.c b/drivers/staging/irda/net/irqueue.c index 160dc89335e2..14291cbc4097 100644 --- a/drivers/staging/irda/net/irqueue.c +++ b/drivers/staging/irda/net/irqueue.c @@ -217,7 +217,8 @@ static __u32 hash( const char* name) while(*name) { h = (h<<4) + *name++; - if ((g = (h & 0xf0000000))) + g = h & 0xf0000000; + if (g) h ^=g>>24; h &=~g; } diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index eea3b8e5e406..99414c78cd1a 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -160,9 +160,9 @@ struct lnet_libmd { } md_iov; }; -#define LNET_MD_FLAG_ZOMBIE (1 << 0) -#define LNET_MD_FLAG_AUTO_UNLINK (1 << 1) -#define LNET_MD_FLAG_ABORTED (1 << 2) +#define LNET_MD_FLAG_ZOMBIE BIT(0) +#define LNET_MD_FLAG_AUTO_UNLINK BIT(1) +#define LNET_MD_FLAG_ABORTED BIT(2) struct lnet_test_peer { /* info about peers we are trying to fail */ @@ -287,9 +287,9 @@ struct lnet_ni { * of old LNet, so there shouldn't be any compatibility issue */ #define LNET_PING_FEAT_INVAL (0) /* no feature */ -#define LNET_PING_FEAT_BASE (1 << 0) /* just a ping */ -#define LNET_PING_FEAT_NI_STATUS (1 << 1) /* return NI status */ -#define LNET_PING_FEAT_RTE_DISABLED (1 << 2) /* Routing enabled */ +#define LNET_PING_FEAT_BASE BIT(0) /* just a ping */ +#define LNET_PING_FEAT_NI_STATUS BIT(1) /* return NI status */ +#define LNET_PING_FEAT_RTE_DISABLED BIT(2) /* Routing enabled */ #define LNET_PING_FEAT_MASK (LNET_PING_FEAT_BASE | \ LNET_PING_FEAT_NI_STATUS) @@ -440,23 +440,21 @@ struct lnet_rtrbuf { enum lnet_match_flags { /* Didn't match anything */ - LNET_MATCHMD_NONE = (1 << 0), + LNET_MATCHMD_NONE = BIT(0), /* Matched OK */ - LNET_MATCHMD_OK = (1 << 1), + LNET_MATCHMD_OK = BIT(1), /* Must be discarded */ - LNET_MATCHMD_DROP = (1 << 2), + LNET_MATCHMD_DROP = BIT(2), /* match and buffer is exhausted */ - LNET_MATCHMD_EXHAUSTED = (1 << 3), + LNET_MATCHMD_EXHAUSTED = BIT(3), /* match or drop */ LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP), }; /* Options for lnet_portal::ptl_options */ -#define LNET_PTL_LAZY (1 << 0) -#define LNET_PTL_MATCH_UNIQUE (1 << 1) /* unique match, for RDMA */ -#define LNET_PTL_MATCH_WILDCARD (1 << 2) /* wildcard match, - * request portal - */ +#define LNET_PTL_LAZY BIT(0) +#define LNET_PTL_MATCH_UNIQUE BIT(1) /* unique match, for RDMA */ +#define LNET_PTL_MATCH_WILDCARD BIT(2) /* wildcard match, request portal */ /* parameter for matching operations (GET, PUT) */ struct lnet_match_info { diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index fbbd8a5489e9..d0ee58d16e56 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -176,12 +176,9 @@ struct ksock_peer * ksocknal_find_peer_locked(struct lnet_ni *ni, struct lnet_process_id id) { struct list_head *peer_list = ksocknal_nid2peerlist(id.nid); - struct list_head *tmp; struct ksock_peer *peer; - list_for_each(tmp, peer_list) { - peer = list_entry(tmp, struct ksock_peer, ksnp_list); - + list_for_each_entry(peer, peer_list, ksnp_list) { LASSERT(!peer->ksnp_closing); if (peer->ksnp_ni != ni) @@ -453,7 +450,6 @@ int ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id, __u32 ipaddr, int port) { - struct list_head *tmp; struct ksock_peer *peer; struct ksock_peer *peer2; struct ksock_route *route; @@ -491,9 +487,7 @@ ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id, __u32 ipaddr, } route2 = NULL; - list_for_each(tmp, &peer->ksnp_routes) { - route2 = list_entry(tmp, struct ksock_route, ksnr_list); - + list_for_each_entry(route2, &peer->ksnp_routes, ksnr_list) { if (route2->ksnr_ipaddr == ipaddr) break; @@ -1854,12 +1848,10 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when) peer = ksocknal_find_peer_locked(ni, id); if (peer) { - struct list_head *tmp; struct ksock_conn *conn; int bufnob; - list_for_each(tmp, &peer->ksnp_conns) { - conn = list_entry(tmp, struct ksock_conn, ksnc_list); + list_for_each_entry(conn, &peer->ksnp_conns, ksnc_list) { bufnob = conn->ksnc_sock->sk->sk_wmem_queued; if (bufnob < conn->ksnc_tx_bufnob) { diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 3df101bafd9f..b8eba3325f52 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -222,15 +222,12 @@ struct lnet_remotenet * lnet_find_net_locked(__u32 net) { struct lnet_remotenet *rnet; - struct list_head *tmp; struct list_head *rn_list; LASSERT(!the_lnet.ln_shutdown); rn_list = lnet_net2rnethash(net); - list_for_each(tmp, rn_list) { - rnet = list_entry(tmp, struct lnet_remotenet, lrn_list); - + list_for_each_entry(rnet, rn_list, lrn_list) { if (rnet->lrn_net == net) return rnet; } @@ -243,7 +240,6 @@ static void lnet_shuffle_seed(void) __u32 lnd_type, seed[2]; struct timespec64 ts; struct lnet_ni *ni; - struct list_head *tmp; if (seeded) return; @@ -254,8 +250,7 @@ static void lnet_shuffle_seed(void) * Nodes with small feet have little entropy * the NID for this node gives the most entropy in the low bits */ - list_for_each(tmp, &the_lnet.ln_nis) { - ni = list_entry(tmp, struct lnet_ni, ni_list); + list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) { lnd_type = LNET_NETTYP(LNET_NIDNET(ni->ni_nid)); if (lnd_type != LOLND) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index cd7a5391a574..0a3f832095ea 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -847,7 +847,7 @@ void sptlrpc_request_out_callback(struct ptlrpc_request *req) if (req->rq_pool || !req->rq_reqbuf) return; - kfree(req->rq_reqbuf); + kvfree(req->rq_reqbuf); req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c index 05897b747349..5027fd20d966 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c @@ -155,7 +155,7 @@ static void atomisp_css2_hw_store(hrt_address addr, const void *from, uint32_t n) { unsigned long flags; - unsigned i; + unsigned int i; unsigned int _to = (unsigned int)addr; const char *_from = (const char *)from; @@ -168,7 +168,7 @@ static void atomisp_css2_hw_store(hrt_address addr, static void atomisp_css2_hw_load(hrt_address addr, void *to, uint32_t n) { unsigned long flags; - unsigned i; + unsigned int i; char *_to = (char *)to; unsigned int _from = (unsigned int)addr; @@ -232,9 +232,11 @@ static void __dump_pipe_config(struct atomisp_sub_device *asd, unsigned int pipe_id) { struct atomisp_device *isp = asd->isp; + if (stream_env->pipes[pipe_id]) { struct ia_css_pipe_config *p_config; struct ia_css_pipe_extra_config *pe_config; + p_config = &stream_env->pipe_configs[pipe_id]; pe_config = &stream_env->pipe_extra_configs[pipe_id]; dev_dbg(isp->dev, "dumping pipe[%d] config:\n", pipe_id); @@ -507,6 +509,7 @@ static int __destroy_stream(struct atomisp_sub_device *asd, static int __destroy_streams(struct atomisp_sub_device *asd, bool force) { int ret, i; + for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) { ret = __destroy_stream(asd, &asd->stream_env[i], force); if (ret) @@ -573,6 +576,7 @@ static int __destroy_stream_pipes(struct atomisp_sub_device *asd, struct atomisp_device *isp = asd->isp; int ret = 0; int i; + for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) { if (!stream_env->pipes[i] || !(force || stream_env->update_pipe[i])) @@ -892,12 +896,12 @@ static inline int __set_css_print_env(struct atomisp_device *isp, int opt) { int ret = 0; - if (0 == opt) + if (opt == 0) isp->css_env.isp_css_env.print_env.debug_print = NULL; - else if (1 == opt) + else if (opt == 1) isp->css_env.isp_css_env.print_env.debug_print = atomisp_css2_dbg_ftrace_print; - else if (2 == opt) + else if (opt == 2) isp->css_env.isp_css_env.print_env.debug_print = atomisp_css2_dbg_print; else @@ -1051,6 +1055,7 @@ int atomisp_css_irq_enable(struct atomisp_device *isp, void atomisp_css_init_struct(struct atomisp_sub_device *asd) { int i, j; + for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) { asd->stream_env[i].stream = NULL; for (j = 0; j < IA_CSS_PIPE_MODE_NUM; j++) { @@ -1189,6 +1194,7 @@ int atomisp_css_start(struct atomisp_sub_device *asd, struct atomisp_device *isp = asd->isp; bool sp_is_started = false; int ret = 0, i = 0; + if (in_reset) { if (__destroy_streams(asd, true)) dev_warn(isp->dev, "destroy stream failed.\n"); @@ -1976,6 +1982,7 @@ void atomisp_css_enable_raw_binning(struct atomisp_sub_device *asd, void atomisp_css_enable_dz(struct atomisp_sub_device *asd, bool enable) { int i; + for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++) asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL] .pipe_configs[i].enable_dz = enable; @@ -2002,6 +2009,7 @@ void atomisp_css_input_set_mode(struct atomisp_sub_device *asd, int i; struct atomisp_device *isp = asd->isp; unsigned int size_mem_words; + for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) asd->stream_env[i].stream_config.mode = mode; @@ -2275,6 +2283,7 @@ int atomisp_css_stop(struct atomisp_sub_device *asd, if (!in_reset) { struct atomisp_stream_env *stream_env; int i, j; + for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) { stream_env = &asd->stream_env[i]; for (j = 0; j < IA_CSS_PIPE_ID_NUM; j++) { @@ -2801,6 +2810,7 @@ static void __configure_video_vf_output(struct atomisp_sub_device *asd, struct atomisp_stream_env *stream_env = &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL]; struct ia_css_frame_info *css_output_info; + stream_env->pipe_configs[pipe_id].mode = __pipe_id_to_pipe_mode(asd, pipe_id); stream_env->update_pipe[pipe_id] = true; @@ -4464,7 +4474,8 @@ int atomisp_css_load_acc_binary(struct atomisp_sub_device *asd, static struct atomisp_sub_device *__get_atomisp_subdev( struct ia_css_pipe *css_pipe, struct atomisp_device *isp, - enum atomisp_input_stream_id *stream_id) { + enum atomisp_input_stream_id *stream_id) +{ int i, j, k; struct atomisp_sub_device *asd; struct atomisp_stream_env *stream_env; @@ -4659,7 +4670,7 @@ int atomisp_css_dump_sp_raw_copy_linecount(bool reduced) int atomisp_css_dump_blob_infor(void) { struct ia_css_blob_descr *bd = sh_css_blob_info; - unsigned i, nm = sh_css_num_binaries; + unsigned int i, nm = sh_css_num_binaries; if (nm == 0) return -EPERM; @@ -4695,7 +4706,7 @@ int atomisp_set_css_dbgfunc(struct atomisp_device *isp, int opt) int ret; ret = __set_css_print_env(isp, opt); - if (0 == ret) + if (ret == 0) dbg_func = opt; return ret; diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c index 63582161050a..53a7891111f9 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c @@ -145,8 +145,8 @@ sh_css_load_blob_info(const char *fw, const struct ia_css_fw_info *bi, struct ia size_t configstruct_size = sizeof(struct ia_css_config_memory_offsets); size_t statestruct_size = sizeof(struct ia_css_state_memory_offsets); - char *parambuf = (char *)kmalloc(paramstruct_size + configstruct_size + statestruct_size, - GFP_KERNEL); + char *parambuf = kmalloc(paramstruct_size + configstruct_size + statestruct_size, + GFP_KERNEL); if (parambuf == NULL) return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY; diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c index 11162f595fc7..5232327f5d9c 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm_bo.c @@ -725,7 +725,7 @@ static int alloc_private_pages(struct hmm_buffer_object *bo, pgnr = bo->pgnr; - bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * pgnr, + bo->page_obj = kmalloc_array(pgnr, sizeof(struct hmm_page_object), GFP_KERNEL); if (unlikely(!bo->page_obj)) { dev_err(atomisp_dev, "out of memory for bo->page_obj\n"); @@ -990,13 +990,13 @@ static int alloc_user_pages(struct hmm_buffer_object *bo, struct vm_area_struct *vma; struct page **pages; - pages = kmalloc(sizeof(struct page *) * bo->pgnr, GFP_KERNEL); + pages = kmalloc_array(bo->pgnr, sizeof(struct page *), GFP_KERNEL); if (unlikely(!pages)) { dev_err(atomisp_dev, "out of memory for pages...\n"); return -ENOMEM; } - bo->page_obj = kmalloc(sizeof(struct hmm_page_object) * bo->pgnr, + bo->page_obj = kmalloc_array(bo->pgnr, sizeof(struct hmm_page_object), GFP_KERNEL); if (unlikely(!bo->page_obj)) { dev_err(atomisp_dev, "out of memory for bo->page_obj...\n"); @@ -1363,7 +1363,7 @@ void *hmm_bo_vmap(struct hmm_buffer_object *bo, bool cached) bo->status &= ~(HMM_BO_VMAPED | HMM_BO_VMAPED_CACHED); } - pages = kmalloc(sizeof(*pages) * bo->pgnr, GFP_KERNEL); + pages = kmalloc_array(bo->pgnr, sizeof(*pages), GFP_KERNEL); if (unlikely(!pages)) { mutex_unlock(&bo->mutex); dev_err(atomisp_dev, "out of memory for pages...\n"); diff --git a/drivers/staging/pi433/Documentation/pi433.txt b/drivers/staging/pi433/Documentation/pi433.txt index 38b83b86c334..245fef33d688 100644 --- a/drivers/staging/pi433/Documentation/pi433.txt +++ b/drivers/staging/pi433/Documentation/pi433.txt @@ -20,7 +20,7 @@ Discription of driver operation a) transmission Each transmission can take place with a different configuration of the rf -module. Therfore each application can set its own set of parameters. The driver +module. Therefore each application can set its own set of parameters. The driver takes care, that each transmission takes place with the parameterset of the application, that requests the transmission. To allow the transmission to take place in the background, a tx thread is introduced. @@ -33,7 +33,7 @@ there is no receive request or the receiver is still waiting for something in the air, the rf module is set to standby, the parameters for transmission gets set, the hardware fifo of the rf chip gets preloaded and the transmission gets started. Upon hardware fifo threshold interrupt it gets reloaded, thus enabling -much longer telegrams then hardware fifo size. If the telegram is send and there +much longer telegrams than the hardware fifo size. If the telegram is sent and there is more data available in the kfifo, the procedure is repeated. If not the transmission cycle ends. @@ -41,7 +41,7 @@ b) reception Since there is only one application allowed to receive data at a time, for reception there is only one configuration set. -As soon as an application sets an request for receiving a telegram, the reception +As soon as an application sets a request for receiving a telegram, the reception configuration set is written to the rf module and it gets set into receiving mode. Now the driver is waiting, that a predefined RSSI level (signal strength at the receiver) is reached. Until this hasn't happened, the reception can be @@ -123,7 +123,7 @@ packet format: optionOff - no preamble will be generated enable_sync optionOn - a sync word will be automatically added to - the telegram after preamble + the telegram after the preamble optionOff - no sync word will be added Attention: While possible to generate sync without preamble, the receiver won't be able to detect the sync without preamble. @@ -136,7 +136,7 @@ packet format: Attention: should be used in combination with sync, only enable_address_byte optionOn - the address byte will be automatically added to the - telgram. It's part of the payload + telegram. It's part of the payload optionOff - the address byte will not be added to the telegram. The address byte can be used for address filtering, so the receiver will only receive telegrams with a given address byte. @@ -161,7 +161,7 @@ packet format: one byte, used as address byte on address byte option. -The rx configuration is transfered via struct pi433_rx_cfg, the parameterset for receiving. It is devided into two sections: rf parameters and packet format. +The rx configuration is transferred via struct pi433_rx_cfg, the parameterset for receiving. It is divided into two sections: rf parameters and packet format. rf params: frequency @@ -178,7 +178,7 @@ rf params: OOK - on off key rssi_threshold threshold value for the signal strength on the receiver input. - If this value is exeeded, a reception cycle starts + If this value is exceeded, a reception cycle starts Allowed values: 0...255 thresholdDecrement in order to adapt to different levels of singnal strength, over @@ -198,7 +198,7 @@ rf params: twohundretOhm - for antennas with an impedance of 200Ohm lnaGain sets the gain of the low noise amp - automatic - lna gain is determed by an agc + automatic - lna gain is determined by an agc max - lna gain is set to maximum maxMinus6 - lna gain is set to 6db below max maxMinus12 - lna gain is set to 12db below max @@ -232,7 +232,7 @@ rf params: amount of bytes that were requested by the read request. Attention: should be used in combination with sync, only enable_address_filtering; - filteringOff - no adress filtering will take place + filteringOff - no address filtering will take place nodeAddress - all telegrams, not matching the node address will be internally discarded nodeOrBroadcastAddress - all telegrams, neither matching the @@ -245,7 +245,7 @@ rf params: calculated crc doesn't match to two bytes, that follow the payload, the telegram will be internally discarded. - Attention: This option is only operational, if sync on and fixed length + Attention: This option is only operational if sync on and fixed length or length byte is used sync_length Gives the length of the payload. @@ -255,9 +255,9 @@ rf params: Overrides the telegram length either given by the first byte of payload or by the read request. bytes_to_drop - gives the number of bytes, that will be dropped before transfering + gives the number of bytes, that will be dropped before transferring data to the read buffer - This option is only usefull, if all packet helper are switched + This option is only useful if all packet helper are switched off and the rf chip is used in raw receiving mode. This may be needed, if a telegram of a third party device should be received, using a protocol not compatible with the packet engine of the rf69 chip. diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 93c01680f016..d82c74db9b6c 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -136,17 +136,17 @@ static irqreturn_t DIO0_irq_handler(int irq, void *dev_id) if (device->irq_state[DIO0] == DIO_PacketSent) { device->free_in_fifo = FIFO_SIZE; - printk("DIO0 irq: Packet sent\n"); // TODO: printk() should include KERN_ facility level + dev_dbg(device->dev, "DIO0 irq: Packet sent\n"); wake_up_interruptible(&device->fifo_wait_queue); } else if (device->irq_state[DIO0] == DIO_Rssi_DIO0) { - printk("DIO0 irq: RSSI level over threshold\n"); + dev_dbg(device->dev, "DIO0 irq: RSSI level over threshold\n"); wake_up_interruptible(&device->rx_wait_queue); } else if (device->irq_state[DIO0] == DIO_PayloadReady) { - printk("DIO0 irq: PayloadReady\n"); + dev_dbg(device->dev, "DIO0 irq: PayloadReady\n"); device->free_in_fifo = 0; wake_up_interruptible(&device->fifo_wait_queue); } @@ -167,7 +167,8 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id) if (device->rx_active) device->free_in_fifo = FIFO_THRESHOLD - 1; else device->free_in_fifo = FIFO_SIZE - FIFO_THRESHOLD - 1; } - printk("DIO1 irq: %d bytes free in fifo\n", device->free_in_fifo); // TODO: printk() should include KERN_ facility level + dev_dbg(device->dev, + "DIO1 irq: %d bytes free in fifo\n", device->free_in_fifo); wake_up_interruptible(&device->fifo_wait_queue); return IRQ_HANDLED; @@ -466,7 +467,7 @@ pi433_receive(void *data) } - /* rx done, wait was interrupted or error occured */ + /* rx done, wait was interrupted or error occurred */ abort: dev->interrupt_rx_allowed = true; SET_CHECKED(rf69_set_mode(dev->spi, standby)); @@ -1030,7 +1031,7 @@ static int setup_GPIOs(struct pi433_device *device) if (retval) return retval; - dev_dbg(&device->spi->dev, "%s succesfully configured", name); + dev_dbg(&device->spi->dev, "%s successfully configured", name); } return 0; diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 290b419aa9dd..0305edc16861 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -687,9 +687,7 @@ int rf69_set_preamble_length(struct spi_device *spi, u16 preambleLength) /* transmit to chip */ retval = WRITE_REG(REG_PREAMBLE_MSB, msb); if (retval) return retval; - retval = WRITE_REG(REG_PREAMBLE_LSB, lsb); - - return retval; + return WRITE_REG(REG_PREAMBLE_LSB, lsb); } int rf69_set_sync_enable(struct spi_device *spi, enum optionOnOff optionOnOff) diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index b9bdff0490ca..2c4c8c43b1ad 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -48,7 +48,7 @@ void Efuse_PowerSwitch( if (PwrState) { usb_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); - /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), defualt valid */ + /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), default valid */ tmpV16 = usb_read16(pAdapter, REG_SYS_ISO_CTRL); if (!(tmpV16 & PWC_EV12V)) { tmpV16 |= PWC_EV12V; diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index f663e6c41f8a..b15cf17f77c5 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -1135,7 +1135,7 @@ static u8 search_max_mac_id(struct adapter *padapter) #if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - for (aid = (pstapriv->max_num_sta); aid > 0; aid--) { + for (aid = pstapriv->max_num_sta; aid > 0; aid--) { if (pstapriv->sta_aid[aid-1]) break; } @@ -1143,7 +1143,7 @@ static u8 search_max_mac_id(struct adapter *padapter) } else #endif {/* adhoc id = 31~2 */ - for (mac_id = (NUM_STA-1); mac_id >= IBSS_START_MAC_ID; mac_id--) { + for (mac_id = NUM_STA-1; mac_id >= IBSS_START_MAC_ID; mac_id--) { if (pmlmeinfo->FW_sta_info[mac_id].status == 1) break; } @@ -1329,7 +1329,7 @@ void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf) } /* - * _rtw_join_timeout_handler - Timeout/faliure handler for CMD JoinBss + * _rtw_join_timeout_handler - Timeout/failure handler for CMD JoinBss * @adapter: pointer to struct adapter structure */ void _rtw_join_timeout_handler (unsigned long data) @@ -1569,7 +1569,7 @@ int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) psetauthparm->mode = (unsigned char)psecuritypriv->dot11AuthAlgrthm; pcmd->cmdcode = _SetAuth_CMD_; pcmd->parmbuf = (unsigned char *)psetauthparm; - pcmd->cmdsz = (sizeof(struct setauth_parm)); + pcmd->cmdsz = sizeof(struct setauth_parm); pcmd->rsp = NULL; pcmd->rspsz = 0; INIT_LIST_HEAD(&pcmd->list); @@ -1648,7 +1648,7 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in } pcmd->cmdcode = _SetKey_CMD_; pcmd->parmbuf = (u8 *)psetkeyparm; - pcmd->cmdsz = (sizeof(struct setkey_parm)); + pcmd->cmdsz = sizeof(struct setkey_parm); pcmd->rsp = NULL; pcmd->rspsz = 0; INIT_LIST_HEAD(&pcmd->list); @@ -1814,45 +1814,45 @@ void rtw_update_registrypriv_dev_network(struct adapter *adapter) struct security_priv *psecuritypriv = &adapter->securitypriv; struct wlan_network *cur_network = &adapter->mlmepriv.cur_network; - pdev_network->Privacy = (psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0); /* adhoc no 802.1x */ + pdev_network->Privacy = psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0; /* adhoc no 802.1x */ pdev_network->Rssi = 0; switch (pregistrypriv->wireless_mode) { case WIRELESS_11B: - pdev_network->NetworkTypeInUse = (Ndis802_11DS); + pdev_network->NetworkTypeInUse = Ndis802_11DS; break; case WIRELESS_11G: case WIRELESS_11BG: case WIRELESS_11_24N: case WIRELESS_11G_24N: case WIRELESS_11BG_24N: - pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); + pdev_network->NetworkTypeInUse = Ndis802_11OFDM24; break; case WIRELESS_11A: case WIRELESS_11A_5N: - pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5); + pdev_network->NetworkTypeInUse = Ndis802_11OFDM5; break; case WIRELESS_11ABGN: if (pregistrypriv->channel > 14) - pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5); + pdev_network->NetworkTypeInUse = Ndis802_11OFDM5; else - pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); + pdev_network->NetworkTypeInUse = Ndis802_11OFDM24; break; default: /* TODO */ break; } - pdev_network->Configuration.DSConfig = (pregistrypriv->channel); + pdev_network->Configuration.DSConfig = pregistrypriv->channel; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("pregistrypriv->channel=%d, pdev_network->Configuration.DSConfig=0x%x\n", pregistrypriv->channel, pdev_network->Configuration.DSConfig)); if (cur_network->network.InfrastructureMode == Ndis802_11IBSS) - pdev_network->Configuration.ATIMWindow = (0); + pdev_network->Configuration.ATIMWindow = 0; - pdev_network->InfrastructureMode = (cur_network->network.InfrastructureMode); + pdev_network->InfrastructureMode = cur_network->network.InfrastructureMode; /* 1. Supported rates */ /* 2. IE */ diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 611c9409bb98..685c0717c605 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -605,7 +605,9 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da) dump_mgntframe(padapter, pmgntframe); } -static int issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, bool wait_ack) +static int issue_probereq(struct adapter *padapter, + struct ndis_802_11_ssid *pssid, u8 *da, + bool wait_ack) { int ret = _FAIL; struct xmit_frame *pmgntframe; @@ -707,7 +709,7 @@ static int issue_probereq_ex(struct adapter *padapter, unsigned long start = jiffies; do { - ret = issue_probereq(padapter, pssid, da, wait_ms > 0 ? true : false); + ret = issue_probereq(padapter, pssid, da, wait_ms > 0); i++; @@ -1196,7 +1198,8 @@ exit: } /* when wait_ack is true, this function should be called at process context */ -static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int wait_ack) +static int _issue_nulldata(struct adapter *padapter, unsigned char *da, + unsigned int power_mode, bool wait_ack) { int ret = _FAIL; struct xmit_frame *pmgntframe; @@ -1269,7 +1272,8 @@ exit: /* when wait_ms > 0 , this function should be called at process context */ /* da == NULL for station mode */ -int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms) +int issue_nulldata(struct adapter *padapter, unsigned char *da, + unsigned int power_mode, int try_cnt, int wait_ms) { int ret; int i = 0; @@ -1283,7 +1287,7 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow da = pnetwork->MacAddress; do { - ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0 ? true : false); + ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0); i++; @@ -1316,7 +1320,8 @@ exit: } /* when wait_ack is true, this function should be called at process context */ -static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int wait_ack) +static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, + u16 tid, bool wait_ack) { int ret = _FAIL; struct xmit_frame *pmgntframe; @@ -1396,7 +1401,8 @@ exit: /* when wait_ms > 0 , this function should be called at process context */ /* da == NULL for station mode */ -int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms) +int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, + u16 tid, int try_cnt, int wait_ms) { int ret; int i = 0; @@ -1410,7 +1416,7 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int da = pnetwork->MacAddress; do { - ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0 ? true : false); + ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0); i++; @@ -1442,7 +1448,8 @@ exit: return ret; } -static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason, u8 wait_ack) +static int _issue_deauth(struct adapter *padapter, unsigned char *da, + unsigned short reason, bool wait_ack) { struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; @@ -1502,7 +1509,8 @@ exit: return ret; } -int issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason) +int issue_deauth(struct adapter *padapter, unsigned char *da, + unsigned short reason) { DBG_88E("%s to %pM\n", __func__, da); return _issue_deauth(padapter, da, reason, false); @@ -1517,7 +1525,7 @@ static int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned long start = jiffies; do { - ret = _issue_deauth(padapter, da, reason, wait_ms > 0 ? true : false); + ret = _issue_deauth(padapter, da, reason, wait_ms > 0); i++; @@ -3413,7 +3421,7 @@ static unsigned int OnAssocRsp(struct adapter *padapter, /* following are moved to join event callback function */ /* to handle HT, WMM, rate adaptive, update MAC reg */ /* for not to handle the synchronous IO in the tasklet */ - for (i = (6 + WLAN_HDR_A3_LEN); i < pkt_len;) { + for (i = 6 + WLAN_HDR_A3_LEN; i < pkt_len;) { pIE = (struct ndis_802_11_var_ie *)(pframe + i); switch (pIE->ElementID) { @@ -3757,7 +3765,8 @@ static unsigned int on_action_public_vendor(struct recv_frame *precv_frame) return ret; } -static unsigned int on_action_public_default(struct recv_frame *precv_frame, u8 action) +static unsigned int on_action_public_default(struct recv_frame *precv_frame, + u8 action) { unsigned int ret = _FAIL; u8 *pframe = precv_frame->pkt->data; @@ -3972,9 +3981,10 @@ static int has_channel(struct rt_channel_info *channel_set, return 0; } -static void init_channel_list(struct adapter *padapter, struct rt_channel_info *channel_set, - u8 chanset_size, - struct p2p_channels *channel_list) +static void init_channel_list(struct adapter *padapter, + struct rt_channel_info *channel_set, + u8 chanset_size, + struct p2p_channels *channel_list) { struct p2p_oper_class_map op_class[] = { { IEEE80211G, 81, 1, 13, 1, BW20 }, @@ -3999,7 +4009,7 @@ static void init_channel_list(struct adapter *padapter, struct rt_channel_info * continue; if ((0 == (padapter->registrypriv.cbw40_enable & BIT(1))) && - ((BW40MINUS == o->bw) || (BW40PLUS == o->bw))) + ((o->bw == BW40MINUS) || (o->bw == BW40PLUS))) continue; if (reg == NULL) { @@ -4015,7 +4025,8 @@ static void init_channel_list(struct adapter *padapter, struct rt_channel_info * channel_list->reg_classes = cla; } -static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_channel_info *channel_set) +static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, + struct rt_channel_info *channel_set) { u8 index, chanset_size = 0; u8 b2_4GBand = false; @@ -4030,7 +4041,7 @@ static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_c if (padapter->registrypriv.wireless_mode & WIRELESS_11G) { b2_4GBand = true; - if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan) + if (ChannelPlan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE) Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G; else Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G; @@ -4040,14 +4051,14 @@ static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_c for (index = 0; index < RTW_ChannelPlan2G[Index2G].Len; index++) { channel_set[chanset_size].ChannelNum = RTW_ChannelPlan2G[Index2G].Channel[index]; - if ((RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN == ChannelPlan) ||/* Channel 1~11 is active, and 12~14 is passive */ - (RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G == ChannelPlan)) { + if ((ChannelPlan == RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN) ||/* Channel 1~11 is active, and 12~14 is passive */ + (ChannelPlan == RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G)) { if (channel_set[chanset_size].ChannelNum >= 1 && channel_set[chanset_size].ChannelNum <= 11) channel_set[chanset_size].ScanType = SCAN_ACTIVE; else if ((channel_set[chanset_size].ChannelNum >= 12 && channel_set[chanset_size].ChannelNum <= 14)) channel_set[chanset_size].ScanType = SCAN_PASSIVE; - } else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == ChannelPlan || - RT_CHANNEL_DOMAIN_2G_WORLD == Index2G) {/* channel 12~13, passive scan */ + } else if (ChannelPlan == RT_CHANNEL_DOMAIN_WORLD_WIDE_13 || + Index2G == RT_CHANNEL_DOMAIN_2G_WORLD) {/* channel 12~13, passive scan */ if (channel_set[chanset_size].ChannelNum <= 11) channel_set[chanset_size].ScanType = SCAN_ACTIVE; else @@ -4105,7 +4116,9 @@ void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext) } } -static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptable, struct recv_frame *precv_frame) +static void _mgt_dispatcher(struct adapter *padapter, + struct mlme_handler *ptable, + struct recv_frame *precv_frame) { u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 *pframe = precv_frame->pkt->data; @@ -4351,7 +4364,8 @@ void report_join_res(struct adapter *padapter, int res) rtw_enqueue_cmd(pcmdpriv, pcmd_obj); } -void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason) +void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, + unsigned short reason) { struct cmd_obj *pcmd_obj; u8 *pevtcmd; @@ -4406,7 +4420,8 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi rtw_enqueue_cmd(pcmdpriv, pcmd_obj); } -void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int cam_idx) +void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, + int cam_idx) { struct cmd_obj *pcmd_obj; u8 *pevtcmd; @@ -4767,7 +4782,7 @@ void linked_status_chk(struct adapter *padapter) if (pmlmeinfo->FW_sta_info[i].status == 1) { psta = pmlmeinfo->FW_sta_info[i].psta; - if (NULL == psta) + if (psta == NULL) continue; if (pmlmeinfo->FW_sta_info[i].rx_pkt == sta_rx_pkts(psta)) { if (pmlmeinfo->FW_sta_info[i].retry < 3) { @@ -5125,8 +5140,10 @@ u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) return H2C_SUCCESS; } -static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_channel *out, - u32 out_num, struct rtw_ieee80211_channel *in, u32 in_num) +static int rtw_scan_ch_decision(struct adapter *padapter, + struct rtw_ieee80211_channel *out, + u32 out_num, + struct rtw_ieee80211_channel *in, u32 in_num) { int i, j; int set_idx; diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index f86c9cebf09a..9ba511aca48d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -37,7 +37,7 @@ static int rtw_hw_suspend(struct adapter *padapter) /* system suspend */ LeaveAllPowerSaveMode(padapter); - DBG_88E("==> rtw_hw_suspend\n"); + DBG_88E("==> %s\n", __func__); mutex_lock(&pwrpriv->mutex_lock); pwrpriv->bips_processing = true; /* s1. */ @@ -89,7 +89,7 @@ static int rtw_hw_resume(struct adapter *padapter) /* system resume */ - DBG_88E("==> rtw_hw_resume\n"); + DBG_88E("==> %s\n", __func__); mutex_lock(&pwrpriv->mutex_lock); pwrpriv->bips_processing = true; rtw_reset_drv_sw(padapter); @@ -146,7 +146,7 @@ void ips_enter(struct adapter *padapter) pwrpriv->ips_mode = pwrpriv->ips_mode_req; pwrpriv->ips_enter_cnts++; - DBG_88E("==>ips_enter cnts:%d\n", pwrpriv->ips_enter_cnts); + DBG_88E("==>%s:%d\n", __func__, pwrpriv->ips_enter_cnts); if (rf_off == pwrpriv->change_rfpwrstate) { pwrpriv->bpower_saving = true; DBG_88E_LEVEL(_drv_info_, "nolinked power save enter\n"); @@ -177,7 +177,7 @@ int ips_leave(struct adapter *padapter) pwrpriv->bips_processing = true; pwrpriv->change_rfpwrstate = rf_on; pwrpriv->ips_leave_cnts++; - DBG_88E("==>ips_leave cnts:%d\n", pwrpriv->ips_leave_cnts); + DBG_88E("==>%s:%d\n", __func__, pwrpriv->ips_leave_cnts); result = rtw_ips_pwr_up(padapter); if (result == _SUCCESS) @@ -198,7 +198,7 @@ int ips_leave(struct adapter *padapter) } } - DBG_88E("==> ips_leave.....LED(0x%08x)...\n", usb_read32(padapter, 0x4c)); + DBG_88E("==> %s.....LED(0x%08x)...\n", __func__, usb_read32(padapter, 0x4c)); pwrpriv->bips_processing = false; pwrpriv->bkeepfwalive = false; @@ -332,7 +332,7 @@ void rtw_set_rpwm(struct adapter *padapter, u8 pslv) rpwm = pslv | pwrpriv->tog; RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, - ("rtw_set_rpwm: rpwm=0x%02x cpwm=0x%02x\n", rpwm, pwrpriv->cpwm)); + ("%s: rpwm=0x%02x cpwm=0x%02x\n", __func__, rpwm, pwrpriv->cpwm)); pwrpriv->rpwm = pslv; @@ -525,7 +525,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE; else pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ - pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; + pwrctrlpriv->bLeisurePs = (pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE) ? true : false; pwrctrlpriv->bFwCurrentInPSMode = false; @@ -595,7 +595,7 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal } if (rf_off == pwrpriv->rf_pwrstate) { DBG_88E("%s call ips_leave....\n", __func__); - if (_FAIL == ips_leave(padapter)) { + if (ips_leave(padapter) == _FAIL) { DBG_88E("======> ips_leave fail.............\n"); ret = _FAIL; goto exit; @@ -628,12 +628,12 @@ int rtw_pm_set_lps(struct adapter *padapter, u8 mode) if (mode < PS_MODE_NUM) { if (pwrctrlpriv->power_mgnt != mode) { - if (PS_MODE_ACTIVE == mode) + if (mode == PS_MODE_ACTIVE) LeaveAllPowerSaveMode(padapter); else pwrctrlpriv->LpsIdleCount = 2; pwrctrlpriv->power_mgnt = mode; - pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; + pwrctrlpriv->bLeisurePs = (pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE) ? true : false; } } else { ret = -EINVAL; @@ -653,7 +653,7 @@ int rtw_pm_set_ips(struct adapter *padapter, u8 mode) } else if (mode == IPS_NONE) { rtw_ips_mode_req(pwrctrlpriv, mode); DBG_88E("%s %s\n", __func__, "IPS_NONE"); - if ((padapter->bSurpriseRemoved == 0) && (_FAIL == rtw_pwr_wakeup(padapter))) + if ((padapter->bSurpriseRemoved == 0) && (rtw_pwr_wakeup(padapter) == _FAIL)) return -EFAULT; } else { return -EINVAL; diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 3fd5f4102b36..c0d580969029 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -193,7 +193,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfre plist = phead->next; while (phead != plist) { - hdr = container_of(plist, struct recv_frame, list); + hdr = list_entry(plist, struct recv_frame, list); plist = plist->next; @@ -237,25 +237,31 @@ static int recvframe_chkmic(struct adapter *adapter, stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]); if (prxattrib->encrypt == _TKIP_) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:prxattrib->encrypt==_TKIP_\n")); - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:da=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5])); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + ("\n %s: prxattrib->encrypt==_TKIP_\n", __func__)); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + ("\n %s: da=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", + __func__, prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], + prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5])); /* calculate mic code */ if (stainfo != NULL) { if (IS_MCAST(prxattrib->ra)) { if (!psecuritypriv) { res = _FAIL; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n")); - DBG_88E("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n"); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("\n %s: didn't install group key!!!!!!!!!!\n", __func__)); + DBG_88E("\n %s: didn't install group key!!!!!!!!!!\n", __func__); goto exit; } mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n")); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + ("\n %s: bcmc key\n", __func__)); } else { mickey = &stainfo->dot11tkiprxmickey.skey[0]; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic: unicast key\n")); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("\n %s: unicast key\n", __func__)); } /* icv_len included the mic code */ @@ -273,8 +279,8 @@ static int recvframe_chkmic(struct adapter *adapter, for (i = 0; i < 8; i++) { if (miccode[i] != *(pframemic+i)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, - ("recvframe_chkmic:miccode[%d](%02x)!=*(pframemic+%d)(%02x) ", - i, miccode[i], i, *(pframemic+i))); + ("%s: miccode[%d](%02x)!=*(pframemic+%d)(%02x) ", + __func__, i, miccode[i], i, *(pframemic + i))); bmic_err = true; } } @@ -346,7 +352,8 @@ static int recvframe_chkmic(struct adapter *adapter, } } } else { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic: rtw_get_stainfo==NULL!!!\n")); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("%s: rtw_get_stainfo==NULL!!!\n", __func__)); } skb_trim(precvframe->pkt, precvframe->pkt->len - 8); @@ -943,7 +950,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, xmitframe_plist = xmitframe_phead->next; if (xmitframe_phead != xmitframe_plist) { - pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); + pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = xmitframe_plist->next; @@ -1011,7 +1018,8 @@ static int validate_recv_mgnt_frame(struct adapter *padapter, precv_frame = recvframe_chk_defrag(padapter, precv_frame); if (precv_frame == NULL) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("%s: fragment packet\n", __func__)); + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, + ("%s: fragment packet\n", __func__)); return _SUCCESS; } @@ -1347,7 +1355,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter, phead = get_list_head(defrag_q); plist = phead->next; - pfhdr = container_of(plist, struct recv_frame, list); + pfhdr = list_entry(plist, struct recv_frame, list); prframe = pfhdr; list_del_init(&(prframe->list)); @@ -1367,7 +1375,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter, plist = plist->next; while (phead != plist) { - pnfhdr = container_of(plist, struct recv_frame, list); + pnfhdr = list_entry(plist, struct recv_frame, list); pnextrframe = pnfhdr; /* check the fragment sequence (2nd ~n fragment frame) */ @@ -1655,7 +1663,7 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, plist = phead->next; while (phead != plist) { - hdr = container_of(plist, struct recv_frame, list); + hdr = list_entry(plist, struct recv_frame, list); pnextattrib = &hdr->attrib; if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) @@ -1690,7 +1698,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor if (list_empty(phead)) return true; - prhdr = container_of(plist, struct recv_frame, list); + prhdr = list_entry(plist, struct recv_frame, list); pattrib = &prhdr->attrib; preorder_ctrl->indicate_seq = pattrib->seq_num; } @@ -1698,7 +1706,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor /* Prepare indication list and indication. */ /* Check if there is any packet need indicate. */ while (!list_empty(phead)) { - prhdr = container_of(plist, struct recv_frame, list); + prhdr = list_entry(plist, struct recv_frame, list); prframe = prhdr; pattrib = &prframe->attrib; diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index b283a4903369..5b1ef229df2a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -1690,4 +1690,4 @@ do { \ d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \ d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \ d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]; \ -} while (0); +} while (0) diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index 22cf362b8528..2fd2a9e2416e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -239,8 +239,8 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) } /* init for DM */ - psta->rssi_stat.UndecoratedSmoothedPWDB = (-1); - psta->rssi_stat.UndecoratedSmoothedCCK = (-1); + psta->rssi_stat.UndecoratedSmoothedPWDB = -1; + psta->rssi_stat.UndecoratedSmoothedCCK = -1; /* init for the sequence number of received management frame */ psta->RxMgmtFrameSeqNum = 0xffff; diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index be2f46eb9f78..e8d9858f2942 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -93,7 +93,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf; for (i = 0; i < NR_XMITFRAME; i++) { - INIT_LIST_HEAD(&(pxframe->list)); + INIT_LIST_HEAD(&pxframe->list); pxframe->padapter = padapter; pxframe->frame_tag = NULL_FRAMETAG; @@ -103,7 +103,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxframe->buf_addr = NULL; pxframe->pxmitbuf = NULL; - list_add_tail(&(pxframe->list), &(pxmitpriv->free_xmit_queue.queue)); + list_add_tail(&pxframe->list, &pxmitpriv->free_xmit_queue.queue); pxframe++; } @@ -148,7 +148,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitbuf->flags = XMIT_VO_QUEUE; - list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmitbuf_queue.queue)); + list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmitbuf_queue.queue); pxmitbuf++; } @@ -182,7 +182,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) goto exit; } - list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue)); + list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmit_extbuf_queue.queue); pxmitbuf++; } @@ -258,8 +258,8 @@ static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame * u32 sz; struct pkt_attrib *pattrib = &pxmitframe->attrib; struct sta_info *psta = pattrib->psta; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pattrib->nr_frags != 1) sz = padapter->xmitpriv.frag_len; @@ -697,7 +697,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("curfragnum=%d length=%d pattrib->icv_len=%d", curfragnum, length, pattrib->icv_len)); } } - rtw_secgetmic(&micdata, &(mic[0])); + rtw_secgetmic(&micdata, &mic[0]); RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: before add mic code!!!\n")); RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: pattrib->last_txcmdsz=%d!!!\n", pattrib->last_txcmdsz)); RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: mic[0]=0x%.2x , mic[1]=0x%.2x , mic[2]= 0x%.2x, mic[3]=0x%.2x\n\ @@ -705,18 +705,18 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr mic[0], mic[1], mic[2], mic[3], mic[4], mic[5], mic[6], mic[7])); /* add mic code and add the mic code length in last_txcmdsz */ - memcpy(payload, &(mic[0]), 8); + memcpy(payload, &mic[0], 8); pattrib->last_txcmdsz += 8; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("\n ======== last pkt ========\n")); payload = payload-pattrib->last_txcmdsz+8; for (curfragnum = 0; curfragnum < pattrib->last_txcmdsz; curfragnum = curfragnum+8) - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, - (" %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x ", - *(payload+curfragnum), *(payload+curfragnum+1), - *(payload+curfragnum+2), *(payload+curfragnum+3), - *(payload+curfragnum+4), *(payload+curfragnum+5), - *(payload+curfragnum+6), *(payload+curfragnum+7))); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, + (" %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x ", + *(payload + curfragnum), *(payload + curfragnum + 1), + *(payload + curfragnum + 2), *(payload + curfragnum + 3), + *(payload + curfragnum + 4), *(payload + curfragnum + 5), + *(payload + curfragnum + 6), *(payload + curfragnum + 7))); } else { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: rtw_get_stainfo==NULL!!!\n")); } @@ -786,7 +786,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr SetFrameSubType(fctrl, pattrib->subtype); if (pattrib->subtype & WIFI_DATA_TYPE) { - if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { /* to_ds = 1, fr_ds = 0; */ /* Data transfer to AP */ SetToDs(fctrl); @@ -899,20 +899,20 @@ s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pat switch (priority) { case 1: case 2: - ptxservq = &(psta->sta_xmitpriv.bk_q); + ptxservq = &psta->sta_xmitpriv.bk_q; break; case 4: case 5: - ptxservq = &(psta->sta_xmitpriv.vi_q); + ptxservq = &psta->sta_xmitpriv.vi_q; break; case 6: case 7: - ptxservq = &(psta->sta_xmitpriv.vo_q); + ptxservq = &psta->sta_xmitpriv.vo_q; break; case 0: case 3: default: - ptxservq = &(psta->sta_xmitpriv.be_q); + ptxservq = &psta->sta_xmitpriv.be_q; break; } @@ -1229,7 +1229,7 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) list_del_init(&pxmitbuf->list); - list_add_tail(&(pxmitbuf->list), get_list_head(pfree_queue)); + list_add_tail(&pxmitbuf->list, get_list_head(pfree_queue)); pxmitpriv->free_xmit_extbuf_cnt++; spin_unlock_irqrestore(&pfree_queue->lock, irql); @@ -1283,7 +1283,7 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) list_del_init(&pxmitbuf->list); - list_add_tail(&(pxmitbuf->list), get_list_head(pfree_xmitbuf_queue)); + list_add_tail(&pxmitbuf->list, get_list_head(pfree_xmitbuf_queue)); pxmitpriv->free_xmitbuf_cnt++; spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irql); @@ -1395,7 +1395,7 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram struct xmit_frame *pxmitframe; - spin_lock_bh(&(pframequeue->lock)); + spin_lock_bh(&pframequeue->lock); phead = get_list_head(pframequeue); plist = phead->next; @@ -1407,7 +1407,7 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram rtw_free_xmitframe(pxmitpriv, pxmitframe); } - spin_unlock_bh(&(pframequeue->lock)); + spin_unlock_bh(&pframequeue->lock); } @@ -1503,26 +1503,26 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info * switch (up) { case 1: case 2: - ptxservq = &(psta->sta_xmitpriv.bk_q); + ptxservq = &psta->sta_xmitpriv.bk_q; *(ac) = 3; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BK\n")); break; case 4: case 5: - ptxservq = &(psta->sta_xmitpriv.vi_q); + ptxservq = &psta->sta_xmitpriv.vi_q; *(ac) = 1; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VI\n")); break; case 6: case 7: - ptxservq = &(psta->sta_xmitpriv.vo_q); + ptxservq = &psta->sta_xmitpriv.vo_q; *(ac) = 0; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VO\n")); break; case 0: case 3: default: - ptxservq = &(psta->sta_xmitpriv.be_q); + ptxservq = &psta->sta_xmitpriv.be_q; *(ac) = 2; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BE\n")); break; @@ -1845,21 +1845,21 @@ void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta) pstapriv->sta_dz_bitmap |= BIT(psta->aid); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vo_q.sta_pending); - list_del_init(&(pstaxmitpriv->vo_q.tx_pending)); + list_del_init(&pstaxmitpriv->vo_q.tx_pending); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vi_q.sta_pending); - list_del_init(&(pstaxmitpriv->vi_q.tx_pending)); + list_del_init(&pstaxmitpriv->vi_q.tx_pending); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->be_q.sta_pending); - list_del_init(&(pstaxmitpriv->be_q.tx_pending)); + list_del_init(&pstaxmitpriv->be_q.tx_pending); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->bk_q.sta_pending); - list_del_init(&(pstaxmitpriv->bk_q.tx_pending)); + list_del_init(&pstaxmitpriv->bk_q.tx_pending); /* for BC/MC Frames */ pstaxmitpriv = &psta_bmc->sta_xmitpriv; dequeue_xmitframes_to_sleeping_queue(padapter, psta_bmc, &pstaxmitpriv->be_q.sta_pending); - list_del_init(&(pstaxmitpriv->be_q.tx_pending)); + list_del_init(&pstaxmitpriv->be_q.tx_pending); spin_unlock_bh(&pxmitpriv->lock); } diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index ec8aae76bf40..001d6267b56e 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -382,7 +382,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) } /* add by Neil Chen to avoid PSD is processing */ - if (pDM_Odm->bDMInitialGainEnable == false) { + if (!pDM_Odm->bDMInitialGainEnable) { ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: PSD is Processing\n")); return; } diff --git a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c index 0555e42a3787..5fcbe5639e99 100644 --- a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c @@ -109,7 +109,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, dm_odm->PhyDbgInfo.NumQryPhyStatusCCK++; /* (1)Hardware does not provide RSSI for CCK */ - /* (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) */ + /* (2)PWDB, Average PWDB calculated by hardware (for rate adaptive) */ cck_highpwr = dm_odm->bCckHighPower; @@ -223,7 +223,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, pPhyInfo->RxSNR[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); } - /* (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) */ + /* (2)PWDB, Average PWDB calculated by hardware (for rate adaptive) */ rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1) & 0x7f) - 110; PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index 3039bbe44a25..20253b5b6679 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -820,9 +820,8 @@ static void save_adda_registers(struct adapter *adapt, u32 *addareg, { u32 i; - for (i = 0; i < register_num; i++) { + for (i = 0; i < register_num; i++) backup[i] = phy_query_bb_reg(adapt, addareg[i], bMaskDWord); - } } static void save_mac_registers(struct adapter *adapt, u32 *mac_reg, @@ -830,9 +829,9 @@ static void save_mac_registers(struct adapter *adapt, u32 *mac_reg, { u32 i; - for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { + for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) backup[i] = usb_read8(adapt, mac_reg[i]); - } + backup[i] = usb_read32(adapt, mac_reg[i]); } @@ -850,9 +849,9 @@ static void reload_mac_registers(struct adapter *adapt, { u32 i; - for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { + for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) usb_write8(adapt, mac_reg[i], (u8)backup[i]); - } + usb_write32(adapt, mac_reg[i], backup[i]); } @@ -880,9 +879,9 @@ static void mac_setting_calibration(struct adapter *adapt, u32 *mac_reg, u32 *ba usb_write8(adapt, mac_reg[i], 0x3F); - for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) { + for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) usb_write8(adapt, mac_reg[i], (u8)(backup[i]&(~BIT(3)))); - } + usb_write8(adapt, mac_reg[i], (u8)(backup[i]&(~BIT(5)))); } diff --git a/drivers/staging/rtl8188eu/include/odm.h b/drivers/staging/rtl8188eu/include/odm.h index 4fb3bb07ceaa..50e2673edbf7 100644 --- a/drivers/staging/rtl8188eu/include/odm.h +++ b/drivers/staging/rtl8188eu/include/odm.h @@ -478,7 +478,7 @@ enum odm_operation_mode { /* ODM_CMNINFO_WM_MODE */ enum odm_wireless_mode { - ODM_WM_UNKNOW = 0x0, + ODM_WM_UNKNOWN = 0x0, ODM_WM_B = BIT(0), ODM_WM_G = BIT(1), ODM_WM_A = BIT(2), diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_spec.h b/drivers/staging/rtl8188eu/include/rtl8188e_spec.h index c93e19d1c50f..c33d312c4069 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_spec.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_spec.h @@ -15,7 +15,7 @@ #ifndef __RTL8188E_SPEC_H__ #define __RTL8188E_SPEC_H__ -/* 8192C Regsiter offset definition */ +/* 8192C Register offset definition */ #define HAL_PS_TIMER_INT_DELAY 50 /* 50 microseconds */ #define HAL_92C_NAV_UPPER_UNIT 128 /* micro-second */ @@ -701,7 +701,7 @@ Current IOREG MAP #define REG_USB_HRPWM 0xFE58 #define REG_USB_HCPWM 0xFE57 -/* 8192C Regsiter Bit and Content definition */ +/* 8192C Register Bit and Content definition */ /* 0x0000h ~ 0x00FFh System Configuration */ /* 2 SYS_ISO_CTRL */ diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index e4be85af31e7..1e308dfd7f74 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2811,8 +2811,9 @@ exit: static struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee) { - const u8 broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - + static const u8 broadcast_addr[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + }; struct sk_buff *skb; struct rtllib_probe_response *b; diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index b062cad052b9..3f434411247a 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -323,7 +323,7 @@ typedef struct ieee_param { u8 key[0]; } crypt; } u; -}ieee_param; +} ieee_param; // linux under 2.6.9 release may not support it, so modify it for common use @@ -412,15 +412,15 @@ typedef struct ieee_param { #define IEEE80211_QCTL_TID 0x000F #define FC_QOS_BIT BIT(7) -#define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false ) -#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) ) +#define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false) +#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0] & FC_QOS_BIT))) //added by wb. Is this right? -#define IsQoSDataFrame(pframe) ((*(u16 *)pframe&(IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) -#define Frame_Order(pframe) (*(u16 *)pframe&IEEE80211_FCTL_ORDER) -#define SN_LESS(a, b) (((a-b)&0x800)!=0) +#define IsQoSDataFrame(pframe) ((*(u16 *)pframe & (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA)) +#define Frame_Order(pframe) (*(u16 *)pframe & IEEE80211_FCTL_ORDER) +#define SN_LESS(a, b) (((a - b) & 0x800) != 0) #define SN_EQUAL(a, b) (a == b) #define MAX_DEV_ADDR_SIZE 8 -typedef enum _ACT_CATEGORY{ +typedef enum _ACT_CATEGORY { ACT_CAT_QOS = 1, ACT_CAT_DLS = 2, ACT_CAT_BA = 3, @@ -428,24 +428,24 @@ typedef enum _ACT_CATEGORY{ ACT_CAT_WMM = 17, } ACT_CATEGORY, *PACT_CATEGORY; -typedef enum _TS_ACTION{ +typedef enum _TS_ACTION { ACT_ADDTSREQ = 0, ACT_ADDTSRSP = 1, ACT_DELTS = 2, ACT_SCHEDULE = 3, } TS_ACTION, *PTS_ACTION; -typedef enum _BA_ACTION{ +typedef enum _BA_ACTION { ACT_ADDBAREQ = 0, ACT_ADDBARSP = 1, ACT_DELBA = 2, } BA_ACTION, *PBA_ACTION; -typedef enum _InitialGainOpType{ - IG_Backup=0, +typedef enum _InitialGainOpType { + IG_Backup = 0, IG_Restore, IG_Max -}InitialGainOpType; +} InitialGainOpType; /* debug macros */ #define CONFIG_IEEE80211_DEBUG @@ -457,22 +457,22 @@ do { if (ieee80211_debug_level & (level)) \ //wb added to debug out data buf //if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA #define IEEE80211_DEBUG_DATA(level, data, datalen) \ - do{ if ((ieee80211_debug_level & (level)) == (level)) \ + do { if ((ieee80211_debug_level & (level)) == (level)) \ { \ int i; \ u8 *pdata = (u8 *) data; \ printk(KERN_DEBUG "ieee80211: %s()\n", __func__); \ - for(i=0; i<(int)(datalen); i++) \ + for (i = 0; i < (int)(datalen); i++) \ { \ printk("%2x ", pdata[i]); \ - if ((i+1)%16 == 0) printk("\n"); \ + if ((i + 1) % 16 == 0) printk("\n"); \ } \ printk("\n"); \ } \ } while (0) #else -#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) -#define IEEE80211_DEBUG_DATA(level, data, datalen) do {} while(0) +#define IEEE80211_DEBUG (level, fmt, args...) do {} while (0) +#define IEEE80211_DEBUG_DATA (level, data, datalen) do {} while(0) #endif /* CONFIG_IEEE80211_DEBUG */ /* debug macros not dependent on CONFIG_IEEE80211_DEBUG */ @@ -876,9 +876,9 @@ enum ieee80211_mfie { MFIE_TYPE_ERP = 42, MFIE_TYPE_RSN = 48, MFIE_TYPE_RATES_EX = 50, - MFIE_TYPE_HT_CAP= 45, - MFIE_TYPE_HT_INFO= 61, - MFIE_TYPE_AIRONET=133, + MFIE_TYPE_HT_CAP = 45, + MFIE_TYPE_HT_INFO = 61, + MFIE_TYPE_AIRONET = 133, MFIE_TYPE_GENERIC = 221, MFIE_TYPE_QOS_PARAMETER = 222, }; @@ -1051,7 +1051,7 @@ typedef union _frameqos { u16 ack_policy:2; u16 reserved:1; u16 txop:8; - }field; + } field; } frameqos, *pframeqos; /* SWEEP TABLE ENTRIES NUMBER*/ @@ -1196,7 +1196,7 @@ static inline u8 Frame_QoSTID(u8 *buf) u16 fc; hdr = (struct rtl_80211_hdr_3addr *)buf; fc = le16_to_cpu(hdr->frame_ctl); - return (u8)((frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24)))->field.tid; + return (u8)((frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS) && (fc & IEEE80211_FCTL_FROMDS)) ? 30 : 24)))->field.tid; } //added by amy for reorder @@ -1209,7 +1209,7 @@ struct eapol { u16 length; } __packed; -struct ieee80211_softmac_stats{ +struct ieee80211_softmac_stats { unsigned int rx_ass_ok; unsigned int rx_ass_err; unsigned int rx_probe_rq; @@ -1320,7 +1320,7 @@ struct ether_header { #define ETHERTYPE_IP 0x0800 /* IP protocol */ #endif -typedef enum _erp_t{ +typedef enum _erp_t { ERP_NonERPpresent = 0x01, ERP_UseProtection = 0x02, ERP_BarkerPreambleMode = 0x04, @@ -1479,37 +1479,35 @@ typedef struct _RX_REORDER_ENTRY { struct ieee80211_rxb *prxb; } RX_REORDER_ENTRY, *PRX_REORDER_ENTRY; //added by amy for order -typedef enum _Fsync_State{ +typedef enum _Fsync_State { Default_Fsync, HW_Fsync, SW_Fsync -}Fsync_State; +} Fsync_State; // Power save mode configured. -typedef enum _RT_PS_MODE -{ +typedef enum _RT_PS_MODE { eActive, // Active/Continuous access. eMaxPs, // Max power save mode. eFastPs // Fast power save mode. -}RT_PS_MODE; +} RT_PS_MODE; -typedef enum _IPS_CALLBACK_FUNCION -{ +typedef enum _IPS_CALLBACK_FUNCION { IPS_CALLBACK_NONE = 0, IPS_CALLBACK_MGNT_LINK_REQUEST = 1, IPS_CALLBACK_JOIN_REQUEST = 2, -}IPS_CALLBACK_FUNCION; +} IPS_CALLBACK_FUNCION; -typedef enum _RT_JOIN_ACTION{ +typedef enum _RT_JOIN_ACTION { RT_JOIN_INFRA = 1, RT_JOIN_IBSS = 2, RT_START_IBSS = 3, RT_NO_ACTION = 4, -}RT_JOIN_ACTION; +} RT_JOIN_ACTION; -typedef struct _IbssParms{ +typedef struct _IbssParms { u16 atimWin; -}IbssParms, *PIbssParms; +} IbssParms, *PIbssParms; #define MAX_NUM_RATES 264 // Max num of support rates element: 8, Max num of ext. support rate: 255. 061122, by rcnjko. // RF state. @@ -1517,7 +1515,7 @@ typedef enum _RT_RF_POWER_STATE { eRfOn, eRfSleep, eRfOff -}RT_RF_POWER_STATE; +} RT_RF_POWER_STATE; typedef struct _RT_POWER_SAVE_CONTROL { @@ -1572,8 +1570,7 @@ typedef u32 RT_RF_CHANGE_SOURCE; #define RF_CHANGE_BY_IPS BIT(28) #define RF_CHANGE_BY_INIT 0 // Do not change the RFOff reason. Defined by Bruce, 2008-01-17. -typedef enum -{ +typedef enum { COUNTRY_CODE_FCC = 0, COUNTRY_CODE_IC = 1, COUNTRY_CODE_ETSI = 2, @@ -1585,10 +1582,10 @@ typedef enum COUNTRY_CODE_TELEC, COUNTRY_CODE_MIC, COUNTRY_CODE_GLOBAL_DOMAIN -}country_code_type_t; +} country_code_type_t; #define RT_MAX_LD_SLOT_NUM 10 -typedef struct _RT_LINK_DETECT_T{ +typedef struct _RT_LINK_DETECT_T { u32 NumRecvBcnInPeriod; u32 NumRecvDataInPeriod; @@ -1601,7 +1598,7 @@ typedef struct _RT_LINK_DETECT_T{ u32 NumTxOkInPeriod; u32 NumRxOkInPeriod; bool bBusyTraffic; -}RT_LINK_DETECT_T, *PRT_LINK_DETECT_T; +} RT_LINK_DETECT_T, *PRT_LINK_DETECT_T; struct ieee80211_device { @@ -1917,11 +1914,11 @@ struct ieee80211_device { struct net_device *dev); int (*reset_port)(struct net_device *dev); - int (*is_queue_full) (struct net_device *dev, int pri); + int (*is_queue_full)(struct net_device *dev, int pri); - int (*handle_management) (struct net_device *dev, + int (*handle_management)(struct net_device *dev, struct ieee80211_network *network, u16 type); - int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb); + int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb); /* Softmac-generated frames (management) are TXed via this * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is @@ -1989,16 +1986,16 @@ struct ieee80211_device { * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ - void (*start_send_beacons) (struct net_device *dev,u16 tx_rate); - void (*stop_send_beacons) (struct net_device *dev); + void (*start_send_beacons)(struct net_device *dev, u16 tx_rate); + void (*stop_send_beacons)(struct net_device *dev); /* power save mode related */ - void (*sta_wake_up) (struct net_device *dev); - void (*ps_request_tx_ack) (struct net_device *dev); - void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); - short (*ps_is_queue_empty) (struct net_device *dev); - int (*handle_beacon) (struct net_device *dev, struct ieee80211_beacon *beacon, struct ieee80211_network *network); - int (*handle_assoc_response) (struct net_device *dev, struct ieee80211_assoc_response_frame *resp, struct ieee80211_network *network); + void (*sta_wake_up)(struct net_device *dev); + void (*ps_request_tx_ack)(struct net_device *dev); + void (*enter_sleep_state)(struct net_device *dev, u32 th, u32 tl); + short (*ps_is_queue_empty)(struct net_device *dev); + int (*handle_beacon)(struct net_device *dev, struct ieee80211_beacon *beacon, struct ieee80211_network *network); + int (*handle_assoc_response)(struct net_device *dev, struct ieee80211_assoc_response_frame *resp, struct ieee80211_network *network); /* check whether Tx hw resource available */ @@ -2023,7 +2020,7 @@ struct ieee80211_device { #define IEEE_G (1<<2) #define IEEE_N_24G (1<<4) #define IEEE_N_5G (1<<5) -#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) +#define IEEE_MODE_MASK (IEEE_A | IEEE_B | IEEE_G) /* Generate a 802.11 header */ @@ -2112,7 +2109,7 @@ static inline int ieee80211_get_hdrlen(u16 fc) case IEEE80211_FTYPE_DATA: if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) hdrlen = IEEE80211_4ADDR_LEN; /* Addr4 */ - if(IEEE80211_QOS_HAS_SEQ(fc)) + if (IEEE80211_QOS_HAS_SEQ(fc)) hdrlen += 2; /* QOS ctrl*/ break; case IEEE80211_FTYPE_CTL: @@ -2379,7 +2376,7 @@ void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee, u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSFilter); extern u8 MCS_FILTER_ALL[]; -extern u16 MCS_DATA_RATE[2][2][77] ; +extern u16 MCS_DATA_RATE[2][2][77]; u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame); //extern void HTSetConnectBwModeCallback(unsigned long data); void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo); @@ -2426,7 +2423,8 @@ static inline int ieee80211_get_scans(struct ieee80211_device *ieee) return ieee->scans; } -static inline const char *escape_essid(const char *essid, u8 essid_len) { +static inline const char *escape_essid(const char *essid, u8 essid_len) +{ static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; if (ieee80211_is_empty_essid(essid, essid_len)) { diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index fe6f38b7ec35..4e7908322d77 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -2948,8 +2948,9 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, struct ieee_param *param, int param_len) { int ret = 0; + const char *module = NULL; - struct ieee80211_crypto_ops *ops; + struct ieee80211_crypto_ops *ops = NULL; struct ieee80211_crypt_data **crypt; struct ieee80211_security sec = { @@ -2995,19 +2996,17 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, strcmp(param->u.crypt.alg, "TKIP")) goto skip_host_crypt; - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); - if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) { - request_module("ieee80211_crypt_wep"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); - //set WEP40 first, it will be modified according to WEP104 or WEP40 at other place - } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) { - request_module("ieee80211_crypt_tkip"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); - } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) { - request_module("ieee80211_crypt_ccmp"); - ops = ieee80211_get_crypto_ops(param->u.crypt.alg); - } - if (ops == NULL) { + //set WEP40 first, it will be modified according to WEP104 or WEP40 at other place + if (!strcmp(param->u.crypt.alg, "WEP")) + module = "ieee80211_crypt_wep"; + else if (!strcmp(param->u.crypt.alg, "TKIP")) + module = "ieee80211_crypt_tkip"; + else if (!strcmp(param->u.crypt.alg, "CCMP")) + module = "ieee80211_crypt_ccmp"; + if (module) + ops = try_then_request_module(ieee80211_get_crypto_ops(param->u.crypt.alg), + module); + if (!ops) { printk("unknown crypto alg '%s'\n", param->u.crypt.alg); param->u.crypt.err = IEEE_CRYPT_ERR_UNKNOWN_ALG; ret = -EINVAL; diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index f58971a4a2e3..9a1a84548bc6 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -302,7 +302,6 @@ ieee80211_classify(struct sk_buff *skb, struct ieee80211_network *network) } } -#define SN_LESS(a, b) (((a-b)&0x800)!=0) static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee, struct sk_buff *skb, struct cb_desc *tcb_desc) { diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index c925e53bf013..f2fcdec9bd17 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -364,11 +364,8 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, GFP_KERNEL); if (!new_crypt) return -ENOMEM; - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); - if (!new_crypt->ops) { - request_module("ieee80211_crypt_wep"); - new_crypt->ops = ieee80211_get_crypto_ops("WEP"); - } + new_crypt->ops = try_then_request_module(ieee80211_get_crypto_ops("WEP"), + "ieee80211_crypt_wep"); if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) new_crypt->priv = new_crypt->ops->init(key); @@ -591,12 +588,8 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, } printk("alg name:%s\n",alg); - ops = ieee80211_get_crypto_ops(alg); - if (ops == NULL) { - request_module(module); - ops = ieee80211_get_crypto_ops(alg); - } - if (ops == NULL) { + ops = try_then_request_module(ieee80211_get_crypto_ops(alg), module); + if (!ops) { IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n", dev->name, ext->alg); printk("========>unknown crypto alg %d\n", ext->alg); diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 8aa38dcf0dfd..0f86195680e8 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -143,7 +143,7 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P if (ACT_ADDBARSP == type) { // Status Code - printk(KERN_INFO "=====>to send ADDBARSP\n"); + netdev_info(ieee->dev, "=====>to send ADDBARSP\n"); put_unaligned_le16(StatusCode, tag); tag += 2; @@ -345,7 +345,7 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb) pBaTimeoutVal = (u16 *)(tag + 5); pBaStartSeqCtrl = (PSEQUENCE_CONTROL)(req + 7); - printk(KERN_INFO "====================>rx ADDBAREQ from :%pM\n", dst); + netdev_info(ieee->dev, "====================>rx ADDBAREQ from :%pM\n", dst); //some other capability is not ready now. if ((ieee->current_network.qos_data.active == 0) || (!ieee->pHTInfo->bCurrentHTSupport)) //|| diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 46b3f19e0878..8701ce25abe4 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1687,9 +1687,13 @@ static short rtl8192_usb_initendpoints(struct net_device *dev) #ifndef JACKSON_NEW_RX for (i = 0; i < (MAX_RX_URB + 1); i++) { priv->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); + if (!priv->rx_urb[i]) + return -ENOMEM; priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); + if (!priv->rx_urb[i]->transfer_buffer) + return -ENOMEM; priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } @@ -2690,9 +2694,6 @@ static short rtl8192_init(struct net_device *dev) err = rtl8192_read_eeprom_info(dev); if (err) { DMESG("Reading EEPROM info failed"); - kfree(priv->pFirmware); - priv->pFirmware = NULL; - free_ieee80211(dev); return err; } rtl8192_get_channel_map(dev); @@ -4994,11 +4995,11 @@ static int rtl8192_usb_probe(struct usb_interface *intf, fail2: rtl8192_down(dev); +fail: kfree(priv->pFirmware); priv->pFirmware = NULL; rtl8192_usb_deleteendpoints(dev); mdelay(10); -fail: free_ieee80211(dev); RT_TRACE(COMP_ERR, "wlan driver load failed\n"); diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c index a9545386fbc5..e4e6c979bedf 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c @@ -964,7 +964,7 @@ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev) return wstats; } -struct iw_handler_def r8192_wx_handlers_def = { +const struct iw_handler_def r8192_wx_handlers_def = { .standard = r8192_wx_handlers, .num_standard = ARRAY_SIZE(r8192_wx_handlers), .private = r8192_private_handler, diff --git a/drivers/staging/rtl8192u/r8192U_wx.h b/drivers/staging/rtl8192u/r8192U_wx.h index fb5f808433d1..a6c2b95e2e69 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.h +++ b/drivers/staging/rtl8192u/r8192U_wx.h @@ -17,7 +17,7 @@ #ifndef R8180_WX_H #define R8180_WX_H -extern struct iw_handler_def r8192_wx_handlers_def; +extern const struct iw_handler_def r8192_wx_handlers_def; /* Enable the rtl819x_core.c to share this function, david 2008.9.22 */ struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev); diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index c83d7ebb164f..de832b0b5eec 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -216,9 +216,9 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) emem_sz = fwhdr.img_SRAM_size; do { memset(ptx_desc, 0, TXDESC_SIZE); - if (emem_sz > MAX_DUMP_FWSZ) /* max=48k */ + if (emem_sz > MAX_DUMP_FWSZ) { /* max=48k */ dump_emem_sz = MAX_DUMP_FWSZ; - else { + } else { dump_emem_sz = emem_sz; ptx_desc->txdw0 |= cpu_to_le32(BIT(28)); } diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index e698f6ede449..990a3438dfbb 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -385,11 +385,11 @@ static int netdev_open(struct net_device *pnetdev) padapter->bup = true; if (rtl871x_hal_init(padapter) != _SUCCESS) goto netdev_open_error; - if (!r8712_initmac) + if (!r8712_initmac) { /* Use the mac address stored in the Efuse */ memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); - else { + } else { /* We have to inform f/w to use user-supplied MAC * address. */ diff --git a/drivers/staging/rtl8712/rtl8712_cmd.c b/drivers/staging/rtl8712/rtl8712_cmd.c index 0104aced113e..3c88994fdfcd 100644 --- a/drivers/staging/rtl8712/rtl8712_cmd.c +++ b/drivers/staging/rtl8712/rtl8712_cmd.c @@ -356,11 +356,11 @@ _next: if ((wr_sz % 64) == 0) blnPending = 1; } - if (blnPending) /* 32 bytes for TX Desc - 8 offset */ + if (blnPending) { /* 32 bytes for TX Desc - 8 offset */ pdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ + 8) << OFFSET_SHT) & 0x00ff0000); - else { + } else { pdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & diff --git a/drivers/staging/rtl8712/rtl8712_event.h b/drivers/staging/rtl8712/rtl8712_event.h index b38374025c93..cad7085c3f8a 100644 --- a/drivers/staging/rtl8712/rtl8712_event.h +++ b/drivers/staging/rtl8712/rtl8712_event.h @@ -60,7 +60,6 @@ enum rtl8712_c2h_event { MAX_C2HEVT }; - #ifdef _RTL8712_CMD_C_ static struct fwevent wlanevents[] = { diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c index ea3eb94b28b3..8f555e6e1b3f 100644 --- a/drivers/staging/rtl8712/rtl8712_recv.c +++ b/drivers/staging/rtl8712/rtl8712_recv.c @@ -149,7 +149,7 @@ int r8712_free_recvframe(union recv_frame *precvframe, list_add_tail(&(precvframe->u.hdr.list), &pfree_recv_queue->queue); if (padapter != NULL) { if (pfree_recv_queue == &precvpriv->free_recv_queue) - precvpriv->free_recvframe_cnt++; + precvpriv->free_recvframe_cnt++; } spin_unlock_irqrestore(&pfree_recv_queue->lock, irqL); return _SUCCESS; @@ -883,10 +883,10 @@ static void query_rx_phy_status(struct _adapter *padapter, * from 0~100. It is assigned to the BSS List in * GetValueFromBeaconOrProbeRsp(). */ - if (bcck_rate) + if (bcck_rate) { prframe->u.hdr.attrib.signal_strength = (u8)r8712_signal_scale_mapping(pwdb_all); - else { + } else { if (rf_rx_num != 0) prframe->u.hdr.attrib.signal_strength = (u8)(r8712_signal_scale_mapping(total_rssi /= diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 04638f1e4e88..a424f447a725 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -899,9 +899,10 @@ void r8712_createbss_cmd_callback(struct _adapter *padapter, if (!pwlan) goto createbss_cmd_fail; pwlan->last_scanned = jiffies; - } else + } else { list_add_tail(&(pwlan->list), &pmlmepriv->scanned_queue.queue); + } pnetwork->Length = r8712_get_wlan_bssid_ex_sz(pnetwork); memcpy(&(pwlan->network), pnetwork, pnetwork->Length); pwlan->fixed = true; diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c index 01a150446f5a..8a5ced4fa9d3 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c @@ -78,10 +78,10 @@ static u8 do_join(struct _adapter *padapter) int ret; ret = r8712_select_and_join_from_scan(pmlmepriv); - if (ret == _SUCCESS) + if (ret == _SUCCESS) { mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); - else { + } else { if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { /* submit r8712_createbss_cmd to change to an * ADHOC_MASTER pmlmepriv->lock has been diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index bf1ac22bae1c..111c809afc51 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -574,10 +574,10 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf) set_fwstate(pmlmepriv, _FW_UNDER_LINKING); if (r8712_select_and_join_from_scan(pmlmepriv) - == _SUCCESS) + == _SUCCESS) { mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); - else { + } else { struct wlan_bssid_ex *pdev_network = &(adapter->registrypriv.dev_network); u8 *pibss = diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index b3e266bd57ab..85eadddfaf06 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -590,9 +590,10 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, mac[0] &= 0xFE; dev_info(&udev->dev, "r8712u: MAC Address from user = %pM\n", mac); - } else + } else { dev_info(&udev->dev, "r8712u: MAC Address from efuse = %pM\n", mac); + } ether_addr_copy(pnetdev->dev_addr, mac); } /* step 6. Load the firmware asynchronously */ diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index d3007c1c45e3..0b530ea7fd81 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1581,15 +1581,13 @@ u8 rtw_ap_set_pairwise_key(struct adapter *padapter, struct sta_info *psta) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc( - sizeof(struct set_stakey_parm) - ); + psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm)); if (psetstakey_para == NULL) { kfree((u8 *) ph2c); res = _FAIL; @@ -1630,12 +1628,12 @@ static int rtw_ap_set_key( /* DBG_871X("%s\n", __func__); */ - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd == NULL) { res = _FAIL; goto exit; } - psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); + psetkeyparm = rtw_zmalloc(sizeof(struct setkey_parm)); if (psetkeyparm == NULL) { kfree((unsigned char *)pcmd); res = _FAIL; diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index d381827dba3b..1843c44bc7a4 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -613,11 +613,11 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1); } - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) return _FAIL; - psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); + psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm)); if (psurveyPara == NULL) { kfree((unsigned char *) ph2c); return _FAIL; @@ -681,13 +681,13 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - pbsetdataratepara = (struct setdatarate_parm *)rtw_zmalloc(sizeof(struct setdatarate_parm)); + pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm)); if (pbsetdataratepara == NULL) { kfree((u8 *) ph2c); res = _FAIL; @@ -724,7 +724,7 @@ u8 rtw_createbss_cmd(struct adapter *padapter) RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); } - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd == NULL) { res = _FAIL; goto exit; @@ -757,7 +757,7 @@ u8 rtw_startbss_cmd(struct adapter *padapter, int flags) start_bss_network(padapter, (u8 *)&(padapter->mlmepriv.cur_network.network)); } else { /* need enqueue, prepare cmd_obj and enqueue */ - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd == NULL) { res = _FAIL; goto exit; @@ -815,7 +815,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+Join cmd: SSid =[%s]\n", pmlmepriv->assoc_ssid.Ssid)); } - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd == NULL) { res = _FAIL; RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd: memory allocate for cmd_obj fail!!!\n")); @@ -943,7 +943,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_disassoc_cmd\n")); /* prepare cmd parameter */ - param = (struct disconnect_parm *)rtw_zmalloc(sizeof(*param)); + param = rtw_zmalloc(sizeof(*param)); if (param == NULL) { res = _FAIL; goto exit; @@ -952,7 +952,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu if (enqueue) { /* need enqueue, prepare cmd_obj and enqueue */ - cmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(*cmdobj)); + cmdobj = rtw_zmalloc(sizeof(*cmdobj)); if (cmdobj == NULL) { res = _FAIL; kfree((u8 *)param); @@ -979,7 +979,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRAST struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; - psetop = (struct setopmode_parm *)rtw_zmalloc(sizeof(struct setopmode_parm)); + psetop = rtw_zmalloc(sizeof(struct setopmode_parm)); if (psetop == NULL) { res = _FAIL; @@ -988,7 +988,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRAST psetop->mode = (u8)networktype; if (enqueue) { - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { kfree((u8 *)psetop); res = _FAIL; @@ -1016,7 +1016,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_ struct security_priv *psecuritypriv = &padapter->securitypriv; u8 res = _SUCCESS; - psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); + psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm)); if (psetstakey_para == NULL) { res = _FAIL; goto exit; @@ -1040,14 +1040,14 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_ padapter->securitypriv.busetkipkey = true; if (enqueue) { - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { kfree((u8 *) psetstakey_para); res = _FAIL; goto exit; } - psetstakey_rsp = (struct set_stakey_rsp *)rtw_zmalloc(sizeof(struct set_stakey_rsp)); + psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp)); if (psetstakey_rsp == NULL) { kfree((u8 *) ph2c); kfree((u8 *) psetstakey_para); @@ -1083,20 +1083,20 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu rtw_camid_free(padapter, cam_id); } } else{ - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); + psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm)); if (psetstakey_para == NULL) { kfree((u8 *) ph2c); res = _FAIL; goto exit; } - psetstakey_rsp = (struct set_stakey_rsp *)rtw_zmalloc(sizeof(struct set_stakey_rsp)); + psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp)); if (psetstakey_rsp == NULL) { kfree((u8 *) ph2c); kfree((u8 *) psetstakey_para); @@ -1128,13 +1128,13 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - paddbareq_parm = (struct addBaReq_parm *)rtw_zmalloc(sizeof(struct addBaReq_parm)); + paddbareq_parm = rtw_zmalloc(sizeof(struct addBaReq_parm)); if (paddbareq_parm == NULL) { kfree((unsigned char *)ph2c); res = _FAIL; @@ -1162,13 +1162,13 @@ u8 rtw_reset_securitypriv_cmd(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); if (pdrvextra_cmd_parm == NULL) { kfree((unsigned char *)ph2c); res = _FAIL; @@ -1197,13 +1197,13 @@ u8 rtw_free_assoc_resources_cmd(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); if (pdrvextra_cmd_parm == NULL) { kfree((unsigned char *)ph2c); res = _FAIL; @@ -1233,13 +1233,13 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter) u8 res = _SUCCESS; /* only primary padapter does this cmd */ - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); if (pdrvextra_cmd_parm == NULL) { kfree((unsigned char *)ph2c); res = _FAIL; @@ -1283,7 +1283,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf } /* prepare cmd parameter */ - setChannelPlan_param = (struct SetChannelPlan_param *)rtw_zmalloc(sizeof(struct SetChannelPlan_param)); + setChannelPlan_param = rtw_zmalloc(sizeof(struct SetChannelPlan_param)); if (setChannelPlan_param == NULL) { res = _FAIL; goto exit; @@ -1292,7 +1292,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf if (enqueue) { /* need enqueue, prepare cmd_obj and enqueue */ - pcmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmdobj = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmdobj == NULL) { kfree((u8 *)setChannelPlan_param); res = _FAIL; @@ -1553,13 +1553,13 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue) /* return res; */ if (enqueue) { - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); if (pdrvextra_cmd_parm == NULL) { kfree((unsigned char *)ph2c); res = _FAIL; @@ -1595,13 +1595,13 @@ u8 rtw_dm_in_lps_wk_cmd(struct adapter *padapter) u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); if (pdrvextra_cmd_parm == NULL) { kfree((unsigned char *)ph2c); res = _FAIL; @@ -1668,13 +1668,13 @@ u8 rtw_dm_ra_mask_wk_cmd(struct adapter *padapter, u8 *psta) u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); if (pdrvextra_cmd_parm == NULL) { kfree((unsigned char *)ph2c); res = _FAIL; @@ -1719,13 +1719,13 @@ u8 rtw_ps_cmd(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; - ppscmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ppscmd = rtw_zmalloc(sizeof(struct cmd_obj)); if (ppscmd == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); if (pdrvextra_cmd_parm == NULL) { kfree((unsigned char *)ppscmd); res = _FAIL; @@ -1791,13 +1791,13 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); if (pdrvextra_cmd_parm == NULL) { kfree((unsigned char *)ph2c); res = _FAIL; @@ -1890,13 +1890,13 @@ u8 rtw_c2h_packet_wk_cmd(struct adapter *padapter, u8 *pbuf, u16 length) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); if (pdrvextra_cmd_parm == NULL) { kfree((u8 *)ph2c); res = _FAIL; @@ -1925,13 +1925,13 @@ u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); if (pdrvextra_cmd_parm == NULL) { kfree((u8 *)ph2c); res = _FAIL; @@ -1967,7 +1967,7 @@ static void c2h_wk_callback(_workitem *work) /* This C2H event is read, clear it */ c2h_evt_clear(adapter); } else{ - c2h_evt = (u8 *)rtw_malloc(16); + c2h_evt = rtw_malloc(16); if (c2h_evt != NULL) { /* This C2H event is not read, read & clear now */ if (rtw_hal_c2h_evt_read(adapter, c2h_evt) != _SUCCESS) { diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index cb8a95aabd6c..f9247a0a1539 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -28,9 +28,6 @@ sint _rtw_init_mlme_priv(struct adapter *padapter) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; sint res = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((u8 *)pmlmepriv, 0, sizeof(struct mlme_priv)); */ - pmlmepriv->nic_hdl = (u8 *)padapter; pmlmepriv->pscanned = NULL; @@ -2271,13 +2268,13 @@ sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); sint res = _SUCCESS; - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd == NULL) { res = _FAIL; /* try again */ goto exit; } - psetauthparm = (struct setauth_parm *)rtw_zmalloc(sizeof(struct setauth_parm)); + psetauthparm = rtw_zmalloc(sizeof(struct setauth_parm)); if (psetauthparm == NULL) { kfree((unsigned char *)pcmd); res = _FAIL; @@ -2312,7 +2309,7 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); sint res = _SUCCESS; - psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); + psetkeyparm = rtw_zmalloc(sizeof(struct setkey_parm)); if (psetkeyparm == NULL) { res = _FAIL; goto exit; @@ -2364,7 +2361,7 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s if (enqueue) { - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd == NULL) { kfree((unsigned char *)psetkeyparm); res = _FAIL; /* try again */ diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index b6d137f505e1..355ce9b19d1c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -17,6 +17,7 @@ #include <drv_types.h> #include <rtw_debug.h> #include <rtw_wifi_regd.h> +#include <linux/kernel.h> static struct mlme_handler mlme_sta_tbl[] = { @@ -474,9 +475,6 @@ int init_mlme_ext_priv(struct adapter *padapter) struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((u8 *)pmlmeext, 0, sizeof(struct mlme_ext_priv)); */ - pmlmeext->padapter = padapter; /* fill_fwpriv(padapter, &(pmlmeext->fwpriv)); */ @@ -510,7 +508,7 @@ void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext) if (!padapter) return; - if (padapter->bDriverStopped == true) { + if (padapter->bDriverStopped) { del_timer_sync(&pmlmeext->survey_timer); del_timer_sync(&pmlmeext->link_timer); /* del_timer_sync(&pmlmeext->ADDBA_timer); */ @@ -562,7 +560,7 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) index = GetFrameSubType(pframe) >> 4; - if (index >= (sizeof(mlme_sta_tbl) / sizeof(struct mlme_handler))) { + if (index >= ARRAY_SIZE(mlme_sta_tbl)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Currently we do not support reserved sub-fr-type =%d\n", index)); return; } @@ -582,7 +580,7 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) switch (GetFrameSubType(pframe)) { case WIFI_AUTH: - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) ptable->func = &OnAuth; else ptable->func = &OnAuthClient; @@ -637,8 +635,8 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame) /* DBG_871X("+OnProbeReq\n"); */ #ifdef CONFIG_AUTO_AP_MODE - if (check_fwstate(pmlmepriv, _FW_LINKED) == true && - pmlmepriv->cur_network.join_res == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED) && + pmlmepriv->cur_network.join_res) { struct sta_info *psta; u8 *mac_addr, *peer_addr; struct sta_priv *pstapriv = &padapter->stapriv; @@ -752,7 +750,7 @@ _non_rc_device: /* check (wildcard) SSID */ if (p != NULL) { - if (is_valid_p2p_probereq == true) + if (is_valid_p2p_probereq) goto _issue_probersp; if ((ielen != 0 && false == !memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) @@ -761,8 +759,8 @@ _non_rc_device: return _SUCCESS; _issue_probersp: - if (((check_fwstate(pmlmepriv, _FW_LINKED) == true && - pmlmepriv->cur_network.join_res == true)) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + if ((check_fwstate(pmlmepriv, _FW_LINKED) && + pmlmepriv->cur_network.join_res) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { /* DBG_871X("+issue_probersp during ap mode\n"); */ issue_probersp(padapter, get_sa(pframe), is_valid_p2p_probereq); } @@ -818,7 +816,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { /* we should update current network before auth, or some IE is wrong */ - pbss = (struct wlan_bssid_ex *)rtw_malloc(sizeof(struct wlan_bssid_ex)); + pbss = rtw_malloc(sizeof(struct wlan_bssid_ex)); if (pbss) { if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true); @@ -1773,7 +1771,7 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame) DBG_871X("%s Reason code(%d)\n", __func__, reason); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; @@ -1848,7 +1846,7 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame) DBG_871X("%s Reason code(%d)\n", __func__, reason); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; @@ -1976,7 +1974,7 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra /* process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), GetAddr3Ptr(pframe)); */ process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), addr); - if (pmlmeinfo->bAcceptAddbaReq == true) { + if (pmlmeinfo->bAcceptAddbaReq) { issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 0); } else{ issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */ @@ -2227,7 +2225,7 @@ unsigned int OnAction(struct adapter *padapter, union recv_frame *precv_frame) category = frame_body[0]; - for (i = 0; i < sizeof(OnAction_tbl)/sizeof(struct action_handler); i++) { + for (i = 0; i < ARRAY_SIZE(OnAction_tbl); i++) { ptable = &OnAction_tbl[i]; if (category == ptable->num) @@ -2350,8 +2348,8 @@ void update_mgntframe_attrib_addr(struct adapter *padapter, struct xmit_frame *p void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe) { - if (padapter->bSurpriseRemoved == true || - padapter->bDriverStopped == true) { + if (padapter->bSurpriseRemoved || + padapter->bDriverStopped) { rtw_free_xmitbuf(&padapter->xmitpriv, pmgntframe->pxmitbuf); rtw_free_xmitframe(&padapter->xmitpriv, pmgntframe); return; @@ -2368,8 +2366,8 @@ s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntfr struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf; struct submit_ctx sctx; - if (padapter->bSurpriseRemoved == true || - padapter->bDriverStopped == true) { + if (padapter->bSurpriseRemoved || + padapter->bDriverStopped) { rtw_free_xmitbuf(&padapter->xmitpriv, pmgntframe->pxmitbuf); rtw_free_xmitframe(&padapter->xmitpriv, pmgntframe); return ret; @@ -2397,8 +2395,8 @@ s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmg u32 timeout_ms = 500;/* 500ms */ struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - if (padapter->bSurpriseRemoved == true || - padapter->bDriverStopped == true) { + if (padapter->bSurpriseRemoved || + padapter->bDriverStopped) { rtw_free_xmitbuf(&padapter->xmitpriv, pmgntframe->pxmitbuf); rtw_free_xmitframe(&padapter->xmitpriv, pmgntframe); return -1; @@ -3394,7 +3392,7 @@ void issue_assocreq(struct adapter *padapter) pframe = rtw_set_ie(pframe, EID_WPA2, pIE->Length, pIE->data, &(pattrib->pktlen)); break; case EID_HTCapability: - if (padapter->mlmepriv.htpriv.ht_option == true) { + if (padapter->mlmepriv.htpriv.ht_option) { if (!(is_ap_in_tkip(padapter))) { memcpy(&(pmlmeinfo->HT_caps), pIE->data, sizeof(struct HT_caps_element)); pframe = rtw_set_ie(pframe, EID_HTCapability, pIE->Length, (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); @@ -3403,7 +3401,7 @@ void issue_assocreq(struct adapter *padapter) break; case EID_EXTCapability: - if (padapter->mlmepriv.htpriv.ht_option == true) + if (padapter->mlmepriv.htpriv.ht_option) pframe = rtw_set_ie(pframe, EID_EXTCapability, pIE->Length, pIE->data, &(pattrib->pktlen)); break; default: @@ -4219,7 +4217,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) if (initiator == 0) {/* recipient */ for (tid = 0; tid < MAXTID; tid++) { - if (psta->recvreorder_ctrl[tid].enable == true) { + if (psta->recvreorder_ctrl[tid].enable) { DBG_871X("rx agg disable tid(%d)\n", tid); issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); psta->recvreorder_ctrl[tid].enable = false; @@ -4408,7 +4406,7 @@ void site_survey(struct adapter *padapter) Restore_DM_Func_Flag(padapter); /* Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */ - if (is_client_associated_to_ap(padapter) == true) + if (is_client_associated_to_ap(padapter)) issue_nulldata(padapter, NULL, 0, 3, 500); val8 = 0; /* survey done */ @@ -5049,12 +5047,12 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame pmlmeext = &padapter->mlmeextpriv; pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd_obj == NULL) return; cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = rtw_zmalloc(cmdsz); if (pevtcmd == NULL) { kfree((u8 *)pcmd_obj); return; @@ -5102,12 +5100,12 @@ void report_surveydone_event(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd_obj == NULL) return; cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = rtw_zmalloc(cmdsz); if (pevtcmd == NULL) { kfree((u8 *)pcmd_obj); return; @@ -5149,12 +5147,12 @@ void report_join_res(struct adapter *padapter, int res) struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd_obj == NULL) return; cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = rtw_zmalloc(cmdsz); if (pevtcmd == NULL) { kfree((u8 *)pcmd_obj); return; @@ -5200,12 +5198,12 @@ void report_wmm_edca_update(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd_obj == NULL) return; cmdsz = (sizeof(struct wmm_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = rtw_zmalloc(cmdsz); if (pevtcmd == NULL) { kfree((u8 *)pcmd_obj); return; @@ -5246,13 +5244,13 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd_obj == NULL) { return; } cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = rtw_zmalloc(cmdsz); if (pevtcmd == NULL) { kfree((u8 *)pcmd_obj); return; @@ -5302,12 +5300,12 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj)); if (pcmd_obj == NULL) return; cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = rtw_zmalloc(cmdsz); if (pevtcmd == NULL) { kfree((u8 *)pcmd_obj); return; @@ -5445,7 +5443,7 @@ static void rtw_mlmeext_disconnect(struct adapter *padapter) pmlmeinfo->state = WIFI_FW_NULL_STATE; if (state_backup == WIFI_FW_STATION_STATE) { - if (rtw_port_switch_chk(padapter) == true) { + if (rtw_port_switch_chk(padapter)) { rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL); { struct adapter *port0_iface = dvobj_get_port0_adapter(adapter_to_dvobj(padapter)); @@ -5534,7 +5532,7 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) rtw_hal_macid_wakeup(padapter, psta->mac_id); } - if (rtw_port_switch_chk(padapter) == true) + if (rtw_port_switch_chk(padapter)) rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL); join_type = 2; @@ -5659,7 +5657,7 @@ void _linked_info_dump(struct adapter *padapter) } for (i = 0; i < NUM_STA; i++) { - if (pdvobj->macid[i] == true) { + if (pdvobj->macid[i]) { if (i != 1) /* skip bc/mc sta */ /* tx info ============ */ rtw_hal_get_def_var(padapter, HW_DEF_RA_INFO_DUMP, &i); @@ -5842,7 +5840,7 @@ void survey_timer_hdl(struct adapter *padapter) pmlmeext->sitesurvey_res.channel_idx++; } - if (pmlmeext->scan_abort == true) { + if (pmlmeext->scan_abort) { { pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num; DBG_871X("%s idx:%d\n", __func__ @@ -5853,12 +5851,12 @@ void survey_timer_hdl(struct adapter *padapter) pmlmeext->scan_abort = false;/* reset */ } - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { goto exit_survey_timer_hdl; } - psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); + psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm)); if (psurveyPara == NULL) { kfree((unsigned char *)ph2c); goto exit_survey_timer_hdl; @@ -5933,7 +5931,7 @@ void addba_timer_hdl(struct sta_info *psta) phtpriv = &psta->htpriv; - if ((phtpriv->ht_option == true) && (phtpriv->ampdu_enable == true)) { + if (phtpriv->ht_option && phtpriv->ampdu_enable) { if (phtpriv->candidate_tid_bitmap) phtpriv->candidate_tid_bitmap = 0x0; @@ -5946,7 +5944,7 @@ void sa_query_timer_hdl(struct adapter *padapter) /* disconnect */ spin_lock_bh(&pmlmepriv->lock); - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { rtw_disassoc_cmd(padapter, 0, true); rtw_indicate_disconnect(padapter); rtw_free_assoc_resources(padapter, 1); @@ -6084,7 +6082,7 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) rtw_auto_ap_start_beacon(padapter); #endif - if (rtw_port_switch_chk(padapter) == true) { + if (rtw_port_switch_chk(padapter)) { rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL); if (psetop->mode == Ndis802_11APMode) @@ -6358,7 +6356,7 @@ static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_c set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, in[i].hw_value); if (in[i].hw_value && !(in[i].flags & RTW_IEEE80211_CHAN_DISABLED) && set_idx >= 0 - && rtw_mlme_band_check(padapter, in[i].hw_value) == true + && rtw_mlme_band_check(padapter, in[i].hw_value) ) { if (j >= out_num) { DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" out_num:%u not enough\n", @@ -6383,7 +6381,7 @@ static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_c DBG_871X(FUNC_ADPT_FMT" ch:%u\n", FUNC_ADPT_ARG(padapter), pmlmeext->channel_set[i].ChannelNum); - if (rtw_mlme_band_check(padapter, pmlmeext->channel_set[i].ChannelNum) == true) { + if (rtw_mlme_band_check(padapter, pmlmeext->channel_set[i].ChannelNum)) { if (j >= out_num) { DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" out_num:%u not enough\n", @@ -6435,7 +6433,7 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf) pmlmeext->sitesurvey_res.scan_mode = pparm->scan_mode; /* issue null data if associating to the AP */ - if (is_client_associated_to_ap(padapter) == true) { + if (is_client_associated_to_ap(padapter)) { pmlmeext->sitesurvey_res.state = SCAN_TXNULL; issue_nulldata(padapter, NULL, 1, 3, 500); @@ -6602,7 +6600,7 @@ u8 chk_bmc_sleepq_cmd(struct adapter *padapter) struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; @@ -6626,13 +6624,13 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) u8 res = _SUCCESS; int len_diff = 0; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; goto exit; } - ptxBeacon_parm = (struct Tx_Beacon_param *)rtw_zmalloc(sizeof(struct Tx_Beacon_param)); + ptxBeacon_parm = rtw_zmalloc(sizeof(struct Tx_Beacon_param)); if (ptxBeacon_parm == NULL) { kfree((unsigned char *)ph2c); res = _FAIL; @@ -6767,7 +6765,7 @@ u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf) pxmitframe->attrib.triggered = 1; - if (xmitframe_hiq_filter(pxmitframe) == true) + if (xmitframe_hiq_filter(pxmitframe)) pxmitframe->attrib.qsel = 0x11;/* HIQ */ rtw_hal_xmitframe_enqueue(padapter, pxmitframe); @@ -6809,7 +6807,7 @@ int rtw_chk_start_clnt_join(struct adapter *padapter, u8 *ch, u8 *bw, u8 *offset connect_allow = false; } - if (connect_allow == true) { + if (connect_allow) { DBG_871X("start_join_set_ch_bw: ch =%d, bwmode =%d, ch_offset =%d\n", cur_ch, cur_bw, cur_ch_offset); *ch = cur_ch; *bw = cur_bw; diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index aabdaafcbdd3..820a061506cc 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -1193,8 +1193,6 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) void rtw_free_pwrctrl_priv(struct adapter *adapter) { - /* memset((unsigned char *)pwrctrlpriv, 0, sizeof(struct pwrctrl_priv)); */ - #ifdef CONFIG_PNO_SUPPORT if (pwrctrlpriv->pnlo_info != NULL) printk("****** pnlo_info memory leak********\n"); diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 68a6303e2754..8817902b02c7 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -46,9 +46,6 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) union recv_frame *precvframe; sint res = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((unsigned char *)precvpriv, 0, sizeof (struct recv_priv)); */ - spin_lock_init(&precvpriv->lock); _rtw_init_queue(&precvpriv->free_recv_queue); @@ -65,7 +62,6 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) res = _FAIL; goto exit; } - /* memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); */ precvpriv->precv_frame_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ); /* precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + RXFRAME_ALIGN_SZ - */ @@ -129,7 +125,7 @@ union recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue) plist = get_next(phead); - precvframe = LIST_CONTAINOR(plist, union recv_frame, u); + precvframe = (union recv_frame *)plist; list_del_init(&precvframe->u.hdr.list); padapter = precvframe->u.hdr.adapter; @@ -243,7 +239,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfre plist = get_next(phead); while (phead != plist) { - precvframe = LIST_CONTAINOR(plist, union recv_frame, u); + precvframe = (union recv_frame *)plist; plist = get_next(plist); @@ -1732,7 +1728,7 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter, phead = get_list_head(defrag_q); plist = get_next(phead); - prframe = LIST_CONTAINOR(plist, union recv_frame, u); + prframe = (union recv_frame *)plist; pfhdr = &prframe->u.hdr; list_del_init(&(prframe->u.list)); @@ -1754,7 +1750,7 @@ static union recv_frame *recvframe_defrag(struct adapter *adapter, data = get_recvframe_data(prframe); while (phead != plist) { - pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u); + pnextrframe = (union recv_frame *)plist; pnfhdr = &pnextrframe->u.hdr; @@ -2071,7 +2067,7 @@ int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union rec plist = get_next(phead); while (phead != plist) { - pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u); + pnextrframe = (union recv_frame *)plist; pnextattrib = &pnextrframe->u.hdr.attrib; if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) @@ -2146,7 +2142,7 @@ int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctr return true; } - prframe = LIST_CONTAINOR(plist, union recv_frame, u); + prframe = (union recv_frame *)plist; pattrib = &prframe->u.hdr.attrib; #ifdef DBG_RX_SEQ @@ -2162,7 +2158,7 @@ int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctr /* Check if there is any packet need indicate. */ while (!list_empty(phead)) { - prframe = LIST_CONTAINOR(plist, union recv_frame, u); + prframe = (union recv_frame *)plist; pattrib = &prframe->u.hdr.attrib; if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) { diff --git a/drivers/staging/rtl8723bs/core/rtw_rf.c b/drivers/staging/rtl8723bs/core/rtw_rf.c index b87ea4e388c0..07f5577cc073 100644 --- a/drivers/staging/rtl8723bs/core/rtw_rf.c +++ b/drivers/staging/rtl8723bs/core/rtw_rf.c @@ -15,6 +15,7 @@ #define _RTW_RF_C_ #include <drv_types.h> +#include <linux/kernel.h> struct ch_freq { @@ -44,20 +45,18 @@ static struct ch_freq ch_freq_map[] = { {216, 5080},/* Japan, means J16 */ }; -static int ch_freq_map_num = (sizeof(ch_freq_map) / sizeof(struct ch_freq)); - u32 rtw_ch2freq(u32 channel) { u8 i; u32 freq = 0; - for (i = 0; i < ch_freq_map_num; i++) { + for (i = 0; i < ARRAY_SIZE(ch_freq_map); i++) { if (channel == ch_freq_map[i].channel) { freq = ch_freq_map[i].frequency; break; } } - if (i == ch_freq_map_num) + if (i == ARRAY_SIZE(ch_freq_map)) freq = 2412; return freq; diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 06a7e4059fbb..aadf67bd0559 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -2272,7 +2272,7 @@ static void *aes_encrypt_init(u8 *key, size_t len) u32 *rk; if (len != 16) return NULL; - rk = (u32 *)rtw_malloc(AES_PRIV_SIZE); + rk = rtw_malloc(AES_PRIV_SIZE); if (rk == NULL) return NULL; rijndaelKeySetupEnc(rk, key); diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c index cb43ec90a648..c6ebb9d8cb3c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c @@ -429,7 +429,7 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) plist = get_next(phead); while (!list_empty(phead)) { - prframe = LIST_CONTAINOR(plist, union recv_frame, u); + prframe = (union recv_frame *)plist; plist = get_next(plist); diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index f485f541e36d..a1695348d1d5 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1359,7 +1359,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) return true; } - bssid = (struct wlan_bssid_ex *)rtw_zmalloc(sizeof(struct wlan_bssid_ex)); + bssid = rtw_zmalloc(sizeof(struct wlan_bssid_ex)); if (bssid == NULL) { DBG_871X("%s rtw_zmalloc fail !!!\n", __func__); return true; diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 022f654419e4..be54186fb223 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -51,9 +51,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) struct xmit_frame *pxframe; sint res = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv)); */ - spin_lock_init(&pxmitpriv->lock); spin_lock_init(&pxmitpriv->lock_sctx); sema_init(&pxmitpriv->xmit_sema, 0); @@ -2166,7 +2163,7 @@ void rtw_alloc_hwxmits(struct adapter *padapter) pxmitpriv->hwxmits = NULL; - pxmitpriv->hwxmits = (struct hw_xmit *)rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry); + pxmitpriv->hwxmits = rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry); if (pxmitpriv->hwxmits == NULL) { DBG_871X("alloc hwxmits fail!...\n"); diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c index 51d4219177d3..951585467ab1 100644 --- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c +++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c @@ -13,7 +13,7 @@ * ******************************************************************************/ - +#include <linux/kernel.h> #include "odm_precomp.h" static bool CheckPositive( @@ -268,7 +268,7 @@ static u32 Array_MP_8723B_AGC_TAB[] = { void ODM_ReadAndConfig_MP_8723B_AGC_TAB(PDM_ODM_T pDM_Odm) { u32 i = 0; - u32 ArrayLen = sizeof(Array_MP_8723B_AGC_TAB)/sizeof(u32); + u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_AGC_TAB); u32 *Array = Array_MP_8723B_AGC_TAB; ODM_RT_TRACE( @@ -537,7 +537,7 @@ static u32 Array_MP_8723B_PHY_REG[] = { void ODM_ReadAndConfig_MP_8723B_PHY_REG(PDM_ODM_T pDM_Odm) { u32 i = 0; - u32 ArrayLen = sizeof(Array_MP_8723B_PHY_REG)/sizeof(u32); + u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_PHY_REG); u32 *Array = Array_MP_8723B_PHY_REG; ODM_RT_TRACE( @@ -617,7 +617,6 @@ static u32 Array_MP_8723B_PHY_REG_PG[] = { void ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(PDM_ODM_T pDM_Odm) { u32 i = 0; - u32 ArrayLen = sizeof(Array_MP_8723B_PHY_REG_PG)/sizeof(u32); u32 *Array = Array_MP_8723B_PHY_REG_PG; ODM_RT_TRACE( @@ -630,7 +629,7 @@ void ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(PDM_ODM_T pDM_Odm) pDM_Odm->PhyRegPgVersion = 1; pDM_Odm->PhyRegPgValueType = PHY_REG_PG_EXACT_VALUE; - for (i = 0; i < ArrayLen; i += 6) { + for (i = 0; i < ARRAY_SIZE(Array_MP_8723B_PHY_REG_PG); i += 6) { u32 v1 = Array[i]; u32 v2 = Array[i+1]; u32 v3 = Array[i+2]; diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c index b868e26f20ac..7f8afa1be1ca 100644 --- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c +++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c @@ -13,7 +13,7 @@ * ******************************************************************************/ - +#include <linux/kernel.h> #include "odm_precomp.h" static bool CheckPositive( @@ -239,7 +239,7 @@ static u32 Array_MP_8723B_MAC_REG[] = { void ODM_ReadAndConfig_MP_8723B_MAC_REG(PDM_ODM_T pDM_Odm) { u32 i = 0; - u32 ArrayLen = sizeof(Array_MP_8723B_MAC_REG)/sizeof(u32); + u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_MAC_REG); u32 *Array = Array_MP_8723B_MAC_REG; ODM_RT_TRACE( diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c index 84a0be7ba697..fadfcbd91858 100644 --- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c +++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c @@ -13,7 +13,7 @@ * ******************************************************************************/ - +#include <linux/kernel.h> #include "odm_precomp.h" static bool CheckPositive( @@ -270,7 +270,7 @@ static u32 Array_MP_8723B_RadioA[] = { void ODM_ReadAndConfig_MP_8723B_RadioA(PDM_ODM_T pDM_Odm) { u32 i = 0; - u32 ArrayLen = sizeof(Array_MP_8723B_RadioA)/sizeof(u32); + u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_RadioA); u32 *Array = Array_MP_8723B_RadioA; ODM_RT_TRACE( @@ -766,7 +766,6 @@ static u8 *Array_MP_8723B_TXPWR_LMT[] = { void ODM_ReadAndConfig_MP_8723B_TXPWR_LMT(PDM_ODM_T pDM_Odm) { u32 i = 0; - u32 ArrayLen = sizeof(Array_MP_8723B_TXPWR_LMT)/sizeof(u8 *); u8 **Array = Array_MP_8723B_TXPWR_LMT; ODM_RT_TRACE( @@ -776,7 +775,7 @@ void ODM_ReadAndConfig_MP_8723B_TXPWR_LMT(PDM_ODM_T pDM_Odm) ("===> ODM_ReadAndConfig_MP_8723B_TXPWR_LMT\n") ); - for (i = 0; i < ArrayLen; i += 7) { + for (i = 0; i < ARRAY_SIZE(Array_MP_8723B_TXPWR_LMT); i += 7) { u8 *regulation = Array[i]; u8 *band = Array[i+1]; u8 *bandwidth = Array[i+2]; diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index 3e63b6d9c097..03554a4156d9 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -14,6 +14,7 @@ ******************************************************************************/ #define _HAL_COM_C_ +#include <linux/kernel.h> #include <drv_types.h> #include <rtw_debug.h> #include "hal_com_h2c.h" @@ -1716,7 +1717,6 @@ void rtw_bb_rf_gain_offset(struct adapter *padapter) { u8 value = padapter->eeprompriv.EEPROMRFGainOffset; u32 res, i = 0; - u32 ArrayLen = sizeof(Array_kfreemap)/sizeof(u32); u32 *Array = Array_kfreemap; u32 v1 = 0, v2 = 0, target = 0; /* DBG_871X("+%s value: 0x%02x+\n", __func__, value); */ @@ -1729,7 +1729,7 @@ void rtw_bb_rf_gain_offset(struct adapter *padapter) res &= 0xfff87fff; DBG_871X("Offset RF Gain. before reg 0x7f = 0x%08x\n", res); /* res &= 0xfff87fff; */ - for (i = 0; i < ArrayLen; i += 2) { + for (i = 0; i < ARRAY_SIZE(Array_kfreemap); i += 2) { v1 = Array[i]; v2 = Array[i+1]; if (v1 == padapter->eeprompriv.EEPROMRFGainVal) { diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 566b6f0997da..e6787c22e00b 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -17,6 +17,7 @@ #include <drv_types.h> #include <rtw_debug.h> #include <hal_data.h> +#include <linux/kernel.h> u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 Band, u8 RfPath, u8 TxNum, enum RATE_SECTION RateSection) @@ -860,7 +861,7 @@ struct adapter *padapter for (txNum = RF_1TX; txNum < RF_MAX_TX_NUM; ++txNum) { /* CCK */ base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_11M); - for (i = 0; i < sizeof(cckRates); ++i) { + for (i = 0; i < ARRAY_SIZE(cckRates); ++i) { value = PHY_GetTxPowerByRate(padapter, band, path, txNum, cckRates[i]); PHY_SetTxPowerByRate(padapter, band, path, txNum, cckRates[i], value - base); } @@ -939,58 +940,78 @@ void PHY_SetTxPowerIndexByRateSection( if (RateSection == CCK) { u8 cckRates[] = {MGN_1M, MGN_2M, MGN_5_5M, MGN_11M}; if (pHalData->CurrentBandType == BAND_ON_2_4G) - PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, - cckRates, sizeof(cckRates)/sizeof(u8)); + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, + pHalData->CurrentChannelBW, + Channel, cckRates, + ARRAY_SIZE(cckRates)); } else if (RateSection == OFDM) { u8 ofdmRates[] = {MGN_6M, MGN_9M, MGN_12M, MGN_18M, MGN_24M, MGN_36M, MGN_48M, MGN_54M}; - PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, - ofdmRates, sizeof(ofdmRates)/sizeof(u8)); + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, + pHalData->CurrentChannelBW, + Channel, ofdmRates, + ARRAY_SIZE(ofdmRates)); } else if (RateSection == HT_MCS0_MCS7) { u8 htRates1T[] = {MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7}; - PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, - htRates1T, sizeof(htRates1T)/sizeof(u8)); + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, + pHalData->CurrentChannelBW, + Channel, htRates1T, + ARRAY_SIZE(htRates1T)); } else if (RateSection == HT_MCS8_MCS15) { u8 htRates2T[] = {MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11, MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15}; - PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, - htRates2T, sizeof(htRates2T)/sizeof(u8)); + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, + pHalData->CurrentChannelBW, + Channel, htRates2T, + ARRAY_SIZE(htRates2T)); } else if (RateSection == HT_MCS16_MCS23) { u8 htRates3T[] = {MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19, MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23}; - PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, - htRates3T, sizeof(htRates3T)/sizeof(u8)); + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, + pHalData->CurrentChannelBW, + Channel, htRates3T, + ARRAY_SIZE(htRates3T)); } else if (RateSection == HT_MCS24_MCS31) { u8 htRates4T[] = {MGN_MCS24, MGN_MCS25, MGN_MCS26, MGN_MCS27, MGN_MCS28, MGN_MCS29, MGN_MCS30, MGN_MCS31}; - PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, - htRates4T, sizeof(htRates4T)/sizeof(u8)); + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, + pHalData->CurrentChannelBW, + Channel, htRates4T, + ARRAY_SIZE(htRates4T)); } else if (RateSection == VHT_1SSMCS0_1SSMCS9) { u8 vhtRates1T[] = {MGN_VHT1SS_MCS0, MGN_VHT1SS_MCS1, MGN_VHT1SS_MCS2, MGN_VHT1SS_MCS3, MGN_VHT1SS_MCS4, MGN_VHT1SS_MCS5, MGN_VHT1SS_MCS6, MGN_VHT1SS_MCS7, MGN_VHT1SS_MCS8, MGN_VHT1SS_MCS9}; - PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, - vhtRates1T, sizeof(vhtRates1T)/sizeof(u8)); + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, + pHalData->CurrentChannelBW, + Channel, vhtRates1T, + ARRAY_SIZE(vhtRates1T)); } else if (RateSection == VHT_2SSMCS0_2SSMCS9) { u8 vhtRates2T[] = {MGN_VHT2SS_MCS0, MGN_VHT2SS_MCS1, MGN_VHT2SS_MCS2, MGN_VHT2SS_MCS3, MGN_VHT2SS_MCS4, MGN_VHT2SS_MCS5, MGN_VHT2SS_MCS6, MGN_VHT2SS_MCS7, MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9}; - PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, - vhtRates2T, sizeof(vhtRates2T)/sizeof(u8)); + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, + pHalData->CurrentChannelBW, + Channel, vhtRates2T, + ARRAY_SIZE(vhtRates2T)); } else if (RateSection == VHT_3SSMCS0_3SSMCS9) { u8 vhtRates3T[] = {MGN_VHT3SS_MCS0, MGN_VHT3SS_MCS1, MGN_VHT3SS_MCS2, MGN_VHT3SS_MCS3, MGN_VHT3SS_MCS4, MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7, MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9}; - PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, - vhtRates3T, sizeof(vhtRates3T)/sizeof(u8)); + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, + pHalData->CurrentChannelBW, + Channel, vhtRates3T, + ARRAY_SIZE(vhtRates3T)); } else if (RateSection == VHT_4SSMCS0_4SSMCS9) { u8 vhtRates4T[] = {MGN_VHT4SS_MCS0, MGN_VHT4SS_MCS1, MGN_VHT4SS_MCS2, MGN_VHT4SS_MCS3, MGN_VHT4SS_MCS4, MGN_VHT4SS_MCS5, MGN_VHT4SS_MCS6, MGN_VHT4SS_MCS7, MGN_VHT4SS_MCS8, MGN_VHT4SS_MCS9}; - PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, - vhtRates4T, sizeof(vhtRates4T)/sizeof(u8)); + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, + pHalData->CurrentChannelBW, + Channel, vhtRates4T, + ARRAY_SIZE(vhtRates4T)); } else DBG_871X("Invalid RateSection %d in %s", RateSection, __func__); } @@ -1012,7 +1033,7 @@ static bool phy_GetChnlIndex(u8 Channel, u8 *ChannelIdx) } else { bIn24G = false; - for (i = 0; i < sizeof(channel5G)/sizeof(u8); ++i) { + for (i = 0; i < ARRAY_SIZE(channel5G); ++i) { if (channel5G[i] == Channel) { *ChannelIdx = i; return bIn24G; @@ -1149,7 +1170,7 @@ u8 PHY_GetTxPowerIndexBase( } else if (BandWidth == CHANNEL_WIDTH_80) { /* BW80-1S, BW80-2S */ /* <20121220, Kordan> Get the index of array "Index5G_BW80_Base". */ u8 channel5G_80M[CHANNEL_MAX_NUMBER_5G_80M] = {42, 58, 106, 122, 138, 155, 171}; - for (i = 0; i < sizeof(channel5G_80M)/sizeof(u8); ++i) + for (i = 0; i < ARRAY_SIZE(channel5G_80M); ++i) if (channel5G_80M[i] == Channel) chnlIdx = i; @@ -1588,7 +1609,7 @@ static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel) if (Band == BAND_ON_2_4G) channelIndex = Channel - 1; else if (Band == BAND_ON_5G) { - for (i = 0; i < sizeof(channel5G)/sizeof(u8); ++i) { + for (i = 0; i < ARRAY_SIZE(channel5G); ++i) { if (channel5G[i] == Channel) channelIndex = i; } diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 1565f2d67ea4..d6cef9e8378d 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -891,7 +891,7 @@ static void hal_ReadEFuse_WiFi( return; } - efuseTbl = (u8 *)rtw_malloc(EFUSE_MAX_MAP_LEN); + efuseTbl = rtw_malloc(EFUSE_MAX_MAP_LEN); if (efuseTbl == NULL) { DBG_8192C("%s: alloc efuseTbl fail!\n", __func__); return; diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 1d1b14dedd35..9a4c24861947 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -218,7 +218,7 @@ static u32 sdio_read32(struct intf_hdl *pintfhdl, u32 addr) } else { u8 *ptmpbuf; - ptmpbuf = (u8 *)rtw_malloc(8); + ptmpbuf = rtw_malloc(8); if (NULL == ptmpbuf) { DBG_8192C(KERN_ERR "%s: Allocate memory FAIL!(size =8) addr = 0x%x\n", __func__, addr); return SDIO_ERR_VAL32; @@ -594,7 +594,7 @@ static s32 _sdio_local_read( } n = RND4(cnt); - ptmpbuf = (u8 *)rtw_malloc(n); + ptmpbuf = rtw_malloc(n); if (!ptmpbuf) return (-1); @@ -637,7 +637,7 @@ s32 sdio_local_read( } n = RND4(cnt); - ptmpbuf = (u8 *)rtw_malloc(n); + ptmpbuf = rtw_malloc(n); if (!ptmpbuf) return (-1); @@ -684,7 +684,7 @@ s32 sdio_local_write( return err; } - ptmpbuf = (u8 *)rtw_malloc(cnt); + ptmpbuf = rtw_malloc(cnt); if (!ptmpbuf) return (-1); @@ -1108,7 +1108,7 @@ void sd_int_dpc(struct adapter *padapter) struct c2h_evt_hdr_88xx *c2h_evt; DBG_8192C("%s: C2H Command\n", __func__); - c2h_evt = (struct c2h_evt_hdr_88xx *)rtw_zmalloc(16); + c2h_evt = rtw_zmalloc(16); if (c2h_evt != NULL) { if (rtw_hal_c2h_evt_read(padapter, (u8 *)c2h_evt) == _SUCCESS) { if (c2h_id_filter_ccx_8723b((u8 *)c2h_evt)) { diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h b/drivers/staging/rtl8723bs/include/osdep_service.h index ac9ffe0e3b84..57523baa4517 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service.h +++ b/drivers/staging/rtl8723bs/include/osdep_service.h @@ -96,8 +96,8 @@ typedef enum mstat_status{ #define rtw_mstat_update(flag, status, sz) do {} while (0) #define rtw_mstat_dump(sel) do {} while (0) -u8*_rtw_zmalloc(u32 sz); -u8*_rtw_malloc(u32 sz); +void *_rtw_zmalloc(u32 sz); +void *_rtw_malloc(u32 sz); void _kfree(u8 *pbuf, u32 sz); struct sk_buff *_rtw_skb_alloc(u32 sz); diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h b/drivers/staging/rtl8723bs/include/osdep_service_linux.h index 0c9b4f622fee..09b1e3103244 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h +++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h @@ -86,7 +86,7 @@ __inline static struct list_head *get_list_head(struct __queue *queue) #define LIST_CONTAINOR(ptr, type, member) \ - ((type *)((char *)(ptr)-(__kernel_size_t)(&((type *)0)->member))) + container_of(ptr, type, member) #define RTW_TIMER_HDL_ARGS void *FunctionContext diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index bd4352fe2de3..51d48de24a24 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -136,11 +136,9 @@ static struct ieee80211_supported_band *rtw_spt_band_alloc( goto exit; } - spt_band = (struct ieee80211_supported_band *)rtw_zmalloc( - sizeof(struct ieee80211_supported_band) - + sizeof(struct ieee80211_channel)*n_channels - + sizeof(struct ieee80211_rate)*n_bitrates - ); + spt_band = rtw_zmalloc(sizeof(struct ieee80211_supported_band) + + sizeof(struct ieee80211_channel) * n_channels + + sizeof(struct ieee80211_rate) * n_bitrates); if (!spt_band) goto exit; @@ -1094,7 +1092,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, DBG_871X("pairwise =%d\n", pairwise); param_len = sizeof(struct ieee_param) + params->key_len; - param = (struct ieee_param *)rtw_malloc(param_len); + param = rtw_malloc(param_len); if (param == NULL) return -1; @@ -2183,7 +2181,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, { wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep =(struct ndis_802_11_wep *) rtw_malloc(wep_total_len); + pwep = rtw_malloc(wep_total_len); if (pwep == NULL) { DBG_871X(" wpa_set_encryption: pwep allocate fail !!!\n"); ret = -ENOMEM; @@ -2677,7 +2675,7 @@ static int rtw_cfg80211_add_monitor_if (struct adapter *padapter, char *name, st pnpi->sizeof_priv = sizeof(struct adapter); /* wdev */ - mon_wdev = (struct wireless_dev *)rtw_zmalloc(sizeof(struct wireless_dev)); + mon_wdev = rtw_zmalloc(sizeof(struct wireless_dev)); if (!mon_wdev) { DBG_871X(FUNC_ADPT_FMT" allocate mon_wdev fail\n", FUNC_ADPT_ARG(padapter)); ret = -ENOMEM; @@ -3497,7 +3495,7 @@ int rtw_wdev_alloc(struct adapter *padapter, struct device *dev) } /* wdev */ - wdev = (struct wireless_dev *)rtw_zmalloc(sizeof(struct wireless_dev)); + wdev = rtw_zmalloc(sizeof(struct wireless_dev)); if (!wdev) { DBG_8192C("Couldn't allocate wireless device\n"); ret = -ENOMEM; diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index d5e5f830f2a1..3fca0c2d4c8d 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -18,6 +18,7 @@ #include <rtw_debug.h> #include <rtw_mp.h> #include <linux/jiffies.h> +#include <linux/kernel.h> #define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV+30) @@ -557,7 +558,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep =(struct ndis_802_11_wep *) rtw_malloc(wep_total_len); + pwep = rtw_malloc(wep_total_len); if (pwep == NULL) { RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); goto exit; @@ -2123,12 +2124,9 @@ static int rtw_wx_set_gen_ie(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - int ret; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - ret = rtw_set_wpa_ie(padapter, extra, wrqu->data.length); - - return ret; + return rtw_set_wpa_ie(padapter, extra, wrqu->data.length); } static int rtw_wx_set_auth(struct net_device *dev, @@ -2238,7 +2236,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, int ret = 0; param_len = sizeof(struct ieee_param) + pext->key_len; - param = (struct ieee_param *)rtw_malloc(param_len); + param = rtw_malloc(param_len); if (param == NULL) return -1; @@ -2347,7 +2345,7 @@ static int rtw_wx_read32(struct net_device *dev, if (0 == len) return -EINVAL; - ptmp = (u8 *)rtw_malloc(len); + ptmp = rtw_malloc(len); if (NULL == ptmp) return -ENOMEM; @@ -3500,7 +3498,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) goto out; } - param = (struct ieee_param *)rtw_malloc(p->length); + param = rtw_malloc(p->length); if (param == NULL) { ret = -ENOMEM; goto out; @@ -3621,7 +3619,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep =(struct ndis_802_11_wep *)rtw_malloc(wep_total_len); + pwep = rtw_malloc(wep_total_len); if (pwep == NULL) { DBG_871X(" r871x_set_encryption: pwep allocate fail !!!\n"); goto exit; @@ -3857,7 +3855,6 @@ static int rtw_hostapd_sta_flush(struct net_device *dev) { /* _irqL irqL; */ /* struct list_head *phead, *plist; */ - int ret = 0; /* struct sta_info *psta = NULL; */ struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); /* struct sta_priv *pstapriv = &padapter->stapriv; */ @@ -3866,9 +3863,7 @@ static int rtw_hostapd_sta_flush(struct net_device *dev) flush_all_cam_entry(padapter); /* clear CAM */ - ret = rtw_sta_flush(padapter); - - return ret; + return rtw_sta_flush(padapter); } @@ -4266,7 +4261,6 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -4279,15 +4273,12 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p return -EINVAL; } - ret = rtw_acl_remove_sta(padapter, param->sta_addr); - - return ret; + return rtw_acl_remove_sta(padapter, param->sta_addr); } static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -4300,9 +4291,7 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *para return -EINVAL; } - ret = rtw_acl_add_sta(padapter, param->sta_addr); - - return ret; + return rtw_acl_add_sta(padapter, param->sta_addr); } @@ -4345,7 +4334,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) goto out; } - param = (struct ieee_param *)rtw_malloc(p->length); + param = rtw_malloc(p->length); if (param == NULL) { ret = -ENOMEM; goto out; @@ -4673,7 +4662,7 @@ static int rtw_test( DBG_871X("+%s\n", __func__); len = wrqu->data.length; - pbuf = (u8 *)rtw_zmalloc(len); + pbuf = rtw_zmalloc(len); if (pbuf == NULL) { DBG_871X("%s: no memory!\n", __func__); return -ENOMEM; @@ -5029,12 +5018,12 @@ static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) struct iw_handler_def rtw_handlers_def = { .standard = rtw_handlers, - .num_standard = sizeof(rtw_handlers) / sizeof(iw_handler), + .num_standard = ARRAY_SIZE(rtw_handlers), #if defined(CONFIG_WEXT_PRIV) .private = rtw_private_handler, .private_args = (struct iw_priv_args *)rtw_private_args, - .num_private = sizeof(rtw_private_handler) / sizeof(iw_handler), - .num_private_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args), + .num_private = ARRAY_SIZE(rtw_private_handler), + .num_private_args = ARRAY_SIZE(rtw_private_args), #endif .get_wireless_stats = rtw_get_wireless_stats, }; @@ -5121,8 +5110,8 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ priv = rtw_private_handler; priv_args = rtw_private_args; - num_priv = sizeof(rtw_private_handler) / sizeof(iw_handler); - num_priv_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args); + num_priv = ARRAY_SIZE(rtw_private_handler); + num_priv_args = ARRAY_SIZE(rtw_private_args); if (num_priv_args == 0) { err = -EOPNOTSUPP; diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c index 80ca2d781c5d..49cb701fa6ce 100644 --- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c @@ -19,7 +19,7 @@ #include <drv_types.h> #include <rtw_debug.h> -static void _dynamic_check_timer_handlder (void *FunctionContext) +static void _dynamic_check_timer_handlder(void *FunctionContext) { struct adapter *adapter = FunctionContext; @@ -51,8 +51,8 @@ void rtw_os_indicate_connect(struct adapter *adapter) { struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ==true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ==true)) + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { rtw_cfg80211_ibss_indicate_connect(adapter); } @@ -99,7 +99,7 @@ void rtw_reset_securitypriv(struct adapter *adapter) /* reset RX BIP packet number */ pmlmeext->mgnt_80211w_IPN_rx = 0; - memset((unsigned char *)&adapter->securitypriv, 0, sizeof (struct security_priv)); + memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv)); /* Added by Albert 2009/02/18 */ /* Restore the PMK information to securitypriv structure for the following connection. */ @@ -116,9 +116,9 @@ void rtw_reset_securitypriv(struct adapter *adapter) { /* if (adapter->mlmepriv.fw_state & WIFI_STATION_STATE) */ /* */ - struct security_priv *psec_priv =&adapter->securitypriv; + struct security_priv *psec_priv = &adapter->securitypriv; - psec_priv->dot11AuthAlgrthm =dot11AuthAlgrthm_Open; /* open system */ + psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_; psec_priv->dot11PrivacyKeyIndex = 0; @@ -150,7 +150,7 @@ void rtw_os_indicate_disconnect(struct adapter *adapter) void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) { uint len; - u8 *buff,*p, i; + u8 *buff, *p, i; union iwreq_data wrqu; RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("+rtw_report_sec_ie, authmode =%d\n", authmode)); @@ -168,22 +168,22 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) } p = buff; - p+=sprintf(p,"ASSOCINFO(ReqIEs ="); + p += sprintf(p, "ASSOCINFO(ReqIEs ="); - len = sec_ie[1]+2; - len = (len < IW_CUSTOM_MAX) ? len:IW_CUSTOM_MAX; + len = sec_ie[1] + 2; + len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX; - for (i = 0;i<len;i++) { - p+=sprintf(p,"%02x", sec_ie[i]); + for (i = 0; i < len; i++) { + p += sprintf(p, "%02x", sec_ie[i]); } - p+=sprintf(p,")"); + p += sprintf(p, ")"); memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length =p-buff; + wrqu.data.length = p - buff; - wrqu.data.length = (wrqu.data.length<IW_CUSTOM_MAX) ? wrqu.data.length:IW_CUSTOM_MAX; + wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? wrqu.data.length : IW_CUSTOM_MAX; kfree(buff); } diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 021589913681..51df42de9167 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -24,9 +24,9 @@ MODULE_AUTHOR("Realtek Semiconductor Corp."); MODULE_VERSION(DRIVERVERSION); /* module param defaults */ -static int rtw_chip_version = 0x00; +static int rtw_chip_version; static int rtw_rfintfs = HWPI; -static int rtw_lbkmode = 0;/* RTL8712_AIR_TRX; */ +static int rtw_lbkmode;/* RTL8712_AIR_TRX; */ static int rtw_network_mode = Ndis802_11IBSS;/* Ndis802_11Infrastructure;infra, ad-hoc, auto */ @@ -40,7 +40,7 @@ static int rtw_frag_thresh = 2346;/* */ static int rtw_preamble = PREAMBLE_LONG;/* long, short, auto */ static int rtw_scan_mode = 1;/* active, passive */ static int rtw_adhoc_tx_pwr = 1; -static int rtw_soft_ap = 0; +static int rtw_soft_ap; /* int smart_ps = 1; */ static int rtw_power_mgnt = 1; static int rtw_ips_mode = IPS_NORMAL; @@ -61,18 +61,18 @@ static int rtw_busy_thresh = 40; /* int qos_enable = 0; */ static int rtw_ack_policy = NORMAL_ACK; -static int rtw_software_encrypt = 0; -static int rtw_software_decrypt = 0; +static int rtw_software_encrypt; +static int rtw_software_decrypt; -static int rtw_acm_method = 0;/* 0:By SW 1:By HW. */ +static int rtw_acm_method;/* 0:By SW 1:By HW. */ static int rtw_wmm_enable = 1;/* default is set to enable the wmm. */ -static int rtw_uapsd_enable = 0; +static int rtw_uapsd_enable; static int rtw_uapsd_max_sp = NO_LIMIT; -static int rtw_uapsd_acbk_en = 0; -static int rtw_uapsd_acbe_en = 0; -static int rtw_uapsd_acvi_en = 0; -static int rtw_uapsd_acvo_en = 0; +static int rtw_uapsd_acbk_en; +static int rtw_uapsd_acbe_en; +static int rtw_uapsd_acvi_en; +static int rtw_uapsd_acvo_en; int rtw_ht_enable = 1; /* 0: 20 MHz, 1: 40 MHz, 2: 80 MHz, 3: 160MHz, 4: 80+80MHz */ @@ -81,7 +81,7 @@ int rtw_ht_enable = 1; static int rtw_bw_mode = 0x21; static int rtw_ampdu_enable = 1;/* for enable tx_ampdu ,0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */ static int rtw_rx_stbc = 1;/* 0: disable, 1:enable 2.4g */ -static int rtw_ampdu_amsdu = 0;/* 0: disabled, 1:enabled, 2:auto . There is an IOT issu with DLINK DIR-629 when the flag turn on */ +static int rtw_ampdu_amsdu;/* 0: disabled, 1:enabled, 2:auto . There is an IOT issu with DLINK DIR-629 when the flag turn on */ /* Short GI support Bit Map */ /* BIT0 - 20MHz, 0: non-support, 1: support */ /* BIT1 - 40MHz, 0: non-support, 1: support */ @@ -99,8 +99,8 @@ static int rtw_lowrate_two_xmit = 1;/* Use 2 path Tx to transmit MCS0~7 and lega /* int rf_config = RF_1T2R; 1T2R */ static int rtw_rf_config = RF_MAX_TYPE; /* auto */ -static int rtw_low_power = 0; -static int rtw_wifi_spec = 0; +static int rtw_low_power; +static int rtw_wifi_spec; static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX; static int rtw_btcoex_enable = 1; @@ -116,37 +116,37 @@ MODULE_PARM_DESC(rtw_ant_num, "Antenna number setting"); static int rtw_AcceptAddbaReq = true;/* 0:Reject AP's Add BA req, 1:Accept AP's Add BA req. */ static int rtw_antdiv_cfg = 1; /* 0:OFF , 1:ON, 2:decide by Efuse config */ -static int rtw_antdiv_type = 0 ; /* 0:decide by efuse 1: for 88EE, 1Tx and 1RxCG are diversity.(2 Ant with SPDT), 2: for 88EE, 1Tx and 2Rx are diversity.(2 Ant, Tx and RxCG are both on aux port, RxCS is on main port), 3: for 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */ +static int rtw_antdiv_type; /* 0:decide by efuse 1: for 88EE, 1Tx and 1RxCG are diversity.(2 Ant with SPDT), 2: for 88EE, 1Tx and 2Rx are diversity.(2 Ant, Tx and RxCG are both on aux port, RxCS is on main port), 3: for 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */ -static int rtw_enusbss = 0;/* 0:disable, 1:enable */ +static int rtw_enusbss;/* 0:disable, 1:enable */ -static int rtw_hwpdn_mode =2;/* 0:disable, 1:enable, 2: by EFUSE config */ +static int rtw_hwpdn_mode = 2;/* 0:disable, 1:enable, 2: by EFUSE config */ #ifdef CONFIG_HW_PWRP_DETECTION static int rtw_hwpwrp_detect = 1; #else -static int rtw_hwpwrp_detect = 0; /* HW power ping detect 0:disable , 1:enable */ +static int rtw_hwpwrp_detect; /* HW power ping detect 0:disable , 1:enable */ #endif -static int rtw_hw_wps_pbc = 0; +static int rtw_hw_wps_pbc; int rtw_mc2u_disable = 0; -static int rtw_80211d = 0; +static int rtw_80211d; #ifdef CONFIG_QOS_OPTIMIZATION static int rtw_qos_opt_enable = 1;/* 0: disable, 1:enable */ #else -static int rtw_qos_opt_enable = 0;/* 0: disable, 1:enable */ +static int rtw_qos_opt_enable;/* 0: disable, 1:enable */ #endif module_param(rtw_qos_opt_enable, int, 0644); -static char* ifname = "wlan%d"; +static char *ifname = "wlan%d"; module_param(ifname, charp, 0644); MODULE_PARM_DESC(ifname, "The default name to allocate for first interface"); -char* rtw_initmac = NULL; /* temp mac address if users want to use instead of the mac address in Efuse */ +char *rtw_initmac = NULL; /* temp mac address if users want to use instead of the mac address in Efuse */ module_param(rtw_initmac, charp, 0644); module_param(rtw_channel_plan, int, 0644); @@ -183,7 +183,7 @@ module_param(rtw_hwpwrp_detect, int, 0644); module_param(rtw_hw_wps_pbc, int, 0644); -static uint rtw_max_roaming_times =2; +static uint rtw_max_roaming_times = 2; module_param(rtw_max_roaming_times, uint, 0644); MODULE_PARM_DESC(rtw_max_roaming_times,"The max roaming times to try"); @@ -192,7 +192,7 @@ module_param(rtw_mc2u_disable, int, 0644); module_param(rtw_80211d, int, 0644); MODULE_PARM_DESC(rtw_80211d, "Enable 802.11d mechanism"); -static uint rtw_notch_filter = 0; +static uint rtw_notch_filter; module_param(rtw_notch_filter, uint, 0644); MODULE_PARM_DESC(rtw_notch_filter, "0:Disable, 1:Enable, 2:Enable only for P2P"); @@ -202,8 +202,8 @@ static uint rtw_hiq_filter = CONFIG_RTW_HIQ_FILTER; module_param(rtw_hiq_filter, uint, 0644); MODULE_PARM_DESC(rtw_hiq_filter, "0:allow all, 1:allow special, 2:deny all"); -static int rtw_tx_pwr_lmt_enable = 0; -static int rtw_tx_pwr_by_rate = 0; +static int rtw_tx_pwr_lmt_enable; +static int rtw_tx_pwr_by_rate; module_param(rtw_tx_pwr_lmt_enable, int, 0644); MODULE_PARM_DESC(rtw_tx_pwr_lmt_enable,"0:Disable, 1:Enable, 2: Depend on efuse"); @@ -222,10 +222,10 @@ MODULE_PARM_DESC(rtw_phy_file_path, "The path of phy parameter"); /* BIT4 - RF, 0: non-support, 1: support */ /* BIT5 - RF_TXPWR_TRACK, 0: non-support, 1: support */ /* BIT6 - RF_TXPWR_LMT, 0: non-support, 1: support */ -static int rtw_load_phy_file = (BIT2|BIT6); +static int rtw_load_phy_file = (BIT2 | BIT6); module_param(rtw_load_phy_file, int, 0644); MODULE_PARM_DESC(rtw_load_phy_file,"PHY File Bit Map"); -static int rtw_decrypt_phy_file = 0; +static int rtw_decrypt_phy_file; module_param(rtw_decrypt_phy_file, int, 0644); MODULE_PARM_DESC(rtw_decrypt_phy_file,"Enable Decrypt PHY File"); @@ -255,8 +255,8 @@ static uint loadparam(struct adapter *padapter, _nic_hdl pnetdev) registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense ; registry_par->vcs_type = (u8)rtw_vcs_type; - registry_par->rts_thresh =(u16)rtw_rts_thresh; - registry_par->frag_thresh =(u16)rtw_frag_thresh; + registry_par->rts_thresh = (u16)rtw_rts_thresh; + registry_par->frag_thresh = (u16)rtw_frag_thresh; registry_par->preamble = (u8)rtw_preamble; registry_par->scan_mode = (u8)rtw_scan_mode; registry_par->adhoc_tx_pwr = (u8)rtw_adhoc_tx_pwr; @@ -351,8 +351,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 == false) { /* 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); @@ -425,9 +424,7 @@ static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb skb->priority = rtw_classify8021d(skb); if (pmlmepriv->acm_mask != 0) - { skb->priority = qos_acm(pmlmepriv->acm_mask, skb->priority); - } return rtw_1d_to_queue[skb->priority]; } @@ -440,12 +437,12 @@ u16 rtw_recv_select_queue(struct sk_buff *skb) u32 priority; u8 *pdata = skb->data; - memcpy(ð_type, pdata+(ETH_ALEN<<1), 2); + memcpy(ð_type, pdata + (ETH_ALEN << 1), 2); switch (be16_to_cpu(eth_type)) { case ETH_P_IP: - piphdr = (struct iphdr *)(pdata+ETH_HLEN); + piphdr = (struct iphdr *)(pdata + ETH_HLEN); dscp = piphdr->tos & 0xfc; @@ -457,17 +454,16 @@ u16 rtw_recv_select_queue(struct sk_buff *skb) } return rtw_1d_to_queue[priority]; - } -static int rtw_ndev_notifier_call(struct notifier_block * nb, unsigned long state, void *ptr) +static int rtw_ndev_notifier_call(struct notifier_block *nb, unsigned long state, void *ptr) { struct net_device *dev = netdev_notifier_info_to_dev(ptr); if (dev->netdev_ops->ndo_do_ioctl != rtw_ioctl) return NOTIFY_DONE; - DBG_871X_LEVEL(_drv_info_, FUNC_NDEV_FMT" state:%lu\n", FUNC_NDEV_ARG(dev), state); + DBG_871X_LEVEL(_drv_info_, FUNC_NDEV_FMT " state:%lu\n", FUNC_NDEV_ARG(dev), state); switch (state) { case NETDEV_CHANGENAME: @@ -497,7 +493,7 @@ static int rtw_ndev_init(struct net_device *dev) { struct adapter *adapter = rtw_netdev_priv(dev); - DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter)); + DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(adapter)); strncpy(adapter->old_ifname, dev->name, IFNAMSIZ); rtw_adapter_proc_init(dev); @@ -508,7 +504,7 @@ static void rtw_ndev_uninit(struct net_device *dev) { struct adapter *adapter = rtw_netdev_priv(dev); - DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter)); + DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(adapter)); rtw_adapter_proc_deinit(dev); } @@ -561,7 +557,7 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter) pnetdev->netdev_ops = &rtw_netdev_ops; /* pnetdev->tx_timeout = NULL; */ - pnetdev->watchdog_timeo = HZ*3; /* 3 second timeout */ + pnetdev->watchdog_timeo = HZ * 3; /* 3 second timeout */ pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def; /* step 2. */ @@ -597,7 +593,7 @@ u32 rtw_start_drv_threads(struct adapter *padapter) _status = _FAIL; padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD"); - if (IS_ERR(padapter->cmdThread)) + if (IS_ERR(padapter->cmdThread)) _status = _FAIL; else down(&padapter->cmdpriv.terminate_cmdthread_sema); /* wait for cmd_thread to run */ @@ -623,7 +619,7 @@ void rtw_stop_drv_threads (struct adapter *padapter) static u8 rtw_init_default_value(struct adapter *padapter) { u8 ret = _SUCCESS; - struct registry_priv* pregistrypriv = &padapter->registrypriv; + struct registry_priv *pregistrypriv = &padapter->registrypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; @@ -652,8 +648,8 @@ static u8 rtw_init_default_value(struct adapter *padapter) #ifdef CONFIG_GTK_OL psecuritypriv->binstallKCK_KEK = _FAIL; #endif /* CONFIG_GTK_OL */ - psecuritypriv->sw_encrypt =pregistrypriv->software_encrypt; - psecuritypriv->sw_decrypt =pregistrypriv->software_decrypt; + psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt; + psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt; psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; @@ -691,7 +687,8 @@ struct dvobj_priv *devobj_init(void) { struct dvobj_priv *pdvobj = NULL; - if ((pdvobj = (struct dvobj_priv*)rtw_zmalloc(sizeof(*pdvobj))) == NULL) + pdvobj = rtw_zmalloc(sizeof(*pdvobj)); + if (pdvobj == NULL) return NULL; mutex_init(&pdvobj->hw_init_mutex); @@ -722,7 +719,7 @@ void devobj_deinit(struct dvobj_priv *pdvobj) mutex_destroy(&pdvobj->setch_mutex); mutex_destroy(&pdvobj->setbw_mutex); - kfree((u8 *)pdvobj); + kfree(pdvobj); } u8 rtw_reset_drv_sw(struct adapter *padapter) @@ -748,7 +745,7 @@ u8 rtw_reset_drv_sw(struct adapter *padapter) pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 0; pmlmepriv->LinkDetectInfo.LowPowerTransitionCount = 0; - _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY |_FW_UNDER_LINKING); + _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING); pwrctrlpriv->pwr_state_check_cnts = 0; @@ -777,7 +774,7 @@ u8 rtw_init_drv_sw(struct adapter *padapter) goto exit; } - padapter->cmdpriv.padapter =padapter; + padapter->cmdpriv.padapter = padapter; if ((rtw_init_evt_priv(&padapter->evtpriv)) == _FAIL) { RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init evt_priv\n")); @@ -935,7 +932,7 @@ static int _rtw_drv_register_netdev(struct adapter *padapter, char *name) goto error_register_netdev; } - DBG_871X("%s, MAC Address (if%d) = " MAC_FMT "\n", __func__, (padapter->iface_id+1), MAC_ARG(pnetdev->dev_addr)); + DBG_871X("%s, MAC Address (if%d) = " MAC_FMT "\n", __func__, (padapter->iface_id + 1), MAC_ARG(pnetdev->dev_addr)); return ret; @@ -984,9 +981,9 @@ int _netdev_open(struct net_device *pnetdev) goto netdev_open_error; } - DBG_871X("MAC Address = "MAC_FMT"\n", MAC_ARG(pnetdev->dev_addr)); + DBG_871X("MAC Address = " MAC_FMT "\n", MAC_ARG(pnetdev->dev_addr)); - status =rtw_start_drv_threads(padapter); + status = rtw_start_drv_threads(padapter); if (status == _FAIL) { DBG_871X("Initialize driver software resource Failed!\n"); goto netdev_open_error; @@ -1027,7 +1024,6 @@ netdev_open_error: DBG_871X("-871x_drv - drv_open fail, bup =%d\n", padapter->bup); return (-1); - } int netdev_open(struct net_device *pnetdev) @@ -1036,8 +1032,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 == true) { DBG_871X("+871x_drv - drv_open, bInSuspend =%d\n", pwrctrlpriv->bInSuspend); return 0; } @@ -1066,16 +1061,13 @@ static int ips_netdrv_open(struct adapter *padapter) /* padapter->bup = true; */ status = rtw_hal_init(padapter); - if (status == _FAIL) - { + if (status == _FAIL) { RT_TRACE(_module_os_intfs_c_, _drv_err_, ("ips_netdrv_open(): Can't init h/w!\n")); goto netdev_open_error; } if (padapter->intf_start) - { padapter->intf_start(padapter); - } _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000); @@ -1098,7 +1090,6 @@ int rtw_ips_pwr_up(struct adapter *padapter) DBG_871X("<=== rtw_ips_pwr_up..............\n"); return result; - } void rtw_ips_pwr_down(struct adapter *padapter) @@ -1119,10 +1110,7 @@ void rtw_ips_dev_unload(struct adapter *padapter) if (padapter->bSurpriseRemoved == false) - { rtw_hal_deinit(padapter); - } - } @@ -1132,15 +1120,14 @@ static int pm_netdev_open(struct net_device *pnetdev, u8 bnormal) struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); - if (true == bnormal) - { + if (true == 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)); } } else - status = (_SUCCESS == ips_netdrv_open(padapter))?(0):(-1); + status = (_SUCCESS == ips_netdrv_open(padapter)) ? (0) : (-1); return status; } @@ -1152,8 +1139,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 == true) { /* rtw_pwr_wakeup(padapter); */ if (pwrctl->rf_pwrstate == rf_off) pwrctl->ps_flag = true; @@ -1174,8 +1160,7 @@ static int netdev_close(struct net_device *pnetdev) DBG_871X("(2)871x_drv - drv_close, bup =%d, hw_init_completed =%d\n", padapter->bup, padapter->hw_init_completed); /* s1. */ - if (pnetdev) - { + if (pnetdev) { if (!rtw_netif_queue_stopped(pnetdev)) rtw_netif_stop_queue(pnetdev); } @@ -1198,12 +1183,11 @@ static int netdev_close(struct net_device *pnetdev) DBG_871X("-871x_drv - drv_close, bup =%d\n", padapter->bup); return 0; - } void rtw_ndev_destructor(struct net_device *ndev) { - DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); + DBG_871X(FUNC_NDEV_FMT "\n", FUNC_NDEV_ARG(ndev)); if (ndev->ieee80211_ptr) kfree((u8 *)ndev->ieee80211_ptr); @@ -1219,8 +1203,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 == true) { DBG_871X("===> %s\n", __func__); padapter->bDriverStopped = true; @@ -1257,12 +1240,11 @@ 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 == false) { rtw_btcoex_IpsNotify(padapter, pwrctl->ips_mode_req); #ifdef CONFIG_WOWLAN if (pwrctl->bSupportRemoteWakeup == true && - pwrctl->wowlan_mode ==true) { + pwrctl->wowlan_mode == true) { DBG_871X_LEVEL(_drv_always_, "%s bSupportRemoteWakeup ==true do not run rtw_hal_deinit()\n", __func__); } else @@ -1292,12 +1274,11 @@ static int rtw_suspend_free_assoc_resource(struct adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); + DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter)); if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) - && check_fwstate(pmlmepriv, _FW_LINKED)) - { + && 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), @@ -1307,14 +1288,12 @@ static int rtw_suspend_free_assoc_resource(struct adapter *padapter) } } - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED)) - { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED)) { rtw_disassoc_cmd(padapter, 0, false); /* s2-2. indicate disconnect to os */ rtw_indicate_disconnect(padapter); } - else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) - { + else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { rtw_sta_flush(padapter); } @@ -1327,13 +1306,12 @@ 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) == true) { DBG_871X_LEVEL(_drv_always_, "%s: fw_under_linking\n", __func__); rtw_indicate_disconnect(padapter); } - DBG_871X("<== "FUNC_ADPT_FMT" exit....\n", FUNC_ADPT_ARG(padapter)); + DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter)); return _SUCCESS; } @@ -1347,7 +1325,7 @@ int rtw_suspend_wow(struct adapter *padapter) struct wowlan_ioctl_param poidparam; int ret = _SUCCESS; - DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); + DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter)); DBG_871X("wowlan_mode: %d\n", pwrpriv->wowlan_mode); @@ -1379,8 +1357,7 @@ int rtw_suspend_wow(struct adapter *padapter) 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)) - { + && 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), @@ -1393,15 +1370,14 @@ int 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) == true) { DBG_871X_LEVEL(_drv_always_, "%s: fw_under_survey\n", __func__); rtw_indicate_scan_done(padapter, 1); clr_fwstate(pmlmepriv, _FW_UNDER_SURVEY); } if (rtw_get_ch_setting_union(padapter, &ch, &bw, &offset) != 0) { - DBG_871X(FUNC_ADPT_FMT" back to linked/linking union - ch:%u, bw:%u, offset:%u\n", + DBG_871X(FUNC_ADPT_FMT " back to linked/linking union - ch:%u, bw:%u, offset:%u\n", FUNC_ADPT_ARG(padapter), ch, bw, offset); set_channel_bwmode(padapter, ch, offset, bw); } @@ -1410,13 +1386,11 @@ int 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)); + DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter)); return ret; } #endif /* ifdef CONFIG_WOWLAN */ @@ -1430,7 +1404,7 @@ int rtw_suspend_ap_wow(struct adapter *padapter) struct wowlan_ioctl_param poidparam; int ret = _SUCCESS; - DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); + DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter)); pwrpriv->wowlan_ap_mode = true; @@ -1462,14 +1436,14 @@ int rtw_suspend_ap_wow(struct adapter *padapter) DBG_871X_LEVEL(_drv_always_, "%s: wowmode suspending\n", __func__); if (rtw_get_ch_setting_union(padapter, &ch, &bw, &offset) != 0) { - DBG_871X(FUNC_ADPT_FMT" back to linked/linking union - ch:%u, bw:%u, offset:%u\n", + DBG_871X(FUNC_ADPT_FMT " back to linked/linking union - ch:%u, bw:%u, offset:%u\n", FUNC_ADPT_ARG(padapter), ch, bw, offset); set_channel_bwmode(padapter, ch, offset, bw); } rtw_set_ps_mode(padapter, PS_MODE_MIN, 0, 0, "AP-WOWLAN"); - DBG_871X("<== "FUNC_ADPT_FMT" exit....\n", FUNC_ADPT_ARG(padapter)); + DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter)); return ret; } #endif /* ifdef CONFIG_AP_WOWLAN */ @@ -1480,7 +1454,7 @@ static int rtw_suspend_normal(struct adapter *padapter) struct net_device *pnetdev = padapter->pnetdev; int ret = _SUCCESS; - DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); + DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter)); if (pnetdev) { netif_carrier_off(pnetdev); rtw_netif_stop_queue(pnetdev); @@ -1489,10 +1463,8 @@ static int 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)) - { + || (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); @@ -1501,7 +1473,7 @@ static int rtw_suspend_normal(struct adapter *padapter) if (padapter->intf_deinit) padapter->intf_deinit(adapter_to_dvobj(padapter)); - DBG_871X("<== "FUNC_ADPT_FMT" exit....\n", FUNC_ADPT_ARG(padapter)); + DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter)); return ret; } @@ -1524,8 +1496,7 @@ int rtw_suspend_common(struct adapter *padapter) while (pwrpriv->bips_processing == true) msleep(1); - if ((!padapter->bup) || (padapter->bDriverStopped)||(padapter->bSurpriseRemoved)) - { + if ((!padapter->bup) || (padapter->bDriverStopped) || (padapter->bSurpriseRemoved)) { DBG_871X("%s bup =%d bDriverStopped =%d bSurpriseRemoved = %d\n", __func__ , padapter->bup, padapter->bDriverStopped, padapter->bSurpriseRemoved); pdbgpriv->dbg_suspend_error_cnt++; @@ -1599,7 +1570,7 @@ int rtw_resume_process_wow(struct adapter *padapter) struct sta_info *psta = NULL; int ret = _SUCCESS; - DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); + DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter)); if (padapter) { pnetdev = padapter->pnetdev; @@ -1641,7 +1612,7 @@ int rtw_resume_process_wow(struct adapter *padapter) } /* Disable WOW, set H2C command */ - poidparam.subcode =WOWLAN_DISABLE; + poidparam.subcode = WOWLAN_DISABLE; padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_WOWLAN, (u8 *)&poidparam); psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv)); @@ -1667,11 +1638,10 @@ int rtw_resume_process_wow(struct adapter *padapter) } } else { - DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR ### wowlan_mode =%d\n", __func__, pwrpriv->wowlan_mode); } - if (padapter->pid[1]!= 0) { + if (padapter->pid[1] != 0) { DBG_871X("pid[1]:%d\n", padapter->pid[1]); rtw_signal_process(padapter->pid[1], SIGUSR2); } @@ -1680,7 +1650,6 @@ int rtw_resume_process_wow(struct adapter *padapter) if (pwrpriv->wowlan_wake_reason == FWDecisionDisconnect || pwrpriv->wowlan_wake_reason == Rx_DisAssoc || pwrpriv->wowlan_wake_reason == Rx_DeAuth) { - DBG_871X("%s: disconnect reason: %02x\n", __func__, pwrpriv->wowlan_wake_reason); rtw_indicate_disconnect(padapter); @@ -1705,12 +1674,12 @@ int rtw_resume_process_wow(struct adapter *padapter) DBG_871X_LEVEL(_drv_always_, "do not reset timer\n"); } - pwrpriv->wowlan_mode =false; + pwrpriv->wowlan_mode = false; /* clean driver side wake up reason. */ pwrpriv->wowlan_wake_reason = 0; exit: - DBG_871X("<== "FUNC_ADPT_FMT" exit....\n", FUNC_ADPT_ARG(padapter)); + DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter)); return ret; } #endif /* ifdef CONFIG_WOWLAN */ @@ -1725,7 +1694,7 @@ int rtw_resume_process_ap_wow(struct adapter *padapter) struct wowlan_ioctl_param poidparam; int ret = _SUCCESS; - DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); + DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter)); if (padapter) { pnetdev = padapter->pnetdev; @@ -1774,7 +1743,7 @@ int rtw_resume_process_ap_wow(struct adapter *padapter) rtw_netif_wake_queue(pnetdev); } - if (padapter->pid[1]!= 0) { + if (padapter->pid[1] != 0) { DBG_871X("pid[1]:%d\n", padapter->pid[1]); rtw_signal_process(padapter->pid[1], SIGUSR2); } @@ -1785,7 +1754,7 @@ int rtw_resume_process_ap_wow(struct adapter *padapter) /* clean driver side wake up reason. */ pwrpriv->wowlan_wake_reason = 0; exit: - DBG_871X("<== "FUNC_ADPT_FMT" exit....\n", FUNC_ADPT_ARG(padapter)); + DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter)); return ret; } #endif /* ifdef CONFIG_APWOWLAN */ @@ -1811,19 +1780,17 @@ static int rtw_resume_process_normal(struct adapter *padapter) psdpriv = padapter->dvobj; pdbgpriv = &psdpriv->drv_dbg; - DBG_871X("==> "FUNC_ADPT_FMT" entry....\n", FUNC_ADPT_ARG(padapter)); + DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter)); /* interface init */ /* if (sdio_init(adapter_to_dvobj(padapter)) != _SUCCESS) */ - if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS)) - { + if ((padapter->intf_init) && (padapter->intf_init(adapter_to_dvobj(padapter)) != _SUCCESS)) { ret = -1; RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: initialize SDIO Failed!!\n", __func__)); goto exit; } rtw_hal_disable_interrupt(padapter); /* if (sdio_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS) */ - if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS)) - { + if ((padapter->intf_alloc_irq) && (padapter->intf_alloc_irq(adapter_to_dvobj(padapter)) != _SUCCESS)) { ret = -1; RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("%s: sdio_alloc_irq Failed!!\n", __func__)); goto exit; @@ -1842,28 +1809,28 @@ static int rtw_resume_process_normal(struct adapter *padapter) netif_device_attach(pnetdev); netif_carrier_on(pnetdev); - if (padapter->pid[1]!= 0) { + if (padapter->pid[1] != 0) { DBG_871X("pid[1]:%d\n", padapter->pid[1]); 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)); + DBG_871X(FUNC_ADPT_FMT " fwstate:0x%08x - WIFI_STATION_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv)); if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) rtw_roaming(padapter, NULL); } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - DBG_871X(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_AP_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv)); + DBG_871X(FUNC_ADPT_FMT " fwstate:0x%08x - WIFI_AP_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv)); rtw_ap_restore_network(padapter); } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { - DBG_871X(FUNC_ADPT_FMT" fwstate:0x%08x - WIFI_ADHOC_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv)); + DBG_871X(FUNC_ADPT_FMT " fwstate:0x%08x - WIFI_ADHOC_STATE\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv)); } else { - DBG_871X(FUNC_ADPT_FMT" fwstate:0x%08x - ???\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv)); + DBG_871X(FUNC_ADPT_FMT " fwstate:0x%08x - ???\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv)); } - DBG_871X("<== "FUNC_ADPT_FMT" exit....\n", FUNC_ADPT_ARG(padapter)); + DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter)); exit: return ret; diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c index a05daf06a870..9255cf73bdad 100644 --- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c @@ -30,22 +30,17 @@ inline int RTW_STATUS_CODE(int error_code) return _FAIL; } -u8 *_rtw_malloc(u32 sz) +void *_rtw_malloc(u32 sz) { - u8 *pbuf = NULL; - - pbuf = kmalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); - - return pbuf; + return kmalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); } -u8 *_rtw_zmalloc(u32 sz) +void *_rtw_zmalloc(u32 sz) { - u8 *pbuf = _rtw_malloc(sz); + void *pbuf = _rtw_malloc(sz); - if (pbuf != NULL) { + if (pbuf) memset(pbuf, 0, sz); - } return pbuf; } @@ -470,7 +465,7 @@ struct rtw_cbuf *rtw_cbuf_alloc(u32 size) { struct rtw_cbuf *cbuf; - cbuf = (struct rtw_cbuf *)rtw_malloc(sizeof(*cbuf) + sizeof(void*)*size); + cbuf = rtw_malloc(sizeof(*cbuf) + sizeof(void *) * size); if (cbuf) { cbuf->write = cbuf->read = 0; diff --git a/drivers/staging/rtlwifi/core.c b/drivers/staging/rtlwifi/core.c index d33847d0550d..b55e18304a60 100644 --- a/drivers/staging/rtlwifi/core.c +++ b/drivers/staging/rtlwifi/core.c @@ -49,43 +49,6 @@ u8 channel5g_80m[CHANNEL_MAX_NUMBER_5G_80M] = { 42, 58, 106, 122, 138, 155, 171 }; -void rtl_addr_delay(u32 addr) -{ - if (addr == 0xfe) - mdelay(50); - else if (addr == 0xfd) - msleep(5); - else if (addr == 0xfc) - msleep(1); - else if (addr == 0xfb) - usleep_range(50, 100); - else if (addr == 0xfa) - usleep_range(5, 10); - else if (addr == 0xf9) - usleep_range(1, 2); -} - -void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr, - u32 mask, u32 data) -{ - if (addr >= 0xf9 && addr <= 0xfe) { - rtl_addr_delay(addr); - } else { - rtl_set_rfreg(hw, rfpath, addr, mask, data); - udelay(1); - } -} - -void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data) -{ - if (addr >= 0xf9 && addr <= 0xfe) { - rtl_addr_delay(addr); - } else { - rtl_set_bbreg(hw, addr, MASKDWORD, data); - udelay(1); - } -} - static void rtl_fw_do_work(const struct firmware *firmware, void *context, bool is_wow) { @@ -449,7 +412,8 @@ static void _rtl_add_wowlan_patterns(struct ieee80211_hw *hw, for (i = 0; i < wow->n_patterns; i++) { memset(&rtl_pattern, 0, sizeof(struct rtl_wow_pattern)); memset(mask, 0, MAX_WOL_BIT_MASK_SIZE); - if (patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) { + if (patterns[i].pattern_len < 0 || + patterns[i].pattern_len > MAX_WOL_PATTERN_SIZE) { RT_TRACE(rtlpriv, COMP_POWER, DBG_WARNING, "Pattern[%d] is too long\n", i); continue; @@ -1160,7 +1124,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, if (rtlpriv->dm.supp_phymode_switch) { if (sta->ht_cap.ht_supported) rtl_send_smps_action(hw, sta, - IEEE80211_SMPS_STATIC); + IEEE80211_SMPS_STATIC); } if (rtlhal->current_bandtype == BAND_ON_5G) { @@ -1224,7 +1188,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw, cfg80211_unlink_bss(hw->wiphy, bss); cfg80211_put_bss(hw->wiphy, bss); RT_TRACE(rtlpriv, COMP_MAC80211, DBG_DMESG, - "cfg80211_unlink !!\n"); + "cfg80211_unlink !!\n"); } eth_zero_addr(mac->bssid); @@ -1885,7 +1849,7 @@ bool rtl_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, u8 cut_version, break; case PWR_CMD_WRITE: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, - "%s(): PWR_CMD_WRITE\n", __func__); + "%s(): PWR_CMD_WRITE\n", __func__); offset = GET_PWR_CFG_OFFSET(cfg_cmd); /*Read the value from system register*/ diff --git a/drivers/staging/rtlwifi/core.h b/drivers/staging/rtlwifi/core.h index 782ac2fc4b28..4c2b69412621 100644 --- a/drivers/staging/rtlwifi/core.h +++ b/drivers/staging/rtlwifi/core.h @@ -75,10 +75,6 @@ enum dm_dig_connect_e { extern const struct ieee80211_ops rtl_ops; void rtl_fw_cb(const struct firmware *firmware, void *context); void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context); -void rtl_addr_delay(u32 addr); -void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr, - u32 mask, u32 data); -void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data); bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb); bool rtl_btc_status_false(void); void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igval); diff --git a/drivers/staging/rtlwifi/debug.c b/drivers/staging/rtlwifi/debug.c index 7446d71c41d1..63a9b70ec60f 100644 --- a/drivers/staging/rtlwifi/debug.c +++ b/drivers/staging/rtlwifi/debug.c @@ -127,10 +127,10 @@ static int rtl_debug_get_mac_page(struct seq_file *m, void *v) return 0; } -#define RTL_DEBUG_IMPL_MAC_SERIES(page, addr) \ -struct rtl_debugfs_priv rtl_debug_priv_mac_ ##page = { \ - .cb_read = rtl_debug_get_mac_page, \ - .cb_data = addr, \ +#define RTL_DEBUG_IMPL_MAC_SERIES(page, addr) \ +static struct rtl_debugfs_priv rtl_debug_priv_mac_ ##page = { \ + .cb_read = rtl_debug_get_mac_page, \ + .cb_data = addr, \ } RTL_DEBUG_IMPL_MAC_SERIES(0, 0x0000); @@ -169,10 +169,10 @@ static int rtl_debug_get_bb_page(struct seq_file *m, void *v) return 0; } -#define RTL_DEBUG_IMPL_BB_SERIES(page, addr) \ -struct rtl_debugfs_priv rtl_debug_priv_bb_ ##page = { \ - .cb_read = rtl_debug_get_bb_page, \ - .cb_data = addr, \ +#define RTL_DEBUG_IMPL_BB_SERIES(page, addr) \ +static struct rtl_debugfs_priv rtl_debug_priv_bb_ ##page = { \ + .cb_read = rtl_debug_get_bb_page, \ + .cb_data = addr, \ } RTL_DEBUG_IMPL_BB_SERIES(8, 0x0800); @@ -216,10 +216,10 @@ static int rtl_debug_get_reg_rf(struct seq_file *m, void *v) return 0; } -#define RTL_DEBUG_IMPL_RF_SERIES(page, addr) \ -struct rtl_debugfs_priv rtl_debug_priv_rf_ ##page = { \ - .cb_read = rtl_debug_get_reg_rf, \ - .cb_data = addr, \ +#define RTL_DEBUG_IMPL_RF_SERIES(page, addr) \ +static struct rtl_debugfs_priv rtl_debug_priv_rf_ ##page = { \ + .cb_read = rtl_debug_get_reg_rf, \ + .cb_data = addr, \ } RTL_DEBUG_IMPL_RF_SERIES(a, RF90_PATH_A); @@ -271,10 +271,10 @@ static int rtl_debug_get_cam_register(struct seq_file *m, void *v) return 0; } -#define RTL_DEBUG_IMPL_CAM_SERIES(page, addr) \ -struct rtl_debugfs_priv rtl_debug_priv_cam_ ##page = { \ - .cb_read = rtl_debug_get_cam_register, \ - .cb_data = addr, \ +#define RTL_DEBUG_IMPL_CAM_SERIES(page, addr) \ +static struct rtl_debugfs_priv rtl_debug_priv_cam_ ##page = { \ + .cb_read = rtl_debug_get_cam_register, \ + .cb_data = addr, \ } RTL_DEBUG_IMPL_CAM_SERIES(1, 0); diff --git a/drivers/staging/rtlwifi/efuse.c b/drivers/staging/rtlwifi/efuse.c index 6d5e657017c6..d74c80d512c9 100644 --- a/drivers/staging/rtlwifi/efuse.c +++ b/drivers/staging/rtlwifi/efuse.c @@ -252,12 +252,11 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) sizeof(u8), GFP_ATOMIC); if (!efuse_tbl) return; - efuse_word = kzalloc(EFUSE_MAX_WORD_UNIT * sizeof(u16 *), GFP_ATOMIC); + efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC); if (!efuse_word) goto out; for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { - efuse_word[i] = kzalloc(efuse_max_section * sizeof(u16), - GFP_ATOMIC); + efuse_word[i] = kcalloc(efuse_max_section, sizeof(u16), GFP_ATOMIC); if (!efuse_word[i]) goto done; } diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c index 544f638ed3ef..c4cb217d3d1f 100644 --- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c +++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c @@ -276,17 +276,13 @@ halmac_dump_efuse_drv_88xx(struct halmac_adapter *halmac_adapter) if (!halmac_adapter->hal_efuse_map) { halmac_adapter->hal_efuse_map = kzalloc(efuse_size, GFP_KERNEL); - if (!halmac_adapter->hal_efuse_map) { - pr_err("[ERR]halmac allocate efuse map Fail!!\n"); + if (!halmac_adapter->hal_efuse_map) return HALMAC_RET_MALLOC_FAIL; - } } efuse_map = kzalloc(efuse_size, GFP_KERNEL); - if (!efuse_map) { - /* out of memory */ + if (!efuse_map) return HALMAC_RET_MALLOC_FAIL; - } if (halmac_read_hw_efuse_88xx(halmac_adapter, 0, efuse_size, efuse_map) != HALMAC_RET_SUCCESS) { @@ -325,10 +321,8 @@ halmac_dump_efuse_fw_88xx(struct halmac_adapter *halmac_adapter) if (!halmac_adapter->hal_efuse_map) { halmac_adapter->hal_efuse_map = kzalloc( halmac_adapter->hw_config_info.efuse_size, GFP_KERNEL); - if (!halmac_adapter->hal_efuse_map) { - /* out of memory */ + if (!halmac_adapter->hal_efuse_map) return HALMAC_RET_MALLOC_FAIL; - } } if (!halmac_adapter->hal_efuse_map_valid) { @@ -537,10 +531,8 @@ halmac_read_logical_efuse_map_88xx(struct halmac_adapter *halmac_adapter, if (!halmac_adapter->hal_efuse_map_valid) { efuse_map = kzalloc(efuse_size, GFP_KERNEL); - if (!efuse_map) { - pr_err("[ERR]halmac allocate local efuse map Fail!!\n"); + if (!efuse_map) return HALMAC_RET_MALLOC_FAIL; - } status = halmac_func_read_efuse_88xx(halmac_adapter, 0, efuse_size, efuse_map); @@ -554,7 +546,6 @@ halmac_read_logical_efuse_map_88xx(struct halmac_adapter *halmac_adapter, halmac_adapter->hal_efuse_map = kzalloc(efuse_size, GFP_KERNEL); if (!halmac_adapter->hal_efuse_map) { - pr_err("[ERR]halmac allocate efuse map Fail!!\n"); kfree(efuse_map); return HALMAC_RET_MALLOC_FAIL; } @@ -592,10 +583,8 @@ halmac_func_write_logical_efuse_88xx(struct halmac_adapter *halmac_adapter, driver_adapter = halmac_adapter->driver_adapter; eeprom_map = kzalloc(eeprom_size, GFP_KERNEL); - if (!eeprom_map) { - /* out of memory */ + if (!eeprom_map) return HALMAC_RET_MALLOC_FAIL; - } memset(eeprom_map, 0xFF, eeprom_size); status = halmac_read_logical_efuse_map_88xx(halmac_adapter, eeprom_map); @@ -687,10 +676,8 @@ halmac_func_pg_efuse_by_map_88xx(struct halmac_adapter *halmac_adapter, enum halmac_ret_status status = HALMAC_RET_SUCCESS; eeprom_mask_updated = kzalloc(eeprom_mask_size, GFP_KERNEL); - if (!eeprom_mask_updated) { - /* out of memory */ + if (!eeprom_mask_updated) return HALMAC_RET_MALLOC_FAIL; - } status = halmac_update_eeprom_mask_88xx(halmac_adapter, pg_efuse_info, eeprom_mask_updated); @@ -743,12 +730,10 @@ halmac_update_eeprom_mask_88xx(struct halmac_adapter *halmac_adapter, driver_adapter = halmac_adapter->driver_adapter; eeprom_map = kzalloc(eeprom_size, GFP_KERNEL); - if (!eeprom_map) { - /* out of memory */ + if (!eeprom_map) return HALMAC_RET_MALLOC_FAIL; - } - memset(eeprom_map, 0xFF, eeprom_size); + memset(eeprom_map, 0xFF, eeprom_size); memset(eeprom_mask_updated, 0x00, pg_efuse_info->efuse_mask_size); status = halmac_read_logical_efuse_map_88xx(halmac_adapter, eeprom_map); @@ -1036,7 +1021,7 @@ halmac_dlfw_to_mem_88xx(struct halmac_adapter *halmac_adapter, u8 *ram_code, if (halmac_send_fwpkt_88xx( halmac_adapter, code_ptr + mem_offset, send_pkt_size) != HALMAC_RET_SUCCESS) { - pr_err("halmac_send_fwpkt_88xx fail!!"); + pr_err("halmac_send_fwpkt_88xx fail!!\n"); return HALMAC_RET_DLFW_FAIL; } @@ -1046,7 +1031,7 @@ halmac_dlfw_to_mem_88xx(struct halmac_adapter *halmac_adapter, u8 *ram_code, halmac_adapter->hw_config_info.txdesc_size, dest + mem_offset, send_pkt_size, first_part) != HALMAC_RET_SUCCESS) { - pr_err("halmac_iddma_dlfw_88xx fail!!"); + pr_err("halmac_iddma_dlfw_88xx fail!!\n"); return HALMAC_RET_DLFW_FAIL; } @@ -1057,7 +1042,7 @@ halmac_dlfw_to_mem_88xx(struct halmac_adapter *halmac_adapter, u8 *ram_code, if (halmac_check_fw_chksum_88xx(halmac_adapter, dest) != HALMAC_RET_SUCCESS) { - pr_err("halmac_check_fw_chksum_88xx fail!!"); + pr_err("halmac_check_fw_chksum_88xx fail!!\n"); return HALMAC_RET_DLFW_FAIL; } @@ -2549,10 +2534,8 @@ halmac_parse_efuse_data_88xx(struct halmac_adapter *halmac_adapter, u8 *c2h_buf, halmac_adapter->efuse_segment_size = segment_size; eeprom_map = kzalloc(eeprom_size, GFP_KERNEL); - if (!eeprom_map) { - /* out of memory */ + if (!eeprom_map) return HALMAC_RET_MALLOC_FAIL; - } memset(eeprom_map, 0xFF, eeprom_size); spin_lock(&halmac_adapter->efuse_lock); @@ -3355,10 +3338,8 @@ enum halmac_ret_status halmac_query_dump_logical_efuse_status_88xx( *size = eeprom_size; eeprom_map = kzalloc(eeprom_size, GFP_KERNEL); - if (!eeprom_map) { - /* out of memory */ + if (!eeprom_map) return HALMAC_RET_MALLOC_FAIL; - } memset(eeprom_map, 0xFF, eeprom_size); if (halmac_eeprom_parser_88xx( @@ -3579,10 +3560,8 @@ halmac_verify_send_rsvd_page_88xx(struct halmac_adapter *halmac_adapter) rsvd_buf = kzalloc(h2c_pkt_verify_size, GFP_KERNEL); - if (!rsvd_buf) { - /*pr_err("[ERR]rsvd buffer malloc fail!!\n");*/ + if (!rsvd_buf) return HALMAC_RET_MALLOC_FAIL; - } memset(rsvd_buf, (u8)h2c_pkt_verify_payload, h2c_pkt_verify_size); @@ -3599,7 +3578,6 @@ halmac_verify_send_rsvd_page_88xx(struct halmac_adapter *halmac_adapter) GFP_KERNEL); if (!rsvd_page) { - pr_err("[ERR]rsvd page malloc fail!!\n"); kfree(rsvd_buf); return HALMAC_RET_MALLOC_FAIL; } diff --git a/drivers/staging/rtlwifi/phydm/phydm_debug.c b/drivers/staging/rtlwifi/phydm/phydm_debug.c index a5f90afdae9b..d4dd0fd3d1c7 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_debug.c +++ b/drivers/staging/rtlwifi/phydm/phydm_debug.c @@ -29,6 +29,7 @@ #include "mp_precomp.h" #include "phydm_precomp.h" +#include <linux/kernel.h> bool phydm_api_set_txagc(struct phy_dm_struct *, u32, enum odm_rf_radio_path, u8, bool); @@ -2107,8 +2108,7 @@ void phydm_cmd_parser(struct phy_dm_struct *dm, char input[][MAX_ARGV], /* Parsing Cmd ID */ if (input_num) { - phydm_ary_size = - sizeof(phy_dm_ary) / sizeof(struct phydm_command); + phydm_ary_size = ARRAY_SIZE(phy_dm_ary); for (i = 0; i < phydm_ary_size; i++) { if (strcmp(phy_dm_ary[i].name, input[0]) == 0) { id = phy_dm_ary[i].id; diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c index 4e7946019fcb..29d19f2b300e 100644 --- a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c +++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_bb.c @@ -26,6 +26,7 @@ /*Image2HeaderVersion: 3.2*/ #include "../mp_precomp.h" #include "../phydm_precomp.h" +#include <linux/kernel.h> static bool check_positive(struct phy_dm_struct *dm, const u32 condition1, const u32 condition2, const u32 condition3, @@ -1350,7 +1351,6 @@ void odm_read_and_config_mp_8822b_agc_tab(struct phy_dm_struct *dm) u32 i = 0; u8 c_cond; bool is_matched = true, is_skipped = false; - u32 array_len = sizeof(array_mp_8822b_agc_tab) / sizeof(u32); u32 *array = array_mp_8822b_agc_tab; u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0; @@ -1358,7 +1358,7 @@ void odm_read_and_config_mp_8822b_agc_tab(struct phy_dm_struct *dm) ODM_RT_TRACE(dm, ODM_COMP_INIT, "===> %s\n", __func__); - for (; (i + 1) < array_len; i = i + 2) { + for (; (i + 1) < ARRAY_SIZE(array_mp_8822b_agc_tab); i = i + 2) { v1 = array[i]; v2 = array[i + 1]; @@ -1843,7 +1843,6 @@ void odm_read_and_config_mp_8822b_phy_reg(struct phy_dm_struct *dm) u32 i = 0; u8 c_cond; bool is_matched = true, is_skipped = false; - u32 array_len = sizeof(array_mp_8822b_phy_reg) / sizeof(u32); u32 *array = array_mp_8822b_phy_reg; u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0; @@ -1851,7 +1850,7 @@ void odm_read_and_config_mp_8822b_phy_reg(struct phy_dm_struct *dm) ODM_RT_TRACE(dm, ODM_COMP_INIT, "===> %s\n", __func__); - for (; (i + 1) < array_len; i = i + 2) { + for (; (i + 1) < ARRAY_SIZE(array_mp_8822b_phy_reg); i = i + 2) { v1 = array[i]; v2 = array[i + 1]; @@ -1947,7 +1946,6 @@ static u32 array_mp_8822b_phy_reg_pg[] = { void odm_read_and_config_mp_8822b_phy_reg_pg(struct phy_dm_struct *dm) { u32 i = 0; - u32 array_len = sizeof(array_mp_8822b_phy_reg_pg) / sizeof(u32); u32 *array = array_mp_8822b_phy_reg_pg; ODM_RT_TRACE(dm, ODM_COMP_INIT, @@ -1956,7 +1954,7 @@ void odm_read_and_config_mp_8822b_phy_reg_pg(struct phy_dm_struct *dm) dm->phy_reg_pg_version = 1; dm->phy_reg_pg_value_type = PHY_REG_PG_EXACT_VALUE; - for (i = 0; i < array_len; i += 6) { + for (i = 0; i < ARRAY_SIZE(array_mp_8822b_phy_reg_pg); i += 6) { u32 v1 = array[i]; u32 v2 = array[i + 1]; u32 v3 = array[i + 2]; diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c index 1a9daed2e609..70924f002541 100644 --- a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c +++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_mac.c @@ -26,6 +26,7 @@ /*Image2HeaderVersion: 3.2*/ #include "../mp_precomp.h" #include "../phydm_precomp.h" +#include <linux/kernel.h> static bool check_positive(struct phy_dm_struct *dm, const u32 condition1, const u32 condition2, const u32 condition3, @@ -173,7 +174,6 @@ void odm_read_and_config_mp_8822b_mac_reg(struct phy_dm_struct *dm) u32 i = 0; u8 c_cond; bool is_matched = true, is_skipped = false; - u32 array_len = sizeof(array_mp_8822b_mac_reg) / sizeof(u32); u32 *array = array_mp_8822b_mac_reg; u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0; @@ -181,7 +181,7 @@ void odm_read_and_config_mp_8822b_mac_reg(struct phy_dm_struct *dm) ODM_RT_TRACE(dm, ODM_COMP_INIT, "===> %s\n", __func__); - for (; (i + 1) < array_len; i = i + 2) { + for (; (i + 1) < ARRAY_SIZE(array_mp_8822b_mac_reg); i = i + 2) { v1 = array[i]; v2 = array[i + 1]; diff --git a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c index 84cdc0644207..0ff3a9a712d6 100644 --- a/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c +++ b/drivers/staging/rtlwifi/phydm/rtl8822b/halhwimg8822b_rf.c @@ -26,6 +26,7 @@ /*Image2HeaderVersion: 3.2*/ #include "../mp_precomp.h" #include "../phydm_precomp.h" +#include <linux/kernel.h> static bool check_positive(struct phy_dm_struct *dm, const u32 condition1, const u32 condition2, const u32 condition3, @@ -1346,7 +1347,6 @@ void odm_read_and_config_mp_8822b_radioa(struct phy_dm_struct *dm) u32 i = 0; u8 c_cond; bool is_matched = true, is_skipped = false; - u32 array_len = sizeof(array_mp_8822b_radioa) / sizeof(u32); u32 *array = array_mp_8822b_radioa; u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0; @@ -1354,7 +1354,7 @@ void odm_read_and_config_mp_8822b_radioa(struct phy_dm_struct *dm) ODM_RT_TRACE(dm, ODM_COMP_INIT, "===> %s\n", __func__); - for (; (i + 1) < array_len; i = i + 2) { + for (; (i + 1) < ARRAY_SIZE(array_mp_8822b_radioa); i = i + 2) { v1 = array[i]; v2 = array[i + 1]; @@ -2506,7 +2506,6 @@ void odm_read_and_config_mp_8822b_radiob(struct phy_dm_struct *dm) u32 i = 0; u8 c_cond; bool is_matched = true, is_skipped = false; - u32 array_len = sizeof(array_mp_8822b_radiob) / sizeof(u32); u32 *array = array_mp_8822b_radiob; u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0; @@ -2514,7 +2513,7 @@ void odm_read_and_config_mp_8822b_radiob(struct phy_dm_struct *dm) ODM_RT_TRACE(dm, ODM_COMP_INIT, "===> %s\n", __func__); - for (; (i + 1) < array_len; i = i + 2) { + for (; (i + 1) < ARRAY_SIZE(array_mp_8822b_radiob); i = i + 2) { v1 = array[i]; v2 = array[i + 1]; @@ -4239,13 +4238,12 @@ static const char *const array_mp_8822b_txpwr_lmt[] = { void odm_read_and_config_mp_8822b_txpwr_lmt(struct phy_dm_struct *dm) { u32 i = 0; - u32 array_len = sizeof(array_mp_8822b_txpwr_lmt) / sizeof(u8 *); u8 **array = (u8 **)array_mp_8822b_txpwr_lmt; ODM_RT_TRACE(dm, ODM_COMP_INIT, "===> %s\n", __func__); - for (i = 0; i < array_len; i += 7) { + for (i = 0; i < ARRAY_SIZE(array_mp_8822b_txpwr_lmt); i += 7) { u8 *regulation = array[i]; u8 *band = array[i + 1]; u8 *bandwidth = array[i + 2]; @@ -4723,13 +4721,12 @@ static const char *const array_mp_8822b_txpwr_lmt_type5[] = { void odm_read_and_config_mp_8822b_txpwr_lmt_type5(struct phy_dm_struct *dm) { u32 i = 0; - u32 array_len = sizeof(array_mp_8822b_txpwr_lmt_type5) / sizeof(u8 *); u8 **array = (u8 **)array_mp_8822b_txpwr_lmt_type5; ODM_RT_TRACE(dm, ODM_COMP_INIT, "===> odm_read_and_config_mp_8822b_txpwr_lmt_type5\n"); - for (i = 0; i < array_len; i += 7) { + for (i = 0; i < ARRAY_SIZE(array_mp_8822b_txpwr_lmt_type5); i += 7) { u8 *regulation = array[i]; u8 *band = array[i + 1]; u8 *bandwidth = array[i + 2]; diff --git a/drivers/staging/rtlwifi/rc.c b/drivers/staging/rtlwifi/rc.c index 65de0c7b5a67..779a5c6987a5 100644 --- a/drivers/staging/rtlwifi/rc.c +++ b/drivers/staging/rtlwifi/rc.c @@ -281,10 +281,8 @@ static void *rtl_rate_alloc_sta(void *ppriv, struct rtl_rate_priv *rate_priv; rate_priv = kzalloc(sizeof(*rate_priv), gfp); - if (!rate_priv) { - pr_err("Unable to allocate private rc structure\n"); + if (!rate_priv) return NULL; - } rtlpriv->rate_priv = rate_priv; diff --git a/drivers/staging/rtlwifi/rtl8822be/phy.c b/drivers/staging/rtlwifi/rtl8822be/phy.c index 4cba2adc3165..921226bd687b 100644 --- a/drivers/staging/rtlwifi/rtl8822be/phy.c +++ b/drivers/staging/rtlwifi/rtl8822be/phy.c @@ -890,7 +890,7 @@ bool rtl8822be_load_txpower_by_rate(struct ieee80211_hw *hw) rtstatus = rtlpriv->phydm.ops->phydm_load_txpower_by_rate(rtlpriv); if (!rtstatus) { - pr_err("BB_PG Reg Fail!!"); + pr_err("BB_PG Reg Fail!!\n"); return false; } @@ -915,7 +915,7 @@ bool rtl8822be_load_txpower_limit(struct ieee80211_hw *hw) rtstatus = rtlpriv->phydm.ops->phydm_load_txpower_limit(rtlpriv); if (!rtstatus) { - pr_err("RF TxPwr Limit Fail!!"); + pr_err("RF TxPwr Limit Fail!!\n"); return false; } diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c index 4033a2cf7ac9..d548bc695f9e 100644 --- a/drivers/staging/rts5208/sd.c +++ b/drivers/staging/rts5208/sd.c @@ -4125,12 +4125,6 @@ RTY_SEND_CMD: rtsx_trace(chip); return STATUS_FAIL; } - - } else if (rsp_type == SD_RSP_TYPE_R0) { - if ((ptr[3] & 0x1E) != 0x03) { - rtsx_trace(chip); - return STATUS_FAIL; - } } } } diff --git a/drivers/staging/sm750fb/ddk750_dvi.c b/drivers/staging/sm750fb/ddk750_dvi.c index 87a199d6cdaf..6ecdcf0afd14 100644 --- a/drivers/staging/sm750fb/ddk750_dvi.c +++ b/drivers/staging/sm750fb/ddk750_dvi.c @@ -10,7 +10,7 @@ * function API. Please set the function pointer to NULL whenever the function * is not supported. */ -static dvi_ctrl_device_t g_dcftSupportedDviController[] = { +static struct dvi_ctrl_device g_dcftSupportedDviController[] = { #ifdef DVI_CTRL_SII164 { .pfnInit = sii164InitChip, @@ -40,7 +40,7 @@ int dviInit(unsigned char edgeSelect, unsigned char pllFilterEnable, unsigned char pllFilterValue) { - dvi_ctrl_device_t *pCurrentDviCtrl; + struct dvi_ctrl_device *pCurrentDviCtrl; pCurrentDviCtrl = g_dcftSupportedDviController; if (pCurrentDviCtrl->pfnInit) { diff --git a/drivers/staging/sm750fb/ddk750_dvi.h b/drivers/staging/sm750fb/ddk750_dvi.h index 4a8394561f76..692888ceee40 100644 --- a/drivers/staging/sm750fb/ddk750_dvi.h +++ b/drivers/staging/sm750fb/ddk750_dvi.h @@ -25,7 +25,7 @@ typedef unsigned char (*PFN_DVICTRL_CHECKINTERRUPT)(void); typedef void (*PFN_DVICTRL_CLEARINTERRUPT)(void); /* Structure to hold all the function pointer to the DVI Controller. */ -typedef struct _dvi_ctrl_device_t { +struct dvi_ctrl_device { PFN_DVICTRL_INIT pfnInit; PFN_DVICTRL_RESETCHIP pfnResetChip; PFN_DVICTRL_GETCHIPSTRING pfnGetChipString; @@ -36,7 +36,7 @@ typedef struct _dvi_ctrl_device_t { PFN_DVICTRL_ISCONNECTED pfnIsConnected; PFN_DVICTRL_CHECKINTERRUPT pfnCheckInterrupt; PFN_DVICTRL_CLEARINTERRUPT pfnClearInterrupt; -} dvi_ctrl_device_t; +}; #define DVI_CTRL_SII164 diff --git a/drivers/staging/sm750fb/ddk750_power.c b/drivers/staging/sm750fb/ddk750_power.c index 222ae1a06feb..6f82ab05fdb6 100644 --- a/drivers/staging/sm750fb/ddk750_power.c +++ b/drivers/staging/sm750fb/ddk750_power.c @@ -2,7 +2,7 @@ #include "ddk750_reg.h" #include "ddk750_power.h" -void ddk750_set_dpms(DPMS_t state) +void ddk750_set_dpms(enum dpms state) { unsigned int value; diff --git a/drivers/staging/sm750fb/ddk750_power.h b/drivers/staging/sm750fb/ddk750_power.h index 44c4fc587e96..033889f63920 100644 --- a/drivers/staging/sm750fb/ddk750_power.h +++ b/drivers/staging/sm750fb/ddk750_power.h @@ -1,20 +1,19 @@ #ifndef DDK750_POWER_H__ #define DDK750_POWER_H__ -typedef enum _DPMS_t { +enum dpms { crtDPMS_ON = 0x0, crtDPMS_STANDBY = 0x1, crtDPMS_SUSPEND = 0x2, crtDPMS_OFF = 0x3, -} -DPMS_t; +}; #define setDAC(off) { \ poke32(MISC_CTRL, \ (peek32(MISC_CTRL) & ~MISC_CTRL_DAC_POWER_OFF) | (off)); \ } -void ddk750_set_dpms(DPMS_t state); +void ddk750_set_dpms(enum dpms state); void sm750_set_power_mode(unsigned int powerMode); void sm750_set_current_gate(unsigned int gate); diff --git a/drivers/staging/sm750fb/ddk750_sii164.c b/drivers/staging/sm750fb/ddk750_sii164.c index 0431833de781..3d68e1d00cb1 100644 --- a/drivers/staging/sm750fb/ddk750_sii164.c +++ b/drivers/staging/sm750fb/ddk750_sii164.c @@ -296,7 +296,8 @@ void sii164SetPower(unsigned char powerUp) * sii164SelectHotPlugDetectionMode * This function selects the mode of the hot plug detection. */ -static void sii164SelectHotPlugDetectionMode(sii164_hot_plug_mode_t hotPlugMode) +static +void sii164SelectHotPlugDetectionMode(enum sii164_hot_plug_mode hotPlugMode) { unsigned char detectReg; diff --git a/drivers/staging/sm750fb/ddk750_sii164.h b/drivers/staging/sm750fb/ddk750_sii164.h index 6968cf532f16..e06ba729b4e2 100644 --- a/drivers/staging/sm750fb/ddk750_sii164.h +++ b/drivers/staging/sm750fb/ddk750_sii164.h @@ -4,12 +4,12 @@ #define USE_DVICHIP /* Hot Plug detection mode structure */ -typedef enum _sii164_hot_plug_mode_t { +enum sii164_hot_plug_mode { SII164_HOTPLUG_DISABLE = 0, /* Disable Hot Plug output bit (always high). */ SII164_HOTPLUG_USE_MDI, /* Use Monitor Detect Interrupt bit. */ SII164_HOTPLUG_USE_RSEN, /* Use Receiver Sense detect bit. */ SII164_HOTPLUG_USE_HTPLG /* Use Hot Plug detect bit. */ -} sii164_hot_plug_mode_t; +}; /* Silicon Image SiI164 chip prototype */ diff --git a/drivers/staging/sm750fb/sm750_cursor.c b/drivers/staging/sm750fb/sm750_cursor.c index aa47a16ac75c..6b27b061d4cf 100644 --- a/drivers/staging/sm750fb/sm750_cursor.c +++ b/drivers/staging/sm750fb/sm750_cursor.c @@ -18,8 +18,6 @@ #include "sm750.h" #include "sm750_cursor.h" - - #define poke32(addr, data) \ writel((data), cursor->mmio + (addr)) @@ -45,7 +43,6 @@ writel((data), cursor->mmio + (addr)) #define HWC_COLOR_3 0xC #define HWC_COLOR_3_RGB565_MASK 0xffff - /* hw_cursor_xxx works for voyager,718 and 750 */ void sm750_hw_cursor_enable(struct lynx_cursor *cursor) { @@ -134,7 +131,6 @@ void sm750_hw_cursor_setData(struct lynx_cursor *cursor, u16 rop, } } - void sm750_hw_cursor_setData2(struct lynx_cursor *cursor, u16 rop, const u8 *pcol, const u8 *pmsk) { diff --git a/drivers/staging/speakup/buffers.c b/drivers/staging/speakup/buffers.c index f459e4004bfa..6137fa83c609 100644 --- a/drivers/staging/speakup/buffers.c +++ b/drivers/staging/speakup/buffers.c @@ -27,7 +27,7 @@ void speakup_start_ttys(void) 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)) + if (vc_cons[i].d && vc_cons[i].d->port.tty) start_tty(vc_cons[i].d->port.tty); } } @@ -38,7 +38,7 @@ 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))) + if (vc_cons[i].d && vc_cons[i].d->port.tty) stop_tty(vc_cons[i].d->port.tty); } diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c index 56f7be6af1f6..3809cd2ad838 100644 --- a/drivers/staging/speakup/main.c +++ b/drivers/staging/speakup/main.c @@ -447,7 +447,7 @@ static void speak_char(u16 ch) cp = spk_characters[ch]; if (!cp) { - pr_info("speak_char: cp == NULL!\n"); + pr_info("%s: cp == NULL!\n", __func__); return; } if (IS_CHAR(ch, B_CAP)) { @@ -2101,7 +2101,7 @@ speakup_key(struct vc_data *vc, int shift_state, int keycode, u_short keysym, u_char shift_info, offset; int ret = 0; - if (synth == NULL) + if (!synth) return 0; spin_lock_irqsave(&speakup_info.spinlock, flags); diff --git a/drivers/staging/speakup/speakup_acntsa.c b/drivers/staging/speakup/speakup_acntsa.c index 0e10404e2e8c..43315849b7b6 100644 --- a/drivers/staging/speakup/speakup_acntsa.c +++ b/drivers/staging/speakup/speakup_acntsa.c @@ -136,7 +136,7 @@ static int synth_probe(struct spk_synth *synth) } module_param_named(ser, synth_acntsa.ser, int, 0444); -module_param_named(dev, synth_acntsa.dev_name, charp, S_IRUGO); +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)."); diff --git a/drivers/staging/speakup/speakup_apollo.c b/drivers/staging/speakup/speakup_apollo.c index 2edb56c8a559..dcf0c3b59fdd 100644 --- a/drivers/staging/speakup/speakup_apollo.c +++ b/drivers/staging/speakup/speakup_apollo.c @@ -200,7 +200,7 @@ static void do_catch_up(struct spk_synth *synth) } module_param_named(ser, synth_apollo.ser, int, 0444); -module_param_named(dev, synth_apollo.dev_name, charp, S_IRUGO); +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)."); diff --git a/drivers/staging/speakup/speakup_audptr.c b/drivers/staging/speakup/speakup_audptr.c index 8ae826eba71c..45b5721441ba 100644 --- a/drivers/staging/speakup/speakup_audptr.c +++ b/drivers/staging/speakup/speakup_audptr.c @@ -163,7 +163,7 @@ static int synth_probe(struct spk_synth *synth) } module_param_named(ser, synth_audptr.ser, int, 0444); -module_param_named(dev, synth_audptr.dev_name, charp, S_IRUGO); +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)."); diff --git a/drivers/staging/speakup/speakup_bns.c b/drivers/staging/speakup/speakup_bns.c index 60bcf0df8123..402b0fbfb94d 100644 --- a/drivers/staging/speakup/speakup_bns.c +++ b/drivers/staging/speakup/speakup_bns.c @@ -120,7 +120,7 @@ static struct spk_synth synth_bns = { }; module_param_named(ser, synth_bns.ser, int, 0444); -module_param_named(dev, synth_bns.dev_name, charp, S_IRUGO); +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)."); diff --git a/drivers/staging/speakup/speakup_decext.c b/drivers/staging/speakup/speakup_decext.c index 95f4b2116d0c..4310c2c276c4 100644 --- a/drivers/staging/speakup/speakup_decext.c +++ b/drivers/staging/speakup/speakup_decext.c @@ -227,7 +227,7 @@ static void synth_flush(struct spk_synth *synth) } module_param_named(ser, synth_decext.ser, int, 0444); -module_param_named(dev, synth_decext.dev_name, charp, S_IRUGO); +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)."); diff --git a/drivers/staging/speakup/speakup_dectlk.c b/drivers/staging/speakup/speakup_dectlk.c index f06995480022..5d6a861c9b1e 100644 --- a/drivers/staging/speakup/speakup_dectlk.c +++ b/drivers/staging/speakup/speakup_dectlk.c @@ -299,7 +299,7 @@ static void synth_flush(struct spk_synth *synth) } module_param_named(ser, synth_dectlk.ser, int, 0444); -module_param_named(dev, synth_dectlk.dev_name, charp, S_IRUGO); +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)."); diff --git a/drivers/staging/speakup/speakup_dummy.c b/drivers/staging/speakup/speakup_dummy.c index 851953d5eefb..ea3b2911cab9 100644 --- a/drivers/staging/speakup/speakup_dummy.c +++ b/drivers/staging/speakup/speakup_dummy.c @@ -122,7 +122,7 @@ static struct spk_synth synth_dummy = { }; module_param_named(ser, synth_dummy.ser, int, 0444); -module_param_named(dev, synth_dummy.dev_name, charp, S_IRUGO); +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)."); diff --git a/drivers/staging/speakup/speakup_ltlk.c b/drivers/staging/speakup/speakup_ltlk.c index 423795f88f53..95efaab73813 100644 --- a/drivers/staging/speakup/speakup_ltlk.c +++ b/drivers/staging/speakup/speakup_ltlk.c @@ -167,7 +167,7 @@ static int synth_probe(struct spk_synth *synth) } module_param_named(ser, synth_ltlk.ser, int, 0444); -module_param_named(dev, synth_ltlk.dev_name, charp, S_IRUGO); +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)."); diff --git a/drivers/staging/speakup/speakup_spkout.c b/drivers/staging/speakup/speakup_spkout.c index 9ca21edc42ce..1037aa0d085a 100644 --- a/drivers/staging/speakup/speakup_spkout.c +++ b/drivers/staging/speakup/speakup_spkout.c @@ -131,7 +131,7 @@ static void synth_flush(struct spk_synth *synth) } module_param_named(ser, synth_spkout.ser, int, 0444); -module_param_named(dev, synth_spkout.dev_name, charp, S_IRUGO); +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)."); diff --git a/drivers/staging/speakup/speakup_txprt.c b/drivers/staging/speakup/speakup_txprt.c index 831ee404e7a1..e160034e4a68 100644 --- a/drivers/staging/speakup/speakup_txprt.c +++ b/drivers/staging/speakup/speakup_txprt.c @@ -119,7 +119,7 @@ static struct spk_synth synth_txprt = { }; module_param_named(ser, synth_txprt.ser, int, 0444); -module_param_named(dev, synth_txprt.dev_name, charp, S_IRUGO); +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)."); diff --git a/drivers/staging/speakup/spk_ttyio.c b/drivers/staging/speakup/spk_ttyio.c index 4d7d8f2f66ea..513cebbd161c 100644 --- a/drivers/staging/speakup/spk_ttyio.c +++ b/drivers/staging/speakup/spk_ttyio.c @@ -51,10 +51,8 @@ static int spk_ttyio_ldisc_open(struct tty_struct *tty) speakup_tty = tty; ldisc_data = kmalloc(sizeof(struct spk_ldisc_data), GFP_KERNEL); - if (!ldisc_data) { - pr_err("speakup: Failed to allocate ldisc_data.\n"); + if (!ldisc_data) return -ENOMEM; - } sema_init(&ldisc_data->sem, 0); ldisc_data->buf_free = true; @@ -90,7 +88,8 @@ static int spk_ttyio_receive_buf2(struct tty_struct *tty, return 0; /* Make sure the consumer has read buf before we have seen - * buf_free == true and overwrite buf */ + * buf_free == true and overwrite buf + */ mb(); ldisc_data->buf = cp[0]; @@ -276,7 +275,8 @@ static unsigned char ttyio_in(int timeout) rv = ldisc_data->buf; /* Make sure we have read buf before we set buf_free to let - * the producer overwrite it */ + * the producer overwrite it + */ mb(); ldisc_data->buf_free = true; /* Let TTY push more characters */ diff --git a/drivers/staging/typec/Kconfig b/drivers/staging/typec/Kconfig index 37a0781b0d0c..5359f556d203 100644 --- a/drivers/staging/typec/Kconfig +++ b/drivers/staging/typec/Kconfig @@ -1,13 +1,5 @@ menu "USB Power Delivery and Type-C drivers" -config TYPEC_TCPM - tristate "USB Type-C Port Controller Manager" - depends on USB - select TYPEC - help - The Type-C Port Controller Manager provides a USB PD and USB Type-C - state machine for use with Type-C Port Controllers. - if TYPEC_TCPM config TYPEC_TCPCI @@ -17,8 +9,6 @@ config TYPEC_TCPCI help Type-C Port Controller driver for TCPCI-compliant controller. -source "drivers/staging/typec/fusb302/Kconfig" - endif endmenu diff --git a/drivers/staging/typec/Makefile b/drivers/staging/typec/Makefile index 30a7e29cbc9e..53d649abcb53 100644 --- a/drivers/staging/typec/Makefile +++ b/drivers/staging/typec/Makefile @@ -1,3 +1 @@ -obj-$(CONFIG_TYPEC_TCPM) += tcpm.o obj-$(CONFIG_TYPEC_TCPCI) += tcpci.o -obj-y += fusb302/ diff --git a/drivers/staging/typec/TODO b/drivers/staging/typec/TODO index bc1f97a2d1bf..53fe2f726c88 100644 --- a/drivers/staging/typec/TODO +++ b/drivers/staging/typec/TODO @@ -1,13 +1,3 @@ -tcpm: -- Add documentation (at the very least for the API to low level drivers) -- Split PD code into separate file -- Check if it makes sense to use tracepoints instead of debugfs for debug logs -- Implement Alternate Mode handling -- Address "#if 0" code if not addressed with the above -- Validate all comments marked with "XXX"; either address or remove comments -- Add support for USB PD 3.0. While not mandatory, at least fast role swap - as well as authentication support would be very desirable. - tcpci: - Test with real hardware diff --git a/drivers/staging/typec/fusb302/TODO b/drivers/staging/typec/fusb302/TODO deleted file mode 100644 index 19b466eb585d..000000000000 --- a/drivers/staging/typec/fusb302/TODO +++ /dev/null @@ -1,10 +0,0 @@ -fusb302: -- Find a better logging scheme, at least not having the same debugging/logging - code replicated here and in tcpm -- Find a non-hacky way to coordinate between PM and I2C access -- Documentation? The FUSB302 datasheet provides information on the chip to help - understand the code. But it may still be helpful to have a documentation. -- We may want to replace the "fcs,max-snk-microvolt", "fcs,max-snk-microamp", - "fcs,max-snk-microwatt" and "fcs,operating-snk-microwatt" device(tree) - properties with properties which are part of a generic type-c controller - devicetree binding. diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c index df72d8b01e73..4636804ea1a4 100644 --- a/drivers/staging/typec/tcpci.c +++ b/drivers/staging/typec/tcpci.c @@ -20,11 +20,11 @@ #include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/regmap.h> +#include <linux/usb/pd.h> +#include <linux/usb/tcpm.h> #include <linux/usb/typec.h> -#include "pd.h" #include "tcpci.h" -#include "tcpm.h" #define PD_RETRY_COUNT 3 diff --git a/drivers/staging/unisys/include/iochannel.h b/drivers/staging/unisys/include/iochannel.h index a70760f48566..5cd407ca2251 100644 --- a/drivers/staging/unisys/include/iochannel.h +++ b/drivers/staging/unisys/include/iochannel.h @@ -44,7 +44,7 @@ #include <linux/uuid.h> #include <linux/skbuff.h> -#include "channel.h" +#include "visorchannel.h" /* * Must increment these whenever you insert or delete fields within this channel @@ -348,10 +348,9 @@ struct sense_data { * the start of the NETWORK LAYER HEADER. * * NOTE: - * The full packet is described in frags but the ethernet header is - * separately kept in ethhdr so that uisnic doesn't have "MAP" the - * guest memory to get to the header. uisnic needs ethhdr to - * determine how to route the packet. + * The full packet is described in frags but the ethernet header is separately + * kept in ethhdr so that uisnic doesn't have "MAP" the guest memory to get to + * the header. uisnic needs ethhdr to determine how to route the packet. */ struct net_pkt_xmt { int len; diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h index e4ee38c3dbe4..1a0986ba3d24 100644 --- a/drivers/staging/unisys/include/visorbus.h +++ b/drivers/staging/unisys/include/visorbus.h @@ -28,87 +28,20 @@ #define __VISORBUS_H__ #include <linux/device.h> -#include <linux/module.h> -#include <linux/slab.h> -#include "channel.h" - -struct visor_device; -extern struct bus_type visorbus_type; - -typedef void (*visorbus_state_complete_func) (struct visor_device *dev, - int status); +#include "visorchannel.h" struct visorchipset_state { u32 created:1; u32 attached:1; u32 configured:1; u32 running:1; - /* Add new fields above. */ - /* Remaining bits in this 32-bit word are unused. */ -}; - -/* - * This struct describes a specific Supervisor channel, by providing its - * GUID, name, and sizes. - */ -struct visor_channeltype_descriptor { - const guid_t guid; - const char *name; + /* Remaining bits in this 32-bit word are reserved. */ }; /** - * struct visor_driver - Information provided by each visor driver when it - * registers with the visorbus driver. - * @name: Name of the visor driver. - * @owner: The module owner. - * @channel_types: Types of channels handled by this driver, ending with - * a zero GUID. Our specialized BUS.match() method knows - * about this list, and uses it to determine whether this - * driver will in fact handle a new device that it has - * detected. - * @probe: Called when a new device comes online, by our probe() - * function specified by driver.probe() (triggered - * ultimately by some call to driver_register(), - * bus_add_driver(), or driver_attach()). - * @remove: Called when a new device is removed, by our remove() - * function specified by driver.remove() (triggered - * ultimately by some call to device_release_driver()). - * @channel_interrupt: Called periodically, whenever there is a possiblity - * that "something interesting" may have happened to the - * channel. - * @pause: Called to initiate a change of the device's state. If - * the return valu`e is < 0, there was an error and the - * state transition will NOT occur. If the return value - * is >= 0, then the state transition was INITIATED - * successfully, and complete_func() will be called (or - * was just called) with the final status when either the - * state transition fails or completes successfully. - * @resume: Behaves similar to pause. - * @driver: Private reference to the device driver. For use by bus - * driver only. - */ -struct visor_driver { - const char *name; - struct module *owner; - struct visor_channeltype_descriptor *channel_types; - int (*probe)(struct visor_device *dev); - void (*remove)(struct visor_device *dev); - void (*channel_interrupt)(struct visor_device *dev); - int (*pause)(struct visor_device *dev, - visorbus_state_complete_func complete_func); - int (*resume)(struct visor_device *dev, - visorbus_state_complete_func complete_func); - - /* These fields are for private use by the bus driver only. */ - struct device_driver driver; -}; - -#define to_visor_driver(x) (container_of(x, struct visor_driver, driver)) - -/** * struct visor_device - A device type for things "plugged" into the visorbus - * bus + * bus * @visorchannel: Points to the channel that the device is * associated with. * @channel_type_guid: Identifies the channel type to the bus driver. @@ -139,7 +72,6 @@ struct visor_driver { * same across all visor_devices in the current * guest. Private use by bus driver only. */ - struct visor_device { struct visorchannel *visorchannel; guid_t channel_type_guid; @@ -161,11 +93,74 @@ struct visor_device { void *vbus_hdr_info; guid_t partition_guid; struct dentry *debugfs_dir; - struct dentry *debugfs_client_bus_info; + struct dentry *debugfs_bus_info; }; #define to_visor_device(x) container_of(x, struct visor_device, device) +typedef void (*visorbus_state_complete_func) (struct visor_device *dev, + int status); + +/* + * This struct describes a specific visor channel, by providing its GUID, name, + * and sizes. + */ +struct visor_channeltype_descriptor { + const guid_t guid; + const char *name; + u64 min_bytes; + u32 version; +}; + +/** + * struct visor_driver - Information provided by each visor driver when it + * registers with the visorbus driver + * @name: Name of the visor driver. + * @owner: The module owner. + * @channel_types: Types of channels handled by this driver, ending with + * a zero GUID. Our specialized BUS.match() method knows + * about this list, and uses it to determine whether this + * driver will in fact handle a new device that it has + * detected. + * @probe: Called when a new device comes online, by our probe() + * function specified by driver.probe() (triggered + * ultimately by some call to driver_register(), + * bus_add_driver(), or driver_attach()). + * @remove: Called when a new device is removed, by our remove() + * function specified by driver.remove() (triggered + * ultimately by some call to device_release_driver()). + * @channel_interrupt: Called periodically, whenever there is a possiblity + * that "something interesting" may have happened to the + * channel. + * @pause: Called to initiate a change of the device's state. If + * the return valu`e is < 0, there was an error and the + * state transition will NOT occur. If the return value + * is >= 0, then the state transition was INITIATED + * successfully, and complete_func() will be called (or + * was just called) with the final status when either the + * state transition fails or completes successfully. + * @resume: Behaves similar to pause. + * @driver: Private reference to the device driver. For use by bus + * driver only. + */ +struct visor_driver { + const char *name; + struct module *owner; + struct visor_channeltype_descriptor *channel_types; + int (*probe)(struct visor_device *dev); + void (*remove)(struct visor_device *dev); + void (*channel_interrupt)(struct visor_device *dev); + int (*pause)(struct visor_device *dev, + visorbus_state_complete_func complete_func); + int (*resume)(struct visor_device *dev, + visorbus_state_complete_func complete_func); + + /* These fields are for private use by the bus driver only. */ + struct device_driver driver; +}; + +#define to_visor_driver(x) (container_of(x, struct visor_driver, driver)) + int visor_check_channel(struct channel_header *ch, struct device *dev, const guid_t *expected_uuid, char *chname, u64 expected_min_bytes, u32 expected_version, @@ -182,26 +177,6 @@ int visorbus_write_channel(struct visor_device *dev, int visorbus_enable_channel_interrupts(struct visor_device *dev); void visorbus_disable_channel_interrupts(struct visor_device *dev); -/* - * Levels of severity for diagnostic events, in order from lowest severity to - * highest (i.e. fatal errors are the most severe, and should always be logged, - * but info events rarely need to be logged except during debugging). The - * values DIAG_SEVERITY_ENUM_BEGIN and DIAG_SEVERITY_ENUM_END are not valid - * severity values. They exist merely to dilineate the list, so that future - * additions won't require changes to the driver (i.e. when checking for - * out-of-range severities in SetSeverity). The values DIAG_SEVERITY_OVERRIDE - * and DIAG_SEVERITY_SHUTOFF are not valid severity values for logging events - * but they are valid for controlling the amount of event data. Changes made - * to the enum, need to be reflected in s-Par. - */ -enum diag_severity { - DIAG_SEVERITY_VERBOSE = 0, - DIAG_SEVERITY_INFO = 1, - DIAG_SEVERITY_WARNING = 2, - DIAG_SEVERITY_ERR = 3, - DIAG_SEVERITY_PRINT = 4, -}; - int visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg); int visorchannel_signalinsert(struct visorchannel *channel, u32 queue, diff --git a/drivers/staging/unisys/include/channel.h b/drivers/staging/unisys/include/visorchannel.h index 2babe93631f3..33945749c8b6 100644 --- a/drivers/staging/unisys/include/channel.h +++ b/drivers/staging/unisys/include/visorchannel.h @@ -14,17 +14,13 @@ * details. */ -#ifndef __CHANNEL_H__ -#define __CHANNEL_H__ +#ifndef __VISORCHANNEL_H__ +#define __VISORCHANNEL_H__ #include <linux/types.h> -#include <linux/io.h> #include <linux/uuid.h> -#define SIGNATURE_16(A, B) ((A) | ((B) << 8)) -#define SIGNATURE_32(A, B, C, D) \ - (SIGNATURE_16(A, B) | (SIGNATURE_16(C, D) << 16)) -#define VISOR_CHANNEL_SIGNATURE SIGNATURE_32('E', 'C', 'N', 'L') +#define VISOR_CHANNEL_SIGNATURE ('L' << 24 | 'N' << 16 | 'C' << 8 | 'E') /* * enum channel_serverstate @@ -183,7 +179,7 @@ struct signal_queue_header { u8 filler[12]; } __packed; -/* CHANNEL Guids */ +/* VISORCHANNEL Guids */ /* {414815ed-c58c-11da-95a9-00e08161165f} */ #define VISOR_VHBA_CHANNEL_GUID \ GUID_INIT(0x414815ed, 0xc58c, 0x11da, \ diff --git a/drivers/staging/unisys/visorbus/controlvmchannel.h b/drivers/staging/unisys/visorbus/controlvmchannel.h index 32ff5c1bb6ba..9ee9886a9aed 100644 --- a/drivers/staging/unisys/visorbus/controlvmchannel.h +++ b/drivers/staging/unisys/visorbus/controlvmchannel.h @@ -17,7 +17,8 @@ #define __CONTROLVMCHANNEL_H__ #include <linux/uuid.h> -#include "channel.h" + +#include "visorchannel.h" /* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */ #define VISOR_CONTROLVM_CHANNEL_GUID \ diff --git a/drivers/staging/unisys/visorbus/vbuschannel.h b/drivers/staging/unisys/visorbus/vbuschannel.h index 27e04de14818..981b180f3c4b 100644 --- a/drivers/staging/unisys/visorbus/vbuschannel.h +++ b/drivers/staging/unisys/visorbus/vbuschannel.h @@ -26,8 +26,7 @@ */ #include <linux/uuid.h> -#include <linux/ctype.h> -#include "channel.h" +#include "visorchannel.h" /* {193b331b-c58f-11da-95a9-00e08161165f} */ #define VISOR_VBUS_CHANNEL_GUID \ @@ -50,9 +49,9 @@ * @infostrs: Kernel vversion. * @reserved: Pad size to 256 bytes. * - * An array of this struct is present in the channel area for each vbus. - * (See vbuschannel.h.). It is filled in by the client side to provide info - * about the device and driver from the client's perspective. + * An array of this struct is present in the channel area for each vbus. It is + * filled in by the client side to provide info about the device and driver from + * the client's perspective. */ struct visor_vbus_deviceinfo { u8 devtype[16]; @@ -73,7 +72,7 @@ struct visor_vbus_deviceinfo { * BusInfo struct. * @dev_info_offset: Byte offset from beginning of this struct to the * DevInfo array. - * @reserved: Natural Alignment + * @reserved: Natural alignment. */ struct visor_vbus_headerinfo { u32 struct_bytes; @@ -97,7 +96,6 @@ struct visor_vbus_headerinfo { struct visor_vbus_channel { struct channel_header channel_header; struct visor_vbus_headerinfo hdr_info; - /* The remainder of this channel is filled in by the client */ struct visor_vbus_deviceinfo chp_info; struct visor_vbus_deviceinfo bus_info; struct visor_vbus_deviceinfo dev_info[0]; diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 2bc7ff7bb96a..2f1e8d36aedf 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -13,7 +13,10 @@ * details. */ +#include <linux/ctype.h> #include <linux/debugfs.h> +#include <linux/module.h> +#include <linux/slab.h> #include <linux/uuid.h> #include "visorbus.h" @@ -69,12 +72,9 @@ static LIST_HEAD(list_all_device_instances); * Note that <logCtx> is only needed for callers in the EFI environment, and * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages. */ -int visor_check_channel(struct channel_header *ch, - struct device *dev, - const guid_t *expected_guid, - char *chname, - u64 expected_min_bytes, - u32 expected_version, +int visor_check_channel(struct channel_header *ch, struct device *dev, + const guid_t *expected_guid, char *chname, + u64 expected_min_bytes, u32 expected_version, u64 expected_signature) { if (!guid_is_null(expected_guid)) { @@ -125,7 +125,6 @@ static int visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env) dev = to_visor_device(xdev); guid = visorchannel_get_guid(dev->visorchannel); - return add_uevent_var(env, "MODALIAS=visorbus:%pUl", guid); } @@ -144,17 +143,24 @@ static int visorbus_match(struct device *xdev, struct device_driver *xdrv) int i; struct visor_device *dev; struct visor_driver *drv; + struct visorchannel *chan; dev = to_visor_device(xdev); channel_type = visorchannel_get_guid(dev->visorchannel); drv = to_visor_driver(xdrv); + chan = dev->visorchannel; if (!drv->channel_types) return 0; - for (i = 0; !guid_is_null(&drv->channel_types[i].guid); i++) - if (guid_equal(&drv->channel_types[i].guid, channel_type)) + if (guid_equal(&drv->channel_types[i].guid, channel_type) && + visor_check_channel(visorchannel_get_header(chan), + xdev, + &drv->channel_types[i].guid, + (char *)drv->channel_types[i].name, + drv->channel_types[i].min_bytes, + drv->channel_types[i].version, + VISOR_CHANNEL_SIGNATURE)) return i + 1; - return 0; } @@ -162,13 +168,48 @@ static int visorbus_match(struct device *xdev, struct device_driver *xdrv) * This describes the TYPE of bus. * (Don't confuse this with an INSTANCE of the bus.) */ -struct bus_type visorbus_type = { +static struct bus_type visorbus_type = { .name = "visorbus", .match = visorbus_match, .uevent = visorbus_uevent, .dev_groups = visorbus_dev_groups, }; +struct visor_busdev { + u32 bus_no; + u32 dev_no; +}; + +static int match_visorbus_dev_by_id(struct device *dev, void *data) +{ + struct visor_device *vdev = to_visor_device(dev); + struct visor_busdev *id = data; + + if (vdev->chipset_bus_no == id->bus_no && + vdev->chipset_dev_no == id->dev_no) + return 1; + return 0; +} + +struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no, + struct visor_device *from) +{ + struct device *dev; + struct device *dev_start = NULL; + struct visor_busdev id = { + .bus_no = bus_no, + .dev_no = dev_no + }; + + if (from) + dev_start = &from->device; + dev = bus_find_device(&visorbus_type, dev_start, (void *)&id, + match_visorbus_dev_by_id); + if (!dev) + return NULL; + return to_visor_device(dev); +} + /* * visorbus_release_busdevice() - called when device_unregister() is called for * the bus device instance, after all other tasks @@ -179,8 +220,9 @@ static void visorbus_release_busdevice(struct device *xdev) { struct visor_device *dev = dev_get_drvdata(xdev); - debugfs_remove(dev->debugfs_client_bus_info); + debugfs_remove(dev->debugfs_bus_info); debugfs_remove_recursive(dev->debugfs_dir); + visorchannel_destroy(dev->visorchannel); kfree(dev); } @@ -198,7 +240,7 @@ static void visorbus_release_device(struct device *xdev) } /* - * begin implementation of specific channel attributes to appear under + * BUS specific channel attributes to appear under * /sys/bus/visorbus<x>/dev<y>/channel */ @@ -218,7 +260,7 @@ static ssize_t nbytes_show(struct device *dev, struct device_attribute *attr, struct visor_device *vdev = to_visor_device(dev); return sprintf(buf, "0x%lx\n", - visorchannel_get_nbytes(vdev->visorchannel)); + visorchannel_get_nbytes(vdev->visorchannel)); } static DEVICE_ATTR_RO(nbytes); @@ -284,18 +326,14 @@ static struct attribute *channel_attrs[] = { ATTRIBUTE_GROUPS(channel); -/* end implementation of specific channel attributes */ - /* * BUS instance attributes * * define & implement display of bus attributes under * /sys/bus/visorbus/devices/visorbus<n>. */ - static ssize_t partition_handle_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { struct visor_device *vdev = to_visor_device(dev); u64 handle = visorchannel_get_clientpartition(vdev->visorchannel); @@ -305,8 +343,7 @@ static ssize_t partition_handle_show(struct device *dev, static DEVICE_ATTR_RO(partition_handle); static ssize_t partition_guid_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { struct visor_device *vdev = to_visor_device(dev); @@ -315,8 +352,7 @@ static ssize_t partition_guid_show(struct device *dev, static DEVICE_ATTR_RO(partition_guid); static ssize_t partition_name_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { struct visor_device *vdev = to_visor_device(dev); @@ -325,8 +361,7 @@ static ssize_t partition_name_show(struct device *dev, static DEVICE_ATTR_RO(partition_name); static ssize_t channel_addr_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { struct visor_device *vdev = to_visor_device(dev); u64 addr = visorchannel_get_physaddr(vdev->visorchannel); @@ -336,8 +371,7 @@ static ssize_t channel_addr_show(struct device *dev, static DEVICE_ATTR_RO(channel_addr); static ssize_t channel_bytes_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { struct visor_device *vdev = to_visor_device(dev); u64 nbytes = visorchannel_get_nbytes(vdev->visorchannel); @@ -347,8 +381,7 @@ static ssize_t channel_bytes_show(struct device *dev, static DEVICE_ATTR_RO(channel_bytes); static ssize_t channel_id_show(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { struct visor_device *vdev = to_visor_device(dev); int len = 0; @@ -356,7 +389,6 @@ static ssize_t channel_id_show(struct device *dev, visorchannel_id(vdev->visorchannel, buf); len = strlen(buf); buf[len++] = '\n'; - return len; } static DEVICE_ATTR_RO(channel_id); @@ -396,13 +428,11 @@ static void vbuschannel_print_devinfo(struct visor_vbus_deviceinfo *devinfo, /* uninitialized vbus device entry */ if (!isprint(devinfo->devtype[0])) return; - if (devix >= 0) seq_printf(seq, "[%d]", devix); else /* vbus device entry is for bus or chipset */ seq_puts(seq, " "); - /* * Note: because the s-Par back-end is free to scribble in this area, * we never assume '\0'-termination. @@ -415,7 +445,7 @@ static void vbuschannel_print_devinfo(struct visor_vbus_deviceinfo *devinfo, devinfo->infostrs); } -static int client_bus_info_debugfs_show(struct seq_file *seq, void *v) +static int bus_info_debugfs_show(struct seq_file *seq, void *v) { int i = 0; unsigned long off; @@ -427,10 +457,9 @@ static int client_bus_info_debugfs_show(struct seq_file *seq, void *v) return 0; seq_printf(seq, - "Client device / client driver info for %s partition (vbus #%u):\n", + "Client device/driver info for %s partition (vbus #%u):\n", ((vdev->name) ? (char *)(vdev->name) : ""), vdev->chipset_bus_no); - if (visorchannel_read(channel, offsetof(struct visor_vbus_channel, chp_info), &dev_info, sizeof(dev_info)) >= 0) @@ -448,19 +477,17 @@ static int client_bus_info_debugfs_show(struct seq_file *seq, void *v) off += sizeof(dev_info); i++; } - return 0; } -static int client_bus_info_debugfs_open(struct inode *inode, struct file *file) +static int bus_info_debugfs_open(struct inode *inode, struct file *file) { - return single_open(file, client_bus_info_debugfs_show, - inode->i_private); + return single_open(file, bus_info_debugfs_show, inode->i_private); } -static const struct file_operations client_bus_info_debugfs_fops = { +static const struct file_operations bus_info_debugfs_fops = { .owner = THIS_MODULE, - .open = client_bus_info_debugfs_open, + .open = bus_info_debugfs_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, @@ -479,6 +506,7 @@ static int dev_start_periodic_work(struct visor_device *dev) { if (dev->being_removed || dev->timer_active) return -EINVAL; + /* now up by at least 2 */ get_device(&dev->device); dev->timer.expires = jiffies + POLLJIFFIES_NORMALCHANNEL; @@ -491,6 +519,7 @@ static void dev_stop_periodic_work(struct visor_device *dev) { if (!dev->timer_active) return; + del_timer_sync(&dev->timer); dev->timer_active = false; put_device(&dev->device); @@ -508,20 +537,15 @@ static void dev_stop_periodic_work(struct visor_device *dev) */ static int visordriver_remove_device(struct device *xdev) { - struct visor_device *dev; - struct visor_driver *drv; - - dev = to_visor_device(xdev); - drv = to_visor_driver(xdev->driver); + struct visor_device *dev = to_visor_device(xdev); + struct visor_driver *drv = to_visor_driver(xdev->driver); mutex_lock(&dev->visordriver_callback_lock); dev->being_removed = true; drv->remove(dev); mutex_unlock(&dev->visordriver_callback_lock); - dev_stop_periodic_work(dev); put_device(&dev->device); - return 0; } @@ -546,8 +570,7 @@ EXPORT_SYMBOL_GPL(visorbus_unregister_visor_driver); * @dest: the destination buffer that is written into from the channel * @nbytes: the number of bytes to read from the channel * - * If receiving a message, use the visorchannel_signalremove() - * function instead. + * If receiving a message, use the visorchannel_signalremove() function instead. * * Return: integer indicating success (zero) or failure (non-zero) */ @@ -566,8 +589,7 @@ EXPORT_SYMBOL_GPL(visorbus_read_channel); * @src: the source buffer that is written into the channel * @nbytes: the number of bytes to write into the channel * - * If sending a message, use the visorchannel_signalinsert() - * function instead. + * If sending a message, use the visorchannel_signalinsert() function instead. * * Return: integer indicating success (zero) or failure (non-zero) */ @@ -618,17 +640,16 @@ EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts); * * This is how everything starts from the device end. * This function is called when a channel first appears via a ControlVM - * message. In response, this function allocates a visor_device to - * correspond to the new channel, and attempts to connect it the appropriate - * driver. If the appropriate driver is found, the visor_driver.probe() - * function for that driver will be called, and will be passed the new - * visor_device that we just created. + * message. In response, this function allocates a visor_device to correspond + * to the new channel, and attempts to connect it the appropriate * driver. If + * the appropriate driver is found, the visor_driver.probe() function for that + * driver will be called, and will be passed the new * visor_device that we + * just created. * * It's ok if the appropriate driver is not yet loaded, because in that case * the new device struct will just stick around in the bus' list of devices. * When the appropriate driver calls visorbus_register_visor_driver(), the - * visor_driver.probe() for the new driver will be called with the new - * device. + * visor_driver.probe() for the new driver will be called with the new device. * * Return: 0 if successful, otherwise the negative value returned by * device_add() indicating the reason for failure @@ -647,17 +668,15 @@ int create_visor_device(struct visor_device *dev) /* keep a reference just for us (now 2) */ get_device(&dev->device); setup_timer(&dev->timer, dev_periodic_work, (unsigned long)dev); - /* - * bus_id must be a unique name with respect to this bus TYPE - * (NOT bus instance). That's why we need to include the bus - * number within the name. + * bus_id must be a unique name with respect to this bus TYPE (NOT bus + * instance). That's why we need to include the bus number within the + * name. */ err = dev_set_name(&dev->device, "vbus%u:dev%u", chipset_bus_no, chipset_dev_no); if (err) goto err_put; - /* * device_add does this: * bus_add_device(dev) @@ -671,14 +690,13 @@ int create_visor_device(struct visor_device *dev) * if (!drv.probe(dev)) [visordriver_probe_device] * dev.drv = NULL * - * Note that device_add does NOT fail if no driver failed to - * claim the device. The device will be linked onto - * bus_type.klist_devices regardless (use bus_for_each_dev). + * Note that device_add does NOT fail if no driver failed to claim the + * device. The device will be linked onto bus_type.klist_devices + * regardless (use bus_for_each_dev). */ err = device_add(&dev->device); if (err < 0) goto err_put; - list_add_tail(&dev->list_all, &list_all_device_instances); dev->state.created = 1; visorbus_response(dev, err, CONTROLVM_DEVICE_CREATE); @@ -695,8 +713,9 @@ void remove_visor_device(struct visor_device *dev) { list_del(&dev->list_all); put_device(&dev->device); + if (dev->pending_msg_hdr) + visorbus_response(dev, 0, CONTROLVM_DEVICE_DESTROY); device_unregister(&dev->device); - visorbus_response(dev, 0, CONTROLVM_DEVICE_DESTROY); } static int get_vbus_header_info(struct visorchannel *chan, @@ -718,14 +737,11 @@ static int get_vbus_header_info(struct visorchannel *chan, sizeof(*hdr_info)); if (err < 0) return err; - if (hdr_info->struct_bytes < sizeof(struct visor_vbus_headerinfo)) return -EINVAL; - if (hdr_info->device_info_struct_bytes < sizeof(struct visor_vbus_deviceinfo)) return -EINVAL; - return 0; } @@ -746,11 +762,12 @@ static void write_vbus_chp_info(struct visorchannel *chan, struct visor_vbus_headerinfo *hdr_info, struct visor_vbus_deviceinfo *info) { - int off = sizeof(struct channel_header) + hdr_info->chp_info_offset; + int off; if (hdr_info->chp_info_offset == 0) return; + off = sizeof(struct channel_header) + hdr_info->chp_info_offset; visorchannel_write(chan, off, info, sizeof(*info)); } @@ -771,11 +788,12 @@ static void write_vbus_bus_info(struct visorchannel *chan, struct visor_vbus_headerinfo *hdr_info, struct visor_vbus_deviceinfo *info) { - int off = sizeof(struct channel_header) + hdr_info->bus_info_offset; + int off; if (hdr_info->bus_info_offset == 0) return; + off = sizeof(struct channel_header) + hdr_info->bus_info_offset; visorchannel_write(chan, off, info, sizeof(*info)); } @@ -798,13 +816,12 @@ static void write_vbus_dev_info(struct visorchannel *chan, struct visor_vbus_deviceinfo *info, unsigned int devix) { - int off = - (sizeof(struct channel_header) + hdr_info->dev_info_offset) + - (hdr_info->device_info_struct_bytes * devix); + int off; if (hdr_info->dev_info_offset == 0) return; - + off = (sizeof(struct channel_header) + hdr_info->dev_info_offset) + + (hdr_info->device_info_struct_bytes * devix); visorchannel_write(chan, off, info, sizeof(*info)); } @@ -844,7 +861,6 @@ static void publish_vbus_dev_info(struct visor_device *visordev) if (!visordev->device.driver) return; - bdev = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL); if (!bdev) return; @@ -860,14 +876,12 @@ static void publish_vbus_dev_info(struct visor_device *visordev) * type name */ for (i = 0; visordrv->channel_types[i].name; i++) { - if (memcmp(&visordrv->channel_types[i].guid, - &visordev->channel_type_guid, - sizeof(visordrv->channel_types[i].guid)) == 0) { + if (guid_equal(&visordrv->channel_types[i].guid, + &visordev->channel_type_guid)) { chan_type_name = visordrv->channel_types[i].name; break; } } - bus_device_info_init(&dev_info, chan_type_name, visordrv->name); write_vbus_dev_info(bdev->visorchannel, hdr_info, &dev_info, dev_no); write_vbus_chp_info(bdev->visorchannel, hdr_info, &chipset_driverinfo); @@ -892,36 +906,32 @@ static void publish_vbus_dev_info(struct visor_device *visordev) */ static int visordriver_probe_device(struct device *xdev) { - int res; - struct visor_driver *drv; - struct visor_device *dev; - - dev = to_visor_device(xdev); - drv = to_visor_driver(xdev->driver); + int err; + struct visor_driver *drv = to_visor_driver(xdev->driver); + struct visor_device *dev = to_visor_device(xdev); mutex_lock(&dev->visordriver_callback_lock); dev->being_removed = false; - - res = drv->probe(dev); - if (res >= 0) { - /* success: reference kept via unmatched get_device() */ - get_device(&dev->device); - publish_vbus_dev_info(dev); + err = drv->probe(dev); + if (err) { + mutex_unlock(&dev->visordriver_callback_lock); + return err; } - + /* success: reference kept via unmatched get_device() */ + get_device(&dev->device); + publish_vbus_dev_info(dev); mutex_unlock(&dev->visordriver_callback_lock); - return res; + return 0; } /* - * visorbus_register_visor_driver() - registers the provided visor driver - * for handling one or more visor device + * visorbus_register_visor_driver() - registers the provided visor driver for + * handling one or more visor device * types (channel_types) * @drv: the driver to register * - * A visor function driver calls this function to register - * the driver. The caller MUST fill in the following fields within the - * #drv structure: + * A visor function driver calls this function to register the driver. The + * caller MUST fill in the following fields within the #drv structure: * name, version, owner, channel_types, probe, remove * * Here's how the whole Linux bus / driver / device model works. @@ -967,16 +977,12 @@ int visorbus_register_visor_driver(struct visor_driver *drv) /* can't register on a nonexistent bus */ if (!initialized) return -ENODEV; - if (!drv->probe) return -EINVAL; - if (!drv->remove) return -EINVAL; - if (!drv->pause) return -EINVAL; - if (!drv->resume) return -EINVAL; @@ -985,7 +991,6 @@ int visorbus_register_visor_driver(struct visor_driver *drv) drv->driver.probe = visordriver_probe_device; drv->driver.remove = visordriver_remove_device; drv->driver.owner = drv->owner; - /* * driver_register does this: * bus_add_driver(drv) @@ -998,7 +1003,6 @@ int visorbus_register_visor_driver(struct visor_driver *drv) * if (!drv.probe(dev)) [visordriver_probe_device] * dev.drv = NULL */ - return driver_register(&drv->driver); } EXPORT_SYMBOL_GPL(visorbus_register_visor_driver); @@ -1019,39 +1023,28 @@ int visorbus_create_instance(struct visor_device *dev) hdr_info = kzalloc(sizeof(*hdr_info), GFP_KERNEL); if (!hdr_info) return -ENOMEM; - dev_set_name(&dev->device, "visorbus%d", id); dev->device.bus = &visorbus_type; dev->device.groups = visorbus_groups; dev->device.release = visorbus_release_busdevice; - dev->debugfs_dir = debugfs_create_dir(dev_name(&dev->device), visorbus_debugfs_dir); - dev->debugfs_client_bus_info = - debugfs_create_file("client_bus_info", 0440, - dev->debugfs_dir, dev, - &client_bus_info_debugfs_fops); - + dev->debugfs_bus_info = debugfs_create_file("client_bus_info", 0440, + dev->debugfs_dir, dev, + &bus_info_debugfs_fops); dev_set_drvdata(&dev->device, dev); err = get_vbus_header_info(dev->visorchannel, &dev->device, hdr_info); if (err < 0) goto err_debugfs_dir; - err = device_register(&dev->device); if (err < 0) goto err_debugfs_dir; - list_add_tail(&dev->list_all, &list_all_bus_instances); - dev->state.created = 1; dev->vbus_hdr_info = (void *)hdr_info; - write_vbus_chp_info(dev->visorchannel, hdr_info, - &chipset_driverinfo); - write_vbus_bus_info(dev->visorchannel, hdr_info, - &clientbus_driverinfo); - + write_vbus_chp_info(dev->visorchannel, hdr_info, &chipset_driverinfo); + write_vbus_bus_info(dev->visorchannel, hdr_info, &clientbus_driverinfo); visorbus_response(dev, err, CONTROLVM_BUS_CREATE); - return 0; err_debugfs_dir: @@ -1075,11 +1068,11 @@ void visorbus_remove_instance(struct visor_device *dev) * successfully been able to trace thru the code to see where/how * release() gets called. But I know it does. */ - visorchannel_destroy(dev->visorchannel); kfree(dev->vbus_hdr_info); list_del(&dev->list_all); + if (dev->pending_msg_hdr) + visorbus_response(dev, 0, CONTROLVM_BUS_DESTROY); device_unregister(&dev->device); - visorbus_response(dev, 0, CONTROLVM_BUS_DESTROY); } /* @@ -1090,9 +1083,9 @@ static void remove_all_visor_devices(void) struct list_head *listentry, *listtmp; list_for_each_safe(listentry, listtmp, &list_all_device_instances) { - struct visor_device *dev = list_entry(listentry, - struct visor_device, - list_all); + struct visor_device *dev; + + dev = list_entry(listentry, struct visor_device, list_all); remove_visor_device(dev); } } @@ -1131,7 +1124,6 @@ static void resume_state_change_complete(struct visor_device *dev, int status) return; dev->resuming = false; - /* * Notify the chipset driver that the resume is complete, * which will presumably want to send some sort of response to @@ -1156,7 +1148,7 @@ static int visorchipset_initiate_device_pause_resume(struct visor_device *dev, bool is_pause) { int err; - struct visor_driver *drv = NULL; + struct visor_driver *drv; /* If no driver associated with the device nothing to pause/resume */ if (!dev->device.driver) @@ -1177,7 +1169,6 @@ static int visorchipset_initiate_device_pause_resume(struct visor_device *dev, dev->resuming = true; err = drv->resume(dev, resume_state_change_complete); } - return err; } @@ -1198,7 +1189,6 @@ int visorchipset_device_pause(struct visor_device *dev_info) dev_info->pausing = false; return err; } - return 0; } @@ -1219,7 +1209,6 @@ int visorchipset_device_resume(struct visor_device *dev_info) dev_info->resuming = false; return err; } - return 0; } @@ -1230,16 +1219,12 @@ int visorbus_init(void) visorbus_debugfs_dir = debugfs_create_dir("visorbus", NULL); if (!visorbus_debugfs_dir) return -ENOMEM; - bus_device_info_init(&clientbus_driverinfo, "clientbus", "visorbus"); - err = bus_register(&visorbus_type); if (err < 0) return err; - initialized = true; bus_device_info_init(&chipset_driverinfo, "chipset", "visorchipset"); - return 0; } @@ -1248,14 +1233,12 @@ void visorbus_exit(void) struct list_head *listentry, *listtmp; remove_all_visor_devices(); - list_for_each_safe(listentry, listtmp, &list_all_bus_instances) { - struct visor_device *dev = list_entry(listentry, - struct visor_device, - list_all); + struct visor_device *dev; + + dev = list_entry(listentry, struct visor_device, list_all); visorbus_remove_instance(dev); } - bus_unregister(&visorbus_type); initialized = false; debugfs_remove_recursive(visorbus_debugfs_dir); diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index e878d65ab668..4a8b12d7cfaa 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -23,25 +23,23 @@ #include "vbuschannel.h" #include "visorbus.h" +struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no, + struct visor_device *from); int visorbus_create_instance(struct visor_device *dev); void visorbus_remove_instance(struct visor_device *bus_info); int create_visor_device(struct visor_device *dev_info); void remove_visor_device(struct visor_device *dev_info); int visorchipset_device_pause(struct visor_device *dev_info); int visorchipset_device_resume(struct visor_device *dev_info); - void visorbus_response(struct visor_device *p, int response, int controlvm_id); void visorbus_device_changestate_response(struct visor_device *p, int response, struct visor_segment_state state); - int visorbus_init(void); void visorbus_exit(void); /* visorchannel access functions */ struct visorchannel *visorchannel_create(u64 physaddr, gfp_t gfp, - const guid_t *guid); -struct visorchannel *visorchannel_create_with_lock(u64 physaddr, gfp_t gfp, - const guid_t *guid); + const guid_t *guid, bool needs_lock); void visorchannel_destroy(struct visorchannel *channel); int visorchannel_read(struct visorchannel *channel, ulong offset, void *dest, ulong nbytes); diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c index 2a000fee3119..aae16073ba03 100644 --- a/drivers/staging/unisys/visorbus/visorchannel.c +++ b/drivers/staging/unisys/visorbus/visorchannel.c @@ -20,6 +20,7 @@ #include <linux/uuid.h> #include <linux/io.h> +#include <linux/slab.h> #include "visorbus.h" #include "visorbus_private.h" @@ -41,8 +42,8 @@ struct visorchannel { struct channel_header chan_hdr; guid_t guid; /* - * channel creator knows if more than one - * thread will be inserting or removing + * channel creator knows if more than one thread will be inserting or + * removing */ bool needs_lock; /* protect head writes in chan_hdr */ @@ -57,6 +58,7 @@ void visorchannel_destroy(struct visorchannel *channel) { if (!channel) return; + if (channel->mapped) { memunmap(channel->mapped); if (channel->requested) @@ -122,7 +124,6 @@ int visorchannel_read(struct visorchannel *channel, ulong offset, void *dest, return -EIO; memcpy(dest, channel->mapped + offset, nbytes); - return 0; } @@ -140,9 +141,7 @@ int visorchannel_write(struct visorchannel *channel, ulong offset, void *dest, memcpy(((char *)(&channel->chan_hdr)) + offset, dest, copy_size); } - memcpy(channel->mapped + offset, dest, nbytes); - return 0; } @@ -173,8 +172,8 @@ static int sig_data_offset(struct channel_header *chan_hdr, int q, } /* - * Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back - * into host memory + * Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back into + * host memory */ #define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD) \ visorchannel_write(channel, \ @@ -226,32 +225,25 @@ static int signalremove_inner(struct visorchannel *channel, u32 queue, error = sig_read_header(channel, queue, &sig_hdr); if (error) return error; - /* No signals to remove; have caller try again. */ if (sig_hdr.head == sig_hdr.tail) return -EAGAIN; - sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots; - error = sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg); if (error) return error; - sig_hdr.num_received++; - /* - * For each data field in SIGNAL_QUEUE_HEADER that was modified, - * update host memory. Required for channel sync. + * For each data field in SIGNAL_QUEUE_HEADER that was modified, update + * host memory. Required for channel sync. */ mb(); - error = SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail); if (error) return error; error = SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received); if (error) return error; - return 0; } @@ -288,13 +280,12 @@ static bool queue_empty(struct visorchannel *channel, u32 queue) if (sig_read_header(channel, queue, &sig_hdr)) return true; - return (sig_hdr.head == sig_hdr.tail); } /** - * visorchannel_signalempty() - checks if the designated channel/queue - * contains any messages + * visorchannel_signalempty() - checks if the designated channel/queue contains + * any messages * @channel: the channel to query * @queue: the queue in the channel to query * @@ -308,11 +299,9 @@ bool visorchannel_signalempty(struct visorchannel *channel, u32 queue) if (!channel->needs_lock) return queue_empty(channel, queue); - spin_lock_irqsave(&channel->remove_lock, flags); rc = queue_empty(channel, queue); spin_unlock_irqrestore(&channel->remove_lock, flags); - return rc; } EXPORT_SYMBOL_GPL(visorchannel_signalempty); @@ -326,7 +315,6 @@ static int signalinsert_inner(struct visorchannel *channel, u32 queue, err = sig_read_header(channel, queue, &sig_hdr); if (err) return err; - sig_hdr.head = (sig_hdr.head + 1) % sig_hdr.max_slots; if (sig_hdr.head == sig_hdr.tail) { sig_hdr.num_overflows++; @@ -335,33 +323,28 @@ static int signalinsert_inner(struct visorchannel *channel, u32 queue, return err; return -EIO; } - err = sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg); if (err) return err; - sig_hdr.num_sent++; - /* - * For each data field in SIGNAL_QUEUE_HEADER that was modified, - * update host memory. Required for channel sync. + * For each data field in SIGNAL_QUEUE_HEADER that was modified, update + * host memory. Required for channel sync. */ mb(); - err = SIG_WRITE_FIELD(channel, queue, &sig_hdr, head); if (err) return err; err = SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent); if (err) return err; - return 0; } /* - * visorchannel_create_guts() - creates the struct visorchannel abstraction - * for a data area in memory, but does NOT modify - * this data area + * visorchannel_create() - creates the struct visorchannel abstraction for a + * data area in memory, but does NOT modify this data + * area * @physaddr: physical address of start of channel * @gfp: gfp_t to use when allocating memory for the data struct * @guid: GUID that identifies channel type; @@ -372,9 +355,8 @@ static int signalinsert_inner(struct visorchannel *channel, u32 queue, * Return: pointer to visorchannel that was created if successful, * otherwise NULL */ -static struct visorchannel *visorchannel_create_guts(u64 physaddr, gfp_t gfp, - const guid_t *guid, - bool needs_lock) +struct visorchannel *visorchannel_create(u64 physaddr, gfp_t gfp, + const guid_t *guid, bool needs_lock) { struct visorchannel *channel; int err; @@ -386,37 +368,30 @@ static struct visorchannel *visorchannel_create_guts(u64 physaddr, gfp_t gfp, channel = kzalloc(sizeof(*channel), gfp); if (!channel) return NULL; - channel->needs_lock = needs_lock; spin_lock_init(&channel->insert_lock); spin_lock_init(&channel->remove_lock); - /* - * Video driver constains the efi framebuffer so it will get a - * conflict resource when requesting its full mem region. Since - * we are only using the efi framebuffer for video we can ignore - * this. Remember that we haven't requested it so we don't try to - * release later on. + * Video driver constains the efi framebuffer so it will get a conflict + * resource when requesting its full mem region. Since we are only + * using the efi framebuffer for video we can ignore this. Remember that + * we haven't requested it so we don't try to release later on. */ channel->requested = request_mem_region(physaddr, size, VISOR_DRV_NAME); if (!channel->requested && !guid_equal(guid, &visor_video_guid)) /* we only care about errors if this is not the video channel */ goto err_destroy_channel; - channel->mapped = memremap(physaddr, size, MEMREMAP_WB); if (!channel->mapped) { release_mem_region(physaddr, size); goto err_destroy_channel; } - channel->physaddr = physaddr; channel->nbytes = size; - err = visorchannel_read(channel, 0, &channel->chan_hdr, size); if (err) goto err_destroy_channel; size = (ulong)channel->chan_hdr.size; - memunmap(channel->mapped); if (channel->requested) release_mem_region(channel->physaddr, channel->nbytes); @@ -426,13 +401,11 @@ static struct visorchannel *visorchannel_create_guts(u64 physaddr, gfp_t gfp, if (!channel->requested && !guid_equal(guid, &visor_video_guid)) /* we only care about errors if this is not the video channel */ goto err_destroy_channel; - channel->mapped = memremap(channel->physaddr, size, MEMREMAP_WB); if (!channel->mapped) { release_mem_region(channel->physaddr, size); goto err_destroy_channel; } - channel->nbytes = size; guid_copy(&channel->guid, guid); return channel; @@ -442,18 +415,6 @@ err_destroy_channel: return NULL; } -struct visorchannel *visorchannel_create(u64 physaddr, gfp_t gfp, - const guid_t *guid) -{ - return visorchannel_create_guts(physaddr, gfp, guid, false); -} - -struct visorchannel *visorchannel_create_with_lock(u64 physaddr, gfp_t gfp, - const guid_t *guid) -{ - return visorchannel_create_guts(physaddr, gfp, guid, true); -} - /** * visorchannel_signalinsert() - inserts a message into the designated * channel/queue diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 27ecf6fb49fd..fed554a43151 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -27,8 +27,8 @@ static const guid_t visor_vhba_channel_guid = VISOR_VHBA_CHANNEL_GUID; static const guid_t visor_siovm_guid = VISOR_SIOVM_GUID; static const guid_t visor_controlvm_channel_guid = VISOR_CONTROLVM_CHANNEL_GUID; -#define POLLJIFFIES_CONTROLVMCHANNEL_FAST 1 -#define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100 +#define POLLJIFFIES_CONTROLVM_FAST 1 +#define POLLJIFFIES_CONTROLVM_SLOW 100 #define MAX_CONTROLVM_PAYLOAD_BYTES (1024 * 128) @@ -128,7 +128,6 @@ static ssize_t toolaction_show(struct device *dev, &tool_action, sizeof(u8)); if (err) return err; - return sprintf(buf, "%u\n", tool_action); } @@ -141,7 +140,6 @@ static ssize_t toolaction_store(struct device *dev, if (kstrtou8(buf, 10, &tool_action)) return -EINVAL; - err = visorchannel_write(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, tool_action), @@ -178,7 +176,6 @@ static ssize_t boottotool_store(struct device *dev, if (kstrtoint(buf, 10, &val)) return -EINVAL; - efi_visor_indication.boot_to_tool = val; err = visorchannel_write(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, @@ -214,7 +211,6 @@ static ssize_t error_store(struct device *dev, struct device_attribute *attr, if (kstrtou32(buf, 10, &error)) return -EINVAL; - err = visorchannel_write(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, installation_error), @@ -237,7 +233,6 @@ static ssize_t textid_show(struct device *dev, struct device_attribute *attr, &text_id, sizeof(u32)); if (err) return err; - return sprintf(buf, "%u\n", text_id); } @@ -249,7 +244,6 @@ static ssize_t textid_store(struct device *dev, struct device_attribute *attr, if (kstrtou32(buf, 10, &text_id)) return -EINVAL; - err = visorchannel_write(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, installation_text_id), @@ -272,7 +266,6 @@ static ssize_t remaining_steps_show(struct device *dev, &remaining_steps, sizeof(u16)); if (err) return err; - return sprintf(buf, "%hu\n", remaining_steps); } @@ -285,7 +278,6 @@ static ssize_t remaining_steps_store(struct device *dev, if (kstrtou16(buf, 10, &remaining_steps)) return -EINVAL; - err = visorchannel_write(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, installation_remaining_steps), @@ -296,43 +288,6 @@ static ssize_t remaining_steps_store(struct device *dev, } static DEVICE_ATTR_RW(remaining_steps); -struct visor_busdev { - u32 bus_no; - u32 dev_no; -}; - -static int match_visorbus_dev_by_id(struct device *dev, void *data) -{ - struct visor_device *vdev = to_visor_device(dev); - struct visor_busdev *id = data; - - if ((vdev->chipset_bus_no == id->bus_no) && - (vdev->chipset_dev_no == id->dev_no)) - return 1; - - return 0; -} - -struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no, - struct visor_device *from) -{ - struct device *dev; - struct device *dev_start = NULL; - struct visor_device *vdev = NULL; - struct visor_busdev id = { - .bus_no = bus_no, - .dev_no = dev_no - }; - - if (from) - dev_start = &from->device; - dev = bus_find_device(&visorbus_type, dev_start, (void *)&id, - match_visorbus_dev_by_id); - if (dev) - vdev = to_visor_device(dev); - return vdev; -} - static void controlvm_init_response(struct controlvm_message *msg, struct controlvm_message_header *msg_hdr, int response) @@ -374,18 +329,13 @@ static int chipset_init(struct controlvm_message *inmsg) goto out_respond; } chipset_inited = 1; - /* * Set features to indicate we support parahotplug (if Command also - * supports it). + * supports it). Set the "reply" bit so Command knows this is a + * features-aware driver. */ features = inmsg->cmd.init_chipset.features & VISOR_CHIPSET_FEATURE_PARA_HOTPLUG; - - /* - * Set the "reply" bit so Command knows this is a features-aware - * driver. - */ features |= VISOR_CHIPSET_FEATURE_REPLY; out_respond: @@ -396,20 +346,17 @@ out_respond: } static int controlvm_respond(struct controlvm_message_header *msg_hdr, - int response, - struct visor_segment_state *state) + int response, struct visor_segment_state *state) { struct controlvm_message outmsg; controlvm_init_response(&outmsg, msg_hdr, response); if (outmsg.hdr.flags.test_message == 1) return -EINVAL; - if (state) { outmsg.cmd.device_change_state.state = *state; outmsg.cmd.device_change_state.flags.phys_device = 1; } - return visorchannel_signalinsert(chipset_dev->controlvm_channel, CONTROLVM_QUEUE_REQUEST, &outmsg); } @@ -435,13 +382,11 @@ static int save_crash_message(struct controlvm_message *msg, "failed to read message count\n"); return err; } - if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) { dev_err(&chipset_dev->acpi_device->dev, "invalid number of messages\n"); return -EIO; } - err = visorchannel_read(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, saved_crash_message_offset), @@ -451,13 +396,11 @@ static int save_crash_message(struct controlvm_message *msg, "failed to read offset\n"); return err; } - switch (cr_type) { case CRASH_DEV: local_crash_msg_offset += sizeof(struct controlvm_message); err = visorchannel_write(chipset_dev->controlvm_channel, - local_crash_msg_offset, - msg, + local_crash_msg_offset, msg, sizeof(struct controlvm_message)); if (err) { dev_err(&chipset_dev->acpi_device->dev, @@ -467,8 +410,7 @@ static int save_crash_message(struct controlvm_message *msg, break; case CRASH_BUS: err = visorchannel_write(chipset_dev->controlvm_channel, - local_crash_msg_offset, - msg, + local_crash_msg_offset, msg, sizeof(struct controlvm_message)); if (err) { dev_err(&chipset_dev->acpi_device->dev, @@ -488,33 +430,25 @@ static int controlvm_responder(enum controlvm_id cmd_id, struct controlvm_message_header *pending_msg_hdr, int response) { - if (!pending_msg_hdr) - return -EIO; - if (pending_msg_hdr->id != (u32)cmd_id) return -EINVAL; return controlvm_respond(pending_msg_hdr, response, NULL); } -static int device_changestate_responder( - enum controlvm_id cmd_id, - struct visor_device *p, int response, - struct visor_segment_state response_state) +static int device_changestate_responder(enum controlvm_id cmd_id, + struct visor_device *p, int response, + struct visor_segment_state state) { struct controlvm_message outmsg; - if (!p->pending_msg_hdr) - return -EIO; if (p->pending_msg_hdr->id != cmd_id) return -EINVAL; controlvm_init_response(&outmsg, p->pending_msg_hdr, response); - outmsg.cmd.device_change_state.bus_no = p->chipset_bus_no; outmsg.cmd.device_change_state.dev_no = p->chipset_dev_no; - outmsg.cmd.device_change_state.state = response_state; - + outmsg.cmd.device_change_state.state = state; return visorchannel_signalinsert(chipset_dev->controlvm_channel, CONTROLVM_QUEUE_REQUEST, &outmsg); } @@ -522,64 +456,55 @@ static int device_changestate_responder( static int visorbus_create(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - struct controlvm_message_header *pmsg_hdr = NULL; + struct controlvm_message_header *pmsg_hdr; u32 bus_no = cmd->create_bus.bus_no; struct visor_device *bus_info; struct visorchannel *visorchannel; int err; bus_info = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL); - if (bus_info && (bus_info->state.created == 1)) { + if (bus_info && bus_info->state.created == 1) { dev_err(&chipset_dev->acpi_device->dev, "failed %s: already exists\n", __func__); err = -EEXIST; goto err_respond; } - bus_info = kzalloc(sizeof(*bus_info), GFP_KERNEL); if (!bus_info) { err = -ENOMEM; goto err_respond; } - INIT_LIST_HEAD(&bus_info->list_all); bus_info->chipset_bus_no = bus_no; bus_info->chipset_dev_no = BUS_ROOT_DEVICE; - if (guid_equal(&cmd->create_bus.bus_inst_guid, &visor_siovm_guid)) { err = save_crash_message(inmsg, CRASH_BUS); if (err) goto err_free_bus_info; } - if (inmsg->hdr.flags.response_expected == 1) { - pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), - GFP_KERNEL); + pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL); if (!pmsg_hdr) { err = -ENOMEM; goto err_free_bus_info; } - memcpy(pmsg_hdr, &inmsg->hdr, sizeof(struct controlvm_message_header)); bus_info->pending_msg_hdr = pmsg_hdr; } - visorchannel = visorchannel_create(cmd->create_bus.channel_addr, GFP_KERNEL, - &cmd->create_bus.bus_data_type_guid); + &cmd->create_bus.bus_data_type_guid, + false); if (!visorchannel) { err = -ENOMEM; goto err_free_pending_msg; } - bus_info->visorchannel = visorchannel; - /* Response will be handled by visorbus_create_instance on success */ err = visorbus_create_instance(bus_info); if (err) goto err_destroy_channel; - return 0; err_destroy_channel: @@ -599,9 +524,8 @@ err_respond: static int visorbus_destroy(struct controlvm_message *inmsg) { - struct controlvm_message_packet *cmd = &inmsg->cmd; - struct controlvm_message_header *pmsg_hdr = NULL; - u32 bus_no = cmd->destroy_bus.bus_no; + struct controlvm_message_header *pmsg_hdr; + u32 bus_no = inmsg->cmd.destroy_bus.bus_no; struct visor_device *bus_info; int err; @@ -625,12 +549,10 @@ static int visorbus_destroy(struct controlvm_message *inmsg) err = -ENOMEM; goto err_respond; } - memcpy(pmsg_hdr, &inmsg->hdr, sizeof(struct controlvm_message_header)); bus_info->pending_msg_hdr = pmsg_hdr; } - /* Response will be handled by visorbus_remove_instance */ visorbus_remove_instance(bus_info); return 0; @@ -646,51 +568,33 @@ static const guid_t *parser_id_get(struct parser_context *ctx) return &ctx->data.id; } -static void *parser_string_get(struct parser_context *ctx) +static void *parser_string_get(u8 *pscan, int nscan) { - u8 *pscan; - unsigned long nscan; int value_length; void *value; - int i; - pscan = ctx->curr; - if (!pscan) - return NULL; - nscan = ctx->bytes_remaining; if (nscan == 0) return NULL; - for (i = 0, value_length = -1; i < nscan; i++) - if (pscan[i] == '\0') { - value_length = i; - break; - } - /* '\0' was not included in the length */ - if (value_length < 0) - value_length = nscan; - - value = kmalloc(value_length + 1, GFP_KERNEL); + value_length = strnlen(pscan, nscan); + value = kzalloc(value_length + 1, GFP_KERNEL); if (!value) return NULL; if (value_length > 0) memcpy(value, pscan, value_length); - ((u8 *)(value))[value_length] = '\0'; return value; } static void *parser_name_get(struct parser_context *ctx) { - struct visor_controlvm_parameters_header *phdr = NULL; + struct visor_controlvm_parameters_header *phdr; phdr = &ctx->data; - if (phdr->name_offset + phdr->name_length > ctx->param_bytes) return NULL; - ctx->curr = (char *)&phdr + phdr->name_offset; ctx->bytes_remaining = phdr->name_length; - return parser_string_get(ctx); + return parser_string_get(ctx->curr, phdr->name_length); } static int visorbus_configure(struct controlvm_message *inmsg, @@ -715,20 +619,16 @@ static int visorbus_configure(struct controlvm_message *inmsg, err = -EIO; goto err_respond; } - - err = visorchannel_set_clientpartition - (bus_info->visorchannel, - cmd->configure_bus.guest_handle); + err = visorchannel_set_clientpartition(bus_info->visorchannel, + cmd->configure_bus.guest_handle); if (err) goto err_respond; - if (parser_ctx) { const guid_t *partition_guid = parser_id_get(parser_ctx); guid_copy(&bus_info->partition_guid, partition_guid); bus_info->name = parser_name_get(parser_ctx); } - if (inmsg->hdr.flags.response_expected == 1) controlvm_responder(inmsg->hdr.id, &inmsg->hdr, err); return 0; @@ -744,10 +644,10 @@ err_respond: static int visorbus_device_create(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - struct controlvm_message_header *pmsg_hdr = NULL; + struct controlvm_message_header *pmsg_hdr; u32 bus_no = cmd->create_device.bus_no; u32 dev_no = cmd->create_device.dev_no; - struct visor_device *dev_info = NULL; + struct visor_device *dev_info; struct visor_device *bus_info; struct visorchannel *visorchannel; int err; @@ -765,9 +665,8 @@ static int visorbus_device_create(struct controlvm_message *inmsg) err = -EINVAL; goto err_respond; } - dev_info = visorbus_get_device_by_id(bus_no, dev_no, NULL); - if (dev_info && (dev_info->state.created == 1)) { + if (dev_info && dev_info->state.created == 1) { dev_err(&chipset_dev->acpi_device->dev, "failed to get bus by id: %d/%d\n", bus_no, dev_no); err = -EEXIST; @@ -779,16 +678,14 @@ static int visorbus_device_create(struct controlvm_message *inmsg) err = -ENOMEM; goto err_respond; } - dev_info->chipset_bus_no = bus_no; dev_info->chipset_dev_no = dev_no; guid_copy(&dev_info->inst, &cmd->create_device.dev_inst_guid); dev_info->device.parent = &bus_info->device; - - visorchannel = - visorchannel_create_with_lock(cmd->create_device.channel_addr, - GFP_KERNEL, - &cmd->create_device.data_type_guid); + visorchannel = visorchannel_create(cmd->create_device.channel_addr, + GFP_KERNEL, + &cmd->create_device.data_type_guid, + true); if (!visorchannel) { dev_err(&chipset_dev->acpi_device->dev, "failed to create visorchannel: %d/%d\n", @@ -797,20 +694,20 @@ static int visorbus_device_create(struct controlvm_message *inmsg) goto err_free_dev_info; } dev_info->visorchannel = visorchannel; - guid_copy(&dev_info->channel_type_guid, &cmd->create_device.data_type_guid); - if (guid_equal(&cmd->create_device.data_type_guid, &visor_vhba_channel_guid)) { + guid_copy(&dev_info->channel_type_guid, + &cmd->create_device.data_type_guid); + if (guid_equal(&cmd->create_device.data_type_guid, + &visor_vhba_channel_guid)) { err = save_crash_message(inmsg, CRASH_DEV); if (err) goto err_destroy_visorchannel; } - if (inmsg->hdr.flags.response_expected == 1) { pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL); if (!pmsg_hdr) { err = -ENOMEM; goto err_destroy_visorchannel; } - memcpy(pmsg_hdr, &inmsg->hdr, sizeof(struct controlvm_message_header)); dev_info->pending_msg_hdr = pmsg_hdr; @@ -837,7 +734,7 @@ err_respond: static int visorbus_device_changestate(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - struct controlvm_message_header *pmsg_hdr = NULL; + struct controlvm_message_header *pmsg_hdr; u32 bus_no = cmd->device_change_state.bus_no; u32 dev_no = cmd->device_change_state.dev_no; struct visor_segment_state state = cmd->device_change_state.state; @@ -858,18 +755,17 @@ static int visorbus_device_changestate(struct controlvm_message *inmsg) err = -EIO; goto err_respond; } + if (inmsg->hdr.flags.response_expected == 1) { pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL); if (!pmsg_hdr) { err = -ENOMEM; goto err_respond; } - memcpy(pmsg_hdr, &inmsg->hdr, sizeof(struct controlvm_message_header)); dev_info->pending_msg_hdr = pmsg_hdr; } - if (state.alive == segment_state_running.alive && state.operating == segment_state_running.operating) /* Response will be sent from visorchipset_device_resume */ @@ -884,7 +780,6 @@ static int visorbus_device_changestate(struct controlvm_message *inmsg) err = visorchipset_device_pause(dev_info); if (err) goto err_respond; - return 0; err_respond: @@ -897,7 +792,7 @@ err_respond: static int visorbus_device_destroy(struct controlvm_message *inmsg) { struct controlvm_message_packet *cmd = &inmsg->cmd; - struct controlvm_message_header *pmsg_hdr = NULL; + struct controlvm_message_header *pmsg_hdr; u32 bus_no = cmd->destroy_device.bus_no; u32 dev_no = cmd->destroy_device.dev_no; struct visor_device *dev_info; @@ -928,7 +823,6 @@ static int visorbus_device_destroy(struct controlvm_message *inmsg) sizeof(struct controlvm_message_header)); dev_info->pending_msg_hdr = pmsg_hdr; } - kfree(dev_info->name); remove_visor_device(dev_info); return 0; @@ -995,11 +889,9 @@ static struct parahotplug_request *parahotplug_request_create( req = kmalloc(sizeof(*req), GFP_KERNEL); if (!req) return NULL; - req->id = parahotplug_next_id(); req->expiration = parahotplug_next_expiration(); req->msg = *msg; - return req; } @@ -1031,13 +923,12 @@ static int parahotplug_request_complete(int id, u16 active) { struct list_head *pos; struct list_head *tmp; + struct parahotplug_request *req; spin_lock(¶hotplug_request_list_lock); - /* Look for a request matching "id". */ list_for_each_safe(pos, tmp, ¶hotplug_request_list) { - struct parahotplug_request *req = - list_entry(pos, struct parahotplug_request, list); + req = list_entry(pos, struct parahotplug_request, list); if (req->id == id) { /* * Found a match. Remove it from the list and @@ -1054,7 +945,6 @@ static int parahotplug_request_complete(int id, u16 active) return 0; } } - spin_unlock(¶hotplug_request_list_lock); return -EINVAL; } @@ -1081,7 +971,6 @@ static ssize_t devicedisabled_store(struct device *dev, if (kstrtouint(buf, 10, &id)) return -EINVAL; - err = parahotplug_request_complete(id, 0); if (err < 0) return err; @@ -1110,7 +999,6 @@ static ssize_t deviceenabled_store(struct device *dev, if (kstrtouint(buf, 10, &id)) return -EINVAL; - parahotplug_request_complete(id, 1); return count; } @@ -1158,9 +1046,9 @@ static int parahotplug_request_kickoff(struct parahotplug_request *req) { struct controlvm_message_packet *cmd = &req->msg.cmd; char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40], - env_func[40]; - char *envp[] = { - env_cmd, env_id, env_state, env_bus, env_dev, env_func, NULL + env_func[40]; + char *envp[] = { env_cmd, env_id, env_state, env_bus, env_dev, + env_func, NULL }; sprintf(env_cmd, "VISOR_PARAHOTPLUG=1"); @@ -1173,7 +1061,6 @@ static int parahotplug_request_kickoff(struct parahotplug_request *req) cmd->device_change_state.dev_no >> 3); sprintf(env_func, "VISOR_PARAHOTPLUG_FUNCTION=%d", cmd->device_change_state.dev_no & 0x7); - return kobject_uevent_env(&chipset_dev->acpi_device->dev.kobj, KOBJ_CHANGE, envp); } @@ -1191,7 +1078,6 @@ static int parahotplug_process_message(struct controlvm_message *inmsg) req = parahotplug_request_create(inmsg); if (!req) return -ENOMEM; - /* * For enable messages, just respond with success right away, we don't * need to wait to see if the enable was successful. @@ -1205,7 +1091,6 @@ static int parahotplug_process_message(struct controlvm_message *inmsg) parahotplug_request_destroy(req); return 0; } - /* * For disable messages, add the request to the request list before * kicking off the udev script. It won't get responded to until the @@ -1214,7 +1099,6 @@ static int parahotplug_process_message(struct controlvm_message *inmsg) spin_lock(¶hotplug_request_list_lock); list_add_tail(&req->list, ¶hotplug_request_list); spin_unlock(¶hotplug_request_list_lock); - err = parahotplug_request_kickoff(req); if (err) goto err_respond; @@ -1237,12 +1121,9 @@ static int chipset_ready_uevent(struct controlvm_message_header *msg_hdr) { int res; - res = kobject_uevent(&chipset_dev->acpi_device->dev.kobj, - KOBJ_ONLINE); - + res = kobject_uevent(&chipset_dev->acpi_device->dev.kobj, KOBJ_ONLINE); if (msg_hdr->flags.response_expected) controlvm_respond(msg_hdr, res, NULL); - return res; } @@ -1262,10 +1143,8 @@ static int chipset_selftest_uevent(struct controlvm_message_header *msg_hdr) sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1); res = kobject_uevent_env(&chipset_dev->acpi_device->dev.kobj, KOBJ_CHANGE, envp); - if (msg_hdr->flags.response_expected) controlvm_respond(msg_hdr, res, NULL); - return res; } @@ -1279,11 +1158,10 @@ static int chipset_selftest_uevent(struct controlvm_message_header *msg_hdr) static int chipset_notready_uevent(struct controlvm_message_header *msg_hdr) { int res = kobject_uevent(&chipset_dev->acpi_device->dev.kobj, - KOBJ_OFFLINE); + KOBJ_OFFLINE); if (msg_hdr->flags.response_expected) controlvm_respond(msg_hdr, res, NULL); - return res; } @@ -1296,17 +1174,15 @@ static int unisys_vmcall(unsigned long tuple, unsigned long param) reg_ebx = param & 0xFFFFFFFF; reg_ecx = param >> 32; - cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx); if (!(cpuid_ecx & 0x80000000)) return -EPERM; - __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) : - "a"(tuple), "b"(reg_ebx), "c"(reg_ecx)); + "a"(tuple), "b"(reg_ebx), "c"(reg_ecx)); if (result) goto error; - return 0; + /* Need to convert from VMCALL error codes to Linux */ error: switch (result) { @@ -1330,8 +1206,8 @@ static int controlvm_channel_create(struct visorchipset_device *dev) if (err) return err; addr = dev->controlvm_params.address; - chan = visorchannel_create_with_lock(addr, GFP_KERNEL, - &visor_controlvm_channel_guid); + chan = visorchannel_create(addr, GFP_KERNEL, + &visor_controlvm_channel_guid, true); if (!chan) return -ENOMEM; dev->controlvm_channel = chan; @@ -1350,9 +1226,7 @@ static void setup_crash_devices_work_queue(struct work_struct *work) msg.hdr.id = CONTROLVM_CHIPSET_INIT; msg.cmd.init_chipset.bus_count = 23; msg.cmd.init_chipset.switch_count = 0; - chipset_init(&msg); - /* get saved message count */ if (visorchannel_read(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, @@ -1362,13 +1236,10 @@ static void setup_crash_devices_work_queue(struct work_struct *work) "failed to read channel\n"); return; } - if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) { - dev_err(&chipset_dev->acpi_device->dev, - "invalid count\n"); + dev_err(&chipset_dev->acpi_device->dev, "invalid count\n"); return; } - /* get saved crash message offset */ if (visorchannel_read(chipset_dev->controlvm_channel, offsetof(struct visor_controlvm_channel, @@ -1378,7 +1249,6 @@ static void setup_crash_devices_work_queue(struct work_struct *work) "failed to read channel\n"); return; } - /* read create device message for storage bus offset */ if (visorchannel_read(chipset_dev->controlvm_channel, local_crash_msg_offset, @@ -1388,7 +1258,6 @@ static void setup_crash_devices_work_queue(struct work_struct *work) "failed to read channel\n"); return; } - /* read create device message for storage device */ if (visorchannel_read(chipset_dev->controlvm_channel, local_crash_msg_offset + @@ -1399,7 +1268,6 @@ static void setup_crash_devices_work_queue(struct work_struct *work) "failed to read channel\n"); return; } - /* reuse IOVM create bus message */ if (!local_crash_bus_msg.cmd.create_bus.channel_addr) { dev_err(&chipset_dev->acpi_device->dev, @@ -1407,7 +1275,6 @@ static void setup_crash_devices_work_queue(struct work_struct *work) return; } visorbus_create(&local_crash_bus_msg); - /* reuse create device message for storage device */ if (!local_crash_dev_msg.cmd.create_device.channel_addr) { dev_err(&chipset_dev->acpi_device->dev, @@ -1420,8 +1287,10 @@ static void setup_crash_devices_work_queue(struct work_struct *work) void visorbus_response(struct visor_device *bus_info, int response, int controlvm_id) { - controlvm_responder(controlvm_id, bus_info->pending_msg_hdr, response); + if (!bus_info->pending_msg_hdr) + return; + controlvm_responder(controlvm_id, bus_info->pending_msg_hdr, response); kfree(bus_info->pending_msg_hdr); bus_info->pending_msg_hdr = NULL; } @@ -1430,9 +1299,11 @@ void visorbus_device_changestate_response(struct visor_device *dev_info, int response, struct visor_segment_state state) { - device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, - dev_info, response, state); + if (!dev_info->pending_msg_hdr) + return; + device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, dev_info, + response, state); kfree(dev_info->pending_msg_hdr); dev_info->pending_msg_hdr = NULL; } @@ -1451,12 +1322,11 @@ static struct parser_context *parser_init_stream(u64 addr, u32 bytes, void *mapping; *retry = false; - /* alloc an extra byte to ensure payload is \0 terminated */ allocbytes = bytes + 1 + (sizeof(struct parser_context) - sizeof(struct visor_controlvm_parameters_header)); - if ((chipset_dev->controlvm_payload_bytes_buffered + bytes) - > MAX_CONTROLVM_PAYLOAD_BYTES) { + if ((chipset_dev->controlvm_payload_bytes_buffered + bytes) > + MAX_CONTROLVM_PAYLOAD_BYTES) { *retry = true; return NULL; } @@ -1465,7 +1335,6 @@ static struct parser_context *parser_init_stream(u64 addr, u32 bytes, *retry = true; return NULL; } - ctx->allocbytes = allocbytes; ctx->param_bytes = bytes; mapping = memremap(addr, bytes, MEMREMAP_WB); @@ -1475,7 +1344,6 @@ static struct parser_context *parser_init_stream(u64 addr, u32 bytes, memunmap(mapping); ctx->byte_stream = true; chipset_dev->controlvm_payload_bytes_buffered += ctx->param_bytes; - return ctx; err_finish_ctx: @@ -1508,14 +1376,13 @@ static int handle_command(struct controlvm_message inmsg, u64 channel_addr) /* create parsing context if necessary */ parm_addr = channel_addr + inmsg.hdr.payload_vm_offset; parm_bytes = inmsg.hdr.payload_bytes; - /* * Parameter and channel addresses within test messages actually lie * within our OS-controlled memory. We need to know that, because it * makes a difference in how we compute the virtual address. */ if (parm_bytes) { - bool retry = false; + bool retry; parser_ctx = parser_init_stream(parm_addr, parm_bytes, &retry); if (!parser_ctx && retry) @@ -1526,7 +1393,6 @@ static int handle_command(struct controlvm_message inmsg, u64 channel_addr) CONTROLVM_QUEUE_ACK, &ackmsg); if (err) return err; - switch (inmsg.hdr.id) { case CONTROLVM_CHIPSET_INIT: err = chipset_init(&inmsg); @@ -1580,7 +1446,6 @@ static int handle_command(struct controlvm_message inmsg, u64 channel_addr) -CONTROLVM_RESP_ID_UNKNOWN, NULL); break; } - if (parser_ctx) { parser_done(parser_ctx); parser_ctx = NULL; @@ -1599,14 +1464,13 @@ static int handle_command(struct controlvm_message inmsg, u64 channel_addr) static int read_controlvm_event(struct controlvm_message *msg) { int err = visorchannel_signalremove(chipset_dev->controlvm_channel, - CONTROLVM_QUEUE_EVENT, msg); + CONTROLVM_QUEUE_EVENT, msg); + if (err) return err; - /* got a message */ if (msg->hdr.flags.test_message == 1) return -EINVAL; - return 0; } @@ -1620,14 +1484,12 @@ static void parahotplug_process_list(void) struct list_head *tmp; spin_lock(¶hotplug_request_list_lock); - list_for_each_safe(pos, tmp, ¶hotplug_request_list) { struct parahotplug_request *req = list_entry(pos, struct parahotplug_request, list); if (!time_after_eq(jiffies, req->expiration)) continue; - list_del(pos); if (req->msg.hdr.flags.response_expected) controlvm_respond( @@ -1636,7 +1498,6 @@ static void parahotplug_process_list(void) &req->msg.cmd.device_change_state.state); parahotplug_request_destroy(req); } - spin_unlock(¶hotplug_request_list_lock); } @@ -1652,10 +1513,8 @@ static void controlvm_periodic_work(struct work_struct *work) CONTROLVM_QUEUE_RESPONSE, &inmsg); } while ((!err) && (++count < CONTROLVM_MESSAGE_MAX)); - if (err != -EAGAIN) goto schedule_out; - if (chipset_dev->controlvm_pending_msg_valid) { /* * we throttled processing of a prior msg, so try to process @@ -1667,7 +1526,6 @@ static void controlvm_periodic_work(struct work_struct *work) } else { err = read_controlvm_event(&inmsg); } - while (!err) { chipset_dev->most_recent_message_jiffies = jiffies; err = handle_command(inmsg, @@ -1681,7 +1539,6 @@ static void controlvm_periodic_work(struct work_struct *work) err = read_controlvm_event(&inmsg); } - /* parahotplug_worker */ parahotplug_process_list(); @@ -1697,17 +1554,12 @@ schedule_out: * it's been longer than MIN_IDLE_SECONDS since we processed * our last controlvm message; slow down the polling */ - if (chipset_dev->poll_jiffies != - POLLJIFFIES_CONTROLVMCHANNEL_SLOW) - chipset_dev->poll_jiffies = - POLLJIFFIES_CONTROLVMCHANNEL_SLOW; + if (chipset_dev->poll_jiffies != POLLJIFFIES_CONTROLVM_SLOW) + chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVM_SLOW; } else { - if (chipset_dev->poll_jiffies != - POLLJIFFIES_CONTROLVMCHANNEL_FAST) - chipset_dev->poll_jiffies = - POLLJIFFIES_CONTROLVMCHANNEL_FAST; + if (chipset_dev->poll_jiffies != POLLJIFFIES_CONTROLVM_FAST) + chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVM_FAST; } - schedule_delayed_work(&chipset_dev->periodic_controlvm_work, chipset_dev->poll_jiffies); } @@ -1720,20 +1572,16 @@ static int visorchipset_init(struct acpi_device *acpi_device) chipset_dev = kzalloc(sizeof(*chipset_dev), GFP_KERNEL); if (!chipset_dev) goto error; - err = controlvm_channel_create(chipset_dev); if (err) goto error_free_chipset_dev; - acpi_device->driver_data = chipset_dev; chipset_dev->acpi_device = acpi_device; - chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; - + chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVM_FAST; err = sysfs_create_groups(&chipset_dev->acpi_device->dev.kobj, visorchipset_dev_groups); if (err < 0) goto error_destroy_channel; - controlvm_channel = chipset_dev->controlvm_channel; if (!visor_check_channel(visorchannel_get_header(controlvm_channel), &chipset_dev->acpi_device->dev, @@ -1743,7 +1591,6 @@ static int visorchipset_init(struct acpi_device *acpi_device) VISOR_CONTROLVM_CHANNEL_VERSIONID, VISOR_CHANNEL_SIGNATURE)) goto error_delete_groups; - /* if booting in a crash kernel */ if (is_kdump_kernel()) INIT_DELAYED_WORK(&chipset_dev->periodic_controlvm_work, @@ -1751,16 +1598,13 @@ static int visorchipset_init(struct acpi_device *acpi_device) else INIT_DELAYED_WORK(&chipset_dev->periodic_controlvm_work, controlvm_periodic_work); - chipset_dev->most_recent_message_jiffies = jiffies; - chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; + chipset_dev->poll_jiffies = POLLJIFFIES_CONTROLVM_FAST; schedule_delayed_work(&chipset_dev->periodic_controlvm_work, chipset_dev->poll_jiffies); - err = visorbus_init(); if (err < 0) goto error_cancel_work; - return 0; error_cancel_work: @@ -1787,10 +1631,8 @@ static int visorchipset_exit(struct acpi_device *acpi_device) cancel_delayed_work_sync(&chipset_dev->periodic_controlvm_work); sysfs_remove_groups(&chipset_dev->acpi_device->dev.kobj, visorchipset_dev_groups); - visorchannel_destroy(chipset_dev->controlvm_channel); kfree(chipset_dev); - return 0; } @@ -1832,11 +1674,9 @@ static int __init init_unisys(void) if (!visorutil_spar_detect()) return -ENODEV; - result = acpi_bus_register_driver(&unisys_acpi_driver); if (result) return -ENODEV; - pr_info("Unisys Visorchipset Driver Loaded.\n"); return 0; }; diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 419dba89af06..0bcd3acb7b0c 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -17,6 +17,7 @@ #include <linux/debugfs.h> #include <linux/kthread.h> #include <linux/idr.h> +#include <linux/module.h> #include <linux/seq_file.h> #include <scsi/scsi.h> #include <scsi/scsi_host.h> @@ -39,7 +40,8 @@ static struct visor_channeltype_descriptor visorhba_channel_types[] = { /* Note that the only channel type we expect to be reported by the * bus driver is the VISOR_VHBA channel. */ - { VISOR_VHBA_CHANNEL_GUID, "sparvhba" }, + { VISOR_VHBA_CHANNEL_GUID, "sparvhba", sizeof(struct channel_header), + VISOR_VHBA_CHANNEL_VERSIONID }, {} }; @@ -818,9 +820,9 @@ static void do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, memcpy(scsicmd->sense_buffer, cmdrsp->scsi.sensebuf, MAX_SENSE_SIZE); /* Do not log errors for disk-not-present inquiries */ - if ((cmdrsp->scsi.cmnd[0] == INQUIRY) && + if (cmdrsp->scsi.cmnd[0] == INQUIRY && (host_byte(cmdrsp->scsi.linuxstat) == DID_NO_CONNECT) && - (cmdrsp->scsi.addlstat == ADDL_SEL_TIMEOUT)) + cmdrsp->scsi.addlstat == ADDL_SEL_TIMEOUT) return; /* Okay see what our error_count is here.... */ vdisk = scsidev->hostdata; @@ -868,8 +870,8 @@ static void do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct visordisk_info *vdisk; scsidev = scsicmd->device; - if ((cmdrsp->scsi.cmnd[0] == INQUIRY) && - (cmdrsp->scsi.bufflen >= MIN_INQUIRY_RESULT_LEN)) { + if (cmdrsp->scsi.cmnd[0] == INQUIRY && + cmdrsp->scsi.bufflen >= MIN_INQUIRY_RESULT_LEN) { if (cmdrsp->scsi.no_disk_result == 0) return; diff --git a/drivers/staging/unisys/visorinput/visorinput.c b/drivers/staging/unisys/visorinput/visorinput.c index 9d8cbc52de8b..450f003743c0 100644 --- a/drivers/staging/unisys/visorinput/visorinput.c +++ b/drivers/staging/unisys/visorinput/visorinput.c @@ -23,6 +23,7 @@ #include <linux/fb.h> #include <linux/input.h> #include <linux/kernel.h> +#include <linux/module.h> #include <linux/uuid.h> #include "visorbus.h" @@ -711,8 +712,9 @@ out: /* GUIDS for all channel types supported by this driver. */ static struct visor_channeltype_descriptor visorinput_channel_types[] = { - { VISOR_KEYBOARD_CHANNEL_GUID, "keyboard"}, - { VISOR_MOUSE_CHANNEL_GUID, "mouse"}, + { VISOR_KEYBOARD_CHANNEL_GUID, "keyboard", + sizeof(struct channel_header), 0 }, + { VISOR_MOUSE_CHANNEL_GUID, "mouse", sizeof(struct channel_header), 0 }, {} }; diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c index dc390eae2960..735d7e5fa86b 100644 --- a/drivers/staging/unisys/visornic/visornic_main.c +++ b/drivers/staging/unisys/visornic/visornic_main.c @@ -20,6 +20,7 @@ #include <linux/debugfs.h> #include <linux/etherdevice.h> +#include <linux/module.h> #include <linux/netdevice.h> #include <linux/kthread.h> #include <linux/skbuff.h> @@ -48,7 +49,8 @@ static struct visor_channeltype_descriptor visornic_channel_types[] = { /* Note that the only channel type we expect to be reported by the * bus driver is the VISOR_VNIC channel. */ - { VISOR_VNIC_CHANNEL_GUID, "ultravnic" }, + { VISOR_VNIC_CHANNEL_GUID, "ultravnic", sizeof(struct channel_header), + VISOR_VNIC_CHANNEL_VERSIONID }, {} }; MODULE_DEVICE_TABLE(visorbus, visornic_channel_types); @@ -899,7 +901,7 @@ static int visornic_xmit(struct sk_buff *skb, struct net_device *netdev) return NETDEV_TX_OK; } - if ((len < ETH_MIN_PACKET_SIZE) && + if (len < ETH_MIN_PACKET_SIZE && ((skb_end_pointer(skb) - skb->data) >= ETH_MIN_PACKET_SIZE)) { /* pad the packet out to minimum size */ padlen = ETH_MIN_PACKET_SIZE - len; @@ -1450,7 +1452,7 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf, rcu_read_lock(); for_each_netdev_rcu(current->nsproxy->net_ns, dev) { /* Only consider netdevs that are visornic, and are open */ - if ((dev->netdev_ops != &visornic_dev_ops) || + if (dev->netdev_ops != &visornic_dev_ops || (!netif_queue_stopped(dev))) continue; @@ -1680,7 +1682,7 @@ static void service_resp_queue(struct uiscmdrsp *cmdrsp, /* only call queue wake if we stopped it */ netdev = ((struct sk_buff *)cmdrsp->net.buf)->dev; /* ASSERT netdev == vnicinfo->netdev; */ - if ((netdev == devdata->netdev) && + if (netdev == devdata->netdev && netif_queue_stopped(netdev)) { /* check if we have crossed the lower watermark * for netif_wake_queue() diff --git a/drivers/staging/vc04_services/Kconfig b/drivers/staging/vc04_services/Kconfig index 9e2763663ab8..f5aaf7d629f0 100644 --- a/drivers/staging/vc04_services/Kconfig +++ b/drivers/staging/vc04_services/Kconfig @@ -19,18 +19,6 @@ config BCM2835_VCHIQ Defaults to Y when the Broadcom Videocore services are included in the build, N otherwise. -if BCM2835_VCHIQ - -config BCM2835_VCHIQ_SUPPORT_MEMDUMP - bool "Support dumping memory contents to debug log" - help - BCM2835 VCHIQ supports the ability to dump the - contents of memory to the debug log. This - is typically only needed by diagnostic tools used - to debug issues with VideoCore. - -endif - source "drivers/staging/vc04_services/bcm2835-audio/Kconfig" source "drivers/staging/vc04_services/bcm2835-camera/Kconfig" diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c index 94654c0c7bba..7e68b3e28246 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c @@ -65,7 +65,6 @@ void bcm2835_playback_fifo(struct bcm2835_alsa_stream *alsa_stream) unsigned int consumed = 0; int new_period = 0; - audio_info("alsa_stream=%p substream=%p\n", alsa_stream, alsa_stream ? alsa_stream->substream : 0); @@ -111,7 +110,6 @@ static int snd_bcm2835_playback_open_generic( int idx; int err; - if (mutex_lock_interruptible(&chip->audio_mutex)) { audio_error("Interrupted whilst waiting for lock\n"); return -EINTR; @@ -184,7 +182,6 @@ static int snd_bcm2835_playback_open_generic( out: mutex_unlock(&chip->audio_mutex); - return err; } @@ -207,7 +204,6 @@ static int snd_bcm2835_playback_close(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime; struct bcm2835_alsa_stream *alsa_stream; - chip = snd_pcm_substream_chip(substream); if (mutex_lock_interruptible(&chip->audio_mutex)) { audio_error("Interrupted whilst waiting for lock\n"); @@ -259,7 +255,6 @@ static int snd_bcm2835_pcm_hw_params(struct snd_pcm_substream *substream, struct bcm2835_alsa_stream *alsa_stream = runtime->private_data; int err; - err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); if (err < 0) { audio_error @@ -289,7 +284,6 @@ static int snd_bcm2835_pcm_prepare(struct snd_pcm_substream *substream) int channels; int err; - if (mutex_lock_interruptible(&chip->audio_mutex)) return -EINTR; @@ -307,13 +301,11 @@ static int snd_bcm2835_pcm_prepare(struct snd_pcm_substream *substream) if (err < 0) audio_error(" error setting hw params\n"); - bcm2835_audio_setup(alsa_stream); /* in preparation of the stream, set the controls (volume level) of the stream */ bcm2835_audio_set_ctls(alsa_stream->chip); - memset(&alsa_stream->pcm_indirect, 0, sizeof(alsa_stream->pcm_indirect)); alsa_stream->pcm_indirect.hw_buffer_size = @@ -364,7 +356,6 @@ static int snd_bcm2835_pcm_trigger(struct snd_pcm_substream *substream, int cmd) struct bcm2835_alsa_stream *alsa_stream = runtime->private_data; int err = 0; - switch (cmd) { case SNDRV_PCM_TRIGGER_START: audio_debug("bcm2835_AUDIO_TRIGGER_START running=%d\n", @@ -416,7 +407,6 @@ snd_bcm2835_pcm_pointer(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct bcm2835_alsa_stream *alsa_stream = runtime->private_data; - audio_debug("pcm_pointer... (%d) hwptr=%d appl=%d pos=%d\n", 0, frames_to_bytes(runtime, runtime->status->hw_ptr), frames_to_bytes(runtime, runtime->control->appl_ptr), @@ -493,7 +483,6 @@ int snd_bcm2835_new_pcm(struct bcm2835_chip *chip, u32 numchannels) snd_bcm2835_playback_hw.buffer_bytes_max, snd_bcm2835_playback_hw.buffer_bytes_max); - out: mutex_unlock(&chip->audio_mutex); diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 5f3d8f2339e3..7469c9bd19be 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -337,7 +337,6 @@ static int vc_vchi_audio_deinit(struct bcm2835_audio_instance *instance) { unsigned int i; - if (!instance) { LOG_ERR("%s: invalid handle %p\n", __func__, instance); @@ -369,7 +368,6 @@ static int vc_vchi_audio_deinit(struct bcm2835_audio_instance *instance) kfree(instance); - return 0; } @@ -382,7 +380,6 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream (struct bcm2835_audio_instance *)alsa_stream->instance; int ret; - LOG_INFO("%s: start\n", __func__); BUG_ON(instance); if (instance) { @@ -443,7 +440,6 @@ int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream) int status; int ret; - my_workqueue_init(alsa_stream); ret = bcm2835_audio_open_connection(alsa_stream); @@ -491,7 +487,6 @@ static int bcm2835_audio_set_ctls_chan(struct bcm2835_alsa_stream *alsa_stream, int status; int ret; - LOG_INFO(" Setting ALSA dest(%d), volume(%d)\n", chip->dest, chip->volume); @@ -575,7 +570,6 @@ int bcm2835_audio_set_params(struct bcm2835_alsa_stream *alsa_stream, int status; int ret; - LOG_INFO(" Setting ALSA channels(%d), samplerate(%d), bits-per-sample(%d)\n", channels, samplerate, bps); @@ -636,7 +630,6 @@ unlock: int bcm2835_audio_setup(struct bcm2835_alsa_stream *alsa_stream) { - return 0; } @@ -647,7 +640,6 @@ static int bcm2835_audio_start_worker(struct bcm2835_alsa_stream *alsa_stream) int status; int ret; - if (mutex_lock_interruptible(&instance->vchi_mutex)) { LOG_DBG("Interrupted whilst waiting for lock on (%d)\n", instance->num_connections); @@ -684,7 +676,6 @@ static int bcm2835_audio_stop_worker(struct bcm2835_alsa_stream *alsa_stream) int status; int ret; - if (mutex_lock_interruptible(&instance->vchi_mutex)) { LOG_DBG("Interrupted whilst waiting for lock on (%d)\n", instance->num_connections); @@ -722,7 +713,6 @@ int bcm2835_audio_close(struct bcm2835_alsa_stream *alsa_stream) int status; int ret; - my_workqueue_quit(alsa_stream); if (mutex_lock_interruptible(&instance->vchi_mutex)) { @@ -780,7 +770,6 @@ static int bcm2835_audio_write_worker(struct bcm2835_alsa_stream *alsa_stream, int status; int ret; - LOG_INFO(" Writing %d bytes from %p\n", count, src); if (mutex_lock_interruptible(&instance->vchi_mutex)) { diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h index 379604d3554e..f1e43e45fd67 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h @@ -123,8 +123,6 @@ struct bcm2835_alsa_stream { struct snd_pcm_indirect pcm_indirect; spinlock_t lock; - volatile unsigned int control; - volatile unsigned int status; int open; int running; diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h index 52cdf4da1b47..5a1b2a7d8eb0 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h @@ -70,7 +70,7 @@ enum mmal_msg_type { /* port action request messages differ depending on the action type */ enum mmal_msg_port_action_type { - MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unkown action */ + 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 */ @@ -217,36 +217,36 @@ struct mmal_msg_port_action_reply { #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 (1<<0) +#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 (1<<1) +#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 (1<<2) +#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 (1<<3) +#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 (1<<4) +#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 (1<<5) +#define MMAL_BUFFER_HEADER_FLAG_CONFIG BIT(5) /** Signals an encrypted payload */ -#define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED (1<<6) +#define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED BIT(6) /** Signals a buffer containing side information */ -#define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO (1<<7) +#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 (1<<8) +#define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT BIT(8) /** Signals a buffer which contains data known to be corrupted */ -#define MMAL_BUFFER_HEADER_FLAG_CORRUPTED (1<<9) +#define MMAL_BUFFER_HEADER_FLAG_CORRUPTED BIT(9) /** Signals that a buffer failed to be transmitted */ -#define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED (1<<10) +#define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED BIT(10) struct mmal_driver_buffer { u32 magic; diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index 4360db6d4392..6ea7fb0ea50e 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -1963,7 +1963,7 @@ int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance) status = vchi_service_close(instance->handle); if (status != 0) - pr_err("mmal-vchiq: VCHIQ close failed"); + pr_err("mmal-vchiq: VCHIQ close failed\n"); mutex_unlock(&instance->vchiq_mutex); diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h index 63db053532bf..db39900c9d91 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h @@ -130,7 +130,7 @@ int vchiq_mmal_component_disable( /* enable a mmal port * * enables a port and if a buffer callback provided enque buffer - * headers as apropriate for the port. + * headers as appropriate for the port. */ int vchiq_mmal_port_enable( struct vchiq_mmal_instance *instance, diff --git a/drivers/staging/vc04_services/interface/vchi/connections/connection.h b/drivers/staging/vc04_services/interface/vchi/connections/connection.h index e793cdf2847c..67c84386c65a 100644 --- a/drivers/staging/vc04_services/interface/vchi/connections/connection.h +++ b/drivers/staging/vc04_services/interface/vchi/connections/connection.h @@ -54,7 +54,6 @@ typedef struct opaque_vchi_connection_info_t VCHI_CONNECTION_STATE_T; typedef struct vchi_connection_t VCHI_CONNECTION_T; - /****************************************************************************** API *****************************************************************************/ @@ -212,7 +211,6 @@ typedef void * (*VCHI_BUFFER_ALLOCATE)(VCHI_CONNECTION_SERVICE_HANDLE_T service_ // free memory allocated by buffer_allocate typedef void (*VCHI_BUFFER_FREE)(VCHI_CONNECTION_SERVICE_HANDLE_T service_handle, void * address); - /****************************************************************************** System driver struct *****************************************************************************/ @@ -321,7 +319,6 @@ struct vchi_connection_t { #endif }; - #endif /* CONNECTION_H_ */ /****************************** End of file **********************************/ diff --git a/drivers/staging/vc04_services/interface/vchi/message_drivers/message.h b/drivers/staging/vc04_services/interface/vchi/message_drivers/message.h index a7740a425388..834263f278cf 100644 --- a/drivers/staging/vc04_services/interface/vchi/message_drivers/message.h +++ b/drivers/staging/vc04_services/interface/vchi/message_drivers/message.h @@ -41,7 +41,6 @@ #include "interface/vchi/vchi_cfg_internal.h" #include "interface/vchi/vchi_common.h" - typedef enum message_event_type { MESSAGE_EVENT_NONE, MESSAGE_EVENT_NOP, @@ -111,7 +110,6 @@ typedef struct rx_bulk_slotinfo_t { VCHI_FLAGS_T flags; } RX_BULK_SLOTINFO_T; - /* ---------------------------------------------------------------------- * each connection driver will have a pool of the following struct. * @@ -155,7 +153,6 @@ typedef struct { } MESSAGE_EVENT_T; - // callbacks typedef void VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T( void *state ); @@ -163,7 +160,6 @@ typedef struct { VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T *event_callback; } VCHI_MESSAGE_DRIVER_OPEN_T; - // handle to this instance of message driver (as returned by ->open) typedef struct opaque_mhandle_t *VCHI_MDRIVER_HANDLE_T; @@ -195,7 +191,6 @@ struct opaque_vchi_message_driver_t { void (*debug)( VCHI_MDRIVER_HANDLE_T *handle ); }; - #endif // _VCHI_MESSAGE_H_ /****************************** End of file ***********************************/ diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index addb7b00b688..66a3a060fad2 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -39,7 +39,6 @@ #include "interface/vchi/connections/connection.h" #include "vchi_mh.h" - /****************************************************************************** Global defs *****************************************************************************/ @@ -92,7 +91,6 @@ typedef struct vchi_msg_vector_ex { } u; } VCHI_MSG_VECTOR_EX_T; - // Construct an entry in a msg vector for a pointer (p) of length (l) #define VCHI_VEC_POINTER(p,l) VCHI_VEC_POINTER, { { (VCHI_MEM_HANDLE_T)(p), (l) } } @@ -103,7 +101,6 @@ typedef struct vchi_msg_vector_ex { #define MAKE_FOURCC(x) ((int32_t)( (x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3] )) #define FOURCC_TO_CHAR(x) (x >> 24) & 0xFF,(x >> 16) & 0xFF,(x >> 8) & 0xFF, x & 0xFF - // Opaque service information struct opaque_vchi_service_t; @@ -114,8 +111,6 @@ typedef struct { void *message; } VCHI_HELD_MSG_T; - - // structure used to provide the information needed to open a server or a client typedef struct { struct vchi_version version; @@ -162,7 +157,6 @@ extern "C" { extern /*@observer@*/ VCHI_CONNECTION_T * vchi_create_connection( const VCHI_CONNECTION_API_T * function_table, const VCHI_MESSAGE_DRIVER_T * low_level); - // Routine used to initialise the vchi on both local + remote connections extern int32_t vchi_initialise( VCHI_INSTANCE_T *instance_handle ); @@ -185,7 +179,6 @@ extern void * vchi_allocate_buffer(VCHI_SERVICE_HANDLE_T handle, uint32_t *lengt extern void vchi_free_buffer(VCHI_SERVICE_HANDLE_T handle, void *address); extern uint32_t vchi_current_time(VCHI_INSTANCE_T instance_handle); - /****************************************************************************** Global service API *****************************************************************************/ @@ -194,7 +187,7 @@ extern int32_t vchi_service_create( VCHI_INSTANCE_T instance_handle, SERVICE_CREATION_T *setup, VCHI_SERVICE_HANDLE_T *handle ); -// Routine to destory a service +// Routine to destroy a service extern int32_t vchi_service_destroy( const VCHI_SERVICE_HANDLE_T handle ); // Routine to open a named service @@ -307,7 +300,6 @@ extern int32_t vchi_msg_iter_hold_next( VCHI_MSG_ITER_T *iter, uint32_t *msg_size, // } VCHI_HELD_MSG_T *message ); - /****************************************************************************** Global bulk API *****************************************************************************/ @@ -319,7 +311,6 @@ extern int32_t vchi_bulk_queue_receive( VCHI_SERVICE_HANDLE_T handle, VCHI_FLAGS_T flags, void *transfer_handle ); - // Prepare interface for a transfer from the other side into relocatable memory. int32_t vchi_bulk_queue_receive_reloc( const VCHI_SERVICE_HANDLE_T handle, VCHI_MEM_HANDLE_T h_dst, @@ -335,7 +326,6 @@ extern int32_t vchi_bulk_queue_transmit( VCHI_SERVICE_HANDLE_T handle, VCHI_FLAGS_T flags, void *transfer_handle ); - /****************************************************************************** Configuration plumbing *****************************************************************************/ diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_common.h b/drivers/staging/vc04_services/interface/vchi/vchi_common.h index 45c2070d46b0..76e10fe65d9b 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_common.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_common.h @@ -34,7 +34,6 @@ #ifndef VCHI_COMMON_H_ #define VCHI_COMMON_H_ - //flags used when sending messages (must be bitmapped) typedef enum { VCHI_FLAGS_NONE = 0x0, @@ -118,14 +117,11 @@ typedef enum { VCHI_SERVICE_OPTION_MAX } VCHI_SERVICE_OPTION_T; - //Callback used by all services / bulk transfers typedef void (*VCHI_CALLBACK_T)(void *callback_param, //my service local param VCHI_CALLBACK_REASON_T 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 @@ -154,7 +150,6 @@ typedef struct opaque_vchi_connection_api_t VCHI_CONNECTION_API_T; // Opaque type for a message driver typedef struct opaque_vchi_message_driver_t VCHI_MESSAGE_DRIVER_T; - // 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 - @@ -168,5 +163,4 @@ typedef struct { void *remove; } VCHI_MSG_ITER_T; - #endif // VCHI_COMMON_H_ 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 be08849175ea..81827b8a7601 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 @@ -59,10 +59,10 @@ #define BELL0 0x00 #define BELL2 0x08 -typedef struct vchiq_2835_state_struct { +struct vchiq_2835_state { int inited; VCHIQ_ARM_STATE_T arm_state; -} VCHIQ_2835_ARM_STATE_T; +}; struct vchiq_pagelist_info { PAGELIST_T *pagelist; @@ -84,8 +84,6 @@ static char *g_free_fragments; static struct semaphore g_free_fragments_sema; static struct device *g_dev; -extern int vchiq_arm_log_level; - static DEFINE_SEMAPHORE(g_free_fragments_mutex); static irqreturn_t @@ -207,12 +205,12 @@ vchiq_platform_init_state(VCHIQ_STATE_T *state) { VCHIQ_STATUS_T status = VCHIQ_SUCCESS; - state->platform_state = kzalloc(sizeof(VCHIQ_2835_ARM_STATE_T), GFP_KERNEL); - ((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->inited = 1; - status = vchiq_arm_init_state(state, &((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->arm_state); + state->platform_state = kzalloc(sizeof(struct vchiq_2835_state), GFP_KERNEL); + ((struct vchiq_2835_state *)state->platform_state)->inited = 1; + status = vchiq_arm_init_state(state, &((struct vchiq_2835_state *)state->platform_state)->arm_state); if (status != VCHIQ_SUCCESS) { - ((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->inited = 0; + ((struct vchiq_2835_state *)state->platform_state)->inited = 0; } return status; } @@ -220,11 +218,11 @@ vchiq_platform_init_state(VCHIQ_STATE_T *state) VCHIQ_ARM_STATE_T* vchiq_platform_get_arm_state(VCHIQ_STATE_T *state) { - if (!((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->inited) + if (!((struct vchiq_2835_state *)state->platform_state)->inited) { BUG(); } - return &((VCHIQ_2835_ARM_STATE_T *)state->platform_state)->arm_state; + return &((struct vchiq_2835_state *)state->platform_state)->arm_state; } void 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 314ffac50bb8..6fcc62603580 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -109,10 +109,8 @@ static const char *const resume_state_names[] = { * requested */ #define FORCE_SUSPEND_TIMEOUT_MS 200 - static void suspend_timer_callback(unsigned long context); - typedef struct user_service_struct { VCHIQ_SERVICE_T *service; void *userdata; @@ -195,11 +193,6 @@ static const char *const ioctl_names[] = { vchiq_static_assert(ARRAY_SIZE(ioctl_names) == (VCHIQ_IOC_MAX + 1)); -#if defined(CONFIG_BCM2835_VCHIQ_SUPPORT_MEMDUMP) -static void -dump_phys_mem(void *virt_addr, u32 num_bytes); -#endif - /**************************************************************************** * * add_completion @@ -1161,20 +1154,6 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) args.handle, args.option, args.value); } break; -#if defined(CONFIG_BCM2835_VCHIQ_SUPPORT_MEMDUMP) - case VCHIQ_IOC_DUMP_PHYS_MEM: { - VCHIQ_DUMP_MEM_T args; - - if (copy_from_user - (&args, (const void __user *)arg, - sizeof(args)) != 0) { - ret = -EFAULT; - break; - } - dump_phys_mem(args.virt_addr, args.num_bytes); - } break; -#endif - case VCHIQ_IOC_LIB_VERSION: { unsigned int lib_version = (unsigned int)arg; @@ -1654,42 +1633,6 @@ vchiq_compat_ioctl_get_config(struct file *file, return vchiq_ioctl(file, VCHIQ_IOC_GET_CONFIG, (unsigned long)args); } -#if defined(CONFIG_BCM2835_VCHIQ_SUPPORT_MEMDUMP) - -struct vchiq_dump_mem32 { - compat_uptr_t virt_addr; - u32 num_bytes; -}; - -#define VCHIQ_IOC_DUMP_PHYS_MEM32 \ - _IOW(VCHIQ_IOC_MAGIC, 15, struct vchiq_dump_mem32) - -static long -vchiq_compat_ioctl_dump_phys_mem(struct file *file, - unsigned int cmd, - unsigned long arg) -{ - VCHIQ_DUMP_MEM_T *args; - struct vchiq_dump_mem32 args32; - - args = compat_alloc_user_space(sizeof(*args)); - if (!args) - return -EFAULT; - - if (copy_from_user(&args32, - (struct vchiq_dump_mem32 *)arg, - sizeof(args32))) - return -EFAULT; - - if (put_user(compat_ptr(args32.virt_addr), &args->virt_addr) || - put_user(args32.num_bytes, &args->num_bytes)) - return -EFAULT; - - return vchiq_ioctl(file, VCHIQ_IOC_DUMP_PHYS_MEM, (unsigned long)args); -} - -#endif - static long vchiq_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -1707,10 +1650,6 @@ vchiq_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return vchiq_compat_ioctl_dequeue_message(file, cmd, arg); case VCHIQ_IOC_GET_CONFIG32: return vchiq_compat_ioctl_get_config(file, cmd, arg); -#if defined(CONFIG_BCM2835_VCHIQ_SUPPORT_MEMDUMP) - case VCHIQ_IOC_DUMP_PHYS_MEM32: - return vchiq_compat_ioctl_dump_phys_mem(file, cmd, arg); -#endif default: return vchiq_ioctl(file, cmd, arg); } @@ -2050,98 +1989,6 @@ vchiq_dump_platform_service_state(void *dump_context, VCHIQ_SERVICE_T *service) /**************************************************************************** * -* dump_user_mem -* -***************************************************************************/ - -#if defined(CONFIG_BCM2835_VCHIQ_SUPPORT_MEMDUMP) - -static void -dump_phys_mem(void *virt_addr, u32 num_bytes) -{ - int rc; - u8 *end_virt_addr = virt_addr + num_bytes; - int num_pages; - int offset; - int end_offset; - int page_idx; - int prev_idx; - struct page *page; - struct page **pages; - u8 *kmapped_virt_ptr; - - /* Align virt_addr and end_virt_addr to 16 byte boundaries. */ - - virt_addr = (void *)((unsigned long)virt_addr & ~0x0fuL); - end_virt_addr = (void *)(((unsigned long)end_virt_addr + 15uL) & - ~0x0fuL); - - offset = (int)(long)virt_addr & (PAGE_SIZE - 1); - end_offset = (int)(long)end_virt_addr & (PAGE_SIZE - 1); - - num_pages = DIV_ROUND_UP(offset + num_bytes, PAGE_SIZE); - - pages = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL); - if (!pages) { - vchiq_log_error(vchiq_arm_log_level, - "Unable to allocation memory for %d pages\n", - num_pages); - return; - } - - down_read(¤t->mm->mmap_sem); - rc = get_user_pages( - (unsigned long)virt_addr, /* start */ - num_pages, /* len */ - 0, /* gup_flags */ - pages, /* pages (array of page pointers) */ - NULL); /* vmas */ - up_read(¤t->mm->mmap_sem); - - prev_idx = -1; - page = NULL; - - if (rc < 0) { - vchiq_log_error(vchiq_arm_log_level, - "Failed to get user pages: %d\n", rc); - goto out; - } - - while (offset < end_offset) { - int page_offset = offset % PAGE_SIZE; - - page_idx = offset / PAGE_SIZE; - if (page_idx != prev_idx) { - if (page != NULL) - kunmap(page); - page = pages[page_idx]; - kmapped_virt_ptr = kmap(page); - prev_idx = page_idx; - } - - if (vchiq_arm_log_level >= VCHIQ_LOG_TRACE) - vchiq_log_dump_mem("ph", - (u32)(unsigned long)&kmapped_virt_ptr[ - page_offset], - &kmapped_virt_ptr[page_offset], 16); - - offset += 16; - } - -out: - if (page != NULL) - kunmap(page); - - for (page_idx = 0; page_idx < num_pages; page_idx++) - put_page(pages[page_idx]); - - kfree(pages); -} - -#endif - -/**************************************************************************** -* * vchiq_read * ***************************************************************************/ @@ -2307,8 +2154,6 @@ exit: return 0; } - - VCHIQ_STATUS_T vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_STATE_T *arm_state) { @@ -2469,7 +2314,6 @@ set_resume_state(VCHIQ_ARM_STATE_T *arm_state, } } - /* should be called with the write lock held */ inline void start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state) @@ -2589,7 +2433,6 @@ vchiq_arm_vcsuspend(VCHIQ_STATE_T *state) vchiq_log_trace(vchiq_susp_log_level, "%s", __func__); status = VCHIQ_SUCCESS; - switch (arm_state->vc_suspend_state) { case VC_SUSPEND_REQUESTED: vchiq_log_info(vchiq_susp_log_level, "%s: suspend already " @@ -2654,7 +2497,6 @@ out: return; } - static void output_timeout_error(VCHIQ_STATE_T *state) { @@ -2834,7 +2676,6 @@ out: return; } - int vchiq_arm_allow_resume(VCHIQ_STATE_T *state) { @@ -2996,7 +2837,6 @@ vchiq_use_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, "%s %s count %d, state count %d", __func__, entity, *entity_uc, local_uc); - write_unlock_bh(&arm_state->susp_res_lock); /* Completion is in a done state when we're not suspended, so this won't diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index bfbd81d9db33..a4cc0db899be 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -42,7 +42,6 @@ #include "vchiq_core.h" #include "vchiq_debugfs.h" - enum vc_suspend_status { VC_SUSPEND_FORCE_CANCELED = -3, /* Force suspend canceled, too busy */ VC_SUSPEND_REJECTED = -2, /* Videocore rejected suspend request */ @@ -61,15 +60,12 @@ enum vc_resume_status { VC_RESUME_RESUMED /* Videocore resumed successfully (active) */ }; - enum USE_TYPE_E { USE_TYPE_SERVICE, USE_TYPE_SERVICE_NO_RESUME, USE_TYPE_VCHIQ }; - - typedef struct vchiq_arm_state_struct { /* Keepalive-related data */ struct task_struct *ka_thread; @@ -216,5 +212,4 @@ set_resume_state(VCHIQ_ARM_STATE_T *arm_state, extern void start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state); - #endif /* VCHIQ_ARM_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 486be990d7fc..c3bb8e073367 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -130,7 +130,6 @@ static const char *const conn_state_names[] = { "RESUME_TIMEOUT" }; - static void release_message_sync(VCHIQ_STATE_T *state, VCHIQ_HEADER_T *header); @@ -2168,7 +2167,6 @@ slot_handler_func(void *v) break; } - } DEBUG_TRACE(SLOT_HANDLER_LINE); @@ -2177,7 +2175,6 @@ slot_handler_func(void *v) return 0; } - /* Called by the recycle thread */ static int recycle_func(void *v) @@ -2193,7 +2190,6 @@ recycle_func(void *v) return 0; } - /* Called by the sync thread */ static int sync_func(void *v) @@ -2301,7 +2297,6 @@ sync_func(void *v) return 0; } - static void init_bulk_queue(VCHIQ_BULK_QUEUE_T *queue) { @@ -2312,14 +2307,12 @@ init_bulk_queue(VCHIQ_BULK_QUEUE_T *queue) queue->remove = 0; } - inline const char * get_conn_state_name(VCHIQ_CONNSTATE_T conn_state) { return conn_state_names[conn_state]; } - VCHIQ_SLOT_ZERO_T * vchiq_init_slots(void *mem_base, int mem_size) { @@ -3296,7 +3289,6 @@ vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) return status; } - /* This function may be called by kernel threads or user threads. * User threads may receive VCHIQ_RETRY to indicate that a signal has been * received and the call should be retried after being returned to user @@ -3876,7 +3868,6 @@ vchiq_dump_service_state(void *dump_context, VCHIQ_SERVICE_T *service) vchiq_dump_platform_service_state(dump_context, service); } - void vchiq_loud_error_header(void) { @@ -3901,7 +3892,6 @@ vchiq_loud_error_footer(void) "================"); } - VCHIQ_STATUS_T vchiq_send_remote_use(VCHIQ_STATE_T *state) { VCHIQ_STATUS_T status = VCHIQ_RETRY; 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 9e164652548a..afc1d8144a84 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -702,7 +702,6 @@ vchiq_platform_handle_timeout(VCHIQ_STATE_T *state); extern void vchiq_set_conn_state(VCHIQ_STATE_T *state, VCHIQ_CONNSTATE_T newstate); - extern void vchiq_log_dump_mem(const char *label, uint32_t addr, const void *voidMem, size_t numBytes); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c index 9367a9a5aa3c..766b4fe5f32c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c @@ -32,7 +32,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #include <linux/debugfs.h> #include "vchiq_core.h" #include "vchiq_arm.h" @@ -52,7 +51,6 @@ #define VCHIQ_LOG_INFO_STR "info" #define VCHIQ_LOG_TRACE_STR "trace" - /* Top-level debug info */ struct vchiq_debugfs_info { /* Global 'vchiq' debugfs entry used by all instances */ @@ -316,7 +314,6 @@ void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance) debugfs_remove_recursive(node->dentry); } - int vchiq_debugfs_init(void) { BUG_ON(debugfs_info.vchiq_cfg_dir != NULL); 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 8af95fc361ed..d465e1cf5db9 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -41,14 +41,14 @@ #define vchiq_status_to_vchi(status) ((int32_t)status) -typedef struct { +struct shim_service { VCHIQ_SERVICE_HANDLE_T handle; VCHIU_QUEUE_T queue; VCHI_CALLBACK_T callback; void *callback_param; -} SHIM_SERVICE_T; +}; /* ---------------------------------------------------------------------- * return pointer to the mphi message driver function table @@ -84,7 +84,6 @@ VCHI_CONNECTION_T *vchi_create_connection( * void **data, * uint32_t *msg_size, - * VCHI_FLAGS_T flags * * Description: Routine to return a pointer to the current message (to allow in @@ -99,7 +98,7 @@ int32_t vchi_msg_peek(VCHI_SERVICE_HANDLE_T handle, uint32_t *msg_size, VCHI_FLAGS_T flags) { - SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + struct shim_service *service = (struct shim_service *)handle; VCHIQ_HEADER_T *header; WARN_ON((flags != VCHI_FLAGS_NONE) && @@ -131,7 +130,7 @@ EXPORT_SYMBOL(vchi_msg_peek); ***********************************************************/ int32_t vchi_msg_remove(VCHI_SERVICE_HANDLE_T handle) { - SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + struct shim_service *service = (struct shim_service *)handle; VCHIQ_HEADER_T *header; header = vchiu_queue_pop(&service->queue); @@ -163,7 +162,7 @@ int32_t vchi_msg_queue(VCHI_SERVICE_HANDLE_T handle, void *context, uint32_t data_size) { - SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + struct shim_service *service = (struct shim_service *)handle; VCHIQ_STATUS_T status; while (1) { @@ -262,7 +261,7 @@ int32_t vchi_bulk_queue_receive(VCHI_SERVICE_HANDLE_T handle, VCHI_FLAGS_T flags, void *bulk_handle) { - SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + struct shim_service *service = (struct shim_service *)handle; VCHIQ_BULK_MODE_T mode; VCHIQ_STATUS_T status; @@ -322,7 +321,7 @@ int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle, VCHI_FLAGS_T flags, void *bulk_handle) { - SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + struct shim_service *service = (struct shim_service *)handle; VCHIQ_BULK_MODE_T mode; VCHIQ_STATUS_T status; @@ -384,7 +383,7 @@ int32_t vchi_msg_dequeue(VCHI_SERVICE_HANDLE_T handle, uint32_t *actual_msg_size, VCHI_FLAGS_T flags) { - SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + struct shim_service *service = (struct shim_service *)handle; VCHIQ_HEADER_T *header; WARN_ON((flags != VCHI_FLAGS_NONE) && @@ -458,7 +457,7 @@ int32_t vchi_msg_hold(VCHI_SERVICE_HANDLE_T handle, VCHI_FLAGS_T flags, VCHI_HELD_MSG_T *message_handle) { - SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + struct shim_service *service = (struct shim_service *)handle; VCHIQ_HEADER_T *header; WARN_ON((flags != VCHI_FLAGS_NONE) && @@ -541,7 +540,6 @@ int32_t vchi_connect(VCHI_CONNECTION_T **connections, } EXPORT_SYMBOL(vchi_connect); - /*********************************************************** * Name: vchi_disconnect * @@ -561,7 +559,6 @@ int32_t vchi_disconnect(VCHI_INSTANCE_T instance_handle) } EXPORT_SYMBOL(vchi_disconnect); - /*********************************************************** * Name: vchi_service_open * Name: vchi_service_create @@ -579,8 +576,8 @@ EXPORT_SYMBOL(vchi_disconnect); static VCHIQ_STATUS_T shim_callback(VCHIQ_REASON_T reason, VCHIQ_HEADER_T *header, VCHIQ_SERVICE_HANDLE_T handle, void *bulk_user) { - SHIM_SERVICE_T *service = - (SHIM_SERVICE_T *)VCHIQ_GET_SERVICE_USERDATA(handle); + struct shim_service *service = + (struct shim_service *)VCHIQ_GET_SERVICE_USERDATA(handle); if (!service->callback) goto release; @@ -637,10 +634,10 @@ done: return VCHIQ_SUCCESS; } -static SHIM_SERVICE_T *service_alloc(VCHIQ_INSTANCE_T instance, +static struct shim_service *service_alloc(VCHIQ_INSTANCE_T instance, SERVICE_CREATION_T *setup) { - SHIM_SERVICE_T *service = kzalloc(sizeof(SHIM_SERVICE_T), GFP_KERNEL); + struct shim_service *service = kzalloc(sizeof(struct shim_service), GFP_KERNEL); (void)instance; @@ -657,7 +654,7 @@ static SHIM_SERVICE_T *service_alloc(VCHIQ_INSTANCE_T instance, return service; } -static void service_free(SHIM_SERVICE_T *service) +static void service_free(struct shim_service *service) { if (service) { vchiu_queue_delete(&service->queue); @@ -670,7 +667,7 @@ int32_t vchi_service_open(VCHI_INSTANCE_T instance_handle, VCHI_SERVICE_HANDLE_T *handle) { VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle; - SHIM_SERVICE_T *service = service_alloc(instance, setup); + struct shim_service *service = service_alloc(instance, setup); *handle = (VCHI_SERVICE_HANDLE_T)service; @@ -703,7 +700,7 @@ int32_t vchi_service_create(VCHI_INSTANCE_T instance_handle, VCHI_SERVICE_HANDLE_T *handle) { VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle; - SHIM_SERVICE_T *service = service_alloc(instance, setup); + struct shim_service *service = service_alloc(instance, setup); *handle = (VCHI_SERVICE_HANDLE_T)service; @@ -733,7 +730,7 @@ EXPORT_SYMBOL(vchi_service_create); int32_t vchi_service_close(const VCHI_SERVICE_HANDLE_T handle) { int32_t ret = -1; - SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + struct shim_service *service = (struct shim_service *)handle; if (service) { VCHIQ_STATUS_T status = vchiq_close_service(service->handle); @@ -751,7 +748,7 @@ EXPORT_SYMBOL(vchi_service_close); int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle) { int32_t ret = -1; - SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + struct shim_service *service = (struct shim_service *)handle; if (service) { VCHIQ_STATUS_T status = vchiq_remove_service(service->handle); @@ -772,7 +769,7 @@ int32_t vchi_service_set_option(const VCHI_SERVICE_HANDLE_T handle, int value) { int32_t ret = -1; - SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + struct shim_service *service = (struct shim_service *)handle; VCHIQ_SERVICE_OPTION_T vchiq_option; switch (option) { @@ -801,7 +798,7 @@ EXPORT_SYMBOL(vchi_service_set_option); int32_t vchi_get_peer_version(const VCHI_SERVICE_HANDLE_T handle, short *peer_version) { int32_t ret = -1; - SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + struct shim_service *service = (struct shim_service *)handle; if (service) { @@ -828,7 +825,7 @@ int32_t vchi_service_use(const VCHI_SERVICE_HANDLE_T handle) { int32_t ret = -1; - SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + struct shim_service *service = (struct shim_service *)handle; if (service) ret = vchiq_status_to_vchi(vchiq_use_service(service->handle)); return ret; @@ -849,7 +846,7 @@ int32_t vchi_service_release(const VCHI_SERVICE_HANDLE_T handle) { int32_t ret = -1; - SHIM_SERVICE_T *service = (SHIM_SERVICE_T *)handle; + struct shim_service *service = (struct shim_service *)handle; if (service) ret = vchiq_status_to_vchi( vchiq_release_service(service->handle)); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index ac5aaafa461c..e7882b24a338 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1111,7 +1111,6 @@ static int del_key(struct wiphy *wiphy, struct net_device *netdev, g_key_gtk_params.key = NULL; kfree(g_key_gtk_params.seq); g_key_gtk_params.seq = NULL; - } if (key_index >= 0 && key_index <= 3) { @@ -1617,7 +1616,7 @@ static int mgmt_tx(struct wiphy *wiphy, *cookie = (unsigned long)buf; priv->u64tx_cookie = *cookie; - mgmt = (const struct ieee80211_mgmt *) buf; + mgmt = (const struct ieee80211_mgmt *)buf; if (ieee80211_is_mgmt(mgmt->frame_control)) { mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL); diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index c4aa9e7e7003..72070593394a 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -394,8 +394,9 @@ int prism2mgmt_scan_results(struct wlandevice *wlandev, void *msgp) count = HFA384x_SCANRESULT_MAX; if (req->bssindex.data >= count) { - pr_debug("requested index (%d) out of range (%d)\n", - req->bssindex.data, count); + netdev_dbg(wlandev->netdev, + "requested index (%d) out of range (%d)\n", + req->bssindex.data, count); result = 2; req->resultcode.data = P80211ENUM_resultcode_invalid_parameters; goto exit; @@ -684,7 +685,8 @@ int prism2mgmt_start(struct wlandevice *wlandev, void *msgp) goto done; failed: - pr_debug("Failed to set a config option, result=%d\n", result); + netdev_dbg(wlandev->netdev, + "Failed to set a config option, result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_invalid_parameters; done: @@ -1120,15 +1122,17 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) /* Disable monitor mode */ result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_DISABLE); if (result) { - pr_debug("failed to disable monitor mode, result=%d\n", - result); + netdev_dbg(wlandev->netdev, + "failed to disable monitor mode, result=%d\n", + result); goto failed; } /* Disable port 0 */ result = hfa384x_drvr_disable(hw, 0); if (result) { - pr_debug - ("failed to disable port 0 after sniffing, result=%d\n", + netdev_dbg + (wlandev->netdev, + "failed to disable port 0 after sniffing, result=%d\n", result); goto failed; } @@ -1140,8 +1144,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) HFA384x_RID_CNFWEPFLAGS, hw->presniff_wepflags); if (result) { - pr_debug - ("failed to restore wepflags=0x%04x, result=%d\n", + netdev_dbg + (wlandev->netdev, + "failed to restore wepflags=0x%04x, result=%d\n", hw->presniff_wepflags, result); goto failed; } @@ -1153,8 +1158,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) HFA384x_RID_CNFPORTTYPE, word); if (result) { - pr_debug - ("failed to restore porttype, result=%d\n", + netdev_dbg + (wlandev->netdev, + "failed to restore porttype, result=%d\n", result); goto failed; } @@ -1162,8 +1168,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) /* Enable the port */ result = hfa384x_drvr_enable(hw, 0); if (result) { - pr_debug("failed to enable port to presniff setting, result=%d\n", - result); + netdev_dbg(wlandev->netdev, + "failed to enable port to presniff setting, result=%d\n", + result); goto failed; } } else { @@ -1182,8 +1189,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) HFA384x_RID_CNFPORTTYPE, &(hw->presniff_port_type)); if (result) { - pr_debug - ("failed to read porttype, result=%d\n", + netdev_dbg + (wlandev->netdev, + "failed to read porttype, result=%d\n", result); goto failed; } @@ -1192,24 +1200,27 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) HFA384x_RID_CNFWEPFLAGS, &(hw->presniff_wepflags)); if (result) { - pr_debug - ("failed to read wepflags, result=%d\n", + netdev_dbg + (wlandev->netdev, + "failed to read wepflags, result=%d\n", result); goto failed; } hfa384x_drvr_stop(hw); result = hfa384x_drvr_start(hw); if (result) { - pr_debug("failed to restart the card for sniffing, result=%d\n", - result); + netdev_dbg(wlandev->netdev, + "failed to restart the card for sniffing, result=%d\n", + result); goto failed; } } else { /* Disable the port */ result = hfa384x_drvr_disable(hw, 0); if (result) { - pr_debug("failed to enable port for sniffing, result=%d\n", - result); + netdev_dbg(wlandev->netdev, + "failed to enable port for sniffing, result=%d\n", + result); goto failed; } } @@ -1225,8 +1236,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) hw->sniff_channel = word; if (result) { - pr_debug("failed to set channel %d, result=%d\n", - word, result); + netdev_dbg(wlandev->netdev, + "failed to set channel %d, result=%d\n", + word, result); goto failed; } @@ -1238,8 +1250,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) HFA384x_RID_CNFPORTTYPE, word); if (result) { - pr_debug - ("failed to set porttype %d, result=%d\n", + netdev_dbg + (wlandev->netdev, + "failed to set porttype %d, result=%d\n", word, result); goto failed; } @@ -1257,8 +1270,9 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) } if (result) { - pr_debug - ("failed to set wepflags=0x%04x, result=%d\n", + netdev_dbg + (wlandev->netdev, + "failed to set wepflags=0x%04x, result=%d\n", word, result); goto failed; } @@ -1283,16 +1297,18 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) /* Enable the port */ result = hfa384x_drvr_enable(hw, 0); if (result) { - pr_debug - ("failed to enable port for sniffing, result=%d\n", + netdev_dbg + (wlandev->netdev, + "failed to enable port for sniffing, result=%d\n", result); goto failed; } /* Enable monitor mode */ result = hfa384x_cmd_monitor(hw, HFA384x_MONITOR_ENABLE); if (result) { - pr_debug("failed to enable monitor mode, result=%d\n", - result); + netdev_dbg(wlandev->netdev, + "failed to enable monitor mode, result=%d\n", + result); goto failed; } diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c index c9df45063ab3..070a237004cb 100644 --- a/drivers/staging/wlan-ng/prism2sta.c +++ b/drivers/staging/wlan-ng/prism2sta.c @@ -1447,7 +1447,7 @@ static void prism2sta_inf_linkstatus(struct wlandevice *wlandev, { struct hfa384x *hw = wlandev->priv; - hw->link_status_new = inf->info.linkstatus.linkstatus; + hw->link_status_new = le16_to_cpu(inf->info.linkstatus.linkstatus); schedule_work(&hw->link_bh); } diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index b450c740f626..b813f1d460ce 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -1697,7 +1697,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (XGIfb_get_dram_size(xgifb_info)) { xgifb_info->video_size = min_t(unsigned long, video_size_max, - SZ_16M); + SZ_16M); } else if (xgifb_info->video_size > video_size_max) { xgifb_info->video_size = video_size_max; } @@ -1736,7 +1736,7 @@ static int xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) hw_info->pjVideoMemoryAddress = ioremap_wc(xgifb_info->video_base, xgifb_info->video_size); xgifb_info->mmio_vbase = ioremap(xgifb_info->mmio_base, - xgifb_info->mmio_size); + xgifb_info->mmio_size); dev_info(&pdev->dev, "Framebuffer at 0x%llx, mapped to 0x%p, size %dk\n", diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index cea128bede52..a6cd0a1e8c05 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -5046,7 +5046,7 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { - const u8 LCDARefreshIndex[] = { + static const u8 LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00 }; unsigned short RefreshRateTableIndex, i, index, temp; @@ -5479,8 +5479,9 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, ModeIdIndex)) return 0; - pVBInfo->ModeType = XGI330_EModeIDTable[ModeIdIndex]. - Ext_ModeFlag & ModeTypeMask; + pVBInfo->ModeType = + XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag + & ModeTypeMask; pVBInfo->SetFlag = 0; pVBInfo->VBInfo = DisableCRT2Display; diff --git a/drivers/usb/typec/Kconfig b/drivers/usb/typec/Kconfig index bc1b7745f1d4..819c0ed2b200 100644 --- a/drivers/usb/typec/Kconfig +++ b/drivers/usb/typec/Kconfig @@ -4,6 +4,20 @@ menu "USB Power Delivery and Type-C drivers" config TYPEC tristate +config TYPEC_TCPM + tristate "USB Type-C Port Controller Manager" + depends on USB + select TYPEC + help + The Type-C Port Controller Manager provides a USB PD and USB Type-C + state machine for use with Type-C Port Controllers. + +if TYPEC_TCPM + +source "drivers/usb/typec/fusb302/Kconfig" + +endif + config TYPEC_WCOVE tristate "Intel WhiskeyCove PMIC USB Type-C PHY driver" depends on ACPI diff --git a/drivers/usb/typec/Makefile b/drivers/usb/typec/Makefile index bc214f15f1b5..b77688ce1f16 100644 --- a/drivers/usb/typec/Makefile +++ b/drivers/usb/typec/Makefile @@ -1,3 +1,5 @@ obj-$(CONFIG_TYPEC) += typec.o +obj-$(CONFIG_TYPEC_TCPM) += tcpm.o +obj-y += fusb302/ obj-$(CONFIG_TYPEC_WCOVE) += typec_wcove.o obj-$(CONFIG_TYPEC_UCSI) += ucsi/ diff --git a/drivers/staging/typec/fusb302/Kconfig b/drivers/usb/typec/fusb302/Kconfig index 48a4f2fcee03..48a4f2fcee03 100644 --- a/drivers/staging/typec/fusb302/Kconfig +++ b/drivers/usb/typec/fusb302/Kconfig diff --git a/drivers/staging/typec/fusb302/Makefile b/drivers/usb/typec/fusb302/Makefile index 207efa5fbab8..207efa5fbab8 100644 --- a/drivers/staging/typec/fusb302/Makefile +++ b/drivers/usb/typec/fusb302/Makefile diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c index fc6a3cf74eb3..e790b67d4953 100644 --- a/drivers/staging/typec/fusb302/fusb302.c +++ b/drivers/usb/typec/fusb302/fusb302.c @@ -37,11 +37,11 @@ #include <linux/string.h> #include <linux/types.h> #include <linux/usb/typec.h> +#include <linux/usb/tcpm.h> +#include <linux/usb/pd.h> #include <linux/workqueue.h> #include "fusb302_reg.h" -#include "../tcpm.h" -#include "../pd.h" /* * When the device is SNK, BC_LVL interrupt is used to monitor cc pins diff --git a/drivers/staging/typec/fusb302/fusb302_reg.h b/drivers/usb/typec/fusb302/fusb302_reg.h index 0682e63de773..0682e63de773 100644 --- a/drivers/staging/typec/fusb302/fusb302_reg.h +++ b/drivers/usb/typec/fusb302/fusb302_reg.h diff --git a/drivers/staging/typec/tcpm.c b/drivers/usb/typec/tcpm.c index 8af62e74d54c..f557c479fdc2 100644 --- a/drivers/staging/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -26,14 +26,13 @@ #include <linux/seq_file.h> #include <linux/slab.h> #include <linux/spinlock.h> +#include <linux/usb/pd.h> +#include <linux/usb/pd_bdo.h> +#include <linux/usb/pd_vdo.h> +#include <linux/usb/tcpm.h> #include <linux/usb/typec.h> #include <linux/workqueue.h> -#include "pd.h" -#include "pd_vdo.h" -#include "pd_bdo.h" -#include "tcpm.h" - #define FOREACH_STATE(S) \ S(INVALID_STATE), \ S(DRP_TOGGLING), \ @@ -908,27 +907,6 @@ static void svdm_consume_identity(struct tcpm_port *port, const __le32 *payload, memset(&port->mode_data, 0, sizeof(port->mode_data)); -#if 0 /* Not really a match */ - switch (PD_IDH_PTYPE(vdo)) { - case IDH_PTYPE_UNDEF: - port->partner.type = TYPEC_PARTNER_NONE; /* no longer exists */ - break; - case IDH_PTYPE_HUB: - break; - case IDH_PTYPE_PERIPH: - break; - case IDH_PTYPE_PCABLE: - break; - case IDH_PTYPE_ACABLE: - break; - case IDH_PTYPE_AMA: - port->partner.type = TYPEC_PARTNER_ALTMODE; - break; - default: - break; - } -#endif - port->partner_ident.id_header = vdo; port->partner_ident.cert_stat = le32_to_cpu(payload[VDO_INDEX_CSTAT]); port->partner_ident.product = product; @@ -1103,11 +1081,7 @@ static int tcpm_pd_svdm(struct tcpm_port *port, const __le32 *payload, int cnt, response[0] = VDO(svid, 1, CMD_DISCOVER_MODES); rlen = 1; } else { -#if 0 - response[0] = pd_dfp_enter_mode(port, 0, 0); - if (response[0]) - rlen = 1; -#endif + /* enter alternate mode if/when implemented */ } break; case CMD_ENTER_MODE: @@ -1145,10 +1119,6 @@ static void tcpm_handle_vdm_request(struct tcpm_port *port, if (PD_VDO_SVDM(p0)) rlen = tcpm_pd_svdm(port, payload, cnt, response); -#if 0 - else - rlen = tcpm_pd_custom_vdm(port, cnt, payload, response); -#endif if (rlen > 0) { tcpm_queue_vdm(port, response[0], &response[1], rlen - 1); @@ -2442,7 +2412,6 @@ static void run_state_machine(struct tcpm_port *port) tcpm_set_state(port, SNK_STARTUP, 0); break; case SNK_STARTUP: - /* XXX: callback into infrastructure */ opmode = tcpm_get_pwr_opmode(port->polarity ? port->cc2 : port->cc1); typec_set_pwr_opmode(port->typec_port, opmode); @@ -3589,11 +3558,6 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) port->partner_desc.identity = &port->partner_ident; port->port_type = tcpc->config->type; - /* - * TODO: - * - alt_modes, set_alt_mode - * - {debug,audio}_accessory - */ port->typec_port = typec_register_port(port->dev, &port->typec_caps); if (!port->typec_port) { diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index c380daa40c0e..50cae8504256 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -369,8 +369,6 @@ struct iio_dev; /** * struct iio_info - constant information about device - * @driver_module: module structure used to ensure correct - * ownership of chrdevs etc * @event_attrs: event control attributes * @attrs: general purpose device attributes * @read_raw: function to request a value from the device. @@ -425,7 +423,6 @@ struct iio_dev; * were flushed and there was an error. **/ struct iio_info { - struct module *driver_module; const struct attribute_group *event_attrs; const struct attribute_group *attrs; @@ -518,6 +515,7 @@ struct iio_buffer_setup_ops { /** * struct iio_dev - industrial I/O device * @id: [INTERN] used to identify device internally + * @driver_module: [INTERN] used to make it harder to undercut users * @modes: [DRIVER] operating modes supported by device * @currentmode: [DRIVER] current operating mode * @dev: [DRIVER] device structure, should be assigned a parent @@ -558,6 +556,7 @@ struct iio_buffer_setup_ops { */ struct iio_dev { int id; + struct module *driver_module; int modes; int currentmode; @@ -604,9 +603,34 @@ struct iio_dev { const struct iio_chan_spec *iio_find_channel_from_si(struct iio_dev *indio_dev, int si); -int iio_device_register(struct iio_dev *indio_dev); +/** + * iio_device_register() - register a device with the IIO subsystem + * @indio_dev: Device structure filled by the device driver + **/ +#define iio_device_register(iio_dev) \ + __iio_device_register((iio_dev), THIS_MODULE) +int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod); void iio_device_unregister(struct iio_dev *indio_dev); -int devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev); +/** + * devm_iio_device_register - Resource-managed iio_device_register() + * @dev: Device to allocate iio_dev for + * @indio_dev: Device structure filled by the device driver + * + * Managed iio_device_register. The IIO device registered with this + * function is automatically unregistered on driver detach. This function + * calls iio_device_register() internally. Refer to that function for more + * information. + * + * If an iio_dev registered with this function needs to be unregistered + * separately, devm_iio_device_unregister() must be used. + * + * RETURNS: + * 0 on success, negative error number on failure. + */ +#define devm_iio_device_register(dev, indio_dev) \ + __devm_iio_device_register((dev), (indio_dev), THIS_MODULE); +int __devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev, + struct module *this_mod); void devm_iio_device_unregister(struct device *dev, struct iio_dev *indio_dev); int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp); int iio_device_claim_direct_mode(struct iio_dev *indio_dev); diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h index 7142d8d6e470..7d5e44518379 100644 --- a/include/linux/iio/trigger.h +++ b/include/linux/iio/trigger.h @@ -23,7 +23,6 @@ struct iio_trigger; /** * struct iio_trigger_ops - operations structure for an iio_trigger. - * @owner: used to monitor usage count of the trigger. * @set_trigger_state: switch on/off the trigger on demand * @try_reenable: function to reenable the trigger when the * use count is zero (may be NULL) @@ -34,7 +33,6 @@ struct iio_trigger; * instances of a given device. **/ struct iio_trigger_ops { - struct module *owner; int (*set_trigger_state)(struct iio_trigger *trig, bool state); int (*try_reenable)(struct iio_trigger *trig); int (*validate_device)(struct iio_trigger *trig, @@ -62,6 +60,7 @@ struct iio_trigger_ops { **/ struct iio_trigger { const struct iio_trigger_ops *ops; + struct module *owner; int id; const char *name; struct device dev; @@ -87,14 +86,14 @@ static inline struct iio_trigger *to_iio_trigger(struct device *d) static inline void iio_trigger_put(struct iio_trigger *trig) { - module_put(trig->ops->owner); + module_put(trig->owner); put_device(&trig->dev); } static inline struct iio_trigger *iio_trigger_get(struct iio_trigger *trig) { get_device(&trig->dev); - __module_get(trig->ops->owner); + __module_get(trig->owner); return trig; } @@ -127,10 +126,16 @@ static inline void *iio_trigger_get_drvdata(struct iio_trigger *trig) * iio_trigger_register() - register a trigger with the IIO core * @trig_info: trigger to be registered **/ -int iio_trigger_register(struct iio_trigger *trig_info); - -int devm_iio_trigger_register(struct device *dev, - struct iio_trigger *trig_info); +#define iio_trigger_register(trig_info) \ + __iio_trigger_register((trig_info), THIS_MODULE) +int __iio_trigger_register(struct iio_trigger *trig_info, + struct module *this_mod); + +#define devm_iio_trigger_register(dev, trig_info) \ + __devm_iio_trigger_register((dev), (trig_info), THIS_MODULE) +int __devm_iio_trigger_register(struct device *dev, + struct iio_trigger *trig_info, + struct module *this_mod); /** * iio_trigger_unregister() - unregister a trigger from the core diff --git a/drivers/staging/typec/pd.h b/include/linux/usb/pd.h index 30b32ad72acd..e00051ced806 100644 --- a/drivers/staging/typec/pd.h +++ b/include/linux/usb/pd.h @@ -104,6 +104,11 @@ static inline unsigned int pd_header_msgid_le(__le16 header) #define PD_MAX_PAYLOAD 7 +/** + * struct pd_message - PD message as seen on wire + * @header: PD message header + * @payload: PD message payload + */ struct pd_message { __le16 header; __le32 payload[PD_MAX_PAYLOAD]; diff --git a/drivers/staging/typec/pd_bdo.h b/include/linux/usb/pd_bdo.h index 90b94d9fea5d..90b94d9fea5d 100644 --- a/drivers/staging/typec/pd_bdo.h +++ b/include/linux/usb/pd_bdo.h diff --git a/drivers/staging/typec/pd_vdo.h b/include/linux/usb/pd_vdo.h index d92259f8de0a..d92259f8de0a 100644 --- a/drivers/staging/typec/pd_vdo.h +++ b/include/linux/usb/pd_vdo.h diff --git a/drivers/staging/typec/tcpm.h b/include/linux/usb/tcpm.h index 7e9a6b7b5cd6..073197f0d2bb 100644 --- a/drivers/staging/typec/tcpm.h +++ b/include/linux/usb/tcpm.h @@ -54,6 +54,27 @@ enum tcpm_transmit_type { TCPC_TX_BIST_MODE_2 = 7 }; +/** + * struct tcpc_config - Port configuration + * @src_pdo: PDO parameters sent to port partner as response to + * PD_CTRL_GET_SOURCE_CAP message + * @nr_src_pdo: Number of entries in @src_pdo + * @snk_pdo: PDO parameters sent to partner as response to + * PD_CTRL_GET_SINK_CAP message + * @nr_snk_pdo: Number of entries in @snk_pdo + * @max_snk_mv: Maximum acceptable sink voltage in mV + * @max_snk_ma: Maximum sink current in mA + * @max_snk_mw: Maximum required sink power in mW + * @operating_snk_mw: + * Required operating sink power in mW + * @type: Port type (TYPEC_PORT_DFP, TYPEC_PORT_UFP, or + * TYPEC_PORT_DRP) + * @default_role: + * Default port role (TYPEC_SINK or TYPEC_SOURCE). + * Set to TYPEC_NO_PREFERRED_ROLE if no default role. + * @try_role_hw:True if try.{Src,Snk} is implemented in hardware + * @alt_modes: List of supported alternate modes + */ struct tcpc_config { const u32 *src_pdo; unsigned int nr_src_pdo; @@ -79,7 +100,6 @@ struct tcpc_config { enum tcpc_usb_switch { TCPC_USB_SWITCH_CONNECT, TCPC_USB_SWITCH_DISCONNECT, - TCPC_USB_SWITCH_RESTORE, /* TODO FIXME */ }; /* Mux state attributes */ @@ -104,17 +124,40 @@ struct tcpc_mux_dev { void *priv_data; }; +/** + * struct tcpc_dev - Port configuration and callback functions + * @config: Pointer to port configuration + * @get_vbus: Called to read current VBUS state + * @get_current_limit: + * Optional; called by the tcpm core when configured as a snk + * and cc=Rp-def. This allows the tcpm to provide a fallback + * current-limit detection method for the cc=Rp-def case. + * For example, some tcpcs may include BC1.2 charger detection + * and use that in this case. + * @set_cc: Called to set value of CC pins + * @get_cc: Called to read current CC pin values + * @set_polarity: + * Called to set polarity + * @set_vconn: Called to enable or disable VCONN + * @set_vbus: Called to enable or disable VBUS + * @set_current_limit: + * Optional; called to set current limit as negotiated + * with partner. + * @set_pd_rx: Called to enable or disable reception of PD messages + * @set_roles: Called to set power and data roles + * @start_drp_toggling: + * Optional; if supported by hardware, called to start DRP + * toggling. DRP toggling is stopped automatically if + * a connection is established. + * @try_role: Optional; called to set a preferred role + * @pd_transmit:Called to transmit PD message + * @mux: Pointer to multiplexer data + */ struct tcpc_dev { const struct tcpc_config *config; int (*init)(struct tcpc_dev *dev); int (*get_vbus)(struct tcpc_dev *dev); - /* - * This optional callback gets called by the tcpm core when configured - * as a snk and cc=Rp-def. This allows the tcpm to provide a fallback - * current-limit detection method for the cc=Rp-def case. E.g. some - * tcpcs may include BC1.2 charger detection and use that in this case. - */ int (*get_current_limit)(struct tcpc_dev *dev); int (*set_cc)(struct tcpc_dev *dev, enum typec_cc_status cc); int (*get_cc)(struct tcpc_dev *dev, enum typec_cc_status *cc1, |