From a8175ba33542d625430b66a805ef315ea3b4e755 Mon Sep 17 00:00:00 2001 From: Crestez Dan Leonard Date: Fri, 29 Apr 2016 22:05:32 +0300 Subject: iio: ak8975: Support adapters limited to BYTE_DATA The device has simple 8-bit registers but the driver incorrectly uses block or word reads without checking functionality bits. Fix by using i2c_smbus_read_i2c_block_data_or_emulated instead of i2c_smbus_read_i2c_block_data or i2c_smbus_read_word_data. This will check functionality bits and use the fastest available transfer method. Signed-off-by: Crestez Dan Leonard Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/ak8975.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index dbf0661..c24b8a5 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -430,8 +430,8 @@ static int ak8975_who_i_am(struct i2c_client *client, * AK8975 | DEVICE_ID | NA * AK8963 | DEVICE_ID | NA */ - ret = i2c_smbus_read_i2c_block_data(client, AK09912_REG_WIA1, - 2, wia_val); + ret = i2c_smbus_read_i2c_block_data_or_emulated( + client, AK09912_REG_WIA1, 2, wia_val); if (ret < 0) { dev_err(&client->dev, "Error reading WIA\n"); return ret; @@ -543,9 +543,9 @@ static int ak8975_setup(struct i2c_client *client) } /* Get asa data and store in the device data. */ - ret = i2c_smbus_read_i2c_block_data(client, - data->def->ctrl_regs[ASA_BASE], - 3, data->asa); + ret = i2c_smbus_read_i2c_block_data_or_emulated( + client, data->def->ctrl_regs[ASA_BASE], + 3, data->asa); if (ret < 0) { dev_err(&client->dev, "Not able to read asa data\n"); return ret; @@ -686,6 +686,7 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val) struct ak8975_data *data = iio_priv(indio_dev); const struct i2c_client *client = data->client; const struct ak_def *def = data->def; + u16 buff; int ret; mutex_lock(&data->lock); @@ -694,14 +695,17 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val) if (ret) goto exit; - ret = i2c_smbus_read_word_data(client, def->data_regs[index]); + ret = i2c_smbus_read_i2c_block_data_or_emulated( + client, def->data_regs[index], + sizeof(buff), (u8*)&buff); if (ret < 0) goto exit; mutex_unlock(&data->lock); - /* Clamp to valid range. */ - *val = clamp_t(s16, ret, -def->range, def->range); + /* Swap bytes and convert to valid range. */ + buff = le16_to_cpu(buff); + *val = clamp_t(s16, buff, -def->range, def->range); return IIO_VAL_INT; exit: -- cgit v1.1 From 32133be6768257726b57094f673415418cb3dc48 Mon Sep 17 00:00:00 2001 From: Constantin Musca Date: Tue, 3 May 2016 15:05:45 +0300 Subject: iio: accel: Add support for Freescale MMA7660FC Minimal implementation of an IIO driver for the Freescale MMA7660FC 3-axis accelerometer. Datasheet: http://www.nxp.com/files/sensors/doc/data_sheet/MMA7660FC.pdf Includes: - ACPI support; - read_raw for x,y,z axes; - reading and setting the scale (range) parameter. - power management Signed-off-by: Constantin Musca Reviewed-by: Martin Klepplinger Signed-off-by: Jonathan Cameron --- drivers/iio/accel/Kconfig | 10 ++ drivers/iio/accel/Makefile | 2 + drivers/iio/accel/mma7660.c | 277 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 289 insertions(+) create mode 100644 drivers/iio/accel/mma7660.c diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index e4a758c..1df6361 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -136,6 +136,16 @@ config MMA7455_SPI To compile this driver as a module, choose M here: the module will be called mma7455_spi. +config MMA7660 + tristate "Freescale MMA7660FC 3-Axis Accelerometer Driver" + depends on I2C + help + Say yes here to get support for the Freescale MMA7660FC 3-Axis + accelerometer. + + Choosing M will build the driver as a module. If so, the module + will be called mma7660. + config MMA8452 tristate "Freescale MMA8452Q and similar Accelerometers Driver" depends on I2C diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile index 71b6794..ba1165f 100644 --- a/drivers/iio/accel/Makefile +++ b/drivers/iio/accel/Makefile @@ -15,6 +15,8 @@ obj-$(CONFIG_MMA7455) += mma7455_core.o obj-$(CONFIG_MMA7455_I2C) += mma7455_i2c.o obj-$(CONFIG_MMA7455_SPI) += mma7455_spi.o +obj-$(CONFIG_MMA7660) += mma7660.o + obj-$(CONFIG_MMA8452) += mma8452.o obj-$(CONFIG_MMA9551_CORE) += mma9551_core.o diff --git a/drivers/iio/accel/mma7660.c b/drivers/iio/accel/mma7660.c new file mode 100644 index 0000000..0acdee5 --- /dev/null +++ b/drivers/iio/accel/mma7660.c @@ -0,0 +1,277 @@ +/** + * Freescale MMA7660FC 3-Axis Accelerometer + * + * Copyright (c) 2016, Intel Corporation. + * + * This file is subject to the terms and conditions of version 2 of + * the GNU General Public License. See the file COPYING in the main + * directory of this archive for more details. + * + * IIO driver for Freescale MMA7660FC; 7-bit I2C address: 0x4c. + */ + +#include +#include +#include +#include +#include + +#define MMA7660_DRIVER_NAME "mma7660" + +#define MMA7660_REG_XOUT 0x00 +#define MMA7660_REG_YOUT 0x01 +#define MMA7660_REG_ZOUT 0x02 +#define MMA7660_REG_OUT_BIT_ALERT BIT(6) + +#define MMA7660_REG_MODE 0x07 +#define MMA7660_REG_MODE_BIT_MODE BIT(0) +#define MMA7660_REG_MODE_BIT_TON BIT(2) + +#define MMA7660_I2C_READ_RETRIES 5 + +/* + * The accelerometer has one measurement range: + * + * -1.5g - +1.5g (6-bit, signed) + * + * scale = (1.5 + 1.5) * 9.81 / (2^6 - 1) = 0.467142857 + */ + +#define MMA7660_SCALE_AVAIL "0.467142857" + +const int mma7660_nscale = 467142857; + +#define MMA7660_CHANNEL(reg, axis) { \ + .type = IIO_ACCEL, \ + .address = reg, \ + .modified = 1, \ + .channel2 = IIO_MOD_##axis, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ +} + +static const struct iio_chan_spec mma7660_channels[] = { + MMA7660_CHANNEL(MMA7660_REG_XOUT, X), + MMA7660_CHANNEL(MMA7660_REG_YOUT, Y), + MMA7660_CHANNEL(MMA7660_REG_ZOUT, Z), +}; + +enum mma7660_mode { + MMA7660_MODE_STANDBY, + MMA7660_MODE_ACTIVE +}; + +struct mma7660_data { + struct i2c_client *client; + struct mutex lock; + enum mma7660_mode mode; +}; + +static IIO_CONST_ATTR(in_accel_scale_available, MMA7660_SCALE_AVAIL); + +static struct attribute *mma7660_attributes[] = { + &iio_const_attr_in_accel_scale_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group mma7660_attribute_group = { + .attrs = mma7660_attributes +}; + +static int mma7660_set_mode(struct mma7660_data *data, + enum mma7660_mode mode) +{ + int ret; + struct i2c_client *client = data->client; + + if (mode == data->mode) + return 0; + + ret = i2c_smbus_read_byte_data(client, MMA7660_REG_MODE); + if (ret < 0) { + dev_err(&client->dev, "failed to read sensor mode\n"); + return ret; + } + + if (mode == MMA7660_MODE_ACTIVE) { + ret &= ~MMA7660_REG_MODE_BIT_TON; + ret |= MMA7660_REG_MODE_BIT_MODE; + } else { + ret &= ~MMA7660_REG_MODE_BIT_TON; + ret &= ~MMA7660_REG_MODE_BIT_MODE; + } + + ret = i2c_smbus_write_byte_data(client, MMA7660_REG_MODE, ret); + if (ret < 0) { + dev_err(&client->dev, "failed to change sensor mode\n"); + return ret; + } + + data->mode = mode; + + return ret; +} + +static int mma7660_read_accel(struct mma7660_data *data, u8 address) +{ + int ret, retries = MMA7660_I2C_READ_RETRIES; + struct i2c_client *client = data->client; + + /* + * Read data. If the Alert bit is set, the register was read at + * the same time as the device was attempting to update the content. + * The solution is to read the register again. Do this only + * MMA7660_I2C_READ_RETRIES times to avoid spending too much time + * in the kernel. + */ + do { + ret = i2c_smbus_read_byte_data(client, address); + if (ret < 0) { + dev_err(&client->dev, "register read failed\n"); + return ret; + } + } while (retries-- > 0 && ret & MMA7660_REG_OUT_BIT_ALERT); + + if (ret & MMA7660_REG_OUT_BIT_ALERT) { + dev_err(&client->dev, "all register read retries failed\n"); + return -ETIMEDOUT; + } + + return ret; +} + +static int mma7660_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct mma7660_data *data = iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&data->lock); + ret = mma7660_read_accel(data, chan->address); + mutex_unlock(&data->lock); + if (ret < 0) + return ret; + *val = sign_extend32(ret, 5); + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + *val = 0; + *val2 = mma7660_nscale; + return IIO_VAL_INT_PLUS_NANO; + default: + return -EINVAL; + } + + return -EINVAL; +} + +static const struct iio_info mma7660_info = { + .driver_module = THIS_MODULE, + .read_raw = mma7660_read_raw, + .attrs = &mma7660_attribute_group, +}; + +static int mma7660_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int ret; + struct iio_dev *indio_dev; + struct mma7660_data *data; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) { + dev_err(&client->dev, "iio allocation failed!\n"); + return -ENOMEM; + } + + data = iio_priv(indio_dev); + data->client = client; + i2c_set_clientdata(client, indio_dev); + mutex_init(&data->lock); + data->mode = MMA7660_MODE_STANDBY; + + indio_dev->dev.parent = &client->dev; + indio_dev->info = &mma7660_info; + indio_dev->name = MMA7660_DRIVER_NAME; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = mma7660_channels; + indio_dev->num_channels = ARRAY_SIZE(mma7660_channels); + + ret = mma7660_set_mode(data, MMA7660_MODE_ACTIVE); + if (ret < 0) + return ret; + + ret = iio_device_register(indio_dev); + if (ret < 0) { + dev_err(&client->dev, "device_register failed\n"); + mma7660_set_mode(data, MMA7660_MODE_STANDBY); + } + + return ret; +} + +static int mma7660_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + + iio_device_unregister(indio_dev); + + return mma7660_set_mode(iio_priv(indio_dev), MMA7660_MODE_STANDBY); +} + +#ifdef CONFIG_PM_SLEEP +static int mma7660_suspend(struct device *dev) +{ + struct mma7660_data *data; + + data = iio_priv(i2c_get_clientdata(to_i2c_client(dev))); + + return mma7660_set_mode(data, MMA7660_MODE_STANDBY); +} + +static int mma7660_resume(struct device *dev) +{ + struct mma7660_data *data; + + data = iio_priv(i2c_get_clientdata(to_i2c_client(dev))); + + return mma7660_set_mode(data, MMA7660_MODE_ACTIVE); +} + +static SIMPLE_DEV_PM_OPS(mma7660_pm_ops, mma7660_suspend, mma7660_resume); + +#define MMA7660_PM_OPS (&mma7660_pm_ops) +#else +#define MMA7660_PM_OPS NULL +#endif + +static const struct i2c_device_id mma7660_i2c_id[] = { + {"mma7660", 0}, + {} +}; + +static const struct acpi_device_id mma7660_acpi_id[] = { + {"MMA7660", 0}, + {} +}; + +MODULE_DEVICE_TABLE(acpi, mma7660_acpi_id); + +static struct i2c_driver mma7660_driver = { + .driver = { + .name = "mma7660", + .pm = MMA7660_PM_OPS, + .acpi_match_table = ACPI_PTR(mma7660_acpi_id), + }, + .probe = mma7660_probe, + .remove = mma7660_remove, + .id_table = mma7660_i2c_id, +}; + +module_i2c_driver(mma7660_driver); + +MODULE_AUTHOR("Constantin Musca "); +MODULE_DESCRIPTION("Freescale MMA7660FC 3-Axis Accelerometer driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.1 From a91e0b6de468cc4413d8ca260ed4ed0366dfb5b7 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Sat, 23 Apr 2016 19:57:57 +0000 Subject: iio: mxs-lradc: simplify TS registration This patch simplifies the TS registration of mxs-lradc by using devm_input_allocate_device. Signed-off-by: Stefan Wahren Reviewed-by: Marek Vasut Acked-by: Dmitry Torokhov Signed-off-by: Jonathan Cameron --- drivers/iio/adc/mxs-lradc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/mxs-lradc.c b/drivers/iio/adc/mxs-lradc.c index ad26da1..3d1d370 100644 --- a/drivers/iio/adc/mxs-lradc.c +++ b/drivers/iio/adc/mxs-lradc.c @@ -1120,18 +1120,16 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc) { struct input_dev *input; struct device *dev = lradc->dev; - int ret; if (!lradc->use_touchscreen) return 0; - input = input_allocate_device(); + input = devm_input_allocate_device(dev); if (!input) return -ENOMEM; input->name = DRIVER_NAME; input->id.bustype = BUS_HOST; - input->dev.parent = dev; input->open = mxs_lradc_ts_open; input->close = mxs_lradc_ts_close; @@ -1146,11 +1144,8 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc) lradc->ts_input = input; input_set_drvdata(input, lradc); - ret = input_register_device(input); - if (ret) - input_free_device(lradc->ts_input); - return ret; + return input_register_device(input); } static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc) @@ -1159,7 +1154,6 @@ static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc) return; mxs_lradc_disable_ts(lradc); - input_unregister_device(lradc->ts_input); } /* -- cgit v1.1 From 962ed43a3eac49da65ad90fd1036e74faa5b5066 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Sat, 23 Apr 2016 19:57:58 +0000 Subject: iio: mxs-lradc: remove mxs_lradc_ts_unregister After using devm_input_allocate_device for registration the function mxs_lradc_ts_unregister isn't necessary anymore since mxs_lradc_ts_close already does the job. Signed-off-by: Stefan Wahren Suggested-by: Dmitry Torokhov Acked-by: Dmitry Torokhov Signed-off-by: Jonathan Cameron --- drivers/iio/adc/mxs-lradc.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/iio/adc/mxs-lradc.c b/drivers/iio/adc/mxs-lradc.c index 3d1d370..90242ba 100644 --- a/drivers/iio/adc/mxs-lradc.c +++ b/drivers/iio/adc/mxs-lradc.c @@ -1148,14 +1148,6 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc) return input_register_device(input); } -static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc) -{ - if (!lradc->use_touchscreen) - return; - - mxs_lradc_disable_ts(lradc); -} - /* * IRQ Handling */ @@ -1715,13 +1707,11 @@ static int mxs_lradc_probe(struct platform_device *pdev) ret = iio_device_register(iio); if (ret) { dev_err(dev, "Failed to register IIO device\n"); - goto err_ts; + return ret; } return 0; -err_ts: - mxs_lradc_ts_unregister(lradc); err_ts_register: mxs_lradc_hw_stop(lradc); err_dev: @@ -1739,7 +1729,6 @@ static int mxs_lradc_remove(struct platform_device *pdev) struct mxs_lradc *lradc = iio_priv(iio); iio_device_unregister(iio); - mxs_lradc_ts_unregister(lradc); mxs_lradc_hw_stop(lradc); mxs_lradc_trigger_remove(iio); iio_triggered_buffer_cleanup(iio); -- cgit v1.1 From 331dd5be97a9a241329a99cbe19e217273ae541b Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Sat, 23 Apr 2016 19:57:59 +0000 Subject: iio: mxs-lradc: disable only masked channels in mxs_lradc_hw_stop Disabling of the touchscreen IRQs should be done in mxs_lradc_disable_ts. So disable only the masked virtual channels in mxs_lradc_hw_stop and finally remove the unused function mxs_lradc_irq_en_mask. Signed-off-by: Stefan Wahren Reviewed-by: Marek Vasut Tested-by: Marek Vasut Signed-off-by: Jonathan Cameron --- drivers/iio/adc/mxs-lradc.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/mxs-lradc.c b/drivers/iio/adc/mxs-lradc.c index 90242ba..b84d37c 100644 --- a/drivers/iio/adc/mxs-lradc.c +++ b/drivers/iio/adc/mxs-lradc.c @@ -373,13 +373,6 @@ static u32 mxs_lradc_plate_mask(struct mxs_lradc *lradc) return LRADC_CTRL0_MX28_PLATE_MASK; } -static u32 mxs_lradc_irq_en_mask(struct mxs_lradc *lradc) -{ - if (lradc->soc == IMX23_LRADC) - return LRADC_CTRL1_MX23_LRADC_IRQ_EN_MASK; - return LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK; -} - static u32 mxs_lradc_irq_mask(struct mxs_lradc *lradc) { if (lradc->soc == IMX23_LRADC) @@ -1496,7 +1489,9 @@ static void mxs_lradc_hw_stop(struct mxs_lradc *lradc) { int i; - mxs_lradc_reg_clear(lradc, mxs_lradc_irq_en_mask(lradc), LRADC_CTRL1); + mxs_lradc_reg_clear(lradc, + lradc->buffer_vchans << LRADC_CTRL1_LRADC_IRQ_EN_OFFSET, + LRADC_CTRL1); for (i = 0; i < LRADC_MAX_DELAY_CHANS; i++) mxs_lradc_reg_wrt(lradc, 0, LRADC_DELAY(i)); -- cgit v1.1 From 216912e3f1aa6c7216ba7913c8694c41c885fa04 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Fri, 29 Apr 2016 14:42:35 +0300 Subject: imu: bmi160: Add avail frequency and scale attributes Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/imu/bmi160/bmi160_core.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c index 0bf92b0..914e2e7 100644 --- a/drivers/iio/imu/bmi160/bmi160_core.c +++ b/drivers/iio/imu/bmi160/bmi160_core.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "bmi160.h" @@ -466,10 +467,36 @@ static int bmi160_write_raw(struct iio_dev *indio_dev, return 0; } +static +IIO_CONST_ATTR(in_accel_sampling_frequency_available, + "0.78125 1.5625 3.125 6.25 12.5 25 50 100 200 400 800 1600"); +static +IIO_CONST_ATTR(in_anglvel_sampling_frequency_available, + "25 50 100 200 400 800 1600 3200"); +static +IIO_CONST_ATTR(in_accel_scale_available, + "0.000598 0.001197 0.002394 0.004788"); +static +IIO_CONST_ATTR(in_anglvel_scale_available, + "0.001065 0.000532 0.000266 0.000133 0.000066"); + +static struct attribute *bmi160_attrs[] = { + &iio_const_attr_in_accel_sampling_frequency_available.dev_attr.attr, + &iio_const_attr_in_anglvel_sampling_frequency_available.dev_attr.attr, + &iio_const_attr_in_accel_scale_available.dev_attr.attr, + &iio_const_attr_in_anglvel_scale_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group bmi160_attrs_group = { + .attrs = bmi160_attrs, +}; + 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, }; static const char *bmi160_match_acpi_device(struct device *dev) -- cgit v1.1 From f59e6b5ae0a9dd94ac9a3d5d95f8650649343dc3 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 1 May 2016 15:36:51 -0500 Subject: iio: health/afe440x: Fix kernel-doc format Fix kernel-doc formatting for structs, and while we are making little fixes, clarify the module description and update the copywrite. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- drivers/iio/health/afe4403.c | 18 +++++++++--------- drivers/iio/health/afe4404.c | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index 88e43f8..2094113 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -1,7 +1,7 @@ /* * AFE4403 Heart Rate Monitors and Low-Cost Pulse Oximeters * - * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/ * Andrew F. Davis * * This program is free software; you can redistribute it and/or modify @@ -103,13 +103,13 @@ #define AFE4403_TIAGAIN_RES_NONE 0x7 /** - * struct afe4403_data - * @dev - Device structure - * @spi - SPI device handle - * @regmap - Register map of the device - * @regulator - Pointer to the regulator for the IC - * @trig - IIO trigger for this device - * @irq - ADC_RDY line interrupt number + * struct afe4403_data - AFE4403 device instance data + * @dev: Device structure + * @spi: SPI device handle + * @regmap: Register map of the device + * @regulator: Pointer to the regulator for the IC + * @trig: IIO trigger for this device + * @irq: ADC_RDY line interrupt number */ struct afe4403_data { struct device *dev; @@ -704,5 +704,5 @@ static struct spi_driver afe4403_spi_driver = { module_spi_driver(afe4403_spi_driver); MODULE_AUTHOR("Andrew F. Davis "); -MODULE_DESCRIPTION("TI AFE4403 Heart Rate and Pulse Oximeter"); +MODULE_DESCRIPTION("TI AFE4403 Heart Rate Monitor and Pulse Oximeter AFE"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index 5096a46..7127d03 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -1,7 +1,7 @@ /* * AFE4404 Heart Rate Monitors and Low-Cost Pulse Oximeters * - * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/ * Andrew F. Davis * * This program is free software; you can redistribute it and/or modify @@ -106,12 +106,12 @@ #define AFE4404_TIA_GAIN_RES_2_M 0x7 /** - * struct afe4404_data - * @dev - Device structure - * @regmap - Register map of the device - * @regulator - Pointer to the regulator for the IC - * @trig - IIO trigger for this device - * @irq - ADC_RDY line interrupt number + * struct afe4404_data - AFE4404 device instance data + * @dev: Device structure + * @regmap: Register map of the device + * @regulator: Pointer to the regulator for the IC + * @trig: IIO trigger for this device + * @irq: ADC_RDY line interrupt number */ struct afe4404_data { struct device *dev; @@ -675,5 +675,5 @@ static struct i2c_driver afe4404_i2c_driver = { module_i2c_driver(afe4404_i2c_driver); MODULE_AUTHOR("Andrew F. Davis "); -MODULE_DESCRIPTION("TI AFE4404 Heart Rate and Pulse Oximeter"); +MODULE_DESCRIPTION("TI AFE4404 Heart Rate Monitor and Pulse Oximeter AFE"); MODULE_LICENSE("GPL v2"); -- cgit v1.1 From daffd7a75c7e878845ddae8e16d9dc76eea7e2d2 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 1 May 2016 15:36:52 -0500 Subject: iio: health/afe440x: Remove of_match_ptr and ifdefs The drivers DT tables are not built-in when OF is not enabled, this does not save us enough to justify ugly ifdefs. Clean this up. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- drivers/iio/health/afe4403.c | 4 +--- drivers/iio/health/afe4404.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index 2094113..e3700cf 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -498,13 +498,11 @@ static const struct regmap_config afe4403_regmap_config = { .volatile_table = &afe4403_volatile_table, }; -#ifdef CONFIG_OF static const struct of_device_id afe4403_of_match[] = { { .compatible = "ti,afe4403", }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, afe4403_of_match); -#endif static int __maybe_unused afe4403_suspend(struct device *dev) { @@ -694,7 +692,7 @@ MODULE_DEVICE_TABLE(spi, afe4403_ids); static struct spi_driver afe4403_spi_driver = { .driver = { .name = AFE4403_DRIVER_NAME, - .of_match_table = of_match_ptr(afe4403_of_match), + .of_match_table = afe4403_of_match, .pm = &afe4403_pm_ops, }, .probe = afe4403_probe, diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index 7127d03..783b9b4 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -469,13 +469,11 @@ static const struct regmap_config afe4404_regmap_config = { .volatile_table = &afe4404_volatile_table, }; -#ifdef CONFIG_OF static const struct of_device_id afe4404_of_match[] = { { .compatible = "ti,afe4404", }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, afe4404_of_match); -#endif static int __maybe_unused afe4404_suspend(struct device *dev) { @@ -665,7 +663,7 @@ MODULE_DEVICE_TABLE(i2c, afe4404_ids); static struct i2c_driver afe4404_i2c_driver = { .driver = { .name = AFE4404_DRIVER_NAME, - .of_match_table = of_match_ptr(afe4404_of_match), + .of_match_table = afe4404_of_match, .pm = &afe4404_pm_ops, }, .probe = afe4404_probe, -- cgit v1.1 From e85fa0338b4c0399d7c42837f45f9afb8ede7541 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 1 May 2016 15:36:53 -0500 Subject: iio: health/afe440x: Remove unneeded initializers The drivers set some register values during initialization that can be set at runtime, these defaults were used in testing but are not necessary, remove these. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- drivers/iio/health/afe4403.c | 7 +------ drivers/iio/health/afe4404.c | 4 ---- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index e3700cf..5484785 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -472,12 +472,7 @@ static const struct iio_trigger_ops afe4403_trigger_ops = { static const struct reg_sequence afe4403_reg_sequences[] = { AFE4403_TIMING_PAIRS, - { AFE440X_CONTROL1, AFE440X_CONTROL1_TIMEREN | 0x000007}, - { AFE4403_TIA_AMB_GAIN, AFE4403_TIAGAIN_RES_1_M }, - { AFE440X_LEDCNTRL, (0x14 << AFE440X_LEDCNTRL_LED1_SHIFT) | - (0x14 << AFE440X_LEDCNTRL_LED2_SHIFT) }, - { AFE440X_CONTROL2, AFE440X_CONTROL2_TX_REF_050 << - AFE440X_CONTROL2_TX_REF_SHIFT }, + { AFE440X_CONTROL1, AFE440X_CONTROL1_TIMEREN }, }; static const struct regmap_range afe4403_yes_ranges[] = { diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index 783b9b4..2d4c522 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -443,10 +443,6 @@ static const struct iio_trigger_ops afe4404_trigger_ops = { static const struct reg_sequence afe4404_reg_sequences[] = { AFE4404_TIMING_PAIRS, { AFE440X_CONTROL1, AFE440X_CONTROL1_TIMEREN }, - { AFE4404_TIA_GAIN, AFE4404_TIA_GAIN_RES_50_K }, - { AFE440X_LEDCNTRL, (0xf << AFE4404_LEDCNTRL_ILED1_SHIFT) | - (0x3 << AFE4404_LEDCNTRL_ILED2_SHIFT) | - (0x3 << AFE4404_LEDCNTRL_ILED3_SHIFT) }, { AFE440X_CONTROL2, AFE440X_CONTROL3_OSC_ENABLE }, }; -- cgit v1.1 From 81f517270da632c0ddf4c511a086d5aa7e5606ee Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 1 May 2016 15:36:54 -0500 Subject: iio: health/afe440x: Always use separate gain values Locking the two gain stages to the same setting adds no value for us, so initialize them as unlocked and remove the sysfs for unlocking them. This also allows us to greatly simplify showing and setting the gain registers. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- .../ABI/testing/sysfs-bus-iio-health-afe440x | 9 ---- drivers/iio/health/afe4403.c | 60 ++++++---------------- drivers/iio/health/afe4404.c | 60 ++++++---------------- drivers/iio/health/afe440x.h | 15 ++---- 4 files changed, 37 insertions(+), 107 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio-health-afe440x b/Documentation/ABI/testing/sysfs-bus-iio-health-afe440x index 3740f25..b19053a 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio-health-afe440x +++ b/Documentation/ABI/testing/sysfs-bus-iio-health-afe440x @@ -8,15 +8,6 @@ Description: Transimpedance Amplifier. Y is 1 for Rf1 and Cf1, Y is 2 for Rf2 and Cf2 values. -What: /sys/bus/iio/devices/iio:deviceX/tia_separate_en -Date: December 2015 -KernelVersion: -Contact: Andrew F. Davis -Description: - Enable or disable separate settings for the TransImpedance - Amplifier above, when disabled both values are set by the - first channel. - What: /sys/bus/iio/devices/iio:deviceX/in_intensity_ledY_raw /sys/bus/iio/devices/iio:deviceX/in_intensity_ledY_ambient_raw Date: December 2015 diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index 5484785..bcff528 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -180,9 +180,9 @@ static ssize_t afe440x_show_register(struct device *dev, struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct afe4403_data *afe = iio_priv(indio_dev); struct afe440x_attr *afe440x_attr = to_afe440x_attr(attr); - unsigned int reg_val, type; + unsigned int reg_val; int vals[2]; - int ret, val_len; + int ret; ret = regmap_read(afe->regmap, afe440x_attr->reg, ®_val); if (ret) @@ -191,27 +191,13 @@ static ssize_t afe440x_show_register(struct device *dev, reg_val &= afe440x_attr->mask; reg_val >>= afe440x_attr->shift; - switch (afe440x_attr->type) { - case SIMPLE: - type = IIO_VAL_INT; - val_len = 1; - vals[0] = reg_val; - break; - case RESISTANCE: - case CAPACITANCE: - type = IIO_VAL_INT_PLUS_MICRO; - val_len = 2; - if (reg_val < afe440x_attr->table_size) { - vals[0] = afe440x_attr->val_table[reg_val].integer; - vals[1] = afe440x_attr->val_table[reg_val].fract; - break; - } + if (reg_val >= afe440x_attr->table_size) return -EINVAL; - default: - return -EINVAL; - } - return iio_format_value(buf, type, val_len, vals); + vals[0] = afe440x_attr->val_table[reg_val].integer; + vals[1] = afe440x_attr->val_table[reg_val].fract; + + return iio_format_value(buf, IIO_VAL_INT_PLUS_MICRO, 2, vals); } static ssize_t afe440x_store_register(struct device *dev, @@ -227,22 +213,12 @@ static ssize_t afe440x_store_register(struct device *dev, if (ret) return ret; - switch (afe440x_attr->type) { - case SIMPLE: - val = integer; - break; - case RESISTANCE: - case CAPACITANCE: - for (val = 0; val < afe440x_attr->table_size; val++) - if (afe440x_attr->val_table[val].integer == integer && - afe440x_attr->val_table[val].fract == fract) - break; - if (val == afe440x_attr->table_size) - return -EINVAL; - break; - default: + for (val = 0; val < afe440x_attr->table_size; val++) + if (afe440x_attr->val_table[val].integer == integer && + afe440x_attr->val_table[val].fract == fract) + break; + if (val == afe440x_attr->table_size) return -EINVAL; - } ret = regmap_update_bits(afe->regmap, afe440x_attr->reg, afe440x_attr->mask, @@ -253,16 +229,13 @@ static ssize_t afe440x_store_register(struct device *dev, return count; } -static AFE440X_ATTR(tia_separate_en, AFE4403_TIAGAIN, AFE440X_TIAGAIN_ENSEPGAIN, SIMPLE, NULL, 0); - -static AFE440X_ATTR(tia_resistance1, AFE4403_TIAGAIN, AFE4403_TIAGAIN_RES, RESISTANCE, afe4403_res_table, ARRAY_SIZE(afe4403_res_table)); -static AFE440X_ATTR(tia_capacitance1, AFE4403_TIAGAIN, AFE4403_TIAGAIN_CAP, CAPACITANCE, afe4403_cap_table, ARRAY_SIZE(afe4403_cap_table)); +static AFE440X_ATTR(tia_resistance1, AFE4403_TIAGAIN, AFE4403_TIAGAIN_RES, afe4403_res_table); +static AFE440X_ATTR(tia_capacitance1, AFE4403_TIAGAIN, AFE4403_TIAGAIN_CAP, afe4403_cap_table); -static AFE440X_ATTR(tia_resistance2, AFE4403_TIA_AMB_GAIN, AFE4403_TIAGAIN_RES, RESISTANCE, afe4403_res_table, ARRAY_SIZE(afe4403_res_table)); -static AFE440X_ATTR(tia_capacitance2, AFE4403_TIA_AMB_GAIN, AFE4403_TIAGAIN_RES, CAPACITANCE, afe4403_cap_table, ARRAY_SIZE(afe4403_cap_table)); +static AFE440X_ATTR(tia_resistance2, AFE4403_TIA_AMB_GAIN, AFE4403_TIAGAIN_RES, afe4403_res_table); +static AFE440X_ATTR(tia_capacitance2, AFE4403_TIA_AMB_GAIN, AFE4403_TIAGAIN_RES, afe4403_cap_table); static struct attribute *afe440x_attributes[] = { - &afe440x_attr_tia_separate_en.dev_attr.attr, &afe440x_attr_tia_resistance1.dev_attr.attr, &afe440x_attr_tia_capacitance1.dev_attr.attr, &afe440x_attr_tia_resistance2.dev_attr.attr, @@ -473,6 +446,7 @@ static const struct iio_trigger_ops afe4403_trigger_ops = { static const struct reg_sequence afe4403_reg_sequences[] = { AFE4403_TIMING_PAIRS, { AFE440X_CONTROL1, AFE440X_CONTROL1_TIMEREN }, + { AFE4403_TIAGAIN, AFE440X_TIAGAIN_ENSEPGAIN }, }; static const struct regmap_range afe4403_yes_ranges[] = { diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index 2d4c522..b9c1666 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -193,9 +193,9 @@ static ssize_t afe440x_show_register(struct device *dev, struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct afe4404_data *afe = iio_priv(indio_dev); struct afe440x_attr *afe440x_attr = to_afe440x_attr(attr); - unsigned int reg_val, type; + unsigned int reg_val; int vals[2]; - int ret, val_len; + int ret; ret = regmap_read(afe->regmap, afe440x_attr->reg, ®_val); if (ret) @@ -204,27 +204,13 @@ static ssize_t afe440x_show_register(struct device *dev, reg_val &= afe440x_attr->mask; reg_val >>= afe440x_attr->shift; - switch (afe440x_attr->type) { - case SIMPLE: - type = IIO_VAL_INT; - val_len = 1; - vals[0] = reg_val; - break; - case RESISTANCE: - case CAPACITANCE: - type = IIO_VAL_INT_PLUS_MICRO; - val_len = 2; - if (reg_val < afe440x_attr->table_size) { - vals[0] = afe440x_attr->val_table[reg_val].integer; - vals[1] = afe440x_attr->val_table[reg_val].fract; - break; - } + if (reg_val >= afe440x_attr->table_size) return -EINVAL; - default: - return -EINVAL; - } - return iio_format_value(buf, type, val_len, vals); + vals[0] = afe440x_attr->val_table[reg_val].integer; + vals[1] = afe440x_attr->val_table[reg_val].fract; + + return iio_format_value(buf, IIO_VAL_INT_PLUS_MICRO, 2, vals); } static ssize_t afe440x_store_register(struct device *dev, @@ -240,22 +226,12 @@ static ssize_t afe440x_store_register(struct device *dev, if (ret) return ret; - switch (afe440x_attr->type) { - case SIMPLE: - val = integer; - break; - case RESISTANCE: - case CAPACITANCE: - for (val = 0; val < afe440x_attr->table_size; val++) - if (afe440x_attr->val_table[val].integer == integer && - afe440x_attr->val_table[val].fract == fract) - break; - if (val == afe440x_attr->table_size) - return -EINVAL; - break; - default: + for (val = 0; val < afe440x_attr->table_size; val++) + if (afe440x_attr->val_table[val].integer == integer && + afe440x_attr->val_table[val].fract == fract) + break; + if (val == afe440x_attr->table_size) return -EINVAL; - } ret = regmap_update_bits(afe->regmap, afe440x_attr->reg, afe440x_attr->mask, @@ -266,16 +242,13 @@ static ssize_t afe440x_store_register(struct device *dev, return count; } -static AFE440X_ATTR(tia_separate_en, AFE4404_TIA_GAIN_SEP, AFE440X_TIAGAIN_ENSEPGAIN, SIMPLE, NULL, 0); - -static AFE440X_ATTR(tia_resistance1, AFE4404_TIA_GAIN, AFE4404_TIA_GAIN_RES, RESISTANCE, afe4404_res_table, ARRAY_SIZE(afe4404_res_table)); -static AFE440X_ATTR(tia_capacitance1, AFE4404_TIA_GAIN, AFE4404_TIA_GAIN_CAP, CAPACITANCE, afe4404_cap_table, ARRAY_SIZE(afe4404_cap_table)); +static AFE440X_ATTR(tia_resistance1, AFE4404_TIA_GAIN, AFE4404_TIA_GAIN_RES, afe4404_res_table); +static AFE440X_ATTR(tia_capacitance1, AFE4404_TIA_GAIN, AFE4404_TIA_GAIN_CAP, afe4404_cap_table); -static AFE440X_ATTR(tia_resistance2, AFE4404_TIA_GAIN_SEP, AFE4404_TIA_GAIN_RES, RESISTANCE, afe4404_res_table, ARRAY_SIZE(afe4404_res_table)); -static AFE440X_ATTR(tia_capacitance2, AFE4404_TIA_GAIN_SEP, AFE4404_TIA_GAIN_CAP, CAPACITANCE, afe4404_cap_table, ARRAY_SIZE(afe4404_cap_table)); +static AFE440X_ATTR(tia_resistance2, AFE4404_TIA_GAIN_SEP, AFE4404_TIA_GAIN_RES, afe4404_res_table); +static AFE440X_ATTR(tia_capacitance2, AFE4404_TIA_GAIN_SEP, AFE4404_TIA_GAIN_CAP, afe4404_cap_table); static struct attribute *afe440x_attributes[] = { - &afe440x_attr_tia_separate_en.dev_attr.attr, &afe440x_attr_tia_resistance1.dev_attr.attr, &afe440x_attr_tia_capacitance1.dev_attr.attr, &afe440x_attr_tia_resistance2.dev_attr.attr, @@ -443,6 +416,7 @@ static const struct iio_trigger_ops afe4404_trigger_ops = { static const struct reg_sequence afe4404_reg_sequences[] = { AFE4404_TIMING_PAIRS, { AFE440X_CONTROL1, AFE440X_CONTROL1_TIMEREN }, + { AFE4404_TIA_GAIN_SEP, AFE440X_TIAGAIN_ENSEPGAIN }, { AFE440X_CONTROL2, AFE440X_CONTROL3_OSC_ENABLE }, }; diff --git a/drivers/iio/health/afe440x.h b/drivers/iio/health/afe440x.h index c671ab7..544bbab 100644 --- a/drivers/iio/health/afe440x.h +++ b/drivers/iio/health/afe440x.h @@ -71,8 +71,7 @@ #define AFE440X_CONTROL1_TIMEREN BIT(8) /* TIAGAIN register fields */ -#define AFE440X_TIAGAIN_ENSEPGAIN_MASK BIT(15) -#define AFE440X_TIAGAIN_ENSEPGAIN_SHIFT 15 +#define AFE440X_TIAGAIN_ENSEPGAIN BIT(15) /* CONTROL2 register fields */ #define AFE440X_CONTROL2_PDN_AFE BIT(0) @@ -133,12 +132,6 @@ struct afe440x_reg_info { .output = true, \ } -enum afe440x_reg_type { - SIMPLE, - RESISTANCE, - CAPACITANCE, -}; - struct afe440x_val_table { int integer; int fract; @@ -167,7 +160,6 @@ struct afe440x_attr { unsigned int reg; unsigned int shift; unsigned int mask; - enum afe440x_reg_type type; const struct afe440x_val_table *val_table; unsigned int table_size; }; @@ -175,7 +167,7 @@ struct afe440x_attr { #define to_afe440x_attr(_dev_attr) \ container_of(_dev_attr, struct afe440x_attr, dev_attr) -#define AFE440X_ATTR(_name, _reg, _field, _type, _table, _size) \ +#define AFE440X_ATTR(_name, _reg, _field, _table) \ struct afe440x_attr afe440x_attr_##_name = { \ .dev_attr = __ATTR(_name, (S_IRUGO | S_IWUSR), \ afe440x_show_register, \ @@ -183,9 +175,8 @@ struct afe440x_attr { .reg = _reg, \ .shift = _field ## _SHIFT, \ .mask = _field ## _MASK, \ - .type = _type, \ .val_table = _table, \ - .table_size = _size, \ + .table_size = ARRAY_SIZE(_table), \ } #endif /* _AFE440X_H */ -- cgit v1.1 From 9d3d9a57e4242b155b965f58639a230b212a0ea5 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 1 May 2016 15:36:55 -0500 Subject: iio: health/afe440x: Fix scan_index assignment The LED channels are not scannable and so scan_index should be negative, fix this here. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- drivers/iio/health/afe440x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/health/afe440x.h b/drivers/iio/health/afe440x.h index 544bbab..583d071 100644 --- a/drivers/iio/health/afe440x.h +++ b/drivers/iio/health/afe440x.h @@ -125,7 +125,7 @@ struct afe440x_reg_info { .type = IIO_CURRENT, \ .channel = _index, \ .address = _index, \ - .scan_index = _index, \ + .scan_index = -1, \ .extend_name = _name, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ BIT(IIO_CHAN_INFO_SCALE), \ -- cgit v1.1 From 2e0df3a583af9297259ff5512c1a843220492770 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 1 May 2016 15:36:56 -0500 Subject: iio: health/afe440x: Remove unneeded offset handling No channel in the afe4403 driver has IIO_CHAN_INFO_OFFSET set so remove the handlers for this. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- drivers/iio/health/afe4403.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index bcff528..cac6090 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -293,14 +293,6 @@ static int afe4403_read_raw(struct iio_dev *indio_dev, if (ret) return ret; return IIO_VAL_INT; - case IIO_CHAN_INFO_OFFSET: - ret = regmap_read(afe->regmap, reg_info.offreg, - val); - if (ret) - return ret; - *val &= reg_info.mask; - *val >>= reg_info.shift; - return IIO_VAL_INT; } break; case IIO_CURRENT: @@ -333,15 +325,6 @@ static int afe4403_write_raw(struct iio_dev *indio_dev, const struct afe440x_reg_info reg_info = afe4403_reg_info[chan->address]; switch (chan->type) { - case IIO_INTENSITY: - switch (mask) { - case IIO_CHAN_INFO_OFFSET: - return regmap_update_bits(afe->regmap, - reg_info.offreg, - reg_info.mask, - (val << reg_info.shift)); - } - break; case IIO_CURRENT: switch (mask) { case IIO_CHAN_INFO_RAW: -- cgit v1.1 From 606c7e6c1b02054febd78aac1d3cff448c7bd052 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 1 May 2016 15:36:57 -0500 Subject: iio: health/afe4404: Remove LED3 input channel Input channel LED3 is only an alias for stage ALED2, this virtual channel does nothing for us, remove this channel. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- drivers/iio/health/afe4404.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index b9c1666..2edb7d7 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -126,7 +126,6 @@ enum afe4404_chan_id { ALED1, LED2, ALED2, - LED3, LED1_ALED1, LED2_ALED2, ILED1, @@ -139,7 +138,6 @@ static const struct afe440x_reg_info afe4404_reg_info[] = { [ALED1] = AFE440X_REG_INFO(AFE440X_ALED1VAL, AFE4404_OFFDAC, AFE4404_OFFDAC_CURR_ALED1), [LED2] = AFE440X_REG_INFO(AFE440X_LED2VAL, AFE4404_OFFDAC, AFE4404_OFFDAC_CURR_LED2), [ALED2] = AFE440X_REG_INFO(AFE440X_ALED2VAL, AFE4404_OFFDAC, AFE4404_OFFDAC_CURR_ALED2), - [LED3] = AFE440X_REG_INFO(AFE440X_ALED2VAL, 0, NULL), [LED1_ALED1] = AFE440X_REG_INFO(AFE440X_LED1_ALED1VAL, 0, NULL), [LED2_ALED2] = AFE440X_REG_INFO(AFE440X_LED2_ALED2VAL, 0, NULL), [ILED1] = AFE440X_REG_INFO(AFE440X_LEDCNTRL, 0, AFE4404_LEDCNTRL_ILED1), @@ -153,7 +151,6 @@ static const struct iio_chan_spec afe4404_channels[] = { AFE440X_INTENSITY_CHAN(ALED1, "led1_ambient", BIT(IIO_CHAN_INFO_OFFSET)), AFE440X_INTENSITY_CHAN(LED2, "led2", BIT(IIO_CHAN_INFO_OFFSET)), AFE440X_INTENSITY_CHAN(ALED2, "led2_ambient", BIT(IIO_CHAN_INFO_OFFSET)), - AFE440X_INTENSITY_CHAN(LED3, "led3", BIT(IIO_CHAN_INFO_OFFSET)), AFE440X_INTENSITY_CHAN(LED1_ALED1, "led1-led1_ambient", 0), AFE440X_INTENSITY_CHAN(LED2_ALED2, "led2-led2_ambient", 0), /* LED current */ -- cgit v1.1 From 24b9dea764bdf0de8434fb4567e7f62038ba869e Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 1 May 2016 15:36:58 -0500 Subject: iio: health/afe440x: Remove channel names These AFEs have 4 ADC mesuring stages (called LED2, ALED2, LED1, and ALED1 in the datasheet), we map these as channels, these stages can serve different purposes depending on the application. For instance the AFE4404 has an additional LED (LED3), this LED can be timed to be active during stage 2 (or anystage, but the datasheet describes this case and the name of the stage reflects this use). This ability is used further in upcoming parts that tie the front-end gain and the LED timings together. For these reasons we remove explicit naming the channels. Without channel names it is best that the index numbers are in order to match the stage number, reorder the channel numbers. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- .../ABI/testing/sysfs-bus-iio-health-afe440x | 39 ++++++++++------------ drivers/iio/health/afe4403.c | 28 ++++++++-------- drivers/iio/health/afe4404.c | 30 ++++++++--------- drivers/iio/health/afe440x.h | 8 ++--- 4 files changed, 51 insertions(+), 54 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio-health-afe440x b/Documentation/ABI/testing/sysfs-bus-iio-health-afe440x index b19053a..a067073 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio-health-afe440x +++ b/Documentation/ABI/testing/sysfs-bus-iio-health-afe440x @@ -8,38 +8,35 @@ Description: Transimpedance Amplifier. Y is 1 for Rf1 and Cf1, Y is 2 for Rf2 and Cf2 values. -What: /sys/bus/iio/devices/iio:deviceX/in_intensity_ledY_raw - /sys/bus/iio/devices/iio:deviceX/in_intensity_ledY_ambient_raw -Date: December 2015 +What: /sys/bus/iio/devices/iio:deviceX/in_intensityY_raw +Date: May 2016 KernelVersion: Contact: Andrew F. Davis Description: Get measured values from the ADC for these stages. Y is the - specific LED number. The values are expressed in 24-bit twos - complement. - -What: /sys/bus/iio/devices/iio:deviceX/in_intensity_ledY-ledY_ambient_raw -Date: December 2015 -KernelVersion: -Contact: Andrew F. Davis -Description: - Get differential values from the ADC for these stages. Y is the - specific LED number. The values are expressed in 24-bit twos - complement for the specified LEDs. + specific stage number corresponding to datasheet stage names + as follows: + 1 -> LED2 + 2 -> ALED2/LED3 + 3 -> LED1 + 4 -> ALED1/LED4 + Note that channels 5 and 6 represent LED2-ALED2 and LED1-ALED1 + respectively which simply helper channels containing the + calculated difference in the value of stage 1 - 2 and 3 - 4. + The values are expressed in 24-bit twos complement. -What: /sys/bus/iio/devices/iio:deviceX/out_current_ledY_offset - /sys/bus/iio/devices/iio:deviceX/out_current_ledY_ambient_offset -Date: December 2015 +What: /sys/bus/iio/devices/iio:deviceX/in_intensityY_offset +Date: May 2016 KernelVersion: Contact: Andrew F. Davis Description: Get and set the offset cancellation DAC setting for these stages. The values are expressed in 5-bit sign-magnitude. -What: /sys/bus/iio/devices/iio:deviceX/out_current_ledY_raw -Date: December 2015 +What: /sys/bus/iio/devices/iio:deviceX/out_currentY_raw +Date: May 2016 KernelVersion: Contact: Andrew F. Davis Description: - Get and set the LED current for the specified LED. Y is the - specific LED number. + Get and set the LED current for the specified LED active during + this stage. Y is the specific stage number. diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index cac6090..4a58064 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -121,38 +121,38 @@ struct afe4403_data { }; enum afe4403_chan_id { + LED2 = 1, + ALED2, LED1, ALED1, - LED2, - ALED2, - LED1_ALED1, LED2_ALED2, + LED1_ALED1, ILED1, ILED2, }; static const struct afe440x_reg_info afe4403_reg_info[] = { - [LED1] = AFE440X_REG_INFO(AFE440X_LED1VAL, 0, NULL), - [ALED1] = AFE440X_REG_INFO(AFE440X_ALED1VAL, 0, NULL), [LED2] = AFE440X_REG_INFO(AFE440X_LED2VAL, 0, NULL), [ALED2] = AFE440X_REG_INFO(AFE440X_ALED2VAL, 0, NULL), - [LED1_ALED1] = AFE440X_REG_INFO(AFE440X_LED1_ALED1VAL, 0, NULL), + [LED1] = AFE440X_REG_INFO(AFE440X_LED1VAL, 0, NULL), + [ALED1] = AFE440X_REG_INFO(AFE440X_ALED1VAL, 0, NULL), [LED2_ALED2] = AFE440X_REG_INFO(AFE440X_LED2_ALED2VAL, 0, NULL), + [LED1_ALED1] = AFE440X_REG_INFO(AFE440X_LED1_ALED1VAL, 0, NULL), [ILED1] = AFE440X_REG_INFO(AFE440X_LEDCNTRL, 0, AFE440X_LEDCNTRL_LED1), [ILED2] = AFE440X_REG_INFO(AFE440X_LEDCNTRL, 0, AFE440X_LEDCNTRL_LED2), }; static const struct iio_chan_spec afe4403_channels[] = { /* ADC values */ - AFE440X_INTENSITY_CHAN(LED1, "led1", 0), - AFE440X_INTENSITY_CHAN(ALED1, "led1_ambient", 0), - AFE440X_INTENSITY_CHAN(LED2, "led2", 0), - AFE440X_INTENSITY_CHAN(ALED2, "led2_ambient", 0), - AFE440X_INTENSITY_CHAN(LED1_ALED1, "led1-led1_ambient", 0), - AFE440X_INTENSITY_CHAN(LED2_ALED2, "led2-led2_ambient", 0), + AFE440X_INTENSITY_CHAN(LED2, 0), + AFE440X_INTENSITY_CHAN(ALED2, 0), + AFE440X_INTENSITY_CHAN(LED1, 0), + AFE440X_INTENSITY_CHAN(ALED1, 0), + AFE440X_INTENSITY_CHAN(LED2_ALED2, 0), + AFE440X_INTENSITY_CHAN(LED1_ALED1, 0), /* LED current */ - AFE440X_CURRENT_CHAN(ILED1, "led1"), - AFE440X_CURRENT_CHAN(ILED2, "led2"), + AFE440X_CURRENT_CHAN(ILED1), + AFE440X_CURRENT_CHAN(ILED2), }; static const struct afe440x_val_table afe4403_res_table[] = { diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index 2edb7d7..7806a45 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -122,24 +122,24 @@ struct afe4404_data { }; enum afe4404_chan_id { + LED2 = 1, + ALED2, LED1, ALED1, - LED2, - ALED2, - LED1_ALED1, LED2_ALED2, + LED1_ALED1, ILED1, ILED2, ILED3, }; static const struct afe440x_reg_info afe4404_reg_info[] = { - [LED1] = AFE440X_REG_INFO(AFE440X_LED1VAL, AFE4404_OFFDAC, AFE4404_OFFDAC_CURR_LED1), - [ALED1] = AFE440X_REG_INFO(AFE440X_ALED1VAL, AFE4404_OFFDAC, AFE4404_OFFDAC_CURR_ALED1), [LED2] = AFE440X_REG_INFO(AFE440X_LED2VAL, AFE4404_OFFDAC, AFE4404_OFFDAC_CURR_LED2), [ALED2] = AFE440X_REG_INFO(AFE440X_ALED2VAL, AFE4404_OFFDAC, AFE4404_OFFDAC_CURR_ALED2), - [LED1_ALED1] = AFE440X_REG_INFO(AFE440X_LED1_ALED1VAL, 0, NULL), + [LED1] = AFE440X_REG_INFO(AFE440X_LED1VAL, AFE4404_OFFDAC, AFE4404_OFFDAC_CURR_LED1), + [ALED1] = AFE440X_REG_INFO(AFE440X_ALED1VAL, AFE4404_OFFDAC, AFE4404_OFFDAC_CURR_ALED1), [LED2_ALED2] = AFE440X_REG_INFO(AFE440X_LED2_ALED2VAL, 0, NULL), + [LED1_ALED1] = AFE440X_REG_INFO(AFE440X_LED1_ALED1VAL, 0, NULL), [ILED1] = AFE440X_REG_INFO(AFE440X_LEDCNTRL, 0, AFE4404_LEDCNTRL_ILED1), [ILED2] = AFE440X_REG_INFO(AFE440X_LEDCNTRL, 0, AFE4404_LEDCNTRL_ILED2), [ILED3] = AFE440X_REG_INFO(AFE440X_LEDCNTRL, 0, AFE4404_LEDCNTRL_ILED3), @@ -147,16 +147,16 @@ static const struct afe440x_reg_info afe4404_reg_info[] = { static const struct iio_chan_spec afe4404_channels[] = { /* ADC values */ - AFE440X_INTENSITY_CHAN(LED1, "led1", BIT(IIO_CHAN_INFO_OFFSET)), - AFE440X_INTENSITY_CHAN(ALED1, "led1_ambient", BIT(IIO_CHAN_INFO_OFFSET)), - AFE440X_INTENSITY_CHAN(LED2, "led2", BIT(IIO_CHAN_INFO_OFFSET)), - AFE440X_INTENSITY_CHAN(ALED2, "led2_ambient", BIT(IIO_CHAN_INFO_OFFSET)), - AFE440X_INTENSITY_CHAN(LED1_ALED1, "led1-led1_ambient", 0), - AFE440X_INTENSITY_CHAN(LED2_ALED2, "led2-led2_ambient", 0), + AFE440X_INTENSITY_CHAN(LED2, BIT(IIO_CHAN_INFO_OFFSET)), + AFE440X_INTENSITY_CHAN(ALED2, BIT(IIO_CHAN_INFO_OFFSET)), + AFE440X_INTENSITY_CHAN(LED1, BIT(IIO_CHAN_INFO_OFFSET)), + AFE440X_INTENSITY_CHAN(ALED1, BIT(IIO_CHAN_INFO_OFFSET)), + AFE440X_INTENSITY_CHAN(LED2_ALED2, 0), + AFE440X_INTENSITY_CHAN(LED1_ALED1, 0), /* LED current */ - AFE440X_CURRENT_CHAN(ILED1, "led1"), - AFE440X_CURRENT_CHAN(ILED2, "led2"), - AFE440X_CURRENT_CHAN(ILED3, "led3"), + AFE440X_CURRENT_CHAN(ILED1), + AFE440X_CURRENT_CHAN(ILED2), + AFE440X_CURRENT_CHAN(ILED3), }; static const struct afe440x_val_table afe4404_res_table[] = { diff --git a/drivers/iio/health/afe440x.h b/drivers/iio/health/afe440x.h index 583d071..713972f 100644 --- a/drivers/iio/health/afe440x.h +++ b/drivers/iio/health/afe440x.h @@ -103,7 +103,7 @@ struct afe440x_reg_info { .mask = _sm ## _MASK, \ } -#define AFE440X_INTENSITY_CHAN(_index, _name, _mask) \ +#define AFE440X_INTENSITY_CHAN(_index, _mask) \ { \ .type = IIO_INTENSITY, \ .channel = _index, \ @@ -115,20 +115,20 @@ struct afe440x_reg_info { .storagebits = 32, \ .endianness = IIO_CPU, \ }, \ - .extend_name = _name, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ _mask, \ + .indexed = true, \ } -#define AFE440X_CURRENT_CHAN(_index, _name) \ +#define AFE440X_CURRENT_CHAN(_index) \ { \ .type = IIO_CURRENT, \ .channel = _index, \ .address = _index, \ .scan_index = -1, \ - .extend_name = _name, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ BIT(IIO_CHAN_INFO_SCALE), \ + .indexed = true, \ .output = true, \ } -- cgit v1.1 From b36e8257641a043764c62240316610c81e36376c Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 1 May 2016 15:36:59 -0500 Subject: iio: health/afe440x: Use regmap fields These drivers can use regmap fields to access fields in registers, this allows us to remove some macros/defines and simplify code, do this here. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- drivers/iio/health/afe4403.c | 118 ++++++++++++++++---------------- drivers/iio/health/afe4404.c | 156 ++++++++++++++++++++++--------------------- drivers/iio/health/afe440x.h | 25 +------ 3 files changed, 144 insertions(+), 155 deletions(-) diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index 4a58064..1950155 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -39,32 +39,6 @@ #define AFE4403_TIAGAIN 0x20 #define AFE4403_TIA_AMB_GAIN 0x21 -/* AFE4403 GAIN register fields */ -#define AFE4403_TIAGAIN_RES_MASK GENMASK(2, 0) -#define AFE4403_TIAGAIN_RES_SHIFT 0 -#define AFE4403_TIAGAIN_CAP_MASK GENMASK(7, 3) -#define AFE4403_TIAGAIN_CAP_SHIFT 3 - -/* AFE4403 LEDCNTRL register fields */ -#define AFE440X_LEDCNTRL_LED1_MASK GENMASK(15, 8) -#define AFE440X_LEDCNTRL_LED1_SHIFT 8 -#define AFE440X_LEDCNTRL_LED2_MASK GENMASK(7, 0) -#define AFE440X_LEDCNTRL_LED2_SHIFT 0 -#define AFE440X_LEDCNTRL_LED_RANGE_MASK GENMASK(17, 16) -#define AFE440X_LEDCNTRL_LED_RANGE_SHIFT 16 - -/* AFE4403 CONTROL2 register fields */ -#define AFE440X_CONTROL2_PWR_DWN_TX BIT(2) -#define AFE440X_CONTROL2_EN_SLOW_DIAG BIT(8) -#define AFE440X_CONTROL2_DIAG_OUT_TRI BIT(10) -#define AFE440X_CONTROL2_TX_BRDG_MOD BIT(11) -#define AFE440X_CONTROL2_TX_REF_MASK GENMASK(18, 17) -#define AFE440X_CONTROL2_TX_REF_SHIFT 17 - -/* AFE4404 NULL fields */ -#define NULL_MASK 0 -#define NULL_SHIFT 0 - /* AFE4403 LEDCNTRL values */ #define AFE440X_LEDCNTRL_RANGE_TX_HALF 0x1 #define AFE440X_LEDCNTRL_RANGE_TX_FULL 0x2 @@ -102,11 +76,35 @@ #define AFE4403_TIAGAIN_RES_1_M 0x6 #define AFE4403_TIAGAIN_RES_NONE 0x7 +enum afe4403_fields { + /* Gains */ + F_RF_LED1, F_CF_LED1, + F_RF_LED, F_CF_LED, + + /* LED Current */ + F_ILED1, F_ILED2, + + /* sentinel */ + F_MAX_FIELDS +}; + +static const struct reg_field afe4403_reg_fields[] = { + /* Gains */ + [F_RF_LED1] = REG_FIELD(AFE4403_TIAGAIN, 0, 2), + [F_CF_LED1] = REG_FIELD(AFE4403_TIAGAIN, 3, 7), + [F_RF_LED] = REG_FIELD(AFE4403_TIA_AMB_GAIN, 0, 2), + [F_CF_LED] = REG_FIELD(AFE4403_TIA_AMB_GAIN, 3, 7), + /* LED Current */ + [F_ILED1] = REG_FIELD(AFE440X_LEDCNTRL, 0, 7), + [F_ILED2] = REG_FIELD(AFE440X_LEDCNTRL, 8, 15), +}; + /** * struct afe4403_data - AFE4403 device instance data * @dev: Device structure * @spi: SPI device handle * @regmap: Register map of the device + * @fields: Register fields of the device * @regulator: Pointer to the regulator for the IC * @trig: IIO trigger for this device * @irq: ADC_RDY line interrupt number @@ -115,6 +113,7 @@ struct afe4403_data { struct device *dev; struct spi_device *spi; struct regmap *regmap; + struct regmap_field *fields[F_MAX_FIELDS]; struct regulator *regulator; struct iio_trigger *trig; int irq; @@ -131,15 +130,18 @@ enum afe4403_chan_id { ILED2, }; -static const struct afe440x_reg_info afe4403_reg_info[] = { - [LED2] = AFE440X_REG_INFO(AFE440X_LED2VAL, 0, NULL), - [ALED2] = AFE440X_REG_INFO(AFE440X_ALED2VAL, 0, NULL), - [LED1] = AFE440X_REG_INFO(AFE440X_LED1VAL, 0, NULL), - [ALED1] = AFE440X_REG_INFO(AFE440X_ALED1VAL, 0, NULL), - [LED2_ALED2] = AFE440X_REG_INFO(AFE440X_LED2_ALED2VAL, 0, NULL), - [LED1_ALED1] = AFE440X_REG_INFO(AFE440X_LED1_ALED1VAL, 0, NULL), - [ILED1] = AFE440X_REG_INFO(AFE440X_LEDCNTRL, 0, AFE440X_LEDCNTRL_LED1), - [ILED2] = AFE440X_REG_INFO(AFE440X_LEDCNTRL, 0, AFE440X_LEDCNTRL_LED2), +static const unsigned int afe4403_channel_values[] = { + [LED2] = AFE440X_LED2VAL, + [ALED2] = AFE440X_ALED2VAL, + [LED1] = AFE440X_LED1VAL, + [ALED1] = AFE440X_ALED1VAL, + [LED2_ALED2] = AFE440X_LED2_ALED2VAL, + [LED1_ALED1] = AFE440X_LED1_ALED1VAL, +}; + +static const unsigned int afe4403_channel_leds[] = { + [ILED1] = F_ILED1, + [ILED2] = F_ILED2, }; static const struct iio_chan_spec afe4403_channels[] = { @@ -184,13 +186,10 @@ static ssize_t afe440x_show_register(struct device *dev, int vals[2]; int ret; - ret = regmap_read(afe->regmap, afe440x_attr->reg, ®_val); + ret = regmap_field_read(afe->fields[afe440x_attr->field], ®_val); if (ret) return ret; - reg_val &= afe440x_attr->mask; - reg_val >>= afe440x_attr->shift; - if (reg_val >= afe440x_attr->table_size) return -EINVAL; @@ -220,20 +219,18 @@ static ssize_t afe440x_store_register(struct device *dev, if (val == afe440x_attr->table_size) return -EINVAL; - ret = regmap_update_bits(afe->regmap, afe440x_attr->reg, - afe440x_attr->mask, - (val << afe440x_attr->shift)); + ret = regmap_field_write(afe->fields[afe440x_attr->field], val); if (ret) return ret; return count; } -static AFE440X_ATTR(tia_resistance1, AFE4403_TIAGAIN, AFE4403_TIAGAIN_RES, afe4403_res_table); -static AFE440X_ATTR(tia_capacitance1, AFE4403_TIAGAIN, AFE4403_TIAGAIN_CAP, afe4403_cap_table); +static AFE440X_ATTR(tia_resistance1, F_RF_LED1, afe4403_res_table); +static AFE440X_ATTR(tia_capacitance1, F_CF_LED1, afe4403_cap_table); -static AFE440X_ATTR(tia_resistance2, AFE4403_TIA_AMB_GAIN, AFE4403_TIAGAIN_RES, afe4403_res_table); -static AFE440X_ATTR(tia_capacitance2, AFE4403_TIA_AMB_GAIN, AFE4403_TIAGAIN_RES, afe4403_cap_table); +static AFE440X_ATTR(tia_resistance2, F_RF_LED, afe4403_res_table); +static AFE440X_ATTR(tia_capacitance2, F_CF_LED, afe4403_cap_table); static struct attribute *afe440x_attributes[] = { &afe440x_attr_tia_resistance1.dev_attr.attr, @@ -282,14 +279,15 @@ static int afe4403_read_raw(struct iio_dev *indio_dev, int *val, int *val2, long mask) { struct afe4403_data *afe = iio_priv(indio_dev); - const struct afe440x_reg_info reg_info = afe4403_reg_info[chan->address]; + unsigned int reg = afe4403_channel_values[chan->address]; + unsigned int field = afe4403_channel_leds[chan->address]; int ret; switch (chan->type) { case IIO_INTENSITY: switch (mask) { case IIO_CHAN_INFO_RAW: - ret = afe4403_read(afe, reg_info.reg, val); + ret = afe4403_read(afe, reg, val); if (ret) return ret; return IIO_VAL_INT; @@ -298,11 +296,9 @@ static int afe4403_read_raw(struct iio_dev *indio_dev, case IIO_CURRENT: switch (mask) { case IIO_CHAN_INFO_RAW: - ret = regmap_read(afe->regmap, reg_info.reg, val); + ret = regmap_field_read(afe->fields[field], val); if (ret) return ret; - *val &= reg_info.mask; - *val >>= reg_info.shift; return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = 0; @@ -322,16 +318,13 @@ static int afe4403_write_raw(struct iio_dev *indio_dev, int val, int val2, long mask) { struct afe4403_data *afe = iio_priv(indio_dev); - const struct afe440x_reg_info reg_info = afe4403_reg_info[chan->address]; + unsigned int field = afe4403_channel_leds[chan->address]; switch (chan->type) { case IIO_CURRENT: switch (mask) { case IIO_CHAN_INFO_RAW: - return regmap_update_bits(afe->regmap, - reg_info.reg, - reg_info.mask, - (val << reg_info.shift)); + return regmap_field_write(afe->fields[field], val); } break; default: @@ -366,7 +359,7 @@ static irqreturn_t afe4403_trigger_handler(int irq, void *private) for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) { ret = spi_write_then_read(afe->spi, - &afe4403_reg_info[bit].reg, 1, + &afe4403_channel_values[bit], 1, rx, 3); if (ret) goto err; @@ -503,7 +496,7 @@ static int afe4403_probe(struct spi_device *spi) { struct iio_dev *indio_dev; struct afe4403_data *afe; - int ret; + int i, ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*afe)); if (!indio_dev) @@ -522,6 +515,15 @@ static int afe4403_probe(struct spi_device *spi) return PTR_ERR(afe->regmap); } + for (i = 0; i < F_MAX_FIELDS; i++) { + afe->fields[i] = devm_regmap_field_alloc(afe->dev, afe->regmap, + afe4403_reg_fields[i]); + if (IS_ERR(afe->fields[i])) { + dev_err(afe->dev, "Unable to allocate regmap fields\n"); + return PTR_ERR(afe->fields[i]); + } + } + afe->regulator = devm_regulator_get(afe->dev, "tx_sup"); if (IS_ERR(afe->regulator)) { dev_err(afe->dev, "Unable to get regulator\n"); diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index 7806a45..0d1af4a 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -48,43 +48,9 @@ #define AFE4404_AVG_LED2_ALED2VAL 0x3f #define AFE4404_AVG_LED1_ALED1VAL 0x40 -/* AFE4404 GAIN register fields */ -#define AFE4404_TIA_GAIN_RES_MASK GENMASK(2, 0) -#define AFE4404_TIA_GAIN_RES_SHIFT 0 -#define AFE4404_TIA_GAIN_CAP_MASK GENMASK(5, 3) -#define AFE4404_TIA_GAIN_CAP_SHIFT 3 - -/* AFE4404 LEDCNTRL register fields */ -#define AFE4404_LEDCNTRL_ILED1_MASK GENMASK(5, 0) -#define AFE4404_LEDCNTRL_ILED1_SHIFT 0 -#define AFE4404_LEDCNTRL_ILED2_MASK GENMASK(11, 6) -#define AFE4404_LEDCNTRL_ILED2_SHIFT 6 -#define AFE4404_LEDCNTRL_ILED3_MASK GENMASK(17, 12) -#define AFE4404_LEDCNTRL_ILED3_SHIFT 12 - -/* AFE4404 CONTROL2 register fields */ -#define AFE440X_CONTROL2_ILED_2X_MASK BIT(17) -#define AFE440X_CONTROL2_ILED_2X_SHIFT 17 - /* AFE4404 CONTROL3 register fields */ #define AFE440X_CONTROL3_OSC_ENABLE BIT(9) -/* AFE4404 OFFDAC register current fields */ -#define AFE4404_OFFDAC_CURR_LED1_MASK GENMASK(9, 5) -#define AFE4404_OFFDAC_CURR_LED1_SHIFT 5 -#define AFE4404_OFFDAC_CURR_LED2_MASK GENMASK(19, 15) -#define AFE4404_OFFDAC_CURR_LED2_SHIFT 15 -#define AFE4404_OFFDAC_CURR_LED3_MASK GENMASK(4, 0) -#define AFE4404_OFFDAC_CURR_LED3_SHIFT 0 -#define AFE4404_OFFDAC_CURR_ALED1_MASK GENMASK(14, 10) -#define AFE4404_OFFDAC_CURR_ALED1_SHIFT 10 -#define AFE4404_OFFDAC_CURR_ALED2_MASK GENMASK(4, 0) -#define AFE4404_OFFDAC_CURR_ALED2_SHIFT 0 - -/* AFE4404 NULL fields */ -#define NULL_MASK 0 -#define NULL_SHIFT 0 - /* AFE4404 TIA_GAIN_CAP values */ #define AFE4404_TIA_GAIN_CAP_5_P 0x0 #define AFE4404_TIA_GAIN_CAP_2_5_P 0x1 @@ -105,10 +71,43 @@ #define AFE4404_TIA_GAIN_RES_1_M 0x6 #define AFE4404_TIA_GAIN_RES_2_M 0x7 +enum afe4404_fields { + /* Gains */ + F_TIA_GAIN_SEP, F_TIA_CF_SEP, + F_TIA_GAIN, TIA_CF, + + /* LED Current */ + F_ILED1, F_ILED2, F_ILED3, + + /* Offset DAC */ + F_OFFDAC_AMB2, F_OFFDAC_LED1, F_OFFDAC_AMB1, F_OFFDAC_LED2, + + /* sentinel */ + F_MAX_FIELDS +}; + +static const struct reg_field afe4404_reg_fields[] = { + /* Gains */ + [F_TIA_GAIN_SEP] = REG_FIELD(AFE4404_TIA_GAIN_SEP, 0, 2), + [F_TIA_CF_SEP] = REG_FIELD(AFE4404_TIA_GAIN_SEP, 3, 5), + [F_TIA_GAIN] = REG_FIELD(AFE4404_TIA_GAIN, 0, 2), + [TIA_CF] = REG_FIELD(AFE4404_TIA_GAIN, 3, 5), + /* LED Current */ + [F_ILED1] = REG_FIELD(AFE440X_LEDCNTRL, 0, 5), + [F_ILED2] = REG_FIELD(AFE440X_LEDCNTRL, 6, 11), + [F_ILED3] = REG_FIELD(AFE440X_LEDCNTRL, 12, 17), + /* Offset DAC */ + [F_OFFDAC_AMB2] = REG_FIELD(AFE4404_OFFDAC, 0, 4), + [F_OFFDAC_LED1] = REG_FIELD(AFE4404_OFFDAC, 5, 9), + [F_OFFDAC_AMB1] = REG_FIELD(AFE4404_OFFDAC, 10, 14), + [F_OFFDAC_LED2] = REG_FIELD(AFE4404_OFFDAC, 15, 19), +}; + /** * struct afe4404_data - AFE4404 device instance data * @dev: Device structure * @regmap: Register map of the device + * @fields: Register fields of the device * @regulator: Pointer to the regulator for the IC * @trig: IIO trigger for this device * @irq: ADC_RDY line interrupt number @@ -116,6 +115,7 @@ struct afe4404_data { struct device *dev; struct regmap *regmap; + struct regmap_field *fields[F_MAX_FIELDS]; struct regulator *regulator; struct iio_trigger *trig; int irq; @@ -133,16 +133,26 @@ enum afe4404_chan_id { ILED3, }; -static const struct afe440x_reg_info afe4404_reg_info[] = { - [LED2] = AFE440X_REG_INFO(AFE440X_LED2VAL, AFE4404_OFFDAC, AFE4404_OFFDAC_CURR_LED2), - [ALED2] = AFE440X_REG_INFO(AFE440X_ALED2VAL, AFE4404_OFFDAC, AFE4404_OFFDAC_CURR_ALED2), - [LED1] = AFE440X_REG_INFO(AFE440X_LED1VAL, AFE4404_OFFDAC, AFE4404_OFFDAC_CURR_LED1), - [ALED1] = AFE440X_REG_INFO(AFE440X_ALED1VAL, AFE4404_OFFDAC, AFE4404_OFFDAC_CURR_ALED1), - [LED2_ALED2] = AFE440X_REG_INFO(AFE440X_LED2_ALED2VAL, 0, NULL), - [LED1_ALED1] = AFE440X_REG_INFO(AFE440X_LED1_ALED1VAL, 0, NULL), - [ILED1] = AFE440X_REG_INFO(AFE440X_LEDCNTRL, 0, AFE4404_LEDCNTRL_ILED1), - [ILED2] = AFE440X_REG_INFO(AFE440X_LEDCNTRL, 0, AFE4404_LEDCNTRL_ILED2), - [ILED3] = AFE440X_REG_INFO(AFE440X_LEDCNTRL, 0, AFE4404_LEDCNTRL_ILED3), +static const unsigned int afe4404_channel_values[] = { + [LED2] = AFE440X_LED2VAL, + [ALED2] = AFE440X_ALED2VAL, + [LED1] = AFE440X_LED1VAL, + [ALED1] = AFE440X_ALED1VAL, + [LED2_ALED2] = AFE440X_LED2_ALED2VAL, + [LED1_ALED1] = AFE440X_LED1_ALED1VAL, +}; + +static const unsigned int afe4404_channel_leds[] = { + [ILED1] = F_ILED1, + [ILED2] = F_ILED2, + [ILED3] = F_ILED3, +}; + +static const unsigned int afe4404_channel_offdacs[] = { + [LED2] = F_OFFDAC_LED2, + [ALED2] = F_OFFDAC_AMB2, + [LED1] = F_OFFDAC_LED1, + [ALED1] = F_OFFDAC_AMB1, }; static const struct iio_chan_spec afe4404_channels[] = { @@ -194,13 +204,10 @@ static ssize_t afe440x_show_register(struct device *dev, int vals[2]; int ret; - ret = regmap_read(afe->regmap, afe440x_attr->reg, ®_val); + ret = regmap_field_read(afe->fields[afe440x_attr->field], ®_val); if (ret) return ret; - reg_val &= afe440x_attr->mask; - reg_val >>= afe440x_attr->shift; - if (reg_val >= afe440x_attr->table_size) return -EINVAL; @@ -230,20 +237,18 @@ static ssize_t afe440x_store_register(struct device *dev, if (val == afe440x_attr->table_size) return -EINVAL; - ret = regmap_update_bits(afe->regmap, afe440x_attr->reg, - afe440x_attr->mask, - (val << afe440x_attr->shift)); + ret = regmap_field_write(afe->fields[afe440x_attr->field], val); if (ret) return ret; return count; } -static AFE440X_ATTR(tia_resistance1, AFE4404_TIA_GAIN, AFE4404_TIA_GAIN_RES, afe4404_res_table); -static AFE440X_ATTR(tia_capacitance1, AFE4404_TIA_GAIN, AFE4404_TIA_GAIN_CAP, afe4404_cap_table); +static AFE440X_ATTR(tia_resistance1, F_TIA_GAIN, afe4404_res_table); +static AFE440X_ATTR(tia_capacitance1, TIA_CF, afe4404_cap_table); -static AFE440X_ATTR(tia_resistance2, AFE4404_TIA_GAIN_SEP, AFE4404_TIA_GAIN_RES, afe4404_res_table); -static AFE440X_ATTR(tia_capacitance2, AFE4404_TIA_GAIN_SEP, AFE4404_TIA_GAIN_CAP, afe4404_cap_table); +static AFE440X_ATTR(tia_resistance2, F_TIA_GAIN_SEP, afe4404_res_table); +static AFE440X_ATTR(tia_capacitance2, F_TIA_CF_SEP, afe4404_cap_table); static struct attribute *afe440x_attributes[] = { &afe440x_attr_tia_resistance1.dev_attr.attr, @@ -264,35 +269,32 @@ static int afe4404_read_raw(struct iio_dev *indio_dev, int *val, int *val2, long mask) { struct afe4404_data *afe = iio_priv(indio_dev); - const struct afe440x_reg_info reg_info = afe4404_reg_info[chan->address]; + unsigned int value_reg = afe4404_channel_values[chan->address]; + unsigned int led_field = afe4404_channel_leds[chan->address]; + unsigned int offdac_field = afe4404_channel_offdacs[chan->address]; int ret; switch (chan->type) { case IIO_INTENSITY: switch (mask) { case IIO_CHAN_INFO_RAW: - ret = regmap_read(afe->regmap, reg_info.reg, val); + ret = regmap_read(afe->regmap, value_reg, val); if (ret) return ret; return IIO_VAL_INT; case IIO_CHAN_INFO_OFFSET: - ret = regmap_read(afe->regmap, reg_info.offreg, - val); + ret = regmap_field_read(afe->fields[offdac_field], val); if (ret) return ret; - *val &= reg_info.mask; - *val >>= reg_info.shift; return IIO_VAL_INT; } break; case IIO_CURRENT: switch (mask) { case IIO_CHAN_INFO_RAW: - ret = regmap_read(afe->regmap, reg_info.reg, val); + ret = regmap_field_read(afe->fields[led_field], val); if (ret) return ret; - *val &= reg_info.mask; - *val >>= reg_info.shift; return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = 0; @@ -312,25 +314,20 @@ static int afe4404_write_raw(struct iio_dev *indio_dev, int val, int val2, long mask) { struct afe4404_data *afe = iio_priv(indio_dev); - const struct afe440x_reg_info reg_info = afe4404_reg_info[chan->address]; + unsigned int led_field = afe4404_channel_leds[chan->address]; + unsigned int offdac_field = afe4404_channel_offdacs[chan->address]; switch (chan->type) { case IIO_INTENSITY: switch (mask) { case IIO_CHAN_INFO_OFFSET: - return regmap_update_bits(afe->regmap, - reg_info.offreg, - reg_info.mask, - (val << reg_info.shift)); + return regmap_field_write(afe->fields[offdac_field], val); } break; case IIO_CURRENT: switch (mask) { case IIO_CHAN_INFO_RAW: - return regmap_update_bits(afe->regmap, - reg_info.reg, - reg_info.mask, - (val << reg_info.shift)); + return regmap_field_write(afe->fields[led_field], val); } break; default: @@ -357,7 +354,7 @@ static irqreturn_t afe4404_trigger_handler(int irq, void *private) for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) { - ret = regmap_read(afe->regmap, afe4404_reg_info[bit].reg, + ret = regmap_read(afe->regmap, afe4404_channel_values[bit], &buffer[i++]); if (ret) goto err; @@ -490,7 +487,7 @@ static int afe4404_probe(struct i2c_client *client, { struct iio_dev *indio_dev; struct afe4404_data *afe; - int ret; + int i, ret; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*afe)); if (!indio_dev) @@ -508,6 +505,15 @@ static int afe4404_probe(struct i2c_client *client, return PTR_ERR(afe->regmap); } + for (i = 0; i < F_MAX_FIELDS; i++) { + afe->fields[i] = devm_regmap_field_alloc(afe->dev, afe->regmap, + afe4404_reg_fields[i]); + if (IS_ERR(afe->fields[i])) { + dev_err(afe->dev, "Unable to allocate regmap fields\n"); + return PTR_ERR(afe->fields[i]); + } + } + afe->regulator = devm_regulator_get(afe->dev, "tx_sup"); if (IS_ERR(afe->regulator)) { dev_err(afe->dev, "Unable to get regulator\n"); diff --git a/drivers/iio/health/afe440x.h b/drivers/iio/health/afe440x.h index 713972f..1a0f247 100644 --- a/drivers/iio/health/afe440x.h +++ b/drivers/iio/health/afe440x.h @@ -88,21 +88,6 @@ #define AFE440X_CONTROL0_WRITE 0x0 #define AFE440X_CONTROL0_READ 0x1 -struct afe440x_reg_info { - unsigned int reg; - unsigned int offreg; - unsigned int shift; - unsigned int mask; -}; - -#define AFE440X_REG_INFO(_reg, _offreg, _sm) \ - { \ - .reg = _reg, \ - .offreg = _offreg, \ - .shift = _sm ## _SHIFT, \ - .mask = _sm ## _MASK, \ - } - #define AFE440X_INTENSITY_CHAN(_index, _mask) \ { \ .type = IIO_INTENSITY, \ @@ -157,9 +142,7 @@ static DEVICE_ATTR_RO(_name) struct afe440x_attr { struct device_attribute dev_attr; - unsigned int reg; - unsigned int shift; - unsigned int mask; + unsigned int field; const struct afe440x_val_table *val_table; unsigned int table_size; }; @@ -167,14 +150,12 @@ struct afe440x_attr { #define to_afe440x_attr(_dev_attr) \ container_of(_dev_attr, struct afe440x_attr, dev_attr) -#define AFE440X_ATTR(_name, _reg, _field, _table) \ +#define AFE440X_ATTR(_name, _field, _table) \ struct afe440x_attr afe440x_attr_##_name = { \ .dev_attr = __ATTR(_name, (S_IRUGO | S_IWUSR), \ afe440x_show_register, \ afe440x_store_register), \ - .reg = _reg, \ - .shift = _field ## _SHIFT, \ - .mask = _field ## _MASK, \ + .field = _field, \ .val_table = _table, \ .table_size = ARRAY_SIZE(_table), \ } -- cgit v1.1 From 1276187c5261217aa9cc23ec153e0e903181c16b Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 1 May 2016 15:37:00 -0500 Subject: iio: health/afe440x: Make gain settings a modifier for the stages Currently the TIA gain settings are exported to userspace as sysfs entries that do not clearly represent their internal relation to the sampling stages. The gain settings are enabled on a per-stage basis, this can be seen in figure 24 of the current AFE4404 datasheet. These gain settings should therefore be tied to the channels that are read during these stages. Make this change here. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- .../ABI/testing/sysfs-bus-iio-health-afe440x | 19 ++++++------ drivers/iio/health/afe4403.c | 34 ++++++++++++++-------- drivers/iio/health/afe4404.c | 34 ++++++++++++++-------- 3 files changed, 53 insertions(+), 34 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio-health-afe440x b/Documentation/ABI/testing/sysfs-bus-iio-health-afe440x index a067073..6adba90 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio-health-afe440x +++ b/Documentation/ABI/testing/sysfs-bus-iio-health-afe440x @@ -1,13 +1,3 @@ -What: /sys/bus/iio/devices/iio:deviceX/tia_resistanceY - /sys/bus/iio/devices/iio:deviceX/tia_capacitanceY -Date: December 2015 -KernelVersion: -Contact: Andrew F. Davis -Description: - Get and set the resistance and the capacitance settings for the - Transimpedance Amplifier. Y is 1 for Rf1 and Cf1, Y is 2 for - Rf2 and Cf2 values. - What: /sys/bus/iio/devices/iio:deviceX/in_intensityY_raw Date: May 2016 KernelVersion: @@ -33,6 +23,15 @@ Description: Get and set the offset cancellation DAC setting for these stages. The values are expressed in 5-bit sign-magnitude. +What: /sys/bus/iio/devices/iio:deviceX/in_intensityY_resistance +What: /sys/bus/iio/devices/iio:deviceX/in_intensityY_capacitance +Date: May 2016 +KernelVersion: +Contact: Andrew F. Davis +Description: + Get and set the resistance and the capacitance settings for the + Transimpedance Amplifier during the associated stage. + What: /sys/bus/iio/devices/iio:deviceX/out_currentY_raw Date: May 2016 KernelVersion: diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index 1950155..610631b 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -161,7 +161,7 @@ static const struct afe440x_val_table afe4403_res_table[] = { { 500000 }, { 250000 }, { 100000 }, { 50000 }, { 25000 }, { 10000 }, { 1000000 }, { 0 }, }; -AFE440X_TABLE_ATTR(tia_resistance_available, afe4403_res_table); +AFE440X_TABLE_ATTR(in_intensity_resistance_available, afe4403_res_table); static const struct afe440x_val_table afe4403_cap_table[] = { { 0, 5000 }, { 0, 10000 }, { 0, 20000 }, { 0, 25000 }, @@ -173,7 +173,7 @@ static const struct afe440x_val_table afe4403_cap_table[] = { { 0, 205000 }, { 0, 210000 }, { 0, 220000 }, { 0, 225000 }, { 0, 230000 }, { 0, 235000 }, { 0, 245000 }, { 0, 250000 }, }; -AFE440X_TABLE_ATTR(tia_capacitance_available, afe4403_cap_table); +AFE440X_TABLE_ATTR(in_intensity_capacitance_available, afe4403_cap_table); static ssize_t afe440x_show_register(struct device *dev, struct device_attribute *attr, @@ -226,19 +226,29 @@ static ssize_t afe440x_store_register(struct device *dev, return count; } -static AFE440X_ATTR(tia_resistance1, F_RF_LED1, afe4403_res_table); -static AFE440X_ATTR(tia_capacitance1, F_CF_LED1, afe4403_cap_table); +static AFE440X_ATTR(in_intensity1_resistance, F_RF_LED, afe4403_res_table); +static AFE440X_ATTR(in_intensity1_capacitance, F_CF_LED, afe4403_cap_table); -static AFE440X_ATTR(tia_resistance2, F_RF_LED, afe4403_res_table); -static AFE440X_ATTR(tia_capacitance2, F_CF_LED, afe4403_cap_table); +static AFE440X_ATTR(in_intensity2_resistance, F_RF_LED, afe4403_res_table); +static AFE440X_ATTR(in_intensity2_capacitance, F_CF_LED, afe4403_cap_table); + +static AFE440X_ATTR(in_intensity3_resistance, F_RF_LED1, afe4403_res_table); +static AFE440X_ATTR(in_intensity3_capacitance, F_CF_LED1, afe4403_cap_table); + +static AFE440X_ATTR(in_intensity4_resistance, F_RF_LED1, afe4403_res_table); +static AFE440X_ATTR(in_intensity4_capacitance, F_CF_LED1, afe4403_cap_table); static struct attribute *afe440x_attributes[] = { - &afe440x_attr_tia_resistance1.dev_attr.attr, - &afe440x_attr_tia_capacitance1.dev_attr.attr, - &afe440x_attr_tia_resistance2.dev_attr.attr, - &afe440x_attr_tia_capacitance2.dev_attr.attr, - &dev_attr_tia_resistance_available.attr, - &dev_attr_tia_capacitance_available.attr, + &dev_attr_in_intensity_resistance_available.attr, + &dev_attr_in_intensity_capacitance_available.attr, + &afe440x_attr_in_intensity1_resistance.dev_attr.attr, + &afe440x_attr_in_intensity1_capacitance.dev_attr.attr, + &afe440x_attr_in_intensity2_resistance.dev_attr.attr, + &afe440x_attr_in_intensity2_capacitance.dev_attr.attr, + &afe440x_attr_in_intensity3_resistance.dev_attr.attr, + &afe440x_attr_in_intensity3_capacitance.dev_attr.attr, + &afe440x_attr_in_intensity4_resistance.dev_attr.attr, + &afe440x_attr_in_intensity4_capacitance.dev_attr.attr, NULL }; diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index 0d1af4a..69116cd 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -179,7 +179,7 @@ static const struct afe440x_val_table afe4404_res_table[] = { { .integer = 1000000, .fract = 0 }, { .integer = 2000000, .fract = 0 }, }; -AFE440X_TABLE_ATTR(tia_resistance_available, afe4404_res_table); +AFE440X_TABLE_ATTR(in_intensity_resistance_available, afe4404_res_table); static const struct afe440x_val_table afe4404_cap_table[] = { { .integer = 0, .fract = 5000 }, @@ -191,7 +191,7 @@ static const struct afe440x_val_table afe4404_cap_table[] = { { .integer = 0, .fract = 25000 }, { .integer = 0, .fract = 22500 }, }; -AFE440X_TABLE_ATTR(tia_capacitance_available, afe4404_cap_table); +AFE440X_TABLE_ATTR(in_intensity_capacitance_available, afe4404_cap_table); static ssize_t afe440x_show_register(struct device *dev, struct device_attribute *attr, @@ -244,19 +244,29 @@ static ssize_t afe440x_store_register(struct device *dev, return count; } -static AFE440X_ATTR(tia_resistance1, F_TIA_GAIN, afe4404_res_table); -static AFE440X_ATTR(tia_capacitance1, TIA_CF, afe4404_cap_table); +static AFE440X_ATTR(in_intensity1_resistance, F_TIA_GAIN_SEP, afe4404_res_table); +static AFE440X_ATTR(in_intensity1_capacitance, F_TIA_CF_SEP, afe4404_cap_table); -static AFE440X_ATTR(tia_resistance2, F_TIA_GAIN_SEP, afe4404_res_table); -static AFE440X_ATTR(tia_capacitance2, F_TIA_CF_SEP, afe4404_cap_table); +static AFE440X_ATTR(in_intensity2_resistance, F_TIA_GAIN_SEP, afe4404_res_table); +static AFE440X_ATTR(in_intensity2_capacitance, F_TIA_CF_SEP, afe4404_cap_table); + +static AFE440X_ATTR(in_intensity3_resistance, F_TIA_GAIN, afe4404_res_table); +static AFE440X_ATTR(in_intensity3_capacitance, TIA_CF, afe4404_cap_table); + +static AFE440X_ATTR(in_intensity4_resistance, F_TIA_GAIN, afe4404_res_table); +static AFE440X_ATTR(in_intensity4_capacitance, TIA_CF, afe4404_cap_table); static struct attribute *afe440x_attributes[] = { - &afe440x_attr_tia_resistance1.dev_attr.attr, - &afe440x_attr_tia_capacitance1.dev_attr.attr, - &afe440x_attr_tia_resistance2.dev_attr.attr, - &afe440x_attr_tia_capacitance2.dev_attr.attr, - &dev_attr_tia_resistance_available.attr, - &dev_attr_tia_capacitance_available.attr, + &dev_attr_in_intensity_resistance_available.attr, + &dev_attr_in_intensity_capacitance_available.attr, + &afe440x_attr_in_intensity1_resistance.dev_attr.attr, + &afe440x_attr_in_intensity1_capacitance.dev_attr.attr, + &afe440x_attr_in_intensity2_resistance.dev_attr.attr, + &afe440x_attr_in_intensity2_capacitance.dev_attr.attr, + &afe440x_attr_in_intensity3_resistance.dev_attr.attr, + &afe440x_attr_in_intensity3_capacitance.dev_attr.attr, + &afe440x_attr_in_intensity4_resistance.dev_attr.attr, + &afe440x_attr_in_intensity4_capacitance.dev_attr.attr, NULL }; -- cgit v1.1 From 3ff34ee2ad2aa16fdde728bd9048098f71391087 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 1 May 2016 15:37:01 -0500 Subject: iio: health/afe440x: Match LED currents to stages The current channel number for the LEDs should match the stage number that they are active during, fix this here. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- drivers/iio/health/afe4403.c | 10 ++++------ drivers/iio/health/afe4404.c | 15 ++++++--------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index 610631b..059d521 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -126,8 +126,6 @@ enum afe4403_chan_id { ALED1, LED2_ALED2, LED1_ALED1, - ILED1, - ILED2, }; static const unsigned int afe4403_channel_values[] = { @@ -140,8 +138,8 @@ static const unsigned int afe4403_channel_values[] = { }; static const unsigned int afe4403_channel_leds[] = { - [ILED1] = F_ILED1, - [ILED2] = F_ILED2, + [LED2] = F_ILED2, + [LED1] = F_ILED1, }; static const struct iio_chan_spec afe4403_channels[] = { @@ -153,8 +151,8 @@ static const struct iio_chan_spec afe4403_channels[] = { AFE440X_INTENSITY_CHAN(LED2_ALED2, 0), AFE440X_INTENSITY_CHAN(LED1_ALED1, 0), /* LED current */ - AFE440X_CURRENT_CHAN(ILED1), - AFE440X_CURRENT_CHAN(ILED2), + AFE440X_CURRENT_CHAN(LED2), + AFE440X_CURRENT_CHAN(LED1), }; static const struct afe440x_val_table afe4403_res_table[] = { diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index 69116cd..aa8770b 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -128,9 +128,6 @@ enum afe4404_chan_id { ALED1, LED2_ALED2, LED1_ALED1, - ILED1, - ILED2, - ILED3, }; static const unsigned int afe4404_channel_values[] = { @@ -143,9 +140,9 @@ static const unsigned int afe4404_channel_values[] = { }; static const unsigned int afe4404_channel_leds[] = { - [ILED1] = F_ILED1, - [ILED2] = F_ILED2, - [ILED3] = F_ILED3, + [LED2] = F_ILED2, + [ALED2] = F_ILED3, + [LED1] = F_ILED1, }; static const unsigned int afe4404_channel_offdacs[] = { @@ -164,9 +161,9 @@ static const struct iio_chan_spec afe4404_channels[] = { AFE440X_INTENSITY_CHAN(LED2_ALED2, 0), AFE440X_INTENSITY_CHAN(LED1_ALED1, 0), /* LED current */ - AFE440X_CURRENT_CHAN(ILED1), - AFE440X_CURRENT_CHAN(ILED2), - AFE440X_CURRENT_CHAN(ILED3), + AFE440X_CURRENT_CHAN(LED2), + AFE440X_CURRENT_CHAN(ALED2), + AFE440X_CURRENT_CHAN(LED1), }; static const struct afe440x_val_table afe4404_res_table[] = { -- cgit v1.1 From e462350a95ee6d1ea53bc518f2bc5232b451e2e2 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 1 May 2016 15:37:02 -0500 Subject: iio: health/afe440x: Remove unused definitions These definitions are not currently used and if the functionality they represent is needed the values should be added back to a table for easy userspace use. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- drivers/iio/health/afe4403.c | 37 ------------------------------------- drivers/iio/health/afe4404.c | 20 -------------------- 2 files changed, 57 deletions(-) diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c index 059d521..9a08146 100644 --- a/drivers/iio/health/afe4403.c +++ b/drivers/iio/health/afe4403.c @@ -39,43 +39,6 @@ #define AFE4403_TIAGAIN 0x20 #define AFE4403_TIA_AMB_GAIN 0x21 -/* AFE4403 LEDCNTRL values */ -#define AFE440X_LEDCNTRL_RANGE_TX_HALF 0x1 -#define AFE440X_LEDCNTRL_RANGE_TX_FULL 0x2 -#define AFE440X_LEDCNTRL_RANGE_TX_OFF 0x3 - -/* AFE4403 CONTROL2 values */ -#define AFE440X_CONTROL2_TX_REF_025 0x0 -#define AFE440X_CONTROL2_TX_REF_050 0x1 -#define AFE440X_CONTROL2_TX_REF_100 0x2 -#define AFE440X_CONTROL2_TX_REF_075 0x3 - -/* AFE4403 CONTROL3 values */ -#define AFE440X_CONTROL3_CLK_DIV_2 0x0 -#define AFE440X_CONTROL3_CLK_DIV_4 0x2 -#define AFE440X_CONTROL3_CLK_DIV_6 0x3 -#define AFE440X_CONTROL3_CLK_DIV_8 0x4 -#define AFE440X_CONTROL3_CLK_DIV_12 0x5 -#define AFE440X_CONTROL3_CLK_DIV_1 0x7 - -/* AFE4403 TIAGAIN_CAP values */ -#define AFE4403_TIAGAIN_CAP_5_P 0x0 -#define AFE4403_TIAGAIN_CAP_10_P 0x1 -#define AFE4403_TIAGAIN_CAP_20_P 0x2 -#define AFE4403_TIAGAIN_CAP_30_P 0x3 -#define AFE4403_TIAGAIN_CAP_55_P 0x8 -#define AFE4403_TIAGAIN_CAP_155_P 0x10 - -/* AFE4403 TIAGAIN_RES values */ -#define AFE4403_TIAGAIN_RES_500_K 0x0 -#define AFE4403_TIAGAIN_RES_250_K 0x1 -#define AFE4403_TIAGAIN_RES_100_K 0x2 -#define AFE4403_TIAGAIN_RES_50_K 0x3 -#define AFE4403_TIAGAIN_RES_25_K 0x4 -#define AFE4403_TIAGAIN_RES_10_K 0x5 -#define AFE4403_TIAGAIN_RES_1_M 0x6 -#define AFE4403_TIAGAIN_RES_NONE 0x7 - enum afe4403_fields { /* Gains */ F_RF_LED1, F_CF_LED1, diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index aa8770b..3a8131d 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -51,26 +51,6 @@ /* AFE4404 CONTROL3 register fields */ #define AFE440X_CONTROL3_OSC_ENABLE BIT(9) -/* AFE4404 TIA_GAIN_CAP values */ -#define AFE4404_TIA_GAIN_CAP_5_P 0x0 -#define AFE4404_TIA_GAIN_CAP_2_5_P 0x1 -#define AFE4404_TIA_GAIN_CAP_10_P 0x2 -#define AFE4404_TIA_GAIN_CAP_7_5_P 0x3 -#define AFE4404_TIA_GAIN_CAP_20_P 0x4 -#define AFE4404_TIA_GAIN_CAP_17_5_P 0x5 -#define AFE4404_TIA_GAIN_CAP_25_P 0x6 -#define AFE4404_TIA_GAIN_CAP_22_5_P 0x7 - -/* AFE4404 TIA_GAIN_RES values */ -#define AFE4404_TIA_GAIN_RES_500_K 0x0 -#define AFE4404_TIA_GAIN_RES_250_K 0x1 -#define AFE4404_TIA_GAIN_RES_100_K 0x2 -#define AFE4404_TIA_GAIN_RES_50_K 0x3 -#define AFE4404_TIA_GAIN_RES_25_K 0x4 -#define AFE4404_TIA_GAIN_RES_10_K 0x5 -#define AFE4404_TIA_GAIN_RES_1_M 0x6 -#define AFE4404_TIA_GAIN_RES_2_M 0x7 - enum afe4404_fields { /* Gains */ F_TIA_GAIN_SEP, F_TIA_CF_SEP, -- cgit v1.1 From 0825cce21f764c04a96b719af2b491011bc6c523 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Sun, 1 May 2016 15:37:03 -0500 Subject: iio: health/afe4404: ENSEPGAIN is part of CONTROL2 register Rename this definition, no functional changes. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- drivers/iio/health/afe4404.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/health/afe4404.c b/drivers/iio/health/afe4404.c index 3a8131d..4526640 100644 --- a/drivers/iio/health/afe4404.c +++ b/drivers/iio/health/afe4404.c @@ -48,8 +48,8 @@ #define AFE4404_AVG_LED2_ALED2VAL 0x3f #define AFE4404_AVG_LED1_ALED1VAL 0x40 -/* AFE4404 CONTROL3 register fields */ -#define AFE440X_CONTROL3_OSC_ENABLE BIT(9) +/* AFE4404 CONTROL2 register fields */ +#define AFE440X_CONTROL2_OSC_ENABLE BIT(9) enum afe4404_fields { /* Gains */ @@ -398,7 +398,7 @@ static const struct reg_sequence afe4404_reg_sequences[] = { AFE4404_TIMING_PAIRS, { AFE440X_CONTROL1, AFE440X_CONTROL1_TIMEREN }, { AFE4404_TIA_GAIN_SEP, AFE440X_TIAGAIN_ENSEPGAIN }, - { AFE440X_CONTROL2, AFE440X_CONTROL3_OSC_ENABLE }, + { AFE440X_CONTROL2, AFE440X_CONTROL2_OSC_ENABLE }, }; static const struct regmap_range afe4404_yes_ranges[] = { -- cgit v1.1 From 0f3a8c3f34f728e7c96651bb7271e1c388c9aac2 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Mon, 25 Apr 2016 16:15:51 +0300 Subject: iio: Add support for creating IIO devices via configfs This is similar with support for creating triggers via configfs. Devices will be hosted under: * /config/iio/devices We allow users to register "device types" under: * /config/iio/devices// Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/Kconfig | 8 ++ drivers/iio/Makefile | 1 + drivers/iio/industrialio-sw-device.c | 182 +++++++++++++++++++++++++++++++++++ include/linux/iio/sw_device.h | 70 ++++++++++++++ 4 files changed, 261 insertions(+) create mode 100644 drivers/iio/industrialio-sw-device.c create mode 100644 include/linux/iio/sw_device.h diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig index 505e921..6743b18 100644 --- a/drivers/iio/Kconfig +++ b/drivers/iio/Kconfig @@ -46,6 +46,14 @@ config IIO_CONSUMERS_PER_TRIGGER This value controls the maximum number of consumers that a given trigger may handle. Default is 2. +config IIO_SW_DEVICE + tristate "Enable software IIO device support" + select IIO_CONFIGFS + help + Provides IIO core support for software devices. A software + device can be created via configfs or directly by a driver + using the API provided. + config IIO_SW_TRIGGER tristate "Enable software triggers support" select IIO_CONFIGFS diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile index 20f6490..87e4c43 100644 --- a/drivers/iio/Makefile +++ b/drivers/iio/Makefile @@ -8,6 +8,7 @@ industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o obj-$(CONFIG_IIO_CONFIGFS) += industrialio-configfs.o +obj-$(CONFIG_IIO_SW_DEVICE) += industrialio-sw-device.o obj-$(CONFIG_IIO_SW_TRIGGER) += industrialio-sw-trigger.o obj-$(CONFIG_IIO_TRIGGERED_EVENT) += industrialio-triggered-event.o diff --git a/drivers/iio/industrialio-sw-device.c b/drivers/iio/industrialio-sw-device.c new file mode 100644 index 0000000..81b49cf --- /dev/null +++ b/drivers/iio/industrialio-sw-device.c @@ -0,0 +1,182 @@ +/* + * The Industrial I/O core, software IIO devices functions + * + * Copyright (c) 2016 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +static struct config_group *iio_devices_group; +static struct config_item_type iio_device_type_group_type; + +static struct config_item_type iio_devices_group_type = { + .ct_owner = THIS_MODULE, +}; + +static LIST_HEAD(iio_device_types_list); +static DEFINE_MUTEX(iio_device_types_lock); + +static +struct iio_sw_device_type *__iio_find_sw_device_type(const char *name, + unsigned len) +{ + struct iio_sw_device_type *d = NULL, *iter; + + list_for_each_entry(iter, &iio_device_types_list, list) + if (!strcmp(iter->name, name)) { + d = iter; + break; + } + + return d; +} + +int iio_register_sw_device_type(struct iio_sw_device_type *d) +{ + struct iio_sw_device_type *iter; + int ret = 0; + + mutex_lock(&iio_device_types_lock); + iter = __iio_find_sw_device_type(d->name, strlen(d->name)); + if (iter) + ret = -EBUSY; + else + list_add_tail(&d->list, &iio_device_types_list); + mutex_unlock(&iio_device_types_lock); + + if (ret) + return ret; + + d->group = configfs_register_default_group(iio_devices_group, d->name, + &iio_device_type_group_type); + if (IS_ERR(d->group)) + ret = PTR_ERR(d->group); + + return ret; +} +EXPORT_SYMBOL(iio_register_sw_device_type); + +void iio_unregister_sw_device_type(struct iio_sw_device_type *dt) +{ + struct iio_sw_device_type *iter; + + mutex_lock(&iio_device_types_lock); + iter = __iio_find_sw_device_type(dt->name, strlen(dt->name)); + if (iter) + list_del(&dt->list); + mutex_unlock(&iio_device_types_lock); + + configfs_unregister_default_group(dt->group); +} +EXPORT_SYMBOL(iio_unregister_sw_device_type); + +static +struct iio_sw_device_type *iio_get_sw_device_type(const char *name) +{ + struct iio_sw_device_type *dt; + + mutex_lock(&iio_device_types_lock); + dt = __iio_find_sw_device_type(name, strlen(name)); + if (dt && !try_module_get(dt->owner)) + dt = NULL; + mutex_unlock(&iio_device_types_lock); + + return dt; +} + +struct iio_sw_device *iio_sw_device_create(const char *type, const char *name) +{ + struct iio_sw_device *d; + struct iio_sw_device_type *dt; + + dt = iio_get_sw_device_type(type); + if (!dt) { + pr_err("Invalid device type: %s\n", type); + return ERR_PTR(-EINVAL); + } + d = dt->ops->probe(name); + if (IS_ERR(d)) + goto out_module_put; + + d->device_type = dt; + + return d; +out_module_put: + module_put(dt->owner); + return d; +} +EXPORT_SYMBOL(iio_sw_device_create); + +void iio_sw_device_destroy(struct iio_sw_device *d) +{ + struct iio_sw_device_type *dt = d->device_type; + + dt->ops->remove(d); + module_put(dt->owner); +} +EXPORT_SYMBOL(iio_sw_device_destroy); + +static struct config_group *device_make_group(struct config_group *group, + const char *name) +{ + struct iio_sw_device *d; + + d = iio_sw_device_create(group->cg_item.ci_name, name); + if (IS_ERR(d)) + return ERR_CAST(d); + + config_item_set_name(&d->group.cg_item, "%s", name); + + return &d->group; +} + +static void device_drop_group(struct config_group *group, + struct config_item *item) +{ + struct iio_sw_device *d = to_iio_sw_device(item); + + iio_sw_device_destroy(d); + config_item_put(item); +} + +static struct configfs_group_operations device_ops = { + .make_group = &device_make_group, + .drop_item = &device_drop_group, +}; + +static struct config_item_type iio_device_type_group_type = { + .ct_group_ops = &device_ops, + .ct_owner = THIS_MODULE, +}; + +static int __init iio_sw_device_init(void) +{ + iio_devices_group = + configfs_register_default_group(&iio_configfs_subsys.su_group, + "devices", + &iio_devices_group_type); + return PTR_ERR_OR_ZERO(iio_devices_group); +} +module_init(iio_sw_device_init); + +static void __exit iio_sw_device_exit(void) +{ + configfs_unregister_default_group(iio_devices_group); +} +module_exit(iio_sw_device_exit); + +MODULE_AUTHOR("Daniel Baluta "); +MODULE_DESCRIPTION("Industrial I/O software devices support"); +MODULE_LICENSE("GPL v2"); diff --git a/include/linux/iio/sw_device.h b/include/linux/iio/sw_device.h new file mode 100644 index 0000000..23ca415 --- /dev/null +++ b/include/linux/iio/sw_device.h @@ -0,0 +1,70 @@ +/* + * Industrial I/O software device interface + * + * Copyright (c) 2016 Intel Corporation + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + */ + +#ifndef __IIO_SW_DEVICE +#define __IIO_SW_DEVICE + +#include +#include +#include +#include + +#define module_iio_sw_device_driver(__iio_sw_device_type) \ + module_driver(__iio_sw_device_type, iio_register_sw_device_type, \ + iio_unregister_sw_device_type) + +struct iio_sw_device_ops; + +struct iio_sw_device_type { + const char *name; + struct module *owner; + const struct iio_sw_device_ops *ops; + struct list_head list; + struct config_group *group; +}; + +struct iio_sw_device { + struct iio_dev *device; + struct iio_sw_device_type *device_type; + struct config_group group; +}; + +struct iio_sw_device_ops { + struct iio_sw_device* (*probe)(const char *); + int (*remove)(struct iio_sw_device *); +}; + +static inline +struct iio_sw_device *to_iio_sw_device(struct config_item *item) +{ + return container_of(to_config_group(item), struct iio_sw_device, + group); +} + +int iio_register_sw_device_type(struct iio_sw_device_type *dt); +void iio_unregister_sw_device_type(struct iio_sw_device_type *dt); + +struct iio_sw_device *iio_sw_device_create(const char *, const char *); +void iio_sw_device_destroy(struct iio_sw_device *); + +int iio_sw_device_type_configfs_register(struct iio_sw_device_type *dt); +void iio_sw_device_type_configfs_unregister(struct iio_sw_device_type *dt); + +static inline +void iio_swd_group_init_type_name(struct iio_sw_device *d, + const char *name, + struct config_item_type *type) +{ +#ifdef CONFIG_CONFIGFS_FS + config_group_init_type_name(&d->group, name, type); +#endif +} + +#endif /* __IIO_SW_DEVICE */ -- cgit v1.1 From 3d85fb6f81046b51e4428e14fb9643ea75648630 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Mon, 25 Apr 2016 16:15:52 +0300 Subject: iio: dummy: Convert IIO dummy to configfs We register a new device type named "dummy", this will create a configfs entry under: * /config/iio/devices/dummy. Creating dummy devices is now as simple as: $ mkdir /config/iio/devices/dummy/my_dummy_device Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/dummy/Kconfig | 1 + drivers/iio/dummy/iio_simple_dummy.c | 102 +++++++++++++---------------------- 2 files changed, 38 insertions(+), 65 deletions(-) diff --git a/drivers/iio/dummy/Kconfig b/drivers/iio/dummy/Kconfig index 71805ce..aa5824d 100644 --- a/drivers/iio/dummy/Kconfig +++ b/drivers/iio/dummy/Kconfig @@ -10,6 +10,7 @@ config IIO_DUMMY_EVGEN config IIO_SIMPLE_DUMMY tristate "An example driver with no hardware requirements" + depends on IIO_SW_DEVICE help Driver intended mainly as documentation for how to write a driver. May also be useful for testing userspace code diff --git a/drivers/iio/dummy/iio_simple_dummy.c b/drivers/iio/dummy/iio_simple_dummy.c index 43fe4ba..ad3410e 100644 --- a/drivers/iio/dummy/iio_simple_dummy.c +++ b/drivers/iio/dummy/iio_simple_dummy.c @@ -17,26 +17,18 @@ #include #include #include +#include #include #include #include #include +#include #include "iio_simple_dummy.h" -/* - * A few elements needed to fake a bus for this driver - * Note instances parameter controls how many of these - * dummy devices are registered. - */ -static unsigned instances = 1; -module_param(instances, uint, 0); - -/* Pointer array used to fake bus elements */ -static struct iio_dev **iio_dummy_devs; - -/* Fake a name for the part number, usually obtained from the id table */ -static const char *iio_dummy_part_number = "iio_dummy_part_no"; +static struct config_item_type iio_dummy_type = { + .ct_owner = THIS_MODULE, +}; /** * struct iio_dummy_accel_calibscale - realworld to register mapping @@ -572,12 +564,18 @@ static int iio_dummy_init_device(struct iio_dev *indio_dev) * const struct i2c_device_id *id) * SPI: iio_dummy_probe(struct spi_device *spi) */ -static int iio_dummy_probe(int index) +static struct iio_sw_device *iio_dummy_probe(const char *name) { int ret; struct iio_dev *indio_dev; struct iio_dummy_state *st; + struct iio_sw_device *swd; + swd = kzalloc(sizeof(*swd), GFP_KERNEL); + if (!swd) { + ret = -ENOMEM; + goto error_kzalloc; + } /* * Allocate an IIO device. * @@ -608,7 +606,7 @@ static int iio_dummy_probe(int index) * i2c_set_clientdata(client, indio_dev); * spi_set_drvdata(spi, indio_dev); */ - iio_dummy_devs[index] = indio_dev; + swd->device = indio_dev; /* * Set the device name. @@ -619,7 +617,7 @@ static int iio_dummy_probe(int index) * indio_dev->name = id->name; * indio_dev->name = spi_get_device_id(spi)->name; */ - indio_dev->name = iio_dummy_part_number; + indio_dev->name = kstrdup(name, GFP_KERNEL); /* Provide description of available channels */ indio_dev->channels = iio_dummy_channels; @@ -646,7 +644,9 @@ static int iio_dummy_probe(int index) if (ret < 0) goto error_unconfigure_buffer; - return 0; + iio_swd_group_init_type_name(swd, name, &iio_dummy_type); + + return swd; error_unconfigure_buffer: iio_simple_dummy_unconfigure_buffer(indio_dev); error_unregister_events: @@ -654,16 +654,18 @@ error_unregister_events: error_free_device: iio_device_free(indio_dev); error_ret: - return ret; + kfree(swd); +error_kzalloc: + return ERR_PTR(ret); } /** * iio_dummy_remove() - device instance removal function - * @index: device index. + * @swd: pointer to software IIO device abstraction * * Parameters follow those of iio_dummy_probe for buses. */ -static void iio_dummy_remove(int index) +static int iio_dummy_remove(struct iio_sw_device *swd) { /* * Get a pointer to the device instance iio_dev structure @@ -671,7 +673,7 @@ static void iio_dummy_remove(int index) * struct iio_dev *indio_dev = i2c_get_clientdata(client); * struct iio_dev *indio_dev = spi_get_drvdata(spi); */ - struct iio_dev *indio_dev = iio_dummy_devs[index]; + struct iio_dev *indio_dev = swd->device; /* Unregister the device */ iio_device_unregister(indio_dev); @@ -684,11 +686,13 @@ static void iio_dummy_remove(int index) iio_simple_dummy_events_unregister(indio_dev); /* Free all structures */ + kfree(indio_dev->name); iio_device_free(indio_dev); -} + return 0; +} /** - * iio_dummy_init() - device driver registration + * module_iio_sw_device_driver() - device driver registration * * Varies depending on bus type of the device. As there is no device * here, call probe directly. For information on device registration @@ -697,50 +701,18 @@ static void iio_dummy_remove(int index) * spi: * Documentation/spi/spi-summary */ -static __init int iio_dummy_init(void) -{ - int i, ret; - - if (instances > 10) { - instances = 1; - return -EINVAL; - } - - /* Fake a bus */ - iio_dummy_devs = kcalloc(instances, sizeof(*iio_dummy_devs), - GFP_KERNEL); - /* Here we have no actual device so call probe */ - for (i = 0; i < instances; i++) { - ret = iio_dummy_probe(i); - if (ret < 0) - goto error_remove_devs; - } - return 0; - -error_remove_devs: - while (i--) - iio_dummy_remove(i); - - kfree(iio_dummy_devs); - return ret; -} -module_init(iio_dummy_init); +static const struct iio_sw_device_ops iio_dummy_device_ops = { + .probe = iio_dummy_probe, + .remove = iio_dummy_remove, +}; -/** - * iio_dummy_exit() - device driver removal - * - * Varies depending on bus type of the device. - * As there is no device here, call remove directly. - */ -static __exit void iio_dummy_exit(void) -{ - int i; +static struct iio_sw_device_type iio_dummy_device = { + .name = "dummy", + .owner = THIS_MODULE, + .ops = &iio_dummy_device_ops, +}; - for (i = 0; i < instances; i++) - iio_dummy_remove(i); - kfree(iio_dummy_devs); -} -module_exit(iio_dummy_exit); +module_iio_sw_device_driver(iio_dummy_device); MODULE_AUTHOR("Jonathan Cameron "); MODULE_DESCRIPTION("IIO dummy driver"); -- cgit v1.1 From 6994aea7842d824a8cc38c950ddcab3f8a75c278 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Mon, 25 Apr 2016 16:15:53 +0300 Subject: Documentation: iio: Add IIO software devices docs Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/configfs-iio | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Documentation/ABI/testing/configfs-iio b/Documentation/ABI/testing/configfs-iio index 2483756..aebda53 100644 --- a/Documentation/ABI/testing/configfs-iio +++ b/Documentation/ABI/testing/configfs-iio @@ -19,3 +19,16 @@ KernelVersion: 4.4 Description: High resolution timers directory. Creating a directory here will result in creating a hrtimer trigger in the IIO subsystem. + +What: /config/iio/devices +Date: April 2016 +KernelVersion: 4.7 +Description: + Industrial IO software devices directory. + +What: /config/iio/devices/dummy +Date: April 2016 +KernelVersion: 4.7 +Description: + Dummy IIO devices directory. Creating a directory here will result + in creating a dummy IIO device in the IIO subystem. -- cgit v1.1 From ed859fc17d67f4c0ade6f5a58365e621f88de3cf Mon Sep 17 00:00:00 2001 From: Martin Kepplinger Date: Mon, 25 Apr 2016 14:08:25 +0200 Subject: iio: mma8452: add support for oversampling ratio This adds the following sysfs files according to the iio ABI: -rw-r--r-- 4096 in_accel_oversampling_ratio -r--r--r-- 4096 in_accel_oversampling_ratio_available Internally, the device knows about 4 different power modes that differ in oversampling ratio (and power consumption). We just show the user what oversampling ratio(s) is/are available, depending on the current frequency. The referenced table in the datasheets makes it easier to understand. Signed-off-by: Martin Kepplinger Signed-off-by: Christoph Muellner Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 185 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 160 insertions(+), 25 deletions(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index e225d3c..458c827 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -76,6 +76,8 @@ #define MMA8452_CTRL_DR_DEFAULT 0x4 /* 50 Hz sample frequency */ #define MMA8452_CTRL_REG2 0x2b #define MMA8452_CTRL_REG2_RST BIT(6) +#define MMA8452_CTRL_REG2_MODS_SHIFT 3 +#define MMA8452_CTRL_REG2_MODS_MASK 0x1b #define MMA8452_CTRL_REG4 0x2d #define MMA8452_CTRL_REG5 0x2e #define MMA8452_OFF_X 0x2f @@ -257,20 +259,17 @@ static const int mma8452_samp_freq[8][2] = { {6, 250000}, {1, 560000} }; -/* Datasheet table 35 (step time vs sample frequency) */ -static const int mma8452_transient_time_step_us[8] = { - 1250, - 2500, - 5000, - 10000, - 20000, - 20000, - 20000, - 20000 +/* Datasheet table: step time "Relationship with the ODR" (sample frequency) */ +static const int mma8452_transient_time_step_us[4][8] = { + { 1250, 2500, 5000, 10000, 20000, 20000, 20000, 20000 }, /* normal */ + { 1250, 2500, 5000, 10000, 20000, 80000, 80000, 80000 }, /* l p l n */ + { 1250, 2500, 2500, 2500, 2500, 2500, 2500, 2500 }, /* high res*/ + { 1250, 2500, 5000, 10000, 20000, 80000, 160000, 160000 } /* l p */ }; -/* Datasheet table 18 (normal mode) */ -static const int mma8452_hp_filter_cutoff[8][4][2] = { +/* Datasheet table "High-Pass Filter Cutoff Options" */ +static const int mma8452_hp_filter_cutoff[4][8][4][2] = { + { /* normal */ { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, /* 800 Hz sample */ { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, /* 400 Hz sample */ { {8, 0}, {4, 0}, {2, 0}, {1, 0} }, /* 200 Hz sample */ @@ -279,8 +278,61 @@ static const int mma8452_hp_filter_cutoff[8][4][2] = { { {2, 0}, {1, 0}, {0, 500000}, {0, 250000} }, /* 12.5 Hz sample */ { {2, 0}, {1, 0}, {0, 500000}, {0, 250000} }, /* 6.25 Hz sample */ { {2, 0}, {1, 0}, {0, 500000}, {0, 250000} } /* 1.56 Hz sample */ + }, + { /* low noise low power */ + { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, + { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, + { {8, 0}, {4, 0}, {2, 0}, {1, 0} }, + { {4, 0}, {2, 0}, {1, 0}, {0, 500000} }, + { {2, 0}, {1, 0}, {0, 500000}, {0, 250000} }, + { {0, 500000}, {0, 250000}, {0, 125000}, {0, 063000} }, + { {0, 500000}, {0, 250000}, {0, 125000}, {0, 063000} }, + { {0, 500000}, {0, 250000}, {0, 125000}, {0, 063000} } + }, + { /* high resolution */ + { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, + { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, + { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, + { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, + { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, + { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, + { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, + { {16, 0}, {8, 0}, {4, 0}, {2, 0} } + }, + { /* low power */ + { {16, 0}, {8, 0}, {4, 0}, {2, 0} }, + { {8, 0}, {4, 0}, {2, 0}, {1, 0} }, + { {4, 0}, {2, 0}, {1, 0}, {0, 500000} }, + { {2, 0}, {1, 0}, {0, 500000}, {0, 250000} }, + { {1, 0}, {0, 500000}, {0, 250000}, {0, 125000} }, + { {0, 250000}, {0, 125000}, {0, 063000}, {0, 031000} }, + { {0, 250000}, {0, 125000}, {0, 063000}, {0, 031000} }, + { {0, 250000}, {0, 125000}, {0, 063000}, {0, 031000} } + } }; +/* Datasheet table "MODS Oversampling modes averaging values at each ODR" */ +static const u16 mma8452_os_ratio[4][8] = { + /* 800 Hz, 400 Hz, ... , 1.56 Hz */ + { 2, 4, 4, 4, 4, 16, 32, 128 }, /* normal */ + { 2, 4, 4, 4, 4, 4, 8, 32 }, /* low power low noise */ + { 2, 4, 8, 16, 32, 128, 256, 1024 }, /* high resolution */ + { 2, 2, 2, 2, 2, 2, 4, 16 } /* low power */ +}; + +static int mma8452_get_power_mode(struct mma8452_data *data) +{ + int reg; + + reg = i2c_smbus_read_byte_data(data->client, + MMA8452_CTRL_REG2); + if (reg < 0) + return reg; + + return ((reg & MMA8452_CTRL_REG2_MODS_MASK) >> + MMA8452_CTRL_REG2_MODS_SHIFT); +} + static ssize_t mma8452_show_samp_freq_avail(struct device *dev, struct device_attribute *attr, char *buf) @@ -306,10 +358,39 @@ static ssize_t mma8452_show_hp_cutoff_avail(struct device *dev, { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct mma8452_data *data = iio_priv(indio_dev); + int i, j; + + i = mma8452_get_odr_index(data); + j = mma8452_get_power_mode(data); + if (j < 0) + return j; + + return mma8452_show_int_plus_micros(buf, mma8452_hp_filter_cutoff[j][i], + ARRAY_SIZE(mma8452_hp_filter_cutoff[0][0])); +} + +static ssize_t mma8452_show_os_ratio_avail(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct mma8452_data *data = iio_priv(indio_dev); int i = mma8452_get_odr_index(data); + int j; + u16 val = 0; + size_t len = 0; + + for (j = 0; j < ARRAY_SIZE(mma8452_os_ratio); j++) { + if (val == mma8452_os_ratio[j][i]) + continue; + + val = mma8452_os_ratio[j][i]; + + len += scnprintf(buf + len, PAGE_SIZE - len, "%d ", val); + } + buf[len - 1] = '\n'; - return mma8452_show_int_plus_micros(buf, mma8452_hp_filter_cutoff[i], - ARRAY_SIZE(mma8452_hp_filter_cutoff[0])); + return len; } static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(mma8452_show_samp_freq_avail); @@ -317,6 +398,8 @@ static IIO_DEVICE_ATTR(in_accel_scale_available, S_IRUGO, 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, + mma8452_show_os_ratio_avail, NULL, 0); static int mma8452_get_samp_freq_index(struct mma8452_data *data, int val, int val2) @@ -335,24 +418,33 @@ static int mma8452_get_scale_index(struct mma8452_data *data, int val, int val2) static int mma8452_get_hp_filter_index(struct mma8452_data *data, int val, int val2) { - int i = mma8452_get_odr_index(data); + int i, j; + + i = mma8452_get_odr_index(data); + j = mma8452_get_power_mode(data); + if (j < 0) + return j; - return mma8452_get_int_plus_micros_index(mma8452_hp_filter_cutoff[i], - ARRAY_SIZE(mma8452_hp_filter_cutoff[0]), val, val2); + return mma8452_get_int_plus_micros_index(mma8452_hp_filter_cutoff[j][i], + ARRAY_SIZE(mma8452_hp_filter_cutoff[0][0]), val, val2); } static int mma8452_read_hp_filter(struct mma8452_data *data, int *hz, int *uHz) { - int i, ret; + int j, i, ret; ret = i2c_smbus_read_byte_data(data->client, MMA8452_HP_FILTER_CUTOFF); if (ret < 0) return ret; i = mma8452_get_odr_index(data); + j = mma8452_get_power_mode(data); + if (j < 0) + return j; + ret &= MMA8452_HP_FILTER_CUTOFF_SEL_MASK; - *hz = mma8452_hp_filter_cutoff[i][ret][0]; - *uHz = mma8452_hp_filter_cutoff[i][ret][1]; + *hz = mma8452_hp_filter_cutoff[j][i][ret][0]; + *uHz = mma8452_hp_filter_cutoff[j][i][ret][1]; return 0; } @@ -414,6 +506,15 @@ static int mma8452_read_raw(struct iio_dev *indio_dev, } return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + ret = mma8452_get_power_mode(data); + if (ret < 0) + return ret; + + i = mma8452_get_odr_index(data); + + *val = mma8452_os_ratio[ret][i]; + return IIO_VAL_INT; } return -EINVAL; @@ -480,6 +581,21 @@ fail: return ret; } +static int mma8452_set_power_mode(struct mma8452_data *data, u8 mode) +{ + int reg; + + reg = i2c_smbus_read_byte_data(data->client, + MMA8452_CTRL_REG2); + if (reg < 0) + return reg; + + reg &= ~MMA8452_CTRL_REG2_MODS_MASK; + reg |= mode << MMA8452_CTRL_REG2_MODS_SHIFT; + + return mma8452_change_config(data, MMA8452_CTRL_REG2, reg); +} + /* returns >0 if in freefall mode, 0 if not or <0 if an error occurred */ static int mma8452_freefall_mode_enabled(struct mma8452_data *data) { @@ -597,6 +713,14 @@ static int mma8452_write_raw(struct iio_dev *indio_dev, return mma8452_change_config(data, MMA8452_DATA_CFG, data->data_cfg); + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + ret = mma8452_get_odr_index(data); + + for (i = 0; i < ARRAY_SIZE(mma8452_os_ratio); i++) { + if (mma8452_os_ratio[i][ret] == val) + return mma8452_set_power_mode(data, i); + } + default: return -EINVAL; } @@ -610,7 +734,7 @@ static int mma8452_read_thresh(struct iio_dev *indio_dev, int *val, int *val2) { struct mma8452_data *data = iio_priv(indio_dev); - int ret, us; + int ret, us, power_mode; switch (info) { case IIO_EV_INFO_VALUE: @@ -629,7 +753,11 @@ static int mma8452_read_thresh(struct iio_dev *indio_dev, if (ret < 0) return ret; - us = ret * mma8452_transient_time_step_us[ + power_mode = mma8452_get_power_mode(data); + if (power_mode < 0) + return power_mode; + + us = ret * mma8452_transient_time_step_us[power_mode][ mma8452_get_odr_index(data)]; *val = us / USEC_PER_SEC; *val2 = us % USEC_PER_SEC; @@ -677,8 +805,12 @@ static int mma8452_write_thresh(struct iio_dev *indio_dev, val); case IIO_EV_INFO_PERIOD: + ret = mma8452_get_power_mode(data); + if (ret < 0) + return ret; + steps = (val * USEC_PER_SEC + val2) / - mma8452_transient_time_step_us[ + mma8452_transient_time_step_us[ret][ mma8452_get_odr_index(data)]; if (steps < 0 || steps > 0xff) @@ -978,7 +1110,8 @@ static struct attribute_group mma8452_event_attribute_group = { BIT(IIO_CHAN_INFO_CALIBBIAS), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ BIT(IIO_CHAN_INFO_SCALE) | \ - BIT(IIO_CHAN_INFO_HIGH_PASS_FILTER_3DB_FREQUENCY), \ + BIT(IIO_CHAN_INFO_HIGH_PASS_FILTER_3DB_FREQUENCY) | \ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ .scan_index = idx, \ .scan_type = { \ .sign = 's', \ @@ -998,7 +1131,8 @@ static struct attribute_group mma8452_event_attribute_group = { .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ BIT(IIO_CHAN_INFO_CALIBBIAS), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ - BIT(IIO_CHAN_INFO_SCALE), \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ .scan_index = idx, \ .scan_type = { \ .sign = 's', \ @@ -1171,6 +1305,7 @@ static struct attribute *mma8452_attributes[] = { &iio_dev_attr_sampling_frequency_available.dev_attr.attr, &iio_dev_attr_in_accel_scale_available.dev_attr.attr, &iio_dev_attr_in_accel_filter_high_pass_3db_frequency_available.dev_attr.attr, + &iio_dev_attr_in_accel_oversampling_ratio_available.dev_attr.attr, NULL }; -- cgit v1.1 From 2763ac94f3e4d3711863729f4c11500d245f68cc Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Wed, 11 May 2016 21:47:48 -0700 Subject: iio: potentiometer: tpl0102: remove unneeded i2c check functionality test Actually I2C_FUNC_SMBUS_WORD_DATA isn't need for this device, and regmap handles all single byte reads transparently. Signed-off-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- drivers/iio/potentiometer/tpl0102.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/iio/potentiometer/tpl0102.c b/drivers/iio/potentiometer/tpl0102.c index 5c304d4..7b6b545 100644 --- a/drivers/iio/potentiometer/tpl0102.c +++ b/drivers/iio/potentiometer/tpl0102.c @@ -116,10 +116,6 @@ static int tpl0102_probe(struct i2c_client *client, struct tpl0102_data *data; struct iio_dev *indio_dev; - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WORD_DATA)) - return -EOPNOTSUPP; - indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); if (!indio_dev) return -ENOMEM; -- cgit v1.1 From bf2a5600a3ebc9dc5f085b47791009e25ade0157 Mon Sep 17 00:00:00 2001 From: Tiberiu Breana Date: Thu, 5 May 2016 18:48:55 +0300 Subject: iio: accel: Add support for Bosch BMA220 This commit adds basic support for the Bosch Sensortec BMA220 digital triaxial acceleration sensor. The device datasheet can be found here: http://www.mouser.com/pdfdocs/BSTBMA220DS00308.PDF Includes: - raw readings - ACPI detection - power management Signed-off-by: Tiberiu Breana Signed-off-by: Jonathan Cameron --- drivers/iio/accel/Kconfig | 10 ++ drivers/iio/accel/Makefile | 1 + drivers/iio/accel/bma220_spi.c | 277 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 288 insertions(+) create mode 100644 drivers/iio/accel/bma220_spi.c diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index 1df6361..3132587 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -17,6 +17,16 @@ config BMA180 To compile this driver as a module, choose M here: the module will be called bma180. +config BMA220 + tristate "Bosch BMA220 3-Axis Accelerometer Driver" + depends on SPI + help + Say yes here to add support for the Bosch BMA220 triaxial + acceleration sensor. + + To compile this driver as a module, choose M here: the + module will be called bma220_spi. + config BMC150_ACCEL tristate "Bosch BMC150 Accelerometer Driver" select IIO_BUFFER diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile index ba1165f..6cedbec 100644 --- a/drivers/iio/accel/Makefile +++ b/drivers/iio/accel/Makefile @@ -4,6 +4,7 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_BMA180) += bma180.o +obj-$(CONFIG_BMA220) += bma220_spi.o obj-$(CONFIG_BMC150_ACCEL) += bmc150-accel-core.o obj-$(CONFIG_BMC150_ACCEL_I2C) += bmc150-accel-i2c.o obj-$(CONFIG_BMC150_ACCEL_SPI) += bmc150-accel-spi.o diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c new file mode 100644 index 0000000..7343575 --- /dev/null +++ b/drivers/iio/accel/bma220_spi.c @@ -0,0 +1,277 @@ +/** + * BMA220 Digital triaxial acceleration sensor driver + * + * Copyright (c) 2016, Intel Corporation. + * + * This file is subject to the terms and conditions of version 2 of + * the GNU General Public License. See the file COPYING in the main + * directory of this archive for more details. + */ + +#include +#include +#include +#include +#include +#include + +#define BMA220_REG_ID 0x00 +#define BMA220_REG_ACCEL_X 0x02 +#define BMA220_REG_ACCEL_Y 0x03 +#define BMA220_REG_ACCEL_Z 0x04 +#define BMA220_REG_RANGE 0x11 +#define BMA220_REG_SUSPEND 0x18 + +#define BMA220_CHIP_ID 0xDD +#define BMA220_READ_MASK 0x80 +#define BMA220_RANGE_MASK 0x03 +#define BMA220_DATA_SHIFT 2 +#define BMA220_SUSPEND_SLEEP 0xFF +#define BMA220_SUSPEND_WAKE 0x00 + +#define BMA220_DEVICE_NAME "bma220" +#define BMA220_SCALE_AVAILABLE "0.623 1.248 2.491 4.983" + +#define BMA220_ACCEL_CHANNEL(index, reg, axis) { \ + .type = IIO_ACCEL, \ + .address = reg, \ + .modified = 1, \ + .channel2 = IIO_MOD_##axis, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ +} + +static IIO_CONST_ATTR(in_accel_scale_available, BMA220_SCALE_AVAILABLE); + +static struct attribute *bma220_attributes[] = { + &iio_const_attr_in_accel_scale_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group bma220_attribute_group = { + .attrs = bma220_attributes, +}; + +static const int bma220_scale_table[][4] = { + {0, 623000}, {1, 248000}, {2, 491000}, {4, 983000} +}; + +struct bma220_data { + struct spi_device *spi_device; + struct mutex lock; + u8 tx_buf[2] ____cacheline_aligned; +}; + +static const struct iio_chan_spec bma220_channels[] = { + BMA220_ACCEL_CHANNEL(0, BMA220_REG_ACCEL_X, X), + BMA220_ACCEL_CHANNEL(1, BMA220_REG_ACCEL_Y, Y), + BMA220_ACCEL_CHANNEL(2, BMA220_REG_ACCEL_Z, Z), +}; + +static inline int bma220_read_reg(struct spi_device *spi, u8 reg) +{ + return spi_w8r8(spi, reg | BMA220_READ_MASK); +} + +static int bma220_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + int ret; + u8 range_idx; + struct bma220_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = bma220_read_reg(data->spi_device, chan->address); + if (ret < 0) + return -EINVAL; + *val = sign_extend32(ret >> BMA220_DATA_SHIFT, 5); + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + ret = bma220_read_reg(data->spi_device, BMA220_REG_RANGE); + if (ret < 0) + return ret; + range_idx = ret & BMA220_RANGE_MASK; + *val = bma220_scale_table[range_idx][0]; + *val2 = bma220_scale_table[range_idx][1]; + return IIO_VAL_INT_PLUS_MICRO; + } + + return -EINVAL; +} + +static int bma220_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + int i; + int ret; + int index = -1; + struct bma220_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + for (i = 0; i < ARRAY_SIZE(bma220_scale_table); i++) + if (val == bma220_scale_table[i][0] && + val2 == bma220_scale_table[i][1]) { + index = i; + break; + } + if (index < 0) + return -EINVAL; + + mutex_lock(&data->lock); + data->tx_buf[0] = BMA220_REG_RANGE; + data->tx_buf[1] = index; + ret = spi_write(data->spi_device, data->tx_buf, + sizeof(data->tx_buf)); + if (ret < 0) + dev_err(&data->spi_device->dev, + "failed to set measurement range\n"); + mutex_unlock(&data->lock); + + return 0; + } + + return -EINVAL; +} + +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, +}; + +static int bma220_init(struct spi_device *spi) +{ + int ret; + + ret = bma220_read_reg(spi, BMA220_REG_ID); + if (ret != BMA220_CHIP_ID) + return -ENODEV; + + /* Make sure the chip is powered on */ + ret = bma220_read_reg(spi, BMA220_REG_SUSPEND); + if (ret < 0) + return ret; + else if (ret == BMA220_SUSPEND_WAKE) + return bma220_read_reg(spi, BMA220_REG_SUSPEND); + + return 0; +} + +static int bma220_deinit(struct spi_device *spi) +{ + int ret; + + /* Make sure the chip is powered off */ + ret = bma220_read_reg(spi, BMA220_REG_SUSPEND); + if (ret < 0) + return ret; + else if (ret == BMA220_SUSPEND_SLEEP) + return bma220_read_reg(spi, BMA220_REG_SUSPEND); + + return 0; +} + +static int bma220_probe(struct spi_device *spi) +{ + int ret; + struct iio_dev *indio_dev; + struct bma220_data *data; + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*data)); + if (!indio_dev) { + dev_err(&spi->dev, "iio allocation failed!\n"); + return -ENOMEM; + } + + data = iio_priv(indio_dev); + data->spi_device = spi; + spi_set_drvdata(spi, indio_dev); + mutex_init(&data->lock); + + indio_dev->dev.parent = &spi->dev; + indio_dev->info = &bma220_info; + indio_dev->name = BMA220_DEVICE_NAME; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = bma220_channels; + indio_dev->num_channels = ARRAY_SIZE(bma220_channels); + + ret = bma220_init(data->spi_device); + if (ret < 0) + return ret; + + ret = iio_device_register(indio_dev); + if (ret < 0) { + dev_err(&spi->dev, "iio_device_register failed\n"); + return bma220_deinit(spi); + } + + return ret; +} + +static int bma220_remove(struct spi_device *spi) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + + iio_device_unregister(indio_dev); + + return bma220_deinit(spi); +} + +#ifdef CONFIG_PM_SLEEP +static int bma220_suspend(struct device *dev) +{ + struct bma220_data *data = + iio_priv(spi_get_drvdata(to_spi_device(dev))); + + /* The chip can be suspended/woken up by a simple register read. */ + return bma220_read_reg(data->spi_device, BMA220_REG_SUSPEND); +} + +static int bma220_resume(struct device *dev) +{ + struct bma220_data *data = + iio_priv(spi_get_drvdata(to_spi_device(dev))); + + return bma220_read_reg(data->spi_device, BMA220_REG_SUSPEND); +} + +static SIMPLE_DEV_PM_OPS(bma220_pm_ops, bma220_suspend, bma220_resume); + +#define BMA220_PM_OPS (&bma220_pm_ops) +#else +#define BMA220_PM_OPS NULL +#endif + +static const struct spi_device_id bma220_spi_id[] = { + {"bma220", 0}, + {} +}; + +static const struct acpi_device_id bma220_acpi_id[] = { + {"BMA0220", 0}, + {} +}; + +MODULE_DEVICE_TABLE(spi, bma220_spi_id); + +static struct spi_driver bma220_driver = { + .driver = { + .name = "bma220_spi", + .pm = BMA220_PM_OPS, + .acpi_match_table = ACPI_PTR(bma220_acpi_id), + }, + .probe = bma220_probe, + .remove = bma220_remove, + .id_table = bma220_spi_id, +}; + +module_spi_driver(bma220_driver); + +MODULE_AUTHOR("Tiberiu Breana "); +MODULE_DESCRIPTION("BMA220 acceleration sensor driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.1 From 9d75db36df146d212ade86a1aa69b718ebf31ac8 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Tue, 26 Apr 2016 15:39:58 +0300 Subject: iio: magn: Add support for BMM150 magnetometer BMM150 is register compatible with magnetometer part of BMC156. Datasheet is at: http://www.mouser.com/ds/2/783/BST-BMM150-DS001-01-786480.pdf Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/bmc150_magn_i2c.c | 3 +++ drivers/iio/magnetometer/bmc150_magn_spi.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/iio/magnetometer/bmc150_magn_i2c.c b/drivers/iio/magnetometer/bmc150_magn_i2c.c index eddc7f0..ee05722 100644 --- a/drivers/iio/magnetometer/bmc150_magn_i2c.c +++ b/drivers/iio/magnetometer/bmc150_magn_i2c.c @@ -2,6 +2,7 @@ * 3-axis magnetometer driver supporting following I2C Bosch-Sensortec chips: * - BMC150 * - BMC156 + * - BMM150 * * Copyright (c) 2016, Intel Corporation. * @@ -49,6 +50,7 @@ static int bmc150_magn_i2c_remove(struct i2c_client *client) static const struct acpi_device_id bmc150_magn_acpi_match[] = { {"BMC150B", 0}, {"BMC156B", 0}, + {"BMM150B", 0}, {}, }; MODULE_DEVICE_TABLE(acpi, bmc150_magn_acpi_match); @@ -56,6 +58,7 @@ MODULE_DEVICE_TABLE(acpi, bmc150_magn_acpi_match); static const struct i2c_device_id bmc150_magn_i2c_id[] = { {"bmc150_magn", 0}, {"bmc156_magn", 0}, + {"bmm150_magn", 0}, {} }; MODULE_DEVICE_TABLE(i2c, bmc150_magn_i2c_id); diff --git a/drivers/iio/magnetometer/bmc150_magn_spi.c b/drivers/iio/magnetometer/bmc150_magn_spi.c index c4c738a..7d4152d 100644 --- a/drivers/iio/magnetometer/bmc150_magn_spi.c +++ b/drivers/iio/magnetometer/bmc150_magn_spi.c @@ -2,6 +2,7 @@ * 3-axis magnetometer driver support following SPI Bosch-Sensortec chips: * - BMC150 * - BMC156 + * - BMM150 * * Copyright (c) 2016, Intel Corporation. * @@ -41,6 +42,7 @@ static int bmc150_magn_spi_remove(struct spi_device *spi) static const struct spi_device_id bmc150_magn_spi_id[] = { {"bmc150_magn", 0}, {"bmc156_magn", 0}, + {"bmm150_magn", 0}, {} }; MODULE_DEVICE_TABLE(spi, bmc150_magn_spi_id); @@ -48,6 +50,7 @@ MODULE_DEVICE_TABLE(spi, bmc150_magn_spi_id); static const struct acpi_device_id bmc150_magn_acpi_match[] = { {"BMC150B", 0}, {"BMC156B", 0}, + {"BMM150B", 0}, {}, }; MODULE_DEVICE_TABLE(acpi, bmc150_magn_acpi_match); -- cgit v1.1 From ba35f111aa6f386df33f950aeaea53a2bf040cc2 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Sun, 15 May 2016 22:18:46 -0700 Subject: iio: adc: ti-ads1015: add support for ADS1115 part TI ADS1115 is a 16-bit resolution ADC that is register map compatible with the ADS1015 device. Signed-off-by: Matt Ranostay Acked-by: Daniel Baluta Acked-by: Crt Mori Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-ads1015.c | 124 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 109 insertions(+), 15 deletions(-) diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index 73cbf0b..a835423 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -55,6 +55,11 @@ #define ADS1015_DEFAULT_DATA_RATE 4 #define ADS1015_DEFAULT_CHAN 0 +enum { + ADS1015, + ADS1115, +}; + enum ads1015_channels { ADS1015_AIN0_AIN1 = 0, ADS1015_AIN0_AIN3, @@ -71,6 +76,10 @@ static const unsigned int ads1015_data_rate[] = { 128, 250, 490, 920, 1600, 2400, 3300, 3300 }; +static const unsigned int ads1115_data_rate[] = { + 8, 16, 32, 64, 128, 250, 475, 860 +}; + static const struct { int scale; int uscale; @@ -123,6 +132,42 @@ static const struct { }, \ } +#define ADS1115_V_CHAN(_chan, _addr) { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .address = _addr, \ + .channel = _chan, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + .scan_index = _addr, \ + .scan_type = { \ + .sign = 's', \ + .realbits = 16, \ + .storagebits = 16, \ + .endianness = IIO_CPU, \ + }, \ +} + +#define ADS1115_V_DIFF_CHAN(_chan, _chan2, _addr) { \ + .type = IIO_VOLTAGE, \ + .differential = 1, \ + .indexed = 1, \ + .address = _addr, \ + .channel = _chan, \ + .channel2 = _chan2, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + .scan_index = _addr, \ + .scan_type = { \ + .sign = 's', \ + .realbits = 16, \ + .storagebits = 16, \ + .endianness = IIO_CPU, \ + }, \ +} + struct ads1015_data { struct regmap *regmap; /* @@ -131,6 +176,8 @@ struct ads1015_data { */ struct mutex lock; struct ads1015_channel_data channel_data[ADS1015_CHANNELS]; + + unsigned int *data_rate; }; static bool ads1015_is_writeable_reg(struct device *dev, unsigned int reg) @@ -157,6 +204,18 @@ static const struct iio_chan_spec ads1015_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(ADS1015_TIMESTAMP), }; +static const struct iio_chan_spec ads1115_channels[] = { + ADS1115_V_DIFF_CHAN(0, 1, ADS1015_AIN0_AIN1), + ADS1115_V_DIFF_CHAN(0, 3, ADS1015_AIN0_AIN3), + ADS1115_V_DIFF_CHAN(1, 3, ADS1015_AIN1_AIN3), + ADS1115_V_DIFF_CHAN(2, 3, ADS1015_AIN2_AIN3), + ADS1115_V_CHAN(0, ADS1015_AIN0), + ADS1115_V_CHAN(1, ADS1015_AIN1), + ADS1115_V_CHAN(2, ADS1015_AIN2), + ADS1115_V_CHAN(3, ADS1015_AIN3), + IIO_CHAN_SOFT_TIMESTAMP(ADS1015_TIMESTAMP), +}; + static int ads1015_set_power_state(struct ads1015_data *data, bool on) { int ret; @@ -196,7 +255,7 @@ int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val) return ret; if (change) { - conv_time = DIV_ROUND_UP(USEC_PER_SEC, ads1015_data_rate[dr]); + conv_time = DIV_ROUND_UP(USEC_PER_SEC, data->data_rate[dr]); usleep_range(conv_time, conv_time + 1); } @@ -263,7 +322,7 @@ static int ads1015_set_data_rate(struct ads1015_data *data, int chan, int rate) int i, ret, rindex = -1; for (i = 0; i < ARRAY_SIZE(ads1015_data_rate); i++) - if (ads1015_data_rate[i] == rate) { + if (data->data_rate[i] == rate) { rindex = i; break; } @@ -291,7 +350,9 @@ static int ads1015_read_raw(struct iio_dev *indio_dev, mutex_lock(&indio_dev->mlock); mutex_lock(&data->lock); switch (mask) { - case IIO_CHAN_INFO_RAW: + case IIO_CHAN_INFO_RAW: { + int shift = chan->scan_type.shift; + if (iio_buffer_enabled(indio_dev)) { ret = -EBUSY; break; @@ -307,8 +368,7 @@ static int ads1015_read_raw(struct iio_dev *indio_dev, break; } - /* 12 bit res, D0 is bit 4 in conversion register */ - *val = sign_extend32(*val >> 4, 11); + *val = sign_extend32(*val >> shift, 15 - shift); ret = ads1015_set_power_state(data, false); if (ret < 0) @@ -316,6 +376,7 @@ static int ads1015_read_raw(struct iio_dev *indio_dev, ret = IIO_VAL_INT; break; + } case IIO_CHAN_INFO_SCALE: idx = data->channel_data[chan->address].pga; *val = ads1015_scale[idx].scale; @@ -324,7 +385,7 @@ static int ads1015_read_raw(struct iio_dev *indio_dev, break; case IIO_CHAN_INFO_SAMP_FREQ: idx = data->channel_data[chan->address].data_rate; - *val = ads1015_data_rate[idx]; + *val = data->data_rate[idx]; ret = IIO_VAL_INT; break; default: @@ -380,12 +441,15 @@ static const struct iio_buffer_setup_ops ads1015_buffer_setup_ops = { }; static IIO_CONST_ATTR(scale_available, "3 2 1 0.5 0.25 0.125"); -static IIO_CONST_ATTR(sampling_frequency_available, - "128 250 490 920 1600 2400 3300"); + +static IIO_CONST_ATTR_NAMED(ads1015_sampling_frequency_available, + sampling_frequency_available, "128 250 490 920 1600 2400 3300"); +static IIO_CONST_ATTR_NAMED(ads1115_sampling_frequency_available, + sampling_frequency_available, "8 16 32 64 128 250 475 860"); static struct attribute *ads1015_attributes[] = { &iio_const_attr_scale_available.dev_attr.attr, - &iio_const_attr_sampling_frequency_available.dev_attr.attr, + &iio_const_attr_ads1015_sampling_frequency_available.dev_attr.attr, NULL, }; @@ -393,11 +457,28 @@ static const struct attribute_group ads1015_attribute_group = { .attrs = ads1015_attributes, }; -static const struct iio_info ads1015_info = { +static struct attribute *ads1115_attributes[] = { + &iio_const_attr_scale_available.dev_attr.attr, + &iio_const_attr_ads1115_sampling_frequency_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group ads1115_attribute_group = { + .attrs = ads1115_attributes, +}; + +static struct iio_info ads1015_info = { + .driver_module = THIS_MODULE, + .read_raw = ads1015_read_raw, + .write_raw = ads1015_write_raw, + .attrs = &ads1015_attribute_group, +}; + +static struct iio_info ads1115_info = { .driver_module = THIS_MODULE, .read_raw = ads1015_read_raw, .write_raw = ads1015_write_raw, - .attrs = &ads1015_attribute_group, + .attrs = &ads1115_attribute_group, }; #ifdef CONFIG_OF @@ -500,12 +581,24 @@ static int ads1015_probe(struct i2c_client *client, mutex_init(&data->lock); indio_dev->dev.parent = &client->dev; - indio_dev->info = &ads1015_info; indio_dev->name = ADS1015_DRV_NAME; - indio_dev->channels = ads1015_channels; - indio_dev->num_channels = ARRAY_SIZE(ads1015_channels); indio_dev->modes = INDIO_DIRECT_MODE; + switch (id->driver_data) { + case ADS1015: + indio_dev->channels = ads1015_channels; + indio_dev->num_channels = ARRAY_SIZE(ads1015_channels); + indio_dev->info = &ads1015_info; + data->data_rate = (unsigned int *) &ads1015_data_rate; + break; + case ADS1115: + indio_dev->channels = ads1115_channels; + indio_dev->num_channels = ARRAY_SIZE(ads1115_channels); + indio_dev->info = &ads1115_info; + data->data_rate = (unsigned int *) &ads1115_data_rate; + break; + } + /* we need to keep this ABI the same as used by hwmon ADS1015 driver */ ads1015_get_channels_config(client); @@ -590,7 +683,8 @@ static const struct dev_pm_ops ads1015_pm_ops = { }; static const struct i2c_device_id ads1015_id[] = { - {"ads1015", 0}, + {"ads1015", ADS1015}, + {"ads1115", ADS1115}, {} }; MODULE_DEVICE_TABLE(i2c, ads1015_id); -- cgit v1.1 From 194dc4c714132a63a7a731fe4debeccbdfab13e1 Mon Sep 17 00:00:00 2001 From: Tiberiu Breana Date: Mon, 16 May 2016 14:58:23 +0300 Subject: iio: accel: Add triggered buffer support for BMA220 Signed-off-by: Tiberiu Breana Signed-off-by: Jonathan Cameron --- drivers/iio/accel/bma220_spi.c | 65 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c index 7343575..1098d10 100644 --- a/drivers/iio/accel/bma220_spi.c +++ b/drivers/iio/accel/bma220_spi.c @@ -11,9 +11,12 @@ #include #include #include +#include #include #include #include +#include +#include #define BMA220_REG_ID 0x00 #define BMA220_REG_ACCEL_X 0x02 @@ -39,8 +42,22 @@ .channel2 = IIO_MOD_##axis, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .scan_index = index, \ + .scan_type = { \ + .sign = 's', \ + .realbits = 6, \ + .storagebits = 8, \ + .shift = BMA220_DATA_SHIFT, \ + .endianness = IIO_CPU, \ + }, \ } +enum bma220_axis { + AXIS_X, + AXIS_Y, + AXIS_Z, +}; + static IIO_CONST_ATTR(in_accel_scale_available, BMA220_SCALE_AVAILABLE); static struct attribute *bma220_attributes[] = { @@ -59,6 +76,7 @@ static const int bma220_scale_table[][4] = { struct bma220_data { struct spi_device *spi_device; struct mutex lock; + s8 buffer[16]; /* 3x8-bit channels + 5x8 padding + 8x8 timestamp */ u8 tx_buf[2] ____cacheline_aligned; }; @@ -66,6 +84,7 @@ static const struct iio_chan_spec bma220_channels[] = { BMA220_ACCEL_CHANNEL(0, BMA220_REG_ACCEL_X, X), BMA220_ACCEL_CHANNEL(1, BMA220_REG_ACCEL_Y, Y), BMA220_ACCEL_CHANNEL(2, BMA220_REG_ACCEL_Z, Z), + IIO_CHAN_SOFT_TIMESTAMP(3), }; static inline int bma220_read_reg(struct spi_device *spi, u8 reg) @@ -73,6 +92,35 @@ static inline int bma220_read_reg(struct spi_device *spi, u8 reg) return spi_w8r8(spi, reg | BMA220_READ_MASK); } +static const unsigned long bma220_accel_scan_masks[] = { + BIT(AXIS_X) | BIT(AXIS_Y) | BIT(AXIS_Z), + 0 +}; + +static irqreturn_t bma220_trigger_handler(int irq, void *p) +{ + int ret; + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct bma220_data *data = iio_priv(indio_dev); + struct spi_device *spi = data->spi_device; + + mutex_lock(&data->lock); + data->tx_buf[0] = BMA220_REG_ACCEL_X | BMA220_READ_MASK; + ret = spi_write_then_read(spi, data->tx_buf, 1, data->buffer, + ARRAY_SIZE(bma220_channels) - 1); + if (ret < 0) + goto err; + + iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, + pf->timestamp); +err: + mutex_unlock(&data->lock); + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + static int bma220_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) @@ -199,18 +247,30 @@ static int bma220_probe(struct spi_device *spi) indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = bma220_channels; indio_dev->num_channels = ARRAY_SIZE(bma220_channels); + indio_dev->available_scan_masks = bma220_accel_scan_masks; ret = bma220_init(data->spi_device); if (ret < 0) return ret; + ret = iio_triggered_buffer_setup(indio_dev, NULL, + bma220_trigger_handler, NULL); + if (ret < 0) { + dev_err(&spi->dev, "iio triggered buffer setup failed\n"); + goto err_suspend; + } + ret = iio_device_register(indio_dev); if (ret < 0) { dev_err(&spi->dev, "iio_device_register failed\n"); - return bma220_deinit(spi); + iio_triggered_buffer_cleanup(indio_dev); + goto err_suspend; } - return ret; + return 0; + +err_suspend: + return bma220_deinit(spi); } static int bma220_remove(struct spi_device *spi) @@ -218,6 +278,7 @@ static int bma220_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); iio_device_unregister(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); return bma220_deinit(spi); } -- cgit v1.1 From cdd469ad9e008a58ed465efa09f8594f1387e8ce Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 17 May 2016 12:25:37 -0400 Subject: iio: Export I2C module alias information The I2C drivers have an i2c_device_id array but that information isn't exported to the modules using the MODULE_DEVICE_TABLE() macro. So the modules autoloading won't work if the I2C device is registered using OF or legacy board files due missing alias information in the modules. The issue was found using Kieran Bingham's coccinelle semantic patch: https://lkml.org/lkml/2016/5/10/520 Signed-off-by: Javier Martinez Canillas Signed-off-by: Jonathan Cameron --- drivers/iio/humidity/am2315.c | 1 + drivers/iio/humidity/htu21.c | 1 + drivers/iio/pressure/hp206c.c | 1 + drivers/iio/pressure/ms5637.c | 1 + drivers/iio/temperature/tsys02d.c | 1 + 5 files changed, 5 insertions(+) diff --git a/drivers/iio/humidity/am2315.c b/drivers/iio/humidity/am2315.c index 3be6d20..8de39bd 100644 --- a/drivers/iio/humidity/am2315.c +++ b/drivers/iio/humidity/am2315.c @@ -278,6 +278,7 @@ static const struct i2c_device_id am2315_i2c_id[] = { {"am2315", 0}, {} }; +MODULE_DEVICE_TABLE(i2c, am2315_i2c_id); static const struct acpi_device_id am2315_acpi_id[] = { {"AOS2315", 0}, diff --git a/drivers/iio/humidity/htu21.c b/drivers/iio/humidity/htu21.c index 11cbc38..0fbbd8c 100644 --- a/drivers/iio/humidity/htu21.c +++ b/drivers/iio/humidity/htu21.c @@ -236,6 +236,7 @@ static const struct i2c_device_id htu21_id[] = { {"ms8607-humidity", MS8607}, {} }; +MODULE_DEVICE_TABLE(i2c, htu21_id); static struct i2c_driver htu21_driver = { .probe = htu21_probe, diff --git a/drivers/iio/pressure/hp206c.c b/drivers/iio/pressure/hp206c.c index 90f2b6e..12f769e8 100644 --- a/drivers/iio/pressure/hp206c.c +++ b/drivers/iio/pressure/hp206c.c @@ -401,6 +401,7 @@ static const struct i2c_device_id hp206c_id[] = { {"hp206c"}, {} }; +MODULE_DEVICE_TABLE(i2c, hp206c_id); #ifdef CONFIG_ACPI static const struct acpi_device_id hp206c_acpi_match[] = { diff --git a/drivers/iio/pressure/ms5637.c b/drivers/iio/pressure/ms5637.c index e68052c..8fb6f7a 100644 --- a/drivers/iio/pressure/ms5637.c +++ b/drivers/iio/pressure/ms5637.c @@ -173,6 +173,7 @@ static const struct i2c_device_id ms5637_id[] = { {"ms8607-temppressure", 1}, {} }; +MODULE_DEVICE_TABLE(i2c, ms5637_id); static struct i2c_driver ms5637_driver = { .probe = ms5637_probe, diff --git a/drivers/iio/temperature/tsys02d.c b/drivers/iio/temperature/tsys02d.c index ab6fe8f..c0a19a0 100644 --- a/drivers/iio/temperature/tsys02d.c +++ b/drivers/iio/temperature/tsys02d.c @@ -174,6 +174,7 @@ static const struct i2c_device_id tsys02d_id[] = { {"tsys02d", 0}, {} }; +MODULE_DEVICE_TABLE(i2c, tsys02d_id); static struct i2c_driver tsys02d_driver = { .probe = tsys02d_probe, -- cgit v1.1 From 9a47894fbeda2ab92c6ec57ee359adeaf283b962 Mon Sep 17 00:00:00 2001 From: Cristina Moraru Date: Thu, 19 May 2016 08:55:46 +0300 Subject: iio: max5487: Add support for Maxim digital potentiometers Add implementation for Maxim MAX5487, MAX5488, MAX5489 digital potentiometers. Datasheet: http://datasheets.maximintegrated.com/en/ds/MAX5487-MAX5489.pdf Signed-off-by: Cristina Moraru CC: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/potentiometer/Kconfig | 11 +++ drivers/iio/potentiometer/Makefile | 1 + drivers/iio/potentiometer/max5487.c | 161 ++++++++++++++++++++++++++++++++++++ 3 files changed, 173 insertions(+) create mode 100644 drivers/iio/potentiometer/max5487.c diff --git a/drivers/iio/potentiometer/Kconfig b/drivers/iio/potentiometer/Kconfig index 6acb238..0941c8d4 100644 --- a/drivers/iio/potentiometer/Kconfig +++ b/drivers/iio/potentiometer/Kconfig @@ -15,6 +15,17 @@ config DS1803 To compile this driver as a module, choose M here: the module will be called ds1803. +config MAX5487 + tristate "Maxim MAX5487/MAX5488/MAX5489 Digital Potentiometer driver" + depends on SPI + help + Say yes here to build support for the Maxim + MAX5487, MAX5488, MAX5489 digital potentiometer + chips. + + To compile this driver as a module, choose M here: the + module will be called max5487. + config MCP4131 tristate "Microchip MCP413X/414X/415X/416X/423X/424X/425X/426X Digital Potentiometer driver" depends on SPI diff --git a/drivers/iio/potentiometer/Makefile b/drivers/iio/potentiometer/Makefile index 6007faa..8adb58f 100644 --- a/drivers/iio/potentiometer/Makefile +++ b/drivers/iio/potentiometer/Makefile @@ -4,6 +4,7 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_DS1803) += ds1803.o +obj-$(CONFIG_MAX5487) += max5487.o obj-$(CONFIG_MCP4131) += mcp4131.o obj-$(CONFIG_MCP4531) += mcp4531.o obj-$(CONFIG_TPL0102) += tpl0102.o diff --git a/drivers/iio/potentiometer/max5487.c b/drivers/iio/potentiometer/max5487.c new file mode 100644 index 0000000..6c50939 --- /dev/null +++ b/drivers/iio/potentiometer/max5487.c @@ -0,0 +1,161 @@ +/* + * max5487.c - Support for MAX5487, MAX5488, MAX5489 digital potentiometers + * + * Copyright (C) 2016 Cristina-Gabriela Moraru + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ +#include +#include +#include + +#include +#include + +#define MAX5487_WRITE_WIPER_A (0x01 << 8) +#define MAX5487_WRITE_WIPER_B (0x02 << 8) + +/* copy both wiper regs to NV regs */ +#define MAX5487_COPY_AB_TO_NV (0x23 << 8) +/* copy both NV regs to wiper regs */ +#define MAX5487_COPY_NV_TO_AB (0x33 << 8) + +#define MAX5487_MAX_POS 255 + +struct max5487_data { + struct spi_device *spi; + int kohms; +}; + +#define MAX5487_CHANNEL(ch, addr) { \ + .type = IIO_RESISTANCE, \ + .indexed = 1, \ + .output = 1, \ + .channel = ch, \ + .address = addr, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ +} + +static const struct iio_chan_spec max5487_channels[] = { + MAX5487_CHANNEL(0, MAX5487_WRITE_WIPER_A), + MAX5487_CHANNEL(1, MAX5487_WRITE_WIPER_B), +}; + +static int max5487_write_cmd(struct spi_device *spi, u16 cmd) +{ + return spi_write(spi, (const void *) &cmd, sizeof(u16)); +} + +static int max5487_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct max5487_data *data = iio_priv(indio_dev); + + if (mask != IIO_CHAN_INFO_SCALE) + return -EINVAL; + + *val = 1000 * data->kohms; + *val2 = MAX5487_MAX_POS; + + return IIO_VAL_FRACTIONAL; +} + +static int max5487_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct max5487_data *data = iio_priv(indio_dev); + + if (mask != IIO_CHAN_INFO_RAW) + return -EINVAL; + + if (val < 0 || val > MAX5487_MAX_POS) + return -EINVAL; + + return max5487_write_cmd(data->spi, chan->address | val); +} + +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) +{ + struct iio_dev *indio_dev; + struct max5487_data *data; + const struct spi_device_id *id = spi_get_device_id(spi); + int ret; + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + dev_set_drvdata(&spi->dev, indio_dev); + data = iio_priv(indio_dev); + + data->spi = spi; + data->kohms = id->driver_data; + + indio_dev->info = &max5487_info; + indio_dev->name = id->name; + indio_dev->dev.parent = &spi->dev; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = max5487_channels; + indio_dev->num_channels = ARRAY_SIZE(max5487_channels); + + /* restore both wiper regs from NV regs */ + ret = max5487_write_cmd(data->spi, MAX5487_COPY_NV_TO_AB); + if (ret < 0) + return ret; + + return iio_device_register(indio_dev); +} + +static int max5487_spi_remove(struct spi_device *spi) +{ + struct iio_dev *indio_dev = dev_get_drvdata(&spi->dev); + + iio_device_unregister(indio_dev); + + /* save both wiper regs to NV regs */ + return max5487_write_cmd(spi, MAX5487_COPY_AB_TO_NV); +} + +static const struct spi_device_id max5487_id[] = { + { "MAX5487", 10 }, + { "MAX5488", 50 }, + { "MAX5489", 100 }, + { } +}; +MODULE_DEVICE_TABLE(spi, max5487_id); + +static const struct acpi_device_id max5487_acpi_match[] = { + { "MAX5487", 10 }, + { "MAX5488", 50 }, + { "MAX5489", 100 }, + { }, +}; +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, + .probe = max5487_spi_probe, + .remove = max5487_spi_remove +}; +module_spi_driver(max5487_driver); + +MODULE_AUTHOR("Cristina-Gabriela Moraru "); +MODULE_DESCRIPTION("max5487 SPI driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.1 From 44072b2c8da876e19c862ef609c14c8c4aecb48f Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Wed, 18 May 2016 17:16:18 +0200 Subject: iio: adc: nau7802: Expose possible gains in sysfs The Nuvoton NAU7802 ADC is able to adjust its gain but prior knowledge of its possible values was required to adjust it. Users had to guess the possible gain values based on the ADC datasheet or on this driver's code. This exposes the possible values in the in_voltage_scale_available file of each nau7802 ADC device. The gain is set for the whole ADC and is therefore not configurable by channel. Thus, there exists only one in_voltage_scale_available file for each nau7802 ADC device even if it has two separate channels. Signed-off-by: Quentin Schulz Acked-by: Alexandre Belloni Signed-off-by: Jonathan Cameron --- drivers/iio/adc/nau7802.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c index e525aa6..57365c5 100644 --- a/drivers/iio/adc/nau7802.c +++ b/drivers/iio/adc/nau7802.c @@ -79,10 +79,29 @@ static const struct iio_chan_spec nau7802_chan_array[] = { static const u16 nau7802_sample_freq_avail[] = {10, 20, 40, 80, 10, 10, 10, 320}; +static ssize_t nau7802_show_scales(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct nau7802_state *st = iio_priv(dev_to_iio_dev(dev)); + int i, len = 0; + + for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) + len += scnprintf(buf + len, PAGE_SIZE - len, "0.%09d ", + st->scale_avail[i]); + + buf[len-1] = '\n'; + + return len; +} + static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("10 40 80 320"); +static IIO_DEVICE_ATTR(in_voltage_scale_available, S_IRUGO, nau7802_show_scales, + NULL, 0); + static struct attribute *nau7802_attributes[] = { &iio_const_attr_sampling_frequency_available.dev_attr.attr, + &iio_dev_attr_in_voltage_scale_available.dev_attr.attr, NULL }; -- cgit v1.1 From b7a96bb96fa0dfa3974c1f7830aa698959bff155 Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Sun, 15 May 2016 11:37:27 -0700 Subject: iio: light: jsa1212: remove unneeded i2c check functionality test This driver does not call i2c_smbus_read|write_byte_data(), so remove the corresponding functionality test. It uses regmap to handle byte transfers transparently. Signed-off-by: Alison Schofield Reviewed-by:Kuppuswamy Sathyanarayanan Reviewed-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- drivers/iio/light/jsa1212.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/iio/light/jsa1212.c b/drivers/iio/light/jsa1212.c index 99a6281..e8a8931 100644 --- a/drivers/iio/light/jsa1212.c +++ b/drivers/iio/light/jsa1212.c @@ -325,9 +325,6 @@ static int jsa1212_probe(struct i2c_client *client, struct regmap *regmap; int ret; - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) - return -EOPNOTSUPP; - indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); if (!indio_dev) return -ENOMEM; -- cgit v1.1 From 14beaa8f5ab11b881c5e822e2474f5278d0946d5 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Wed, 4 May 2016 22:57:30 -0700 Subject: iio: pressure: bmp280: add humidity support Enable humidity support for the BME280 part Signed-off-by: Matt Ranostay Acked-by: Vlad Dogaru Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/Kconfig | 3 +- drivers/iio/pressure/bmp280.c | 200 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 200 insertions(+), 3 deletions(-) diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index cda9f12..9125a93 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -12,7 +12,8 @@ config BMP280 select REGMAP_I2C help Say yes here to build support for Bosch Sensortec BMP180 and BMP280 - pressure and temperature sensors. + pressure and temperature sensors. Also supports the BE280 with + an additional humidty sensor channel. To compile this driver as a module, choose M here: the module will be called bmp280. diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c index 2f1498e..1876b50 100644 --- a/drivers/iio/pressure/bmp280.c +++ b/drivers/iio/pressure/bmp280.c @@ -10,6 +10,7 @@ * Datasheet: * https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMP180-DS000-121.pdf * https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMP280-DS001-12.pdf + * https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME280_DS001-11.pdf */ #define pr_fmt(fmt) "bmp280: " fmt @@ -23,6 +24,8 @@ #include /* BMP280 specific registers */ +#define BMP280_REG_HUMIDITY_LSB 0xFE +#define BMP280_REG_HUMIDITY_MSB 0xFD #define BMP280_REG_TEMP_XLSB 0xFC #define BMP280_REG_TEMP_LSB 0xFB #define BMP280_REG_TEMP_MSB 0xFA @@ -31,7 +34,17 @@ #define BMP280_REG_PRESS_MSB 0xF7 #define BMP280_REG_CONFIG 0xF5 +#define BMP280_REG_CTRL_MEAS 0xF4 #define BMP280_REG_STATUS 0xF3 +#define BMP280_REG_CTRL_HUMIDITY 0xF2 + +/* Due to non linear mapping, and data sizes we can't do a bulk read */ +#define BMP280_REG_COMP_H1 0xA1 +#define BMP280_REG_COMP_H2 0xE1 +#define BMP280_REG_COMP_H3 0xE3 +#define BMP280_REG_COMP_H4 0xE4 +#define BMP280_REG_COMP_H5 0xE5 +#define BMP280_REG_COMP_H6 0xE7 #define BMP280_REG_COMP_TEMP_START 0x88 #define BMP280_COMP_TEMP_REG_COUNT 6 @@ -46,6 +59,15 @@ #define BMP280_FILTER_8X (BIT(3) | BIT(2)) #define BMP280_FILTER_16X BIT(4) +#define BMP280_OSRS_HUMIDITY_MASK (BIT(2) | BIT(1) | BIT(0)) +#define BMP280_OSRS_HUMIDITIY_X(osrs_h) ((osrs_h) << 0) +#define BMP280_OSRS_HUMIDITY_SKIP 0 +#define BMP280_OSRS_HUMIDITY_1X BMP280_OSRS_HUMIDITIY_X(1) +#define BMP280_OSRS_HUMIDITY_2X BMP280_OSRS_HUMIDITIY_X(2) +#define BMP280_OSRS_HUMIDITY_4X BMP280_OSRS_HUMIDITIY_X(3) +#define BMP280_OSRS_HUMIDITY_8X BMP280_OSRS_HUMIDITIY_X(4) +#define BMP280_OSRS_HUMIDITY_16X BMP280_OSRS_HUMIDITIY_X(5) + #define BMP280_OSRS_TEMP_MASK (BIT(7) | BIT(6) | BIT(5)) #define BMP280_OSRS_TEMP_SKIP 0 #define BMP280_OSRS_TEMP_X(osrs_t) ((osrs_t) << 5) @@ -92,6 +114,7 @@ #define BMP180_CHIP_ID 0x55 #define BMP280_CHIP_ID 0x58 +#define BME280_CHIP_ID 0x60 #define BMP280_SOFT_RESET_VAL 0xB6 struct bmp280_data { @@ -103,6 +126,7 @@ struct bmp280_data { /* log of base 2 of oversampling rate */ u8 oversampling_press; u8 oversampling_temp; + u8 oversampling_humid; /* * Carryover value from temperature conversion, used in pressure @@ -120,9 +144,13 @@ struct bmp280_chip_info { const int *oversampling_press_avail; int num_oversampling_press_avail; + const int *oversampling_humid_avail; + int num_oversampling_humid_avail; + int (*chip_config)(struct bmp280_data *); int (*read_temp)(struct bmp280_data *, int *); int (*read_press)(struct bmp280_data *, int *, int *); + int (*read_humid)(struct bmp280_data *, int *, int *); }; /* @@ -143,12 +171,18 @@ static const struct iio_chan_spec bmp280_channels[] = { .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), }, + { + .type = IIO_HUMIDITYRELATIVE, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), + }, }; static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg) { switch (reg) { case BMP280_REG_CONFIG: + case BMP280_REG_CTRL_HUMIDITY: case BMP280_REG_CTRL_MEAS: case BMP280_REG_RESET: return true; @@ -160,6 +194,8 @@ static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg) static bool bmp280_is_volatile_reg(struct device *dev, unsigned int reg) { switch (reg) { + case BMP280_REG_HUMIDITY_LSB: + case BMP280_REG_HUMIDITY_MSB: case BMP280_REG_TEMP_XLSB: case BMP280_REG_TEMP_LSB: case BMP280_REG_TEMP_MSB: @@ -177,7 +213,7 @@ static const struct regmap_config bmp280_regmap_config = { .reg_bits = 8, .val_bits = 8, - .max_register = BMP280_REG_TEMP_XLSB, + .max_register = BMP280_REG_HUMIDITY_LSB, .cache_type = REGCACHE_RBTREE, .writeable_reg = bmp280_is_writeable_reg, @@ -185,6 +221,70 @@ static const struct regmap_config bmp280_regmap_config = { }; /* + * Returns humidity in percent, resolution is 0.01 percent. Output value of + * "47445" represents 47445/1024 = 46.333 %RH. + * + * Taken from BME280 datasheet, Section 4.2.3, "Compensation formula". + */ + +static u32 bmp280_compensate_humidity(struct bmp280_data *data, + s32 adc_humidity) +{ + struct device *dev = &data->client->dev; + unsigned int H1, H3, tmp; + int H2, H4, H5, H6, ret, var; + + ret = regmap_read(data->regmap, BMP280_REG_COMP_H1, &H1); + if (ret < 0) { + dev_err(dev, "failed to read H1 comp value\n"); + return ret; + } + + ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H2, &tmp, 2); + if (ret < 0) { + dev_err(dev, "failed to read H2 comp value\n"); + return ret; + } + H2 = sign_extend32(le16_to_cpu(tmp), 15); + + ret = regmap_read(data->regmap, BMP280_REG_COMP_H3, &H3); + if (ret < 0) { + dev_err(dev, "failed to read H3 comp value\n"); + return ret; + } + + ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H4, &tmp, 2); + if (ret < 0) { + dev_err(dev, "failed to read H4 comp value\n"); + return ret; + } + H4 = sign_extend32(((be16_to_cpu(tmp) >> 4) & 0xff0) | + (be16_to_cpu(tmp) & 0xf), 11); + + ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H5, &tmp, 2); + if (ret < 0) { + dev_err(dev, "failed to read H5 comp value\n"); + return ret; + } + H5 = sign_extend32(((le16_to_cpu(tmp) >> 4) & 0xfff), 11); + + ret = regmap_read(data->regmap, BMP280_REG_COMP_H6, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read H6 comp value\n"); + return ret; + } + H6 = sign_extend32(tmp, 7); + + var = ((s32)data->t_fine) - 76800; + var = ((((adc_humidity << 14) - (H4 << 20) - (H5 * var)) + 16384) >> 15) + * (((((((var * H6) >> 10) * (((var * H3) >> 11) + 32768)) >> 10) + + 2097152) * H2 + 8192) >> 14); + var -= ((((var >> 15) * (var >> 15)) >> 7) * H1) >> 4; + + return var >> 12; +}; + +/* * Returns temperature in DegC, resolution is 0.01 DegC. Output value of * "5123" equals 51.23 DegC. t_fine carries fine temperature as global * value. @@ -324,6 +424,34 @@ static int bmp280_read_press(struct bmp280_data *data, return IIO_VAL_FRACTIONAL; } +static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2) +{ + int ret; + __be16 tmp = 0; + s32 adc_humidity; + u32 comp_humidity; + + /* Read and compensate temperature so we get a reading of t_fine. */ + ret = bmp280_read_temp(data, NULL); + if (ret < 0) + return ret; + + ret = regmap_bulk_read(data->regmap, BMP280_REG_HUMIDITY_MSB, + (u8 *) &tmp, 2); + if (ret < 0) { + dev_err(&data->client->dev, "failed to read humidity\n"); + return ret; + } + + adc_humidity = be16_to_cpu(tmp); + comp_humidity = bmp280_compensate_humidity(data, adc_humidity); + + *val = comp_humidity; + *val2 = 1024; + + return IIO_VAL_FRACTIONAL; +} + static int bmp280_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) @@ -336,6 +464,9 @@ static int bmp280_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_PROCESSED: switch (chan->type) { + case IIO_HUMIDITYRELATIVE: + ret = data->chip_info->read_humid(data, val, val2); + break; case IIO_PRESSURE: ret = data->chip_info->read_press(data, val, val2); break; @@ -349,6 +480,10 @@ static int bmp280_read_raw(struct iio_dev *indio_dev, break; case IIO_CHAN_INFO_OVERSAMPLING_RATIO: switch (chan->type) { + case IIO_HUMIDITYRELATIVE: + *val = 1 << data->oversampling_humid; + ret = IIO_VAL_INT; + break; case IIO_PRESSURE: *val = 1 << data->oversampling_press; ret = IIO_VAL_INT; @@ -372,6 +507,23 @@ static int bmp280_read_raw(struct iio_dev *indio_dev, return ret; } +static int bmp280_write_oversampling_ratio_humid(struct bmp280_data *data, + int val) +{ + int i; + const int *avail = data->chip_info->oversampling_humid_avail; + const int n = data->chip_info->num_oversampling_humid_avail; + + for (i = 0; i < n; i++) { + if (avail[i] == val) { + data->oversampling_humid = ilog2(val); + + return data->chip_info->chip_config(data); + } + } + return -EINVAL; +} + static int bmp280_write_oversampling_ratio_temp(struct bmp280_data *data, int val) { @@ -417,6 +569,9 @@ static int bmp280_write_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_OVERSAMPLING_RATIO: mutex_lock(&data->lock); switch (chan->type) { + case IIO_HUMIDITYRELATIVE: + ret = bmp280_write_oversampling_ratio_humid(data, val); + break; case IIO_PRESSURE: ret = bmp280_write_oversampling_ratio_press(data, val); break; @@ -535,6 +690,37 @@ static const struct bmp280_chip_info bmp280_chip_info = { .read_press = bmp280_read_press, }; +static int bme280_chip_config(struct bmp280_data *data) +{ + int ret = bmp280_chip_config(data); + u8 osrs = BMP280_OSRS_HUMIDITIY_X(data->oversampling_humid + 1); + + if (ret < 0) + return ret; + + return regmap_update_bits(data->regmap, BMP280_REG_CTRL_HUMIDITY, + BMP280_OSRS_HUMIDITY_MASK, osrs); +} + +static const struct bmp280_chip_info bme280_chip_info = { + .regmap_config = &bmp280_regmap_config, + + .oversampling_temp_avail = bmp280_oversampling_avail, + .num_oversampling_temp_avail = ARRAY_SIZE(bmp280_oversampling_avail), + + .oversampling_press_avail = bmp280_oversampling_avail, + .num_oversampling_press_avail = ARRAY_SIZE(bmp280_oversampling_avail), + + .oversampling_humid_avail = bmp280_oversampling_avail, + .num_oversampling_humid_avail = ARRAY_SIZE(bmp280_oversampling_avail), + + .chip_config = bme280_chip_config, + .read_temp = bmp280_read_temp, + .read_press = bmp280_read_press, + .read_humid = bmp280_read_humid, +}; + + static bool bmp180_is_writeable_reg(struct device *dev, unsigned int reg) { switch (reg) { @@ -849,21 +1035,29 @@ static int bmp280_probe(struct i2c_client *client, indio_dev->dev.parent = &client->dev; indio_dev->name = id->name; indio_dev->channels = bmp280_channels; - indio_dev->num_channels = ARRAY_SIZE(bmp280_channels); indio_dev->info = &bmp280_info; indio_dev->modes = INDIO_DIRECT_MODE; switch (id->driver_data) { case BMP180_CHIP_ID: + indio_dev->num_channels = 2; data->chip_info = &bmp180_chip_info; data->oversampling_press = ilog2(8); data->oversampling_temp = ilog2(1); break; case BMP280_CHIP_ID: + indio_dev->num_channels = 2; data->chip_info = &bmp280_chip_info; data->oversampling_press = ilog2(16); data->oversampling_temp = ilog2(2); break; + case BME280_CHIP_ID: + indio_dev->num_channels = 3; + data->chip_info = &bme280_chip_info; + data->oversampling_press = ilog2(16); + data->oversampling_humid = ilog2(16); + data->oversampling_temp = ilog2(2); + break; default: return -EINVAL; } @@ -895,6 +1089,7 @@ static const struct acpi_device_id bmp280_acpi_match[] = { {"BMP0280", BMP280_CHIP_ID }, {"BMP0180", BMP180_CHIP_ID }, {"BMP0085", BMP180_CHIP_ID }, + {"BME0280", BME280_CHIP_ID }, { }, }; MODULE_DEVICE_TABLE(acpi, bmp280_acpi_match); @@ -903,6 +1098,7 @@ static const struct i2c_device_id bmp280_id[] = { {"bmp280", BMP280_CHIP_ID }, {"bmp180", BMP180_CHIP_ID }, {"bmp085", BMP180_CHIP_ID }, + {"bme280", BME280_CHIP_ID }, { }, }; MODULE_DEVICE_TABLE(i2c, bmp280_id); -- cgit v1.1 From 866b148a73e72af919ff836f3dfb5a6022823623 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 22 May 2016 11:05:57 +0200 Subject: MAINTAINERS: Add file patterns for iio device tree bindings Submitters of device tree binding documentation may forget to CC the subsystem maintainer if this is missing. Signed-off-by: Geert Uytterhoeven Cc: Jonathan Cameron Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: linux-iio@vger.kernel.org Signed-off-by: Jonathan Cameron --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 1ace393..cb1eadd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5541,6 +5541,7 @@ R: Lars-Peter Clausen R: Peter Meerwald-Stadler L: linux-iio@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/iio/ F: drivers/iio/ F: drivers/staging/iio/ F: include/linux/iio/ -- cgit v1.1 From 5291582dc6a4a9c1167ee86748bce5444633d7cc Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 22 May 2016 11:06:22 +0200 Subject: MAINTAINERS: Add file patterns for staging iio device tree bindings Submitters of device tree binding documentation may forget to CC the subsystem maintainer if this is missing. Signed-off-by: Geert Uytterhoeven Cc: Jonathan Cameron Cc: linux-iio@vger.kernel.org Signed-off-by: Jonathan Cameron --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index cb1eadd..0c484c4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10561,6 +10561,7 @@ STAGING - INDUSTRIAL IO M: Jonathan Cameron L: linux-iio@vger.kernel.org S: Odd Fixes +F: Documentation/devicetree/bindings/staging/iio/ F: drivers/staging/iio/ STAGING - LIRC (LINUX INFRARED REMOTE CONTROL) DRIVERS -- cgit v1.1 From 8ac8aa61f87eda944cf29229c9c20cba9e83f1ea Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Tue, 17 May 2016 15:02:03 -0700 Subject: iio: adc: ti-ads1015: add datasheet names Add datasheet names for ADC channels to allow iio consumers access. Signed-off-by: Matt Ranostay Acked-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-ads1015.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index a835423..8be192a 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -110,6 +110,7 @@ static const struct { .shift = 4, \ .endianness = IIO_CPU, \ }, \ + .datasheet_name = "AIN"#_chan, \ } #define ADS1015_V_DIFF_CHAN(_chan, _chan2, _addr) { \ @@ -130,6 +131,7 @@ static const struct { .shift = 4, \ .endianness = IIO_CPU, \ }, \ + .datasheet_name = "AIN"#_chan"-AIN"#_chan2, \ } #define ADS1115_V_CHAN(_chan, _addr) { \ @@ -147,6 +149,7 @@ static const struct { .storagebits = 16, \ .endianness = IIO_CPU, \ }, \ + .datasheet_name = "AIN"#_chan, \ } #define ADS1115_V_DIFF_CHAN(_chan, _chan2, _addr) { \ @@ -166,6 +169,7 @@ static const struct { .storagebits = 16, \ .endianness = IIO_CPU, \ }, \ + .datasheet_name = "AIN"#_chan"-AIN"#_chan2, \ } struct ads1015_data { -- cgit v1.1 From ef2d71d6b7fbbb57e332883d8fad39f2adb9199e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 14 May 2016 18:42:08 +0100 Subject: iio: triggers: Make trigger ops structure explicitly non optional. This structure has not been optional for a long time (if ever) but the code implies that it is. As we then use it later in a fashion that would crash if it was in fact NULL, it's inconsistent so fix it up by removing unnecessary checks. Reported-by: Dan Carpenter Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-trigger.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index ae2806a..6729112 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -68,6 +68,10 @@ int iio_trigger_register(struct iio_trigger *trig_info) { int ret; + /* trig_info->ops is required for the module member */ + if (!trig_info->ops) + return -EINVAL; + trig_info->id = ida_simple_get(&iio_trigger_ida, 0, 0, GFP_KERNEL); if (trig_info->id < 0) return trig_info->id; @@ -164,8 +168,7 @@ 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 && - trig->ops->try_reenable) + if (atomic_dec_and_test(&trig->use_count) && trig->ops->try_reenable) if (trig->ops->try_reenable(trig)) /* Missed an interrupt so launch new poll now */ iio_trigger_poll(trig); @@ -219,7 +222,7 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig, return ret; } - if (trig->ops && trig->ops->set_trigger_state && notinuse) { + if (trig->ops->set_trigger_state && notinuse) { ret = trig->ops->set_trigger_state(trig, true); if (ret < 0) module_put(pf->indio_dev->info->driver_module); @@ -236,7 +239,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 && trig->ops->set_trigger_state && no_other_users) { + if (trig->ops->set_trigger_state && no_other_users) { ret = trig->ops->set_trigger_state(trig, false); if (ret) return ret; @@ -358,7 +361,7 @@ static ssize_t iio_trigger_write_current(struct device *dev, return ret; } - if (trig && trig->ops && trig->ops->validate_device) { + if (trig && trig->ops->validate_device) { ret = trig->ops->validate_device(trig, indio_dev); if (ret) return ret; -- cgit v1.1 From e039e2f5b4dab9a90bb5441a154c01a051b1abfa Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Tue, 19 Apr 2016 11:18:32 +0200 Subject: iio:st_pressure:initial lps22hb sensor support Initial support for ST LPS22HB pressure sensor. Datasheet: http://www2.st.com/resource/en/datasheet/lps22hb.pdf Features: * pressure data and timestamping channels * sampling frequency selection * interrupt based trigger * over I2C or SPI Signed-off-by: Gregor Boirie Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/st-sensors.txt | 1 + drivers/iio/pressure/Kconfig | 2 +- drivers/iio/pressure/st_pressure.h | 1 + drivers/iio/pressure/st_pressure_core.c | 93 +++++++++++++++++++++- drivers/iio/pressure/st_pressure_i2c.c | 4 + drivers/iio/pressure/st_pressure_spi.c | 1 + 6 files changed, 97 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt index 5844cf7..e41fe34 100644 --- a/Documentation/devicetree/bindings/iio/st-sensors.txt +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt @@ -64,3 +64,4 @@ Pressure sensors: - st,lps001wp-press - st,lps25h-press - st,lps331ap-press +- st,lps22hb-press diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index 9125a93..8d654f6 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -131,7 +131,7 @@ config IIO_ST_PRESS select IIO_TRIGGERED_BUFFER if (IIO_BUFFER) help Say yes here to build support for STMicroelectronics pressure - sensors: LPS001WP, LPS25H, LPS331AP. + sensors: LPS001WP, LPS25H, LPS331AP, LPS22HB. This driver can also be built as a module. If so, these modules will be created: diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h index f5f4149..903a21e 100644 --- a/drivers/iio/pressure/st_pressure.h +++ b/drivers/iio/pressure/st_pressure.h @@ -17,6 +17,7 @@ #define LPS001WP_PRESS_DEV_NAME "lps001wp" #define LPS25H_PRESS_DEV_NAME "lps25h" #define LPS331AP_PRESS_DEV_NAME "lps331ap" +#define LPS22HB_PRESS_DEV_NAME "lps22hb" /** * 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 9e9b72a..c0ff3bf 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -113,6 +113,26 @@ #define ST_PRESS_LPS25H_OUT_XL_ADDR 0x28 #define ST_TEMP_LPS25H_OUT_L_ADDR 0x2b +/* CUSTOM VALUES FOR LPS22HB SENSOR */ +#define ST_PRESS_LPS22HB_WAI_EXP 0xb1 +#define ST_PRESS_LPS22HB_ODR_ADDR 0x10 +#define ST_PRESS_LPS22HB_ODR_MASK 0x70 +#define ST_PRESS_LPS22HB_ODR_AVL_1HZ_VAL 0x01 +#define ST_PRESS_LPS22HB_ODR_AVL_10HZ_VAL 0x02 +#define ST_PRESS_LPS22HB_ODR_AVL_25HZ_VAL 0x03 +#define ST_PRESS_LPS22HB_ODR_AVL_50HZ_VAL 0x04 +#define ST_PRESS_LPS22HB_ODR_AVL_75HZ_VAL 0x05 +#define ST_PRESS_LPS22HB_PW_ADDR 0x10 +#define ST_PRESS_LPS22HB_PW_MASK 0x70 +#define ST_PRESS_LPS22HB_BDU_ADDR 0x10 +#define ST_PRESS_LPS22HB_BDU_MASK 0x02 +#define ST_PRESS_LPS22HB_DRDY_IRQ_ADDR 0x12 +#define ST_PRESS_LPS22HB_DRDY_IRQ_INT1_MASK 0x04 +#define ST_PRESS_LPS22HB_DRDY_IRQ_INT2_MASK 0x08 +#define ST_PRESS_LPS22HB_IHL_IRQ_ADDR 0x12 +#define ST_PRESS_LPS22HB_IHL_IRQ_MASK 0x80 +#define ST_PRESS_LPS22HB_MULTIREAD_BIT true + static const struct iio_chan_spec st_press_1_channels[] = { { .type = IIO_PRESSURE, @@ -183,6 +203,27 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(1) }; +static const struct iio_chan_spec st_press_lps22hb_channels[] = { + { + .type = IIO_PRESSURE, + .channel2 = IIO_NO_MOD, + .address = ST_PRESS_1_OUT_XL_ADDR, + .scan_index = 0, + .scan_type = { + .sign = 'u', + .realbits = 24, + .storagebits = 24, + .endianness = IIO_LE, + }, + .info_mask_separate = + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), + .modified = 0, + }, + IIO_CHAN_SOFT_TIMESTAMP(1) +}; + static const struct st_sensor_settings st_press_sensors_settings[] = { { .wai = ST_PRESS_LPS331AP_WAI_EXP, @@ -326,6 +367,51 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { .multi_read_bit = ST_PRESS_LPS25H_MULTIREAD_BIT, .bootime = 2, }, + { + .wai = ST_PRESS_LPS22HB_WAI_EXP, + .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, + .sensors_supported = { + [0] = LPS22HB_PRESS_DEV_NAME, + }, + .ch = (struct iio_chan_spec *)st_press_lps22hb_channels, + .num_ch = ARRAY_SIZE(st_press_lps22hb_channels), + .odr = { + .addr = ST_PRESS_LPS22HB_ODR_ADDR, + .mask = ST_PRESS_LPS22HB_ODR_MASK, + .odr_avl = { + { 1, ST_PRESS_LPS22HB_ODR_AVL_1HZ_VAL, }, + { 10, ST_PRESS_LPS22HB_ODR_AVL_10HZ_VAL, }, + { 25, ST_PRESS_LPS22HB_ODR_AVL_25HZ_VAL, }, + { 50, ST_PRESS_LPS22HB_ODR_AVL_50HZ_VAL, }, + { 75, ST_PRESS_LPS22HB_ODR_AVL_75HZ_VAL, }, + }, + }, + .pw = { + .addr = ST_PRESS_LPS22HB_PW_ADDR, + .mask = ST_PRESS_LPS22HB_PW_MASK, + .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, + }, + .fs = { + .fs_avl = { + [0] = { + .num = ST_PRESS_FS_AVL_1260MB, + .gain = ST_PRESS_KPASCAL_NANO_SCALE, + }, + }, + }, + .bdu = { + .addr = ST_PRESS_LPS22HB_BDU_ADDR, + .mask = ST_PRESS_LPS22HB_BDU_MASK, + }, + .drdy_irq = { + .addr = ST_PRESS_LPS22HB_DRDY_IRQ_ADDR, + .mask_int1 = ST_PRESS_LPS22HB_DRDY_IRQ_INT1_MASK, + .mask_int2 = ST_PRESS_LPS22HB_DRDY_IRQ_INT2_MASK, + .addr_ihl = ST_PRESS_LPS22HB_IHL_IRQ_ADDR, + .mask_ihl = ST_PRESS_LPS22HB_IHL_IRQ_MASK, + }, + .multi_read_bit = ST_PRESS_LPS22HB_MULTIREAD_BIT, + }, }; static int st_press_write_raw(struct iio_dev *indio_dev, @@ -454,10 +540,9 @@ int st_press_common_probe(struct iio_dev *indio_dev) indio_dev->channels = press_data->sensor_settings->ch; indio_dev->num_channels = press_data->sensor_settings->num_ch; - if (press_data->sensor_settings->fs.addr != 0) - press_data->current_fullscale = - (struct st_sensor_fullscale_avl *) - &press_data->sensor_settings->fs.fs_avl[0]; + press_data->current_fullscale = + (struct st_sensor_fullscale_avl *) + &press_data->sensor_settings->fs.fs_avl[0]; press_data->odr = press_data->sensor_settings->odr.odr_avl[0].hz; diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c index 8fcf976..ed18701 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c @@ -32,6 +32,10 @@ static const struct of_device_id st_press_of_match[] = { .compatible = "st,lps331ap-press", .data = LPS331AP_PRESS_DEV_NAME, }, + { + .compatible = "st,lps22hb-press", + .data = LPS22HB_PRESS_DEV_NAME, + }, {}, }; MODULE_DEVICE_TABLE(of, st_press_of_match); diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c index 40c0692..5505080 100644 --- a/drivers/iio/pressure/st_pressure_spi.c +++ b/drivers/iio/pressure/st_pressure_spi.c @@ -50,6 +50,7 @@ static const struct spi_device_id st_press_id_table[] = { { LPS001WP_PRESS_DEV_NAME }, { LPS25H_PRESS_DEV_NAME }, { LPS331AP_PRESS_DEV_NAME }, + { LPS22HB_PRESS_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(spi, st_press_id_table); -- cgit v1.1 From dfe3ab1af0765eb800da5ce4cb4c685783096d9c Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Tue, 19 Apr 2016 11:18:38 +0200 Subject: iio:st_sensors: unexport st_sensors_get_buffer_element Remove st_sensors_get_buffer_element symbol export since not explicitly used outside of st_sensors driver. Signed-off-by: Gregor Boirie Signed-off-by: Jonathan Cameron --- drivers/iio/common/st_sensors/st_sensors_buffer.c | 3 +-- include/linux/iio/common/st_sensors.h | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c index c558985..4ccc438 100644 --- a/drivers/iio/common/st_sensors/st_sensors_buffer.c +++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c @@ -22,7 +22,7 @@ #include -int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf) +static int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf) { int i, len; int total = 0; @@ -49,7 +49,6 @@ int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf) return total; } -EXPORT_SYMBOL(st_sensors_get_buffer_element); irqreturn_t st_sensors_trigger_handler(int irq, void *p) { diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index d029ffa..78a1934 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -251,8 +251,6 @@ struct st_sensor_data { #ifdef CONFIG_IIO_BUFFER irqreturn_t st_sensors_trigger_handler(int irq, void *p); - -int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf); #endif #ifdef CONFIG_IIO_TRIGGER -- cgit v1.1 From 169a88c1ee19b0734c9703d51a6d8ebe538f5bc3 Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Tue, 19 Apr 2016 11:18:39 +0200 Subject: iio:st_sensors: emulate SMBus block read if needed Use SMBus "block read" protocol only when supported by adapter. Signed-off-by: Gregor Boirie Signed-off-by: Jonathan Cameron --- drivers/iio/common/st_sensors/st_sensors_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c index 98cfee29..b43aa36 100644 --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c @@ -48,8 +48,8 @@ static int st_sensors_i2c_read_multiple_byte( if (multiread_bit) reg_addr |= ST_SENSORS_I2C_MULTIREAD; - return i2c_smbus_read_i2c_block_data(to_i2c_client(dev), - reg_addr, len, data); + return i2c_smbus_read_i2c_block_data_or_emulated(to_i2c_client(dev), + reg_addr, len, data); } static int st_sensors_i2c_write_byte(struct st_sensor_transfer_buffer *tb, -- cgit v1.1 From 14f295c846063c4f1812b09427195cee522aa006 Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Tue, 19 Apr 2016 11:18:40 +0200 Subject: iio:st_sensors: fix power regulator usage Ensure failure to enable power regulators is properly handled. Signed-off-by: Gregor Boirie Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_core.c | 12 ++++++---- drivers/iio/common/st_sensors/st_sensors_core.c | 29 ++++++++++++++++++++----- drivers/iio/gyro/st_gyro_core.c | 12 ++++++---- drivers/iio/magnetometer/st_magn_core.c | 12 ++++++---- drivers/iio/pressure/st_pressure_core.c | 12 ++++++---- include/linux/iio/common/st_sensors.h | 2 +- 6 files changed, 57 insertions(+), 22 deletions(-) diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index dc73f2d..b8d3c3c 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -757,13 +757,15 @@ int st_accel_common_probe(struct iio_dev *indio_dev) indio_dev->info = &accel_info; mutex_init(&adata->tb.buf_lock); - st_sensors_power_enable(indio_dev); + err = st_sensors_power_enable(indio_dev); + if (err) + return err; err = st_sensors_check_device_support(indio_dev, ARRAY_SIZE(st_accel_sensors_settings), st_accel_sensors_settings); if (err < 0) - return err; + goto st_accel_power_off; adata->num_data_channels = ST_ACCEL_NUMBER_DATA_CHANNELS; adata->multiread_bit = adata->sensor_settings->multi_read_bit; @@ -780,11 +782,11 @@ int st_accel_common_probe(struct iio_dev *indio_dev) err = st_sensors_init_sensor(indio_dev, adata->dev->platform_data); if (err < 0) - return err; + goto st_accel_power_off; err = st_accel_allocate_ring(indio_dev); if (err < 0) - return err; + goto st_accel_power_off; if (irq > 0) { err = st_sensors_allocate_trigger(indio_dev, @@ -807,6 +809,8 @@ st_accel_device_register_error: st_sensors_deallocate_trigger(indio_dev); st_accel_probe_trigger_error: st_accel_deallocate_ring(indio_dev); +st_accel_power_off: + st_sensors_power_disable(indio_dev); return err; } diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index dffe006..00078b5 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -228,7 +228,7 @@ int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable) } EXPORT_SYMBOL(st_sensors_set_axis_enable); -void st_sensors_power_enable(struct iio_dev *indio_dev) +int st_sensors_power_enable(struct iio_dev *indio_dev) { struct st_sensor_data *pdata = iio_priv(indio_dev); int err; @@ -237,18 +237,37 @@ void st_sensors_power_enable(struct iio_dev *indio_dev) pdata->vdd = devm_regulator_get_optional(indio_dev->dev.parent, "vdd"); if (!IS_ERR(pdata->vdd)) { err = regulator_enable(pdata->vdd); - if (err != 0) + if (err != 0) { dev_warn(&indio_dev->dev, "Failed to enable specified Vdd supply\n"); + return err; + } + } else { + err = PTR_ERR(pdata->vdd); + if (err != -ENODEV) + return err; } pdata->vdd_io = devm_regulator_get_optional(indio_dev->dev.parent, "vddio"); if (!IS_ERR(pdata->vdd_io)) { err = regulator_enable(pdata->vdd_io); - if (err != 0) + if (err != 0) { dev_warn(&indio_dev->dev, "Failed to enable specified Vdd_IO supply\n"); + goto st_sensors_disable_vdd; + } + } else { + err = PTR_ERR(pdata->vdd_io); + if (err != -ENODEV) + goto st_sensors_disable_vdd; } + + return 0; + +st_sensors_disable_vdd: + if (!IS_ERR_OR_NULL(pdata->vdd)) + regulator_disable(pdata->vdd); + return err; } EXPORT_SYMBOL(st_sensors_power_enable); @@ -256,10 +275,10 @@ void st_sensors_power_disable(struct iio_dev *indio_dev) { struct st_sensor_data *pdata = iio_priv(indio_dev); - if (!IS_ERR(pdata->vdd)) + if (!IS_ERR_OR_NULL(pdata->vdd)) regulator_disable(pdata->vdd); - if (!IS_ERR(pdata->vdd_io)) + if (!IS_ERR_OR_NULL(pdata->vdd_io)) regulator_disable(pdata->vdd_io); } EXPORT_SYMBOL(st_sensors_power_disable); diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index 52a3c87..ae1377d 100644 --- a/drivers/iio/gyro/st_gyro_core.c +++ b/drivers/iio/gyro/st_gyro_core.c @@ -425,13 +425,15 @@ int st_gyro_common_probe(struct iio_dev *indio_dev) indio_dev->info = &gyro_info; mutex_init(&gdata->tb.buf_lock); - st_sensors_power_enable(indio_dev); + err = st_sensors_power_enable(indio_dev); + if (err) + return err; err = st_sensors_check_device_support(indio_dev, ARRAY_SIZE(st_gyro_sensors_settings), st_gyro_sensors_settings); if (err < 0) - return err; + goto st_gyro_power_off; gdata->num_data_channels = ST_GYRO_NUMBER_DATA_CHANNELS; gdata->multiread_bit = gdata->sensor_settings->multi_read_bit; @@ -445,11 +447,11 @@ int st_gyro_common_probe(struct iio_dev *indio_dev) err = st_sensors_init_sensor(indio_dev, (struct st_sensors_platform_data *)&gyro_pdata); if (err < 0) - return err; + goto st_gyro_power_off; err = st_gyro_allocate_ring(indio_dev); if (err < 0) - return err; + goto st_gyro_power_off; if (irq > 0) { err = st_sensors_allocate_trigger(indio_dev, @@ -472,6 +474,8 @@ st_gyro_device_register_error: st_sensors_deallocate_trigger(indio_dev); st_gyro_probe_trigger_error: st_gyro_deallocate_ring(indio_dev); +st_gyro_power_off: + st_sensors_power_disable(indio_dev); return err; } diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 62036d2..7c94adc 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -588,13 +588,15 @@ int st_magn_common_probe(struct iio_dev *indio_dev) indio_dev->info = &magn_info; mutex_init(&mdata->tb.buf_lock); - st_sensors_power_enable(indio_dev); + err = st_sensors_power_enable(indio_dev); + if (err) + return err; err = st_sensors_check_device_support(indio_dev, ARRAY_SIZE(st_magn_sensors_settings), st_magn_sensors_settings); if (err < 0) - return err; + goto st_magn_power_off; mdata->num_data_channels = ST_MAGN_NUMBER_DATA_CHANNELS; mdata->multiread_bit = mdata->sensor_settings->multi_read_bit; @@ -607,11 +609,11 @@ int st_magn_common_probe(struct iio_dev *indio_dev) err = st_sensors_init_sensor(indio_dev, NULL); if (err < 0) - return err; + goto st_magn_power_off; err = st_magn_allocate_ring(indio_dev); if (err < 0) - return err; + goto st_magn_power_off; if (irq > 0) { err = st_sensors_allocate_trigger(indio_dev, @@ -634,6 +636,8 @@ st_magn_device_register_error: st_sensors_deallocate_trigger(indio_dev); st_magn_probe_trigger_error: st_magn_deallocate_ring(indio_dev); +st_magn_power_off: + st_sensors_power_disable(indio_dev); return err; } diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index c0ff3bf..4d317af 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -527,13 +527,15 @@ int st_press_common_probe(struct iio_dev *indio_dev) indio_dev->info = &press_info; mutex_init(&press_data->tb.buf_lock); - st_sensors_power_enable(indio_dev); + err = st_sensors_power_enable(indio_dev); + if (err) + return err; err = st_sensors_check_device_support(indio_dev, ARRAY_SIZE(st_press_sensors_settings), st_press_sensors_settings); if (err < 0) - return err; + goto st_press_power_off; press_data->num_data_channels = ST_PRESS_NUMBER_DATA_CHANNELS; press_data->multiread_bit = press_data->sensor_settings->multi_read_bit; @@ -554,11 +556,11 @@ int st_press_common_probe(struct iio_dev *indio_dev) err = st_sensors_init_sensor(indio_dev, press_data->dev->platform_data); if (err < 0) - return err; + goto st_press_power_off; err = st_press_allocate_ring(indio_dev); if (err < 0) - return err; + goto st_press_power_off; if (irq > 0) { err = st_sensors_allocate_trigger(indio_dev, @@ -581,6 +583,8 @@ st_press_device_register_error: st_sensors_deallocate_trigger(indio_dev); st_press_probe_trigger_error: st_press_deallocate_ring(indio_dev); +st_press_power_off: + st_sensors_power_disable(indio_dev); return err; } diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index 78a1934..91d5f68 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -278,7 +278,7 @@ int st_sensors_set_enable(struct iio_dev *indio_dev, bool enable); int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable); -void st_sensors_power_enable(struct iio_dev *indio_dev); +int st_sensors_power_enable(struct iio_dev *indio_dev); void st_sensors_power_disable(struct iio_dev *indio_dev); -- cgit v1.1 From c70df20e31595cf696c8b4f50fc7d82b69f3dd5c Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Tue, 24 May 2016 12:16:23 -0700 Subject: iio: adc: ad7266: claim direct mode during sensor read Driver was checking for direct mode but not locking it down. Use iio_device_claim_direct_mode() to guarantee device stays in direct mode. Signed-off-by: Alison Schofield Acked-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7266.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c index 21e19b6..01240ae 100644 --- a/drivers/iio/adc/ad7266.c +++ b/drivers/iio/adc/ad7266.c @@ -154,12 +154,11 @@ static int ad7266_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_RAW: - if (iio_buffer_enabled(indio_dev)) - return -EBUSY; - - ret = ad7266_read_single(st, val, chan->address); + ret = iio_device_claim_direct_mode(indio_dev); if (ret) return ret; + ret = ad7266_read_single(st, val, chan->address); + iio_device_release_direct_mode(indio_dev); *val = (*val >> 2) & 0xfff; if (chan->scan_type.sign == 's') -- cgit v1.1 From a52f238e7c808d9fd1f9dfc675f583b77156cdeb Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Tue, 24 May 2016 12:18:06 -0700 Subject: iio: adc: ad7476: use iio helper function to guarantee direct mode Replace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same. Signed-off-by: Alison Schofield Acked-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7476.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c index be85c2a..810c9a9 100644 --- a/drivers/iio/adc/ad7476.c +++ b/drivers/iio/adc/ad7476.c @@ -106,12 +106,11 @@ static int ad7476_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_RAW: - mutex_lock(&indio_dev->mlock); - if (iio_buffer_enabled(indio_dev)) - ret = -EBUSY; - else - ret = ad7476_scan_direct(st); - mutex_unlock(&indio_dev->mlock); + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + ret = ad7476_scan_direct(st); + iio_device_release_direct_mode(indio_dev); if (ret < 0) return ret; -- cgit v1.1 From 6fea8a426b67455a58b59964cee905754ab77497 Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Tue, 24 May 2016 12:18:43 -0700 Subject: iio: adc: ad7887: use iio helper function to guarantee direct mode Replace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same. Signed-off-by: Alison Schofield Acked-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7887.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c index 2d3c397..ee2ccc1 100644 --- a/drivers/iio/adc/ad7887.c +++ b/drivers/iio/adc/ad7887.c @@ -156,12 +156,11 @@ static int ad7887_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_RAW: - mutex_lock(&indio_dev->mlock); - if (iio_buffer_enabled(indio_dev)) - ret = -EBUSY; - else - ret = ad7887_scan_direct(st, chan->address); - mutex_unlock(&indio_dev->mlock); + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + ret = ad7887_scan_direct(st, chan->address); + iio_device_release_direct_mode(indio_dev); if (ret < 0) return ret; -- cgit v1.1 From 9f57e068e01c14f34f69244e1f4a6c567d93cdfe Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Tue, 24 May 2016 12:19:49 -0700 Subject: iio: adc: ad7923: use iio helper function to guarantee direct mode Replace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same. Signed-off-by: Alison Schofield Acked-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7923.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index 45e29cc..ff444c1 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -233,12 +233,11 @@ static int ad7923_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_RAW: - mutex_lock(&indio_dev->mlock); - if (iio_buffer_enabled(indio_dev)) - ret = -EBUSY; - else - ret = ad7923_scan_direct(st, chan->address); - mutex_unlock(&indio_dev->mlock); + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + ret = ad7923_scan_direct(st, chan->address); + iio_device_release_direct_mode(indio_dev); if (ret < 0) return ret; -- cgit v1.1 From 1bb86ecb6c03e156cdbd89978320c839e9f954b4 Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Tue, 24 May 2016 12:20:24 -0700 Subject: iio: adc: ad799x: use iio helper function to guarantee direct mode Replace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same. Signed-off-by: Alison Schofield Acked-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad799x.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index a3f5254..ec0200d 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -282,12 +282,11 @@ static int ad799x_read_raw(struct iio_dev *indio_dev, switch (m) { case IIO_CHAN_INFO_RAW: - mutex_lock(&indio_dev->mlock); - if (iio_buffer_enabled(indio_dev)) - ret = -EBUSY; - else - ret = ad799x_scan_direct(st, chan->scan_index); - mutex_unlock(&indio_dev->mlock); + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + ret = ad799x_scan_direct(st, chan->scan_index); + iio_device_release_direct_mode(indio_dev); if (ret < 0) return ret; @@ -395,11 +394,9 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev, struct ad799x_state *st = iio_priv(indio_dev); int ret; - mutex_lock(&indio_dev->mlock); - if (iio_buffer_enabled(indio_dev)) { - ret = -EBUSY; - goto done; - } + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; if (state) st->config |= BIT(chan->scan_index) << AD799X_CHANNEL_SHIFT; @@ -412,10 +409,7 @@ static int ad799x_write_event_config(struct iio_dev *indio_dev, st->config &= ~AD7998_ALERT_EN; ret = ad799x_write_config(st, st->config); - -done: - mutex_unlock(&indio_dev->mlock); - + iio_device_release_direct_mode(indio_dev); return ret; } -- cgit v1.1 From 0c4b650029ec6d8b13b527c5b775549c2a06c898 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Wed, 25 May 2016 14:31:13 +0100 Subject: tools: iio: Add ability to install/uninstall Add options to the Makefile for install/uninstall similar to other tools. Signed-off-by: Peter Robinson Signed-off-by: Jonathan Cameron --- tools/iio/Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/iio/Makefile b/tools/iio/Makefile index 3a7a54f..5c32e90 100644 --- a/tools/iio/Makefile +++ b/tools/iio/Makefile @@ -1,6 +1,10 @@ CC = $(CROSS_COMPILE)gcc CFLAGS += -Wall -g -D_GNU_SOURCE +BINDIR=usr/bin +INSTALL_PROGRAM=install -m 755 -p +DEL_FILE=rm -f + all: iio_event_monitor lsiio generic_buffer iio_event_monitor: iio_event_monitor.o iio_utils.o @@ -11,6 +15,17 @@ generic_buffer: generic_buffer.o iio_utils.o %.o: %.c iio_utils.h +install: + - mkdir -p $(INSTALL_ROOT)/$(BINDIR) + - $(INSTALL_PROGRAM) "iio_event_monitor" "$(INSTALL_ROOT)/$(BINDIR)/iio_event_monitor" + - $(INSTALL_PROGRAM) "lsiio" "$(INSTALL_ROOT)/$(BINDIR)/lsiio" + - $(INSTALL_PROGRAM) "generic_buffer" "$(INSTALL_ROOT)/$(BINDIR)/generic_buffer" + +uninstall: + $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/iio_event_monitor" + $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/lsiio" + $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/generic_buffer" + .PHONY: clean clean: rm -f *.o iio_event_monitor lsiio generic_buffer -- cgit v1.1 From 5d48d6b0203de854587e8338376661e2315b2571 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Tue, 24 May 2016 18:03:55 +0300 Subject: tools: iio: Rename generic_buffer to iio_generic_buffer This makes it clear that generic_buffer is an IIO tool and also complies with filename conventions in tools/iio. Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- tools/iio/Makefile | 10 +- tools/iio/generic_buffer.c | 581 ----------------------------------------- tools/iio/iio_generic_buffer.c | 581 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 586 insertions(+), 586 deletions(-) delete mode 100644 tools/iio/generic_buffer.c create mode 100644 tools/iio/iio_generic_buffer.c diff --git a/tools/iio/Makefile b/tools/iio/Makefile index 5c32e90..5446d62 100644 --- a/tools/iio/Makefile +++ b/tools/iio/Makefile @@ -5,13 +5,13 @@ BINDIR=usr/bin INSTALL_PROGRAM=install -m 755 -p DEL_FILE=rm -f -all: iio_event_monitor lsiio generic_buffer +all: iio_event_monitor lsiio iio_generic_buffer iio_event_monitor: iio_event_monitor.o iio_utils.o lsiio: lsiio.o iio_utils.o -generic_buffer: generic_buffer.o iio_utils.o +iio_generic_buffer: iio_generic_buffer.o iio_utils.o %.o: %.c iio_utils.h @@ -19,13 +19,13 @@ install: - mkdir -p $(INSTALL_ROOT)/$(BINDIR) - $(INSTALL_PROGRAM) "iio_event_monitor" "$(INSTALL_ROOT)/$(BINDIR)/iio_event_monitor" - $(INSTALL_PROGRAM) "lsiio" "$(INSTALL_ROOT)/$(BINDIR)/lsiio" - - $(INSTALL_PROGRAM) "generic_buffer" "$(INSTALL_ROOT)/$(BINDIR)/generic_buffer" + - $(INSTALL_PROGRAM) "iio_generic_buffer" "$(INSTALL_ROOT)/$(BINDIR)/iio_generic_buffer" uninstall: $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/iio_event_monitor" $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/lsiio" - $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/generic_buffer" + $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/iio_generic_buffer" .PHONY: clean clean: - rm -f *.o iio_event_monitor lsiio generic_buffer + rm -f *.o iio_event_monitor lsiio iio_generic_buffer diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c deleted file mode 100644 index 2429c78..0000000 --- a/tools/iio/generic_buffer.c +++ /dev/null @@ -1,581 +0,0 @@ -/* Industrialio buffer test code. - * - * Copyright (c) 2008 Jonathan Cameron - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is primarily intended as an example application. - * Reads the current buffer setup from sysfs and starts a short capture - * from the specified device, pretty printing the result after appropriate - * conversion. - * - * Command line parameters - * generic_buffer -n -t - * If trigger name is not specified the program assumes you want a dataready - * trigger associated with the device and goes looking for it. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "iio_utils.h" - -/** - * enum autochan - state for the automatic channel enabling mechanism - */ -enum autochan { - AUTOCHANNELS_DISABLED, - AUTOCHANNELS_ENABLED, - AUTOCHANNELS_ACTIVE, -}; - -/** - * size_from_channelarray() - calculate the storage size of a scan - * @channels: the channel info array - * @num_channels: number of channels - * - * Has the side effect of filling the channels[i].location values used - * in processing the buffer output. - **/ -int size_from_channelarray(struct iio_channel_info *channels, int num_channels) -{ - int bytes = 0; - int i = 0; - - while (i < num_channels) { - if (bytes % channels[i].bytes == 0) - channels[i].location = bytes; - else - channels[i].location = bytes - bytes % channels[i].bytes - + channels[i].bytes; - - bytes = channels[i].location + channels[i].bytes; - i++; - } - - return bytes; -} - -void print1byte(uint8_t input, struct iio_channel_info *info) -{ - /* - * Shift before conversion to avoid sign extension - * of left aligned data - */ - input >>= info->shift; - input &= info->mask; - if (info->is_signed) { - int8_t val = (int8_t)(input << (8 - info->bits_used)) >> - (8 - info->bits_used); - printf("%05f ", ((float)val + info->offset) * info->scale); - } else { - printf("%05f ", ((float)input + info->offset) * info->scale); - } -} - -void print2byte(uint16_t input, struct iio_channel_info *info) -{ - /* First swap if incorrect endian */ - if (info->be) - input = be16toh(input); - else - input = le16toh(input); - - /* - * Shift before conversion to avoid sign extension - * of left aligned data - */ - input >>= info->shift; - input &= info->mask; - if (info->is_signed) { - int16_t val = (int16_t)(input << (16 - info->bits_used)) >> - (16 - info->bits_used); - printf("%05f ", ((float)val + info->offset) * info->scale); - } else { - printf("%05f ", ((float)input + info->offset) * info->scale); - } -} - -void print4byte(uint32_t input, struct iio_channel_info *info) -{ - /* First swap if incorrect endian */ - if (info->be) - input = be32toh(input); - else - input = le32toh(input); - - /* - * Shift before conversion to avoid sign extension - * of left aligned data - */ - input >>= info->shift; - input &= info->mask; - if (info->is_signed) { - int32_t val = (int32_t)(input << (32 - info->bits_used)) >> - (32 - info->bits_used); - printf("%05f ", ((float)val + info->offset) * info->scale); - } else { - printf("%05f ", ((float)input + info->offset) * info->scale); - } -} - -void print8byte(uint64_t input, struct iio_channel_info *info) -{ - /* First swap if incorrect endian */ - if (info->be) - input = be64toh(input); - else - input = le64toh(input); - - /* - * Shift before conversion to avoid sign extension - * of left aligned data - */ - input >>= info->shift; - input &= info->mask; - if (info->is_signed) { - int64_t val = (int64_t)(input << (64 - info->bits_used)) >> - (64 - info->bits_used); - /* special case for timestamp */ - if (info->scale == 1.0f && info->offset == 0.0f) - printf("%" PRId64 " ", val); - else - printf("%05f ", - ((float)val + info->offset) * info->scale); - } else { - printf("%05f ", ((float)input + info->offset) * info->scale); - } -} - -/** - * process_scan() - print out the values in SI units - * @data: pointer to the start of the scan - * @channels: information about the channels. - * Note: size_from_channelarray must have been called first - * to fill the location offsets. - * @num_channels: number of channels - **/ -void process_scan(char *data, - struct iio_channel_info *channels, - int num_channels) -{ - int k; - - for (k = 0; k < num_channels; k++) - switch (channels[k].bytes) { - /* only a few cases implemented so far */ - case 1: - print1byte(*(uint8_t *)(data + channels[k].location), - &channels[k]); - break; - case 2: - print2byte(*(uint16_t *)(data + channels[k].location), - &channels[k]); - break; - case 4: - print4byte(*(uint32_t *)(data + channels[k].location), - &channels[k]); - break; - case 8: - print8byte(*(uint64_t *)(data + channels[k].location), - &channels[k]); - break; - default: - break; - } - printf("\n"); -} - -static int enable_disable_all_channels(char *dev_dir_name, int enable) -{ - const struct dirent *ent; - char scanelemdir[256]; - DIR *dp; - int ret; - - snprintf(scanelemdir, sizeof(scanelemdir), - FORMAT_SCAN_ELEMENTS_DIR, dev_dir_name); - scanelemdir[sizeof(scanelemdir)-1] = '\0'; - - dp = opendir(scanelemdir); - if (!dp) { - fprintf(stderr, "Enabling/disabling channels: can't open %s\n", - scanelemdir); - return -EIO; - } - - ret = -ENOENT; - while (ent = readdir(dp), ent) { - if (iioutils_check_suffix(ent->d_name, "_en")) { - printf("%sabling: %s\n", - enable ? "En" : "Dis", - ent->d_name); - ret = write_sysfs_int(ent->d_name, scanelemdir, - enable); - if (ret < 0) - fprintf(stderr, "Failed to enable/disable %s\n", - ent->d_name); - } - } - - if (closedir(dp) == -1) { - perror("Enabling/disabling channels: " - "Failed to close directory"); - return -errno; - } - return 0; -} - -void print_usage(void) -{ - fprintf(stderr, "Usage: generic_buffer [options]...\n" - "Capture, convert and output data from IIO device buffer\n" - " -a Auto-activate all available channels\n" - " -c Do n conversions\n" - " -e Disable wait for event (new data)\n" - " -g Use trigger-less mode\n" - " -l Set buffer length to n samples\n" - " -n Set device name (mandatory)\n" - " -t Set trigger name\n" - " -w Set delay between reads in us (event-less mode)\n"); -} - -int main(int argc, char **argv) -{ - unsigned long num_loops = 2; - unsigned long timedelay = 1000000; - unsigned long buf_len = 128; - - int ret, c, i, j, toread; - int fp; - - int num_channels; - char *trigger_name = NULL, *device_name = NULL; - char *dev_dir_name, *buf_dir_name; - - int datardytrigger = 1; - char *data; - ssize_t read_size; - int dev_num, trig_num; - char *buffer_access; - int scan_size; - int noevents = 0; - int notrigger = 0; - enum autochan autochannels = AUTOCHANNELS_DISABLED; - char *dummy; - - struct iio_channel_info *channels; - - while ((c = getopt(argc, argv, "ac:egl:n:t:w:")) != -1) { - switch (c) { - case 'a': - autochannels = AUTOCHANNELS_ENABLED; - break; - case 'c': - errno = 0; - num_loops = strtoul(optarg, &dummy, 10); - if (errno) - return -errno; - - break; - case 'e': - noevents = 1; - break; - case 'g': - notrigger = 1; - break; - case 'l': - errno = 0; - buf_len = strtoul(optarg, &dummy, 10); - if (errno) - return -errno; - - break; - case 'n': - device_name = optarg; - break; - case 't': - trigger_name = optarg; - datardytrigger = 0; - break; - case 'w': - errno = 0; - timedelay = strtoul(optarg, &dummy, 10); - if (errno) - return -errno; - break; - case '?': - print_usage(); - return -1; - } - } - - if (!device_name) { - fprintf(stderr, "Device name not set\n"); - print_usage(); - return -1; - } - - /* Find the device requested */ - dev_num = find_type_by_name(device_name, "iio:device"); - if (dev_num < 0) { - fprintf(stderr, "Failed to find the %s\n", device_name); - return dev_num; - } - - printf("iio device number being used is %d\n", dev_num); - - ret = asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num); - if (ret < 0) - return -ENOMEM; - - if (!notrigger) { - if (!trigger_name) { - /* - * Build the trigger name. If it is device associated - * its name is _dev[n] where n matches - * the device number found above. - */ - ret = asprintf(&trigger_name, - "%s-dev%d", device_name, dev_num); - if (ret < 0) { - ret = -ENOMEM; - goto error_free_dev_dir_name; - } - } - - /* Look for this "-devN" trigger */ - trig_num = find_type_by_name(trigger_name, "trigger"); - if (trig_num < 0) { - /* OK try the simpler "-trigger" suffix instead */ - free(trigger_name); - ret = asprintf(&trigger_name, - "%s-trigger", device_name); - if (ret < 0) { - ret = -ENOMEM; - goto error_free_dev_dir_name; - } - } - - trig_num = find_type_by_name(trigger_name, "trigger"); - if (trig_num < 0) { - fprintf(stderr, "Failed to find the trigger %s\n", - trigger_name); - ret = trig_num; - goto error_free_triggername; - } - - printf("iio trigger number being used is %d\n", trig_num); - } else { - printf("trigger-less mode selected\n"); - } - - /* - * Parse the files in scan_elements to identify what channels are - * present - */ - ret = build_channel_array(dev_dir_name, &channels, &num_channels); - if (ret) { - fprintf(stderr, "Problem reading scan element information\n" - "diag %s\n", dev_dir_name); - goto error_free_triggername; - } - if (num_channels && autochannels == AUTOCHANNELS_ENABLED) { - fprintf(stderr, "Auto-channels selected but some channels " - "are already activated in sysfs\n"); - fprintf(stderr, "Proceeding without activating any channels\n"); - } - - if (!num_channels && autochannels == AUTOCHANNELS_ENABLED) { - fprintf(stderr, - "No channels are enabled, enabling all channels\n"); - - ret = enable_disable_all_channels(dev_dir_name, 1); - if (ret) { - fprintf(stderr, "Failed to enable all channels\n"); - goto error_free_triggername; - } - - /* This flags that we need to disable the channels again */ - autochannels = AUTOCHANNELS_ACTIVE; - - ret = build_channel_array(dev_dir_name, &channels, - &num_channels); - if (ret) { - fprintf(stderr, "Problem reading scan element " - "information\n" - "diag %s\n", dev_dir_name); - goto error_disable_channels; - } - if (!num_channels) { - fprintf(stderr, "Still no channels after " - "auto-enabling, giving up\n"); - goto error_disable_channels; - } - } - - if (!num_channels && autochannels == AUTOCHANNELS_DISABLED) { - fprintf(stderr, - "No channels are enabled, we have nothing to scan.\n"); - fprintf(stderr, "Enable channels manually in " - FORMAT_SCAN_ELEMENTS_DIR - "/*_en or pass -a to autoenable channels and " - "try again.\n", dev_dir_name); - ret = -ENOENT; - goto error_free_triggername; - } - - /* - * Construct the directory name for the associated buffer. - * As we know that the lis3l02dq has only one buffer this may - * be built rather than found. - */ - ret = asprintf(&buf_dir_name, - "%siio:device%d/buffer", iio_dir, dev_num); - if (ret < 0) { - ret = -ENOMEM; - goto error_free_channels; - } - - if (!notrigger) { - printf("%s %s\n", dev_dir_name, trigger_name); - /* - * Set the device trigger to be the data ready trigger found - * above - */ - ret = write_sysfs_string_and_verify("trigger/current_trigger", - dev_dir_name, - trigger_name); - if (ret < 0) { - fprintf(stderr, - "Failed to write current_trigger file\n"); - goto error_free_buf_dir_name; - } - } - - /* Setup ring buffer parameters */ - ret = write_sysfs_int("length", buf_dir_name, buf_len); - if (ret < 0) - goto error_free_buf_dir_name; - - /* Enable the buffer */ - ret = write_sysfs_int("enable", buf_dir_name, 1); - if (ret < 0) { - fprintf(stderr, - "Failed to enable buffer: %s\n", strerror(-ret)); - goto error_free_buf_dir_name; - } - - scan_size = size_from_channelarray(channels, num_channels); - data = malloc(scan_size * buf_len); - if (!data) { - ret = -ENOMEM; - goto error_free_buf_dir_name; - } - - ret = asprintf(&buffer_access, "/dev/iio:device%d", dev_num); - if (ret < 0) { - ret = -ENOMEM; - goto error_free_data; - } - - /* Attempt to open non blocking the access dev */ - fp = open(buffer_access, O_RDONLY | O_NONBLOCK); - if (fp == -1) { /* TODO: If it isn't there make the node */ - ret = -errno; - fprintf(stderr, "Failed to open %s\n", buffer_access); - goto error_free_buffer_access; - } - - for (j = 0; j < num_loops; j++) { - if (!noevents) { - struct pollfd pfd = { - .fd = fp, - .events = POLLIN, - }; - - ret = poll(&pfd, 1, -1); - if (ret < 0) { - ret = -errno; - goto error_close_buffer_access; - } else if (ret == 0) { - continue; - } - - toread = buf_len; - } else { - usleep(timedelay); - toread = 64; - } - - read_size = read(fp, data, toread * scan_size); - if (read_size < 0) { - if (errno == EAGAIN) { - fprintf(stderr, "nothing available\n"); - continue; - } else { - break; - } - } - for (i = 0; i < read_size / scan_size; i++) - process_scan(data + scan_size * i, channels, - num_channels); - } - - /* Stop the buffer */ - ret = write_sysfs_int("enable", buf_dir_name, 0); - if (ret < 0) - goto error_close_buffer_access; - - if (!notrigger) - /* Disconnect the trigger - just write a dummy name. */ - ret = write_sysfs_string("trigger/current_trigger", - dev_dir_name, "NULL"); - if (ret < 0) - fprintf(stderr, "Failed to write to %s\n", - dev_dir_name); - -error_close_buffer_access: - if (close(fp) == -1) - perror("Failed to close buffer"); - -error_free_buffer_access: - free(buffer_access); -error_free_data: - free(data); -error_free_buf_dir_name: - free(buf_dir_name); -error_free_channels: - for (i = num_channels - 1; i >= 0; i--) { - free(channels[i].name); - free(channels[i].generic_name); - } - free(channels); -error_free_triggername: - if (datardytrigger) - free(trigger_name); -error_disable_channels: - if (autochannels == AUTOCHANNELS_ACTIVE) { - ret = enable_disable_all_channels(dev_dir_name, 0); - if (ret) - fprintf(stderr, "Failed to disable all channels\n"); - } -error_free_dev_dir_name: - free(dev_dir_name); - - return ret; -} diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c new file mode 100644 index 0000000..2429c78 --- /dev/null +++ b/tools/iio/iio_generic_buffer.c @@ -0,0 +1,581 @@ +/* Industrialio buffer test code. + * + * Copyright (c) 2008 Jonathan Cameron + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * This program is primarily intended as an example application. + * Reads the current buffer setup from sysfs and starts a short capture + * from the specified device, pretty printing the result after appropriate + * conversion. + * + * Command line parameters + * generic_buffer -n -t + * If trigger name is not specified the program assumes you want a dataready + * trigger associated with the device and goes looking for it. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "iio_utils.h" + +/** + * enum autochan - state for the automatic channel enabling mechanism + */ +enum autochan { + AUTOCHANNELS_DISABLED, + AUTOCHANNELS_ENABLED, + AUTOCHANNELS_ACTIVE, +}; + +/** + * size_from_channelarray() - calculate the storage size of a scan + * @channels: the channel info array + * @num_channels: number of channels + * + * Has the side effect of filling the channels[i].location values used + * in processing the buffer output. + **/ +int size_from_channelarray(struct iio_channel_info *channels, int num_channels) +{ + int bytes = 0; + int i = 0; + + while (i < num_channels) { + if (bytes % channels[i].bytes == 0) + channels[i].location = bytes; + else + channels[i].location = bytes - bytes % channels[i].bytes + + channels[i].bytes; + + bytes = channels[i].location + channels[i].bytes; + i++; + } + + return bytes; +} + +void print1byte(uint8_t input, struct iio_channel_info *info) +{ + /* + * Shift before conversion to avoid sign extension + * of left aligned data + */ + input >>= info->shift; + input &= info->mask; + if (info->is_signed) { + int8_t val = (int8_t)(input << (8 - info->bits_used)) >> + (8 - info->bits_used); + printf("%05f ", ((float)val + info->offset) * info->scale); + } else { + printf("%05f ", ((float)input + info->offset) * info->scale); + } +} + +void print2byte(uint16_t input, struct iio_channel_info *info) +{ + /* First swap if incorrect endian */ + if (info->be) + input = be16toh(input); + else + input = le16toh(input); + + /* + * Shift before conversion to avoid sign extension + * of left aligned data + */ + input >>= info->shift; + input &= info->mask; + if (info->is_signed) { + int16_t val = (int16_t)(input << (16 - info->bits_used)) >> + (16 - info->bits_used); + printf("%05f ", ((float)val + info->offset) * info->scale); + } else { + printf("%05f ", ((float)input + info->offset) * info->scale); + } +} + +void print4byte(uint32_t input, struct iio_channel_info *info) +{ + /* First swap if incorrect endian */ + if (info->be) + input = be32toh(input); + else + input = le32toh(input); + + /* + * Shift before conversion to avoid sign extension + * of left aligned data + */ + input >>= info->shift; + input &= info->mask; + if (info->is_signed) { + int32_t val = (int32_t)(input << (32 - info->bits_used)) >> + (32 - info->bits_used); + printf("%05f ", ((float)val + info->offset) * info->scale); + } else { + printf("%05f ", ((float)input + info->offset) * info->scale); + } +} + +void print8byte(uint64_t input, struct iio_channel_info *info) +{ + /* First swap if incorrect endian */ + if (info->be) + input = be64toh(input); + else + input = le64toh(input); + + /* + * Shift before conversion to avoid sign extension + * of left aligned data + */ + input >>= info->shift; + input &= info->mask; + if (info->is_signed) { + int64_t val = (int64_t)(input << (64 - info->bits_used)) >> + (64 - info->bits_used); + /* special case for timestamp */ + if (info->scale == 1.0f && info->offset == 0.0f) + printf("%" PRId64 " ", val); + else + printf("%05f ", + ((float)val + info->offset) * info->scale); + } else { + printf("%05f ", ((float)input + info->offset) * info->scale); + } +} + +/** + * process_scan() - print out the values in SI units + * @data: pointer to the start of the scan + * @channels: information about the channels. + * Note: size_from_channelarray must have been called first + * to fill the location offsets. + * @num_channels: number of channels + **/ +void process_scan(char *data, + struct iio_channel_info *channels, + int num_channels) +{ + int k; + + for (k = 0; k < num_channels; k++) + switch (channels[k].bytes) { + /* only a few cases implemented so far */ + case 1: + print1byte(*(uint8_t *)(data + channels[k].location), + &channels[k]); + break; + case 2: + print2byte(*(uint16_t *)(data + channels[k].location), + &channels[k]); + break; + case 4: + print4byte(*(uint32_t *)(data + channels[k].location), + &channels[k]); + break; + case 8: + print8byte(*(uint64_t *)(data + channels[k].location), + &channels[k]); + break; + default: + break; + } + printf("\n"); +} + +static int enable_disable_all_channels(char *dev_dir_name, int enable) +{ + const struct dirent *ent; + char scanelemdir[256]; + DIR *dp; + int ret; + + snprintf(scanelemdir, sizeof(scanelemdir), + FORMAT_SCAN_ELEMENTS_DIR, dev_dir_name); + scanelemdir[sizeof(scanelemdir)-1] = '\0'; + + dp = opendir(scanelemdir); + if (!dp) { + fprintf(stderr, "Enabling/disabling channels: can't open %s\n", + scanelemdir); + return -EIO; + } + + ret = -ENOENT; + while (ent = readdir(dp), ent) { + if (iioutils_check_suffix(ent->d_name, "_en")) { + printf("%sabling: %s\n", + enable ? "En" : "Dis", + ent->d_name); + ret = write_sysfs_int(ent->d_name, scanelemdir, + enable); + if (ret < 0) + fprintf(stderr, "Failed to enable/disable %s\n", + ent->d_name); + } + } + + if (closedir(dp) == -1) { + perror("Enabling/disabling channels: " + "Failed to close directory"); + return -errno; + } + return 0; +} + +void print_usage(void) +{ + fprintf(stderr, "Usage: generic_buffer [options]...\n" + "Capture, convert and output data from IIO device buffer\n" + " -a Auto-activate all available channels\n" + " -c Do n conversions\n" + " -e Disable wait for event (new data)\n" + " -g Use trigger-less mode\n" + " -l Set buffer length to n samples\n" + " -n Set device name (mandatory)\n" + " -t Set trigger name\n" + " -w Set delay between reads in us (event-less mode)\n"); +} + +int main(int argc, char **argv) +{ + unsigned long num_loops = 2; + unsigned long timedelay = 1000000; + unsigned long buf_len = 128; + + int ret, c, i, j, toread; + int fp; + + int num_channels; + char *trigger_name = NULL, *device_name = NULL; + char *dev_dir_name, *buf_dir_name; + + int datardytrigger = 1; + char *data; + ssize_t read_size; + int dev_num, trig_num; + char *buffer_access; + int scan_size; + int noevents = 0; + int notrigger = 0; + enum autochan autochannels = AUTOCHANNELS_DISABLED; + char *dummy; + + struct iio_channel_info *channels; + + while ((c = getopt(argc, argv, "ac:egl:n:t:w:")) != -1) { + switch (c) { + case 'a': + autochannels = AUTOCHANNELS_ENABLED; + break; + case 'c': + errno = 0; + num_loops = strtoul(optarg, &dummy, 10); + if (errno) + return -errno; + + break; + case 'e': + noevents = 1; + break; + case 'g': + notrigger = 1; + break; + case 'l': + errno = 0; + buf_len = strtoul(optarg, &dummy, 10); + if (errno) + return -errno; + + break; + case 'n': + device_name = optarg; + break; + case 't': + trigger_name = optarg; + datardytrigger = 0; + break; + case 'w': + errno = 0; + timedelay = strtoul(optarg, &dummy, 10); + if (errno) + return -errno; + break; + case '?': + print_usage(); + return -1; + } + } + + if (!device_name) { + fprintf(stderr, "Device name not set\n"); + print_usage(); + return -1; + } + + /* Find the device requested */ + dev_num = find_type_by_name(device_name, "iio:device"); + if (dev_num < 0) { + fprintf(stderr, "Failed to find the %s\n", device_name); + return dev_num; + } + + printf("iio device number being used is %d\n", dev_num); + + ret = asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num); + if (ret < 0) + return -ENOMEM; + + if (!notrigger) { + if (!trigger_name) { + /* + * Build the trigger name. If it is device associated + * its name is _dev[n] where n matches + * the device number found above. + */ + ret = asprintf(&trigger_name, + "%s-dev%d", device_name, dev_num); + if (ret < 0) { + ret = -ENOMEM; + goto error_free_dev_dir_name; + } + } + + /* Look for this "-devN" trigger */ + trig_num = find_type_by_name(trigger_name, "trigger"); + if (trig_num < 0) { + /* OK try the simpler "-trigger" suffix instead */ + free(trigger_name); + ret = asprintf(&trigger_name, + "%s-trigger", device_name); + if (ret < 0) { + ret = -ENOMEM; + goto error_free_dev_dir_name; + } + } + + trig_num = find_type_by_name(trigger_name, "trigger"); + if (trig_num < 0) { + fprintf(stderr, "Failed to find the trigger %s\n", + trigger_name); + ret = trig_num; + goto error_free_triggername; + } + + printf("iio trigger number being used is %d\n", trig_num); + } else { + printf("trigger-less mode selected\n"); + } + + /* + * Parse the files in scan_elements to identify what channels are + * present + */ + ret = build_channel_array(dev_dir_name, &channels, &num_channels); + if (ret) { + fprintf(stderr, "Problem reading scan element information\n" + "diag %s\n", dev_dir_name); + goto error_free_triggername; + } + if (num_channels && autochannels == AUTOCHANNELS_ENABLED) { + fprintf(stderr, "Auto-channels selected but some channels " + "are already activated in sysfs\n"); + fprintf(stderr, "Proceeding without activating any channels\n"); + } + + if (!num_channels && autochannels == AUTOCHANNELS_ENABLED) { + fprintf(stderr, + "No channels are enabled, enabling all channels\n"); + + ret = enable_disable_all_channels(dev_dir_name, 1); + if (ret) { + fprintf(stderr, "Failed to enable all channels\n"); + goto error_free_triggername; + } + + /* This flags that we need to disable the channels again */ + autochannels = AUTOCHANNELS_ACTIVE; + + ret = build_channel_array(dev_dir_name, &channels, + &num_channels); + if (ret) { + fprintf(stderr, "Problem reading scan element " + "information\n" + "diag %s\n", dev_dir_name); + goto error_disable_channels; + } + if (!num_channels) { + fprintf(stderr, "Still no channels after " + "auto-enabling, giving up\n"); + goto error_disable_channels; + } + } + + if (!num_channels && autochannels == AUTOCHANNELS_DISABLED) { + fprintf(stderr, + "No channels are enabled, we have nothing to scan.\n"); + fprintf(stderr, "Enable channels manually in " + FORMAT_SCAN_ELEMENTS_DIR + "/*_en or pass -a to autoenable channels and " + "try again.\n", dev_dir_name); + ret = -ENOENT; + goto error_free_triggername; + } + + /* + * Construct the directory name for the associated buffer. + * As we know that the lis3l02dq has only one buffer this may + * be built rather than found. + */ + ret = asprintf(&buf_dir_name, + "%siio:device%d/buffer", iio_dir, dev_num); + if (ret < 0) { + ret = -ENOMEM; + goto error_free_channels; + } + + if (!notrigger) { + printf("%s %s\n", dev_dir_name, trigger_name); + /* + * Set the device trigger to be the data ready trigger found + * above + */ + ret = write_sysfs_string_and_verify("trigger/current_trigger", + dev_dir_name, + trigger_name); + if (ret < 0) { + fprintf(stderr, + "Failed to write current_trigger file\n"); + goto error_free_buf_dir_name; + } + } + + /* Setup ring buffer parameters */ + ret = write_sysfs_int("length", buf_dir_name, buf_len); + if (ret < 0) + goto error_free_buf_dir_name; + + /* Enable the buffer */ + ret = write_sysfs_int("enable", buf_dir_name, 1); + if (ret < 0) { + fprintf(stderr, + "Failed to enable buffer: %s\n", strerror(-ret)); + goto error_free_buf_dir_name; + } + + scan_size = size_from_channelarray(channels, num_channels); + data = malloc(scan_size * buf_len); + if (!data) { + ret = -ENOMEM; + goto error_free_buf_dir_name; + } + + ret = asprintf(&buffer_access, "/dev/iio:device%d", dev_num); + if (ret < 0) { + ret = -ENOMEM; + goto error_free_data; + } + + /* Attempt to open non blocking the access dev */ + fp = open(buffer_access, O_RDONLY | O_NONBLOCK); + if (fp == -1) { /* TODO: If it isn't there make the node */ + ret = -errno; + fprintf(stderr, "Failed to open %s\n", buffer_access); + goto error_free_buffer_access; + } + + for (j = 0; j < num_loops; j++) { + if (!noevents) { + struct pollfd pfd = { + .fd = fp, + .events = POLLIN, + }; + + ret = poll(&pfd, 1, -1); + if (ret < 0) { + ret = -errno; + goto error_close_buffer_access; + } else if (ret == 0) { + continue; + } + + toread = buf_len; + } else { + usleep(timedelay); + toread = 64; + } + + read_size = read(fp, data, toread * scan_size); + if (read_size < 0) { + if (errno == EAGAIN) { + fprintf(stderr, "nothing available\n"); + continue; + } else { + break; + } + } + for (i = 0; i < read_size / scan_size; i++) + process_scan(data + scan_size * i, channels, + num_channels); + } + + /* Stop the buffer */ + ret = write_sysfs_int("enable", buf_dir_name, 0); + if (ret < 0) + goto error_close_buffer_access; + + if (!notrigger) + /* Disconnect the trigger - just write a dummy name. */ + ret = write_sysfs_string("trigger/current_trigger", + dev_dir_name, "NULL"); + if (ret < 0) + fprintf(stderr, "Failed to write to %s\n", + dev_dir_name); + +error_close_buffer_access: + if (close(fp) == -1) + perror("Failed to close buffer"); + +error_free_buffer_access: + free(buffer_access); +error_free_data: + free(data); +error_free_buf_dir_name: + free(buf_dir_name); +error_free_channels: + for (i = num_channels - 1; i >= 0; i--) { + free(channels[i].name); + free(channels[i].generic_name); + } + free(channels); +error_free_triggername: + if (datardytrigger) + free(trigger_name); +error_disable_channels: + if (autochannels == AUTOCHANNELS_ACTIVE) { + ret = enable_disable_all_channels(dev_dir_name, 0); + if (ret) + fprintf(stderr, "Failed to disable all channels\n"); + } +error_free_dev_dir_name: + free(dev_dir_name); + + return ret; +} -- cgit v1.1 From 7103b99b031cb0ff6979331757bfc4893f37ae9e Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Tue, 24 May 2016 21:29:18 -0700 Subject: iio: chemical: atlas-ph-sensor: reorg driver to allow multiple chips Signed-off-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- drivers/iio/chemical/atlas-ph-sensor.c | 145 ++++++++++++++++++++------------- 1 file changed, 90 insertions(+), 55 deletions(-) diff --git a/drivers/iio/chemical/atlas-ph-sensor.c b/drivers/iio/chemical/atlas-ph-sensor.c index 62b37cd..e85477c 100644 --- a/drivers/iio/chemical/atlas-ph-sensor.c +++ b/drivers/iio/chemical/atlas-ph-sensor.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -43,20 +44,25 @@ #define ATLAS_REG_PWR_CONTROL 0x06 -#define ATLAS_REG_CALIB_STATUS 0x0d -#define ATLAS_REG_CALIB_STATUS_MASK 0x07 -#define ATLAS_REG_CALIB_STATUS_LOW BIT(0) -#define ATLAS_REG_CALIB_STATUS_MID BIT(1) -#define ATLAS_REG_CALIB_STATUS_HIGH BIT(2) +#define ATLAS_REG_PH_CALIB_STATUS 0x0d +#define ATLAS_REG_PH_CALIB_STATUS_MASK 0x07 +#define ATLAS_REG_PH_CALIB_STATUS_LOW BIT(0) +#define ATLAS_REG_PH_CALIB_STATUS_MID BIT(1) +#define ATLAS_REG_PH_CALIB_STATUS_HIGH BIT(2) -#define ATLAS_REG_TEMP_DATA 0x0e +#define ATLAS_REG_PH_TEMP_DATA 0x0e #define ATLAS_REG_PH_DATA 0x16 #define ATLAS_PH_INT_TIME_IN_US 450000 +enum { + ATLAS_PH_SM, +}; + struct atlas_data { struct i2c_client *client; struct iio_trigger *trig; + struct atlas_device *chip; struct regmap *regmap; struct irq_work work; @@ -84,9 +90,10 @@ static const struct regmap_config atlas_regmap_config = { .cache_type = REGCACHE_RBTREE, }; -static const struct iio_chan_spec atlas_channels[] = { +static const struct iio_chan_spec atlas_ph_channels[] = { { .type = IIO_PH, + .address = ATLAS_REG_PH_DATA, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), .scan_index = 0, @@ -100,7 +107,7 @@ static const struct iio_chan_spec atlas_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(1), { .type = IIO_TEMP, - .address = ATLAS_REG_TEMP_DATA, + .address = ATLAS_REG_PH_TEMP_DATA, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), .output = 1, @@ -108,6 +115,52 @@ static const struct iio_chan_spec atlas_channels[] = { }, }; +static int atlas_check_ph_calibration(struct atlas_data *data) +{ + struct device *dev = &data->client->dev; + int ret; + unsigned int val; + + ret = regmap_read(data->regmap, ATLAS_REG_PH_CALIB_STATUS, &val); + if (ret) + return ret; + + if (!(val & ATLAS_REG_PH_CALIB_STATUS_MASK)) { + dev_warn(dev, "device has not been calibrated\n"); + return 0; + } + + if (!(val & ATLAS_REG_PH_CALIB_STATUS_LOW)) + dev_warn(dev, "device missing low point calibration\n"); + + if (!(val & ATLAS_REG_PH_CALIB_STATUS_MID)) + dev_warn(dev, "device missing mid point calibration\n"); + + if (!(val & ATLAS_REG_PH_CALIB_STATUS_HIGH)) + dev_warn(dev, "device missing high point calibration\n"); + + return 0; +} + +struct atlas_device { + const struct iio_chan_spec *channels; + int num_channels; + int data_reg; + + int (*calibration)(struct atlas_data *data); + int delay; +}; + +static struct atlas_device atlas_devices[] = { + [ATLAS_PH_SM] = { + .channels = atlas_ph_channels, + .num_channels = 3, + .data_reg = ATLAS_REG_PH_DATA, + .calibration = &atlas_check_ph_calibration, + .delay = ATLAS_PH_INT_TIME_IN_US, + }, +}; + static int atlas_set_powermode(struct atlas_data *data, int on) { return regmap_write(data->regmap, ATLAS_REG_PWR_CONTROL, on); @@ -178,8 +231,9 @@ static irqreturn_t atlas_trigger_handler(int irq, void *private) struct atlas_data *data = iio_priv(indio_dev); int ret; - ret = regmap_bulk_read(data->regmap, ATLAS_REG_PH_DATA, - (u8 *) &data->buffer, sizeof(data->buffer[0])); + ret = regmap_bulk_read(data->regmap, data->chip->data_reg, + (u8 *) &data->buffer, + sizeof(__be32) * (data->chip->num_channels - 2)); if (!ret) iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, @@ -200,7 +254,7 @@ static irqreturn_t atlas_interrupt_handler(int irq, void *private) return IRQ_HANDLED; } -static int atlas_read_ph_measurement(struct atlas_data *data, __be32 *val) +static int atlas_read_measurement(struct atlas_data *data, int reg, __be32 *val) { struct device *dev = &data->client->dev; int suspended = pm_runtime_suspended(dev); @@ -213,11 +267,9 @@ static int atlas_read_ph_measurement(struct atlas_data *data, __be32 *val) } if (suspended) - usleep_range(ATLAS_PH_INT_TIME_IN_US, - ATLAS_PH_INT_TIME_IN_US + 100000); + usleep_range(data->chip->delay, data->chip->delay + 100000); - ret = regmap_bulk_read(data->regmap, ATLAS_REG_PH_DATA, - (u8 *) val, sizeof(*val)); + ret = regmap_bulk_read(data->regmap, reg, (u8 *) val, sizeof(*val)); pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); @@ -247,7 +299,8 @@ static int atlas_read_raw(struct iio_dev *indio_dev, if (iio_buffer_enabled(indio_dev)) ret = -EBUSY; else - ret = atlas_read_ph_measurement(data, ®); + ret = atlas_read_measurement(data, + chan->address, ®); mutex_unlock(&indio_dev->mlock); break; @@ -303,37 +356,24 @@ static const struct iio_info atlas_info = { .write_raw = atlas_write_raw, }; -static int atlas_check_calibration(struct atlas_data *data) -{ - struct device *dev = &data->client->dev; - int ret; - unsigned int val; - - ret = regmap_read(data->regmap, ATLAS_REG_CALIB_STATUS, &val); - if (ret) - return ret; - - if (!(val & ATLAS_REG_CALIB_STATUS_MASK)) { - dev_warn(dev, "device has not been calibrated\n"); - return 0; - } - - if (!(val & ATLAS_REG_CALIB_STATUS_LOW)) - dev_warn(dev, "device missing low point calibration\n"); - - if (!(val & ATLAS_REG_CALIB_STATUS_MID)) - dev_warn(dev, "device missing mid point calibration\n"); - - if (!(val & ATLAS_REG_CALIB_STATUS_HIGH)) - dev_warn(dev, "device missing high point calibration\n"); +static const struct i2c_device_id atlas_id[] = { + { "atlas-ph-sm", ATLAS_PH_SM}, + {} +}; +MODULE_DEVICE_TABLE(i2c, atlas_id); - return 0; +static const struct of_device_id atlas_dt_ids[] = { + { .compatible = "atlas,ph-sm", .data = (void *)ATLAS_PH_SM, }, + { } }; +MODULE_DEVICE_TABLE(of, atlas_dt_ids); static int atlas_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct atlas_data *data; + struct atlas_device *chip; + const struct of_device_id *of_id; struct iio_trigger *trig; struct iio_dev *indio_dev; int ret; @@ -342,10 +382,16 @@ static int atlas_probe(struct i2c_client *client, if (!indio_dev) return -ENOMEM; + of_id = of_match_device(atlas_dt_ids, &client->dev); + if (!of_id) + chip = &atlas_devices[id->driver_data]; + else + chip = &atlas_devices[(unsigned long)of_id->data]; + indio_dev->info = &atlas_info; indio_dev->name = ATLAS_DRV_NAME; - indio_dev->channels = atlas_channels; - indio_dev->num_channels = ARRAY_SIZE(atlas_channels); + indio_dev->channels = chip->channels; + indio_dev->num_channels = chip->num_channels; indio_dev->modes = INDIO_BUFFER_SOFTWARE | INDIO_DIRECT_MODE; indio_dev->dev.parent = &client->dev; @@ -358,6 +404,7 @@ static int atlas_probe(struct i2c_client *client, data = iio_priv(indio_dev); data->client = client; data->trig = trig; + data->chip = chip; trig->dev.parent = indio_dev->dev.parent; trig->ops = &atlas_interrupt_trigger_ops; iio_trigger_set_drvdata(trig, indio_dev); @@ -379,7 +426,7 @@ static int atlas_probe(struct i2c_client *client, return -EINVAL; } - ret = atlas_check_calibration(data); + ret = chip->calibration(data); if (ret) return ret; @@ -480,18 +527,6 @@ static const struct dev_pm_ops atlas_pm_ops = { atlas_runtime_resume, NULL) }; -static const struct i2c_device_id atlas_id[] = { - { "atlas-ph-sm", 0 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, atlas_id); - -static const struct of_device_id atlas_dt_ids[] = { - { .compatible = "atlas,ph-sm" }, - { } -}; -MODULE_DEVICE_TABLE(of, atlas_dt_ids); - static struct i2c_driver atlas_driver = { .driver = { .name = ATLAS_DRV_NAME, -- cgit v1.1 From 4b9d2090a444d44f16788b9ad60180011d133f97 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Tue, 24 May 2016 21:29:19 -0700 Subject: iio: electricalconductivity: add IIO_ELECTRICALCONDUCTIVITY type Signed-off-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 7 +++++++ drivers/iio/industrialio-core.c | 1 + include/uapi/linux/iio/types.h | 1 + 3 files changed, 9 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index df44998..e7f590c 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1565,3 +1565,10 @@ Description: * X is in the plane of the propellers, perpendicular to Y axis, and positive towards the starboard side of the UAV ; * Z is perpendicular to propellers plane and positive upwards. + +What: /sys/bus/iio/devices/iio:deviceX/in_electricalconductivity_raw +KernelVersion: 4.8 +Contact: linux-iio@vger.kernel.org +Description: + Raw (unscaled no offset etc.) electric conductivity reading that + can be processed to siemens per meter. diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index e6319a9..2a85bd8 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -80,6 +80,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_RESISTANCE] = "resistance", [IIO_PH] = "ph", [IIO_UVINDEX] = "uvindex", + [IIO_ELECTRICALCONDUCTIVITY] = "electricalconductivity", }; static const char * const iio_modifier_names[] = { diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h index b0916fc..22e5e58 100644 --- a/include/uapi/linux/iio/types.h +++ b/include/uapi/linux/iio/types.h @@ -39,6 +39,7 @@ enum iio_chan_type { IIO_RESISTANCE, IIO_PH, IIO_UVINDEX, + IIO_ELECTRICALCONDUCTIVITY, }; enum iio_modifier { -- cgit v1.1 From e8dd92bfbff2516f3e76bf08f38131c522454edd Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Tue, 24 May 2016 21:29:20 -0700 Subject: iio: chemical: atlas-ph-sensor: add EC feature Signed-off-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- .../bindings/iio/chemical/atlas,ec-sm.txt | 22 ++++ drivers/iio/chemical/Kconfig | 8 +- drivers/iio/chemical/atlas-ph-sensor.c | 122 ++++++++++++++++++++- 3 files changed, 147 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/chemical/atlas,ec-sm.txt diff --git a/Documentation/devicetree/bindings/iio/chemical/atlas,ec-sm.txt b/Documentation/devicetree/bindings/iio/chemical/atlas,ec-sm.txt new file mode 100644 index 0000000..2962bd9 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/chemical/atlas,ec-sm.txt @@ -0,0 +1,22 @@ +* Atlas Scientific EC-SM OEM sensor + +http://www.atlas-scientific.com/_files/_datasheets/_oem/EC_oem_datasheet.pdf + +Required properties: + + - compatible: must be "atlas,ec-sm" + - reg: the I2C address of the sensor + - interrupt-parent: should be the phandle for the interrupt controller + - interrupts: the sole interrupt generated by the device + + Refer to interrupt-controller/interrupts.txt for generic interrupt client + node bindings. + +Example: + +atlas@64 { + compatible = "atlas,ec-sm"; + reg = <0x64>; + interrupt-parent = <&gpio1>; + interrupts = <16 2>; +}; diff --git a/drivers/iio/chemical/Kconfig b/drivers/iio/chemical/Kconfig index f73290f..4bcc025 100644 --- a/drivers/iio/chemical/Kconfig +++ b/drivers/iio/chemical/Kconfig @@ -5,15 +5,17 @@ menu "Chemical Sensors" config ATLAS_PH_SENSOR - tristate "Atlas Scientific OEM pH-SM sensor" + tristate "Atlas Scientific OEM SM sensors" depends on I2C select REGMAP_I2C select IIO_BUFFER select IIO_TRIGGERED_BUFFER select IRQ_WORK help - Say Y here to build I2C interface support for the Atlas - Scientific OEM pH-SM sensor. + Say Y here to build I2C interface support for the following + Atlas Scientific OEM SM sensors: + * pH SM sensor + * EC SM sensor To compile this driver as module, choose M here: the module will be called atlas-ph-sensor. diff --git a/drivers/iio/chemical/atlas-ph-sensor.c b/drivers/iio/chemical/atlas-ph-sensor.c index e85477c..02e85db 100644 --- a/drivers/iio/chemical/atlas-ph-sensor.c +++ b/drivers/iio/chemical/atlas-ph-sensor.c @@ -50,13 +50,28 @@ #define ATLAS_REG_PH_CALIB_STATUS_MID BIT(1) #define ATLAS_REG_PH_CALIB_STATUS_HIGH BIT(2) +#define ATLAS_REG_EC_CALIB_STATUS 0x0f +#define ATLAS_REG_EC_CALIB_STATUS_MASK 0x0f +#define ATLAS_REG_EC_CALIB_STATUS_DRY BIT(0) +#define ATLAS_REG_EC_CALIB_STATUS_SINGLE BIT(1) +#define ATLAS_REG_EC_CALIB_STATUS_LOW BIT(2) +#define ATLAS_REG_EC_CALIB_STATUS_HIGH BIT(3) + #define ATLAS_REG_PH_TEMP_DATA 0x0e #define ATLAS_REG_PH_DATA 0x16 +#define ATLAS_REG_EC_PROBE 0x08 +#define ATLAS_REG_EC_TEMP_DATA 0x10 +#define ATLAS_REG_EC_DATA 0x18 +#define ATLAS_REG_TDS_DATA 0x1c +#define ATLAS_REG_PSS_DATA 0x20 + #define ATLAS_PH_INT_TIME_IN_US 450000 +#define ATLAS_EC_INT_TIME_IN_US 650000 enum { ATLAS_PH_SM, + ATLAS_EC_SM, }; struct atlas_data { @@ -66,12 +81,13 @@ struct atlas_data { struct regmap *regmap; struct irq_work work; - __be32 buffer[4]; /* 32-bit pH data + 32-bit pad + 64-bit timestamp */ + __be32 buffer[6]; /* 96-bit data + 32-bit pad + 64-bit timestamp */ }; static const struct regmap_range atlas_volatile_ranges[] = { regmap_reg_range(ATLAS_REG_INT_CONTROL, ATLAS_REG_INT_CONTROL), regmap_reg_range(ATLAS_REG_PH_DATA, ATLAS_REG_PH_DATA + 4), + regmap_reg_range(ATLAS_REG_EC_DATA, ATLAS_REG_PSS_DATA + 4), }; static const struct regmap_access_table atlas_volatile_table = { @@ -86,7 +102,7 @@ static const struct regmap_config atlas_regmap_config = { .val_bits = 8, .volatile_table = &atlas_volatile_table, - .max_register = ATLAS_REG_PH_DATA + 4, + .max_register = ATLAS_REG_PSS_DATA + 4, .cache_type = REGCACHE_RBTREE, }; @@ -115,6 +131,50 @@ static const struct iio_chan_spec atlas_ph_channels[] = { }, }; +#define ATLAS_EC_CHANNEL(_idx, _addr) \ + {\ + .type = IIO_CONCENTRATION, \ + .indexed = 1, \ + .channel = _idx, \ + .address = _addr, \ + .info_mask_separate = \ + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), \ + .scan_index = _idx + 1, \ + .scan_type = { \ + .sign = 'u', \ + .realbits = 32, \ + .storagebits = 32, \ + .endianness = IIO_BE, \ + }, \ + } + +static const struct iio_chan_spec atlas_ec_channels[] = { + { + .type = IIO_ELECTRICALCONDUCTIVITY, + .address = ATLAS_REG_EC_DATA, + .info_mask_separate = + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + .scan_index = 0, + .scan_type = { + .sign = 'u', + .realbits = 32, + .storagebits = 32, + .endianness = IIO_BE, + }, + }, + ATLAS_EC_CHANNEL(0, ATLAS_REG_TDS_DATA), + ATLAS_EC_CHANNEL(1, ATLAS_REG_PSS_DATA), + IIO_CHAN_SOFT_TIMESTAMP(3), + { + .type = IIO_TEMP, + .address = ATLAS_REG_EC_TEMP_DATA, + .info_mask_separate = + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + .output = 1, + .scan_index = -1 + }, +}; + static int atlas_check_ph_calibration(struct atlas_data *data) { struct device *dev = &data->client->dev; @@ -142,6 +202,44 @@ static int atlas_check_ph_calibration(struct atlas_data *data) return 0; } +static int atlas_check_ec_calibration(struct atlas_data *data) +{ + struct device *dev = &data->client->dev; + int ret; + unsigned int val; + + ret = regmap_bulk_read(data->regmap, ATLAS_REG_EC_PROBE, &val, 2); + if (ret) + return ret; + + dev_info(dev, "probe set to K = %d.%.2d", be16_to_cpu(val) / 100, + be16_to_cpu(val) % 100); + + ret = regmap_read(data->regmap, ATLAS_REG_EC_CALIB_STATUS, &val); + if (ret) + return ret; + + if (!(val & ATLAS_REG_EC_CALIB_STATUS_MASK)) { + dev_warn(dev, "device has not been calibrated\n"); + return 0; + } + + if (!(val & ATLAS_REG_EC_CALIB_STATUS_DRY)) + dev_warn(dev, "device missing dry point calibration\n"); + + if (val & ATLAS_REG_EC_CALIB_STATUS_SINGLE) { + dev_warn(dev, "device using single point calibration\n"); + } else { + if (!(val & ATLAS_REG_EC_CALIB_STATUS_LOW)) + dev_warn(dev, "device missing low point calibration\n"); + + if (!(val & ATLAS_REG_EC_CALIB_STATUS_HIGH)) + dev_warn(dev, "device missing high point calibration\n"); + } + + return 0; +} + struct atlas_device { const struct iio_chan_spec *channels; int num_channels; @@ -159,6 +257,14 @@ static struct atlas_device atlas_devices[] = { .calibration = &atlas_check_ph_calibration, .delay = ATLAS_PH_INT_TIME_IN_US, }, + [ATLAS_EC_SM] = { + .channels = atlas_ec_channels, + .num_channels = 5, + .data_reg = ATLAS_REG_EC_DATA, + .calibration = &atlas_check_ec_calibration, + .delay = ATLAS_EC_INT_TIME_IN_US, + }, + }; static int atlas_set_powermode(struct atlas_data *data, int on) @@ -294,6 +400,8 @@ static int atlas_read_raw(struct iio_dev *indio_dev, (u8 *) ®, sizeof(reg)); break; case IIO_PH: + case IIO_CONCENTRATION: + case IIO_ELECTRICALCONDUCTIVITY: mutex_lock(&indio_dev->mlock); if (iio_buffer_enabled(indio_dev)) @@ -324,6 +432,14 @@ static int atlas_read_raw(struct iio_dev *indio_dev, *val = 1; /* 0.001 */ *val2 = 1000; break; + case IIO_ELECTRICALCONDUCTIVITY: + *val = 1; /* 0.00001 */ + *val = 100000; + break; + case IIO_CONCENTRATION: + *val = 0; /* 0.000000001 */ + *val2 = 1000; + return IIO_VAL_INT_PLUS_NANO; default: return -EINVAL; } @@ -358,12 +474,14 @@ static const struct iio_info atlas_info = { static const struct i2c_device_id atlas_id[] = { { "atlas-ph-sm", ATLAS_PH_SM}, + { "atlas-ec-sm", ATLAS_EC_SM}, {} }; MODULE_DEVICE_TABLE(i2c, atlas_id); static const struct of_device_id atlas_dt_ids[] = { { .compatible = "atlas,ph-sm", .data = (void *)ATLAS_PH_SM, }, + { .compatible = "atlas,ec-sm", .data = (void *)ATLAS_EC_SM, }, { } }; MODULE_DEVICE_TABLE(of, atlas_dt_ids); -- cgit v1.1 From 0aea7ac8548a9cda7a5003b39fe9b6031f0c19e0 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Tue, 24 May 2016 15:42:28 +0300 Subject: iio: magnetometer: bmc150: Document Bosch supported chips bmc150 driver supports also BMC156 and BMM150 chips. Signed-off-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index 84e6559..1f842ab 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig @@ -44,6 +44,7 @@ config BMC150_MAGN_I2C This driver is only implementing magnetometer part, which has its own address and register map. + This driver also supports I2C Bosch BMC156 and BMM150 chips. To compile this driver as a module, choose M here: the module will be called bmc150_magn_i2c. @@ -60,6 +61,7 @@ config BMC150_MAGN_SPI This driver is only implementing magnetometer part, which has its own address and register map. + This driver also supports SPI Bosch BMC156 and BMM150 chips. To compile this driver as a module, choose M here: the module will be called bmc150_magn_spi. -- cgit v1.1 From 90e9a9500f16e60bf96c95cd6b74f84d56e12ef0 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Mon, 23 May 2016 23:27:30 -0700 Subject: iio: proximity: as3935: remove redundant MODULE_ALIAS MODULE_ALIAS isn't needed since the module name is the same as the alias defined. Signed-off-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/as3935.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c index f4d29d5..c12fde2 100644 --- a/drivers/iio/proximity/as3935.c +++ b/drivers/iio/proximity/as3935.c @@ -461,4 +461,3 @@ module_spi_driver(as3935_driver); MODULE_AUTHOR("Matt Ranostay "); MODULE_DESCRIPTION("AS3935 lightning sensor"); MODULE_LICENSE("GPL"); -MODULE_ALIAS("spi:as3935"); -- cgit v1.1 From 4f20d5927b8e900ff1c3ee590b700ca71cd3f3ca Mon Sep 17 00:00:00 2001 From: Crestez Dan Leonard Date: Mon, 23 May 2016 21:39:56 +0300 Subject: iio: iio_generic_buffer: Cleanup when receiving signals This will clean (disable buffer/trigger/channels) when doing something like a CTRL-C. Otherwise restarting generic_buffer requires a manual echo 0 > buffer/enable This also cleanup up all the code freeing string buffers at the end of main. We initialize all pointers to NULL so that cleanup can all be done under a single error label. Signed-off-by: Crestez Dan Leonard Signed-off-by: Jonathan Cameron --- tools/iio/iio_generic_buffer.c | 172 ++++++++++++++++++++++++++--------------- 1 file changed, 108 insertions(+), 64 deletions(-) diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c index 2429c78..972f400 100644 --- a/tools/iio/iio_generic_buffer.c +++ b/tools/iio/iio_generic_buffer.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include #include "iio_utils.h" /** @@ -254,6 +256,65 @@ void print_usage(void) " -w Set delay between reads in us (event-less mode)\n"); } +enum autochan autochannels = AUTOCHANNELS_DISABLED; +char *dev_dir_name = NULL; +char *buf_dir_name = NULL; +bool current_trigger_set = false; + +void cleanup(void) +{ + int ret; + + /* Disable trigger */ + if (dev_dir_name && current_trigger_set) { + /* Disconnect the trigger - just write a dummy name. */ + ret = write_sysfs_string("trigger/current_trigger", + dev_dir_name, "NULL"); + if (ret < 0) + fprintf(stderr, "Failed to disable trigger: %s\n", + strerror(-ret)); + current_trigger_set = false; + } + + /* Disable buffer */ + if (buf_dir_name) { + ret = write_sysfs_int("enable", buf_dir_name, 0); + if (ret < 0) + fprintf(stderr, "Failed to disable buffer: %s\n", + strerror(-ret)); + } + + /* Disable channels if auto-enabled */ + if (dev_dir_name && autochannels == AUTOCHANNELS_ACTIVE) { + ret = enable_disable_all_channels(dev_dir_name, 0); + if (ret) + fprintf(stderr, "Failed to disable all channels\n"); + autochannels = AUTOCHANNELS_DISABLED; + } +} + +void sig_handler(int signum) +{ + fprintf(stderr, "Caught signal %d\n", signum); + cleanup(); + exit(-signum); +} + +void register_cleanup(void) +{ + struct sigaction sa = { .sa_handler = sig_handler }; + const int signums[] = { SIGINT, SIGTERM, SIGABRT }; + int ret, i; + + for (i = 0; i < ARRAY_SIZE(signums); ++i) { + ret = sigaction(signums[i], &sa, NULL); + if (ret) { + perror("Failed to register signal handler"); + exit(-1); + } + } +} + int main(int argc, char **argv) { unsigned long num_loops = 2; @@ -261,25 +322,24 @@ int main(int argc, char **argv) unsigned long buf_len = 128; int ret, c, i, j, toread; - int fp; + int fp = -1; - int num_channels; + int num_channels = 0; char *trigger_name = NULL, *device_name = NULL; - char *dev_dir_name, *buf_dir_name; - int datardytrigger = 1; - char *data; + char *data = NULL; ssize_t read_size; int dev_num, trig_num; - char *buffer_access; + char *buffer_access = NULL; int scan_size; int noevents = 0; int notrigger = 0; - enum autochan autochannels = AUTOCHANNELS_DISABLED; char *dummy; struct iio_channel_info *channels; + register_cleanup(); + while ((c = getopt(argc, argv, "ac:egl:n:t:w:")) != -1) { switch (c) { case 'a': @@ -288,8 +348,10 @@ int main(int argc, char **argv) case 'c': errno = 0; num_loops = strtoul(optarg, &dummy, 10); - if (errno) - return -errno; + if (errno) { + ret = -errno; + goto error; + } break; case 'e': @@ -301,26 +363,30 @@ int main(int argc, char **argv) case 'l': errno = 0; buf_len = strtoul(optarg, &dummy, 10); - if (errno) - return -errno; + if (errno) { + ret = -errno; + goto error; + } break; case 'n': device_name = optarg; break; case 't': - trigger_name = optarg; - datardytrigger = 0; + trigger_name = strdup(optarg); break; case 'w': errno = 0; timedelay = strtoul(optarg, &dummy, 10); - if (errno) - return -errno; + if (errno) { + ret = -errno; + goto error; + } break; case '?': print_usage(); - return -1; + ret = -1; + goto error; } } @@ -334,14 +400,17 @@ int main(int argc, char **argv) dev_num = find_type_by_name(device_name, "iio:device"); if (dev_num < 0) { fprintf(stderr, "Failed to find the %s\n", device_name); - return dev_num; + ret = dev_num; + goto error; } printf("iio device number being used is %d\n", dev_num); ret = asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num); - if (ret < 0) - return -ENOMEM; + if (ret < 0) { + ret = -ENOMEM; + goto error; + } if (!notrigger) { if (!trigger_name) { @@ -354,7 +423,7 @@ int main(int argc, char **argv) "%s-dev%d", device_name, dev_num); if (ret < 0) { ret = -ENOMEM; - goto error_free_dev_dir_name; + goto error; } } @@ -367,7 +436,7 @@ int main(int argc, char **argv) "%s-trigger", device_name); if (ret < 0) { ret = -ENOMEM; - goto error_free_dev_dir_name; + goto error; } } @@ -376,7 +445,7 @@ int main(int argc, char **argv) fprintf(stderr, "Failed to find the trigger %s\n", trigger_name); ret = trig_num; - goto error_free_triggername; + goto error; } printf("iio trigger number being used is %d\n", trig_num); @@ -392,7 +461,7 @@ int main(int argc, char **argv) if (ret) { fprintf(stderr, "Problem reading scan element information\n" "diag %s\n", dev_dir_name); - goto error_free_triggername; + goto error; } if (num_channels && autochannels == AUTOCHANNELS_ENABLED) { fprintf(stderr, "Auto-channels selected but some channels " @@ -407,7 +476,7 @@ int main(int argc, char **argv) ret = enable_disable_all_channels(dev_dir_name, 1); if (ret) { fprintf(stderr, "Failed to enable all channels\n"); - goto error_free_triggername; + goto error; } /* This flags that we need to disable the channels again */ @@ -419,12 +488,12 @@ int main(int argc, char **argv) fprintf(stderr, "Problem reading scan element " "information\n" "diag %s\n", dev_dir_name); - goto error_disable_channels; + goto error; } if (!num_channels) { fprintf(stderr, "Still no channels after " "auto-enabling, giving up\n"); - goto error_disable_channels; + goto error; } } @@ -436,7 +505,7 @@ int main(int argc, char **argv) "/*_en or pass -a to autoenable channels and " "try again.\n", dev_dir_name); ret = -ENOENT; - goto error_free_triggername; + goto error; } /* @@ -448,7 +517,7 @@ int main(int argc, char **argv) "%siio:device%d/buffer", iio_dir, dev_num); if (ret < 0) { ret = -ENOMEM; - goto error_free_channels; + goto error; } if (!notrigger) { @@ -463,34 +532,34 @@ int main(int argc, char **argv) if (ret < 0) { fprintf(stderr, "Failed to write current_trigger file\n"); - goto error_free_buf_dir_name; + goto error; } } /* Setup ring buffer parameters */ ret = write_sysfs_int("length", buf_dir_name, buf_len); if (ret < 0) - goto error_free_buf_dir_name; + goto error; /* Enable the buffer */ ret = write_sysfs_int("enable", buf_dir_name, 1); if (ret < 0) { fprintf(stderr, "Failed to enable buffer: %s\n", strerror(-ret)); - goto error_free_buf_dir_name; + goto error; } scan_size = size_from_channelarray(channels, num_channels); data = malloc(scan_size * buf_len); if (!data) { ret = -ENOMEM; - goto error_free_buf_dir_name; + goto error; } ret = asprintf(&buffer_access, "/dev/iio:device%d", dev_num); if (ret < 0) { ret = -ENOMEM; - goto error_free_data; + goto error; } /* Attempt to open non blocking the access dev */ @@ -498,7 +567,7 @@ int main(int argc, char **argv) if (fp == -1) { /* TODO: If it isn't there make the node */ ret = -errno; fprintf(stderr, "Failed to open %s\n", buffer_access); - goto error_free_buffer_access; + goto error; } for (j = 0; j < num_loops; j++) { @@ -511,7 +580,7 @@ int main(int argc, char **argv) ret = poll(&pfd, 1, -1); if (ret < 0) { ret = -errno; - goto error_close_buffer_access; + goto error; } else if (ret == 0) { continue; } @@ -536,45 +605,20 @@ int main(int argc, char **argv) num_channels); } - /* Stop the buffer */ - ret = write_sysfs_int("enable", buf_dir_name, 0); - if (ret < 0) - goto error_close_buffer_access; - - if (!notrigger) - /* Disconnect the trigger - just write a dummy name. */ - ret = write_sysfs_string("trigger/current_trigger", - dev_dir_name, "NULL"); - if (ret < 0) - fprintf(stderr, "Failed to write to %s\n", - dev_dir_name); +error: + cleanup(); -error_close_buffer_access: - if (close(fp) == -1) + if (fp >= 0 && close(fp) == -1) perror("Failed to close buffer"); - -error_free_buffer_access: free(buffer_access); -error_free_data: free(data); -error_free_buf_dir_name: free(buf_dir_name); -error_free_channels: for (i = num_channels - 1; i >= 0; i--) { free(channels[i].name); free(channels[i].generic_name); } free(channels); -error_free_triggername: - if (datardytrigger) - free(trigger_name); -error_disable_channels: - if (autochannels == AUTOCHANNELS_ACTIVE) { - ret = enable_disable_all_channels(dev_dir_name, 0); - if (ret) - fprintf(stderr, "Failed to disable all channels\n"); - } -error_free_dev_dir_name: + free(trigger_name); free(dev_dir_name); return ret; -- cgit v1.1 From de397db8ab9e292ed3b5be42d0892a0ec717330d Mon Sep 17 00:00:00 2001 From: Crestez Dan Leonard Date: Mon, 23 May 2016 21:39:57 +0300 Subject: iio: iio_generic_buffer: Add --device-num option This makes it possible to distinguish between iio devices with the same name. Signed-off-by: Crestez Dan Leonard Signed-off-by: Jonathan Cameron --- tools/iio/iio_generic_buffer.c | 69 +++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c index 972f400..3f16e9f 100644 --- a/tools/iio/iio_generic_buffer.c +++ b/tools/iio/iio_generic_buffer.c @@ -251,7 +251,9 @@ void print_usage(void) " -e Disable wait for event (new data)\n" " -g Use trigger-less mode\n" " -l Set buffer length to n samples\n" - " -n Set device name (mandatory)\n" + " --device-name -n \n" + " --device-num -N \n" + " Set device by name or number (mandatory)\n" " -t Set trigger name\n" " -w Set delay between reads in us (event-less mode)\n"); } @@ -315,6 +317,12 @@ void register_cleanup(void) } } +static const struct option longopts[] = { + { "device-name", 1, 0, 'n' }, + { "device-num", 1, 0, 'N' }, + { }, +}; + int main(int argc, char **argv) { unsigned long num_loops = 2; @@ -329,7 +337,7 @@ int main(int argc, char **argv) char *data = NULL; ssize_t read_size; - int dev_num, trig_num; + int dev_num = -1, trig_num; char *buffer_access = NULL; int scan_size; int noevents = 0; @@ -340,7 +348,7 @@ int main(int argc, char **argv) register_cleanup(); - while ((c = getopt(argc, argv, "ac:egl:n:t:w:")) != -1) { + while ((c = getopt_long(argc, argv, "ac:egl:n:N:t:w:", longopts, NULL)) != -1) { switch (c) { case 'a': autochannels = AUTOCHANNELS_ENABLED; @@ -370,7 +378,15 @@ int main(int argc, char **argv) break; case 'n': - device_name = optarg; + device_name = strdup(optarg); + break; + case 'N': + errno = 0; + dev_num = strtoul(optarg, &dummy, 10); + if (errno) { + ret = -errno; + goto error; + } break; case 't': trigger_name = strdup(optarg); @@ -390,26 +406,42 @@ int main(int argc, char **argv) } } - if (!device_name) { - fprintf(stderr, "Device name not set\n"); - print_usage(); - return -1; - } - /* Find the device requested */ - dev_num = find_type_by_name(device_name, "iio:device"); - if (dev_num < 0) { - fprintf(stderr, "Failed to find the %s\n", device_name); - ret = dev_num; + if (dev_num < 0 && !device_name) { + fprintf(stderr, "Device not set\n"); + print_usage(); + ret = -1; + goto error; + } else if (dev_num >= 0 && device_name) { + fprintf(stderr, "Only one of --device-num or --device-name needs to be set\n"); + print_usage(); + ret = -1; goto error; + } else if (dev_num < 0) { + dev_num = find_type_by_name(device_name, "iio:device"); + if (dev_num < 0) { + fprintf(stderr, "Failed to find the %s\n", device_name); + ret = dev_num; + goto error; + } } - printf("iio device number being used is %d\n", dev_num); ret = asprintf(&dev_dir_name, "%siio:device%d", iio_dir, dev_num); - if (ret < 0) { - ret = -ENOMEM; - goto error; + if (ret < 0) + return -ENOMEM; + /* Fetch device_name if specified by number */ + if (!device_name) { + device_name = malloc(IIO_MAX_NAME_LENGTH); + if (!device_name) { + ret = -ENOMEM; + goto error; + } + ret = read_sysfs_string("name", dev_dir_name, device_name); + if (ret < 0) { + fprintf(stderr, "Failed to read name of device %d\n", dev_num); + goto error; + } } if (!notrigger) { @@ -619,6 +651,7 @@ error: } free(channels); free(trigger_name); + free(device_name); free(dev_dir_name); return ret; -- cgit v1.1 From 7c7e9dad7017ff5b5f0524ea6d85dcda3c62431e Mon Sep 17 00:00:00 2001 From: Crestez Dan Leonard Date: Mon, 23 May 2016 21:39:58 +0300 Subject: iio: iio_generic_buffer: Add --trigger-num option Signed-off-by: Crestez Dan Leonard Signed-off-by: Jonathan Cameron --- tools/iio/iio_generic_buffer.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c index 3f16e9f..e8c3052 100644 --- a/tools/iio/iio_generic_buffer.c +++ b/tools/iio/iio_generic_buffer.c @@ -254,7 +254,9 @@ void print_usage(void) " --device-name -n \n" " --device-num -N \n" " Set device by name or number (mandatory)\n" - " -t Set trigger name\n" + " --trigger-name -t \n" + " --trigger-num -T \n" + " Set trigger by name or number\n" " -w Set delay between reads in us (event-less mode)\n"); } @@ -320,6 +322,8 @@ void register_cleanup(void) static const struct option longopts[] = { { "device-name", 1, 0, 'n' }, { "device-num", 1, 0, 'N' }, + { "trigger-name", 1, 0, 't' }, + { "trigger-num", 1, 0, 'T' }, { }, }; @@ -348,7 +352,7 @@ int main(int argc, char **argv) register_cleanup(); - while ((c = getopt_long(argc, argv, "ac:egl:n:N:t:w:", longopts, NULL)) != -1) { + while ((c = getopt_long(argc, argv, "ac:egl:n:N:t:T:w:", longopts, NULL)) != -1) { switch (c) { case 'a': autochannels = AUTOCHANNELS_ENABLED; @@ -391,6 +395,12 @@ int main(int argc, char **argv) case 't': trigger_name = strdup(optarg); break; + case 'T': + errno = 0; + trig_num = strtoul(optarg, &dummy, 10); + if (errno) + return -errno; + break; case 'w': errno = 0; timedelay = strtoul(optarg, &dummy, 10); @@ -444,7 +454,23 @@ int main(int argc, char **argv) } } - if (!notrigger) { + if (notrigger) { + printf("trigger-less mode selected\n"); + } if (trig_num > 0) { + char *trig_dev_name; + ret = asprintf(&trig_dev_name, "%strigger%d", iio_dir, trig_num); + if (ret < 0) { + return -ENOMEM; + } + trigger_name = malloc(IIO_MAX_NAME_LENGTH); + ret = read_sysfs_string("name", trig_dev_name, trigger_name); + free(trig_dev_name); + if (ret < 0) { + fprintf(stderr, "Failed to read trigger%d name from\n", trig_num); + return ret; + } + printf("iio trigger number being used is %d\n", trig_num); + } else { if (!trigger_name) { /* * Build the trigger name. If it is device associated @@ -481,8 +507,6 @@ int main(int argc, char **argv) } printf("iio trigger number being used is %d\n", trig_num); - } else { - printf("trigger-less mode selected\n"); } /* -- cgit v1.1 From afa814841c812cd1a36dbbb124542a487c2df5ee Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Wed, 1 Jun 2016 21:28:14 -0700 Subject: iio: adc: ad7793: claim direct mode when writing frequency Driver was checking for direct mode and trying to lock it, but left a gap where mode could change before the desired operation. Use iio_device_claim_direct_mode() to guarantee device stays in direct mode. Refactor function to clarify look-up followed by lock sequence. Signed-off-by: Alison Schofield Cc: Daniel Baluta Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7793.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c index 7b07bb6..a43722f 100644 --- a/drivers/iio/adc/ad7793.c +++ b/drivers/iio/adc/ad7793.c @@ -369,13 +369,6 @@ static ssize_t ad7793_write_frequency(struct device *dev, long lval; int i, ret; - mutex_lock(&indio_dev->mlock); - if (iio_buffer_enabled(indio_dev)) { - mutex_unlock(&indio_dev->mlock); - return -EBUSY; - } - mutex_unlock(&indio_dev->mlock); - ret = kstrtol(buf, 10, &lval); if (ret) return ret; @@ -383,20 +376,21 @@ static ssize_t ad7793_write_frequency(struct device *dev, if (lval == 0) return -EINVAL; - ret = -EINVAL; - for (i = 0; i < 16; i++) - if (lval == st->chip_info->sample_freq_avail[i]) { - mutex_lock(&indio_dev->mlock); - st->mode &= ~AD7793_MODE_RATE(-1); - st->mode |= AD7793_MODE_RATE(i); - ad_sd_write_reg(&st->sd, AD7793_REG_MODE, - sizeof(st->mode), st->mode); - mutex_unlock(&indio_dev->mlock); - ret = 0; - } + if (lval == st->chip_info->sample_freq_avail[i]) + break; + if (i == 16) + return -EINVAL; - return ret ? ret : len; + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + st->mode &= ~AD7793_MODE_RATE(-1); + st->mode |= AD7793_MODE_RATE(i); + ad_sd_write_reg(&st->sd, AD7793_REG_MODE, sizeof(st->mode), st->mode); + iio_device_release_direct_mode(indio_dev); + + return len; } static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, -- cgit v1.1 From d7203ad864db0b34f0e106ec0659890c4e58c143 Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Tue, 31 May 2016 21:35:49 -0700 Subject: iio: adc: ad7791: claim direct mode when writing frequency Driver was checking for direct mode and trying to lock it, but left a gap where mode could change before the desired operation. Use iio_device_claim_direct_mode() to guarantee device stays in direct mode. Refactor function to clarify look-up followed by lock sequence. Signed-off-by: Alison Schofield Cc: Daniel Baluta Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7791.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c index cf172d58..1dfe641 100644 --- a/drivers/iio/adc/ad7791.c +++ b/drivers/iio/adc/ad7791.c @@ -272,30 +272,22 @@ static ssize_t ad7791_write_frequency(struct device *dev, struct ad7791_state *st = iio_priv(indio_dev); int i, ret; - mutex_lock(&indio_dev->mlock); - if (iio_buffer_enabled(indio_dev)) { - mutex_unlock(&indio_dev->mlock); - return -EBUSY; - } - mutex_unlock(&indio_dev->mlock); - - ret = -EINVAL; - - for (i = 0; i < ARRAY_SIZE(ad7791_sample_freq_avail); i++) { - if (sysfs_streq(ad7791_sample_freq_avail[i], buf)) { - - mutex_lock(&indio_dev->mlock); - st->filter &= ~AD7791_FILTER_RATE_MASK; - st->filter |= i; - ad_sd_write_reg(&st->sd, AD7791_REG_FILTER, - sizeof(st->filter), st->filter); - mutex_unlock(&indio_dev->mlock); - ret = 0; + for (i = 0; i < ARRAY_SIZE(ad7791_sample_freq_avail); i++) + if (sysfs_streq(ad7791_sample_freq_avail[i], buf)) break; - } - } + if (i == ARRAY_SIZE(ad7791_sample_freq_avail)) + return -EINVAL; + + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + st->filter &= ~AD7791_FILTER_RATE_MASK; + st->filter |= i; + ad_sd_write_reg(&st->sd, AD7791_REG_FILTER, sizeof(st->filter), + st->filter); + iio_device_release_direct_mode(indio_dev); - return ret ? ret : len; + return len; } static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, -- cgit v1.1 From fea89e2dfceaf78d132b12a4aab3db3c04fb5639 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Tue, 31 May 2016 12:00:12 -0500 Subject: iio: adc: ti_am335x_adc: use variable names for sizeof() operator Fix the code formatting to use the kernel preferred style of using the actual variables to determize the size using the sizeof() operator. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti_am335x_adc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index c1e0553..9f406d0 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -326,8 +326,7 @@ static int tiadc_channel_init(struct iio_dev *indio_dev, int channels) int i; indio_dev->num_channels = channels; - chan_array = kcalloc(channels, - sizeof(struct iio_chan_spec), GFP_KERNEL); + chan_array = kcalloc(channels, sizeof(*chan_array), GFP_KERNEL); if (chan_array == NULL) return -ENOMEM; @@ -467,8 +466,7 @@ static int tiadc_probe(struct platform_device *pdev) return -EINVAL; } - indio_dev = devm_iio_device_alloc(&pdev->dev, - sizeof(struct tiadc_device)); + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*indio_dev)); if (indio_dev == NULL) { dev_err(&pdev->dev, "failed to allocate iio device\n"); return -ENOMEM; -- cgit v1.1 From 27aa832d1882da4b6595abe99e287f46b2d54f45 Mon Sep 17 00:00:00 2001 From: "Andrew F. Davis" Date: Tue, 31 May 2016 12:00:07 -0500 Subject: iio: adc: ti_am335x_adc: use SIMPLE_DEV_PM_OPS helper macro Replace ifdefs with SIMPLE_DEV_PM_OPS helper macro. Signed-off-by: Andrew F. Davis Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti_am335x_adc.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 9f406d0..8a36875 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -529,8 +529,7 @@ static int tiadc_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM -static int tiadc_suspend(struct device *dev) +static int __maybe_unused tiadc_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct tiadc_device *adc_dev = iio_priv(indio_dev); @@ -548,7 +547,7 @@ static int tiadc_suspend(struct device *dev) return 0; } -static int tiadc_resume(struct device *dev) +static int __maybe_unused tiadc_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct tiadc_device *adc_dev = iio_priv(indio_dev); @@ -565,14 +564,7 @@ static int tiadc_resume(struct device *dev) return 0; } -static const struct dev_pm_ops tiadc_pm_ops = { - .suspend = tiadc_suspend, - .resume = tiadc_resume, -}; -#define TIADC_PM_OPS (&tiadc_pm_ops) -#else -#define TIADC_PM_OPS NULL -#endif +static SIMPLE_DEV_PM_OPS(tiadc_pm_ops, tiadc_suspend, tiadc_resume); static const struct of_device_id ti_adc_dt_ids[] = { { .compatible = "ti,am3359-adc", }, @@ -583,7 +575,7 @@ MODULE_DEVICE_TABLE(of, ti_adc_dt_ids); static struct platform_driver tiadc_driver = { .driver = { .name = "TI-am335x-adc", - .pm = TIADC_PM_OPS, + .pm = &tiadc_pm_ops, .of_match_table = ti_adc_dt_ids, }, .probe = tiadc_probe, -- cgit v1.1 From bc2e1126eccb47517b9d1c685020c38600f99a3d Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 6 Mar 2016 20:02:56 +0000 Subject: iio:trigger: Experimental kthread tight loop trigger (thread only) This patch is in response to that of Gregor Boirie who proposed using a tight kthread within a device driver (be it with the support factored out into a helper library) in order to basically spin as fast as possible. It is meant as a talking point rather than a formal proposal of the code (though we are heading towards that I think). Also gives people some working code to mess around with. I proposed that this could be done with a trigger with a few constraints and this is the proof (be it ugly) of that. There are some constraints though, some of which we would want to relax if this were to move forward. * Will only run the thread part of the registered pollfunc. This is to avoid the overhead of jumping in and out of interrupt context. Is the overhead significant? Not certain but feels like it should be! * This limitation precludes any device that 'must' do some work in interrupt context. However, that is true of few if any drivers and I suspect that any that do will be restricted to using triggers they provide themselves. Usually we have a top half mainly to grab a timestamp as soon after the dataready type signal as possible. Signed-off-by: Jonathan Cameron Acked-by: Daniel Baluta --- drivers/iio/trigger/Kconfig | 12 +++ drivers/iio/trigger/Makefile | 1 + drivers/iio/trigger/iio-trig-loop.c | 143 ++++++++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 drivers/iio/trigger/iio-trig-loop.c diff --git a/drivers/iio/trigger/Kconfig b/drivers/iio/trigger/Kconfig index 519e677..809b2e7 100644 --- a/drivers/iio/trigger/Kconfig +++ b/drivers/iio/trigger/Kconfig @@ -24,6 +24,18 @@ config IIO_INTERRUPT_TRIGGER To compile this driver as a module, choose M here: the module will be called iio-trig-interrupt. +config IIO_TIGHTLOOP_TRIGGER + tristate "A kthread based hammering loop trigger" + depends on IIO_SW_TRIGGER + help + An experimental trigger, used to allow sensors to be sampled as fast + as possible under the limitations of whatever else is going on. + Uses a tight loop in a kthread. Will only work with lower half only + trigger consumers. + + To compile this driver as a module, choose M here: the + module will be called iio-trig-loop. + config IIO_SYSFS_TRIGGER tristate "SYSFS trigger" depends on SYSFS diff --git a/drivers/iio/trigger/Makefile b/drivers/iio/trigger/Makefile index fe06eb5..aab4dc2 100644 --- a/drivers/iio/trigger/Makefile +++ b/drivers/iio/trigger/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_IIO_HRTIMER_TRIGGER) += iio-trig-hrtimer.o obj-$(CONFIG_IIO_INTERRUPT_TRIGGER) += iio-trig-interrupt.o obj-$(CONFIG_IIO_SYSFS_TRIGGER) += iio-trig-sysfs.o +obj-$(CONFIG_IIO_TIGHTLOOP_TRIGGER) += iio-trig-loop.o diff --git a/drivers/iio/trigger/iio-trig-loop.c b/drivers/iio/trigger/iio-trig-loop.c new file mode 100644 index 0000000..dc6be28 --- /dev/null +++ b/drivers/iio/trigger/iio-trig-loop.c @@ -0,0 +1,143 @@ +/* + * Copyright 2016 Jonathan Cameron + * + * Licensed under the GPL-2. + * + * Based on a mashup of the hrtimer trigger and continuous sampling proposal of + * Gregor Boirie + * + * Note this is still rather experimental and may eat babies. + * + * Todo + * * Protect against connection of devices that 'need' the top half + * handler. + * * Work out how to run top half handlers in this context if it is + * safe to do so (timestamp grabbing for example) + * + * Tested against a max1363. Used about 33% cpu for the thread and 20% + * for generic_buffer piping to /dev/null. Watermark set at 64 on a 128 + * element kfifo buffer. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +struct iio_loop_info { + struct iio_sw_trigger swt; + struct task_struct *task; +}; + +static struct config_item_type iio_loop_type = { + .ct_owner = THIS_MODULE, +}; + +static int iio_loop_thread(void *data) +{ + struct iio_trigger *trig = data; + + set_freezable(); + + do { + iio_trigger_poll_chained(trig); + } while (likely(!kthread_freezable_should_stop(NULL))); + + return 0; +} + +static int iio_loop_trigger_set_state(struct iio_trigger *trig, bool state) +{ + struct iio_loop_info *loop_trig = iio_trigger_get_drvdata(trig); + + if (state) { + loop_trig->task = kthread_run(iio_loop_thread, + trig, trig->name); + if (unlikely(IS_ERR(loop_trig->task))) { + dev_err(&trig->dev, + "failed to create trigger loop thread\n"); + return PTR_ERR(loop_trig->task); + } + } else { + kthread_stop(loop_trig->task); + } + + return 0; +} + +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) +{ + struct iio_loop_info *trig_info; + int ret; + + trig_info = kzalloc(sizeof(*trig_info), GFP_KERNEL); + if (!trig_info) + return ERR_PTR(-ENOMEM); + + trig_info->swt.trigger = iio_trigger_alloc("%s", name); + if (!trig_info->swt.trigger) { + ret = -ENOMEM; + goto err_free_trig_info; + } + + iio_trigger_set_drvdata(trig_info->swt.trigger, trig_info); + trig_info->swt.trigger->ops = &iio_loop_trigger_ops; + + ret = iio_trigger_register(trig_info->swt.trigger); + if (ret) + goto err_free_trigger; + + iio_swt_group_init_type_name(&trig_info->swt, name, &iio_loop_type); + + return &trig_info->swt; + +err_free_trigger: + iio_trigger_free(trig_info->swt.trigger); +err_free_trig_info: + kfree(trig_info); + + return ERR_PTR(ret); +} + +static int iio_trig_loop_remove(struct iio_sw_trigger *swt) +{ + struct iio_loop_info *trig_info; + + trig_info = iio_trigger_get_drvdata(swt->trigger); + + iio_trigger_unregister(swt->trigger); + iio_trigger_free(swt->trigger); + kfree(trig_info); + + return 0; +} + +static const struct iio_sw_trigger_ops iio_trig_loop_ops = { + .probe = iio_trig_loop_probe, + .remove = iio_trig_loop_remove, +}; + +static struct iio_sw_trigger_type iio_trig_loop = { + .name = "loop", + .owner = THIS_MODULE, + .ops = &iio_trig_loop_ops, +}; + +module_iio_sw_trigger_driver(iio_trig_loop); + +MODULE_AUTHOR("Jonathan Cameron "); +MODULE_DESCRIPTION("Loop based trigger for the iio subsystem"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:iio-trig-loop"); -- cgit v1.1 From 494025c634a09f141d9282a5cfdbc24b5415a871 Mon Sep 17 00:00:00 2001 From: Li Dongyang Date: Mon, 9 May 2016 10:53:46 -0400 Subject: staging: lustre: o2iblnd: make rdma_create_id() support containers Add support for lustre's ko2iblnd driver to work with containers which was requested by Sebastien Buisson. Signed-off-by: Li Dongyang Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6215 Reviewed-on: http://review.whamcloud.com/18759 Reviewed-by: James Simmons Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index b22984f..45bbe93 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -109,7 +109,7 @@ extern kib_tunables_t kiblnd_tunables; IBLND_CREDIT_HIGHWATER_V1 : \ t->lnd_peercredits_hiw) -#define kiblnd_rdma_create_id(cb, dev, ps, qpt) rdma_create_id(&init_net, \ +#define kiblnd_rdma_create_id(cb, dev, ps, qpt) rdma_create_id(current->nsproxy->net_ns, \ cb, dev, \ ps, qpt) -- cgit v1.1 From cd779f2edec4a33f12144fb1588abc0d220e36bc Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 9 May 2016 10:53:47 -0400 Subject: staging: lustre: libcfs: fix memort leak in libcfs crypto layer During code review Boyko discovered a memory leak. This patch fixes that leak. Signed-off-by: James Simmons Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4423 Reviewed-on: http://review.whamcloud.com/19716 Reviewed-by: Alexander Boyko Reviewed-by: Frank Zago Reviewed-by: Oleg Drokin Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c index 84f9b7b..5c0116a 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c @@ -99,6 +99,7 @@ static int cfs_crypto_hash_alloc(enum cfs_crypto_hash_alg hash_alg, (*type)->cht_size); if (err != 0) { + ahash_request_free(*req); crypto_free_ahash(tfm); return err; } -- cgit v1.1 From 147280d88f8e0e6544da68c658531eed70b9632d Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 9 May 2016 10:53:48 -0400 Subject: staging: lustre: ko2iblnd: fix memory corruption with fragments In my test of the upstream client this change exposed a long standing issues where we have a offset that is not page algined would causes us to access memory beyond the scatter gather list which was causing memory corruption when all 256 fragments were in use. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 9 +++++---- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 6c59f2f..4bb32f1 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -2011,8 +2011,8 @@ static void kiblnd_destroy_tx_pool(kib_pool_t *pool) sizeof(*tx->tx_pages)); if (tx->tx_frags) LIBCFS_FREE(tx->tx_frags, - IBLND_MAX_RDMA_FRAGS * - sizeof(*tx->tx_frags)); + (1 + IBLND_MAX_RDMA_FRAGS) * + sizeof(*tx->tx_frags)); if (tx->tx_wrq) LIBCFS_FREE(tx->tx_wrq, (1 + IBLND_MAX_RDMA_FRAGS) * @@ -2090,11 +2090,12 @@ static int kiblnd_create_tx_pool(kib_poolset_t *ps, int size, } LIBCFS_CPT_ALLOC(tx->tx_frags, lnet_cpt_table(), ps->ps_cpt, - IBLND_MAX_RDMA_FRAGS * sizeof(*tx->tx_frags)); + (1 + IBLND_MAX_RDMA_FRAGS) * + sizeof(*tx->tx_frags)); if (!tx->tx_frags) break; - sg_init_table(tx->tx_frags, IBLND_MAX_RDMA_FRAGS); + sg_init_table(tx->tx_frags, IBLND_MAX_RDMA_FRAGS + 1); LIBCFS_CPT_ALLOC(tx->tx_wrq, lnet_cpt_table(), ps->ps_cpt, (1 + IBLND_MAX_RDMA_FRAGS) * diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index bbfee53..0f7e3a1 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -689,6 +689,10 @@ kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, sg_set_page(sg, page, fragnob, page_offset); sg = sg_next(sg); + if (!sg) { + CERROR("lacking enough sg entries to map tx\n"); + return -EFAULT; + } if (offset + fragnob < iov->iov_len) { offset += fragnob; @@ -733,6 +737,10 @@ kiblnd_setup_rd_kiov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, sg_set_page(sg, kiov->kiov_page, fragnob, kiov->kiov_offset + offset); sg = sg_next(sg); + if (!sg) { + CERROR("lacking enough sg entries to map tx\n"); + return -EFAULT; + } offset = 0; kiov++; -- cgit v1.1 From 423b09b8f45c8771bca84d41c3254c3904d78a0a Mon Sep 17 00:00:00 2001 From: Muhammad Falak R Wani Date: Wed, 11 May 2016 20:53:31 +0530 Subject: staging: lustre: use setup_timer(). Use setup_timer() for initializing the timer, instead of structure assignments. This is the preferred/standard way. Signed-off-by: Muhammad Falak R Wani Acked-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/net_fault.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c b/drivers/staging/lustre/lnet/lnet/net_fault.c index 7d76f28..e4aceb7 100644 --- a/drivers/staging/lustre/lnet/lnet/net_fault.c +++ b/drivers/staging/lustre/lnet/lnet/net_fault.c @@ -760,9 +760,7 @@ lnet_delay_rule_add(struct lnet_fault_attr *attr) wait_event(delay_dd.dd_ctl_waitq, delay_dd.dd_running); } - init_timer(&rule->dl_timer); - rule->dl_timer.function = delay_timer_cb; - rule->dl_timer.data = (unsigned long)rule; + setup_timer(&rule->dl_timer, delay_timer_cb, (unsigned long)rule); spin_lock_init(&rule->dl_lock); INIT_LIST_HEAD(&rule->dl_msg_list); -- cgit v1.1 From db3c16cdde24ecd59df0f24f93f1a4ba177f4b82 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Mon, 16 May 2016 14:51:42 -0400 Subject: staging/lustre/ptlrpc: Removes potential null dereference The lustre_msg_buf method could return NULL. Subsequent code didn't check if it's null before using it. This patch adds two checks. Signed-off-by: Lidza Louina Acked-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/sec.c | 3 +++ drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 187fd1d..657b41f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -2196,6 +2196,9 @@ int sptlrpc_pack_user_desc(struct lustre_msg *msg, int offset) pud = lustre_msg_buf(msg, offset, 0); + if (!pud) + return -EINVAL; + pud->pud_uid = from_kuid(&init_user_ns, current_uid()); pud->pud_gid = from_kgid(&init_user_ns, current_gid()); pud->pud_fsuid = from_kuid(&init_user_ns, current_fsuid()); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index 37c9f4c..ec8edbf 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -574,8 +574,12 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec, lustre_init_msg_v2(req->rq_reqbuf, PLAIN_PACK_SEGMENTS, buflens, NULL); req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, PLAIN_PACK_MSG_OFF, 0); - if (req->rq_pack_udesc) - sptlrpc_pack_user_desc(req->rq_reqbuf, PLAIN_PACK_USER_OFF); + if (req->rq_pack_udesc) { + int rc = sptlrpc_pack_user_desc(req->rq_reqbuf, + PLAIN_PACK_USER_OFF); + if (rc < 0) + return rc; + } return 0; } -- cgit v1.1 From c6c7a17010697377df1241a2914e3c1e5582e234 Mon Sep 17 00:00:00 2001 From: Tobin C Harding Date: Mon, 23 May 2016 10:14:22 +1000 Subject: staging: lustre: llite: kzalloc/copy_to_user to memdup_user kzalloc call followed by copy_to_user can be replaced by call to memdup_user. Signed-off-by: Tobin C Harding Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 4b00d1a..85c50e0 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1076,17 +1076,11 @@ static int copy_and_ioctl(int cmd, struct obd_export *exp, void *copy; int rc; - copy = kzalloc(size, GFP_NOFS); - if (!copy) - return -ENOMEM; - - if (copy_from_user(copy, data, size)) { - rc = -EFAULT; - goto out; - } + copy = memdup_user(data, size); + if (IS_ERR(copy)) + return PTR_ERR(copy); rc = obd_iocontrol(cmd, exp, size, copy, NULL); -out: kfree(copy); return rc; -- cgit v1.1 From b788dc51e4255b700f566a5d63a9c5028d631c77 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Mon, 23 May 2016 20:35:08 -0400 Subject: staging: lustre: llite: drop acl from cache Commit b8a7a3a6 change get_acl() for posix xattr to always cache the ACL which increases the reference count. That reference count can be reduced by have ll_get_acl() call forget_cached_acl() which it wasn't. When an inode gets deleted by Lustre the POSIX ACL reference count is tested to ensure its 1 and if not produces an error. Since forget_cached_acl() was not called Lustre started to complain. This patch changes ll_get_acl() to call forget_cached_acl(). Signed-off-by: James Simmons Reviewed-by: Andreas Gruenbacher Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index f47f2ac..0191945 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -3124,6 +3124,7 @@ struct posix_acl *ll_get_acl(struct inode *inode, int type) spin_lock(&lli->lli_lock); /* VFS' acl_permission_check->check_acl will release the refcount */ acl = posix_acl_dup(lli->lli_posix_acl); + forget_cached_acl(inode, type); spin_unlock(&lli->lli_lock); return acl; -- cgit v1.1 From ecd4df4a7a3e4e2c58ce39abb0654b2c3cd1a3c6 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Sun, 5 Jun 2016 23:28:50 -0400 Subject: staging/lustre/lov: calculate file offset correctly In lov_stripe_pgoff(), it calls lov_stripe_size() to calculate the file size by ost_size, which will be wrong if the stripe_index happens to be stripe aligned. Signed-off-by: Jinshan Xiong Reviewed-on: http://review.whamcloud.com/14462 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6482 Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_offset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_offset.c b/drivers/staging/lustre/lustre/lov/lov_offset.c index 9302f06..7636bfa 100644 --- a/drivers/staging/lustre/lustre/lov/lov_offset.c +++ b/drivers/staging/lustre/lustre/lov/lov_offset.c @@ -74,7 +74,7 @@ pgoff_t lov_stripe_pgoff(struct lov_stripe_md *lsm, pgoff_t stripe_index, { loff_t offset; - offset = lov_stripe_size(lsm, stripe_index << PAGE_SHIFT, stripe); + offset = lov_stripe_size(lsm, (stripe_index << PAGE_SHIFT) + 1, stripe); return offset >> PAGE_SHIFT; } -- cgit v1.1 From 966c4a8f8029a595a5e1840d51309ac417bb4234 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Sun, 5 Jun 2016 23:28:51 -0400 Subject: staging/lustre/llite: define per open file cache for ll_cl_context In ll_readpage and ll_write_begin, it needs to find out the cl_env and cl_io, a.k.a ll_cl_context, when the IO is initialized. It used to call cl_env_get() to figure it out but turned out to be contended if multiple threads are doing IO. In this patch, a per open file ll_cl_context cache is created. When IO type of CIT_READ, CIT_WRITE and CIR_FAULT is initialized, it will add a ll_cl_context into the cache maintained in ll_file_data. In this case, the ll_cl_context can be found in ll_readpage and ll_write_begin later. Signed-off-by: Jinshan Xiong Reviewed-on: http://review.whamcloud.com/10503 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5108 Reviewed-on: http://review.whamcloud.com/10955 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5260 Reviewed-by: Lai Siyao Reviewed-by: Bobi Jam Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 7 + .../staging/lustre/lustre/llite/llite_internal.h | 11 +- drivers/staging/lustre/lustre/llite/llite_mmap.c | 5 + drivers/staging/lustre/lustre/llite/rw.c | 145 +++++++++------------ drivers/staging/lustre/lustre/llite/rw26.c | 17 +-- 5 files changed, 88 insertions(+), 97 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 0191945..bafa0b7 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -519,6 +519,11 @@ static int ll_local_open(struct file *file, struct lookup_intent *it, LUSTRE_FPRIVATE(file) = fd; ll_readahead_init(inode, &fd->fd_ras); fd->fd_omode = it->it_flags & (FMODE_READ | FMODE_WRITE | FMODE_EXEC); + + /* ll_cl_context initialize */ + rwlock_init(&fd->fd_lock); + INIT_LIST_HEAD(&fd->fd_lccs); + return 0; } @@ -1178,7 +1183,9 @@ restart: CERROR("Unknown IO type - %u\n", vio->vui_io_subtype); LBUG(); } + ll_cl_add(file, env, io); result = cl_io_loop(env, io); + ll_cl_remove(file, env); if (args->via_io_subtype == IO_NORMAL) up_read(&lli->lli_trunc_sem); if (write_mutex_locked) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 3f2f30b..7fb949a 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -640,6 +640,8 @@ struct ll_file_data { * false: unknown failure, should report. */ bool fd_write_failed; + rwlock_t fd_lock; /* protect lcc list */ + struct list_head fd_lccs; /* list of ll_cl_context */ }; struct lov_stripe_md; @@ -715,8 +717,9 @@ void ll_readahead_init(struct inode *inode, struct ll_readahead_state *ras); int ll_readahead(const struct lu_env *env, struct cl_io *io, struct cl_page_list *queue, struct ll_readahead_state *ras, bool hit); -struct ll_cl_context *ll_cl_init(struct file *file, struct page *vmpage); -void ll_cl_fini(struct ll_cl_context *lcc); +struct ll_cl_context *ll_cl_find(struct file *file); +void ll_cl_add(struct file *file, const struct lu_env *env, struct cl_io *io); +void ll_cl_remove(struct file *file, const struct lu_env *env); extern const struct address_space_operations ll_aops; @@ -858,11 +861,11 @@ struct vvp_io_args { }; struct ll_cl_context { + struct list_head lcc_list; void *lcc_cookie; + const struct lu_env *lcc_env; struct cl_io *lcc_io; struct cl_page *lcc_page; - struct lu_env *lcc_env; - int lcc_refcheck; }; struct ll_thread_info { diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index 88ef1ca..7610799 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -315,8 +315,13 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) vio->u.fault.ft_flags = 0; vio->u.fault.ft_flags_valid = false; + /* May call ll_readpage() */ + ll_cl_add(vma->vm_file, env, io); + result = cl_io_loop(env, io); + ll_cl_remove(vma->vm_file, env); + /* ft_flags are only valid if we reached * the call to filemap_fault */ diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index 3363977..fa42869 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -59,84 +59,6 @@ #include "llite_internal.h" #include "../include/linux/lustre_compat25.h" -/** - * Finalizes cl-data before exiting typical address_space operation. Dual to - * ll_cl_init(). - */ -void ll_cl_fini(struct ll_cl_context *lcc) -{ - struct lu_env *env = lcc->lcc_env; - struct cl_io *io = lcc->lcc_io; - struct cl_page *page = lcc->lcc_page; - - LASSERT(lcc->lcc_cookie == current); - LASSERT(env); - - if (page) { - lu_ref_del(&page->cp_reference, "cl_io", io); - cl_page_put(env, page); - } - - cl_env_put(env, &lcc->lcc_refcheck); -} - -/** - * Initializes common cl-data at the typical address_space operation entry - * point. - */ -struct ll_cl_context *ll_cl_init(struct file *file, struct page *vmpage) -{ - struct ll_cl_context *lcc; - struct lu_env *env; - struct cl_io *io; - struct cl_object *clob; - struct vvp_io *vio; - - int refcheck; - int result = 0; - - clob = ll_i2info(file_inode(file))->lli_clob; - LASSERT(clob); - - env = cl_env_get(&refcheck); - if (IS_ERR(env)) - return ERR_CAST(env); - - lcc = &ll_env_info(env)->lti_io_ctx; - memset(lcc, 0, sizeof(*lcc)); - lcc->lcc_env = env; - lcc->lcc_refcheck = refcheck; - lcc->lcc_cookie = current; - - vio = vvp_env_io(env); - io = vio->vui_cl.cis_io; - lcc->lcc_io = io; - if (!io) - result = -EIO; - - if (result == 0 && vmpage) { - struct cl_page *page; - - LASSERT(io->ci_state == CIS_IO_GOING); - LASSERT(vio->vui_fd == LUSTRE_FPRIVATE(file)); - page = cl_page_find(env, clob, vmpage->index, vmpage, - CPT_CACHEABLE); - if (!IS_ERR(page)) { - lcc->lcc_page = page; - lu_ref_add(&page->cp_reference, "cl_io", io); - result = 0; - } else { - result = PTR_ERR(page); - } - } - if (result) { - ll_cl_fini(lcc); - lcc = ERR_PTR(result); - } - - return lcc; -} - static void ll_ra_stats_inc_sbi(struct ll_sb_info *sbi, enum ra_stat which); /** @@ -1112,17 +1034,70 @@ int ll_writepages(struct address_space *mapping, struct writeback_control *wbc) return result; } +struct ll_cl_context *ll_cl_find(struct file *file) +{ + struct ll_file_data *fd = LUSTRE_FPRIVATE(file); + struct ll_cl_context *lcc; + struct ll_cl_context *found = NULL; + + read_lock(&fd->fd_lock); + list_for_each_entry(lcc, &fd->fd_lccs, lcc_list) { + if (lcc->lcc_cookie == current) { + found = lcc; + break; + } + } + read_unlock(&fd->fd_lock); + + return found; +} + +void ll_cl_add(struct file *file, const struct lu_env *env, struct cl_io *io) +{ + struct ll_file_data *fd = LUSTRE_FPRIVATE(file); + struct ll_cl_context *lcc = &ll_env_info(env)->lti_io_ctx; + + memset(lcc, 0, sizeof(*lcc)); + INIT_LIST_HEAD(&lcc->lcc_list); + lcc->lcc_cookie = current; + lcc->lcc_env = env; + lcc->lcc_io = io; + + write_lock(&fd->fd_lock); + list_add(&lcc->lcc_list, &fd->fd_lccs); + write_unlock(&fd->fd_lock); +} + +void ll_cl_remove(struct file *file, const struct lu_env *env) +{ + struct ll_file_data *fd = LUSTRE_FPRIVATE(file); + struct ll_cl_context *lcc = &ll_env_info(env)->lti_io_ctx; + + write_lock(&fd->fd_lock); + list_del_init(&lcc->lcc_list); + write_unlock(&fd->fd_lock); +} + int ll_readpage(struct file *file, struct page *vmpage) { + struct cl_object *clob = ll_i2info(file_inode(file))->lli_clob; struct ll_cl_context *lcc; + const struct lu_env *env; + struct cl_io *io; + struct cl_page *page; int result; - lcc = ll_cl_init(file, vmpage); - if (!IS_ERR(lcc)) { - struct lu_env *env = lcc->lcc_env; - struct cl_io *io = lcc->lcc_io; - struct cl_page *page = lcc->lcc_page; + lcc = ll_cl_find(file); + if (!lcc) { + unlock_page(vmpage); + return -EIO; + } + env = lcc->lcc_env; + io = lcc->lcc_io; + LASSERT(io->ci_state == CIS_IO_GOING); + page = cl_page_find(env, clob, vmpage->index, vmpage, CPT_CACHEABLE); + if (!IS_ERR(page)) { LASSERT(page->cp_type == CPT_CACHEABLE); if (likely(!PageUptodate(vmpage))) { cl_page_assume(env, io, page); @@ -1132,10 +1107,10 @@ int ll_readpage(struct file *file, struct page *vmpage) unlock_page(vmpage); result = 0; } - ll_cl_fini(lcc); + cl_page_put(env, page); } else { unlock_page(vmpage); - result = PTR_ERR(lcc); + result = PTR_ERR(page); } return result; } diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index c12a048..947a4f5 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -489,7 +489,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, struct page **pagep, void **fsdata) { struct ll_cl_context *lcc; - struct lu_env *env; + const struct lu_env *env; struct cl_io *io; struct cl_page *page; struct cl_object *clob = ll_i2info(mapping->host)->lli_clob; @@ -501,9 +501,9 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, CDEBUG(D_VFSTRACE, "Writing %lu of %d to %d bytes\n", index, from, len); - lcc = ll_cl_init(file, NULL); - if (IS_ERR(lcc)) { - result = PTR_ERR(lcc); + lcc = ll_cl_find(file); + if (!lcc) { + result = -EIO; goto out; } @@ -579,8 +579,6 @@ out: unlock_page(vmpage); put_page(vmpage); } - if (!IS_ERR(lcc)) - ll_cl_fini(lcc); } else { *pagep = vmpage; *fsdata = lcc; @@ -593,7 +591,7 @@ static int ll_write_end(struct file *file, struct address_space *mapping, struct page *vmpage, void *fsdata) { struct ll_cl_context *lcc = fsdata; - struct lu_env *env; + const struct lu_env *env; struct cl_io *io; struct vvp_io *vio; struct cl_page *page; @@ -631,6 +629,10 @@ static int ll_write_end(struct file *file, struct address_space *mapping, } else { cl_page_disown(env, io, page); + lcc->lcc_page = NULL; + lu_ref_del(&page->cp_reference, "cl_io", io); + cl_page_put(env, page); + /* page list is not contiguous now, commit it now */ unplug = true; } @@ -639,7 +641,6 @@ static int ll_write_end(struct file *file, struct address_space *mapping, file->f_flags & O_SYNC || IS_SYNC(file_inode(file))) result = vvp_io_write_commit(env, io); - ll_cl_fini(lcc); return result >= 0 ? copied : result; } -- cgit v1.1 From d4722fccbe78c2b45a0a534d8944247592eaefe7 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sun, 5 Jun 2016 23:28:52 -0400 Subject: staging/lustre/osc: Remove ops_temp from osc_page It's no longer used and never set anywhere. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_cl_internal.h | 5 ----- drivers/staging/lustre/lustre/osc/osc_page.c | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index ae19d39..7359fcb 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -356,11 +356,6 @@ struct osc_page { */ unsigned ops_transfer_pinned:1, /** - * True for a `temporary page' created by read-ahead code, probably - * outside of any DLM lock. - */ - ops_temp:1, - /** * in LRU? */ ops_in_lru:1, diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index c29c2ea..fc36743 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -214,7 +214,7 @@ static void osc_page_delete(const struct lu_env *env, struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); int rc; - LINVRNT(opg->ops_temp || osc_page_protected(env, opg, CLM_READ, 1)); + LINVRNT(osc_page_protected(env, opg, CLM_READ, 1)); CDEBUG(D_TRACE, "%p\n", opg); osc_page_transfer_put(env, opg); -- cgit v1.1 From d484ed6f10997bb7a89dc7a71d2bf2614053640a Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sun, 5 Jun 2016 23:28:53 -0400 Subject: staging/lustre/osc: Get rid of osc_page_protected() There was a proper debugging function by that name that's long gone. The currently remaining shadow that always returns true is not really useful so it could be dropped along with all the asserts it is part of. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_page.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index fc36743..5a3e694 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -52,13 +52,6 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, * @{ */ -static int osc_page_protected(const struct lu_env *env, - const struct osc_page *opg, - enum cl_lock_mode mode, int unref) -{ - return 1; -} - /***************************************************************************** * * Page operations. @@ -110,8 +103,6 @@ int osc_page_cache_add(const struct lu_env *env, struct osc_page *opg = cl2osc_page(slice); int result; - LINVRNT(osc_page_protected(env, opg, CLM_WRITE, 0)); - osc_page_transfer_get(opg, "transfer\0cache"); result = osc_queue_async_io(env, io, opg); if (result != 0) @@ -214,8 +205,6 @@ static void osc_page_delete(const struct lu_env *env, struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); int rc; - LINVRNT(osc_page_protected(env, opg, CLM_READ, 1)); - CDEBUG(D_TRACE, "%p\n", opg); osc_page_transfer_put(env, opg); rc = osc_teardown_async_page(env, obj, opg); @@ -254,8 +243,6 @@ static void osc_page_clip(const struct lu_env *env, struct osc_page *opg = cl2osc_page(slice); struct osc_async_page *oap = &opg->ops_oap; - LINVRNT(osc_page_protected(env, opg, CLM_READ, 0)); - opg->ops_from = from; opg->ops_to = to; spin_lock(&oap->oap_lock); @@ -269,8 +256,6 @@ static int osc_page_cancel(const struct lu_env *env, struct osc_page *opg = cl2osc_page(slice); int rc = 0; - LINVRNT(osc_page_protected(env, opg, CLM_READ, 0)); - /* Check if the transferring against this page * is completed, or not even queued. */ @@ -320,10 +305,6 @@ int osc_page_init(const struct lu_env *env, struct cl_object *obj, cl_page_slice_add(page, &opg->ops_cl, obj, index, &osc_page_ops); } - /* - * Cannot assert osc_page_protected() here as read-ahead - * creates temporary pages outside of a lock. - */ /* ops_inflight and ops_lru are the same field, but it doesn't * hurt to initialize it twice :-) */ @@ -382,9 +363,6 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, struct osc_async_page *oap = &opg->ops_oap; struct osc_object *obj = oap->oap_obj; - LINVRNT(osc_page_protected(env, opg, - crt == CRT_WRITE ? CLM_WRITE : CLM_READ, 1)); - LASSERTF(oap->oap_magic == OAP_MAGIC, "Bad oap magic: oap %p, magic 0x%x\n", oap, oap->oap_magic); LASSERT(oap->oap_async_flags & ASYNC_READY); -- cgit v1.1 From e3c9078af85dceaa6cda2a573c4bf0be7d978bc4 Mon Sep 17 00:00:00 2001 From: Tobin C Harding Date: Mon, 23 May 2016 20:17:46 +1000 Subject: staging: lustre: set function scope with static A number of function definitions were found to be candidates for static scoping. This patch adds static to these functions. Signed-off-by: Tobin C Harding Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/vvp_dev.c | 8 ++++---- drivers/staging/lustre/lustre/llite/vvp_io.c | 6 +++--- drivers/staging/lustre/lustre/llite/vvp_req.c | 12 ++++++------ drivers/staging/lustre/lustre/obdclass/obd_mount.c | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index 47101de..c63def9 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -150,8 +150,8 @@ struct lu_context_key vvp_session_key = { .lct_fini = vvp_session_key_fini }; -void *vvp_thread_key_init(const struct lu_context *ctx, - struct lu_context_key *key) +static void *vvp_thread_key_init(const struct lu_context *ctx, + struct lu_context_key *key) { struct vvp_thread_info *vti; @@ -161,8 +161,8 @@ void *vvp_thread_key_init(const struct lu_context *ctx, return vti; } -void vvp_thread_key_fini(const struct lu_context *ctx, - struct lu_context_key *key, void *data) +static void vvp_thread_key_fini(const struct lu_context *ctx, + struct lu_context_key *key, void *data) { struct vvp_thread_info *vti = data; diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 5bf9592..e26e0f8 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -47,8 +47,8 @@ #include "llite_internal.h" #include "vvp_internal.h" -struct vvp_io *cl2vvp_io(const struct lu_env *env, - const struct cl_io_slice *slice) +static struct vvp_io *cl2vvp_io(const struct lu_env *env, + const struct cl_io_slice *slice) { struct vvp_io *vio; @@ -1259,7 +1259,7 @@ static int vvp_io_read_page(const struct lu_env *env, return 0; } -void vvp_io_end(const struct lu_env *env, const struct cl_io_slice *ios) +static void vvp_io_end(const struct lu_env *env, const struct cl_io_slice *ios) { CLOBINVRNT(env, ios->cis_io->ci_obj, vvp_object_invariant(ios->cis_io->ci_obj)); diff --git a/drivers/staging/lustre/lustre/llite/vvp_req.c b/drivers/staging/lustre/lustre/llite/vvp_req.c index fb88629..9fe9d6c 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_req.c +++ b/drivers/staging/lustre/lustre/llite/vvp_req.c @@ -60,10 +60,10 @@ static inline struct vvp_req *cl2vvp_req(const struct cl_req_slice *slice) * - o_ioepoch, * */ -void vvp_req_attr_set(const struct lu_env *env, - const struct cl_req_slice *slice, - const struct cl_object *obj, - struct cl_req_attr *attr, u64 flags) +static void vvp_req_attr_set(const struct lu_env *env, + const struct cl_req_slice *slice, + const struct cl_object *obj, + struct cl_req_attr *attr, u64 flags) { struct inode *inode; struct obdo *oa; @@ -87,8 +87,8 @@ void vvp_req_attr_set(const struct lu_env *env, JOBSTATS_JOBID_SIZE); } -void vvp_req_completion(const struct lu_env *env, - const struct cl_req_slice *slice, int ioret) +static void vvp_req_completion(const struct lu_env *env, + const struct cl_req_slice *slice, int ioret) { struct vvp_req *vrq; diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index e0c90ad..bc4e1e4 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -192,7 +192,7 @@ static int lustre_start_simple(char *obdname, char *type, char *uuid, return rc; } -DEFINE_MUTEX(mgc_start_lock); +static DEFINE_MUTEX(mgc_start_lock); /** Set up a mgc obd to process startup logs * -- cgit v1.1 From 13a9930d15b424ab7d3b906af8ba7ff8c409edfe Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:13 +0200 Subject: staging: ks7010: add driver from Nanonote extra-repository See the TODO for details where this driver came from. Only a few minor changes were made to make the driver suitable for staging: * updated Kconfig help text and dependencies * added TODO * removed two __DATE__ and __TIME__ printouts to allow reproducible builds * added to staging main Kconfig + Makefile Tested on a Renesas Salvator-X board with a Spectec SDW-823 card. I could connect to a WPA-protected network. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/ks7010/Kconfig | 9 + drivers/staging/ks7010/Makefile | 5 + drivers/staging/ks7010/TODO | 38 + drivers/staging/ks7010/eap_packet.h | 136 ++ drivers/staging/ks7010/ks7010_config.c | 556 ++++++ drivers/staging/ks7010/ks7010_sdio.c | 1263 +++++++++++++ drivers/staging/ks7010/ks7010_sdio.h | 165 ++ drivers/staging/ks7010/ks_debug.c | 30 + drivers/staging/ks7010/ks_debug.h | 30 + drivers/staging/ks7010/ks_hostif.c | 2665 +++++++++++++++++++++++++++ drivers/staging/ks7010/ks_hostif.h | 648 +++++++ drivers/staging/ks7010/ks_wlan.h | 541 ++++++ drivers/staging/ks7010/ks_wlan_ioctl.h | 69 + drivers/staging/ks7010/ks_wlan_net.c | 3157 ++++++++++++++++++++++++++++++++ drivers/staging/ks7010/michael_mic.c | 143 ++ drivers/staging/ks7010/michael_mic.h | 29 + 18 files changed, 9487 insertions(+) create mode 100644 drivers/staging/ks7010/Kconfig create mode 100644 drivers/staging/ks7010/Makefile create mode 100644 drivers/staging/ks7010/TODO create mode 100644 drivers/staging/ks7010/eap_packet.h create mode 100644 drivers/staging/ks7010/ks7010_config.c create mode 100644 drivers/staging/ks7010/ks7010_sdio.c create mode 100644 drivers/staging/ks7010/ks7010_sdio.h create mode 100644 drivers/staging/ks7010/ks_debug.c create mode 100644 drivers/staging/ks7010/ks_debug.h create mode 100644 drivers/staging/ks7010/ks_hostif.c create mode 100644 drivers/staging/ks7010/ks_hostif.h create mode 100644 drivers/staging/ks7010/ks_wlan.h create mode 100644 drivers/staging/ks7010/ks_wlan_ioctl.h create mode 100644 drivers/staging/ks7010/ks_wlan_net.c create mode 100644 drivers/staging/ks7010/michael_mic.c create mode 100644 drivers/staging/ks7010/michael_mic.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 7c197d1..af94764 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -102,4 +102,6 @@ source "drivers/staging/most/Kconfig" source "drivers/staging/i4l/Kconfig" +source "drivers/staging/ks7010/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index a470c72..9f6009d 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -40,3 +40,4 @@ obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/ obj-$(CONFIG_WILC1000) += wilc1000/ obj-$(CONFIG_MOST) += most/ obj-$(CONFIG_ISDN_I4L) += i4l/ +obj-$(CONFIG_KS7010) += ks7010/ diff --git a/drivers/staging/ks7010/Kconfig b/drivers/staging/ks7010/Kconfig new file mode 100644 index 0000000..dfd4eed --- /dev/null +++ b/drivers/staging/ks7010/Kconfig @@ -0,0 +1,9 @@ +config KS7010 + tristate "KeyStream KS7010 SDIO support" + depends on MMC && WIRELESS + select WIRELESS_EXT + select WEXT_PRIV + help + This is a driver for KeyStream KS7010 based SDIO WIFI cards. It is + found on at least later Spectec SDW-821 (FCC-ID "S2Y-WLAN-11G-K" only, + sadly not FCC-ID "S2Y-WLAN-11B-G") and Spectec SDW-823 microSD cards. diff --git a/drivers/staging/ks7010/Makefile b/drivers/staging/ks7010/Makefile new file mode 100644 index 0000000..68b7ebf --- /dev/null +++ b/drivers/staging/ks7010/Makefile @@ -0,0 +1,5 @@ +obj-$(CONFIG_KS7010) += ks7010.o + +ccflags-y += -D_SDIO_ -DKS_WLAN_DEBUG=0 +ks7010-y := michael_mic.o ks_hostif.o ks_wlan_net.o ks_debug.o \ + ks7010_sdio.o ks7010_config.o diff --git a/drivers/staging/ks7010/TODO b/drivers/staging/ks7010/TODO new file mode 100644 index 0000000..390e821 --- /dev/null +++ b/drivers/staging/ks7010/TODO @@ -0,0 +1,38 @@ +KS7010 Linux driver +=================== + +This driver is based on source code from the Ben Nanonote extra repository [1] +which is based on the original v007 release from Renesas [2]. Some more +background info about the chipset can be found here [3] and here [4]. Thank +you to all which already participated in cleaning up the driver so far! + +[1] http://projects.qi-hardware.com/index.php/p/openwrt-packages/source/tree/master/ks7010/src +[2] http://downloads.qi-hardware.com/software/ks7010_sdio_v007.tar.bz2 +[3] http://en.qi-hardware.com/wiki/Ben_NanoNote_Wi-Fi +[4] https://wikidevi.com/wiki/Renesas + +TODO +---- + +First a few words what not to do (at least not blindly): + +- don't be overly strict with the 80 char limit. Only if it REALLY makes the + code more readable +- No '#if 0/1' removal unless the surrounding code is understood and removal is + really OK. There might be some hints hidden there. + +Now the TODOs: + +- fix codechecker warnings (checkpatch, sparse, smatch). But PLEASE make sure + that you are not only silencing the warning but really fixing code. You + should understand the change you submit. +- drop using a config file and use an upstream technique for configuration +- fix the 'card removal' event when card is inserted when booting +- driver crashes when removing the card +- check what other upstream wireless mechanisms can be used instead of the + custom ones here + +Please send any patches to: +Greg Kroah-Hartman +Wolfram Sang +Linux Driver Project Developer List diff --git a/drivers/staging/ks7010/eap_packet.h b/drivers/staging/ks7010/eap_packet.h new file mode 100644 index 0000000..b664bdd --- /dev/null +++ b/drivers/staging/ks7010/eap_packet.h @@ -0,0 +1,136 @@ +/* + * + * eap_packet.h + * $Id: eap_packet.h 991 2009-09-14 01:38:58Z sekine $ + * + */ +#ifndef EAP_PACKET_H +#define EAP_PACKET_H + +#define WBIT(n) (1 << (n)) + +#ifndef ETH_ALEN +#define ETH_ALEN 6 +#endif + +struct ether_hdr { + unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ + unsigned char h_source[ETH_ALEN]; /* source ether addr */ + unsigned char h_dest_snap; + unsigned char h_source_snap; + unsigned char h_command; + unsigned char h_vendor_id[3]; + unsigned short h_proto; /* packet type ID field */ +#define ETHER_PROTOCOL_TYPE_EAP 0x888e +#define ETHER_PROTOCOL_TYPE_IP 0x0800 +#define ETHER_PROTOCOL_TYPE_ARP 0x0806 + /* followed by length octets of data */ +} __attribute__ ((packed)); + +struct ieee802_1x_hdr { + unsigned char version; + unsigned char type; + unsigned short length; + /* followed by length octets of data */ +} __attribute__ ((packed)); + +#define EAPOL_VERSION 2 + +enum { IEEE802_1X_TYPE_EAP_PACKET = 0, + IEEE802_1X_TYPE_EAPOL_START = 1, + IEEE802_1X_TYPE_EAPOL_LOGOFF = 2, + IEEE802_1X_TYPE_EAPOL_KEY = 3, + IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4 +}; + +enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2, + EAPOL_KEY_TYPE_WPA = 254 }; + + +#define IEEE8021X_REPLAY_COUNTER_LEN 8 +#define IEEE8021X_KEY_SIGN_LEN 16 +#define IEEE8021X_KEY_IV_LEN 16 + +#define IEEE8021X_KEY_INDEX_FLAG 0x80 +#define IEEE8021X_KEY_INDEX_MASK 0x03 + +struct ieee802_1x_eapol_key { + unsigned char type; + unsigned short key_length; + /* does not repeat within the life of the keying material used to + * encrypt the Key field; 64-bit NTP timestamp MAY be used here */ + unsigned char replay_counter[IEEE8021X_REPLAY_COUNTER_LEN]; + unsigned char key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */ + unsigned char key_index; /* key flag in the most significant bit: + * 0 = broadcast (default key), + * 1 = unicast (key mapping key); key index is in the + * 7 least significant bits */ + /* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as + * the key */ + unsigned char key_signature[IEEE8021X_KEY_SIGN_LEN]; + + /* followed by key: if packet body length = 44 + key length, then the + * key field (of key_length bytes) contains the key in encrypted form; + * if packet body length = 44, key field is absent and key_length + * represents the number of least significant octets from + * MS-MPPE-Send-Key attribute to be used as the keying material; + * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */ +} __attribute__ ((packed)); + + +#define WPA_NONCE_LEN 32 +#define WPA_REPLAY_COUNTER_LEN 8 + +struct wpa_eapol_key { + unsigned char type; + unsigned short key_info; + unsigned short key_length; + unsigned char replay_counter[WPA_REPLAY_COUNTER_LEN]; + unsigned char key_nonce[WPA_NONCE_LEN]; + unsigned char key_iv[16]; + unsigned char key_rsc[8]; + unsigned char key_id[8]; /* Reserved in IEEE 802.11i/RSN */ + unsigned char key_mic[16]; + unsigned short key_data_length; + /* followed by key_data_length bytes of key_data */ +} __attribute__ ((packed)); + +#define WPA_KEY_INFO_TYPE_MASK (WBIT(0) | WBIT(1) | WBIT(2)) +#define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 WBIT(0) +#define WPA_KEY_INFO_TYPE_HMAC_SHA1_AES WBIT(1) +#define WPA_KEY_INFO_KEY_TYPE WBIT(3) /* 1 = Pairwise, 0 = Group key */ +/* bit4..5 is used in WPA, but is reserved in IEEE 802.11i/RSN */ +#define WPA_KEY_INFO_KEY_INDEX_MASK (WBIT(4) | WBIT(5)) +#define WPA_KEY_INFO_KEY_INDEX_SHIFT 4 +#define WPA_KEY_INFO_INSTALL WBIT(6) /* pairwise */ +#define WPA_KEY_INFO_TXRX WBIT(6) /* group */ +#define WPA_KEY_INFO_ACK WBIT(7) +#define WPA_KEY_INFO_MIC WBIT(8) +#define WPA_KEY_INFO_SECURE WBIT(9) +#define WPA_KEY_INFO_ERROR WBIT(10) +#define WPA_KEY_INFO_REQUEST WBIT(11) +#define WPA_KEY_INFO_ENCR_KEY_DATA WBIT(12) /* IEEE 802.11i/RSN only */ + +#define WPA_CAPABILITY_PREAUTH WBIT(0) + +#define GENERIC_INFO_ELEM 0xdd +#define RSN_INFO_ELEM 0x30 + +enum { + REASON_UNSPECIFIED = 1, + REASON_DEAUTH_LEAVING = 3, + REASON_INVALID_IE = 13, + REASON_MICHAEL_MIC_FAILURE = 14, + REASON_4WAY_HANDSHAKE_TIMEOUT = 15, + REASON_GROUP_KEY_UPDATE_TIMEOUT = 16, + REASON_IE_IN_4WAY_DIFFERS = 17, + REASON_GROUP_CIPHER_NOT_VALID = 18, + REASON_PAIRWISE_CIPHER_NOT_VALID = 19, + REASON_AKMP_NOT_VALID = 20, + REASON_UNSUPPORTED_RSN_IE_VERSION = 21, + REASON_INVALID_RSN_IE_CAPAB = 22, + REASON_IEEE_802_1X_AUTH_FAILED = 23, + REASON_CIPHER_SUITE_REJECTED = 24 +}; + +#endif /* EAP_PACKET_H */ diff --git a/drivers/staging/ks7010/ks7010_config.c b/drivers/staging/ks7010/ks7010_config.c new file mode 100644 index 0000000..4a80984 --- /dev/null +++ b/drivers/staging/ks7010/ks7010_config.c @@ -0,0 +1,556 @@ +#include +#include + +#include "ks_wlan.h" +#include "ks_hostif.h" +#include "ks_wlan_ioctl.h" +#include "ks_debug.h" + +static int wep_on_off; +#define WEP_OFF 0 +#define WEP_ON_64BIT 1 +#define WEP_ON_128BIT 2 + +static int wep_type; +#define WEP_KEY_CHARACTER 0 +#define WEP_KEY_HEX 1 + +static +void analyze_character_wep_key(struct ks_wlan_parameter *param, int wep_key_index, char *value) +{ + int i; + unsigned char wep_key[26], key_length; + + key_length = (wep_on_off == WEP_ON_64BIT) ? 5 : 13; + /* 64bit key_length = 5; 128bit key_length = 13; */ + + for (i=0; i 3) + return; + + param->wep_key[wep_key_index].size = key_length; + for (i=0; i<(param->wep_key[wep_key_index].size); i++) { + param->wep_key[wep_key_index].val[i] = wep_key[i]; + } +} + +static +void analyze_hex_wep_key(struct ks_wlan_parameter *param, int wep_key_index, char *value) +{ + unsigned char wep_end[26], i, j, key_length; + + key_length = (wep_on_off == WEP_ON_64BIT) ? 10 : 26; + /* 64bit key_length = 10; 128bit key_length = 26; */ + + for (i=0; i 3) + return ; + + param->wep_key[wep_key_index].size = key_length/2; + for (i=0; i<(param->wep_key[wep_key_index].size); i++) { + param->wep_key[wep_key_index].val[i] = wep_end[i]; + } + +} + +static +int rate_set_configuration(ks_wlan_private *priv, char *value) +{ + int rc=0; + + priv->reg.tx_rate = TX_RATE_FIXED; + priv->reg.rate_set.size = 1; + + switch(*value){ + case '1': /* 1M 11M 12M 18M */ + if(*(value+1) == '8'){ + priv->reg.rate_set.body[0] = TX_RATE_18M; + } + else if(*(value+1) == '2'){ + priv->reg.rate_set.body[0] = TX_RATE_12M|BASIC_RATE; + } + else if(*(value+1) == '1'){ + priv->reg.rate_set.body[0] = TX_RATE_11M|BASIC_RATE; + } + else{ + priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + } + break; + case '2': /* 2M 24M */ + if(*(value+1) == '4'){ + priv->reg.rate_set.body[0] = TX_RATE_24M|BASIC_RATE; + } + else{ + priv->reg.rate_set.body[0] = TX_RATE_2M|BASIC_RATE; + } + break; + case '3': /* 36M */ + priv->reg.rate_set.body[0] = TX_RATE_36M; + break; + case '4': /* 48M */ + priv->reg.rate_set.body[0] = TX_RATE_48M; + break; + case '5': /* 5.5M 54M */ + if(*(value+1) == '4'){ + priv->reg.rate_set.body[0] = TX_RATE_54M; + } + else{ + priv->reg.rate_set.body[0] = TX_RATE_5M|BASIC_RATE; + } + break; + case '6': /* 6M */ + priv->reg.rate_set.body[0] = TX_RATE_6M|BASIC_RATE; + break; + case '9': /* 9M */ + priv->reg.rate_set.body[0] = TX_RATE_9M; + break; + case 'K': + priv->reg.rate_set.body[6] = TX_RATE_36M; + priv->reg.rate_set.body[5] = TX_RATE_18M; + priv->reg.rate_set.body[4] = TX_RATE_24M|BASIC_RATE; + priv->reg.rate_set.body[3] = TX_RATE_12M|BASIC_RATE; + priv->reg.rate_set.body[2] = TX_RATE_6M|BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_11M|BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_2M|BASIC_RATE; + priv->reg.tx_rate = TX_RATE_FULL_AUTO; + priv->reg.rate_set.size = 7; + break; + default: + priv->reg.rate_set.body[11] = TX_RATE_54M; + priv->reg.rate_set.body[10] = TX_RATE_48M; + priv->reg.rate_set.body[9] = TX_RATE_36M; + priv->reg.rate_set.body[8] = TX_RATE_18M; + priv->reg.rate_set.body[7] = TX_RATE_9M; + priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; + priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; + priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; + priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; + priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.tx_rate = TX_RATE_FULL_AUTO; + priv->reg.rate_set.size = 12; + break; + } + return rc; +} + +#ifndef NO_FIRMWARE_CLASS +#include +#else +#define MAX_CONFIG_FILE_SIZE (1024*10) +#endif +int ks_wlan_read_config_file(ks_wlan_private *priv) +{ + struct { + const int key_len; + const char *key; + const char *val; + } cfg_tbl[] = { + {15,"BeaconLostCount", "20"}, /* 0 */ + {7,"Channel", "1"}, /* 1 */ + {17,"FragmentThreshold","2346"}, /* 2 */ + {13,"OperationMode","Infrastructure"}, /* 3 */ + {19,"PowerManagementMode","ACTIVE"}, /* 4 */ + {12,"RTSThreshold","2347"}, /* 5 */ + {4,"SSID","default"}, /* 6 */ + {6,"TxRate","Auto"}, /* 7 */ + {23,"AuthenticationAlgorithm",""}, /* 8 */ + {12,"WepKeyValue1",""}, /* 9 */ + {12,"WepKeyValue2",""}, /* 10 */ + {12,"WepKeyValue3",""}, /* 11 */ + {12,"WepKeyValue4",""}, /* 12 */ + {8,"WepIndex","1"}, /* 13 */ + {7,"WepType","STRING"}, /* 14 */ + {3,"Wep","OFF"}, /* 15 */ + {13,"PREAMBLE_TYPE","SHORT"}, /* 16 */ + {8,"ScanType","ACTIVE_SCAN"}, /* 17 */ + {8,"ROM_FILE", ROM_FILE}, /* 18 */ + {7,"PhyType", "BG_MODE"}, /* 19 */ + {7,"CtsMode", "FALSE"}, /* 20 */ + {19,"PhyInformationTimer", "0"}, /* 21 */ + {0,"",""}, + }; + +#ifndef NO_FIRMWARE_CLASS + const struct firmware *fw_entry; + struct device *dev = NULL; + int retval; +#else + struct file *srcf; + int nr_read ; + int retval; + char *cfg_buf=NULL; + int orgfsuid, orgfsgid; + mm_segment_t orgfs; +#endif + char cfg_file[]=CFG_FILE; + char *cur_p, *end_p; + char wk_buff[256], *wk_p; + + /* Initialize Variable */ + priv->reg.operation_mode = MODE_INFRASTRUCTURE; /* Infrastructure */ + priv->reg.channel = 10; /* 10 */ + memset(priv->reg.bssid, 0x0, ETH_ALEN); /* BSSID */ + priv->reg.ssid.body[0] = '\0'; /* SSID */ + priv->reg.ssid.size = 0; /* SSID size */ + priv->reg.tx_rate = TX_RATE_AUTO; /* TxRate Fully Auto */ + priv->reg.preamble = SHORT_PREAMBLE; /* Preamble = SHORT */ + priv->reg.powermgt = POWMGT_ACTIVE_MODE; /* POWMGT_ACTIVE_MODE */ + priv->reg.scan_type = ACTIVE_SCAN; /* Active */ + priv->reg.beacon_lost_count = 20; /* Beacon Lost Count */ + priv->reg.rts = 2347UL; /* RTS Threashold */ + priv->reg.fragment = 2346UL; /* Fragmentation Threashold */ + + strcpy(&priv->reg.rom_file[0], ROM_FILE); + + priv->skb = NULL; + + priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; /* AuthenticationAlgorithm */ + + priv->reg.privacy_invoked = 0x00; /* WEP */ + priv->reg.wep_index=0; + memset(&priv->reg.wep_key[0],0,sizeof(priv->reg.wep_key[0])); + memset(&priv->reg.wep_key[1],0,sizeof(priv->reg.wep_key[0])); + memset(&priv->reg.wep_key[2],0,sizeof(priv->reg.wep_key[0])); + memset(&priv->reg.wep_key[3],0,sizeof(priv->reg.wep_key[0])); + + priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; + priv->reg.cts_mode = CTS_MODE_FALSE; + priv->reg.phy_info_timer = 0; + priv->reg.rate_set.body[11] = TX_RATE_54M; + priv->reg.rate_set.body[10] = TX_RATE_48M; + priv->reg.rate_set.body[9] = TX_RATE_36M; + priv->reg.rate_set.body[8] = TX_RATE_18M; + priv->reg.rate_set.body[7] = TX_RATE_9M; + priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; + priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; + priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; + priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; + priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.tx_rate = TX_RATE_FULL_AUTO; + priv->reg.rate_set.size = 12; + +#ifndef NO_FIRMWARE_CLASS +#if (defined _PCMCIA_) + dev = &priv->ks_wlan_hw.pcmcia_dev->dev; +#elif (defined _PCI_) + dev = &priv->ks_wlan_hw.pci_dev->dev; +#elif (defined _SDIO_) + dev = &priv->ks_wlan_hw.sdio_card->func->dev; +#endif + if((retval = request_firmware(&fw_entry, cfg_file, dev)) !=0 ){ + DPRINTK(1, "error request_firmware() file=%s ret=%d\n", cfg_file, retval); + return 1; + } + + DPRINTK(4, "success request_firmware() file=%s size=%d\n", cfg_file, fw_entry->size); + cur_p = fw_entry->data; + end_p = cur_p + fw_entry->size; +#else + orgfsuid=current->fsuid; + orgfsgid=current->fsgid; + orgfs=get_fs(); + set_fs(KERNEL_DS); + + srcf = filp_open(cfg_file, O_RDONLY, 0); + if (IS_ERR(srcf)) { + printk(KERN_ERR "error %ld opening %s\n", -PTR_ERR(srcf),cfg_file); + goto no_config_file; + } + + if (!(srcf->f_op && srcf->f_op->read)) { + printk(KERN_ERR "%s does not have a read method\n", cfg_file); + goto no_config_file; + } + + cfg_buf = (char *)kzalloc(MAX_CONFIG_FILE_SIZE, GFP_ATOMIC); + if (!cfg_buf) { + printk(KERN_ERR "%s does not read : out of memory \n", cfg_file); + goto no_config_file; + } + + nr_read = srcf->f_op->read(srcf, (unsigned char *)cfg_buf, MAX_CONFIG_FILE_SIZE, &srcf->f_pos); + + DPRINTK(1, "read retval=%d file=%s\n", nr_read, priv->reg.cfg_file); + retval=filp_close(srcf ,NULL); + if (retval) + DPRINTK(1, "error %d closing %s\n", -retval,priv->reg.cfg_file); + + if (nr_read < 1) { + printk(KERN_ERR "%s does not read : file is empty num=%d\n", cfg_file, nr_read); + goto no_config_file; + }else if(nr_read > MAX_CONFIG_FILE_SIZE){ + printk(KERN_ERR "%s does not read : file is too big \n", cfg_file); + goto no_config_file; + } + cur_p = cfg_buf; + end_p = cur_p + nr_read; +#endif + *end_p = '\0'; + + while (cur_p < end_p) { + int i, j, len; + + len = end_p - cur_p; + for (i=0; cfg_tbl[i].key_len != 0; i++) { + if (*cur_p == '#') { + break; + } + if (len < cfg_tbl[i].key_len) { + continue; + } + if (!strncmp(cfg_tbl[i].key, cur_p, cfg_tbl[i].key_len)) { + break; + } + } + if ((*cur_p == '#') || (cfg_tbl[i].key_len == 0)) { + while (*cur_p != '\n') { + if (cur_p >= end_p) { + break; + } + cur_p++; + } + cur_p++; + } else { + cur_p += cfg_tbl[i].key_len; + if (*cur_p != '=') { + while (*cur_p != '\n') { + if (cur_p >= end_p) { + break; + } + cur_p++; + } + continue; + } + cur_p++; + + for (j=0,wk_p=cur_p; *wk_p != '\n' && wk_p < end_p; j++,wk_p++) { + wk_buff[j] = *wk_p; + } + wk_buff[j] = '\0'; + cur_p = wk_p; + DPRINTK(4,"%s=%s\n",cfg_tbl[i].key, wk_buff); + wk_p = wk_buff; + + switch (i) { + case 0: /* "BeaconLostCount", "10" */ + priv->reg.beacon_lost_count = simple_strtol(wk_buff, NULL, 10); + break; + case 1: /* "Channel", "1" */ + priv->reg.channel = simple_strtol(wk_buff, NULL, 10); + break; + case 2: /* "FragmentThreshold","2346" */ + j = simple_strtol(wk_buff, NULL, 10); + priv->reg.fragment = (unsigned long)j; + break; + case 3: /* "OperationMode","Infrastructure" */ + switch (*wk_buff) { + case 'P': + priv->reg.operation_mode = MODE_PSEUDO_ADHOC; + break; + case 'I': + priv->reg.operation_mode = MODE_INFRASTRUCTURE; + break; + case '8': + priv->reg.operation_mode = MODE_ADHOC; + break; + default: + priv->reg.operation_mode = MODE_INFRASTRUCTURE; + } + break; + case 4: /* "PowerManagementMode","POWER_ACTIVE" */ + if (!strncmp(wk_buff, "SAVE1", 5)) { + priv->reg.powermgt = POWMGT_SAVE1_MODE; + } else if (!strncmp(wk_buff, "SAVE2", 5)){ + priv->reg.powermgt = POWMGT_SAVE2_MODE; + } else { + priv->reg.powermgt = POWMGT_ACTIVE_MODE; + } + break; + case 5: /* "RTSThreshold","2347" */ + j = simple_strtol(wk_buff, NULL, 10); + priv->reg.rts = (unsigned long)j; + break; + case 6: /* "SSID","" */ + if (*wk_p != '"') + break; + wk_p++; + for (j=0; *wk_p != '"'; j++) { + if (wk_p == '\0') { + break; + } + priv->reg.ssid.body[j] = *wk_p++; + } + priv->reg.ssid.body[j] = '\0'; + priv->reg.ssid.size = j; + wk_p++; + break; + case 7: /* "TxRate","Auto" */ + rate_set_configuration(priv, wk_p); + break; + case 8: /* "AuthenticationAlgorithm","OPEN_SYSTEM" */ + switch (*wk_p) { + case 'O': /* Authenticate System : Open System */ + priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; + break; + case 'S': /* Authenticate System : Shared Key */ + priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; + break; + } + break; + case 9: /* "WepKeyValue1","" */ + case 10: /* "WepKeyValue2","" */ + case 11: /* "WepKeyValue3","" */ + case 12: /* "WepKeyValue4","" */ + if (wep_on_off != WEP_OFF) { + switch (wep_type) { + case WEP_KEY_CHARACTER: + analyze_character_wep_key(&priv->reg, (i-9), wk_p); + break; + case WEP_KEY_HEX: + analyze_hex_wep_key(&priv->reg, (i-9), wk_p); + break; + } + } + break; + case 13: /* "WepIndex","1"->0 (So, Zero Origin) */ + priv->reg.wep_index = simple_strtol(wk_buff, NULL, 10) - 1; + break; + case 14: /* "WepType","STRING" */ + if (!strncmp(wk_buff, "STRING", 6)) { + wep_type = WEP_KEY_CHARACTER; + } else { + wep_type = WEP_KEY_HEX; + } + break; + case 15: /* "Wep","OFF" */ + if (!strncmp(wk_buff, "OFF", 3)) { + priv->reg.privacy_invoked = 0x00; + wep_on_off = WEP_OFF; + } else { /* 64bit or 128bit */ + priv->reg.privacy_invoked = 0x01; + if (*wk_buff == '6') { /* 64bit */ + wep_on_off = WEP_ON_64BIT; + } else { /* 128bit */ + wep_on_off = WEP_ON_128BIT; + } + } + break; + case 16: /* "PREAMBLE_TYPE","LONG" */ + if (!strncmp(wk_buff, "SHORT", 5)) { + priv->reg.preamble = SHORT_PREAMBLE; + } else { /* "LONG" */ + priv->reg.preamble = LONG_PREAMBLE; + } + break; + case 17: /* "ScanType","ACTIVE_SCAN" */ + if (!strncmp(wk_buff, "PASSIVE_SCAN", 12)) { + priv->reg.scan_type = PASSIVE_SCAN; + } else { /* "ACTIVE_SCAN" */ + priv->reg.scan_type = ACTIVE_SCAN; + } + break; + case 18: // "ROM_FILE",ROMFILE + if (*wk_p != '"') + break; + wk_p++; + for (j=0; *wk_p != '"'; j++) { + if (wk_p == '\0') { + break; + } + priv->reg.rom_file[j] = *wk_p++; + } + priv->reg.rom_file[j] = '\0'; + wk_p++; + break; + case 19: /*"PhyType", "BG_MODE" */ + if (!strncmp(wk_buff, "B_MODE", 6)) { + priv->reg.phy_type = D_11B_ONLY_MODE; + } else if (!strncmp(wk_buff, "G_MODE", 6)) { + priv->reg.phy_type = D_11G_ONLY_MODE; + } else { + priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; + } + break; + case 20: /* "CtsMode", "FALSE" */ + if (!strncmp(wk_buff, "TRUE", 4)) { + priv->reg.cts_mode = CTS_MODE_TRUE; + } else { + priv->reg.cts_mode = CTS_MODE_FALSE; + } + break; + case 21: /* "PhyInformationTimer", "0" */ + j = simple_strtol(wk_buff, NULL, 10); + priv->reg.phy_info_timer = (uint16_t)j; + break; + default: + break; + } + if (cur_p >= end_p) { + break; + } + cur_p++; + } + + } +#ifndef NO_FIRMWARE_CLASS + release_firmware(fw_entry); +#else +no_config_file: + kfree(cfg_buf); + set_fs(orgfs); + current->fsuid=orgfsuid; + current->fsgid=orgfsgid; +#endif + + DPRINTK(3,"\n operation_mode = %d\n channel = %d\n ssid = %s\n tx_rate = %d\n \ + preamble = %d\n powermgt = %d\n scan_type = %d\n beacon_lost_count = %d\n rts = %d\n \ + fragment = %d\n privacy_invoked = %d\n wep_type = %d\n wep_on_off = %d\n wep_index = %d\n romfile = %s\n", + priv->reg.operation_mode,priv->reg.channel,&priv->reg.ssid.body[0],priv->reg.tx_rate, + priv->reg.preamble,priv->reg.powermgt,priv->reg.scan_type,priv->reg.beacon_lost_count, + priv->reg.rts,priv->reg.fragment,priv->reg.privacy_invoked,wep_type,wep_on_off,priv->reg.wep_index, + &priv->reg.rom_file[0] + ); + DPRINTK(3,"\n phy_type = %d\n cts_mode = %d\n tx_rate = %d\n phy_info_timer = %d\n", + priv->reg.phy_type,priv->reg.cts_mode,priv->reg.tx_rate,priv->reg.phy_info_timer ); + + return(0); +} + diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c new file mode 100644 index 0000000..7cc49a4 --- /dev/null +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -0,0 +1,1263 @@ +/* + * Driver for KeyStream, KS7010 based SDIO cards. + * + * ks7010_sdio.c + * $Id: ks7010_sdio.c 996 2009-09-14 02:54:21Z sekine $ + * + * Copyright (C) 2006-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#include +#include +#include +#include + +#include "ks_wlan.h" +#include "ks_wlan_ioctl.h" +#include "ks_debug.h" +#include "ks_hostif.h" + +#include "ks7010_sdio.h" + +#define KS7010_FUNC_NUM 1 +#define KS7010_IO_BLOCK_SIZE 512 +#define KS7010_MAX_CLOCK 25000000 + +static int reg_net = 0; + +static const struct sdio_device_id if_sdio_ids[] = { + { SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_A, SDIO_DEVICE_ID_KS_7010) }, + { SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_B, SDIO_DEVICE_ID_KS_7010) }, + { /* all zero */ } +}; + +struct ks_sdio_model { + int model; + const char *firmware; +}; + +static struct ks_sdio_model ks_sdio_models[] = { + { + /* ks7010 */ + .model = 0x10, + .firmware = "ks7010sd.rom", + }, +}; + +static int ks7910_sdio_probe(struct sdio_func *function, const struct sdio_device_id *device); +static void ks7910_sdio_remove(struct sdio_func *function); +static void ks7010_rw_function(struct work_struct *work); +static int ks7010_sdio_read( ks_wlan_private *priv, unsigned int address, + unsigned char *buffer, int length ); +static int ks7010_sdio_write( ks_wlan_private *priv, unsigned int address, + unsigned char *buffer, int length ); +#ifdef NO_FIRMWARE_CLASS +static char *romfile = ROM_FILE; +module_param(romfile, charp, S_IRUGO); +#endif +/* macro */ + +#define inc_txqhead(priv) \ + ( priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE ) +#define inc_txqtail(priv) \ + ( priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE ) +#define cnt_txqbody(priv) \ + (((priv->tx_dev.qtail + TX_DEVICE_BUFF_SIZE) - (priv->tx_dev.qhead)) % TX_DEVICE_BUFF_SIZE ) + +#define inc_rxqhead(priv) \ + ( priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE ) +#define inc_rxqtail(priv) \ + ( priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE ) +#define cnt_rxqbody(priv) \ + (((priv->rx_dev.qtail + RX_DEVICE_BUFF_SIZE) - (priv->rx_dev.qhead)) % RX_DEVICE_BUFF_SIZE ) + +void ks_wlan_hw_sleep_doze_request(ks_wlan_private *priv) +{ + unsigned char rw_data; + int retval; + + DPRINTK(4, "\n"); + + /* clear request */ + atomic_set(&priv->sleepstatus.doze_request,0); + + if( atomic_read(&priv->sleepstatus.status) == 0){ + rw_data = GCR_B_DOZE; + retval = ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : GCR_B=%02X\n", rw_data); + goto out; + } + DPRINTK(4, "PMG SET!! : GCR_B=%02X\n", rw_data); + DPRINTK(3,"sleep_mode=SLP_SLEEP\n"); + atomic_set(&priv->sleepstatus.status, 1); + priv->last_doze = jiffies; + } + else{ + DPRINTK(1,"sleep_mode=%d\n",priv->sleep_mode); + } + +out: + priv->sleep_mode = atomic_read(&priv->sleepstatus.status); + return; +} + +void ks_wlan_hw_sleep_wakeup_request(ks_wlan_private *priv) +{ + unsigned char rw_data; + int retval; + + DPRINTK(4, "\n"); + + /* clear request */ + atomic_set(&priv->sleepstatus.wakeup_request,0); + + if( atomic_read(&priv->sleepstatus.status) == 1){ + rw_data = WAKEUP_REQ; + retval = ks7010_sdio_write(priv, WAKEUP, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : WAKEUP=%02X\n", rw_data); + goto out; + } + DPRINTK(4, "wake up : WAKEUP=%02X\n", rw_data); + atomic_set(&priv->sleepstatus.status, 0); + priv->last_wakeup = jiffies; + ++priv->wakeup_count; + } + else{ + DPRINTK(1,"sleep_mode=%d\n",priv->sleep_mode); + } + +out: + priv->sleep_mode = atomic_read(&priv->sleepstatus.status); + return; +} + + +void ks_wlan_hw_wakeup_request(ks_wlan_private *priv) +{ + unsigned char rw_data; + int retval; + + DPRINTK(4, "\n"); + if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ + rw_data = WAKEUP_REQ; + retval = ks7010_sdio_write(priv, WAKEUP, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : WAKEUP=%02X\n", rw_data); + } + DPRINTK(4, "wake up : WAKEUP=%02X\n", rw_data); + priv->last_wakeup = jiffies; + ++priv->wakeup_count; + } + else{ + DPRINTK(1,"psstatus=%d\n",atomic_read(&priv->psstatus.status)); + } +} + +int _ks_wlan_hw_power_save(ks_wlan_private *priv) +{ + int rc=0; + unsigned char rw_data; + int retval; + + if(priv->reg.powermgt == POWMGT_ACTIVE_MODE) + return rc; + + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE && + (priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ + + //DPRINTK(1,"psstatus.status=%d\n",atomic_read(&priv->psstatus.status)); + if (priv->dev_state == DEVICE_STATE_SLEEP) { + switch(atomic_read(&priv->psstatus.status)){ + case PS_SNOOZE: /* 4 */ + break; + default: + DPRINTK(5,"\n\ + psstatus.status=%d\n\ + psstatus.confirm_wait=%d\n\ + psstatus.snooze_guard=%d\n\ + cnt_txqbody=%d\n", + atomic_read(&priv->psstatus.status), + atomic_read(&priv->psstatus.confirm_wait), + atomic_read(&priv->psstatus.snooze_guard), + cnt_txqbody(priv)); + + if(!atomic_read(&priv->psstatus.confirm_wait)&& + !atomic_read(&priv->psstatus.snooze_guard)&& + !cnt_txqbody(priv)){ + retval = ks7010_sdio_read(priv, INT_PENDING, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : INT_PENDING=%02X\n", rw_data); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + break; + } + if(!rw_data){ + rw_data = GCR_B_DOZE; + retval = ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : GCR_B=%02X\n", rw_data); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + break; + } + DPRINTK(4, "PMG SET!! : GCR_B=%02X\n", rw_data); + atomic_set(&priv->psstatus.status, PS_SNOOZE); + DPRINTK(3,"psstatus.status=PS_SNOOZE\n"); + } + else{ + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + } + } + else{ + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); + } + break; + } + } + + } + + return rc; +} + +int ks_wlan_hw_power_save(ks_wlan_private *priv) +{ + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + return 0; +} + +static int ks7010_sdio_read(ks_wlan_private *priv, unsigned int address, + unsigned char *buffer, int length) +{ + int rc = -1; + struct ks_sdio_card *card; + + card = priv->ks_wlan_hw.sdio_card; + + if (length == 1) /* CMD52 */ + *buffer = sdio_readb(card->func, address, &rc); + else /* CMD53 multi-block transfer */ + rc = sdio_memcpy_fromio(card->func, buffer, address, length); + + if(rc != 0){ + printk("sdio error erorr=%d size=%d\n", rc, length); + ++priv->sdio_error_count; + }else{ + priv->sdio_error_count=0; + } + + return rc; +} + +static int ks7010_sdio_write(ks_wlan_private *priv, unsigned int address, + unsigned char *buffer, int length) +{ + int rc = -1; + struct ks_sdio_card *card; + + card = priv->ks_wlan_hw.sdio_card; + + if (length == 1) /* CMD52 */ + sdio_writeb(card->func, *buffer, (unsigned int) address, &rc); + else /* CMD53 */ + rc = sdio_memcpy_toio(card->func, (unsigned int) address, buffer, length); + + if(rc != 0){ + printk("sdio error erorr=%d size=%d\n", rc, length); + ++priv->sdio_error_count; + }else{ + priv->sdio_error_count=0; + } + + return rc; +} + +static int enqueue_txdev(ks_wlan_private *priv, unsigned char *p, unsigned long size, + void (*complete_handler)(void *arg1, void *arg2), + void *arg1, void *arg2 ) +{ + struct tx_device_buffer *sp; + + if (priv->dev_state < DEVICE_STATE_BOOT) { + kfree(p); + if (complete_handler != NULL) + (*complete_handler)(arg1, arg2); + return 1; + } + + if ((TX_DEVICE_BUFF_SIZE - 1) <= cnt_txqbody(priv)) { + /* in case of buffer overflow */ + DPRINTK(1,"tx buffer overflow\n"); + kfree(p); + if (complete_handler != NULL) + (*complete_handler)(arg1, arg2); + return 1; + } + + sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qtail]; + sp->sendp = p; + sp->size = size; + sp->complete_handler = complete_handler; + sp->arg1 = arg1; + sp->arg2 = arg2; + inc_txqtail(priv); + + return 0; +} + +/* write data */ +static int write_to_device(ks_wlan_private *priv, unsigned char *buffer, unsigned long size ) +{ + int rc,retval; + unsigned char rw_data; + struct hostif_hdr *hdr; + hdr = (struct hostif_hdr *)buffer; + rc=0; + + DPRINTK(4,"size=%d\n", hdr->size); + if(hdr->event < HIF_DATA_REQ || HIF_REQ_MAX < hdr->event){ + DPRINTK(1,"unknown event=%04X\n",hdr->event); + return 0; + } + + retval = ks7010_sdio_write(priv, DATA_WINDOW, buffer, size); + if(retval){ + DPRINTK(1, " write error : retval=%d\n", retval); + return -4; + } + + rw_data = WRITE_STATUS_BUSY; + retval = ks7010_sdio_write(priv, WRITE_STATUS, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : WRITE_STATUS=%02X\n", rw_data); + return -3; + } + + return 0; +} + +static void tx_device_task(void *dev) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev; + struct tx_device_buffer *sp; + int rc = 0; + + DPRINTK(4, "\n"); + if(cnt_txqbody(priv)>0 && atomic_read(&priv->psstatus.status) != PS_SNOOZE){ + sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead]; + if(priv->dev_state >= DEVICE_STATE_BOOT){ + rc = write_to_device(priv, sp->sendp, sp->size); + if(rc){ + DPRINTK(1, "write_to_device error !!(%d)\n", rc); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + return; + } + + } + kfree(sp->sendp); /* allocated memory free */ + if(sp->complete_handler != NULL) /* TX Complete */ + (*sp->complete_handler)(sp->arg1, sp->arg2); + inc_txqhead(priv); + + if(cnt_txqbody(priv)>0){ + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); + } + } + return; +} + +int ks_wlan_hw_tx( ks_wlan_private *priv, void *p, unsigned long size, + void (*complete_handler)(void *arg1, void *arg2), + void *arg1, void *arg2 ) +{ + int result=0; + struct hostif_hdr *hdr; + hdr = (struct hostif_hdr *)p; + + if(hdr->event < HIF_DATA_REQ || HIF_REQ_MAX < hdr->event){ + DPRINTK(1,"unknown event=%04X\n",hdr->event); + return 0; + } + + /* add event to hostt buffer */ + priv->hostt.buff[priv->hostt.qtail] = hdr->event; + priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE; + + DPRINTK(4, "event=%04X\n",hdr->event); + spin_lock(&priv->tx_dev.tx_dev_lock); + result = enqueue_txdev(priv, p, size, complete_handler, arg1, arg2); + spin_unlock(&priv->tx_dev.tx_dev_lock); + + if(cnt_txqbody(priv)>0){ + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); + } + return result; +} + +static void rx_event_task(unsigned long dev) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev; + struct rx_device_buffer *rp; + + DPRINTK(4,"\n"); + + if(cnt_rxqbody(priv) > 0 && priv->dev_state >= DEVICE_STATE_BOOT){ + rp = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qhead]; + hostif_receive(priv, rp->data, rp->size); + inc_rxqhead(priv); + + if(cnt_rxqbody(priv) > 0){ + tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task); + } + } + + return; +} + +static void ks_wlan_hw_rx(void *dev, uint16_t size) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev; + int retval; + struct rx_device_buffer *rx_buffer; + struct hostif_hdr *hdr; + unsigned char read_status; + unsigned short event=0; + + DPRINTK(4,"\n"); + + /* receive data */ + if (cnt_rxqbody(priv) >= (RX_DEVICE_BUFF_SIZE-1)) { + /* in case of buffer overflow */ + DPRINTK(1,"rx buffer overflow \n"); + goto error_out; + } + rx_buffer = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qtail]; + + retval = ks7010_sdio_read(priv, DATA_WINDOW, &rx_buffer->data[0], hif_align_size(size)); + if(retval){ + goto error_out; + } + + /* length check */ + if(size > 2046 || size == 0){ + + DPRINTK(5,"-INVAILED DATA dump\n"); + print_buffer(&rx_buffer->data[0],32); + + /* rx_status update */ + read_status = READ_STATUS_IDLE; + retval = ks7010_sdio_write(priv, READ_STATUS, &read_status, sizeof(read_status)); + if(retval){ + DPRINTK(1, " error : READ_STATUS=%02X\n", read_status); + } + goto error_out; + } + + hdr = (struct hostif_hdr *)&rx_buffer->data[0]; + rx_buffer->size = le16_to_cpu(hdr->size) + sizeof(hdr->size); + event = hdr->event; + inc_rxqtail(priv); + + /* read status update */ + read_status = READ_STATUS_IDLE; + retval = ks7010_sdio_write(priv, READ_STATUS, &read_status, sizeof(read_status)); + if(retval){ + DPRINTK(1, " error : READ_STATUS=%02X\n", read_status); + } + DPRINTK(4, "READ_STATUS=%02X\n", read_status); + + if(atomic_read(&priv->psstatus.confirm_wait)){ + if(IS_HIF_CONF(event)){ + DPRINTK(4, "IS_HIF_CONF true !!\n"); + atomic_dec(&priv->psstatus.confirm_wait); + } + } + + /* rx_event_task((void *)priv); */ + tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task); + +error_out: + return; +} + +static void ks7010_rw_function(struct work_struct *work) +{ + struct hw_info_t *hw; + struct ks_wlan_private *priv; + unsigned char rw_data; + int retval; + + hw = container_of(work, struct hw_info_t, rw_wq.work); + priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw); + + DPRINTK(4,"\n"); + + + /* wiat after DOZE */ + if(time_after(priv->last_doze + ((30*HZ)/1000), jiffies )){ + DPRINTK(4, "wait after DOZE \n"); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + return; + } + + /* wiat after WAKEUP */ + while(time_after(priv->last_wakeup + ((30*HZ)/1000), jiffies )){ + DPRINTK(4, "wait after WAKEUP \n"); +/* queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, + (priv->last_wakeup + ((30*HZ)/1000) - jiffies));*/ + printk("wake: %lu %lu\n", priv->last_wakeup + (30* HZ)/1000, jiffies); + msleep(30); + } + + sdio_claim_host(priv->ks_wlan_hw.sdio_card->func); + + /* power save wakeup */ + if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ + if(cnt_txqbody(priv)>0){ + ks_wlan_hw_wakeup_request(priv); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + } + goto err_out; + } + + /* sleep mode doze */ + if(atomic_read(&priv->sleepstatus.doze_request)==1){ + ks_wlan_hw_sleep_doze_request(priv); + goto err_out; + } + /* sleep mode wakeup */ + if(atomic_read(&priv->sleepstatus.wakeup_request)==1){ + ks_wlan_hw_sleep_wakeup_request(priv); + goto err_out; + } + + /* read (WriteStatus/ReadDataSize FN1:00_0014) */ + retval = ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : WSTATUS_RSIZE=%02X psstatus=%d\n", rw_data,atomic_read(&priv->psstatus.status)); + goto err_out; + } + DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data); + + if(rw_data&RSIZE_MASK){ /* Read schedule */ + ks_wlan_hw_rx((void *)priv, (uint16_t)(((rw_data&RSIZE_MASK)<<4))); + } + if((rw_data&WSTATUS_MASK)){ + tx_device_task((void *)priv); + } + _ks_wlan_hw_power_save(priv); + +err_out: + sdio_release_host(priv->ks_wlan_hw.sdio_card->func); + + return; +} + + + +static void ks_sdio_interrupt(struct sdio_func *func) +{ + int retval; + struct ks_sdio_card *card; + ks_wlan_private *priv; + unsigned char status, rsize, rw_data; + + card = sdio_get_drvdata(func); + priv = card->priv; + DPRINTK(4, "\n"); + + if(priv->dev_state >= DEVICE_STATE_BOOT){ + retval = ks7010_sdio_read(priv, INT_PENDING, &status, sizeof(status)); + if(retval){ + DPRINTK(1, "read INT_PENDING Failed!!(%d)\n",retval); + goto intr_out; + } + DPRINTK(4, "INT_PENDING=%02X\n", rw_data); + + /* schedule task for interrupt status */ + /* bit7 -> Write General Communication B register */ + /* read (General Communication B register) */ + /* bit5 -> Write Status Idle */ + /* bit2 -> Read Status Busy */ + if(status&INT_GCR_B || atomic_read(&priv->psstatus.status)==PS_SNOOZE){ + retval = ks7010_sdio_read(priv, GCR_B, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : GCR_B=%02X\n", rw_data); + goto intr_out; + } + /* DPRINTK(1, "GCR_B=%02X\n", rw_data); */ + if(rw_data == GCR_B_ACTIVE){ + if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ + atomic_set(&priv->psstatus.status, PS_WAKEUP); + priv->wakeup_count=0; + } + complete(&priv->psstatus.wakeup_wait); + } + + + } + + do{ + /* read (WriteStatus/ReadDataSize FN1:00_0014) */ + retval = ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data, sizeof(rw_data)); + if(retval){ + DPRINTK(1, " error : WSTATUS_RSIZE=%02X\n", rw_data); + goto intr_out; + } + DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data); + rsize=rw_data&RSIZE_MASK; + if(rsize){ /* Read schedule */ + ks_wlan_hw_rx((void *)priv, (uint16_t)(((rsize)<<4))); + } + if(rw_data&WSTATUS_MASK){ +#if 0 + if(status&INT_WRITE_STATUS && !cnt_txqbody(priv)){ + /* dummy write for interrupt clear */ + rw_data =0; + retval = ks7010_sdio_write(priv, DATA_WINDOW, &rw_data, sizeof(rw_data)); + if (retval) { + DPRINTK(1, "write DATA_WINDOW Failed!!(%d)\n",retval); + } + status &= ~INT_WRITE_STATUS; + } + else{ +#endif + if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ + if(cnt_txqbody(priv)){ + ks_wlan_hw_wakeup_request(priv); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq, 1); + return; + } + } + else{ + tx_device_task((void *)priv); + } +// } + } + }while(rsize); + } + +intr_out: + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); + return; +} + +static int trx_device_init( ks_wlan_private *priv ) +{ + /* initialize values (tx) */ + priv->tx_dev.qtail = priv->tx_dev.qhead = 0; + + /* initialize values (rx) */ + priv->rx_dev.qtail = priv->rx_dev.qhead = 0; + + /* initialize spinLock (tx,rx) */ + spin_lock_init(&priv->tx_dev.tx_dev_lock); + spin_lock_init(&priv->rx_dev.rx_dev_lock); + + tasklet_init(&priv->ks_wlan_hw.rx_bh_task, rx_event_task, (unsigned long)priv); + + return 0; +} + +static void trx_device_exit( ks_wlan_private *priv ) +{ + struct tx_device_buffer *sp; + + /* tx buffer clear */ + while (cnt_txqbody(priv)>0) { + sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead]; + kfree(sp->sendp); /* allocated memory free */ + if (sp->complete_handler != NULL) /* TX Complete */ + (*sp->complete_handler)(sp->arg1, sp->arg2); + inc_txqhead(priv); + } + + tasklet_kill(&priv->ks_wlan_hw.rx_bh_task); + + return; +} +static int ks7010_sdio_update_index(ks_wlan_private *priv, u32 index) +{ + int rc=0; + int retval; + unsigned char *data_buf; + data_buf = NULL; + + data_buf = kmalloc(sizeof(u32), GFP_KERNEL); + if(!data_buf){ rc = 1; goto error_out; } + + memcpy(data_buf, &index, sizeof(index)); + retval = ks7010_sdio_write(priv, WRITE_INDEX, data_buf, sizeof(index)); + if(retval){ rc = 2; goto error_out; } + + retval = ks7010_sdio_write(priv, READ_INDEX, data_buf, sizeof(index)); + if(retval){ rc = 3; goto error_out; } +error_out: + if(data_buf) kfree(data_buf); + return rc; +} + +#define ROM_BUFF_SIZE (64*1024) +static int ks7010_sdio_data_compare(ks_wlan_private *priv, u32 address, + unsigned char *data, unsigned int size) +{ + int rc=0; + int retval; + unsigned char *read_buf; + read_buf = NULL; + read_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL); + if(!read_buf){ rc = 1; goto error_out; } + retval = ks7010_sdio_read(priv, address, read_buf, size); + if(retval){ rc = 2; goto error_out; } + retval = memcmp(data, read_buf, size); + + if(retval){ + DPRINTK(0, "data compare error (%d) \n",retval); rc = 3; goto error_out; + } +error_out: + if(read_buf) kfree(read_buf); + return rc; +} +#ifndef NO_FIRMWARE_CLASS +#include +#endif +static int ks79xx_upload_firmware(ks_wlan_private *priv, struct ks_sdio_card *card) +{ + unsigned int size, offset, n = 0; + unsigned char *rom_buf; + unsigned char rw_data =0; + int retval, rc=0; +#ifndef NO_FIRMWARE_CLASS + int length; + const struct firmware *fw_entry = NULL; +#else + int orgfsuid, orgfsgid; + struct file *srcf; + mm_segment_t orgfs; +#endif + + rom_buf = NULL; + + /* buffer allocate */ + rom_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL); + if(!rom_buf){ rc = 3; goto error_out0; } + + + sdio_claim_host(card->func); + + /* Firmware running ? */ + retval = ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data)); + if(rw_data == GCR_A_RUN){ + DPRINTK( 0, "MAC firmware running ...\n"); + rc = 0; + goto error_out0; + } + +#ifndef NO_FIRMWARE_CLASS + if(request_firmware(&fw_entry, priv->reg.rom_file, &priv->ks_wlan_hw.sdio_card->func->dev)!=0){ + DPRINTK(1,"error request_firmware() file=%s\n", priv->reg.rom_file); + return 1; + } + DPRINTK(4,"success request_firmware() file=%s size=%d\n", priv->reg.rom_file, fw_entry->size); + length = fw_entry->size; +#else + orgfsuid=current->fsuid; + orgfsgid=current->fsgid; + current->fsuid=current->fsgid=0; + orgfs=get_fs(); + set_fs(KERNEL_DS); + + srcf = filp_open(romfile, O_RDONLY, 0); + if (IS_ERR(srcf)) { + DPRINTK(1, "error %ld opening %s\n", -PTR_ERR(srcf),romfile); + rc = 1; + goto error_out1; + } + + if (!(srcf->f_op && srcf->f_op->read)) { + DPRINTK(1, "%s does not have a read method\n", romfile); + rc = 2; + goto error_out2; + } +#endif + + /* Load Program */ + n = 0; + do { +#ifndef NO_FIRMWARE_CLASS + if(length >= ROM_BUFF_SIZE){ + size = ROM_BUFF_SIZE; + length = length - ROM_BUFF_SIZE; + } + else{ + size=length; + length=0; + } + DPRINTK(4, "size = %d\n",size); + if(size == 0) break; + memcpy(rom_buf,fw_entry->data+n,size); +#else + /* The object must have a read method */ + size = srcf->f_op->read(srcf, rom_buf, ROM_BUFF_SIZE, &srcf->f_pos); + if (size < 0) { + DPRINTK(1, "Read %s error %d\n", priv->reg.rom_file, -retval); + rc = 5; + goto error_out2; + } + else if (size == 0) break; +#endif + /* Update write index */ + offset = n; + retval = ks7010_sdio_update_index(priv, KS7010_IRAM_ADDRESS+offset); + if(retval){ rc = 6; goto error_out1; } + + /* Write data */ + retval = ks7010_sdio_write(priv, DATA_WINDOW, rom_buf, size); + if(retval){ rc = 8; goto error_out1; } + + /* compare */ + retval = ks7010_sdio_data_compare(priv, DATA_WINDOW, rom_buf, size); + if(retval){ rc = 9; goto error_out1; } + n += size; + + }while(size); + + /* Remap request */ + rw_data = GCR_A_REMAP; + retval = ks7010_sdio_write(priv, GCR_A, &rw_data, sizeof(rw_data)); + if(retval){ + rc = 11; + goto error_out1; + } + DPRINTK( 4, " REMAP Request : GCR_A=%02X\n", rw_data); + + /* Firmware running check */ + for (n = 0; n < 50; ++n) { + mdelay(10);/* wait_ms(10); */ + retval = ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data)); + if(retval){ rc = 11; goto error_out1; } + if(rw_data == GCR_A_RUN) break; + } + DPRINTK(4, "firmware wakeup (%d)!!!!\n",n); + if ((50) <= n) { + DPRINTK(1, "firmware can't start\n"); + rc = 12; + goto error_out1; + } + + rc = 0; + +#ifdef NO_FIRMWARE_CLASS + error_out2: + retval=filp_close(srcf ,NULL); + if (retval) + DPRINTK(1, "error %d closing %s\n", -retval,priv->reg.rom_file); + + error_out1: + set_fs(orgfs); + current->fsuid=orgfsuid; + current->fsgid=orgfsgid; +#else + error_out1: + release_firmware(fw_entry); +#endif + error_out0: + sdio_release_host(card->func); + if(rom_buf) + kfree(rom_buf); + return rc; +} + +static void card_init_task(struct work_struct *work) +{ + struct hw_info_t *hw; + struct ks_wlan_private *priv; + + hw = container_of(work, struct hw_info_t, init_task); + priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw); + + DPRINTK(5,"\ncard_init_task()\n"); + + /* init_waitqueue_head(&priv->confirm_wait); */ + init_completion(&priv->confirm_wait); + + DPRINTK(5,"init_completion()\n"); + + /* get mac address & firmware version */ + hostif_sme_enqueue(priv, SME_START); + + DPRINTK(5,"hostif_sme_enqueu()\n"); + + if(!wait_for_completion_interruptible_timeout(&priv->confirm_wait,5*HZ)){ + DPRINTK(1,"wait time out!! SME_START\n"); + } + + if(priv->mac_address_valid && priv->version_size){ + priv->dev_state = DEVICE_STATE_PREINIT; + } + + hostif_sme_enqueue(priv, SME_GET_EEPROM_CKSUM); + + /* load initial wireless parameter */ + hostif_sme_enqueue(priv, SME_STOP_REQUEST); + + hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_REQUEST); + hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_REQUEST); + + hostif_sme_enqueue(priv, SME_WEP_INDEX_REQUEST); + hostif_sme_enqueue(priv, SME_WEP_KEY1_REQUEST); + hostif_sme_enqueue(priv, SME_WEP_KEY2_REQUEST); + hostif_sme_enqueue(priv, SME_WEP_KEY3_REQUEST); + hostif_sme_enqueue(priv, SME_WEP_KEY4_REQUEST); + + hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST); + hostif_sme_enqueue(priv, SME_RSN_ENABLED_REQUEST); + hostif_sme_enqueue(priv, SME_MODE_SET_REQUEST); + hostif_sme_enqueue(priv, SME_START_REQUEST); + + if(!wait_for_completion_interruptible_timeout(&priv->confirm_wait,5*HZ)){ + DPRINTK(1,"wait time out!! wireless parameter set\n"); + } + + if(priv->dev_state >= DEVICE_STATE_PREINIT){ + DPRINTK(1, "DEVICE READY!!\n"); + priv->dev_state = DEVICE_STATE_READY; + reg_net = register_netdev (priv->net_dev); + DPRINTK(3, "register_netdev=%d\n",reg_net); + } + else { + DPRINTK(1, "dev_state=%d\n",priv->dev_state); + } +} + +static struct sdio_driver ks7010_sdio_driver = { + .name = "ks7910_sdio", + .id_table = if_sdio_ids, + .probe = ks7910_sdio_probe, + .remove = ks7910_sdio_remove, +}; + + +extern int ks_wlan_net_start(struct net_device *dev); +extern int ks_wlan_net_stop(struct net_device *dev); + +static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id *device) +{ + ks_wlan_private *priv; + struct ks_sdio_card *card; + struct net_device *netdev; + unsigned char rw_data; + int i=0, ret; + + DPRINTK(5, "ks7910_sdio_probe()\n"); + + priv = NULL; + netdev=NULL; + + + /* initilize ks_sdio_card */ + card = kzalloc(sizeof(struct ks_sdio_card), GFP_KERNEL); + if (!card) + return -ENOMEM; + + card->func = func; + card->model = 0x10; + spin_lock_init(&card->lock); + + /* select model */ + for (i = 0;i < ARRAY_SIZE(ks_sdio_models);i++) { + if (card->model == ks_sdio_models[i].model) + break; + } + + if (i == ARRAY_SIZE(ks_sdio_models)) { + DPRINTK(5, "unkown card model 0x%x\n", card->model); + goto error; + } + + card->firmware = ks_sdio_models[i].firmware; + + + /*** Initialize SDIO ***/ + sdio_claim_host(func); + + /* bus setting */ + /* Issue config request to override clock rate */ + + /* function blocksize set */ + ret = sdio_set_block_size(func, KS7010_IO_BLOCK_SIZE); + DPRINTK(5, "multi_block=%d sdio_set_block_size()=%d %d\n", func->card->cccr.multi_block, func->cur_blksize, ret); + + /* Allocate the slot current */ + + /* function enable */ + ret = sdio_enable_func(func); + DPRINTK(5, "sdio_enable_func() %d\n", ret); + if (ret) + goto error_free_card; + + /* interrupt disable */ + sdio_writeb(func, 0, INT_ENABLE, &ret); + if (ret) + goto error_free_card; + sdio_writeb(func, 0xff, INT_PENDING, &ret); + if (ret) + goto error_disable_func; + + /* setup interrupt handler */ + ret = sdio_claim_irq(func, ks_sdio_interrupt); + if (ret) + goto error_disable_func; + + sdio_release_host(func); + + sdio_set_drvdata(func, card); + + DPRINTK(5, "class = 0x%X, vendor = 0x%X, " + "device = 0x%X\n", + func->class, func->vendor, func->device); + + + /* private memory allocate */ + netdev = alloc_etherdev(sizeof(*priv)); + if (netdev == NULL) { + printk (KERN_ERR "ks79xx : Unable to alloc new net device\n"); + goto error_release_irq; + } + if (dev_alloc_name(netdev, netdev->name) < 0) { + printk (KERN_ERR "ks79xx : Couldn't get name!\n"); + goto error_free_netdev; + } + + priv = netdev_priv(netdev); + + card->priv = priv; + SET_NETDEV_DEV(netdev, &card->func->dev); /* for create sysfs symlinks */ + + /* private memory initialize */ + priv->ks_wlan_hw.sdio_card = card; + init_completion(&priv->ks_wlan_hw.ks7010_sdio_wait); + priv->ks_wlan_hw.read_buf = NULL; + priv->ks_wlan_hw.read_buf = kmalloc(RX_DATA_SIZE, GFP_KERNEL); + if(!priv->ks_wlan_hw.read_buf){ + goto error_free_netdev; + } + priv->dev_state = DEVICE_STATE_PREBOOT; + priv->net_dev = netdev; + priv->firmware_version[0] = '\0'; + priv->version_size = 0; + priv->last_doze = jiffies; /* set current jiffies */ + priv->last_wakeup = jiffies; + memset(&priv->nstats, 0, sizeof(priv->nstats)); + memset(&priv->wstats, 0, sizeof(priv->wstats)); + + /* sleep mode */ + atomic_set(&priv->sleepstatus.doze_request,0); + atomic_set(&priv->sleepstatus.wakeup_request,0); + atomic_set(&priv->sleepstatus.wakeup_request,0); + + trx_device_init(priv); + hostif_init(priv); + ks_wlan_net_start(netdev); + + /* Read config file */ + ret = ks_wlan_read_config_file(priv); + if (ret) { + printk(KERN_ERR "ks79xx: read configuration file failed !! retern code = %d\n", ret); + goto error_free_read_buf; + } + + /* Upload firmware */ + ret = ks79xx_upload_firmware(priv, card); /* firmware load */ + if(ret){ + printk(KERN_ERR "ks79xx: firmware load failed !! retern code = %d\n", ret); + goto error_free_read_buf; + } + + /* interrupt setting */ + /* clear Interrupt status write (ARMtoSD_InterruptPending FN1:00_0024) */ + rw_data = 0xff; + sdio_claim_host(func); + ret = ks7010_sdio_write(priv, INT_PENDING, &rw_data, sizeof(rw_data)); + sdio_release_host(func); + if(ret){ + DPRINTK(1, " error : INT_PENDING=%02X\n", rw_data); + } + DPRINTK(4, " clear Interrupt : INT_PENDING=%02X\n", rw_data); + + + /* enable ks7010sdio interrupt (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS) */ + rw_data = (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS); + sdio_claim_host(func); + ret = ks7010_sdio_write(priv, INT_ENABLE, &rw_data, sizeof(rw_data)); + sdio_release_host(func); + if(ret){ + DPRINTK(1, " error : INT_ENABLE=%02X\n", rw_data); + } + DPRINTK(4, " enable Interrupt : INT_ENABLE=%02X\n", rw_data); + priv->dev_state = DEVICE_STATE_BOOT; + + priv->ks_wlan_hw.ks7010sdio_wq = create_workqueue("ks7010sdio_wq"); + if(!priv->ks_wlan_hw.ks7010sdio_wq){ + DPRINTK(1, "create_workqueue failed !!\n"); + goto error_free_read_buf; + } + + priv->ks_wlan_hw.ks7010sdio_init = create_singlethread_workqueue("ks7010sdio_init"); + if(!priv->ks_wlan_hw.ks7010sdio_init){ + DPRINTK(1, "create_workqueue failed !!\n"); + goto error_free_sdio_wq; + } + + INIT_WORK(&priv->ks_wlan_hw.init_task, card_init_task); + INIT_DELAYED_WORK(&priv->ks_wlan_hw.rw_wq, ks7010_rw_function); + + queue_work(priv->ks_wlan_hw.ks7010sdio_init, &priv->ks_wlan_hw.init_task); + + return 0; + +error_free_sdio_wq: + flush_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); + destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); + priv->ks_wlan_hw.ks7010sdio_wq = NULL; +error_free_read_buf: + kfree(priv->ks_wlan_hw.read_buf); + priv->ks_wlan_hw.read_buf = NULL; +error_free_netdev: + free_netdev(priv->net_dev); + card->priv = NULL; +error_release_irq: + sdio_claim_host(func); + sdio_release_irq(func); +error_disable_func: + sdio_disable_func(func); +error_free_card: + sdio_release_host(func); + sdio_set_drvdata(func, NULL); + kfree(card); +error: + return -ENODEV; +} + +static void ks7910_sdio_remove(struct sdio_func *func) +{ + int ret; + struct ks_sdio_card *card; + struct ks_wlan_private *priv; + struct net_device *netdev; + DPRINTK(1, "ks7910_sdio_remove()\n"); + + card = sdio_get_drvdata(func); + + if(card == NULL) + return; + + DPRINTK(1, "priv = card->priv\n"); + priv = card->priv; + netdev = priv->net_dev; + if(priv){ + ks_wlan_net_stop(netdev); + DPRINTK(1, "ks_wlan_net_stop\n"); + + /* interrupt disable */ + sdio_claim_host(func); + sdio_writeb(func, 0, INT_ENABLE, &ret); + sdio_writeb(func, 0xff, INT_PENDING, &ret); + sdio_release_host(func); + DPRINTK(1, "interrupt disable\n"); + + /* send stop request to MAC */ + { + struct hostif_stop_request_t *pp; + pp = (struct hostif_stop_request_t *)kzalloc(hif_align_size(sizeof(*pp)), GFP_KERNEL ); + if (pp==NULL) { + DPRINTK(3,"allocate memory failed..\n"); + return; /* to do goto ni suru*/ + } + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ); + + sdio_claim_host(func); + write_to_device(priv, (unsigned char *) pp, hif_align_size(sizeof(*pp))); + sdio_release_host(func); + kfree(pp); + } + DPRINTK(1, "STOP Req\n"); + + if(priv->ks_wlan_hw.ks7010sdio_wq){ + flush_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); + destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); + } + DPRINTK(1, "destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq);\n"); + + if(priv->ks_wlan_hw.ks7010sdio_init){ + flush_workqueue(priv->ks_wlan_hw.ks7010sdio_init); + destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_init); + } + DPRINTK(1, "destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_init);\n"); + + hostif_exit(priv); + DPRINTK(1, "hostif_exit\n"); + + if(!reg_net) + unregister_netdev(netdev); + DPRINTK(1, "unregister_netdev\n"); + + trx_device_exit(priv); + if(priv->ks_wlan_hw.read_buf){ + kfree(priv->ks_wlan_hw.read_buf); + } + free_netdev(priv->net_dev); + card->priv = NULL; + } + + sdio_claim_host(func); + sdio_release_irq(func); + DPRINTK(1, "sdio_release_irq()\n"); + sdio_disable_func(func); + DPRINTK(1, "sdio_disable_func()\n"); + sdio_release_host(func); + + sdio_set_drvdata(func, NULL); + + kfree(card); + DPRINTK(1, "kfree()\n"); + + + DPRINTK(5," Bye !!\n"); + return; +} + +static int __init ks7010_sdio_init( void ) +{ + int status; + + /* register with bus driver core */ + status = sdio_register_driver(&ks7010_sdio_driver); + if(status != 0){ + DPRINTK(1,"ks79xx_sdio : failed to register with bus driver, %d\n", status ); + } + return status; +} + +static void __exit ks7010_sdio_exit( void ) +{ + DPRINTK(5," \n"); + sdio_unregister_driver(&ks7010_sdio_driver); + return; +} + +module_init(ks7010_sdio_init); +module_exit(ks7010_sdio_exit); + +MODULE_AUTHOR("Qi-Hardware based on KeyStream driver"); +MODULE_DESCRIPTION("Driver for KeyStream, KS7010 based SDIO cards. "); +#ifdef MODULE_LICENSE +MODULE_LICENSE("GPL"); +#endif +MODULE_SUPPORTED_DEVICE("KS7910"); diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h new file mode 100644 index 0000000..3af742f --- /dev/null +++ b/drivers/staging/ks7010/ks7010_sdio.h @@ -0,0 +1,165 @@ +/* + * + * Driver for KeyStream, KS7010 based SDIO cards. + * + * ks7010_sdio.h + * $Id: ks7010_sdio.h 1019 2009-09-28 05:41:07Z sekine $ + * + * Copyright (C) 2006-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ +#ifndef _KS7010_SDIO_H +#define _KS7010_SDIO_H + +#ifdef DEVICE_ALIGNMENT +#undef DEVICE_ALIGNMENT +#endif +#define DEVICE_ALIGNMENT 32 + +/* SDIO KeyStream vendor and device */ +#define SDIO_VENDOR_ID_KS_CODE_A 0x005b +#define SDIO_VENDOR_ID_KS_CODE_B 0x0023 +#define SDIO_DEVICE_ID_KS_7010 0x7910 + +/* Read Status Register */ +#define READ_STATUS 0x000000 +#define READ_STATUS_BUSY 0 +#define READ_STATUS_IDLE 1 + +/* Read Index Register */ +#define READ_INDEX 0x000004 + +/* Read Data Size Register */ +#define READ_DATA_SIZE 0x000008 + +/* Write Status Register */ +#define WRITE_STATUS 0x00000C +#define WRITE_STATUS_BUSY 0 +#define WRITE_STATUS_IDLE 1 + +/* Write Index Register */ +#define WRITE_INDEX 0x000010 + +/* Write Status/Read Data Size Register + * for network packet (less than 2048 bytes data) + */ +#define WSTATUS_RSIZE 0x000014 +#define WSTATUS_MASK 0x80 /* Write Status Register value */ +#define RSIZE_MASK 0x7F /* Read Data Size Register value [10:4] */ + +/* ARM to SD interrupt Enable */ +#define INT_ENABLE 0x000020 +/* ARM to SD interrupt Pending */ +#define INT_PENDING 0x000024 + +#define INT_GCR_B (1<<7) +#define INT_GCR_A (1<<6) +#define INT_WRITE_STATUS (1<<5) +#define INT_WRITE_INDEX (1<<4) +#define INT_WRITE_SIZE (1<<3) +#define INT_READ_STATUS (1<<2) +#define INT_READ_INDEX (1<<1) +#define INT_READ_SIZE (1<<0) + +/* General Communication Register A */ +#define GCR_A 0x000028 +#define GCR_A_INIT 0 +#define GCR_A_REMAP 1 +#define GCR_A_RUN 2 + +/* General Communication Register B */ +#define GCR_B 0x00002C +#define GCR_B_ACTIVE 0 +#define GCR_B_DOZE 1 + +/* Wakeup Register */ +/* #define WAKEUP 0x008104 */ +/* #define WAKEUP_REQ 0x00 */ +#define WAKEUP 0x008018 +#define WAKEUP_REQ 0x5a + +/* AHB Data Window 0x010000-0x01FFFF */ +#define DATA_WINDOW 0x010000 +#define WINDOW_SIZE 64*1024 + +#define KS7010_IRAM_ADDRESS 0x06000000 + + +/* + * struct define + */ +struct hw_info_t { + struct ks_sdio_card *sdio_card; + struct completion ks7010_sdio_wait; + struct workqueue_struct *ks7010sdio_wq; + struct workqueue_struct *ks7010sdio_init; + struct work_struct init_task; + struct delayed_work rw_wq; + unsigned char *read_buf; + struct tasklet_struct rx_bh_task; +}; + +struct ks_sdio_packet { + struct ks_sdio_packet *next; + u16 nb; + u8 buffer[0] __attribute__((aligned(4))); +}; + + +struct ks_sdio_card { + struct sdio_func *func; + struct ks_wlan_private *priv; + int model; + const char *firmware; + spinlock_t lock; +}; + + + +/* Tx Device struct */ +#define TX_DEVICE_BUFF_SIZE 1024 + +struct tx_device_buffer { + unsigned char *sendp; /* pointer of send req data */ + unsigned int size; + void (*complete_handler)(void *arg1, void *arg2); + void *arg1; + void *arg2; +}; + +struct tx_device{ + struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE]; + unsigned int qhead; /* tx buffer queue first pointer */ + unsigned int qtail; /* tx buffer queue last pointer */ + spinlock_t tx_dev_lock; +}; + +/* Rx Device struct */ +#define RX_DATA_SIZE (2 + 2 + 2347 + 1) +#define RX_DEVICE_BUFF_SIZE 32 + +struct rx_device_buffer { + unsigned char data[RX_DATA_SIZE]; + unsigned int size; +}; + +struct rx_device{ + struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE]; + unsigned int qhead; /* rx buffer queue first pointer */ + unsigned int qtail; /* rx buffer queue last pointer */ + spinlock_t rx_dev_lock; +}; +#ifndef NO_FIRMWARE_CLASS +#define ROM_FILE "ks7010sd.rom" +#define CFG_FILE "ks79xx.cfg" +#else +#define ROM_FILE "/lib/firmware/ks7010sd.rom" +#define CFG_FILE "/lib/firmware/ks79xx.cfg" +#endif +#define KS_WLAN_DRIVER_VERSION_INFO "ks7010 sdio linux 007" + +#endif /* _KS7010_SDIO_H */ diff --git a/drivers/staging/ks7010/ks_debug.c b/drivers/staging/ks7010/ks_debug.c new file mode 100644 index 0000000..009f5f6 --- /dev/null +++ b/drivers/staging/ks7010/ks_debug.c @@ -0,0 +1,30 @@ +/* + * Driver for KeyStream 11b/g wireless LAN cards. + * + * ks_debug.c + * $Id: ks_debug.c 991 2009-09-14 01:38:58Z sekine $ + * + * Copyright (C) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ +#include "ks_wlan.h" +#include "ks_debug.h" + +void print_buffer(unsigned char *p, int length) +{ +#ifdef KS_WLAN_DEBUG + int i; +#define HEX_OFFSET "\ + +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F" + printk(HEX_OFFSET); + for (i=0; i + + +#ifdef KS_WLAN_DEBUG +#define DPRINTK(n, fmt, args...) \ + if (KS_WLAN_DEBUG>(n)) printk(KERN_NOTICE "%s: "fmt, __FUNCTION__, ## args) +#else +#define DPRINTK(n, fmt, args...) +#endif + +extern void print_buffer(unsigned char *p, int size); + +#endif /* _KS_DEBUG_H */ diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c new file mode 100644 index 0000000..402ddba --- /dev/null +++ b/drivers/staging/ks7010/ks_hostif.c @@ -0,0 +1,2665 @@ +/* + * Driver for KeyStream wireless LAN cards. + * + * ks_hostif.c + * $Id: ks_hostif.c 996 2009-09-14 02:54:21Z sekine $ + * + * Copyright (C) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#include "ks_wlan.h" +#include "ks_debug.h" +#include "ks_hostif.h" +#include "eap_packet.h" +#include "michael_mic.h" + +#include +#include + +/* Include Wireless Extension definition and check version */ +#ifndef WIRELESS_EXT +#include +#endif /* WIRELESS_EXT */ +#if WIRELESS_EXT > 12 +#include /* New driver API */ +#endif /* WIRELESS_EXT > 12 */ + +extern int ks_wlan_hw_tx(ks_wlan_private *priv, void *p, unsigned long size, + void (*complete_handler)(void *arg1, void *arg2), + void *arg1, void *arg2 ); +extern void send_packet_complete(void *, void *); + +extern void ks_wlan_hw_wakeup_request(ks_wlan_private *priv); +extern int ks_wlan_hw_power_save(ks_wlan_private *priv); + +/* macro */ +#define inc_smeqhead(priv) \ + ( priv->sme_i.qhead = (priv->sme_i.qhead + 1) % SME_EVENT_BUFF_SIZE ) +#define inc_smeqtail(priv) \ + ( priv->sme_i.qtail = (priv->sme_i.qtail + 1) % SME_EVENT_BUFF_SIZE ) +#define cnt_smeqbody(priv) \ + (((priv->sme_i.qtail + SME_EVENT_BUFF_SIZE) - (priv->sme_i.qhead)) % SME_EVENT_BUFF_SIZE ) + +#define KS_WLAN_MEM_FLAG (GFP_ATOMIC) + +static +inline u8 get_BYTE(ks_wlan_private *priv) +{ + u8 data; + data = *(priv->rxp)++; + /* length check in advance ! */ + --(priv->rx_size); + return data; +} + +static +inline u16 get_WORD(ks_wlan_private *priv) +{ + u16 data; + data = (get_BYTE(priv) & 0xff); + data |= ((get_BYTE(priv) << 8) & 0xff00); + return data; +} + +static +inline u32 get_DWORD(ks_wlan_private *priv) +{ + u32 data; + data = (get_BYTE(priv) & 0xff); + data |= ((get_BYTE(priv) << 8) & 0x0000ff00); + data |= ((get_BYTE(priv) << 16) & 0x00ff0000); + data |= ((get_BYTE(priv) << 24) & 0xff000000); + return data; +} + +void ks_wlan_hw_wakeup_task(struct work_struct *work) +{ + ks_wlan_private *priv = container_of(work, struct ks_wlan_private, ks_wlan_wakeup_task); + int ps_status = atomic_read(&priv->psstatus.status); + + if(ps_status==PS_SNOOZE){ + ks_wlan_hw_wakeup_request(priv); + if(!wait_for_completion_interruptible_timeout(&priv->psstatus.wakeup_wait,HZ/50)){ /* 20ms timeout */ + DPRINTK(1,"wake up timeout !!!\n"); + schedule_work(&priv->ks_wlan_wakeup_task); + return; + } + } + else{ + DPRINTK(1,"ps_status=%d\n",ps_status); + } + + /* power save */ + if(atomic_read(&priv->sme_task.count) > 0){ + DPRINTK(4,"sme task enable.\n"); + tasklet_enable(&priv->sme_task); + } +} + +static +int ks_wlan_do_power_save(ks_wlan_private *priv) +{ + int rc=0; + + DPRINTK(4,"psstatus.status=%d\n",atomic_read(&priv->psstatus.status)); + +#ifdef _SDIO_ + if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ + hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); + } + else{ + priv->dev_state = DEVICE_STATE_READY; + } +#else + if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ + switch(atomic_read(&priv->psstatus.status)){ + case PS_ACTIVE_SET: + case PS_WAKEUP: + case PS_SAVE_SET: + case PS_SNOOZE: + break; + case PS_CONF_WAIT: + atomic_set(&priv->psstatus.confirm_wait,0); + break; + case PS_NONE: + default: + hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); + break; + } + + } + else{ + switch(atomic_read(&priv->psstatus.status)){ + case PS_ACTIVE_SET: + case PS_WAKEUP: + case PS_SAVE_SET: + break; + case PS_CONF_WAIT: + atomic_set(&priv->psstatus.confirm_wait,0); + atomic_set(&priv->psstatus.status, PS_WAKEUP); + break; + case PS_SNOOZE: + ks_wlan_hw_power_save(priv); + break; + case PS_NONE: + default: + hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); + break; + } + } +#endif + return rc; +} + +static +int get_current_ap(ks_wlan_private *priv, struct link_ap_info_t *ap_info) +{ + struct local_ap_t *ap; +#if WIRELESS_EXT > 13 + union iwreq_data wrqu; + struct net_device *netdev=priv->net_dev; +#endif /* WIRELESS_EXT > 13 */ + int rc=0; + + DPRINTK(3,"\n"); + ap = &(priv->current_ap); + + if((priv->connect_status & CONNECT_STATUS_MASK)== DISCONNECT_STATUS){ + memset(ap,0,sizeof(struct local_ap_t)); + return 1; + } + + /* bssid */ + memcpy(&(ap->bssid[0]),&(ap_info->bssid[0]),ETH_ALEN); + /* essid */ + memcpy(&(ap->ssid.body[0]),&(priv->reg.ssid.body[0]),priv->reg.ssid.size); + ap->ssid.size = priv->reg.ssid.size; + /* rate_set */ + memcpy(&(ap->rate_set.body[0]),&(ap_info->rate_set.body[0]),ap_info->rate_set.size); + ap->rate_set.size = ap_info->rate_set.size; + if(ap_info->ext_rate_set.size){ + /* rate_set */ + memcpy(&(ap->rate_set.body[ap->rate_set.size]), + &(ap_info->ext_rate_set.body[0]), + ap_info->ext_rate_set.size); + ap->rate_set.size += ap_info->ext_rate_set.size; + } + /* channel */ + ap->channel = ap_info->ds_parameter.channel; + /* rssi */ + ap->rssi = ap_info->rssi; + /* sq */ + ap->sq = ap_info->sq; + /* noise */ + ap->noise = ap_info->noise; + /* capability */ + ap->capability = ap_info->capability; + /* rsn */ + if((ap_info->rsn_mode & RSN_MODE_WPA2) && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)){ + ap->rsn_ie.id = 0x30; + if(ap_info->rsn.size <= RSN_IE_BODY_MAX){ + ap->rsn_ie.size = ap_info->rsn.size; + memcpy(&(ap->rsn_ie.body[0]),&(ap_info->rsn.body[0]),ap_info->rsn.size); + } + else{ + ap->rsn_ie.size = RSN_IE_BODY_MAX; + memcpy(&(ap->rsn_ie.body[0]),&(ap_info->rsn.body[0]),RSN_IE_BODY_MAX); + } + } + else if((ap_info->rsn_mode & RSN_MODE_WPA) && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA)){ + ap->wpa_ie.id = 0xdd; + if(ap_info->rsn.size <= RSN_IE_BODY_MAX){ + ap->wpa_ie.size = ap_info->rsn.size; + memcpy(&(ap->wpa_ie.body[0]),&(ap_info->rsn.body[0]),ap_info->rsn.size); + } + else{ + ap->wpa_ie.size = RSN_IE_BODY_MAX; + memcpy(&(ap->wpa_ie.body[0]),&(ap_info->rsn.body[0]),RSN_IE_BODY_MAX); + } + } + else{ + ap->rsn_ie.id = 0; + ap->rsn_ie.size = 0; + ap->wpa_ie.id = 0; + ap->wpa_ie.size = 0; + } + +#if WIRELESS_EXT > 13 + wrqu.data.length = 0; + wrqu.data.flags = 0; + wrqu.ap_addr.sa_family = ARPHRD_ETHER; + if((priv->connect_status & CONNECT_STATUS_MASK)==CONNECT_STATUS){ + memcpy(wrqu.ap_addr.sa_data, + &(priv->current_ap.bssid[0]), ETH_ALEN); + DPRINTK(3,"IWEVENT: connect bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", + (unsigned char)wrqu.ap_addr.sa_data[0],(unsigned char)wrqu.ap_addr.sa_data[1], + (unsigned char)wrqu.ap_addr.sa_data[2],(unsigned char)wrqu.ap_addr.sa_data[3], + (unsigned char)wrqu.ap_addr.sa_data[4],(unsigned char)wrqu.ap_addr.sa_data[5]); + wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL); + } +#endif + DPRINTK(4,"\n Link AP\n"); + DPRINTK(4," bssid=%02X:%02X:%02X:%02X:%02X:%02X\n \ + essid=%s\n rate_set=%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X\n channel=%d\n \ + rssi=%d\n sq=%d\n capability=%04X\n", + ap->bssid[0],ap->bssid[1],ap->bssid[2],ap->bssid[3],ap->bssid[4], + ap->bssid[5],&(ap->ssid.body[0]),ap->rate_set.body[0],ap->rate_set.body[1], + ap->rate_set.body[2],ap->rate_set.body[3],ap->rate_set.body[4], + ap->rate_set.body[5],ap->rate_set.body[6],ap->rate_set.body[7], + ap->channel,ap->rssi,ap->sq,ap->capability); + DPRINTK(4,"\n Link AP\n rsn.mode=%d\n rsn.size=%d\n", + ap_info->rsn_mode,ap_info->rsn.size); + DPRINTK(4,"\n ext_rate_set_size=%d\n rate_set_size=%d\n", + ap_info->ext_rate_set.size,ap_info->rate_set.size); + + + return rc; +} + +static +int get_ap_information(ks_wlan_private *priv, struct ap_info_t *ap_info, struct local_ap_t *ap) +{ + unsigned char *bp; + int bsize,offset; + int rc=0; + + DPRINTK(3,"\n"); + memset(ap,0,sizeof(struct local_ap_t)); + + /* bssid */ + memcpy(&(ap->bssid[0]),&(ap_info->bssid[0]),ETH_ALEN); + /* rssi */ + ap->rssi = ap_info->rssi; + /* sq */ + ap->sq = ap_info->sq; + /* noise */ + ap->noise = ap_info->noise; + /* capability */ + ap->capability = ap_info->capability; + /* channel */ + ap->channel = ap_info->ch_info; + + bp = &(ap_info->body[0]); + bsize = ap_info->body_size; + offset = 0; + + while(bsize > offset){ + /* DPRINTK(4, "Element ID=%d \n",*bp); */ + switch(*bp){ + case 0: /* ssid */ + if(*(bp+1) <= SSID_MAX_SIZE){ + ap->ssid.size = *(bp+1); + } + else { + DPRINTK(1, "size over :: ssid size=%d \n",*(bp+1)); + ap->ssid.size = SSID_MAX_SIZE; + } + memcpy(&(ap->ssid.body[0]),bp+2,ap->ssid.size); + break; + case 1: /* rate */ + case 50: /* ext rate */ + if((*(bp+1) + ap->rate_set.size) <= RATE_SET_MAX_SIZE){ + memcpy(&(ap->rate_set.body[ap->rate_set.size]),bp+2,*(bp+1)); + ap->rate_set.size += *(bp+1); + } + else{ + DPRINTK(1, "size over :: rate size=%d \n", + (*(bp+1) + ap->rate_set.size)); + memcpy(&(ap->rate_set.body[ap->rate_set.size]),bp+2, + RATE_SET_MAX_SIZE - ap->rate_set.size); + ap->rate_set.size += (RATE_SET_MAX_SIZE - ap->rate_set.size); + } + break; + case 3: /* DS parameter */ + break; + case 48: /* RSN(WPA2) */ + ap->rsn_ie.id = *bp; + if(*(bp+1) <= RSN_IE_BODY_MAX){ + ap->rsn_ie.size = *(bp+1); + }else{ + DPRINTK(1, "size over :: rsn size=%d \n",*(bp+1)); + ap->rsn_ie.size = RSN_IE_BODY_MAX; + } + memcpy(&(ap->rsn_ie.body[0]),bp+2,ap->rsn_ie.size); + break; + case 221: /* WPA */ + if(!memcmp(bp+2, "\x00\x50\xf2\x01", 4)){ /* WPA OUI check */ + ap->wpa_ie.id = *bp; + if(*(bp+1) <= RSN_IE_BODY_MAX){ + ap->wpa_ie.size = *(bp+1); + }else{ + DPRINTK(1, "size over :: wpa size=%d \n",*(bp+1)); + ap->wpa_ie.size = RSN_IE_BODY_MAX; + } + memcpy(&(ap->wpa_ie.body[0]),bp+2,ap->wpa_ie.size); + } + break; + + case 2: /* FH parameter */ + case 4: /* CF parameter */ + case 5: /* TIM */ + case 6: /* IBSS parameter */ + case 7: /* Country */ + case 42: /* ERP information */ + case 47: /* Reserve ID 47 Broadcom AP */ + break; + default: + DPRINTK(4, "unknown Element ID=%d \n",*bp); + break; + } + offset += 2; /* id & size field */ + offset += *(bp+1); /* +size offset */ + bp += (*(bp+1) + 2); /* pointer update */ + } + + return rc; +} + +static +void hostif_data_indication(ks_wlan_private *priv) +{ + unsigned int rx_ind_size; /* indicate data size */ + struct sk_buff *skb; + unsigned short auth_type; + unsigned char temp[256]; + + unsigned char RecvMIC[8]; + char buf[128]; + struct ether_hdr *eth_hdr; + unsigned short eth_proto; + unsigned long now; + struct mic_failure_t *mic_failure; + struct ieee802_1x_hdr *aa1x_hdr; + struct wpa_eapol_key *eap_key; + struct michel_mic_t michel_mic; +#if WIRELESS_EXT > 14 + union iwreq_data wrqu; +#endif /* WIRELESS_EXT > 14 */ + + DPRINTK(3,"\n"); + + /* min length check */ + if (priv->rx_size <= ETH_HLEN) { + DPRINTK(3,"rx_size = %d\n", priv->rx_size); + priv->nstats.rx_errors++; + return; + } + + auth_type = get_WORD(priv); /* AuthType */ + get_WORD(priv); /* Reserve Area */ + + eth_hdr = (struct ether_hdr *)(priv->rxp); + eth_proto = ntohs(eth_hdr->h_proto); + DPRINTK(3,"ether protocol = %04X\n", eth_proto); + + /* source address check */ + if (!memcmp(&priv->eth_addr[0],eth_hdr->h_source, ETH_ALEN)){ + DPRINTK(1, "invalid : source is own mac address !!\n"); + DPRINTK(1, "eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n", + eth_hdr->h_source[0],eth_hdr->h_source[1],eth_hdr->h_source[2], + eth_hdr->h_source[3],eth_hdr->h_source[4],eth_hdr->h_source[5]); + priv->nstats.rx_errors++; + return; + } + + /* for WPA */ + if (auth_type != TYPE_DATA && priv->wpa.rsn_enabled){ + if(memcmp(ð_hdr->h_source[0],&priv->eth_addr[0],ETH_ALEN)){ /* source address check */ + if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap){ + DPRINTK(1,"invalid data format\n"); + priv->nstats.rx_errors++; + return; + } + if(((auth_type==TYPE_PMK1 && priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP)|| + (auth_type==TYPE_GMK1 && priv->wpa.group_suite == IW_AUTH_CIPHER_TKIP)|| + (auth_type==TYPE_GMK2 && priv->wpa.group_suite == IW_AUTH_CIPHER_TKIP)) + && priv->wpa.key[auth_type-1].key_len){ + DPRINTK(4,"TKIP: protocol=%04X: size=%u\n", eth_proto, priv->rx_size); + /* MIC save */ + memcpy(&RecvMIC[0], (priv->rxp)+((priv->rx_size)-8), 8); + priv->rx_size = priv->rx_size - 8; + if(auth_type > 0 && auth_type < 4){ /* auth_type check */ + MichaelMICFunction(&michel_mic, + (uint8_t*)priv->wpa.key[auth_type-1].rx_mic_key, + (uint8_t*)priv->rxp, + (int)priv->rx_size, + (uint8_t)0, /* priority */ + (uint8_t*)michel_mic.Result); + } + if(memcmp(michel_mic.Result, RecvMIC, 8)){ + now = jiffies; + mic_failure = &priv->wpa.mic_failure; + /* MIC FAILURE */ + if(mic_failure->last_failure_time && + (now - mic_failure->last_failure_time)/HZ >= 60){ + mic_failure->failure=0; + } + DPRINTK(4,"MIC FAILURE \n"); + if(mic_failure->failure==0){ + mic_failure->failure=1; + mic_failure->counter=0; + }else if(mic_failure->failure==1){ + mic_failure->failure=2; + mic_failure->counter = + (uint16_t)((now - mic_failure->last_failure_time)/HZ); + if(!mic_failure->counter) /* mic_failure counter value range 1-60 */ + mic_failure->counter = 1; + } + priv->wpa.mic_failure.last_failure_time = now; +#if WIRELESS_EXT > 14 + /* needed parameters: count, keyid, key type, TSC */ + sprintf(buf, "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=" + "%02x:%02x:%02x:%02x:%02x:%02x)", + auth_type-1, eth_hdr->h_dest[0] & 0x01 ? "broad" : "uni", + eth_hdr->h_source[0],eth_hdr->h_source[1], + eth_hdr->h_source[2],eth_hdr->h_source[3], + eth_hdr->h_source[4],eth_hdr->h_source[5]); + memset(&wrqu, 0, sizeof(wrqu)); + wrqu.data.length = strlen(buf); + DPRINTK(4,"IWEVENT:MICHAELMICFAILURE\n"); + wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf); +#endif /* WIRELESS_EXT > 14 */ + return; + } + } + } + } + + if((priv->connect_status & FORCE_DISCONNECT)|| + priv->wpa.mic_failure.failure==2){ + return; + } + + /* check 13th byte at rx data */ + switch (*(priv->rxp+12)) { + case 0xAA: /* SNAP */ + rx_ind_size = priv->rx_size - 6; + skb = dev_alloc_skb (rx_ind_size); + DPRINTK(4,"SNAP, rx_ind_size = %d\n", rx_ind_size); + + if(skb) { + memcpy(skb_put(skb,12),priv->rxp,12); /* 8802/FDDI MAC copy */ + /* (SNAP+UI..) skip */ + memcpy(skb_put(skb,rx_ind_size-12),priv->rxp+18,rx_ind_size-12); /* copy after Type */ + + aa1x_hdr=(struct ieee802_1x_hdr *)(priv->rxp+20); + if(aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY && priv->wpa.rsn_enabled){ + eap_key = (struct wpa_eapol_key *)(aa1x_hdr+1); + atomic_set(&priv->psstatus.snooze_guard, 1); + } + + /* rx indication */ + skb->dev = priv->net_dev; + skb->protocol = eth_type_trans (skb, skb->dev); + priv->nstats.rx_packets++; + priv->nstats.rx_bytes += rx_ind_size; + skb->dev->last_rx = jiffies; + netif_rx (skb); + } else { + printk (KERN_WARNING"%s: Memory squeeze, dropping packet.\n",skb->dev->name); + priv->nstats.rx_dropped++; + } + break; + case 0xF0: /* NETBEUI/NetBIOS */ + rx_ind_size = (priv->rx_size + 2); + skb = dev_alloc_skb (rx_ind_size); + DPRINTK(3,"NETBEUI/NetBIOS rx_ind_size=%d\n", rx_ind_size); + + if(skb) { + memcpy(skb_put(skb,12),priv->rxp,12); /* 8802/FDDI MAC copy */ + + temp[0] = (((rx_ind_size-12) >> 8) & 0xff); /* NETBEUI size add */ + temp[1] = ((rx_ind_size-12) & 0xff); + memcpy(skb_put(skb,2),temp,2); + + memcpy(skb_put(skb,rx_ind_size-14),priv->rxp+12,rx_ind_size-14); /* copy after Type */ + + aa1x_hdr=(struct ieee802_1x_hdr *)(priv->rxp+14); + if(aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY && priv->wpa.rsn_enabled){ + eap_key = (struct wpa_eapol_key *)(aa1x_hdr+1); + atomic_set(&priv->psstatus.snooze_guard, 1); + } + + /* rx indication */ + skb->dev = priv->net_dev; + skb->protocol = eth_type_trans (skb, skb->dev); + priv->nstats.rx_packets++; + priv->nstats.rx_bytes += rx_ind_size; + skb->dev->last_rx = jiffies; + netif_rx (skb); + } else { + printk (KERN_WARNING"%s: Memory squeeze, dropping packet.\n",skb->dev->name); + priv->nstats.rx_dropped++; + } + break; + default: /* other rx data */ + DPRINTK(2,"invalid data format\n"); + priv->nstats.rx_errors++; + } +} + +static +void hostif_mib_get_confirm(ks_wlan_private *priv) +{ + struct net_device *dev=priv->net_dev; + uint32_t mib_status; + uint32_t mib_attribute; + uint16_t mib_val_size; + uint16_t mib_val_type; + + DPRINTK(3, "\n"); + + mib_status = get_DWORD(priv); /* MIB status */ + mib_attribute = get_DWORD(priv); /* MIB atttibute */ + mib_val_size = get_WORD(priv); /* MIB value size */ + mib_val_type = get_WORD(priv); /* MIB value type */ + + if (mib_status != 0) { + /* in case of error */ + DPRINTK(1, "attribute=%08X, status=%08X\n", mib_attribute, mib_status); + return; + } + + switch (mib_attribute) { + case DOT11_MAC_ADDRESS: + /* MAC address */ + DPRINTK(3," mib_attribute=DOT11_MAC_ADDRESS\n"); + hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS); + memcpy(priv->eth_addr, priv->rxp, ETH_ALEN); + priv->mac_address_valid = 1; + dev->dev_addr[0] = priv->eth_addr[0]; + dev->dev_addr[1] = priv->eth_addr[1]; + dev->dev_addr[2] = priv->eth_addr[2]; + dev->dev_addr[3] = priv->eth_addr[3]; + dev->dev_addr[4] = priv->eth_addr[4]; + dev->dev_addr[5] = priv->eth_addr[5]; + dev->dev_addr[6] = 0x00; + dev->dev_addr[7] = 0x00; + printk(KERN_INFO "ks_wlan: MAC ADDRESS = %02x:%02x:%02x:%02x:%02x:%02x\n", + priv->eth_addr[0],priv->eth_addr[1],priv->eth_addr[2], + priv->eth_addr[3],priv->eth_addr[4],priv->eth_addr[5]); + break; + case DOT11_PRODUCT_VERSION: + /* firmware version */ + DPRINTK(3," mib_attribute=DOT11_PRODUCT_VERSION\n"); + priv->version_size = priv->rx_size; + memcpy(priv->firmware_version, priv->rxp, priv->rx_size); + priv->firmware_version[priv->rx_size] = '\0'; + printk(KERN_INFO "ks_wlan: firmware ver. = %s\n",priv->firmware_version); + hostif_sme_enqueue(priv, SME_GET_PRODUCT_VERSION); + /* wake_up_interruptible_all(&priv->confirm_wait); */ + complete(&priv->confirm_wait); + break; + case LOCAL_GAIN: + memcpy(&priv->gain, priv->rxp, sizeof(priv->gain)); + DPRINTK(3, "TxMode=%d, RxMode=%d, TxGain=%d, RxGain=%d\n", + priv->gain.TxMode, priv->gain.RxMode, priv->gain.TxGain, priv->gain.RxGain); + break; + case LOCAL_EEPROM_SUM: + memcpy(&priv->eeprom_sum, priv->rxp, sizeof(priv->eeprom_sum)); + DPRINTK(1, "eeprom_sum.type=%x, eeprom_sum.result=%x\n", priv->eeprom_sum.type, priv->eeprom_sum.result); + if(priv->eeprom_sum.type == 0){ + priv->eeprom_checksum = EEPROM_CHECKSUM_NONE; + }else if(priv->eeprom_sum.type == 1){ + if(priv->eeprom_sum.result == 0){ + priv->eeprom_checksum = EEPROM_NG; + printk("LOCAL_EEPROM_SUM NG\n"); + }else if(priv->eeprom_sum.result == 1){ + priv->eeprom_checksum = EEPROM_OK; + } + }else{ + printk("LOCAL_EEPROM_SUM error!\n"); + } + break; + default: + DPRINTK(1,"mib_attribute=%08x\n",(unsigned int)mib_attribute); + break; + } +} + +static +void hostif_mib_set_confirm(ks_wlan_private *priv) +{ + uint32_t mib_status; /* +04 MIB Status */ + uint32_t mib_attribute; /* +08 MIB attribute */ + + DPRINTK(3,"\n"); + + mib_status = get_DWORD(priv); /* MIB Status */ + mib_attribute = get_DWORD(priv); /* MIB attribute */ + + if (mib_status != 0) { + /* in case of error */ + DPRINTK(1, "error :: attribute=%08X, status=%08X\n", mib_attribute, mib_status); + } + + switch (mib_attribute) { + case DOT11_RTS_THRESHOLD: + hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_CONFIRM); + break; + case DOT11_FRAGMENTATION_THRESHOLD: + hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_CONFIRM); + break; + case DOT11_WEP_DEFAULT_KEY_ID: + if(!priv->wpa.wpa_enabled) + hostif_sme_enqueue(priv, SME_WEP_INDEX_CONFIRM); + break; + case DOT11_WEP_DEFAULT_KEY_VALUE1: + DPRINTK(2,"DOT11_WEP_DEFAULT_KEY_VALUE1:mib_status=%d\n",(int)mib_status); + if(priv->wpa.rsn_enabled) + hostif_sme_enqueue(priv, SME_SET_PMK_TSC); + else + hostif_sme_enqueue(priv, SME_WEP_KEY1_CONFIRM); + break; + case DOT11_WEP_DEFAULT_KEY_VALUE2: + DPRINTK(2,"DOT11_WEP_DEFAULT_KEY_VALUE2:mib_status=%d\n",(int)mib_status); + if(priv->wpa.rsn_enabled) + hostif_sme_enqueue(priv, SME_SET_GMK1_TSC); + else + hostif_sme_enqueue(priv, SME_WEP_KEY2_CONFIRM); + break; + case DOT11_WEP_DEFAULT_KEY_VALUE3: + DPRINTK(2,"DOT11_WEP_DEFAULT_KEY_VALUE3:mib_status=%d\n",(int)mib_status); + if(priv->wpa.rsn_enabled) + hostif_sme_enqueue(priv, SME_SET_GMK2_TSC); + else + hostif_sme_enqueue(priv, SME_WEP_KEY3_CONFIRM); + break; + case DOT11_WEP_DEFAULT_KEY_VALUE4: + DPRINTK(2,"DOT11_WEP_DEFAULT_KEY_VALUE4:mib_status=%d\n",(int)mib_status); + if(!priv->wpa.rsn_enabled) + hostif_sme_enqueue(priv, SME_WEP_KEY4_CONFIRM); + break; + case DOT11_PRIVACY_INVOKED: + if(!priv->wpa.rsn_enabled) + hostif_sme_enqueue(priv, SME_WEP_FLAG_CONFIRM); + break; + case DOT11_RSN_ENABLED: + DPRINTK(2,"DOT11_RSN_ENABLED:mib_status=%d\n",(int)mib_status); + hostif_sme_enqueue(priv, SME_RSN_ENABLED_CONFIRM); + break; + case LOCAL_RSN_MODE: + hostif_sme_enqueue(priv, SME_RSN_MODE_CONFIRM); + break; + case LOCAL_MULTICAST_ADDRESS: + hostif_sme_enqueue(priv, SME_MULTICAST_REQUEST); + break; + case LOCAL_MULTICAST_FILTER: + hostif_sme_enqueue(priv, SME_MULTICAST_CONFIRM); + break; + case LOCAL_CURRENTADDRESS: + priv->mac_address_valid = 1; + break; + case DOT11_RSN_CONFIG_MULTICAST_CIPHER: + DPRINTK(2,"DOT11_RSN_CONFIG_MULTICAST_CIPHER:mib_status=%d\n",(int)mib_status); + hostif_sme_enqueue(priv, SME_RSN_MCAST_CONFIRM); + break; + case DOT11_RSN_CONFIG_UNICAST_CIPHER: + DPRINTK(2,"DOT11_RSN_CONFIG_UNICAST_CIPHER:mib_status=%d\n",(int)mib_status); + hostif_sme_enqueue(priv, SME_RSN_UCAST_CONFIRM); + break; + case DOT11_RSN_CONFIG_AUTH_SUITE: + DPRINTK(2,"DOT11_RSN_CONFIG_AUTH_SUITE:mib_status=%d\n",(int)mib_status); + hostif_sme_enqueue(priv, SME_RSN_AUTH_CONFIRM); + break; + case DOT11_PMK_TSC: + DPRINTK(2,"DOT11_PMK_TSC:mib_status=%d\n",(int)mib_status); + break; + case DOT11_GMK1_TSC: + DPRINTK(2,"DOT11_GMK1_TSC:mib_status=%d\n",(int)mib_status); + if(atomic_read(&priv->psstatus.snooze_guard)){ + atomic_set(&priv->psstatus.snooze_guard, 0); + } + break; + case DOT11_GMK2_TSC: + DPRINTK(2,"DOT11_GMK2_TSC:mib_status=%d\n",(int)mib_status); + if(atomic_read(&priv->psstatus.snooze_guard)){ + atomic_set(&priv->psstatus.snooze_guard, 0); + } + break; + case LOCAL_PMK: + DPRINTK(2,"LOCAL_PMK:mib_status=%d\n",(int)mib_status); + break; + case LOCAL_GAIN: + DPRINTK(2,"LOCAL_GAIN:mib_status=%d\n",(int)mib_status); + break; +#ifdef WPS + case LOCAL_WPS_ENABLE: + DPRINTK(2,"LOCAL_WPS_ENABLE:mib_status=%d\n",(int)mib_status); + break; + case LOCAL_WPS_PROBE_REQ: + DPRINTK(2,"LOCAL_WPS_PROBE_REQ:mib_status=%d\n",(int)mib_status); + break; +#endif /* WPS */ + case LOCAL_REGION: + DPRINTK(2,"LOCAL_REGION:mib_status=%d\n",(int)mib_status); + default : + break; + } +} + +static +void hostif_power_mngmt_confirm(ks_wlan_private *priv) +{ + DPRINTK(3,"\n"); + + if(priv->reg.powermgt > POWMGT_ACTIVE_MODE && + priv->reg.operation_mode == MODE_INFRASTRUCTURE){ +#if !defined(_SDIO_) + atomic_set(&priv->psstatus.status,PS_SAVE_SET); +#endif + atomic_set(&priv->psstatus.confirm_wait, 0); + priv->dev_state = DEVICE_STATE_SLEEP; + ks_wlan_hw_power_save(priv); + }else{ + priv->dev_state = DEVICE_STATE_READY; +#if !defined(_SDIO_) + atomic_set(&priv->psstatus.status,PS_ACTIVE_SET); +#endif + } + +} + +static +void hostif_sleep_confirm(ks_wlan_private *priv) +{ + DPRINTK(3,"\n"); + + atomic_set(&priv->sleepstatus.doze_request,1); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); +} + +static +void hostif_start_confirm(ks_wlan_private *priv) +{ +#ifdef WPS + union iwreq_data wrqu; + wrqu.data.length = 0; + wrqu.data.flags = 0; + wrqu.ap_addr.sa_family = ARPHRD_ETHER; + if((priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ + memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); + DPRINTK(3,"IWEVENT: disconnect\n"); + wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); + } +#endif + DPRINTK(3," scan_ind_count=%d\n",priv->scan_ind_count); + hostif_sme_enqueue(priv, SME_START_CONFIRM); +} + +static +void hostif_connect_indication(ks_wlan_private *priv) +{ + unsigned short connect_code; + unsigned int tmp=0; + unsigned int old_status=priv->connect_status; + struct net_device *netdev=priv->net_dev; +#if WIRELESS_EXT > 13 + union iwreq_data wrqu0; +#endif /* WIRELESS_EXT > 13 */ + connect_code = get_WORD(priv); + + switch(connect_code){ + case RESULT_CONNECT: /* connect */ + DPRINTK(3,"connect :: scan_ind_count=%d\n",priv->scan_ind_count); + if(!(priv->connect_status & FORCE_DISCONNECT)) + netif_carrier_on(netdev); + tmp = FORCE_DISCONNECT & priv->connect_status; + priv->connect_status = tmp + CONNECT_STATUS; + break; + case RESULT_DISCONNECT: /* disconnect */ + DPRINTK(3,"disconnect :: scan_ind_count=%d\n",priv->scan_ind_count); + netif_carrier_off(netdev); + tmp = FORCE_DISCONNECT & priv->connect_status; + priv->connect_status = tmp + DISCONNECT_STATUS; + break; + default: + DPRINTK(1,"unknown connect_code=%d :: scan_ind_count=%d\n", + connect_code,priv->scan_ind_count); + netif_carrier_off(netdev); + tmp = FORCE_DISCONNECT & priv->connect_status; + priv->connect_status = tmp + DISCONNECT_STATUS; + break; + } + + get_current_ap(priv, (struct link_ap_info_t *)priv->rxp); + if((priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS && + (old_status & CONNECT_STATUS_MASK)==DISCONNECT_STATUS ){ + /* for power save */ + atomic_set(&priv->psstatus.snooze_guard, 0); + atomic_set(&priv->psstatus.confirm_wait,0); +#if !defined(_SDIO_) + atomic_set(&priv->psstatus.status, PS_NONE); +#endif + } + ks_wlan_do_power_save(priv); + +#if WIRELESS_EXT > 13 + wrqu0.data.length = 0; + wrqu0.data.flags = 0; + wrqu0.ap_addr.sa_family = ARPHRD_ETHER; + if((priv->connect_status & CONNECT_STATUS_MASK)== DISCONNECT_STATUS && + (old_status & CONNECT_STATUS_MASK)==CONNECT_STATUS ){ + memset(wrqu0.ap_addr.sa_data, '\0', ETH_ALEN); + DPRINTK(3,"IWEVENT: disconnect\n"); + DPRINTK(3,"disconnect :: scan_ind_count=%d\n",priv->scan_ind_count); + wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL); + } +#endif /* WIRELESS_EXT > 13 */ + priv->scan_ind_count=0; +} + +static +void hostif_scan_indication(ks_wlan_private *priv) +{ + int i; + struct ap_info_t *ap_info; + + DPRINTK(3,"scan_ind_count = %d\n", priv->scan_ind_count); + ap_info = (struct ap_info_t *)(priv->rxp); + + if(priv->scan_ind_count!=0){ + for(i=0;iaplist.size;i++){ /* bssid check */ + if(!memcmp(&(ap_info->bssid[0]),&(priv->aplist.ap[i].bssid[0]),ETH_ALEN)){ + if(ap_info->frame_type == FRAME_TYPE_PROBE_RESP) + get_ap_information(priv,ap_info,&(priv->aplist.ap[i])); + return; + } + } + } + priv->scan_ind_count++; + if(priv->scan_ind_count < LOCAL_APLIST_MAX+1){ + DPRINTK(4," scan_ind_count=%d :: aplist.size=%d\n", priv->scan_ind_count, priv->aplist.size); + get_ap_information(priv,(struct ap_info_t *)(priv->rxp),&(priv->aplist.ap[priv->scan_ind_count-1])); + priv->aplist.size = priv->scan_ind_count; + } + else{ + DPRINTK(4," count over :: scan_ind_count=%d\n", priv->scan_ind_count); + } + + +} + +static +void hostif_stop_confirm(ks_wlan_private *priv) +{ + unsigned int tmp=0; + unsigned int old_status=priv->connect_status; + struct net_device *netdev=priv->net_dev; + union iwreq_data wrqu0; + + DPRINTK(3,"\n"); +#ifdef _SDIO_ + if(priv->dev_state == DEVICE_STATE_SLEEP) + priv->dev_state = DEVICE_STATE_READY; +#endif + + /* disconnect indication */ + if( (priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ + netif_carrier_off(netdev); + tmp = FORCE_DISCONNECT & priv->connect_status; + priv->connect_status = tmp | DISCONNECT_STATUS; + printk("IWEVENT: disconnect\n"); + + wrqu0.data.length = 0; + wrqu0.data.flags = 0; + wrqu0.ap_addr.sa_family = ARPHRD_ETHER; + if((priv->connect_status & CONNECT_STATUS_MASK)== DISCONNECT_STATUS && + (old_status & CONNECT_STATUS_MASK)==CONNECT_STATUS ){ + memset(wrqu0.ap_addr.sa_data, '\0', ETH_ALEN); + DPRINTK(3,"IWEVENT: disconnect\n"); + printk("IWEVENT: disconnect\n"); + DPRINTK(3,"disconnect :: scan_ind_count=%d\n",priv->scan_ind_count); + wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL); + } + priv->scan_ind_count=0; + } + + hostif_sme_enqueue(priv, SME_STOP_CONFIRM); +} + +static +void hostif_ps_adhoc_set_confirm(ks_wlan_private *priv) +{ + DPRINTK(3,"\n"); + priv->infra_status = 0; /* infrastructure mode cancel */ + hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); + +} + +static +void hostif_infrastructure_set_confirm(ks_wlan_private *priv) +{ + uint16_t result_code; + DPRINTK(3,"\n"); + result_code = get_WORD(priv); + DPRINTK(3,"result code = %d\n",result_code); + priv->infra_status = 1; /* infrastructure mode set */ + hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); +} + +static +void hostif_adhoc_set_confirm(ks_wlan_private *priv) +{ + DPRINTK(3,"\n"); + priv->infra_status = 1; /* infrastructure mode set */ + hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); +} + +static +void hostif_associate_indication(ks_wlan_private *priv) +{ +#if WIRELESS_EXT > 14 + struct association_request_t *assoc_req; + struct association_response_t *assoc_resp; + unsigned char *pb; + union iwreq_data wrqu; + char buf[IW_CUSTOM_MAX]; + char *pbuf = &buf[0]; + int i; + + static const char associnfo_leader0[] = "ASSOCINFO(ReqIEs="; + static const char associnfo_leader1[] = " RespIEs="; + + DPRINTK(3,"\n"); + assoc_req = (struct association_request_t *)(priv->rxp); + assoc_resp = (struct association_response_t *)(assoc_req+1); + pb = (unsigned char *)(assoc_resp+1); + + memset(&wrqu, 0, sizeof(wrqu)); + memcpy(pbuf,associnfo_leader0,sizeof(associnfo_leader0)-1); + wrqu.data.length += sizeof(associnfo_leader0)-1; + pbuf += sizeof(associnfo_leader0)-1; + + for (i = 0; i < assoc_req->reqIEs_size; i++) + pbuf += sprintf(pbuf, "%02x", *(pb+i)); + wrqu.data.length += (assoc_req->reqIEs_size)*2; + + memcpy(pbuf,associnfo_leader1,sizeof(associnfo_leader1)-1); + wrqu.data.length += sizeof(associnfo_leader1)-1; + pbuf += sizeof(associnfo_leader1)-1; + + pb += assoc_req->reqIEs_size; + for (i = 0; i < assoc_resp->respIEs_size; i++) + pbuf += sprintf(pbuf, "%02x", *(pb+i)); + wrqu.data.length += (assoc_resp->respIEs_size)*2; + + pbuf += sprintf(pbuf, ")"); + wrqu.data.length += 1; + + DPRINTK(3,"IWEVENT:ASSOCINFO\n"); + wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf); +#endif /* WIRELESS_EXT > 14 */ +} + +static +void hostif_bss_scan_confirm(ks_wlan_private *priv) +{ + unsigned int result_code; +#if WIRELESS_EXT > 13 + struct net_device *dev = priv->net_dev; + union iwreq_data wrqu; +#endif /* WIRELESS_EXT > 13 */ + result_code = get_DWORD(priv); + DPRINTK(2,"result=%d :: scan_ind_count=%d\n", result_code, priv->scan_ind_count); + + priv->sme_i.sme_flag &= ~SME_AP_SCAN; + hostif_sme_enqueue(priv, SME_BSS_SCAN_CONFIRM); + +#if WIRELESS_EXT > 13 + wrqu.data.length = 0; + wrqu.data.flags = 0; + DPRINTK(3,"IWEVENT: SCAN CONFIRM\n"); + wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL); +#endif /* WIRELESS_EXT > 13 */ + priv->scan_ind_count=0; +} + +static +void hostif_phy_information_confirm(ks_wlan_private *priv) +{ + struct iw_statistics *wstats = &priv->wstats; + unsigned char rssi,signal,noise; + unsigned char LinkSpeed; + unsigned int TransmittedFrameCount, ReceivedFragmentCount; + unsigned int FailedCount, FCSErrorCount; + + DPRINTK(3,"\n"); + rssi = get_BYTE(priv); + signal = get_BYTE(priv); + noise = get_BYTE(priv); + LinkSpeed = get_BYTE(priv); + TransmittedFrameCount = get_DWORD(priv); + ReceivedFragmentCount = get_DWORD(priv); + FailedCount = get_DWORD(priv); + FCSErrorCount = get_DWORD(priv); + + DPRINTK(4, "phyinfo confirm rssi=%d signal=%d\n", rssi, signal); + priv->current_rate = (LinkSpeed & RATE_MASK); + wstats->qual.qual = signal; + wstats->qual.level = 256 - rssi; + wstats->qual.noise = 0; /* invalid noise value */ + wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; + + DPRINTK(3,"\n rssi=%u\n signal=%u\n LinkSpeed=%ux500Kbps\n \ + TransmittedFrameCount=%u\n ReceivedFragmentCount=%u\n FailedCount=%u\n \ + FCSErrorCount=%u\n", + rssi,signal,LinkSpeed,TransmittedFrameCount, + ReceivedFragmentCount,FailedCount,FCSErrorCount); + + /* wake_up_interruptible_all(&priv->confirm_wait); */ + complete(&priv->confirm_wait); +} + +static +void hostif_mic_failure_confirm(ks_wlan_private *priv) +{ + DPRINTK(3,"mic_failure=%u\n",priv->wpa.mic_failure.failure); + hostif_sme_enqueue(priv, SME_MIC_FAILURE_CONFIRM); +} + + +static +void hostif_event_check(ks_wlan_private *priv) +{ + unsigned short event; + + DPRINTK(4, "\n"); + event = get_WORD(priv); /* get event */ + switch (event) { + case HIF_DATA_IND: + hostif_data_indication(priv); + break; + case HIF_MIB_GET_CONF: + hostif_mib_get_confirm(priv); + break; + case HIF_MIB_SET_CONF: + hostif_mib_set_confirm(priv); + break; + case HIF_POWERMGT_CONF: + hostif_power_mngmt_confirm(priv); + break; + case HIF_SLEEP_CONF: + hostif_sleep_confirm(priv); + break; + case HIF_START_CONF: + hostif_start_confirm(priv); + break; + case HIF_CONNECT_IND: + hostif_connect_indication(priv); + break; + case HIF_STOP_CONF: + hostif_stop_confirm(priv); + break; + case HIF_PS_ADH_SET_CONF: + hostif_ps_adhoc_set_confirm(priv); + break; + case HIF_INFRA_SET_CONF: + case HIF_INFRA_SET2_CONF: + hostif_infrastructure_set_confirm(priv); + break; + case HIF_ADH_SET_CONF: + case HIF_ADH_SET2_CONF: + hostif_adhoc_set_confirm(priv); + break; + case HIF_ASSOC_INFO_IND: + hostif_associate_indication(priv); + break; + case HIF_MIC_FAILURE_CONF: + hostif_mic_failure_confirm(priv); + break; + case HIF_SCAN_CONF: + hostif_bss_scan_confirm(priv); + break; + case HIF_PHY_INFO_CONF: + case HIF_PHY_INFO_IND: + hostif_phy_information_confirm(priv); + break; + case HIF_SCAN_IND: + hostif_scan_indication(priv); + break; + case HIF_AP_SET_CONF: + default: + //DPRINTK(1, "undefined event[%04X]\n", event); + printk("undefined event[%04X]\n", event); + /* wake_up_all(&priv->confirm_wait); */ + complete(&priv->confirm_wait); + break; + } + + /* add event to hostt buffer */ + priv->hostt.buff[priv->hostt.qtail] = event; + priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE; +} + +#define CHECK_ALINE(size) (size%4 ? (size+(4-(size%4))):size) + +int hostif_data_request(ks_wlan_private *priv, struct sk_buff *packet) +{ + unsigned int packet_len=0; + + unsigned char *buffer=NULL; + unsigned int length=0; + struct hostif_data_request_t *pp; + unsigned char *p; + int result=0; + unsigned short eth_proto; + struct ether_hdr *eth_hdr; + struct michel_mic_t michel_mic; + unsigned short keyinfo=0; + struct ieee802_1x_hdr *aa1x_hdr; + struct wpa_eapol_key *eap_key; + struct ethhdr *eth; + + packet_len = packet->len; + if (packet_len > ETH_FRAME_LEN) { + DPRINTK(1,"bad length packet_len=%d \n", packet_len); + dev_kfree_skb(packet); + return -1; + } + + if(((priv->connect_status & CONNECT_STATUS_MASK)== DISCONNECT_STATUS) || + (priv->connect_status & FORCE_DISCONNECT) || priv->wpa.mic_failure.stop){ + DPRINTK(3," DISCONNECT\n"); + if(netif_queue_stopped(priv->net_dev)) + netif_wake_queue(priv->net_dev); + if(packet) + dev_kfree_skb(packet); + + return 0; + } + + /* for PowerSave */ + if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ /* power save wakeup */ + if(!netif_queue_stopped(priv->net_dev)) + netif_stop_queue(priv->net_dev); +#if !defined(_SDIO_) + schedule_work(&priv->ks_wlan_wakeup_task); +#endif + } + + DPRINTK(4, "skb_buff length=%d\n", packet_len); + pp = (struct hostif_data_request_t *)kmalloc(hif_align_size(sizeof(*pp)+6+packet_len+8),KS_WLAN_MEM_FLAG ); + + if (pp==NULL) { + DPRINTK(3, "allocate memory failed..\n"); + dev_kfree_skb(packet); + return -2; + } + + p = (unsigned char *)pp->data; + + buffer = packet->data; + length = packet->len; + + /* packet check */ + eth = (struct ethhdr *)packet->data; + if (memcmp(&priv->eth_addr[0],eth->h_source, ETH_ALEN)){ + DPRINTK(1, "invalid mac address !!\n"); + DPRINTK(1, "ethernet->h_source=%02X:%02X:%02X:%02X:%02X:%02X\n", + eth->h_source[0],eth->h_source[1],eth->h_source[2], + eth->h_source[3],eth->h_source[4],eth->h_source[5]); + return -3; + } + + /* MAC address copy */ + memcpy(p, buffer, 12); /* DST/SRC MAC address */ + p += 12; + buffer += 12; + length -= 12; + /* EtherType/Length check */ + if (*(buffer+1) + (*buffer << 8) > 1500) { + /* ProtocolEAP = *(buffer+1) + (*buffer << 8); */ + /* DPRINTK(2, "Send [SNAP]Type %x\n",ProtocolEAP); */ + /* SAP/CTL/OUI(6 byte) add */ + *p++ = 0xAA; /* DSAP */ + *p++ = 0xAA; /* SSAP */ + *p++ = 0x03; /* CTL */ + *p++ = 0x00; /* OUI ("000000") */ + *p++ = 0x00; /* OUI ("000000") */ + *p++ = 0x00; /* OUI ("000000") */ + packet_len += 6; + } else { + DPRINTK(4,"DIX\n"); + /* Length(2 byte) delete */ + buffer += 2; + length -= 2; + packet_len -= 2; + } + + /* pp->data copy */ + memcpy(p, buffer, length); + + p += length; + + /* for WPA */ + eth_hdr = (struct ether_hdr *)&pp->data[0]; + eth_proto = ntohs(eth_hdr->h_proto); + + /* for MIC FAILUER REPORT check */ + if(eth_proto == ETHER_PROTOCOL_TYPE_EAP && priv->wpa.mic_failure.failure>0){ + aa1x_hdr=(struct ieee802_1x_hdr *)(eth_hdr+1); + if(aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY){ + eap_key = (struct wpa_eapol_key *)(aa1x_hdr+1); + keyinfo=ntohs(eap_key->key_info); + } + } + + if (priv->wpa.rsn_enabled && priv->wpa.key[0].key_len){ + if(eth_proto == ETHER_PROTOCOL_TYPE_EAP && !(priv->wpa.key[1].key_len) && + !(priv->wpa.key[2].key_len) && !(priv->wpa.key[3].key_len)){ + pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH); /* no encryption */ + } + else{ + if(priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP){ + MichaelMICFunction( &michel_mic, + (uint8_t*)priv->wpa.key[0].tx_mic_key, + (uint8_t*)&pp->data[0], + (int)packet_len, + (uint8_t)0, /* priority */ + (uint8_t*)michel_mic.Result ); + memcpy(p, michel_mic.Result, 8); + length += 8; + packet_len += 8; + p += 8; + pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA); + + }else if(priv->wpa.pairwise_suite == IW_AUTH_CIPHER_CCMP){ + pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA); + } + } + } + else{ + if(eth_proto == ETHER_PROTOCOL_TYPE_EAP) + pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH); + else + pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA); + } + + /* header value set */ + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size)+packet_len)); + pp->header.event = cpu_to_le16((uint16_t)HIF_DATA_REQ); + + /* tx request */ + result = ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + packet_len), + (void *)send_packet_complete, (void *)priv, (void *)packet); + + /* MIC FAILUER REPORT check */ + if(eth_proto == ETHER_PROTOCOL_TYPE_EAP && priv->wpa.mic_failure.failure>0){ + if(keyinfo & WPA_KEY_INFO_ERROR && keyinfo & WPA_KEY_INFO_REQUEST){ + DPRINTK(3," MIC ERROR Report SET : %04X\n", keyinfo); + hostif_sme_enqueue(priv, SME_MIC_FAILURE_REQUEST); + } + if(priv->wpa.mic_failure.failure==2) + priv->wpa.mic_failure.stop=1; + } + + return result; +} + +#if defined(_SPI_) +#define ps_confirm_wait_inc(priv) +#else +#define ps_confirm_wait_inc(priv) do{if(atomic_read(&priv->psstatus.status) > PS_ACTIVE_SET){ \ + atomic_inc(&priv->psstatus.confirm_wait); \ + /* atomic_set(&priv->psstatus.status, PS_CONF_WAIT);*/ \ + } }while(0) +#endif + +static +void hostif_mib_get_request( ks_wlan_private *priv, unsigned long mib_attribute) +{ + struct hostif_mib_get_request_t *pp; + + DPRINTK(3, "\n"); + + /* make primitive */ + pp = (struct hostif_mib_get_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3,"allocate memory failed..\n"); + return; + } + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_MIB_GET_REQ); + pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +static +void hostif_mib_set_request( ks_wlan_private *priv, unsigned long mib_attribute, + unsigned short size, unsigned short type, + void *vp ) +{ + struct hostif_mib_set_request_t *pp; + + DPRINTK(3,"\n"); + + if (priv->dev_state < DEVICE_STATE_BOOT) { + DPRINTK(3,"DeviceRemove\n"); + return; + } + + /* make primitive */ + pp = (struct hostif_mib_set_request_t *)kmalloc(hif_align_size(sizeof(*pp)+size), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3, "allocate memory failed..\n"); + return; + } + + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size)+size)); + pp->header.event = cpu_to_le16((uint16_t)HIF_MIB_SET_REQ); + pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute); + pp->mib_value.size = cpu_to_le16((uint16_t)size); + pp->mib_value.type = cpu_to_le16((uint16_t)type); + memcpy(&pp->mib_value.body, vp, size); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL, NULL); +} + +static +void hostif_start_request( ks_wlan_private *priv, unsigned char mode ) +{ + struct hostif_start_request_t *pp; + + DPRINTK(3,"\n"); + + /* make primitive */ + pp = (struct hostif_start_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3, "allocate memory failed..\n"); + return; + } + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_START_REQ); + pp->mode = cpu_to_le16((uint16_t)mode); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + + priv->aplist.size = 0; + priv->scan_ind_count=0; +} + +static +void hostif_ps_adhoc_set_request(ks_wlan_private *priv) +{ + struct hostif_ps_adhoc_set_request_t *pp; + uint16_t capability; + + DPRINTK(3,"\n"); + + /* make primitive */ + pp = (struct hostif_ps_adhoc_set_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3, "allocate memory failed..\n"); + return; + } + memset(pp, 0, sizeof(*pp)); + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_PS_ADH_SET_REQ); + pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); + pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); + pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); + pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel)); + pp->rate_set.size = priv->reg.rate_set.size; + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + + capability = 0x0000; + if (priv->reg.preamble==SHORT_PREAMBLE) { + /* short preamble */ + capability |= BSS_CAP_SHORT_PREAMBLE; + } + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if(priv->reg.phy_type != D_11B_ONLY_MODE){ + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM */ + } + pp->capability = cpu_to_le16((uint16_t)capability); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +static +void hostif_infrastructure_set_request(ks_wlan_private *priv) +{ + struct hostif_infrastructure_set_request_t *pp; + uint16_t capability; + + DPRINTK(3, "ssid.size=%d \n",priv->reg.ssid.size); + + /* make primitive */ + pp = (struct hostif_infrastructure_set_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3, "allocate memory failed..\n"); + return; + } + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_INFRA_SET_REQ); + pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); + pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); + pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); + + pp->rate_set.size = priv->reg.rate_set.size; + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + pp->ssid.size = priv->reg.ssid.size; + memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); + + capability = 0x0000; + if (priv->reg.preamble==SHORT_PREAMBLE) { + /* short preamble */ + capability |= BSS_CAP_SHORT_PREAMBLE; + } + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if(priv->reg.phy_type != D_11B_ONLY_MODE){ + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ + } + pp->capability = cpu_to_le16((uint16_t)capability); + pp->beacon_lost_count = cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count)); + pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type)); + + pp->channel_list.body[0] = 1; + pp->channel_list.body[1] = 8; + pp->channel_list.body[2] = 2; + pp->channel_list.body[3] = 9; + pp->channel_list.body[4] = 3; + pp->channel_list.body[5] = 10; + pp->channel_list.body[6] = 4; + pp->channel_list.body[7] = 11; + pp->channel_list.body[8] = 5; + pp->channel_list.body[9] = 12; + pp->channel_list.body[10] = 6; + pp->channel_list.body[11] = 13; + pp->channel_list.body[12] = 7; + if(priv->reg.phy_type == D_11G_ONLY_MODE){ + pp->channel_list.size = 13; + }else{ + pp->channel_list.body[13] = 14; + pp->channel_list.size = 14; + } + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)),NULL, NULL, NULL); +} + +void hostif_infrastructure_set2_request(ks_wlan_private *priv) +{ + struct hostif_infrastructure_set2_request_t *pp; + uint16_t capability; + + DPRINTK(2, "ssid.size=%d \n",priv->reg.ssid.size); + + /* make primitive */ + pp = (struct hostif_infrastructure_set2_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3, "allocate memory failed..\n"); + return; + } + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_INFRA_SET2_REQ); + pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); + pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); + pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); + + pp->rate_set.size = priv->reg.rate_set.size; + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + pp->ssid.size = priv->reg.ssid.size; + memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); + + capability = 0x0000; + if (priv->reg.preamble==SHORT_PREAMBLE) { + /* short preamble */ + capability |= BSS_CAP_SHORT_PREAMBLE; + } + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if(priv->reg.phy_type != D_11B_ONLY_MODE){ + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ + } + pp->capability = cpu_to_le16((uint16_t)capability); + pp->beacon_lost_count = cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count)); + pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type)); + + pp->channel_list.body[0] = 1; + pp->channel_list.body[1] = 8; + pp->channel_list.body[2] = 2; + pp->channel_list.body[3] = 9; + pp->channel_list.body[4] = 3; + pp->channel_list.body[5] = 10; + pp->channel_list.body[6] = 4; + pp->channel_list.body[7] = 11; + pp->channel_list.body[8] = 5; + pp->channel_list.body[9] = 12; + pp->channel_list.body[10] = 6; + pp->channel_list.body[11] = 13; + pp->channel_list.body[12] = 7; + if(priv->reg.phy_type == D_11G_ONLY_MODE){ + pp->channel_list.size = 13; + }else{ + pp->channel_list.body[13] = 14; + pp->channel_list.size = 14; + } + + memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)),NULL, NULL, NULL); +} + +static +void hostif_adhoc_set_request(ks_wlan_private *priv) +{ + struct hostif_adhoc_set_request_t *pp; + uint16_t capability; + + DPRINTK(3, "\n"); + + /* make primitive */ + pp = (struct hostif_adhoc_set_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3, "allocate memory failed..\n"); + return; + } + memset(pp, 0, sizeof(*pp)); + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_ADH_SET_REQ); + pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); + pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); + pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); + pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel)); + pp->rate_set.size = priv->reg.rate_set.size; + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + pp->ssid.size = priv->reg.ssid.size; + memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); + + capability = 0x0000; + if (priv->reg.preamble==SHORT_PREAMBLE) { + /* short preamble */ + capability |= BSS_CAP_SHORT_PREAMBLE; + } + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if(priv->reg.phy_type != D_11B_ONLY_MODE){ + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ + } + pp->capability = cpu_to_le16((uint16_t)capability); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +static +void hostif_adhoc_set2_request(ks_wlan_private *priv) +{ + struct hostif_adhoc_set2_request_t *pp; + uint16_t capability; + + DPRINTK(3, "\n"); + + /* make primitive */ + pp = (struct hostif_adhoc_set2_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3, "allocate memory failed..\n"); + return; + } + memset(pp, 0, sizeof(*pp)); + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_ADH_SET_REQ); + pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); + pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); + pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); + pp->rate_set.size = priv->reg.rate_set.size; + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + pp->ssid.size = priv->reg.ssid.size; + memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); + + capability = 0x0000; + if (priv->reg.preamble==SHORT_PREAMBLE) { + /* short preamble */ + capability |= BSS_CAP_SHORT_PREAMBLE; + } + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if(priv->reg.phy_type != D_11B_ONLY_MODE){ + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ + } + pp->capability = cpu_to_le16((uint16_t)capability); + + pp->channel_list.body[0] = priv->reg.channel; + pp->channel_list.size = 1; + memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +static +void hostif_stop_request( ks_wlan_private *priv ) +{ + struct hostif_stop_request_t *pp; + + DPRINTK(3,"\n"); + + /* make primitive */ + pp = (struct hostif_stop_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3,"allocate memory failed..\n"); + return; + } + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +static +void hostif_phy_information_request( ks_wlan_private *priv ) +{ + struct hostif_phy_information_request_t *pp; + + DPRINTK(3,"\n"); + + /* make primitive */ + pp = (struct hostif_phy_information_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3, "allocate memory failed..\n"); + return; + } + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_PHY_INFO_REQ); + if(priv->reg.phy_info_timer){ + pp->type = cpu_to_le16((uint16_t)TIME_TYPE); + pp->time = cpu_to_le16((uint16_t)(priv->reg.phy_info_timer)); + }else{ + pp->type = cpu_to_le16((uint16_t)NORMAL_TYPE); + pp->time = cpu_to_le16((uint16_t)0); + } + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +static +void hostif_power_mngmt_request( ks_wlan_private *priv, unsigned long mode, + unsigned long wake_up, unsigned long receiveDTIMs ) +{ + struct hostif_power_mngmt_request_t *pp; + + DPRINTK(3,"mode=%lu wake_up=%lu receiveDTIMs=%lu\n",mode,wake_up,receiveDTIMs); + /* make primitive */ + pp = (struct hostif_power_mngmt_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3,"allocate memory failed..\n"); + return; + } + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_POWERMGT_REQ); + pp->mode = cpu_to_le32((uint32_t)mode); + pp->wake_up = cpu_to_le32((uint32_t)wake_up); + pp->receiveDTIMs = cpu_to_le32((uint32_t)receiveDTIMs); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +static +void hostif_sleep_request( ks_wlan_private *priv, unsigned long mode) +{ + struct hostif_sleep_request_t *pp; + + DPRINTK(3,"mode=%lu \n",mode); + + if(mode == SLP_SLEEP){ + /* make primitive */ + pp = (struct hostif_sleep_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3,"allocate memory failed..\n"); + return; + } + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_SLEEP_REQ); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + }else if(mode == SLP_ACTIVE){ + atomic_set(&priv->sleepstatus.wakeup_request,1); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + }else{ + DPRINTK(3,"invalid mode %ld \n", mode); + return; + } +} + + +static +void hostif_bss_scan_request( ks_wlan_private *priv, unsigned long scan_type , uint8_t *scan_ssid, uint8_t scan_ssid_len) +{ + struct hostif_bss_scan_request_t *pp; + + DPRINTK(2,"\n"); + /* make primitive */ + pp = (struct hostif_bss_scan_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3,"allocate memory failed..\n"); + return; + } + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_SCAN_REQ); + pp->scan_type = scan_type; + + pp->ch_time_min = cpu_to_le32((uint32_t)110); /* default value */ + pp->ch_time_max = cpu_to_le32((uint32_t)130); /* default value */ + pp->channel_list.body[0] = 1; + pp->channel_list.body[1] = 8; + pp->channel_list.body[2] = 2; + pp->channel_list.body[3] = 9; + pp->channel_list.body[4] = 3; + pp->channel_list.body[5] = 10; + pp->channel_list.body[6] = 4; + pp->channel_list.body[7] = 11; + pp->channel_list.body[8] = 5; + pp->channel_list.body[9] = 12; + pp->channel_list.body[10] = 6; + pp->channel_list.body[11] = 13; + pp->channel_list.body[12] = 7; + if(priv->reg.phy_type == D_11G_ONLY_MODE){ + pp->channel_list.size = 13; + }else{ + pp->channel_list.body[13] = 14; + pp->channel_list.size = 14; + } + pp->ssid.size = 0; + + /* specified SSID SCAN */ + if(scan_ssid_len > 0 && scan_ssid_len <= 32){ + pp->ssid.size = scan_ssid_len; + memcpy(&pp->ssid.body[0], scan_ssid, scan_ssid_len); + } + + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + + priv->aplist.size = 0; + priv->scan_ind_count=0; +} + +static +void hostif_mic_failure_request( ks_wlan_private *priv, unsigned short failure_count, + unsigned short timer ) +{ + struct hostif_mic_failure_request_t *pp; + + DPRINTK(3,"count=%d :: timer=%d\n",failure_count,timer); + /* make primitive */ + pp = (struct hostif_mic_failure_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); + if (pp==NULL) { + DPRINTK(3,"allocate memory failed..\n"); + return; + } + pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t)HIF_MIC_FAILURE_REQ); + pp->failure_count = cpu_to_le16((uint16_t)failure_count); + pp->timer = cpu_to_le16((uint16_t)timer); + + /* send to device request */ + ps_confirm_wait_inc(priv); + ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); +} + +/* Device I/O Recieve indicate */ +static void devio_rec_ind(ks_wlan_private *priv, unsigned char *p, unsigned int size) +{ + if (priv->device_open_status) { + spin_lock(&priv->dev_read_lock); /* request spin lock */ + priv->dev_data[atomic_read(&priv->rec_count)] = p; + priv->dev_size[atomic_read(&priv->rec_count)] = size; + + if (atomic_read(&priv->event_count) != DEVICE_STOCK_COUNT) { + /* rx event count inc */ + atomic_inc(&priv->event_count); + } + atomic_inc(&priv->rec_count); + if (atomic_read(&priv->rec_count)==DEVICE_STOCK_COUNT) + atomic_set(&priv->rec_count, 0); + + wake_up_interruptible_all(&priv->devread_wait); + + /* release spin lock */ + spin_unlock(&priv->dev_read_lock); + } +} + +void hostif_receive( ks_wlan_private *priv, unsigned char *p, unsigned int size ) +{ + DPRINTK(4,"\n"); + + devio_rec_ind(priv, p, size); + + priv->rxp = p; + priv->rx_size = size; + + if (get_WORD(priv) == priv->rx_size) { /* length check !! */ + hostif_event_check(priv); /* event check */ + } +} + + +static +void hostif_sme_set_wep(ks_wlan_private *priv, int type) +{ + uint32_t val; + switch(type){ + case SME_WEP_INDEX_REQUEST: + val = cpu_to_le32((uint32_t)(priv->reg.wep_index)); + hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID, + sizeof(val), MIB_VALUE_TYPE_INT, + &val ); + break; + case SME_WEP_KEY1_REQUEST: + if(!priv->wpa.wpa_enabled) + hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE1, + priv->reg.wep_key[0].size, MIB_VALUE_TYPE_OSTRING, + &priv->reg.wep_key[0].val[0] ); + break; + case SME_WEP_KEY2_REQUEST: + if(!priv->wpa.wpa_enabled) + hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE2, + priv->reg.wep_key[1].size, MIB_VALUE_TYPE_OSTRING, + &priv->reg.wep_key[1].val[0]); + break; + case SME_WEP_KEY3_REQUEST: + if(!priv->wpa.wpa_enabled) + hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE3, + priv->reg.wep_key[2].size, MIB_VALUE_TYPE_OSTRING, + &priv->reg.wep_key[2].val[0] ); + break; + case SME_WEP_KEY4_REQUEST: + if(!priv->wpa.wpa_enabled) + hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE4, + priv->reg.wep_key[3].size, MIB_VALUE_TYPE_OSTRING, + &priv->reg.wep_key[3].val[0]); + break; + case SME_WEP_FLAG_REQUEST: + val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked)); + hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED, + sizeof(val), MIB_VALUE_TYPE_BOOL, + &val ); + break; + } + + return ; +} + +struct wpa_suite_t { + unsigned short size; + unsigned char suite[4][CIPHER_ID_LEN]; +} __attribute__((packed)); + +struct rsn_mode_t { + uint32_t rsn_mode; + uint16_t rsn_capability; +} __attribute__((packed)); + +static +void hostif_sme_set_rsn(ks_wlan_private *priv, int type) +{ + struct wpa_suite_t wpa_suite; + struct rsn_mode_t rsn_mode; + uint32_t val; + + memset(&wpa_suite,0,sizeof(wpa_suite)); + + switch(type){ + case SME_RSN_UCAST_REQUEST: + wpa_suite.size=cpu_to_le16((uint16_t)1); + switch(priv->wpa.pairwise_suite){ + case IW_AUTH_CIPHER_NONE: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_NONE,CIPHER_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_NONE,CIPHER_ID_LEN); + break; + case IW_AUTH_CIPHER_WEP40: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_WEP40,CIPHER_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_WEP40,CIPHER_ID_LEN); + break; + case IW_AUTH_CIPHER_TKIP: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_TKIP,CIPHER_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_TKIP,CIPHER_ID_LEN); + break; + case IW_AUTH_CIPHER_CCMP: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_CCMP,CIPHER_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_CCMP,CIPHER_ID_LEN); + break; + case IW_AUTH_CIPHER_WEP104: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_WEP104,CIPHER_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_WEP104,CIPHER_ID_LEN); + break; + } + + hostif_mib_set_request(priv, DOT11_RSN_CONFIG_UNICAST_CIPHER, + sizeof(wpa_suite.size)+CIPHER_ID_LEN*wpa_suite.size, + MIB_VALUE_TYPE_OSTRING, &wpa_suite); + break; + case SME_RSN_MCAST_REQUEST: + switch(priv->wpa.group_suite){ + case IW_AUTH_CIPHER_NONE: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_NONE,CIPHER_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_NONE,CIPHER_ID_LEN); + break; + case IW_AUTH_CIPHER_WEP40: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_WEP40,CIPHER_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_WEP40,CIPHER_ID_LEN); + break; + case IW_AUTH_CIPHER_TKIP: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_TKIP,CIPHER_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_TKIP,CIPHER_ID_LEN); + break; + case IW_AUTH_CIPHER_CCMP: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_CCMP,CIPHER_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_CCMP,CIPHER_ID_LEN); + break; + case IW_AUTH_CIPHER_WEP104: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_WEP104,CIPHER_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_WEP104,CIPHER_ID_LEN); + break; + } + + hostif_mib_set_request(priv, DOT11_RSN_CONFIG_MULTICAST_CIPHER, + CIPHER_ID_LEN, MIB_VALUE_TYPE_OSTRING, + &wpa_suite.suite[0][0] ); + break; + case SME_RSN_AUTH_REQUEST: + wpa_suite.size=cpu_to_le16((uint16_t)1); + switch(priv->wpa.key_mgmt_suite){ + case IW_AUTH_KEY_MGMT_802_1X: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA2_1X,KEY_MGMT_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA_1X,KEY_MGMT_ID_LEN); + break; + case IW_AUTH_KEY_MGMT_PSK: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA2_PSK,KEY_MGMT_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA_PSK,KEY_MGMT_ID_LEN); + break; + case 0: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA2_NONE,KEY_MGMT_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA_NONE,KEY_MGMT_ID_LEN); + break; + case 4: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA2_WPANONE,KEY_MGMT_ID_LEN); + else + memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA_WPANONE,KEY_MGMT_ID_LEN); + break; + } + + hostif_mib_set_request(priv, DOT11_RSN_CONFIG_AUTH_SUITE, + sizeof(wpa_suite.size)+KEY_MGMT_ID_LEN*wpa_suite.size, + MIB_VALUE_TYPE_OSTRING, &wpa_suite); + break; + case SME_RSN_ENABLED_REQUEST: + val = cpu_to_le32((uint32_t)(priv->wpa.rsn_enabled)); + hostif_mib_set_request(priv, DOT11_RSN_ENABLED, + sizeof(val), MIB_VALUE_TYPE_BOOL, + &val ); + break; + case SME_RSN_MODE_REQUEST: + if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2){ + rsn_mode.rsn_mode = cpu_to_le32((uint32_t)RSN_MODE_WPA2); + rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0); + } + else if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA){ + rsn_mode.rsn_mode = cpu_to_le32((uint32_t)RSN_MODE_WPA); + rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0); + } + else{ + rsn_mode.rsn_mode = cpu_to_le32((uint32_t)RSN_MODE_NONE); + rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0); + } + hostif_mib_set_request(priv, LOCAL_RSN_MODE,sizeof(rsn_mode), + MIB_VALUE_TYPE_OSTRING,&rsn_mode ); + break; + + } + return; +} + +static +void hostif_sme_mode_setup(ks_wlan_private *priv) +{ + unsigned char rate_size; + unsigned char rate_octet[RATE_SET_MAX_SIZE]; + int i=0; + + /* rate setting if rate segging is auto for changing phy_type (#94)*/ + if(priv->reg.tx_rate == TX_RATE_FULL_AUTO){ + if(priv->reg.phy_type == D_11B_ONLY_MODE){ + priv->reg.rate_set.body[3] = TX_RATE_11M; + priv->reg.rate_set.body[2] = TX_RATE_5M; + priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.rate_set.size = 4; + }else{ /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ + priv->reg.rate_set.body[11] = TX_RATE_54M; + priv->reg.rate_set.body[10] = TX_RATE_48M; + priv->reg.rate_set.body[9] = TX_RATE_36M; + priv->reg.rate_set.body[8] = TX_RATE_18M; + priv->reg.rate_set.body[7] = TX_RATE_9M; + priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; + priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; + priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; + priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; + priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.rate_set.size = 12; + } + } + + /* rate mask by phy setting */ + if(priv->reg.phy_type == D_11B_ONLY_MODE){ + for(i=0;ireg.rate_set.size;i++){ + if(IS_11B_RATE(priv->reg.rate_set.body[i])){ + if((priv->reg.rate_set.body[i] & RATE_MASK) >= TX_RATE_5M) + rate_octet[i] = priv->reg.rate_set.body[i] & RATE_MASK ; + else + rate_octet[i] = priv->reg.rate_set.body[i]; + } + else + break; + } + + }else{ /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ + for(i=0;ireg.rate_set.size;i++){ + if(IS_11BG_RATE(priv->reg.rate_set.body[i])){ + if(IS_OFDM_EXT_RATE(priv->reg.rate_set.body[i])) + rate_octet[i] = priv->reg.rate_set.body[i] & RATE_MASK ; + else + rate_octet[i] = priv->reg.rate_set.body[i]; + } + else + break; + } + } + rate_size = i; + if(rate_size==0){ + if(priv->reg.phy_type == D_11G_ONLY_MODE) + rate_octet[0]=TX_RATE_6M | BASIC_RATE; + else + rate_octet[0]=TX_RATE_2M | BASIC_RATE; + rate_size = 1; + } + + /* rate set update */ + priv->reg.rate_set.size = rate_size; + memcpy(&priv->reg.rate_set.body[0], &rate_octet[0], rate_size); + + switch ( priv->reg.operation_mode ) { + case MODE_PSEUDO_ADHOC: + /* Pseudo Ad-Hoc mode */ + hostif_ps_adhoc_set_request(priv); + break; + case MODE_INFRASTRUCTURE: + /* Infrastructure mode */ + if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) { + hostif_infrastructure_set_request(priv); + } + else { + hostif_infrastructure_set2_request(priv); + DPRINTK(2, "Infra bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", + priv->reg.bssid[0],priv->reg.bssid[1],priv->reg.bssid[2], + priv->reg.bssid[3],priv->reg.bssid[4],priv->reg.bssid[5]); + } + break; + case MODE_ADHOC: + /* IEEE802.11 Ad-Hoc mode */ + if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) { + hostif_adhoc_set_request(priv); + } + else { + hostif_adhoc_set2_request(priv); + DPRINTK(2, "Adhoc bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", + priv->reg.bssid[0],priv->reg.bssid[1],priv->reg.bssid[2], + priv->reg.bssid[3],priv->reg.bssid[4],priv->reg.bssid[5]); + } + break; + default: + break; + } + + return ; +} + +static +void hostif_sme_multicast_set(ks_wlan_private *priv) +{ + + struct net_device *dev = priv->net_dev; + int mc_count; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) + struct netdev_hw_addr *ha; +#else + struct dev_mc_list *mclist; +#endif + char set_address[NIC_MAX_MCAST_LIST*ETH_ALEN]; + unsigned long filter_type; + int i; + + DPRINTK(3,"\n"); + + spin_lock(&priv->multicast_spin); + + memset(set_address, 0, NIC_MAX_MCAST_LIST*ETH_ALEN); + + if (dev->flags & IFF_PROMISC ){ + filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_PROMISC); + hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, sizeof(filter_type), + MIB_VALUE_TYPE_BOOL, &filter_type); + } + else if ((netdev_mc_count(dev) > NIC_MAX_MCAST_LIST) || (dev->flags & IFF_ALLMULTI)){ + filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCASTALL); + hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, sizeof(filter_type), + MIB_VALUE_TYPE_BOOL, &filter_type); + } + else { + if (priv->sme_i.sme_flag & SME_MULTICAST){ + mc_count = netdev_mc_count(dev); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) + netdev_for_each_mc_addr(ha, dev) { + memcpy(&set_address[i*ETH_ALEN], ha->addr, ETH_ALEN); + } +#else + for (i = 0, mclist = dev->mc_list; mclist && i < mc_count; i++, mclist = mclist->next) + memcpy(&set_address[i*ETH_ALEN], mclist->dmi_addr, ETH_ALEN); +#endif + priv->sme_i.sme_flag &= ~SME_MULTICAST; + hostif_mib_set_request(priv, LOCAL_MULTICAST_ADDRESS, + (ETH_ALEN*mc_count), MIB_VALUE_TYPE_OSTRING, &set_address[0]); + }else { + filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCAST); + priv->sme_i.sme_flag |= SME_MULTICAST; + hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, sizeof(filter_type), + MIB_VALUE_TYPE_BOOL, &filter_type); + } + } + + spin_unlock(&priv->multicast_spin); + +} + +static +void hostif_sme_powermgt_set(ks_wlan_private *priv) +{ + unsigned long mode,wake_up,receiveDTIMs ; + + DPRINTK(3,"\n"); + switch(priv->reg.powermgt){ + case POWMGT_ACTIVE_MODE: + mode = POWER_ACTIVE; + wake_up = 0; + receiveDTIMs = 0; + break; + case POWMGT_SAVE1_MODE: + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE){ + mode = POWER_SAVE; + wake_up = 0; + receiveDTIMs = 0; + } else { + mode = POWER_ACTIVE; + wake_up = 0; + receiveDTIMs = 0; + } + break; + case POWMGT_SAVE2_MODE: + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE){ + mode = POWER_SAVE; + wake_up = 0; + receiveDTIMs = 1; + } else { + mode = POWER_ACTIVE; + wake_up = 0; + receiveDTIMs = 0; + } + break; + default: + mode = POWER_ACTIVE; + wake_up = 0; + receiveDTIMs = 0; + break; + } + hostif_power_mngmt_request(priv, mode, wake_up, receiveDTIMs); + + return; +} + +static +void hostif_sme_sleep_set(ks_wlan_private *priv) +{ + DPRINTK(3,"\n"); + switch(priv->sleep_mode){ + case SLP_SLEEP: + hostif_sleep_request(priv, priv->sleep_mode); + break; + case SLP_ACTIVE: + hostif_sleep_request(priv, priv->sleep_mode); + break; + default: + break; + } + + return; +} + +static +void hostif_sme_set_key(ks_wlan_private *priv, int type) +{ + uint32_t val; + switch(type){ + case SME_SET_FLAG: + val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked)); + hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED, + sizeof(val), MIB_VALUE_TYPE_BOOL, + &val ); + break; + case SME_SET_TXKEY: + val = cpu_to_le32((uint32_t)(priv->wpa.txkey)); + hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID, + sizeof(val), MIB_VALUE_TYPE_INT, + &val ); + break; + case SME_SET_KEY1: + hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE1, + priv->wpa.key[0].key_len, MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[0].key_val[0] ); + break; + case SME_SET_KEY2: + hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE2, + priv->wpa.key[1].key_len, MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[1].key_val[0] ); + break; + case SME_SET_KEY3: + hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE3, + priv->wpa.key[2].key_len, MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[2].key_val[0] ); + break; + case SME_SET_KEY4: + hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE4, + priv->wpa.key[3].key_len, MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[3].key_val[0] ); + break; + case SME_SET_PMK_TSC: + hostif_mib_set_request(priv, DOT11_PMK_TSC, + WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[0].rx_seq[0] ); + break; + case SME_SET_GMK1_TSC: + hostif_mib_set_request(priv, DOT11_GMK1_TSC, + WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[1].rx_seq[0] ); + break; + case SME_SET_GMK2_TSC: + hostif_mib_set_request(priv, DOT11_GMK2_TSC, + WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[2].rx_seq[0] ); + break; + } + return; +} + +static +void hostif_sme_set_pmksa(ks_wlan_private *priv) +{ + struct pmk_cache_t { + uint16_t size; + struct { + uint8_t bssid[ETH_ALEN]; + uint8_t pmkid[IW_PMKID_LEN]; + } __attribute__((packed)) list[PMK_LIST_MAX]; + } __attribute__((packed)) pmkcache; + struct pmk_t *pmk; + struct list_head *ptr; + int i; + + DPRINTK(4,"pmklist.size=%d\n",priv->pmklist.size); + i=0; + list_for_each(ptr, &priv->pmklist.head){ + pmk = list_entry(ptr, struct pmk_t, list); + if(ibssid, ETH_ALEN); + memcpy(pmkcache.list[i].pmkid, pmk->pmkid, IW_PMKID_LEN); + i++; + } + } + pmkcache.size = cpu_to_le16((uint16_t)(priv->pmklist.size)); + hostif_mib_set_request(priv, LOCAL_PMK, + sizeof(priv->pmklist.size)+(ETH_ALEN+IW_PMKID_LEN)*(priv->pmklist.size), + MIB_VALUE_TYPE_OSTRING,&pmkcache ); +} + +/* execute sme */ +static +void hostif_sme_execute(ks_wlan_private *priv, int event) +{ + uint32_t val; + + DPRINTK(3,"event=%d\n",event); + switch (event) { + case SME_START: + if ( priv->dev_state == DEVICE_STATE_BOOT ){ + hostif_mib_get_request(priv, DOT11_MAC_ADDRESS); + } + break; + case SME_MULTICAST_REQUEST: + hostif_sme_multicast_set(priv); + break; + case SME_MACADDRESS_SET_REQUEST: + hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS, ETH_ALEN, + MIB_VALUE_TYPE_OSTRING, &priv->eth_addr[0]); + break; + case SME_BSS_SCAN_REQUEST: + hostif_bss_scan_request(priv, priv->reg.scan_type, priv->scan_ssid, priv->scan_ssid_len); + break; + case SME_POW_MNGMT_REQUEST: + hostif_sme_powermgt_set(priv); + break; + case SME_PHY_INFO_REQUEST: + hostif_phy_information_request(priv); + break; + case SME_MIC_FAILURE_REQUEST: + if(priv->wpa.mic_failure.failure == 1){ + hostif_mic_failure_request(priv, priv->wpa.mic_failure.failure-1, 0); + }else if(priv->wpa.mic_failure.failure == 2){ + hostif_mic_failure_request(priv, priv->wpa.mic_failure.failure-1, + priv->wpa.mic_failure.counter); + }else + DPRINTK(4,"SME_MIC_FAILURE_REQUEST: failure count=%u error?\n", + priv->wpa.mic_failure.failure); + break; + case SME_MIC_FAILURE_CONFIRM: + if(priv->wpa.mic_failure.failure == 2){ + if(priv->wpa.mic_failure.stop) + priv->wpa.mic_failure.stop = 0; + priv->wpa.mic_failure.failure = 0; + hostif_start_request( priv, priv->reg.operation_mode ); + } + break; + case SME_GET_MAC_ADDRESS: + if ( priv->dev_state == DEVICE_STATE_BOOT ){ + hostif_mib_get_request(priv, DOT11_PRODUCT_VERSION); + } + break; + case SME_GET_PRODUCT_VERSION: + if ( priv->dev_state == DEVICE_STATE_BOOT ){ + priv->dev_state = DEVICE_STATE_PREINIT; + } + break; + case SME_STOP_REQUEST: + hostif_stop_request(priv); + break; + case SME_RTS_THRESHOLD_REQUEST: + val = cpu_to_le32((uint32_t)(priv->reg.rts)); + hostif_mib_set_request(priv, DOT11_RTS_THRESHOLD, + sizeof(val), MIB_VALUE_TYPE_INT, + &val ); + break; + case SME_FRAGMENTATION_THRESHOLD_REQUEST: + val = cpu_to_le32((uint32_t)(priv->reg.fragment)); + hostif_mib_set_request(priv, DOT11_FRAGMENTATION_THRESHOLD, + sizeof(val), MIB_VALUE_TYPE_INT, + &val ); + break; + case SME_WEP_INDEX_REQUEST: case SME_WEP_KEY1_REQUEST: + case SME_WEP_KEY2_REQUEST: case SME_WEP_KEY3_REQUEST: + case SME_WEP_KEY4_REQUEST: case SME_WEP_FLAG_REQUEST: + hostif_sme_set_wep(priv,event); + break; + case SME_RSN_UCAST_REQUEST: case SME_RSN_MCAST_REQUEST: + case SME_RSN_AUTH_REQUEST: case SME_RSN_ENABLED_REQUEST: + case SME_RSN_MODE_REQUEST: + hostif_sme_set_rsn(priv,event); + break; + case SME_SET_FLAG: case SME_SET_TXKEY: + case SME_SET_KEY1: case SME_SET_KEY2: + case SME_SET_KEY3: case SME_SET_KEY4: + case SME_SET_PMK_TSC: case SME_SET_GMK1_TSC: + case SME_SET_GMK2_TSC: + hostif_sme_set_key(priv,event); + break; + case SME_SET_PMKSA: + hostif_sme_set_pmksa(priv); + break; +#ifdef WPS + case SME_WPS_ENABLE_REQUEST: + hostif_mib_set_request(priv, LOCAL_WPS_ENABLE, + sizeof(priv->wps.wps_enabled), + MIB_VALUE_TYPE_INT, &priv->wps.wps_enabled ); + break; + case SME_WPS_PROBE_REQUEST: + hostif_mib_set_request(priv, LOCAL_WPS_PROBE_REQ, + priv->wps.ielen, + MIB_VALUE_TYPE_OSTRING, priv->wps.ie); + break; +#endif /* WPS */ + case SME_MODE_SET_REQUEST: + hostif_sme_mode_setup(priv); + break; + case SME_SET_GAIN: + hostif_mib_set_request(priv, LOCAL_GAIN, + sizeof(priv->gain), MIB_VALUE_TYPE_OSTRING, + &priv->gain); + break; + case SME_GET_GAIN: + hostif_mib_get_request(priv, LOCAL_GAIN); + break; + case SME_GET_EEPROM_CKSUM: + priv->eeprom_checksum = EEPROM_FW_NOT_SUPPORT; /* initialize */ + hostif_mib_get_request(priv, LOCAL_EEPROM_SUM); + break; + case SME_START_REQUEST: + hostif_start_request( priv, priv->reg.operation_mode ); + break; + case SME_START_CONFIRM: + /* for power save */ + atomic_set(&priv->psstatus.snooze_guard, 0); + atomic_set(&priv->psstatus.confirm_wait,0); +#if !defined(_SDIO_) + atomic_set(&priv->psstatus.status, PS_NONE); +#endif + if ( priv->dev_state == DEVICE_STATE_PREINIT ){ + priv->dev_state = DEVICE_STATE_INIT; + } + /* wake_up_interruptible_all(&priv->confirm_wait); */ + complete(&priv->confirm_wait); + break; + case SME_SLEEP_REQUEST: + hostif_sme_sleep_set(priv); + break; + case SME_SET_REGION: + val = cpu_to_le32((uint32_t)(priv->region)); + hostif_mib_set_request(priv, LOCAL_REGION, + sizeof(val), MIB_VALUE_TYPE_INT, + &val ); + break; + case SME_MULTICAST_CONFIRM: + case SME_BSS_SCAN_CONFIRM: + case SME_POW_MNGMT_CONFIRM: + case SME_PHY_INFO_CONFIRM: + case SME_STOP_CONFIRM: + case SME_RTS_THRESHOLD_CONFIRM: + case SME_FRAGMENTATION_THRESHOLD_CONFIRM: + case SME_WEP_INDEX_CONFIRM: case SME_WEP_KEY1_CONFIRM: + case SME_WEP_KEY2_CONFIRM: case SME_WEP_KEY3_CONFIRM: + case SME_WEP_KEY4_CONFIRM: case SME_WEP_FLAG_CONFIRM: + case SME_RSN_UCAST_CONFIRM: case SME_RSN_MCAST_CONFIRM: + case SME_RSN_AUTH_CONFIRM: case SME_RSN_ENABLED_CONFIRM: + case SME_RSN_MODE_CONFIRM: + case SME_MODE_SET_CONFIRM: + break; + case SME_TERMINATE: + default: + break; + } +} + +static +void hostif_sme_task( unsigned long dev ) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev; + + DPRINTK(3,"\n"); + + if(priv->dev_state >= DEVICE_STATE_BOOT){ + if (0 < cnt_smeqbody(priv) && priv->dev_state >= DEVICE_STATE_BOOT) { + hostif_sme_execute(priv, priv->sme_i.event_buff[priv->sme_i.qhead]); + inc_smeqhead(priv); + if (0 < cnt_smeqbody(priv)) + tasklet_schedule(&priv->sme_task); + } + } + return; +} + +/* send to Station Management Entity module */ +void hostif_sme_enqueue(ks_wlan_private *priv, unsigned short event) +{ + DPRINTK(3,"\n"); + +#if !defined(_SDIO_) + if(atomic_read(&priv->psstatus.status)==PS_SNOOZE && event < SME_START_CONFIRM){ /* power save wakeup*/ + schedule_work(&priv->ks_wlan_wakeup_task); + if(atomic_read(&priv->sme_task.count) <= 0){ + /* schedule_work(&priv->ks_wlan_wakeup_task); */ + DPRINTK(4,"sme task disable.\n"); + tasklet_disable(&priv->sme_task); + } + } +#endif + + + /* enqueue sme event */ + if (cnt_smeqbody(priv) < (SME_EVENT_BUFF_SIZE - 1)) { + priv->sme_i.event_buff[priv->sme_i.qtail] = event; + inc_smeqtail(priv); + //DPRINTK(3,"inc_smeqtail \n"); +#ifdef KS_WLAN_DEBUG + if (priv->sme_i.max_event_count < cnt_smeqbody(priv)) + priv->sme_i.max_event_count = cnt_smeqbody(priv); +#endif /* KS_WLAN_DEBUG */ + } else { + /* in case of buffer overflow */ + //DPRINTK(2,"sme queue buffer overflow\n"); + printk("sme queue buffer overflow\n"); + } + + tasklet_schedule(&priv->sme_task); + +} + +int hostif_init( ks_wlan_private *priv ) +{ + int rc=0; + int i; + + DPRINTK(3,"\n"); + + priv->aplist.size =0; + for(i=0;iaplist.ap[i]),0,sizeof(struct local_ap_t)); + priv->infra_status = 0; + priv->current_rate = 4; + priv->connect_status = DISCONNECT_STATUS; + + spin_lock_init(&priv->multicast_spin); + + spin_lock_init(&priv->dev_read_lock); + init_waitqueue_head (&priv->devread_wait); + priv->dev_count = 0; + atomic_set(&priv->event_count, 0); + atomic_set(&priv->rec_count, 0); + + /* for power save */ + atomic_set(&priv->psstatus.status, PS_NONE); + atomic_set(&priv->psstatus.confirm_wait, 0); + atomic_set(&priv->psstatus.snooze_guard, 0); + /* init_waitqueue_head(&priv->psstatus.wakeup_wait); */ + init_completion(&priv->psstatus.wakeup_wait); + //INIT_WORK(&priv->ks_wlan_wakeup_task, ks_wlan_hw_wakeup_task, (void *)priv); + INIT_WORK(&priv->ks_wlan_wakeup_task, ks_wlan_hw_wakeup_task); + + /* WPA */ + memset(&(priv->wpa), 0, sizeof(priv->wpa)); + priv->wpa.rsn_enabled = 0; + priv->wpa.mic_failure.failure = 0; + priv->wpa.mic_failure.last_failure_time = 0; + priv->wpa.mic_failure.stop = 0; + memset(&(priv->pmklist), 0, sizeof(priv->pmklist)); + INIT_LIST_HEAD(&priv->pmklist.head); + for(i=0;ipmklist.pmk[i].list); + + priv->sme_i.sme_status = SME_IDLE; + priv->sme_i.qhead = priv->sme_i.qtail = 0; +#ifdef KS_WLAN_DEBUG + priv->sme_i.max_event_count = 0; +#endif + spin_lock_init(&priv->sme_i.sme_spin); + priv->sme_i.sme_flag = 0; + + tasklet_init(&priv->sme_task, hostif_sme_task, (unsigned long)priv); + + return rc; +} + +void hostif_exit( ks_wlan_private *priv ) +{ + tasklet_kill(&priv->sme_task); + return; +} + diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h new file mode 100644 index 0000000..24ebf1d --- /dev/null +++ b/drivers/staging/ks7010/ks_hostif.h @@ -0,0 +1,648 @@ +/* + * Driver for KeyStream wireless LAN + * + * ks_hostif.h + * $Id: ks_hostif.h 994 2009-09-14 01:51:16Z sekine $ + * + * Copyright (c) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#ifndef _KS_HOSTIF_H_ +#define _KS_HOSTIF_H_ +/* + * HOST-MAC I/F events + */ +#define HIF_DATA_REQ 0xE001 +#define HIF_DATA_IND 0xE801 +#define HIF_MIB_GET_REQ 0xE002 +#define HIF_MIB_GET_CONF 0xE802 +#define HIF_MIB_SET_REQ 0xE003 +#define HIF_MIB_SET_CONF 0xE803 +#define HIF_POWERMGT_REQ 0xE004 +#define HIF_POWERMGT_CONF 0xE804 +#define HIF_START_REQ 0xE005 +#define HIF_START_CONF 0xE805 +#define HIF_CONNECT_IND 0xE806 +#define HIF_STOP_REQ 0xE006 +#define HIF_STOP_CONF 0xE807 +#define HIF_PS_ADH_SET_REQ 0xE007 +#define HIF_PS_ADH_SET_CONF 0xE808 +#define HIF_INFRA_SET_REQ 0xE008 +#define HIF_INFRA_SET_CONF 0xE809 +#define HIF_ADH_SET_REQ 0xE009 +#define HIF_ADH_SET_CONF 0xE80A +#define HIF_AP_SET_REQ 0xE00A +#define HIF_AP_SET_CONF 0xE80B +#define HIF_ASSOC_INFO_IND 0xE80C +#define HIF_MIC_FAILURE_REQ 0xE00B +#define HIF_MIC_FAILURE_CONF 0xE80D +#define HIF_SCAN_REQ 0xE00C +#define HIF_SCAN_CONF 0xE80E +#define HIF_PHY_INFO_REQ 0xE00D +#define HIF_PHY_INFO_CONF 0xE80F +#define HIF_SLEEP_REQ 0xE00E +#define HIF_SLEEP_CONF 0xE810 +#define HIF_PHY_INFO_IND 0xE811 +#define HIF_SCAN_IND 0xE812 +#define HIF_INFRA_SET2_REQ 0xE00F +#define HIF_INFRA_SET2_CONF 0xE813 +#define HIF_ADH_SET2_REQ 0xE010 +#define HIF_ADH_SET2_CONF 0xE814 + +#define HIF_REQ_MAX 0xE010 + +/* + * HOST-MAC I/F data structure + * Byte alignmet Little Endian + */ + +struct hostif_hdr { + uint16_t size; + uint16_t event; +} __attribute__((packed)); + +struct hostif_data_request_t { + struct hostif_hdr header; + uint16_t auth_type; +#define TYPE_DATA 0x0000 +#define TYPE_AUTH 0x0001 + uint16_t reserved; + uint8_t data[0]; +} __attribute__((packed)); + +struct hostif_data_indication_t { + struct hostif_hdr header; + uint16_t auth_type; +/* #define TYPE_DATA 0x0000 */ +#define TYPE_PMK1 0x0001 +#define TYPE_GMK1 0x0002 +#define TYPE_GMK2 0x0003 + uint16_t reserved; + uint8_t data[0]; +} __attribute__((packed)); + +#define CHANNEL_LIST_MAX_SIZE 14 +struct channel_list_t { + uint8_t size; + uint8_t body[CHANNEL_LIST_MAX_SIZE]; + uint8_t pad; +} __attribute__((packed)); + +/* MIB Attribute */ +#define DOT11_MAC_ADDRESS 0x21010100 /* MAC Address (R) */ +#define DOT11_PRODUCT_VERSION 0x31024100 /* FirmWare Version (R)*/ +#define DOT11_RTS_THRESHOLD 0x21020100 /* RTS Threshold (R/W) */ +#define DOT11_FRAGMENTATION_THRESHOLD 0x21050100 /* Fragment Threshold (R/W) */ +#define DOT11_PRIVACY_INVOKED 0x15010100 /* WEP ON/OFF (W) */ +#define DOT11_WEP_DEFAULT_KEY_ID 0x15020100 /* WEP Index (W) */ +#define DOT11_WEP_DEFAULT_KEY_VALUE1 0x13020101 /* WEP Key#1(TKIP AES: PairwiseTemporalKey) (W) */ +#define DOT11_WEP_DEFAULT_KEY_VALUE2 0x13020102 /* WEP Key#2(TKIP AES: GroupKey1) (W) */ +#define DOT11_WEP_DEFAULT_KEY_VALUE3 0x13020103 /* WEP Key#3(TKIP AES: GroupKey2) (W) */ +#define DOT11_WEP_DEFAULT_KEY_VALUE4 0x13020104 /* WEP Key#4 (W) */ +#define DOT11_WEP_LIST 0x13020100 /* WEP LIST */ +#define DOT11_DESIRED_SSID 0x11090100 /* SSID */ +#define DOT11_CURRENT_CHANNEL 0x45010100 /* channel set */ +#define DOT11_OPERATION_RATE_SET 0x11110100 /* rate set */ + +#define LOCAL_AP_SEARCH_INTEAVAL 0xF1010100 /* AP search interval (R/W) */ +#define LOCAL_CURRENTADDRESS 0xF1050100 /* MAC Adress change (W) */ +#define LOCAL_MULTICAST_ADDRESS 0xF1060100 /* Multicast Adress (W) */ +#define LOCAL_MULTICAST_FILTER 0xF1060200 /* Multicast Adress Filter enable/disable (W) */ +#define LOCAL_SEARCHED_AP_LIST 0xF1030100 /* AP list (R) */ +#define LOCAL_LINK_AP_STATUS 0xF1040100 /* Link AP status (R) */ +#define LOCAL_PACKET_STATISTICS 0xF1020100 /* tx,rx packets statistics */ +#define LOCAL_AP_SCAN_LIST_TYPE_SET 0xF1030200 /* AP_SCAN_LIST_TYPE */ + +#define DOT11_RSN_ENABLED 0x15070100 /* WPA enable/disable (W) */ +#define LOCAL_RSN_MODE 0x56010100 /* RSN mode WPA/WPA2 (W) */ +#define DOT11_RSN_CONFIG_MULTICAST_CIPHER 0x51040100 /* GroupKeyCipherSuite (W) */ +#define DOT11_RSN_CONFIG_UNICAST_CIPHER 0x52020100 /* PairwiseKeyCipherSuite (W) */ +#define DOT11_RSN_CONFIG_AUTH_SUITE 0x53020100 /* AuthenticationKeyManagementSuite (W) */ +#define DOT11_RSN_CONFIG_VERSION 0x51020100 /* RSN version (W) */ +#define LOCAL_RSN_CONFIG_ALL 0x5F010100 /* RSN CONFIG ALL (W) */ +#define DOT11_PMK_TSC 0x55010100 /* PMK_TSC (W) */ +#define DOT11_GMK1_TSC 0x55010101 /* GMK1_TSC (W) */ +#define DOT11_GMK2_TSC 0x55010102 /* GMK2_TSC (W) */ +#define DOT11_GMK3_TSC 0x55010103 /* GMK3_TSC */ +#define LOCAL_PMK 0x58010100 /* Pairwise Master Key cache (W) */ + +#define LOCAL_REGION 0xF10A0100 /* Region setting */ + +#ifdef WPS +#define LOCAL_WPS_ENABLE 0xF10B0100 /* WiFi Protected Setup */ +#define LOCAL_WPS_PROBE_REQ 0xF10C0100 /* WPS Probe Request */ +#endif /* WPS */ + +#define LOCAL_GAIN 0xF10D0100 /* Carrer sense threshold for demo ato show */ +#define LOCAL_EEPROM_SUM 0xF10E0100 /* EEPROM checksum information */ + +struct hostif_mib_get_request_t { + struct hostif_hdr header; + uint32_t mib_attribute; +} __attribute__((packed)); + + +struct hostif_mib_value_t { + uint16_t size; + uint16_t type; +#define MIB_VALUE_TYPE_NULL 0 +#define MIB_VALUE_TYPE_INT 1 +#define MIB_VALUE_TYPE_BOOL 2 +#define MIB_VALUE_TYPE_COUNT32 3 +#define MIB_VALUE_TYPE_OSTRING 4 + uint8_t body[0]; +} __attribute__((packed)); + +struct hostif_mib_get_confirm_t { + struct hostif_hdr header; + uint32_t mib_status; +#define MIB_SUCCESS 0 +#define MIB_INVALID 1 +#define MIB_READ_ONLY 2 +#define MIB_WRITE_ONLY 3 + uint32_t mib_attribute; + struct hostif_mib_value_t mib_value; +} __attribute__((packed)); + +struct hostif_mib_set_request_t { + struct hostif_hdr header; + uint32_t mib_attribute; + struct hostif_mib_value_t mib_value; +} __attribute__((packed)); + +struct hostif_mib_set_confirm_t { + struct hostif_hdr header; + uint32_t mib_status; + uint32_t mib_attribute; +} __attribute__((packed)); + +struct hostif_power_mngmt_request_t { + struct hostif_hdr header; + uint32_t mode; +#define POWER_ACTIVE 1 +#define POWER_SAVE 2 + uint32_t wake_up; +#define SLEEP_FALSE 0 +#define SLEEP_TRUE 1 /* not used */ + uint32_t receiveDTIMs; +#define DTIM_FALSE 0 +#define DTIM_TRUE 1 +} __attribute__((packed)); + +/* power management mode */ +enum { + POWMGT_ACTIVE_MODE=0, + POWMGT_SAVE1_MODE, + POWMGT_SAVE2_MODE +}; + +#define RESULT_SUCCESS 0 +#define RESULT_INVALID_PARAMETERS 1 +#define RESULT_NOT_SUPPORTED 2 +/* #define RESULT_ALREADY_RUNNING 3 */ +#define RESULT_ALREADY_RUNNING 7 + +struct hostif_power_mngmt_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +struct hostif_start_request_t { + struct hostif_hdr header; + uint16_t mode; +#define MODE_PSEUDO_ADHOC 0 +#define MODE_INFRASTRUCTURE 1 +#define MODE_AP 2 /* not used */ +#define MODE_ADHOC 3 +} __attribute__((packed)); + +struct hostif_start_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +#define SSID_MAX_SIZE 32 +struct ssid_t { + uint8_t size; + uint8_t body[SSID_MAX_SIZE]; + uint8_t ssid_pad; +} __attribute__((packed)); + +#define RATE_SET_MAX_SIZE 16 +struct rate_set8_t { + uint8_t size; + uint8_t body[8]; + uint8_t rate_pad; +} __attribute__((packed)); + +struct FhParms_t { + uint16_t dwellTime; + uint8_t hopSet; + uint8_t hopPattern; + uint8_t hopIndex; +} __attribute__((packed)); + +struct DsParms_t { + uint8_t channel; +} __attribute__((packed)); + +struct CfParms_t { + uint8_t count; + uint8_t period; + uint16_t maxDuration; + uint16_t durRemaining; +} __attribute__((packed)); + +struct IbssParms_t { + uint16_t atimWindow; +} __attribute__((packed)); + + +struct rsn_t { + uint8_t size; +#define RSN_BODY_SIZE 64 + uint8_t body[RSN_BODY_SIZE]; +} __attribute__((packed)); + +struct ErpParams_t { + uint8_t erp_info; +} __attribute__((packed)); + +struct rate_set16_t{ + uint8_t size; + uint8_t body[16]; + uint8_t rate_pad; +} __attribute__((packed)); + +struct ap_info_t{ + uint8_t bssid[6]; /* +00 */ + uint8_t rssi; /* +06 */ + uint8_t sq; /* +07 */ + uint8_t noise; /* +08 */ + uint8_t pad0; /* +09 */ + uint16_t beacon_period; /* +10 */ + uint16_t capability; /* +12 */ +#define BSS_CAP_ESS (1<<0) +#define BSS_CAP_IBSS (1<<1) +#define BSS_CAP_CF_POLABLE (1<<2) +#define BSS_CAP_CF_POLL_REQ (1<<3) +#define BSS_CAP_PRIVACY (1<<4) +#define BSS_CAP_SHORT_PREAMBLE (1<<5) +#define BSS_CAP_PBCC (1<<6) +#define BSS_CAP_CHANNEL_AGILITY (1<<7) +#define BSS_CAP_SHORT_SLOT_TIME (1<<10) +#define BSS_CAP_DSSS_OFDM (1<<13) + uint8_t frame_type; /* +14 */ + uint8_t ch_info; /* +15 */ +#define FRAME_TYPE_BEACON 0x80 +#define FRAME_TYPE_PROBE_RESP 0x50 + uint16_t body_size; /* +16 */ + uint8_t body[1024]; /* +18 */ + /* +1032 */ +} __attribute__((packed)); + +struct link_ap_info_t{ + uint8_t bssid[6]; /* +00 */ + uint8_t rssi; /* +06 */ + uint8_t sq; /* +07 */ + uint8_t noise; /* +08 */ + uint8_t pad0; /* +09 */ + uint16_t beacon_period; /* +10 */ + uint16_t capability; /* +12 */ + struct rate_set8_t rate_set; /* +14 */ + struct FhParms_t fh_parameter; /* +24 */ + struct DsParms_t ds_parameter; /* +29 */ + struct CfParms_t cf_parameter; /* +30 */ + struct IbssParms_t ibss_parameter; /* +36 */ + struct ErpParams_t erp_parameter; /* +38 */ + uint8_t pad1; /* +39 */ + struct rate_set8_t ext_rate_set; /* +40 */ + uint8_t DTIM_period; /* +50 */ + uint8_t rsn_mode; /* +51 */ +#define RSN_MODE_NONE 0 +#define RSN_MODE_WPA 1 +#define RSN_MODE_WPA2 2 + struct { + uint8_t size; /* +52 */ + uint8_t body[128]; /* +53 */ + } __attribute__((packed)) rsn; +} __attribute__((packed)); + +struct hostif_connect_indication_t { + struct hostif_hdr header; + uint16_t connect_code; +#define RESULT_CONNECT 0 +#define RESULT_DISCONNECT 1 + struct link_ap_info_t link_ap_info; +} __attribute__((packed)); + +struct hostif_stop_request_t { + struct hostif_hdr header; +} __attribute__((packed)); + +struct hostif_stop_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +struct hostif_ps_adhoc_set_request_t { + struct hostif_hdr header; + uint16_t phy_type; +#define D_11B_ONLY_MODE 0 +#define D_11G_ONLY_MODE 1 +#define D_11BG_COMPATIBLE_MODE 2 +#define D_11A_ONLY_MODE 3 + uint16_t cts_mode; +#define CTS_MODE_FALSE 0 +#define CTS_MODE_TRUE 1 + uint16_t channel; + struct rate_set16_t rate_set; + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t scan_type; +} __attribute__((packed)); + +struct hostif_ps_adhoc_set_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +struct hostif_infrastructure_set_request_t { + struct hostif_hdr header; + uint16_t phy_type; + uint16_t cts_mode; + struct rate_set16_t rate_set; + struct ssid_t ssid; + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t beacon_lost_count; + uint16_t auth_type; +#define AUTH_TYPE_OPEN_SYSTEM 0 +#define AUTH_TYPE_SHARED_KEY 1 + struct channel_list_t channel_list; + uint16_t scan_type; +} __attribute__((packed)); + +struct hostif_infrastructure_set2_request_t { + struct hostif_hdr header; + uint16_t phy_type; + uint16_t cts_mode; + struct rate_set16_t rate_set; + struct ssid_t ssid; + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t beacon_lost_count; + uint16_t auth_type; +#define AUTH_TYPE_OPEN_SYSTEM 0 +#define AUTH_TYPE_SHARED_KEY 1 + struct channel_list_t channel_list; + uint16_t scan_type; + uint8_t bssid[ETH_ALEN]; +} __attribute__((packed)); + + +struct hostif_infrastructure_set_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +struct hostif_adhoc_set_request_t { + struct hostif_hdr header; + uint16_t phy_type; + uint16_t cts_mode; + uint16_t channel; + struct rate_set16_t rate_set; + struct ssid_t ssid; + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t scan_type; +} __attribute__((packed)); + +struct hostif_adhoc_set2_request_t { + struct hostif_hdr header; + uint16_t phy_type; + uint16_t cts_mode; + uint16_t reserved; + struct rate_set16_t rate_set; + struct ssid_t ssid; + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t scan_type; + struct channel_list_t channel_list; + uint8_t bssid[ETH_ALEN]; +} __attribute__((packed)); + +struct hostif_adhoc_set_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + + +struct last_associate_t { + uint8_t type; + uint8_t status; +} __attribute__((packed)); + +struct association_request_t { + uint8_t type; +#define FRAME_TYPE_ASSOC_REQ 0x00 +#define FRAME_TYPE_REASSOC_REQ 0x20 + uint8_t pad; + uint16_t capability; + uint16_t listen_interval; + uint8_t ap_address[6]; + uint16_t reqIEs_size; +} __attribute__((packed)); + +struct association_response_t { + uint8_t type; +#define FRAME_TYPE_ASSOC_RESP 0x10 +#define FRAME_TYPE_REASSOC_RESP 0x30 + uint8_t pad; + uint16_t capability; + uint16_t status; + uint16_t association_id; + uint16_t respIEs_size; +} __attribute__((packed)); + +struct hostif_associate_indication_t { + struct hostif_hdr header; + struct association_request_t assoc_req; + struct association_response_t assoc_resp; + /* followed by (reqIEs_size + respIEs_size) octets of data */ + /* reqIEs data *//* respIEs data */ +} __attribute__((packed)); + +struct hostif_bss_scan_request_t { + struct hostif_hdr header; + uint8_t scan_type; +#define ACTIVE_SCAN 0 +#define PASSIVE_SCAN 1 + uint8_t pad[3]; + uint32_t ch_time_min; + uint32_t ch_time_max; + struct channel_list_t channel_list; + struct ssid_t ssid; +} __attribute__((packed)); + +struct hostif_bss_scan_confirm_t { + struct hostif_hdr header; + uint16_t result_code; + uint16_t reserved; +} __attribute__((packed)); + +struct hostif_phy_information_request_t { + struct hostif_hdr header; + uint16_t type; +#define NORMAL_TYPE 0 +#define TIME_TYPE 1 + uint16_t time; /* unit 100ms */ +} __attribute__((packed)); + +struct hostif_phy_information_confirm_t { + struct hostif_hdr header; + uint8_t rssi; + uint8_t sq; + uint8_t noise; + uint8_t link_speed; + uint32_t tx_frame; + uint32_t rx_frame; + uint32_t tx_error; + uint32_t rx_error; +} __attribute__((packed)); + +/* sleep mode */ +#define SLP_ACTIVE 0 +#define SLP_SLEEP 1 +struct hostif_sleep_request_t { + struct hostif_hdr header; +} __attribute__((packed)); + +struct hostif_sleep_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +struct hostif_mic_failure_request_t { + struct hostif_hdr header; + uint16_t failure_count; + uint16_t timer; +} __attribute__((packed)); + +struct hostif_mic_failure_confirm_t { + struct hostif_hdr header; + uint16_t result_code; +} __attribute__((packed)); + +#define BASIC_RATE 0x80 +#define RATE_MASK 0x7F + +#define TX_RATE_AUTO 0xff +#define TX_RATE_1M_FIXED 0 +#define TX_RATE_2M_FIXED 1 +#define TX_RATE_1_2M_AUTO 2 +#define TX_RATE_5M_FIXED 3 +#define TX_RATE_11M_FIXED 4 + +#define TX_RATE_FULL_AUTO 0 +#define TX_RATE_11_AUTO 1 +#define TX_RATE_11B_AUTO 2 +#define TX_RATE_11BG_AUTO 3 +#define TX_RATE_MANUAL_AUTO 4 +#define TX_RATE_FIXED 5 + +/* 11b rate */ +#define TX_RATE_1M (uint8_t)(10/5) /* 11b 11g basic rate */ +#define TX_RATE_2M (uint8_t)(20/5) /* 11b 11g basic rate */ +#define TX_RATE_5M (uint8_t)(55/5) /* 11g basic rate */ +#define TX_RATE_11M (uint8_t)(110/5) /* 11g basic rate */ + +/* 11g rate */ +#define TX_RATE_6M (uint8_t)(60/5) /* 11g basic rate */ +#define TX_RATE_12M (uint8_t)(120/5) /* 11g basic rate */ +#define TX_RATE_24M (uint8_t)(240/5) /* 11g basic rate */ +#define TX_RATE_9M (uint8_t)(90/5) +#define TX_RATE_18M (uint8_t)(180/5) +#define TX_RATE_36M (uint8_t)(360/5) +#define TX_RATE_48M (uint8_t)(480/5) +#define TX_RATE_54M (uint8_t)(540/5) + +#define IS_11B_RATE(A) (((A&RATE_MASK)==TX_RATE_1M)||((A&RATE_MASK)==TX_RATE_2M)||\ + ((A&RATE_MASK)==TX_RATE_5M)||((A&RATE_MASK)==TX_RATE_11M)) + +#define IS_OFDM_RATE(A) (((A&RATE_MASK)==TX_RATE_6M)||((A&RATE_MASK)==TX_RATE_12M)||\ + ((A&RATE_MASK)==TX_RATE_24M)||((A&RATE_MASK)==TX_RATE_9M)||\ + ((A&RATE_MASK)==TX_RATE_18M)||((A&RATE_MASK)==TX_RATE_36M)||\ + ((A&RATE_MASK)==TX_RATE_48M)||((A&RATE_MASK)==TX_RATE_54M)) + +#define IS_11BG_RATE(A) (IS_11B_RATE(A)||IS_OFDM_RATE(A)) + +#define IS_OFDM_EXT_RATE(A) (((A&RATE_MASK)==TX_RATE_9M)||((A&RATE_MASK)==TX_RATE_18M)||\ + ((A&RATE_MASK)==TX_RATE_36M)||((A&RATE_MASK)==TX_RATE_48M)||\ + ((A&RATE_MASK)==TX_RATE_54M)) + +enum { + CONNECT_STATUS=0, + DISCONNECT_STATUS +}; + +/* preamble type */ +enum { + LONG_PREAMBLE=0, + SHORT_PREAMBLE +}; + +/* multicast filter */ +#define MCAST_FILTER_MCAST 0 +#define MCAST_FILTER_MCASTALL 1 +#define MCAST_FILTER_PROMISC 2 + +#define NIC_MAX_MCAST_LIST 32 + +/* macro function */ +#define HIF_EVENT_MASK 0xE800 +#define IS_HIF_IND(_EVENT) ((_EVENT&HIF_EVENT_MASK)==0xE800 && \ + ((_EVENT&~HIF_EVENT_MASK)==0x0001 || \ + (_EVENT&~HIF_EVENT_MASK)==0x0006 || \ + (_EVENT&~HIF_EVENT_MASK)==0x000C || \ + (_EVENT&~HIF_EVENT_MASK)==0x0011 || \ + (_EVENT&~HIF_EVENT_MASK)==0x0012)) + +#define IS_HIF_CONF(_EVENT) ((_EVENT&HIF_EVENT_MASK)==0xE800 && \ + (_EVENT&~HIF_EVENT_MASK)>0x0000 && \ + (_EVENT&~HIF_EVENT_MASK)<0x0012 && \ + !IS_HIF_IND(_EVENT) ) + +#ifdef __KERNEL__ + +#include "ks_wlan.h" + +/* function prototype */ +extern int hostif_data_request( ks_wlan_private *priv, struct sk_buff *packet ); +extern void hostif_receive( ks_wlan_private *priv, unsigned char *p, unsigned int size ); +extern void hostif_sme_enqueue(ks_wlan_private *priv, uint16_t event); +extern int hostif_init( ks_wlan_private *priv ); +extern void hostif_exit( ks_wlan_private *priv ); + +static +inline int hif_align_size(int size) +{ +#ifdef KS_ATOM + if( size < 1024 ) + size = 1024; +#endif +#ifdef DEVICE_ALIGNMENT + return (size%DEVICE_ALIGNMENT) ? size + DEVICE_ALIGNMENT - (size % DEVICE_ALIGNMENT) : size; +#else + return size; +#endif +} + +#endif /* __KERNEL__ */ + +#endif /* _KS_HOSTIF_H_ */ diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h new file mode 100644 index 0000000..c7cbde1 --- /dev/null +++ b/drivers/staging/ks7010/ks_wlan.h @@ -0,0 +1,541 @@ +/* + * Driver for KeyStream IEEE802.11 b/g wireless LAN cards. + * + * ks_wlan.h + * $Id: ks_wlan.h 994 2009-09-14 01:51:16Z sekine $ + * + * Copyright (C) 2006-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#ifndef _KS_WLAN_H +#define _KS_WLAN_H + +#define WPS + +#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) +#include +#endif +#include +#include +#include + +#include /* spinlock_t */ +#include /* wait_queue_head_t */ +#include /* pid_t */ +#include /* struct net_device_stats, struct sk_buff */ +#include +#include +#include /* struct atmic_t */ +#include /* struct timer_list */ +#include +#include /* struct completion */ + +#include + +/* Workqueue / task queue backwards compatibility stuff */ +#if ((LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41)) || (defined _MVL31_) || (defined _CELF3_)) +#include +#else +#include +#define work_struct tq_struct +#define INIT_WORK INIT_TQUEUE +#define schedule_work schedule_task +#endif + +/* Interrupt handler backwards compatibility stuff */ +/* +#ifndef IRQ_NONE +#define IRQ_NONE +#define IRQ_HANDLED +typedef void irqreturn_t; +#endif +*/ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) +#define free_netdev(x) kfree(x) +#define pci_name(x) x->slot_name +#endif + +#if (defined _PCMCIA_) +#include "pcmcia/ks7010_pcmcia.h" +#elif (defined _PCI_) +#include "pci/ks7010_pci.h" +#elif (defined _SDIO_) +#include "ks7010_sdio.h" +#elif (defined _SPI_) +#include "spi/ks7010_spi.h" +#else +#error not defined bus type ! +#endif + +struct ks_wlan_parameter { + uint8_t operation_mode; /* Operation Mode */ + uint8_t channel; /* Channel */ + uint8_t tx_rate; /* Transmit Rate */ + struct { + uint8_t size; + uint8_t body[16]; + } rate_set; + uint8_t bssid[ETH_ALEN]; /* BSSID */ + struct { + uint8_t size; + uint8_t body[32+1]; + } ssid; /* SSID */ + uint8_t preamble; /* Preamble */ + uint8_t powermgt; /* PowerManagementMode */ + uint32_t scan_type; /* AP List Scan Type */ +#define BEACON_LOST_COUNT_MIN 0 +#define BEACON_LOST_COUNT_MAX 65535 + uint32_t beacon_lost_count; /* Beacon Lost Count */ + uint32_t rts; /* RTS Threashold */ + uint32_t fragment; /* Fragmentation Threashold */ + uint32_t privacy_invoked; + uint32_t wep_index; + struct { + uint8_t size; + uint8_t val[13*2+1]; + } wep_key[4]; + uint16_t authenticate_type; + uint16_t phy_type; /* 11b/11g/11bg mode type*/ + uint16_t cts_mode; /* for 11g/11bg mode cts mode */ + uint16_t phy_info_timer; /* phy information timer */ + char rom_file[256]; +}; + +enum { + DEVICE_STATE_OFF = 0, /* this means hw_unavailable is != 0 */ + DEVICE_STATE_PREBOOT, /* we are in a pre-boot state (empty RAM) */ + DEVICE_STATE_BOOT, /* boot state (fw upload, run fw) */ + DEVICE_STATE_PREINIT, /* pre-init state */ + DEVICE_STATE_INIT, /* init state (restore MIB backup to device) */ + DEVICE_STATE_READY, /* driver&device are in operational state */ + DEVICE_STATE_SLEEP /* device in sleep mode */ +}; + +/* SME flag */ +#define SME_MODE_SET (1<<0) +#define SME_RTS (1<<1) +#define SME_FRAG (1<<2) +#define SME_WEP_FLAG (1<<3) +#define SME_WEP_INDEX (1<<4) +#define SME_WEP_VAL1 (1<<5) +#define SME_WEP_VAL2 (1<<6) +#define SME_WEP_VAL3 (1<<7) +#define SME_WEP_VAL4 (1<<8) +#define SME_WEP_VAL_MASK (SME_WEP_VAL1|SME_WEP_VAL2|SME_WEP_VAL3|SME_WEP_VAL4) +#define SME_RSN (1<<9) +#define SME_RSN_MULTICAST (1<<10) +#define SME_RSN_UNICAST (1<<11) +#define SME_RSN_AUTH (1<<12) + +#define SME_AP_SCAN (1<<13) +#define SME_MULTICAST (1<<14) + +/* SME Event */ +enum { + SME_START, + + SME_MULTICAST_REQUEST, + SME_MACADDRESS_SET_REQUEST, + SME_BSS_SCAN_REQUEST, + SME_SET_FLAG, + SME_SET_TXKEY, + SME_SET_KEY1, + SME_SET_KEY2, + SME_SET_KEY3, + SME_SET_KEY4, + SME_SET_PMK_TSC, + SME_SET_GMK1_TSC, + SME_SET_GMK2_TSC, + SME_SET_GMK3_TSC, + SME_SET_PMKSA, + SME_POW_MNGMT_REQUEST, + SME_PHY_INFO_REQUEST, + SME_MIC_FAILURE_REQUEST, + SME_GET_MAC_ADDRESS, + SME_GET_PRODUCT_VERSION, + SME_STOP_REQUEST, + SME_RTS_THRESHOLD_REQUEST, + SME_FRAGMENTATION_THRESHOLD_REQUEST, + SME_WEP_INDEX_REQUEST, + SME_WEP_KEY1_REQUEST, + SME_WEP_KEY2_REQUEST, + SME_WEP_KEY3_REQUEST, + SME_WEP_KEY4_REQUEST, + SME_WEP_FLAG_REQUEST, + SME_RSN_UCAST_REQUEST, + SME_RSN_MCAST_REQUEST, + SME_RSN_AUTH_REQUEST, + SME_RSN_ENABLED_REQUEST, + SME_RSN_MODE_REQUEST, +#ifdef WPS + SME_WPS_ENABLE_REQUEST, + SME_WPS_PROBE_REQUEST, +#endif + SME_SET_GAIN, + SME_GET_GAIN, + SME_SLEEP_REQUEST, + SME_SET_REGION, + SME_MODE_SET_REQUEST, + SME_START_REQUEST, + SME_GET_EEPROM_CKSUM, + + + SME_MIC_FAILURE_CONFIRM, + SME_START_CONFIRM, + + SME_MULTICAST_CONFIRM, + SME_BSS_SCAN_CONFIRM, + SME_GET_CURRENT_AP, + SME_POW_MNGMT_CONFIRM, + SME_PHY_INFO_CONFIRM, + SME_STOP_CONFIRM, + SME_RTS_THRESHOLD_CONFIRM, + SME_FRAGMENTATION_THRESHOLD_CONFIRM, + SME_WEP_INDEX_CONFIRM, + SME_WEP_KEY1_CONFIRM, + SME_WEP_KEY2_CONFIRM, + SME_WEP_KEY3_CONFIRM, + SME_WEP_KEY4_CONFIRM, + SME_WEP_FLAG_CONFIRM, + SME_RSN_UCAST_CONFIRM, + SME_RSN_MCAST_CONFIRM, + SME_RSN_AUTH_CONFIRM, + SME_RSN_ENABLED_CONFIRM, + SME_RSN_MODE_CONFIRM, + SME_MODE_SET_CONFIRM, + SME_SLEEP_CONFIRM, + + SME_RSN_SET_CONFIRM, + SME_WEP_SET_CONFIRM, + SME_TERMINATE, + + SME_EVENT_SIZE /* end */ +}; + +/* SME Status */ +enum { + SME_IDLE, + SME_SETUP, + SME_DISCONNECT, + SME_CONNECT +}; + +#define SME_EVENT_BUFF_SIZE 128 + +struct sme_info{ + int sme_status; + int event_buff[SME_EVENT_BUFF_SIZE]; + unsigned int qhead; + unsigned int qtail; +#ifdef KS_WLAN_DEBUG + /* for debug */ + unsigned int max_event_count; +#endif + spinlock_t sme_spin; + unsigned long sme_flag; +}; + +struct hostt_t{ + int buff[SME_EVENT_BUFF_SIZE]; + unsigned int qhead; + unsigned int qtail; +}; + +#define RSN_IE_BODY_MAX 64 +struct rsn_ie_t { + uint8_t id; /* 0xdd = WPA or 0x30 = RSN */ + uint8_t size; /* max ? 255 ? */ + uint8_t body[RSN_IE_BODY_MAX]; +} __attribute__((packed)); + +#ifdef WPS +#define WPS_IE_BODY_MAX 255 +struct wps_ie_t { + uint8_t id; /* 221 'dd 00 50 F2 04' */ + uint8_t size; /* max ? 255 ? */ + uint8_t body[WPS_IE_BODY_MAX]; +} __attribute__((packed)); +#endif /* WPS */ + +struct local_ap_t { + uint8_t bssid[6]; + uint8_t rssi; + uint8_t sq; + struct { + uint8_t size; + uint8_t body[32]; + uint8_t ssid_pad; + } ssid; + struct { + uint8_t size; + uint8_t body[16]; + uint8_t rate_pad; + } rate_set; + uint16_t capability; + uint8_t channel; + uint8_t noise; + struct rsn_ie_t wpa_ie; + struct rsn_ie_t rsn_ie; +#ifdef WPS + struct wps_ie_t wps_ie; +#endif /* WPS */ +}; + +#define LOCAL_APLIST_MAX 31 +#define LOCAL_CURRENT_AP LOCAL_APLIST_MAX +struct local_aplist_t { + int size; + struct local_ap_t ap[LOCAL_APLIST_MAX+1]; +}; + +struct local_gain_t{ + uint8_t TxMode; + uint8_t RxMode; + uint8_t TxGain; + uint8_t RxGain; +}; + +struct local_eeprom_sum_t{ + uint8_t type; + uint8_t result; +}; + +enum { + EEPROM_OK, + EEPROM_CHECKSUM_NONE, + EEPROM_FW_NOT_SUPPORT, + EEPROM_NG, +}; + + +/* Power Save Status */ +enum { + PS_NONE, + PS_ACTIVE_SET, + PS_SAVE_SET, + PS_CONF_WAIT, + PS_SNOOZE, + PS_WAKEUP +}; + +struct power_save_status_t { + atomic_t status; /* initialvalue 0 */ + struct completion wakeup_wait; + atomic_t confirm_wait; + atomic_t snooze_guard; +}; + +struct sleep_status_t { + atomic_t status; /* initialvalue 0 */ + atomic_t doze_request; + atomic_t wakeup_request; +}; + +/* WPA */ +struct scan_ext_t { + unsigned int flag; + char ssid[IW_ESSID_MAX_SIZE+1]; +}; + +enum { + CIPHER_NONE, + CIPHER_WEP40, + CIPHER_TKIP, + CIPHER_CCMP, + CIPHER_WEP104 +}; + +#define CIPHER_ID_WPA_NONE "\x00\x50\xf2\x00" +#define CIPHER_ID_WPA_WEP40 "\x00\x50\xf2\x01" +#define CIPHER_ID_WPA_TKIP "\x00\x50\xf2\x02" +#define CIPHER_ID_WPA_CCMP "\x00\x50\xf2\x04" +#define CIPHER_ID_WPA_WEP104 "\x00\x50\xf2\x05" + +#define CIPHER_ID_WPA2_NONE "\x00\x0f\xac\x00" +#define CIPHER_ID_WPA2_WEP40 "\x00\x0f\xac\x01" +#define CIPHER_ID_WPA2_TKIP "\x00\x0f\xac\x02" +#define CIPHER_ID_WPA2_CCMP "\x00\x0f\xac\x04" +#define CIPHER_ID_WPA2_WEP104 "\x00\x0f\xac\x05" + +#define CIPHER_ID_LEN 4 + +enum { + KEY_MGMT_802_1X, + KEY_MGMT_PSK, + KEY_MGMT_WPANONE, +}; + +#define KEY_MGMT_ID_WPA_NONE "\x00\x50\xf2\x00" +#define KEY_MGMT_ID_WPA_1X "\x00\x50\xf2\x01" +#define KEY_MGMT_ID_WPA_PSK "\x00\x50\xf2\x02" +#define KEY_MGMT_ID_WPA_WPANONE "\x00\x50\xf2\xff" + +#define KEY_MGMT_ID_WPA2_NONE "\x00\x0f\xac\x00" +#define KEY_MGMT_ID_WPA2_1X "\x00\x0f\xac\x01" +#define KEY_MGMT_ID_WPA2_PSK "\x00\x0f\xac\x02" +#define KEY_MGMT_ID_WPA2_WPANONE "\x00\x0f\xac\xff" + +#define KEY_MGMT_ID_LEN 4 + +#define MIC_KEY_SIZE 8 + +struct wpa_key_t { + uint32_t ext_flags; /* IW_ENCODE_EXT_xxx */ + uint8_t tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ + uint8_t rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ + struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast + * (group) keys or unicast address for + * individual keys */ + uint16_t alg; + uint16_t key_len; /* WEP: 5 or 13, TKIP: 32, CCMP: 16 */ + uint8_t key_val[IW_ENCODING_TOKEN_MAX]; + uint8_t tx_mic_key[MIC_KEY_SIZE]; + uint8_t rx_mic_key[MIC_KEY_SIZE]; +}; +#define WPA_KEY_INDEX_MAX 4 +#define WPA_RX_SEQ_LEN 6 + +struct mic_failure_t { + uint16_t failure; /* MIC Failure counter 0 or 1 or 2 */ + uint16_t counter; /* 1sec counter 0-60 */ + uint32_t last_failure_time; + int stop; /* stop flag */ +}; + +struct wpa_status_t { + int wpa_enabled; + unsigned int rsn_enabled; + int version; + int pairwise_suite; /* unicast cipher */ + int group_suite; /* multicast cipher */ + int key_mgmt_suite; /* authentication key management suite */ + int auth_alg; + int txkey; + struct wpa_key_t key[WPA_KEY_INDEX_MAX]; + struct scan_ext_t scan_ext; + struct mic_failure_t mic_failure; +}; + +#include +#define PMK_LIST_MAX 8 +struct pmk_list_t { + uint16_t size; + struct list_head head; + struct pmk_t { + struct list_head list; + uint8_t bssid[ETH_ALEN]; + uint8_t pmkid[IW_PMKID_LEN]; + } pmk[PMK_LIST_MAX]; +}; + +#ifdef WPS +struct wps_status_t { + int wps_enabled; + int ielen; + uint8_t ie[255]; +}; +#endif /* WPS */ + +typedef struct ks_wlan_private{ + + struct hw_info_t ks_wlan_hw; /* hardware information */ + + struct net_device *net_dev; + int reg_net; /* register_netdev */ + struct net_device_stats nstats; + struct iw_statistics wstats; + + struct completion confirm_wait; + + /* trx device & sme */ + struct tx_device tx_dev; + struct rx_device rx_dev; + struct sme_info sme_i; + u8 *rxp; + unsigned int rx_size; + struct tasklet_struct sme_task; + struct work_struct ks_wlan_wakeup_task; + int scan_ind_count; + + unsigned char eth_addr[ETH_ALEN]; + + struct local_aplist_t aplist; + struct local_ap_t current_ap; + struct power_save_status_t psstatus; + struct sleep_status_t sleepstatus; + struct wpa_status_t wpa; + struct pmk_list_t pmklist; + /* wireless parameter */ + struct ks_wlan_parameter reg; + uint8_t current_rate; + + char nick[IW_ESSID_MAX_SIZE+1]; + + spinlock_t multicast_spin; + + spinlock_t dev_read_lock; + wait_queue_head_t devread_wait; + + unsigned int need_commit; /* for ioctl */ + + /* DeviceIoControl */ + int device_open_status; + atomic_t event_count; + atomic_t rec_count; + int dev_count; +#define DEVICE_STOCK_COUNT 20 + unsigned char *dev_data[DEVICE_STOCK_COUNT]; + int dev_size[DEVICE_STOCK_COUNT]; + + /* ioctl : IOCTL_FIRMWARE_VERSION */ + unsigned char firmware_version[128+1]; + int version_size; + + int mac_address_valid; /* Mac Address Status */ + + int dev_state; + + struct sk_buff *skb; + unsigned int cur_rx; /* Index into the Rx buffer of next Rx pkt. */ + /* spinlock_t lock; */ +#define FORCE_DISCONNECT 0x80000000 +#define CONNECT_STATUS_MASK 0x7FFFFFFF + uint32_t connect_status; /* connect status */ + int infra_status; /* Infractructure status */ + + uint8_t data_buff[0x1000]; + + uint8_t scan_ssid_len; + uint8_t scan_ssid[IW_ESSID_MAX_SIZE+1]; + struct local_gain_t gain; +#ifdef WPS + struct net_device *l2_dev; + int l2_fd; + struct wps_status_t wps; +#endif /* WPS */ + uint8_t sleep_mode; + + uint8_t region; + struct local_eeprom_sum_t eeprom_sum; + uint8_t eeprom_checksum; + + struct hostt_t hostt; + + unsigned long last_doze; + unsigned long last_wakeup; + + uint sdio_error_count; /* SDIO error */ + uint wakeup_count; /* for detect wakeup loop */ + +} ks_wlan_private; + + + +#endif /* _KS_WLAN_H */ diff --git a/drivers/staging/ks7010/ks_wlan_ioctl.h b/drivers/staging/ks7010/ks_wlan_ioctl.h new file mode 100644 index 0000000..e27f8fb --- /dev/null +++ b/drivers/staging/ks7010/ks_wlan_ioctl.h @@ -0,0 +1,69 @@ +/* + * Driver for KeyStream 11b/g wireless LAN + * + * ks_wlan_ioctl.h + * $Id: ks_wlan_ioctl.h 996 2009-09-14 02:54:21Z sekine $ + * + * Copyright (c) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#ifndef _KS_WLAN_IOCTL_H +#define _KS_WLAN_IOCTL_H + +#include +/* The low order bit identify a SET (0) or a GET (1) ioctl. */ + +/* SIOCIWFIRSTPRIV+0 */ +#define KS_WLAN_GET_DRIVER_VERSION SIOCIWFIRSTPRIV+1 +/* SIOCIWFIRSTPRIV+2 */ +#define KS_WLAN_GET_FIRM_VERSION SIOCIWFIRSTPRIV+3 +#ifdef WPS +#define KS_WLAN_SET_WPS_ENABLE SIOCIWFIRSTPRIV+4 +#define KS_WLAN_GET_WPS_ENABLE SIOCIWFIRSTPRIV+5 +#define KS_WLAN_SET_WPS_PROBE_REQ SIOCIWFIRSTPRIV+6 +#endif +#define KS_WLAN_GET_EEPROM_CKSUM SIOCIWFIRSTPRIV+7 +#define KS_WLAN_SET_PREAMBLE SIOCIWFIRSTPRIV+8 +#define KS_WLAN_GET_PREAMBLE SIOCIWFIRSTPRIV+9 +#define KS_WLAN_SET_POWER_SAVE SIOCIWFIRSTPRIV+10 +#define KS_WLAN_GET_POWER_SAVE SIOCIWFIRSTPRIV+11 +#define KS_WLAN_SET_SCAN_TYPE SIOCIWFIRSTPRIV+12 +#define KS_WLAN_GET_SCAN_TYPE SIOCIWFIRSTPRIV+13 +#define KS_WLAN_SET_RX_GAIN SIOCIWFIRSTPRIV+14 +#define KS_WLAN_GET_RX_GAIN SIOCIWFIRSTPRIV+15 +#define KS_WLAN_HOSTT SIOCIWFIRSTPRIV+16 /* unused */ +//#define KS_WLAN_SET_REGION SIOCIWFIRSTPRIV+17 +#define KS_WLAN_SET_BEACON_LOST SIOCIWFIRSTPRIV+18 +#define KS_WLAN_GET_BEACON_LOST SIOCIWFIRSTPRIV+19 + +#define KS_WLAN_SET_TX_GAIN SIOCIWFIRSTPRIV+20 +#define KS_WLAN_GET_TX_GAIN SIOCIWFIRSTPRIV+21 + +/* for KS7010 */ +#define KS_WLAN_SET_PHY_TYPE SIOCIWFIRSTPRIV+22 +#define KS_WLAN_GET_PHY_TYPE SIOCIWFIRSTPRIV+23 +#define KS_WLAN_SET_CTS_MODE SIOCIWFIRSTPRIV+24 +#define KS_WLAN_GET_CTS_MODE SIOCIWFIRSTPRIV+25 +/* SIOCIWFIRSTPRIV+26 */ +/* SIOCIWFIRSTPRIV+27 */ +#define KS_WLAN_SET_SLEEP_MODE SIOCIWFIRSTPRIV+28 /* sleep mode */ +#define KS_WLAN_GET_SLEEP_MODE SIOCIWFIRSTPRIV+29 /* sleep mode */ +/* SIOCIWFIRSTPRIV+30 */ +/* SIOCIWFIRSTPRIV+31 */ + +#ifdef __KERNEL__ + +#include "ks_wlan.h" +#include + +extern int ks_wlan_read_config_file(ks_wlan_private *priv); +extern int ks_wlan_setup_parameter(ks_wlan_private *priv, unsigned int commit_flag); + +#endif /* __KERNEL__ */ + +#endif /* _KS_WLAN_IOCTL_H */ diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c new file mode 100644 index 0000000..546a256 --- /dev/null +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -0,0 +1,3157 @@ +/* + * Driver for KeyStream 11b/g wireless LAN + * + * ks_wlan_net.c + * $Id: ks_wlan_net.c 1020 2009-09-28 05:48:31Z sekine $ + * + * Copyright (C) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int wep_on_off; +#define WEP_OFF 0 +#define WEP_ON_64BIT 1 +#define WEP_ON_128BIT 2 + +#include "ks_wlan.h" +#include "ks_hostif.h" +#include "ks_wlan_ioctl.h" +#include "ks_debug.h" + +/* Include Wireless Extension definition and check version */ +#include +#define WIRELESS_SPY /* enable iwspy support */ +#include /* New driver API */ + +#ifdef WIRELESS_EXT +/* Frequency list (map channels to frequencies) */ +static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, + 2447, 2452, 2457, 2462, 2467, 2472, 2484 }; + +/* A few details needed for WEP (Wireless Equivalent Privacy) */ +#define MAX_KEY_SIZE 13 /* 128 (?) bits */ +#define MIN_KEY_SIZE 5 /* 40 bits RC4 - WEP */ +typedef struct wep_key_t { + u16 len; + u8 key[16]; /* 40-bit and 104-bit keys */ +} wep_key_t; + +/* Backward compatibility */ +#ifndef IW_ENCODE_NOKEY +#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */ +#define IW_ENCODE_MODE (IW_ENCODE_DISABLED | IW_ENCODE_RESTRICTED | IW_ENCODE_OPEN) +#endif /* IW_ENCODE_NOKEY */ + +/* List of Wireless Handlers (new API) */ +static const struct iw_handler_def ks_wlan_handler_def; + +#define KSC_OPNOTSUPP /* Operation Not Support*/ + +#endif /* WIRELESS_EXT */ + +/* + * function prototypes + */ +extern int ks_wlan_hw_tx(ks_wlan_private *priv, void *p, unsigned long size, + void (*complete_handler)(void *arg1, void *arg2), + void *arg1, + void *arg2 ); +static int ks_wlan_open (struct net_device *dev); +static void ks_wlan_tx_timeout (struct net_device *dev); +static int ks_wlan_start_xmit (struct sk_buff *skb, struct net_device *dev); +static int ks_wlan_close (struct net_device *dev); +static void ks_wlan_set_multicast_list (struct net_device *dev); +static struct net_device_stats *ks_wlan_get_stats (struct net_device *dev); +static int ks_wlan_set_mac_address(struct net_device *dev, void *addr); +static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); + +static atomic_t update_phyinfo; +static struct timer_list update_phyinfo_timer; +static +int ks_wlan_update_phy_information(ks_wlan_private *priv) +{ + struct iw_statistics *wstats = &priv->wstats; + + DPRINTK(4, "in_interrupt = %ld\n", in_interrupt()); + + if (priv->dev_state < DEVICE_STATE_READY) { + return -1; /* not finished initialize */ + } + if(atomic_read(&update_phyinfo)) + return 1; + + /* The status */ + wstats->status = priv->reg.operation_mode; /* Operation mode */ + + /* Signal quality and co. But where is the noise level ??? */ + hostif_sme_enqueue(priv, SME_PHY_INFO_REQUEST); + + /* interruptible_sleep_on_timeout(&priv->confirm_wait, HZ/2); */ + if(!wait_for_completion_interruptible_timeout(&priv->confirm_wait,HZ/2)){ + DPRINTK(1,"wait time out!!\n"); + } + + atomic_inc(&update_phyinfo); + update_phyinfo_timer.expires = jiffies + HZ; /* 1sec */ + add_timer(&update_phyinfo_timer); + + return 0; +} + +static +void ks_wlan_update_phyinfo_timeout(unsigned long ptr) +{ + DPRINTK(4, "in_interrupt = %ld\n", in_interrupt()); + atomic_set(&update_phyinfo,0); +} + +int ks_wlan_setup_parameter(ks_wlan_private *priv, unsigned int commit_flag) +{ + DPRINTK(2,"\n"); + + hostif_sme_enqueue(priv, SME_STOP_REQUEST); + + if(commit_flag & SME_RTS) + hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_REQUEST); + if(commit_flag & SME_FRAG) + hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_REQUEST); + + if(commit_flag & SME_WEP_INDEX) + hostif_sme_enqueue(priv, SME_WEP_INDEX_REQUEST); + if(commit_flag & SME_WEP_VAL1) + hostif_sme_enqueue(priv, SME_WEP_KEY1_REQUEST); + if(commit_flag & SME_WEP_VAL2) + hostif_sme_enqueue(priv, SME_WEP_KEY2_REQUEST); + if(commit_flag & SME_WEP_VAL3) + hostif_sme_enqueue(priv, SME_WEP_KEY3_REQUEST); + if(commit_flag & SME_WEP_VAL4) + hostif_sme_enqueue(priv, SME_WEP_KEY4_REQUEST); + if(commit_flag & SME_WEP_FLAG) + hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST); + + if(commit_flag & SME_RSN){ + hostif_sme_enqueue(priv, SME_RSN_ENABLED_REQUEST); + hostif_sme_enqueue(priv, SME_RSN_MODE_REQUEST); + } + if(commit_flag & SME_RSN_MULTICAST) + hostif_sme_enqueue(priv, SME_RSN_MCAST_REQUEST); + if(commit_flag & SME_RSN_UNICAST) + hostif_sme_enqueue(priv, SME_RSN_UCAST_REQUEST); + if(commit_flag & SME_RSN_AUTH) + hostif_sme_enqueue(priv, SME_RSN_AUTH_REQUEST); + + hostif_sme_enqueue(priv, SME_MODE_SET_REQUEST); + + hostif_sme_enqueue(priv, SME_START_REQUEST); + + return 0; +} + +#ifdef WIRELESS_EXT +/* + * Initial Wireless Extension code for Ks_Wlannet driver by : + * Jean Tourrilhes - HPL - 17 November 00 + * Conversion to new driver API by : + * Jean Tourrilhes - HPL - 26 March 02 + * Javier also did a good amount of work here, adding some new extensions + * and fixing my code. Let's just say that without him this code just + * would not work at all... - Jean II + */ + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get protocol name */ +static int ks_wlan_get_name(struct net_device *dev, struct iw_request_info *info, + char *cwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *) netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if (priv->dev_state < DEVICE_STATE_READY) { + strcpy(cwrq, "NOT READY!"); + } + else if(priv->reg.phy_type == D_11B_ONLY_MODE){ + strcpy(cwrq, "IEEE 802.11b"); + } + else if(priv->reg.phy_type == D_11G_ONLY_MODE){ + strcpy(cwrq, "IEEE 802.11g"); + } + else { + strcpy(cwrq, "IEEE 802.11b/g"); + } + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set frequency */ +static int ks_wlan_set_freq(struct net_device *dev, struct iw_request_info *info, + struct iw_freq *fwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int rc = -EINPROGRESS; /* Call commit handler */ + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* If setting by frequency, convert to a channel */ + if((fwrq->e == 1) && + (fwrq->m >= (int) 2.412e8) && + (fwrq->m <= (int) 2.487e8)) { + int f = fwrq->m / 100000; + int c = 0; + while((c < 14) && (f != frequency_list[c])) + c++; + /* Hack to fall through... */ + fwrq->e = 0; + fwrq->m = c + 1; + } + /* Setting by channel number */ + if((fwrq->m > 1000) || (fwrq->e > 0)) + rc = -EOPNOTSUPP; + else { + int channel = fwrq->m; + /* We should do a better check than that, + * based on the card capability !!! */ + if((channel < 1) || (channel > 14)) { + printk(KERN_DEBUG "%s: New channel value of %d is invalid!\n", dev->name, fwrq->m); + rc = -EINVAL; + } else { + /* Yes ! We can set it !!! */ + priv->reg.channel = (u8)(channel); + priv->need_commit |= SME_MODE_SET; + } + } + + return rc; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get frequency */ +static int ks_wlan_get_freq(struct net_device *dev, struct iw_request_info *info, + struct iw_freq *fwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int f; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ + f = (int)priv->current_ap.channel; + } + else + f = (int)priv->reg.channel; + fwrq->m = frequency_list[f-1] * 100000; + fwrq->e = 1; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set ESSID */ +static int ks_wlan_set_essid(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + size_t len; + + DPRINTK(2," %d\n", dwrq->flags); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* Check if we asked for `any' */ + if(dwrq->flags == 0) { + /* Just send an empty SSID list */ + memset(priv->reg.ssid.body, 0, sizeof(priv->reg.ssid.body)); + priv->reg.ssid.size = 0; + } else { +#if 1 + len = dwrq->length; + /* iwconfig uses nul termination in SSID.. */ + if (len > 0 && extra[len - 1] == '\0') + len--; + + /* Check the size of the string */ + if(len > IW_ESSID_MAX_SIZE) { + return -EINVAL; + } +#else + /* Check the size of the string */ + if(dwrq->length > IW_ESSID_MAX_SIZE+1) { + return -E2BIG ; + } +#endif + + /* Set the SSID */ + memset(priv->reg.ssid.body, 0, sizeof(priv->reg.ssid.body)); + +#if 1 + memcpy(priv->reg.ssid.body, extra, len); + priv->reg.ssid.size = len; +#else + memcpy(priv->reg.ssid.body, extra, dwrq->length); + priv->reg.ssid.size = dwrq->length; +#endif + } + /* Write it to the card */ + priv->need_commit |= SME_MODE_SET; + +// return -EINPROGRESS; /* Call commit handler */ + ks_wlan_setup_parameter(priv, priv->need_commit); + priv->need_commit=0; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get ESSID */ +static int ks_wlan_get_essid(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* Note : if dwrq->flags != 0, we should + * get the relevant SSID from the SSID list... */ + + if(priv->reg.ssid.size){ + /* Get the current SSID */ + memcpy(extra, priv->reg.ssid.body, priv->reg.ssid.size); +#if 0 + extra[priv->reg.ssid.size] = '\0'; +#endif + /* If none, we may want to get the one that was set */ + + /* Push it out ! */ +#if 1 + dwrq->length = priv->reg.ssid.size; +#else + dwrq->length = priv->reg.ssid.size+1; +#endif + dwrq->flags = 1; /* active */ + }else{ +#if 1 + dwrq->length = 0; +#else + extra[0] = '\0'; + dwrq->length = 1; +#endif + dwrq->flags = 0; /* ANY */ + } + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set AP address */ +static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info, + struct sockaddr *ap_addr, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if (priv->reg.operation_mode == MODE_ADHOC || + priv->reg.operation_mode == MODE_INFRASTRUCTURE) { + memcpy(priv->reg.bssid, (u8 *)&ap_addr->sa_data, ETH_ALEN); + + if (is_valid_ether_addr((u8 *)priv->reg.bssid)) { + priv->need_commit |= SME_MODE_SET; + } + } + else { + memset(priv->reg.bssid, 0x0, ETH_ALEN); + return -EOPNOTSUPP; + } + + DPRINTK(2, "bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", + priv->reg.bssid[0],priv->reg.bssid[1],priv->reg.bssid[2], + priv->reg.bssid[3],priv->reg.bssid[4],priv->reg.bssid[5]); + + /* Write it to the card */ + if (priv->need_commit) { + priv->need_commit |= SME_MODE_SET; + return -EINPROGRESS; /* Call commit handler */ + } + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get AP address */ +static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info, + struct sockaddr *awrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ + memcpy(awrq->sa_data, &(priv->current_ap.bssid[0]), ETH_ALEN); + } + else{ + memset(awrq->sa_data, 0, ETH_ALEN); + } + + awrq->sa_family = ARPHRD_ETHER; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Nickname */ +static int ks_wlan_set_nick(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* Check the size of the string */ + if(dwrq->length > 16 + 1) { + return -E2BIG; + } + memset(priv->nick, 0, sizeof(priv->nick)); + memcpy(priv->nick, extra, dwrq->length); + + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Nickname */ +static int ks_wlan_get_nick(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + strncpy(extra, priv->nick, 16); + extra[16] = '\0'; + dwrq->length = strlen(extra) + 1; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Bit-Rate */ +static int ks_wlan_set_rate(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int i = 0; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(priv->reg.phy_type == D_11B_ONLY_MODE){ + if(vwrq->fixed == 1) { + switch(vwrq->value){ + case 11000000: + case 5500000: + priv->reg.rate_set.body[0] = (uint8_t)(vwrq->value/500000); + break; + case 2000000: + case 1000000: + priv->reg.rate_set.body[0] = ((uint8_t)(vwrq->value/500000))|BASIC_RATE; + break; + default: + return -EINVAL; + } + priv->reg.tx_rate = TX_RATE_FIXED; + priv->reg.rate_set.size = 1; + }else{ /* vwrq->fixed == 0 */ + if(vwrq->value > 0){ + switch(vwrq->value){ + case 11000000: + priv->reg.rate_set.body[3] = TX_RATE_11M; i++; + case 5500000: + priv->reg.rate_set.body[2] = TX_RATE_5M; i++; + case 2000000: + priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; i++; + case 1000000: + priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; i++; + break; + default: + return -EINVAL; + } + priv->reg.tx_rate = TX_RATE_MANUAL_AUTO; + priv->reg.rate_set.size = i; + }else{ + priv->reg.rate_set.body[3] = TX_RATE_11M; + priv->reg.rate_set.body[2] = TX_RATE_5M; + priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.tx_rate = TX_RATE_FULL_AUTO; + priv->reg.rate_set.size = 4; + } + } + }else{ /* D_11B_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ + if(vwrq->fixed == 1) { + switch(vwrq->value){ + case 54000000: + case 48000000: + case 36000000: + case 18000000: + case 9000000: + priv->reg.rate_set.body[0] = (uint8_t)(vwrq->value/500000); + break; + case 24000000: + case 12000000: + case 11000000: + case 6000000: + case 5500000: + case 2000000: + case 1000000: + priv->reg.rate_set.body[0] = ((uint8_t)(vwrq->value/500000))|BASIC_RATE; + break; + default: + return -EINVAL; + } + priv->reg.tx_rate = TX_RATE_FIXED; + priv->reg.rate_set.size = 1; + }else{ /* vwrq->fixed == 0 */ + if(vwrq->value > 0){ + switch(vwrq->value){ + case 54000000: + priv->reg.rate_set.body[11] = TX_RATE_54M; i++; + case 48000000: + priv->reg.rate_set.body[10] = TX_RATE_48M; i++; + case 36000000: + priv->reg.rate_set.body[9] = TX_RATE_36M; i++; + case 24000000: case 18000000: case 12000000: + case 11000000: case 9000000: case 6000000: + if(vwrq->value == 24000000){ + priv->reg.rate_set.body[8] = TX_RATE_18M; i++; + priv->reg.rate_set.body[7] = TX_RATE_9M; i++; + priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; i++; + priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; i++; + priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; + priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; + }else if(vwrq->value == 18000000){ + priv->reg.rate_set.body[7] = TX_RATE_18M; i++; + priv->reg.rate_set.body[6] = TX_RATE_9M; i++; + priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; i++; + priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; + priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; + }else if(vwrq->value == 12000000){ + priv->reg.rate_set.body[6] = TX_RATE_9M; i++; + priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; i++; + priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; + priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; + }else if(vwrq->value == 11000000){ + priv->reg.rate_set.body[5] = TX_RATE_9M; i++; + priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; + priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; + }else if(vwrq->value == 9000000){ + priv->reg.rate_set.body[4] = TX_RATE_9M; i++; + priv->reg.rate_set.body[3] = TX_RATE_6M|BASIC_RATE; i++; + }else{ /* vwrq->value == 6000000 */ + priv->reg.rate_set.body[3] = TX_RATE_6M|BASIC_RATE; i++; + } + case 5500000: + priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; i++; + case 2000000: + priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; i++; + case 1000000: + priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; i++; + break; + default: + return -EINVAL; + } + priv->reg.tx_rate = TX_RATE_MANUAL_AUTO; + priv->reg.rate_set.size = i; + }else{ + priv->reg.rate_set.body[11] = TX_RATE_54M; + priv->reg.rate_set.body[10] = TX_RATE_48M; + priv->reg.rate_set.body[9] = TX_RATE_36M; + priv->reg.rate_set.body[8] = TX_RATE_18M; + priv->reg.rate_set.body[7] = TX_RATE_9M; + priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; + priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; + priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; + priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; + priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.tx_rate = TX_RATE_FULL_AUTO; + priv->reg.rate_set.size = 12; + } + } + } + + priv->need_commit |= SME_MODE_SET; + + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Bit-Rate */ +static int ks_wlan_get_rate(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2, "in_interrupt = %ld update_phyinfo = %d\n", + in_interrupt(),atomic_read(&update_phyinfo)); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(!atomic_read(&update_phyinfo)){ + ks_wlan_update_phy_information(priv); + } + vwrq->value = ((priv->current_rate) & RATE_MASK) * 500000; + if(priv->reg.tx_rate == TX_RATE_FIXED) + vwrq->fixed = 1; + else + vwrq->fixed = 0; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set RTS threshold */ +static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int rthr = vwrq->value; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(vwrq->disabled) + rthr = 2347; + if((rthr < 0) || (rthr > 2347)) { + return -EINVAL; + } + priv->reg.rts = rthr; + priv->need_commit |= SME_RTS; + + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get RTS threshold */ +static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + vwrq->value = priv->reg.rts; + vwrq->disabled = (vwrq->value >= 2347); + vwrq->fixed = 1; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Fragmentation threshold */ +static int ks_wlan_set_frag(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int fthr = vwrq->value; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(vwrq->disabled) + fthr = 2346; + if((fthr < 256) || (fthr > 2346)) { + return -EINVAL; + } + fthr &= ~0x1; /* Get an even value - is it really needed ??? */ + priv->reg.fragment = fthr; + priv->need_commit |= SME_FRAG; + + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Fragmentation threshold */ +static int ks_wlan_get_frag(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + vwrq->value = priv->reg.fragment; + vwrq->disabled = (vwrq->value >= 2346); + vwrq->fixed = 1; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Mode of Operation */ +static int ks_wlan_set_mode(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2,"mode=%d\n",*uwrq); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + switch(*uwrq) { + case IW_MODE_ADHOC: + priv->reg.operation_mode = MODE_ADHOC; + priv->need_commit |= SME_MODE_SET; + break; + case IW_MODE_INFRA: + priv->reg.operation_mode = MODE_INFRASTRUCTURE; + priv->need_commit |= SME_MODE_SET; + break; + case IW_MODE_AUTO: + case IW_MODE_MASTER: + case IW_MODE_REPEAT: + case IW_MODE_SECOND: + case IW_MODE_MONITOR: + default: + return -EINVAL; + } + + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Mode of Operation */ +static int ks_wlan_get_mode(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* If not managed, assume it's ad-hoc */ + switch (priv->reg.operation_mode) { + case MODE_INFRASTRUCTURE: + *uwrq = IW_MODE_INFRA; + break; + case MODE_ADHOC: + *uwrq = IW_MODE_ADHOC; + break; + default: + *uwrq = IW_MODE_ADHOC; + } + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Encryption Key */ +static int ks_wlan_set_encode(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + wep_key_t key; + int index = (dwrq->flags & IW_ENCODE_INDEX); + int current_index = priv->reg.wep_index; + int i; + + DPRINTK(2,"flags=%04X\n",dwrq->flags); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* index check */ + if((index<0) || (index>4)) + return -EINVAL; + else if (index==0) + index = current_index; + else + index--; + + /* Is WEP supported ? */ + /* Basic checking: do we have a key to set ? */ + if (dwrq->length > 0) { + if (dwrq->length > MAX_KEY_SIZE) { /* Check the size of the key */ + return -EINVAL; + } + if (dwrq->length > MIN_KEY_SIZE) { /* Set the length */ + key.len = MAX_KEY_SIZE; + priv->reg.privacy_invoked = 0x01; + priv->need_commit |= SME_WEP_FLAG; + wep_on_off = WEP_ON_128BIT; + } else { + if (dwrq->length > 0) { + key.len = MIN_KEY_SIZE; + priv->reg.privacy_invoked = 0x01; + priv->need_commit |= SME_WEP_FLAG; + wep_on_off = WEP_ON_64BIT; + } else { /* Disable the key */ + key.len = 0; + } + } + /* Check if the key is not marked as invalid */ + if(!(dwrq->flags & IW_ENCODE_NOKEY)) { + /* Cleanup */ + memset(key.key, 0, MAX_KEY_SIZE); + /* Copy the key in the driver */ + if(copy_from_user(key.key,dwrq->pointer,dwrq->length)) { + key.len = 0; + return -EFAULT; + } + /* Send the key to the card */ + priv->reg.wep_key[index].size = key.len; + for (i=0; i<(priv->reg.wep_key[index].size); i++) { + priv->reg.wep_key[index].val[i] = key.key[i]; + } + priv->need_commit |= (SME_WEP_VAL1<reg.wep_index = index; + priv->need_commit |= SME_WEP_INDEX; + } + } else { + if(dwrq->flags & IW_ENCODE_DISABLED){ + priv->reg.wep_key[0].size = 0; + priv->reg.wep_key[1].size = 0; + priv->reg.wep_key[2].size = 0; + priv->reg.wep_key[3].size = 0; + priv->reg.privacy_invoked = 0x00; + if(priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY){ + priv->need_commit |= SME_MODE_SET; + } + priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; + wep_on_off = WEP_OFF; + priv->need_commit |= SME_WEP_FLAG; + }else{ + /* Do we want to just set the transmit key index ? */ + if ((index>=0) && (index<4)) { + /* set_wep_key(priv, index, 0, 0, 1); xxx */ + if(priv->reg.wep_key[index].size){ + priv->reg.wep_index = index; + priv->need_commit |= SME_WEP_INDEX; + } + else + return -EINVAL; + } + } + } + + /* Commit the changes if needed */ + if(dwrq->flags & IW_ENCODE_MODE) + priv->need_commit |= SME_WEP_FLAG; + + if(dwrq->flags & IW_ENCODE_OPEN) { + if(priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY){ + priv->need_commit |= SME_MODE_SET; + } + priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; + } else if(dwrq->flags & IW_ENCODE_RESTRICTED) { + if(priv->reg.authenticate_type == AUTH_TYPE_OPEN_SYSTEM){ + priv->need_commit |= SME_MODE_SET; + } + priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; + } + +// return -EINPROGRESS; /* Call commit handler */ + if(priv->need_commit){ + ks_wlan_setup_parameter(priv, priv->need_commit); + priv->need_commit=0; + } + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Encryption Key */ +static int ks_wlan_get_encode(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + char zeros[16]; + int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + dwrq->flags = IW_ENCODE_DISABLED; + + /* Check encryption mode */ + switch(priv->reg.authenticate_type) { + case AUTH_TYPE_OPEN_SYSTEM: + dwrq->flags = IW_ENCODE_OPEN; + break; + case AUTH_TYPE_SHARED_KEY: + dwrq->flags = IW_ENCODE_RESTRICTED; + break; + } + + memset(zeros,0, sizeof(zeros)); + + /* Which key do we want ? -1 -> tx index */ + if((index < 0) || (index >= 4)) + index = priv->reg.wep_index; + if (priv->reg.privacy_invoked){ + dwrq->flags &= ~IW_ENCODE_DISABLED; + /* dwrq->flags |= IW_ENCODE_NOKEY; */ + } + dwrq->flags |= index + 1; + DPRINTK(2,"encoding flag = 0x%04X\n",dwrq->flags); + /* Copy the key to the user buffer */ + if((index >= 0) && (index < 4)) + dwrq->length = priv->reg.wep_key[index].size; + if (dwrq->length > 16) { + dwrq->length=0; + } +#if 1 /* IW_ENCODE_NOKEY; */ + if (dwrq->length) { + if((index >= 0) && (index < 4)) + memcpy(extra,priv->reg.wep_key[index].val,dwrq->length); + } else + memcpy(extra,zeros,dwrq->length); +#endif + return 0; +} + +#ifndef KSC_OPNOTSUPP +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Tx-Power */ +static int ks_wlan_set_txpow(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + return -EOPNOTSUPP; /* Not Support */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Tx-Power */ +static int ks_wlan_get_txpow(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* Not Support */ + vwrq->value = 0; + vwrq->disabled = (vwrq->value == 0); + vwrq->fixed = 1; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Retry limits */ +static int ks_wlan_set_retry(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + return -EOPNOTSUPP; /* Not Support */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Retry limits */ +static int ks_wlan_get_retry(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* Not Support */ + vwrq->value = 0; + vwrq->disabled = (vwrq->value == 0); + vwrq->fixed = 1; + return 0; +} +#endif /* KSC_OPNOTSUPP */ + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get range info */ +static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct iw_range *range = (struct iw_range *) extra; + int i,k; + + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + dwrq->length = sizeof(struct iw_range); + memset(range, 0, sizeof(*range)); + range->min_nwid = 0x0000; + range->max_nwid = 0x0000; + range->num_channels = 14; + /* Should be based on cap_rid.country to give only + * what the current card support */ + k = 0; + for(i = 0; i < 13; i++) { /* channel 1 -- 13*/ + range->freq[k].i = i + 1; /* List index */ + range->freq[k].m = frequency_list[i] * 100000; + range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ + } + range->num_frequency = k; + if(priv->reg.phy_type == D_11B_ONLY_MODE || + priv->reg.phy_type == D_11BG_COMPATIBLE_MODE){ /* channel 14 */ + range->freq[13].i = 14; /* List index */ + range->freq[13].m = frequency_list[13] * 100000; + range->freq[13].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ + range->num_frequency = 14; + } + + /* Hum... Should put the right values there */ + range->max_qual.qual = 100; + range->max_qual.level = 256 - 128; /* 0 dBm? */ + range->max_qual.noise = 256 - 128; + range->sensitivity = 1; + + if(priv->reg.phy_type == D_11B_ONLY_MODE){ + range->bitrate[0] = 1e6; + range->bitrate[1] = 2e6; + range->bitrate[2] = 5.5e6; + range->bitrate[3] = 11e6; + range->num_bitrates = 4; + } + else{ /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ + range->bitrate[0] = 1e6; + range->bitrate[1] = 2e6; + range->bitrate[2] = 5.5e6; + range->bitrate[3] = 11e6; + + range->bitrate[4] = 6e6; + range->bitrate[5] = 9e6; + range->bitrate[6] = 12e6; + if(IW_MAX_BITRATES < 9){ + range->bitrate[7] = 54e6; + range->num_bitrates = 8; + }else{ + range->bitrate[7] = 18e6; + range->bitrate[8] = 24e6; + range->bitrate[9] = 36e6; + range->bitrate[10] = 48e6; + range->bitrate[11] = 54e6; + + range->num_bitrates = 12; + } + } + + /* Set an indication of the max TCP throughput + * in bit/s that we can expect using this interface. + * May be use for QoS stuff... Jean II */ + if(i > 2) + range->throughput = 5000 * 1000; + else + range->throughput = 1500 * 1000; + + range->min_rts = 0; + range->max_rts = 2347; + range->min_frag = 256; + range->max_frag = 2346; + + range->encoding_size[0] = 5; /* WEP: RC4 40 bits */ + range->encoding_size[1] = 13; /* WEP: RC4 ~128 bits */ + range->num_encoding_sizes = 2; + range->max_encoding_tokens = 4; + + /* power management not support */ + range->pmp_flags = IW_POWER_ON; + range->pmt_flags = IW_POWER_ON; + range->pm_capa = 0; + + /* Transmit Power - values are in dBm( or mW) */ + range->txpower[0]=-256; + range->num_txpower = 1; + range->txpower_capa = IW_TXPOW_DBM; + /* range->txpower_capa = IW_TXPOW_MWATT; */ + + range->we_version_source = 21; + range->we_version_compiled = WIRELESS_EXT; + + range->retry_capa = IW_RETRY_ON; + range->retry_flags = IW_RETRY_ON; + range->r_time_flags = IW_RETRY_ON; + + /* Experimental measurements - boundary 11/5.5 Mb/s */ + /* Note : with or without the (local->rssi), results + * are somewhat different. - Jean II */ + range->avg_qual.qual = 50; + range->avg_qual.level = 186; /* -70 dBm */ + range->avg_qual.noise = 0; + +#if defined(WIRELESS_EXT) + /* Event capability (kernel + driver) */ + range->event_capa[0] = (IW_EVENT_CAPA_K_0 | + IW_EVENT_CAPA_MASK(SIOCGIWAP) | + IW_EVENT_CAPA_MASK(SIOCGIWSCAN)); + range->event_capa[1] = IW_EVENT_CAPA_K_1; + range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVCUSTOM) | + IW_EVENT_CAPA_MASK(IWEVMICHAELMICFAILURE)); + + /* encode extension (WPA) capability */ + range->enc_capa = (IW_ENC_CAPA_WPA | + IW_ENC_CAPA_WPA2 | + IW_ENC_CAPA_CIPHER_TKIP | + IW_ENC_CAPA_CIPHER_CCMP); +#endif + return 0; +} + + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Power Management */ +static int ks_wlan_set_power(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + short enabled; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + enabled = vwrq->disabled ? 0 : 1; + if(enabled == 0 ){ /* 0 */ + priv->reg.powermgt = POWMGT_ACTIVE_MODE; + }else if(enabled){ /* 1 */ + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) + priv->reg.powermgt = POWMGT_SAVE1_MODE; + else + return -EINVAL; + }else if(enabled){ /* 2 */ + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) + priv->reg.powermgt = POWMGT_SAVE2_MODE; + else + return -EINVAL; + }else + return -EINVAL; + + hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Power Management */ +static int ks_wlan_get_power(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(priv->reg.powermgt > 0) + vwrq->disabled = 0; + else + vwrq->disabled = 1; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get wirless statistics */ +static int ks_wlan_get_iwstats(struct net_device *dev, struct iw_request_info *info, + struct iw_quality *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + vwrq->qual = 0; /* not supported */ + vwrq->level = priv->wstats.qual.level; + vwrq->noise = 0; /* not supported */ + vwrq->updated = 0; + + return 0; +} + +#ifndef KSC_OPNOTSUPP +/*------------------------------------------------------------------*/ +/* Wireless Handler : set Sensitivity */ +static int ks_wlan_set_sens(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + return -EOPNOTSUPP; /* Not Support */ +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get Sensitivity */ +static int ks_wlan_get_sens(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + /* Not Support */ + vwrq->value = 0; + vwrq->disabled = (vwrq->value == 0); + vwrq->fixed = 1; + return 0; +} +#endif /* KSC_OPNOTSUPP */ + + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get AP List */ +/* Note : this is deprecated in favor of IWSCAN */ +static int ks_wlan_get_aplist(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct sockaddr *address = (struct sockaddr *) extra; + struct iw_quality qual[LOCAL_APLIST_MAX]; + + int i; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + for (i = 0; i < priv->aplist.size; i++) { + memcpy(address[i].sa_data, &(priv->aplist.ap[i].bssid[0]), ETH_ALEN); + address[i].sa_family = ARPHRD_ETHER; + qual[i].level = 256 - priv->aplist.ap[i].rssi; + qual[i].qual = priv->aplist.ap[i].sq; + qual[i].noise = 0; /* invalid noise value */ + qual[i].updated = 7; + } + if (i){ + dwrq->flags = 1; /* Should be define'd */ + memcpy(extra + sizeof(struct sockaddr)*i, + &qual, sizeof(struct iw_quality)*i); + } + dwrq->length = i; + + return 0; +} + +#if defined(WIRELESS_EXT) +/*------------------------------------------------------------------*/ +/* Wireless Handler : Initiate Scan */ +static int ks_wlan_set_scan(struct net_device *dev, struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct iw_scan_req *req = NULL; + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* specified SSID SCAN */ + if(wrqu->data.length == sizeof(struct iw_scan_req) && wrqu->data.flags & IW_SCAN_THIS_ESSID){ + req = (struct iw_scan_req *) extra; + priv->scan_ssid_len = req->essid_len; + memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len); + }else{ + priv->scan_ssid_len = 0; + } + + + priv->sme_i.sme_flag |= SME_AP_SCAN; + hostif_sme_enqueue(priv, SME_BSS_SCAN_REQUEST); + + /* At this point, just return to the user. */ + + return 0; +} + +/*------------------------------------------------------------------*/ +/* + * Translate scan data returned from the card to a card independent + * format that the Wireless Tools will understand - Jean II + */ +static inline char *ks_wlan_translate_scan(struct net_device *dev, struct iw_request_info *info, char *current_ev, + char *end_buf, struct local_ap_t *ap) +{ + /* ks_wlan_private *priv = (ks_wlan_private *)dev->priv; */ + struct iw_event iwe; /* Temporary buffer */ + u16 capabilities; + char *current_val; /* For rates */ + int i; + static const char rsn_leader[] = "rsn_ie="; + static const char wpa_leader[] = "wpa_ie="; + char buf0[RSN_IE_BODY_MAX*2 + 30]; + char buf1[RSN_IE_BODY_MAX*2 + 30]; + char *pbuf; + /* First entry *MUST* be the AP MAC address */ + iwe.cmd = SIOCGIWAP; + iwe.u.ap_addr.sa_family = ARPHRD_ETHER; + memcpy(iwe.u.ap_addr.sa_data, ap->bssid, ETH_ALEN); + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN); + + /* Other entries will be displayed in the order we give them */ + + /* Add the ESSID */ + iwe.u.data.length = ap->ssid.size; + if(iwe.u.data.length > 32) + iwe.u.data.length = 32; + iwe.cmd = SIOCGIWESSID; + iwe.u.data.flags = 1; + current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, &(ap->ssid.body[0])); + + /* Add mode */ + iwe.cmd = SIOCGIWMODE; + capabilities = le16_to_cpu(ap->capability); + if(capabilities & (BSS_CAP_ESS | BSS_CAP_IBSS)) { + if(capabilities & BSS_CAP_ESS) + iwe.u.mode = IW_MODE_INFRA; + else + iwe.u.mode = IW_MODE_ADHOC; + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN); + } + + /* Add frequency */ + iwe.cmd = SIOCGIWFREQ; + iwe.u.freq.m = ap->channel; + iwe.u.freq.m = frequency_list[iwe.u.freq.m-1] * 100000; + iwe.u.freq.e = 1; + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); + + /* Add quality statistics */ + iwe.cmd = IWEVQUAL; + iwe.u.qual.level = 256 - ap->rssi; + iwe.u.qual.qual = ap->sq; + iwe.u.qual.noise = 0; /* invalid noise value */ + current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); + + /* Add encryption capability */ + iwe.cmd = SIOCGIWENCODE; + if(capabilities & BSS_CAP_PRIVACY) + iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; + else + iwe.u.data.flags = IW_ENCODE_DISABLED; + iwe.u.data.length = 0; + current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, &(ap->ssid.body[0])); + + /* Rate : stuffing multiple values in a single event require a bit + * more of magic - Jean II */ + current_val = current_ev + IW_EV_LCP_LEN; + + iwe.cmd = SIOCGIWRATE; + /* Those two flags are ignored... */ + iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; + + /* Max 16 values */ + for(i = 0 ; i < 16 ; i++) { + /* NULL terminated */ + if(i >= ap->rate_set.size) + break; + /* Bit rate given in 500 kb/s units (+ 0x80) */ + iwe.u.bitrate.value = ((ap->rate_set.body[i] & 0x7f) * 500000); + /* Add new value to event */ + current_val = iwe_stream_add_value(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); + } + /* Check if we added any event */ + if((current_val - current_ev) > IW_EV_LCP_LEN) + current_ev = current_val; + +#define GENERIC_INFO_ELEM_ID 0xdd +#define RSN_INFO_ELEM_ID 0x30 + if (ap->rsn_ie.id == RSN_INFO_ELEM_ID && ap->rsn_ie.size != 0) { + pbuf = &buf0[0]; + memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVCUSTOM; + memcpy(buf0,rsn_leader,sizeof(rsn_leader)-1); + iwe.u.data.length += sizeof(rsn_leader)-1; + pbuf += sizeof(rsn_leader)-1; + + pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.id); + pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.size); + iwe.u.data.length += 4; + + for (i = 0; i < ap->rsn_ie.size; i++) + pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.body[i]); + iwe.u.data.length += (ap->rsn_ie.size)*2; + + DPRINTK(4,"ap->rsn.size=%d\n",ap->rsn_ie.size); + + current_ev = iwe_stream_add_point(info, current_ev, end_buf,&iwe, &buf0[0]); + } + if (ap->wpa_ie.id == GENERIC_INFO_ELEM_ID && ap->wpa_ie.size != 0) { + pbuf = &buf1[0]; + memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVCUSTOM; + memcpy(buf1,wpa_leader,sizeof(wpa_leader)-1); + iwe.u.data.length += sizeof(wpa_leader)-1; + pbuf += sizeof(wpa_leader)-1; + + pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.id); + pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.size); + iwe.u.data.length += 4; + + for (i = 0; i < ap->wpa_ie.size; i++) + pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.body[i]); + iwe.u.data.length += (ap->wpa_ie.size)*2; + + DPRINTK(4,"ap->rsn.size=%d\n",ap->wpa_ie.size); + DPRINTK(4,"iwe.u.data.length=%d\n",iwe.u.data.length); + + current_ev = iwe_stream_add_point(info, current_ev, end_buf,&iwe, &buf1[0]); + } + + /* The other data in the scan result are not really + * interesting, so for now drop it - Jean II */ + return current_ev; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : Read Scan Results */ +static int ks_wlan_get_scan(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int i; + char *current_ev = extra; + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(priv->sme_i.sme_flag & SME_AP_SCAN) { +DPRINTK(2,"flag AP_SCAN\n"); + return -EAGAIN; + } + + if(priv->aplist.size == 0) { + /* Client error, no scan results... + * The caller need to restart the scan. */ +DPRINTK(2,"aplist 0\n"); + return -ENODATA; + } +#if 0 + /* current connect ap */ + if((priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ + if ((extra + dwrq->length) - current_ev <= IW_EV_ADDR_LEN) { + dwrq->length = 0; + return -E2BIG; + } + current_ev = ks_wlan_translate_scan(dev, current_ev, +// extra + IW_SCAN_MAX_DATA, + extra + dwrq->length, + &(priv->current_ap)); + } +#endif + /* Read and parse all entries */ + for(i=0; i < priv->aplist.size; i++) { + if ((extra + dwrq->length) - current_ev <= IW_EV_ADDR_LEN) { + dwrq->length = 0; + return -E2BIG; + } + /* Translate to WE format this entry */ + current_ev = ks_wlan_translate_scan(dev, info, current_ev, +// extra + IW_SCAN_MAX_DATA, + extra + dwrq->length, + &(priv->aplist.ap[i])); + } + /* Length of data */ + dwrq->length = (current_ev - extra); + dwrq->flags = 0; + + return 0; +} +#endif /* WIRELESS_EXT */ + +/*------------------------------------------------------------------*/ +/* Commit handler : called after a bunch of SET operations */ +static int ks_wlan_config_commit(struct net_device *dev, struct iw_request_info *info, + void *zwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (!priv->need_commit) + return 0; + + ks_wlan_setup_parameter(priv, priv->need_commit); + priv->need_commit=0; + return 0; +} + +#ifdef WIRELESS_EXT +/*------------------------------------------------------------------*/ +/* Wireless handler : set association ie params */ +static int ks_wlan_set_genie(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2, "\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + return 0; +// return -EOPNOTSUPP; +} + +/*------------------------------------------------------------------*/ +/* Wireless handler : set authentication mode params */ +static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int index = (vwrq->flags & IW_AUTH_INDEX); + int value = vwrq->value; + + DPRINTK(2,"index=%d:value=%08X\n",index,value); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + switch(index){ + case IW_AUTH_WPA_VERSION: /* 0 */ + switch(value){ + case IW_AUTH_WPA_VERSION_DISABLED: + priv->wpa.version = value; + if(priv->wpa.rsn_enabled){ + priv->wpa.rsn_enabled = 0; + } + priv->need_commit |= SME_RSN; + break; + case IW_AUTH_WPA_VERSION_WPA: + case IW_AUTH_WPA_VERSION_WPA2: + priv->wpa.version = value; + if(!(priv->wpa.rsn_enabled)){ + priv->wpa.rsn_enabled = 1; + } + priv->need_commit |= SME_RSN; + break; + default: + return -EOPNOTSUPP; + } + break; + case IW_AUTH_CIPHER_PAIRWISE: /* 1 */ + switch(value){ + case IW_AUTH_CIPHER_NONE: + if(priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x00; + priv->need_commit |= SME_WEP_FLAG; + } + break; + case IW_AUTH_CIPHER_WEP40: + case IW_AUTH_CIPHER_TKIP: + case IW_AUTH_CIPHER_CCMP: + case IW_AUTH_CIPHER_WEP104: + if(!priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x01; + priv->need_commit |= SME_WEP_FLAG; + } + priv->wpa.pairwise_suite = value; + priv->need_commit |= SME_RSN_UNICAST; + break; + default: + return -EOPNOTSUPP; + } + break; + case IW_AUTH_CIPHER_GROUP: /* 2 */ + switch(value){ + case IW_AUTH_CIPHER_NONE: + if(priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x00; + priv->need_commit |= SME_WEP_FLAG; + } + break; + case IW_AUTH_CIPHER_WEP40: + case IW_AUTH_CIPHER_TKIP: + case IW_AUTH_CIPHER_CCMP: + case IW_AUTH_CIPHER_WEP104: + if(!priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x01; + priv->need_commit |= SME_WEP_FLAG; + } + priv->wpa.group_suite = value; + priv->need_commit |= SME_RSN_MULTICAST; + break; + default: + return -EOPNOTSUPP; + } + break; + case IW_AUTH_KEY_MGMT: /* 3 */ + switch(value){ + case IW_AUTH_KEY_MGMT_802_1X: + case IW_AUTH_KEY_MGMT_PSK: + case 0: /* NONE or 802_1X_NO_WPA */ + case 4: /* WPA_NONE */ + priv->wpa.key_mgmt_suite = value; + priv->need_commit |= SME_RSN_AUTH; + break; + default: + return -EOPNOTSUPP; + } + break; + case IW_AUTH_80211_AUTH_ALG: /* 6 */ + switch(value){ + case IW_AUTH_ALG_OPEN_SYSTEM: + priv->wpa.auth_alg = value; + priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; + break; + case IW_AUTH_ALG_SHARED_KEY: + priv->wpa.auth_alg = value; + priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; + break; + case IW_AUTH_ALG_LEAP: + default: + return -EOPNOTSUPP; + } + priv->need_commit |= SME_MODE_SET; + break; + case IW_AUTH_WPA_ENABLED: /* 7 */ + priv->wpa.wpa_enabled = value; + break; + case IW_AUTH_PRIVACY_INVOKED: /* 10 */ + if((value && !priv->reg.privacy_invoked)|| + (!value && priv->reg.privacy_invoked)){ + priv->reg.privacy_invoked = value?0x01:0x00; + priv->need_commit |= SME_WEP_FLAG; + } + break; + case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* 4 */ + case IW_AUTH_TKIP_COUNTERMEASURES: /* 5 */ + case IW_AUTH_DROP_UNENCRYPTED: /* 8 */ + case IW_AUTH_ROAMING_CONTROL: /* 9 */ + default: + break; + } + + /* return -EINPROGRESS; */ + if(priv->need_commit){ + ks_wlan_setup_parameter(priv, priv->need_commit); + priv->need_commit=0; + } + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless handler : get authentication mode params */ +static int ks_wlan_get_auth_mode(struct net_device *dev, struct iw_request_info *info, + struct iw_param *vwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + int index = (vwrq->flags & IW_AUTH_INDEX); + DPRINTK(2,"index=%d\n",index); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* WPA (not used ?? wpa_supplicant) */ + switch(index){ + case IW_AUTH_WPA_VERSION: + vwrq->value = priv->wpa.version; + break; + case IW_AUTH_CIPHER_PAIRWISE: + vwrq->value = priv->wpa.pairwise_suite; + break; + case IW_AUTH_CIPHER_GROUP: + vwrq->value = priv->wpa.group_suite; + break; + case IW_AUTH_KEY_MGMT: + vwrq->value = priv->wpa.key_mgmt_suite; + break; + case IW_AUTH_80211_AUTH_ALG: + vwrq->value = priv->wpa.auth_alg; + break; + case IW_AUTH_WPA_ENABLED: + vwrq->value = priv->wpa.rsn_enabled; + break; + case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* OK??? */ + case IW_AUTH_TKIP_COUNTERMEASURES: + case IW_AUTH_DROP_UNENCRYPTED: + default: + /* return -EOPNOTSUPP; */ + break; + } + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set encoding token & mode (WPA)*/ +static int ks_wlan_set_encode_ext(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct iw_encode_ext *enc; + int index = dwrq->flags & IW_ENCODE_INDEX; + unsigned int commit=0; + + enc = (struct iw_encode_ext *)extra; + + DPRINTK(2,"flags=%04X:: ext_flags=%08X\n",dwrq->flags, enc->ext_flags); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(index<1||index>4) + return -EINVAL; + else + index--; + + if(dwrq->flags & IW_ENCODE_DISABLED){ + priv->wpa.key[index].key_len=0; + } + + if(enc){ + priv->wpa.key[index].ext_flags=enc->ext_flags; + if(enc->ext_flags&IW_ENCODE_EXT_SET_TX_KEY){ + priv->wpa.txkey=index; + commit |= SME_WEP_INDEX; + }else if(enc->ext_flags&IW_ENCODE_EXT_RX_SEQ_VALID){ + if(enc->rx_seq) + memcpy(&priv->wpa.key[index].rx_seq[0], + enc->rx_seq, IW_ENCODE_SEQ_MAX_SIZE); + else + return -EINVAL; + } + + memcpy(&priv->wpa.key[index].addr.sa_data[0], + &enc->addr.sa_data[0], ETH_ALEN); + + switch (enc->alg) { + case IW_ENCODE_ALG_NONE: + if(priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x00; + commit |= SME_WEP_FLAG; + } + priv->wpa.key[index].key_len = 0; + + break; + case IW_ENCODE_ALG_WEP: + case IW_ENCODE_ALG_CCMP: + if(!priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x01; + commit |= SME_WEP_FLAG; + } + if(enc->key && enc->key_len){ + memcpy(&priv->wpa.key[index].key_val[0], + &enc->key[0], enc->key_len); + priv->wpa.key[index].key_len = enc->key_len; + commit |= (SME_WEP_VAL1 << index); + } + break; + case IW_ENCODE_ALG_TKIP: + if(!priv->reg.privacy_invoked){ + priv->reg.privacy_invoked = 0x01; + commit |= SME_WEP_FLAG; + } + if(enc->key && enc->key_len == 32){ + memcpy(&priv->wpa.key[index].key_val[0], + &enc->key[0], enc->key_len-16); + priv->wpa.key[index].key_len = enc->key_len-16; + if(priv->wpa.key_mgmt_suite==4){ /* WPA_NONE */ + memcpy(&priv->wpa.key[index].tx_mic_key[0], + &enc->key[16],8); + memcpy(&priv->wpa.key[index].rx_mic_key[0], + &enc->key[16],8); + }else{ + memcpy(&priv->wpa.key[index].tx_mic_key[0], + &enc->key[16],8); + memcpy(&priv->wpa.key[index].rx_mic_key[0], + &enc->key[24],8); + } + commit |= (SME_WEP_VAL1 << index); + } + break; + default: + return -EINVAL; + } + priv->wpa.key[index].alg=enc->alg; + } + else + return -EINVAL; + + if(commit){ + if(commit&SME_WEP_INDEX) + hostif_sme_enqueue(priv, SME_SET_TXKEY); + if(commit&SME_WEP_VAL_MASK) + hostif_sme_enqueue(priv, SME_SET_KEY1+index); + if(commit&SME_WEP_FLAG) + hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST); + } + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : get encoding token & mode (WPA)*/ +static int ks_wlan_get_encode_ext(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + /* WPA (not used ?? wpa_supplicant) + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + struct iw_encode_ext *enc; + enc = (struct iw_encode_ext *)extra; + int index = dwrq->flags & IW_ENCODE_INDEX; + WPA (not used ?? wpa_supplicant) */ + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : PMKSA cache operation (WPA2) */ +static int ks_wlan_set_pmksa(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct iw_pmksa *pmksa ; + int i; + struct pmk_t *pmk; + struct list_head *ptr; + + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(!extra){ + return -EINVAL; + } + pmksa = (struct iw_pmksa *)extra; + DPRINTK(2,"cmd=%d\n",pmksa->cmd); + + switch(pmksa->cmd){ + case IW_PMKSA_ADD: + if(list_empty(&priv->pmklist.head)){ /* new list */ + for(i=0;ipmklist.pmk[i]; + if(!memcmp("\x00\x00\x00\x00\x00\x00",pmk->bssid,ETH_ALEN)) + break; + } + memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); + memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); + list_add(&pmk->list,&priv->pmklist.head); + priv->pmklist.size++; + } + else { /* search cache data */ + list_for_each(ptr, &priv->pmklist.head){ + pmk = list_entry(ptr, struct pmk_t, list); + if(!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)){ /* match address! list move to head. */ + memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); + list_move(&pmk->list, &priv->pmklist.head); + break; + } + } + if(ptr == &priv->pmklist.head){ /* not find address. */ + if(PMK_LIST_MAX > priv->pmklist.size){ /* new cache data */ + for(i=0;ipmklist.pmk[i]; + if(!memcmp("\x00\x00\x00\x00\x00\x00",pmk->bssid,ETH_ALEN)) + break; + } + memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); + memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); + list_add(&pmk->list,&priv->pmklist.head); + priv->pmklist.size++; + } + else{ /* overwrite old cache data */ + pmk = list_entry(priv->pmklist.head.prev, struct pmk_t, list); + memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); + memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); + list_move(&pmk->list,&priv->pmklist.head); + } + } + } + break; + case IW_PMKSA_REMOVE: + if(list_empty(&priv->pmklist.head)){ /* list empty */ + return -EINVAL; + } + else{ /* search cache data */ + list_for_each(ptr, &priv->pmklist.head){ + pmk = list_entry(ptr, struct pmk_t, list); + if(!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)){ /* match address! list del. */ + memset(pmk->bssid, 0, ETH_ALEN); + memset(pmk->pmkid, 0, IW_PMKID_LEN); + list_del_init(&pmk->list); + break; + } + } + if(ptr == &priv->pmklist.head){ /* not find address. */ + return 0; + } + } + break; + case IW_PMKSA_FLUSH: + memset(&(priv->pmklist), 0, sizeof(priv->pmklist)); + INIT_LIST_HEAD(&priv->pmklist.head); + for(i=0;ipmklist.pmk[i].list); + break; + default: + return -EINVAL; + } + + hostif_sme_enqueue(priv, SME_SET_PMKSA); + return 0; +} + +static struct iw_statistics *ks_get_wireless_stats(struct net_device *dev) +{ + + ks_wlan_private *priv = (ks_wlan_private *) netdev_priv(dev); + struct iw_statistics *wstats = &priv->wstats; + + if(!atomic_read(&update_phyinfo)){ + if (priv->dev_state < DEVICE_STATE_READY) + return NULL; /* not finished initialize */ + else + return wstats; + } + + /* Packets discarded in the wireless adapter due to wireless + * specific problems */ + wstats->discard.nwid = 0; /* Rx invalid nwid */ + wstats->discard.code = 0; /* Rx invalid crypt */ + wstats->discard.fragment = 0; /* Rx invalid frag */ + wstats->discard.retries = 0; /* Tx excessive retries */ + wstats->discard.misc = 0; /* Invalid misc */ + wstats->miss.beacon = 0; /* Missed beacon */ + + return wstats; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set stop request */ +static int ks_wlan_set_stop_request(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(!(*uwrq)) + return -EINVAL; + + hostif_sme_enqueue(priv, SME_STOP_REQUEST); + return 0; +} + +/*------------------------------------------------------------------*/ +/* Wireless Handler : set MLME */ +#include +static int ks_wlan_set_mlme(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct iw_mlme *mlme = (struct iw_mlme *)extra; + __u32 mode; + + DPRINTK(2, ":%d :%d\n", mlme->cmd, mlme->reason_code); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + switch (mlme->cmd) { + case IW_MLME_DEAUTH: + if (mlme->reason_code == WLAN_REASON_MIC_FAILURE) { + return 0; + } + case IW_MLME_DISASSOC: + mode = 1; + return ks_wlan_set_stop_request(dev, NULL, &mode, NULL); + default: + return -EOPNOTSUPP; /* Not Support */ + } +} +#endif /* WIRELESS_EXT */ + +/*------------------------------------------------------------------*/ +/* Private handler : get driver version */ +static int ks_wlan_get_driver_version(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + strcpy(extra, KS_WLAN_DRIVER_VERSION_INFO); + dwrq->length = strlen(KS_WLAN_DRIVER_VERSION_INFO)+1; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get firemware version */ +static int ks_wlan_get_firmware_version(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + strcpy(extra, &(priv->firmware_version[0])); + dwrq->length = priv->version_size+1; + return 0; +} + +#if 0 +/*------------------------------------------------------------------*/ +/* Private handler : set force disconnect status */ +static int ks_wlan_set_detach(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == CONNECT_STATUS){ /* 0 */ + priv->connect_status &= ~FORCE_DISCONNECT; + if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) + netif_carrier_on(dev); + }else if(*uwrq == DISCONNECT_STATUS){ /* 1 */ + priv->connect_status |= FORCE_DISCONNECT; + netif_carrier_off(dev); + }else + return -EINVAL; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get force disconnect status */ +static int ks_wlan_get_detach(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = ((priv->connect_status & FORCE_DISCONNECT) ? 1 : 0 ); + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get connect status */ +static int ks_wlan_get_connect(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = (priv->connect_status & CONNECT_STATUS_MASK); + return 0; +} +#endif + +/*------------------------------------------------------------------*/ +/* Private handler : set preamble */ +static int ks_wlan_set_preamble(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == LONG_PREAMBLE){ /* 0 */ + priv->reg.preamble = LONG_PREAMBLE; + }else if(*uwrq == SHORT_PREAMBLE){ /* 1 */ + priv->reg.preamble = SHORT_PREAMBLE; + }else + return -EINVAL; + + priv->need_commit |= SME_MODE_SET; + return -EINPROGRESS; /* Call commit handler */ + +} + +/*------------------------------------------------------------------*/ +/* Private handler : get preamble */ +static int ks_wlan_get_preamble(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.preamble; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set power save mode */ +static int ks_wlan_set_powermgt(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == POWMGT_ACTIVE_MODE){ /* 0 */ + priv->reg.powermgt = POWMGT_ACTIVE_MODE; + }else if(*uwrq == POWMGT_SAVE1_MODE){ /* 1 */ + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) + priv->reg.powermgt = POWMGT_SAVE1_MODE; + else + return -EINVAL; + }else if(*uwrq == POWMGT_SAVE2_MODE){ /* 2 */ + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) + priv->reg.powermgt = POWMGT_SAVE2_MODE; + else + return -EINVAL; + }else + return -EINVAL; + + hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get power save made */ +static int ks_wlan_get_powermgt(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.powermgt; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set scan type */ +static int ks_wlan_set_scan_type(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == ACTIVE_SCAN){ /* 0 */ + priv->reg.scan_type = ACTIVE_SCAN; + }else if(*uwrq == PASSIVE_SCAN){ /* 1 */ + priv->reg.scan_type = PASSIVE_SCAN; + }else + return -EINVAL; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get scan type */ +static int ks_wlan_get_scan_type(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.scan_type; + return 0; +} +#if 0 +/*------------------------------------------------------------------*/ +/* Private handler : write raw data to device */ +static int ks_wlan_data_write(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + unsigned char *wbuff = NULL; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + wbuff = (unsigned char *)kmalloc(dwrq->length, GFP_ATOMIC); + if(!wbuff) + return -EFAULT; + memcpy(wbuff, extra, dwrq->length); + + /* write to device */ + ks_wlan_hw_tx( priv, wbuff, dwrq->length, NULL, NULL, NULL); + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : read raw data form device */ +static int ks_wlan_data_read(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + unsigned short read_length; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(!atomic_read(&priv->event_count)){ + if (priv->dev_state < DEVICE_STATE_BOOT) { /* Remove device */ + read_length = 4; + memset(extra,0xff,read_length); + dwrq->length = read_length; + return 0; + } + read_length = 0; + memset(extra,0,1); + dwrq->length = 0; + return 0; + } + + if(atomic_read(&priv->event_count)>0) + atomic_dec(&priv->event_count); + + spin_lock(&priv->dev_read_lock); /* request spin lock */ + + /* Copy length max size 0x07ff */ + if(priv->dev_size[priv->dev_count] > 2047) + read_length = 2047; + else + read_length = priv->dev_size[priv->dev_count]; + + /* Copy data */ + memcpy(extra, &(priv->dev_data[priv->dev_count][0]), read_length); + + spin_unlock(&priv->dev_read_lock); /* release spin lock */ + + /* Initialize */ + priv->dev_data[priv->dev_count] = 0; + priv->dev_size[priv->dev_count] = 0; + + priv->dev_count++; + if(priv->dev_count == DEVICE_STOCK_COUNT) + priv->dev_count=0; + + /* Set read size */ + dwrq->length = read_length; + + return 0; +} +#endif + +#if 0 +/*------------------------------------------------------------------*/ +/* Private handler : get wep string */ +#define WEP_ASCII_BUFF_SIZE (17+64*4+1) +static int ks_wlan_get_wep_ascii(struct net_device *dev, struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + int i,j,len=0; + char tmp[WEP_ASCII_BUFF_SIZE]; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + strcpy(tmp," WEP keys ASCII \n"); + len+=strlen(" WEP keys ASCII \n"); + + for(i=0;i<4;i++){ + strcpy(tmp+len,"\t["); + len+=strlen("\t["); + tmp[len] = '1'+i; + len++; + strcpy(tmp+len,"] "); + len+=strlen("] "); + if(priv->reg.wep_key[i].size){ + strcpy(tmp+len,(priv->reg.wep_key[i].size < 6 ? "(40bits) [" : "(104bits) [")); + len+=strlen((priv->reg.wep_key[i].size < 6 ? "(40bits) [" : "(104bits) [")); + for(j=0;jreg.wep_key[i].size;j++,len++) + tmp[len]=(isprint(priv->reg.wep_key[i].val[j]) ? priv->reg.wep_key[i].val[j] : ' '); + + strcpy(tmp+len,"]\n"); + len+=strlen("]\n"); + } + else{ + strcpy(tmp+len,"off\n"); + len+=strlen("off\n"); + } + } + + memcpy(extra, tmp, len); + dwrq->length = len+1; + return 0; +} +#endif + +/*------------------------------------------------------------------*/ +/* Private handler : set beacon lost count */ +static int ks_wlan_set_beacon_lost(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq >= BEACON_LOST_COUNT_MIN && + *uwrq <= BEACON_LOST_COUNT_MAX){ + priv->reg.beacon_lost_count = *uwrq; + }else + return -EINVAL; + + if(priv->reg.operation_mode == MODE_INFRASTRUCTURE){ + priv->need_commit |= SME_MODE_SET; + return -EINPROGRESS; /* Call commit handler */ + } + else + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get beacon lost count */ +static int ks_wlan_get_beacon_lost(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.beacon_lost_count; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set phy type */ +static int ks_wlan_set_phy_type(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == D_11B_ONLY_MODE){ /* 0 */ + priv->reg.phy_type = D_11B_ONLY_MODE; + }else if(*uwrq == D_11G_ONLY_MODE){ /* 1 */ + priv->reg.phy_type = D_11G_ONLY_MODE; + }else if(*uwrq == D_11BG_COMPATIBLE_MODE){ /* 2 */ + priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; + }else + return -EINVAL; + + priv->need_commit |= SME_MODE_SET; + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Private handler : get phy type */ +static int ks_wlan_get_phy_type(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.phy_type; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set cts mode */ +static int ks_wlan_set_cts_mode(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == CTS_MODE_FALSE){ /* 0 */ + priv->reg.cts_mode = CTS_MODE_FALSE; + }else if(*uwrq == CTS_MODE_TRUE){ /* 1 */ + if(priv->reg.phy_type == D_11G_ONLY_MODE || + priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) + priv->reg.cts_mode = CTS_MODE_TRUE; + else + priv->reg.cts_mode = CTS_MODE_FALSE; + }else + return -EINVAL; + + priv->need_commit |= SME_MODE_SET; + return -EINPROGRESS; /* Call commit handler */ +} + +/*------------------------------------------------------------------*/ +/* Private handler : get cts mode */ +static int ks_wlan_get_cts_mode(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.cts_mode; + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set sleep mode */ +static int ks_wlan_set_sleep_mode(struct net_device *dev, + struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2,"\n"); + + if(*uwrq == SLP_SLEEP){ + priv->sleep_mode = *uwrq; + printk("SET_SLEEP_MODE %d\n", priv->sleep_mode); + + hostif_sme_enqueue(priv, SME_STOP_REQUEST); + hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); + + }else if(*uwrq == SLP_ACTIVE) { + priv->sleep_mode = *uwrq; + printk("SET_SLEEP_MODE %d\n", priv->sleep_mode); + hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); + }else{ + printk("SET_SLEEP_MODE %d errror\n", *uwrq); + return -EINVAL; + } + + return 0; +} +/*------------------------------------------------------------------*/ +/* Private handler : get sleep mode */ +static int ks_wlan_get_sleep_mode(struct net_device *dev, + struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2, "GET_SLEEP_MODE %d\n", priv->sleep_mode); + *uwrq = priv->sleep_mode; + + return 0; +} + +#if 0 +/*------------------------------------------------------------------*/ +/* Private handler : set phy information timer */ +static int ks_wlan_set_phy_information_timer(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq >= 0 && *uwrq <= 0xFFFF) /* 0-65535 */ + priv->reg.phy_info_timer = (uint16_t)*uwrq; + else + return -EINVAL; + + hostif_sme_enqueue(priv, SME_PHY_INFO_REQUEST); + + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get phy information timer */ +static int ks_wlan_get_phy_information_timer(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->reg.phy_info_timer; + return 0; +} +#endif + +#ifdef WPS +/*------------------------------------------------------------------*/ +/* Private handler : set WPS enable */ +static int ks_wlan_set_wps_enable(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq == 0 || *uwrq == 1) + priv->wps.wps_enabled = *uwrq; + else + return -EINVAL; + + hostif_sme_enqueue(priv, SME_WPS_ENABLE_REQUEST); + + return 0; +} +/*------------------------------------------------------------------*/ +/* Private handler : get WPS enable */ +static int ks_wlan_get_wps_enable(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->wps.wps_enabled; + printk("return=%d\n", *uwrq); + + return 0; +} +/*------------------------------------------------------------------*/ +/* Private handler : set WPS probe req */ +static int ks_wlan_set_wps_probe_req(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, char *extra) +{ + uint8_t *p = extra; + unsigned char len; + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + DPRINTK(2,"dwrq->length=%d\n", dwrq->length); + + /* length check */ + if(p[1] + 2 != dwrq->length || dwrq->length > 256 ){ + return -EINVAL; + } + + priv->wps.ielen = p[1] + 2 + 1; /* IE header + IE + sizeof(len) */ + len = p[1] + 2; /* IE header + IE */ + + memcpy(priv->wps.ie, &len, sizeof(len)); + p = memcpy(priv->wps.ie+1, p, len); + + DPRINTK(2,"%d(%#x): %02X %02X %02X %02X ... %02X %02X %02X\n", + priv->wps.ielen, priv->wps.ielen, p[0], p[1], p[2], p[3], + p[priv->wps.ielen-3], p[priv->wps.ielen-2], p[priv->wps.ielen-1]); + + hostif_sme_enqueue(priv, SME_WPS_PROBE_REQUEST); + + return 0; +} +#if 0 +/*------------------------------------------------------------------*/ +/* Private handler : get WPS probe req */ +static int ks_wlan_get_wps_probe_req(struct net_device *dev, + struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + DPRINTK(2,"\n"); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + return 0; +} +#endif +#endif /* WPS */ + +/*------------------------------------------------------------------*/ +/* Private handler : set tx gain control value */ +static int ks_wlan_set_tx_gain(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ + priv->gain.TxGain = (uint8_t)*uwrq; + else + return -EINVAL; + + if(priv->gain.TxGain < 0xFF) + priv->gain.TxMode = 1; + else + priv->gain.TxMode = 0; + + + hostif_sme_enqueue(priv, SME_SET_GAIN); + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get tx gain control value */ +static int ks_wlan_get_tx_gain(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->gain.TxGain; + hostif_sme_enqueue(priv, SME_GET_GAIN); + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : set rx gain control value */ +static int ks_wlan_set_rx_gain(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ + priv->gain.RxGain = (uint8_t)*uwrq; + else + return -EINVAL; + + if(priv->gain.RxGain < 0xFF) + priv->gain.RxMode = 1; + else + priv->gain.RxMode = 0; + + hostif_sme_enqueue(priv, SME_SET_GAIN); + return 0; +} + +/*------------------------------------------------------------------*/ +/* Private handler : get rx gain control value */ +static int ks_wlan_get_rx_gain(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + *uwrq = priv->gain.RxGain; + hostif_sme_enqueue(priv, SME_GET_GAIN); + return 0; +} +#if 0 +/*------------------------------------------------------------------*/ +/* Private handler : set region value */ +static int ks_wlan_set_region(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + + if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + + if(*uwrq >= 0x9 && *uwrq <= 0xF) /* 0x9-0xf */ + priv->region = (uint8_t)*uwrq; + else + return -EINVAL; + + hostif_sme_enqueue(priv, SME_SET_REGION); + return 0; +} +#endif + +/*------------------------------------------------------------------*/ +/* Private handler : get eeprom checksum result */ +static int ks_wlan_get_eeprom_cksum(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + *uwrq = priv->eeprom_checksum; + return 0; +} + +static void print_hif_event(int event){ + + switch(event){ + case HIF_DATA_REQ : + printk("HIF_DATA_REQ\n"); + break; + case HIF_DATA_IND : + printk("HIF_DATA_IND\n"); + break; + case HIF_MIB_GET_REQ : + printk("HIF_MIB_GET_REQ\n"); + break; + case HIF_MIB_GET_CONF : + printk("HIF_MIB_GET_CONF\n"); + break; + case HIF_MIB_SET_REQ : + printk("HIF_MIB_SET_REQ\n"); + break; + case HIF_MIB_SET_CONF : + printk("HIF_MIB_SET_CONF\n"); + break; + case HIF_POWERMGT_REQ : + printk("HIF_POWERMGT_REQ\n"); + break; + case HIF_POWERMGT_CONF : + printk("HIF_POWERMGT_CONF\n"); + break; + case HIF_START_REQ : + printk("HIF_START_REQ\n"); + break; + case HIF_START_CONF : + printk("HIF_START_CONF\n"); + break; + case HIF_CONNECT_IND : + printk("HIF_CONNECT_IND\n"); + break; + case HIF_STOP_REQ : + printk("HIF_STOP_REQ\n"); + break; + case HIF_STOP_CONF : + printk("HIF_STOP_CONF\n"); + break; + case HIF_PS_ADH_SET_REQ : + printk("HIF_PS_ADH_SET_REQ\n"); + break; + case HIF_PS_ADH_SET_CONF: + printk("HIF_PS_ADH_SET_CONF\n"); + break; + case HIF_INFRA_SET_REQ : + printk("HIF_INFRA_SET_REQ\n"); + break; + case HIF_INFRA_SET_CONF : + printk("HIF_INFRA_SET_CONF\n"); + break; + case HIF_ADH_SET_REQ : + printk("HIF_ADH_SET_REQ\n"); + break; + case HIF_ADH_SET_CONF : + printk("HIF_ADH_SET_CONF\n"); + break; + case HIF_AP_SET_REQ : + printk("HIF_AP_SET_REQ\n"); + break; + case HIF_AP_SET_CONF : + printk("HIF_AP_SET_CONF\n"); + break; + case HIF_ASSOC_INFO_IND : + printk("HIF_ASSOC_INFO_IND\n"); + break; + case HIF_MIC_FAILURE_REQ: + printk("HIF_MIC_FAILURE_REQ\n"); + break; + case HIF_MIC_FAILURE_CONF : + printk("HIF_MIC_FAILURE_CONF\n"); + break; + case HIF_SCAN_REQ : + printk("HIF_SCAN_REQ\n"); + break; + case HIF_SCAN_CONF : + printk("HIF_SCAN_CONF\n"); + break; + case HIF_PHY_INFO_REQ : + printk("HIF_PHY_INFO_REQ\n"); + break; + case HIF_PHY_INFO_CONF : + printk("HIF_PHY_INFO_CONF\n"); + break; + case HIF_SLEEP_REQ : + printk("HIF_SLEEP_REQ\n"); + break; + case HIF_SLEEP_CONF : + printk("HIF_SLEEP_CONF\n"); + break; + case HIF_PHY_INFO_IND : + printk("HIF_PHY_INFO_IND\n"); + break; + case HIF_SCAN_IND : + printk("HIF_SCAN_IND\n"); + break; + case HIF_INFRA_SET2_REQ : + printk("HIF_INFRA_SET2_REQ\n"); + break; + case HIF_INFRA_SET2_CONF: + printk("HIF_INFRA_SET2_CONF\n"); + break; + case HIF_ADH_SET2_REQ : + printk("HIF_ADH_SET2_REQ\n"); + break; + case HIF_ADH_SET2_CONF : + printk("HIF_ADH_SET2_CONF\n"); + } +} + +/*------------------------------------------------------------------*/ +/* Private handler : get host command history */ +static int ks_wlan_hostt(struct net_device *dev, struct iw_request_info *info, + __u32 *uwrq, char *extra) +{ + int i,event; + ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + + for(i = 63; i >= 0; i--){ + event = priv->hostt.buff[(priv->hostt.qtail -1 -i)%SME_EVENT_BUFF_SIZE] ; + print_hif_event(event); + } + return 0; +} + +/* Structures to export the Wireless Handlers */ + +static const struct iw_priv_args ks_wlan_private_args[] = { +/*{ cmd, set_args, get_args, name[16] } */ + { KS_WLAN_GET_DRIVER_VERSION, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128+1), "GetDriverVer" }, + { KS_WLAN_GET_FIRM_VERSION, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128+1), "GetFirmwareVer" }, +#ifdef WPS + { KS_WLAN_SET_WPS_ENABLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetWPSEnable" }, + { KS_WLAN_GET_WPS_ENABLE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetW" }, + { KS_WLAN_SET_WPS_PROBE_REQ, IW_PRIV_TYPE_BYTE | 2047, IW_PRIV_TYPE_NONE, "SetWPSProbeReq" }, +#endif /* WPS */ + { KS_WLAN_SET_PREAMBLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetPreamble" }, + { KS_WLAN_GET_PREAMBLE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPreamble" }, + { KS_WLAN_SET_POWER_SAVE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetPowerSave" }, + { KS_WLAN_GET_POWER_SAVE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPowerSave" }, + { KS_WLAN_SET_SCAN_TYPE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetScanType" }, + { KS_WLAN_GET_SCAN_TYPE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetScanType" }, + { KS_WLAN_SET_RX_GAIN, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetRxGain" }, + { KS_WLAN_GET_RX_GAIN, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetRxGain" }, + { KS_WLAN_HOSTT, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128+1), "hostt" }, + { KS_WLAN_SET_BEACON_LOST, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetBeaconLost" }, + { KS_WLAN_GET_BEACON_LOST, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetBeaconLost" }, + { KS_WLAN_SET_SLEEP_MODE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetSleepMode" }, + { KS_WLAN_GET_SLEEP_MODE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetSleepMode" }, + { KS_WLAN_SET_TX_GAIN, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetTxGain" }, + { KS_WLAN_GET_TX_GAIN, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetTxGain" }, + { KS_WLAN_SET_PHY_TYPE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetPhyType" }, + { KS_WLAN_GET_PHY_TYPE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPhyType" }, + { KS_WLAN_SET_CTS_MODE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetCtsMode" }, + { KS_WLAN_GET_CTS_MODE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetCtsMode" }, + { KS_WLAN_GET_EEPROM_CKSUM, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetChecksum" }, +}; +static const iw_handler ks_wlan_handler[] = +{ + (iw_handler) ks_wlan_config_commit, /* SIOCSIWCOMMIT */ + (iw_handler) ks_wlan_get_name, /* SIOCGIWNAME */ + (iw_handler) NULL, /* SIOCSIWNWID */ + (iw_handler) NULL, /* SIOCGIWNWID */ + (iw_handler) ks_wlan_set_freq, /* SIOCSIWFREQ */ + (iw_handler) ks_wlan_get_freq, /* SIOCGIWFREQ */ + (iw_handler) ks_wlan_set_mode, /* SIOCSIWMODE */ + (iw_handler) ks_wlan_get_mode, /* SIOCGIWMODE */ +#ifndef KSC_OPNOTSUPP + (iw_handler) ks_wlan_set_sens, /* SIOCSIWSENS */ + (iw_handler) ks_wlan_get_sens, /* SIOCGIWSENS */ +#else /* KSC_OPNOTSUPP */ + (iw_handler) NULL, /* SIOCSIWSENS */ + (iw_handler) NULL, /* SIOCGIWSENS */ +#endif /* KSC_OPNOTSUPP */ + (iw_handler) NULL, /* SIOCSIWRANGE */ + (iw_handler) ks_wlan_get_range, /* SIOCGIWRANGE */ + (iw_handler) NULL, /* SIOCSIWPRIV */ + (iw_handler) NULL, /* SIOCGIWPRIV */ + (iw_handler) NULL, /* SIOCSIWSTATS */ + (iw_handler) ks_wlan_get_iwstats, /* SIOCGIWSTATS */ + (iw_handler) NULL, /* SIOCSIWSPY */ + (iw_handler) NULL, /* SIOCGIWSPY */ + (iw_handler) NULL, /* SIOCSIWTHRSPY */ + (iw_handler) NULL, /* SIOCGIWTHRSPY */ + (iw_handler) ks_wlan_set_wap, /* SIOCSIWAP */ + (iw_handler) ks_wlan_get_wap, /* SIOCGIWAP */ +// (iw_handler) NULL, /* SIOCSIWMLME */ + (iw_handler) ks_wlan_set_mlme, /* SIOCSIWMLME */ + (iw_handler) ks_wlan_get_aplist, /* SIOCGIWAPLIST */ + (iw_handler) ks_wlan_set_scan, /* SIOCSIWSCAN */ + (iw_handler) ks_wlan_get_scan, /* SIOCGIWSCAN */ + (iw_handler) ks_wlan_set_essid, /* SIOCSIWESSID */ + (iw_handler) ks_wlan_get_essid, /* SIOCGIWESSID */ + (iw_handler) ks_wlan_set_nick, /* SIOCSIWNICKN */ + (iw_handler) ks_wlan_get_nick, /* SIOCGIWNICKN */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) ks_wlan_set_rate, /* SIOCSIWRATE */ + (iw_handler) ks_wlan_get_rate, /* SIOCGIWRATE */ + (iw_handler) ks_wlan_set_rts, /* SIOCSIWRTS */ + (iw_handler) ks_wlan_get_rts, /* SIOCGIWRTS */ + (iw_handler) ks_wlan_set_frag, /* SIOCSIWFRAG */ + (iw_handler) ks_wlan_get_frag, /* SIOCGIWFRAG */ +#ifndef KSC_OPNOTSUPP + (iw_handler) ks_wlan_set_txpow, /* SIOCSIWTXPOW */ + (iw_handler) ks_wlan_get_txpow, /* SIOCGIWTXPOW */ + (iw_handler) ks_wlan_set_retry, /* SIOCSIWRETRY */ + (iw_handler) ks_wlan_get_retry, /* SIOCGIWRETRY */ +#else /* KSC_OPNOTSUPP */ + (iw_handler) NULL, /* SIOCSIWTXPOW */ + (iw_handler) NULL, /* SIOCGIWTXPOW */ + (iw_handler) NULL, /* SIOCSIWRETRY */ + (iw_handler) NULL, /* SIOCGIWRETRY */ +#endif /* KSC_OPNOTSUPP */ + (iw_handler) ks_wlan_set_encode, /* SIOCSIWENCODE */ + (iw_handler) ks_wlan_get_encode, /* SIOCGIWENCODE */ + (iw_handler) ks_wlan_set_power, /* SIOCSIWPOWER */ + (iw_handler) ks_wlan_get_power, /* SIOCGIWPOWER */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) NULL, /* -- hole -- */ +// (iw_handler) NULL, /* SIOCSIWGENIE */ + (iw_handler) ks_wlan_set_genie, /* SIOCSIWGENIE */ + (iw_handler) NULL, /* SIOCGIWGENIE */ + (iw_handler) ks_wlan_set_auth_mode, /* SIOCSIWAUTH */ + (iw_handler) ks_wlan_get_auth_mode, /* SIOCGIWAUTH */ + (iw_handler) ks_wlan_set_encode_ext, /* SIOCSIWENCODEEXT */ + (iw_handler) ks_wlan_get_encode_ext, /* SIOCGIWENCODEEXT */ + (iw_handler) ks_wlan_set_pmksa, /* SIOCSIWPMKSA */ + (iw_handler) NULL, /* -- hole -- */ +}; + +/* private_handler */ +static const iw_handler ks_wlan_private_handler[] = +{ + (iw_handler) NULL, /* 0 */ + (iw_handler) ks_wlan_get_driver_version, /* 1 KS_WLAN_GET_DRIVER_VERSION */ + (iw_handler) NULL, /* 2 */ + (iw_handler) ks_wlan_get_firmware_version, /* 3 KS_WLAN_GET_FIRM_VERSION */ +#ifdef WPS + (iw_handler) ks_wlan_set_wps_enable, /* 4 KS_WLAN_SET_WPS_ENABLE */ + (iw_handler) ks_wlan_get_wps_enable, /* 5 KS_WLAN_GET_WPS_ENABLE */ + (iw_handler) ks_wlan_set_wps_probe_req, /* 6 KS_WLAN_SET_WPS_PROBE_REQ */ +#else + (iw_handler) NULL, /* 4 */ + (iw_handler) NULL, /* 5 */ + (iw_handler) NULL, /* 6 */ +#endif /* WPS */ + + (iw_handler) ks_wlan_get_eeprom_cksum, /* 7 KS_WLAN_GET_CONNECT */ + (iw_handler) ks_wlan_set_preamble, /* 8 KS_WLAN_SET_PREAMBLE */ + (iw_handler) ks_wlan_get_preamble, /* 9 KS_WLAN_GET_PREAMBLE */ + (iw_handler) ks_wlan_set_powermgt, /* 10 KS_WLAN_SET_POWER_SAVE */ + (iw_handler) ks_wlan_get_powermgt, /* 11 KS_WLAN_GET_POWER_SAVE */ + (iw_handler) ks_wlan_set_scan_type, /* 12 KS_WLAN_SET_SCAN_TYPE */ + (iw_handler) ks_wlan_get_scan_type, /* 13 KS_WLAN_GET_SCAN_TYPE */ + (iw_handler) ks_wlan_set_rx_gain, /* 14 KS_WLAN_SET_RX_GAIN */ + (iw_handler) ks_wlan_get_rx_gain, /* 15 KS_WLAN_GET_RX_GAIN */ + (iw_handler) ks_wlan_hostt, /* 16 KS_WLAN_HOSTT */ + (iw_handler) NULL, /* 17 */ + (iw_handler) ks_wlan_set_beacon_lost, /* 18 KS_WLAN_SET_BECAN_LOST */ + (iw_handler) ks_wlan_get_beacon_lost, /* 19 KS_WLAN_GET_BECAN_LOST */ + (iw_handler) ks_wlan_set_tx_gain, /* 20 KS_WLAN_SET_TX_GAIN */ + (iw_handler) ks_wlan_get_tx_gain, /* 21 KS_WLAN_GET_TX_GAIN */ + (iw_handler) ks_wlan_set_phy_type, /* 22 KS_WLAN_SET_PHY_TYPE */ + (iw_handler) ks_wlan_get_phy_type, /* 23 KS_WLAN_GET_PHY_TYPE */ + (iw_handler) ks_wlan_set_cts_mode, /* 24 KS_WLAN_SET_CTS_MODE */ + (iw_handler) ks_wlan_get_cts_mode, /* 25 KS_WLAN_GET_CTS_MODE */ + (iw_handler) NULL, /* 26 */ + (iw_handler) NULL, /* 27 */ + (iw_handler) ks_wlan_set_sleep_mode, /* 28 KS_WLAN_SET_SLEEP_MODE */ + (iw_handler) ks_wlan_get_sleep_mode, /* 29 KS_WLAN_GET_SLEEP_MODE */ + (iw_handler) NULL, /* 30 */ + (iw_handler) NULL, /* 31 */ +}; + +static const struct iw_handler_def ks_wlan_handler_def = +{ + .num_standard = sizeof(ks_wlan_handler)/sizeof(iw_handler), + .num_private = sizeof(ks_wlan_private_handler)/sizeof(iw_handler), + .num_private_args = sizeof(ks_wlan_private_args)/sizeof(struct iw_priv_args), + .standard = (iw_handler *) ks_wlan_handler, + .private = (iw_handler *) ks_wlan_private_handler, + .private_args = (struct iw_priv_args *) ks_wlan_private_args, + .get_wireless_stats = ks_get_wireless_stats, +}; + +#endif /* WIRELESS_EXT */ + +static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +{ + int rc = 0; +#if defined(WIRELESS_EXT) + struct iwreq *wrq = (struct iwreq *) rq; +#endif /* WIRELESS_EXT */ + switch (cmd) { +#if defined(WIRELESS_EXT) + case SIOCIWFIRSTPRIV+20: /* KS_WLAN_SET_STOP_REQ */ + rc = ks_wlan_set_stop_request(dev, NULL, &(wrq->u.mode), NULL); + break; +#endif /* WIRELESS_EXT >17 */ + // All other calls are currently unsupported + default: + rc = -EOPNOTSUPP; + } + + DPRINTK(5,"return=%d\n",rc); + return rc; +} + + +static +struct net_device_stats *ks_wlan_get_stats(struct net_device *dev) +{ + ks_wlan_private *priv = netdev_priv(dev); + + if (priv->dev_state < DEVICE_STATE_READY) { + return NULL; /* not finished initialize */ + } + + return &priv->nstats; +} + +static +int ks_wlan_set_mac_address(struct net_device *dev, void *addr) +{ + ks_wlan_private *priv = netdev_priv(dev); + struct sockaddr *mac_addr=(struct sockaddr *)addr; + if (netif_running(dev)) + return -EBUSY; + memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len); + memcpy(priv->eth_addr, mac_addr->sa_data, ETH_ALEN); + + priv->mac_address_valid = 0; + hostif_sme_enqueue(priv, SME_MACADDRESS_SET_REQUEST); + printk(KERN_INFO "ks_wlan: MAC ADDRESS = %02x:%02x:%02x:%02x:%02x:%02x\n", + priv->eth_addr[0],priv->eth_addr[1],priv->eth_addr[2], + priv->eth_addr[3],priv->eth_addr[4],priv->eth_addr[5]); + return 0; +} + + +static +void ks_wlan_tx_timeout(struct net_device *dev) +{ + ks_wlan_private *priv = netdev_priv(dev); + + DPRINTK(1,"head(%d) tail(%d)!!\n",priv->tx_dev.qhead, priv->tx_dev.qtail); + if(!netif_queue_stopped(dev)){ + netif_stop_queue(dev); + } + priv->nstats.tx_errors++; + netif_wake_queue(dev); + + return; +} + +static +int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev) +{ + ks_wlan_private *priv = netdev_priv(dev); + int rc = 0; + + DPRINTK(3,"in_interrupt()=%ld\n",in_interrupt()); + + if ( skb == NULL ) { + printk( KERN_ERR "ks_wlan: skb == NULL!!!\n" ); + return 0; + } + if (priv->dev_state < DEVICE_STATE_READY) { + dev_kfree_skb(skb); + return 0; /* not finished initialize */ + } + + if(netif_running(dev)) + netif_stop_queue(dev); + + rc = hostif_data_request(priv, skb); + dev->trans_start = jiffies; + + DPRINTK(4,"rc=%d\n",rc); + if (rc){ + rc=0; + } + + return rc; +} + +void send_packet_complete(void *arg1, void *arg2) +{ + ks_wlan_private *priv = (ks_wlan_private *)arg1; + struct sk_buff *packet = (struct sk_buff *)arg2; + + DPRINTK(3,"\n"); + + priv->nstats.tx_bytes += packet->len; + priv->nstats.tx_packets++; + + if(netif_queue_stopped(priv->net_dev)) + netif_wake_queue(priv->net_dev); + + if(packet){ + dev_kfree_skb(packet); + packet=NULL; + } + +} + +/* Set or clear the multicast filter for this adaptor. + This routine is not state sensitive and need not be SMP locked. */ +static +void ks_wlan_set_multicast_list(struct net_device *dev) +{ + ks_wlan_private *priv = netdev_priv(dev); + + DPRINTK(4,"\n"); + if (priv->dev_state < DEVICE_STATE_READY) { + return ; /* not finished initialize */ + } + hostif_sme_enqueue(priv, SME_MULTICAST_REQUEST); + + return; +} + +static +int ks_wlan_open(struct net_device *dev) +{ + ks_wlan_private *priv = netdev_priv(dev); + + priv->cur_rx = 0; + + if(!priv->mac_address_valid){ + printk(KERN_ERR "ks_wlan : %s Not READY !!\n", dev->name); + return -EBUSY; + } + else + netif_start_queue (dev); + + return 0; +} + +static +int ks_wlan_close(struct net_device *dev) +{ + + netif_stop_queue (dev); + + DPRINTK(4, "%s: Shutting down ethercard, status was 0x%4.4x.\n", + dev->name, 0x00); + + return 0; +} + + +/* Operational parameters that usually are not changed. */ +/* Time in jiffies before concluding the transmitter is hung. */ +#define TX_TIMEOUT (3*HZ) +static const unsigned char dummy_addr[] = {0x00,0x0b,0xe3,0x00,0x00,0x00}; + +static const struct net_device_ops ks_wlan_netdev_ops = { + .ndo_start_xmit = ks_wlan_start_xmit, + .ndo_open = ks_wlan_open, + .ndo_stop = ks_wlan_close, + .ndo_do_ioctl = ks_wlan_netdev_ioctl, + .ndo_set_mac_address = ks_wlan_set_mac_address, + .ndo_get_stats = ks_wlan_get_stats, + .ndo_tx_timeout = ks_wlan_tx_timeout, + .ndo_set_rx_mode = ks_wlan_set_multicast_list, +}; + +int ks_wlan_net_start(struct net_device *dev) +{ + ks_wlan_private *priv; + /* int rc; */ + + priv = netdev_priv(dev); + priv->mac_address_valid = 0; + priv->need_commit = 0; + + priv->device_open_status = 1; + + /* phy information update timer */ + atomic_set(&update_phyinfo,0); + init_timer(&update_phyinfo_timer); + update_phyinfo_timer.function=ks_wlan_update_phyinfo_timeout; + update_phyinfo_timer.data = (unsigned long)priv; + + /* dummy address set */ + memcpy(priv->eth_addr, dummy_addr, ETH_ALEN); + dev->dev_addr[0] = priv->eth_addr[0]; + dev->dev_addr[1] = priv->eth_addr[1]; + dev->dev_addr[2] = priv->eth_addr[2]; + dev->dev_addr[3] = priv->eth_addr[3]; + dev->dev_addr[4] = priv->eth_addr[4]; + dev->dev_addr[5] = priv->eth_addr[5]; + dev->dev_addr[6] = 0x00; + dev->dev_addr[7] = 0x00; + + /* The ks_wlan-specific entries in the device structure. */ + dev->netdev_ops = &ks_wlan_netdev_ops; + dev->wireless_handlers = (struct iw_handler_def *)&ks_wlan_handler_def; + dev->watchdog_timeo = TX_TIMEOUT; + + netif_carrier_off(dev); + + return 0; +} + + +int ks_wlan_net_stop(struct net_device *dev) +{ + ks_wlan_private *priv = netdev_priv(dev); + + int ret = 0; + priv->device_open_status = 0; + del_timer_sync(&update_phyinfo_timer); + + if(netif_running(dev)) + netif_stop_queue(dev); + + return ret; +} + +int ks_wlan_reset(struct net_device *dev) +{ + return 0; +} diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c new file mode 100644 index 0000000..ec8769a --- /dev/null +++ b/drivers/staging/ks7010/michael_mic.c @@ -0,0 +1,143 @@ +/* + * Driver for KeyStream wireless LAN + * + * michael_mic.c + * $Id: michael_mic.c 991 2009-09-14 01:38:58Z sekine $ + * + * Copyright (C) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +#include +#include +#include "michael_mic.h" + +// Rotation functions on 32 bit values +#define ROL32( A, n ) ( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) ) +#define ROR32( A, n ) ROL32( (A), 32-(n) ) +// Convert from Byte[] to UInt32 in a portable way +#define getUInt32( A, B ) (uint32_t)(A[B+0] << 0) + (A[B+1] << 8) + (A[B+2] << 16) + (A[B+3] << 24) + +// Convert from UInt32 to Byte[] in a portable way +#define putUInt32( A, B, C ) A[B+0] = (uint8_t) (C & 0xff); \ + A[B+1] = (uint8_t) ((C>>8) & 0xff); \ + A[B+2] = (uint8_t) ((C>>16) & 0xff); \ + A[B+3] = (uint8_t) ((C>>24) & 0xff) + +// Reset the state to the empty message. +#define MichaelClear( A ) A->L = A->K0; \ + A->R = A->K1; \ + A->nBytesInM = 0; + +static +void MichaelInitializeFunction( struct michel_mic_t *Mic, uint8_t *key ) +{ + // Set the key + Mic->K0 = getUInt32( key , 0 ); + Mic->K1 = getUInt32( key , 4 ); + + //clear(); + MichaelClear(Mic); +} + +#define MichaelBlockFunction(L, R) \ +do{ \ + R ^= ROL32( L, 17 ); \ + L += R; \ + R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8); \ + L += R; \ + R ^= ROL32( L, 3 ); \ + L += R; \ + R ^= ROR32( L, 2 ); \ + L += R; \ +}while(0) + + +static +void MichaelAppend( struct michel_mic_t *Mic, uint8_t *src, int nBytes ) +{ + int addlen ; + if (Mic->nBytesInM) { + addlen = 4 - Mic->nBytesInM; + if (addlen > nBytes) + addlen = nBytes; + memcpy(&Mic->M[Mic->nBytesInM], src, addlen); + Mic->nBytesInM += addlen; + src += addlen; + nBytes -= addlen; + + if (Mic->nBytesInM < 4) + return; + + Mic->L ^= getUInt32(Mic->M,0); + MichaelBlockFunction(Mic->L, Mic->R); + Mic->nBytesInM = 0; + } + + while(nBytes >= 4){ + Mic->L ^= getUInt32(src,0); + MichaelBlockFunction(Mic->L, Mic->R); + src += 4; + nBytes -= 4; + } + + if (nBytes > 0) { + Mic->nBytesInM = nBytes; + memcpy(Mic->M, src, nBytes); + } +} + +static +void MichaelGetMIC( struct michel_mic_t *Mic, uint8_t *dst ) +{ + uint8_t *data = Mic->M; + switch (Mic->nBytesInM) { + case 0: + Mic->L ^= 0x5a; + break; + case 1: + Mic->L ^= data[0] | 0x5a00; + break; + case 2: + Mic->L ^= data[0] | (data[1] << 8) | 0x5a0000; + break; + case 3: + Mic->L ^= data[0] | (data[1] << 8) | (data[2] << 16) | + 0x5a000000; + break; + } + MichaelBlockFunction(Mic->L, Mic->R); + MichaelBlockFunction(Mic->L, Mic->R); + // The appendByte function has already computed the result. + putUInt32( dst, 0, Mic->L ); + putUInt32( dst, 4, Mic->R ); + + // Reset to the empty message. + MichaelClear(Mic); +} + +void MichaelMICFunction( struct michel_mic_t *Mic, uint8_t *Key, + uint8_t *Data, int Len, uint8_t priority, + uint8_t *Result ) +{ + uint8_t pad_data[4] = {priority,0,0,0}; + // Compute the MIC value + /* + * IEEE802.11i page 47 + * Figure 43g TKIP MIC processing format + * +--+--+--------+--+----+--+--+--+--+--+--+--+--+ + * |6 |6 |1 |3 |M |1 |1 |1 |1 |1 |1 |1 |1 | Octet + * +--+--+--------+--+----+--+--+--+--+--+--+--+--+ + * |DA|SA|Priority|0 |Data|M0|M1|M2|M3|M4|M5|M6|M7| + * +--+--+--------+--+----+--+--+--+--+--+--+--+--+ + */ + MichaelInitializeFunction( Mic, Key ) ; + MichaelAppend( Mic, (uint8_t*)Data, 12 ); /* |DA|SA| */ + MichaelAppend( Mic, pad_data, 4 ); /* |Priority|0|0|0| */ + MichaelAppend( Mic, (uint8_t*)(Data+12), Len -12 ); /* |Data| */ + MichaelGetMIC( Mic, Result ) ; +} diff --git a/drivers/staging/ks7010/michael_mic.h b/drivers/staging/ks7010/michael_mic.h new file mode 100644 index 0000000..f14f160 --- /dev/null +++ b/drivers/staging/ks7010/michael_mic.h @@ -0,0 +1,29 @@ +/* + * Driver for KeyStream wireless LAN + * + * michael_mic.h + * $Id: michael_mic.h 991 2009-09-14 01:38:58Z sekine $ + * + * Copyright (C) 2005-2008 KeyStream Corp. + * Copyright (C) 2009 Renesas Technology Corp. + * + * This program is free software; you can redistribute it and/or modify + * it undr the terms of the GNU General Public License version 2 as + * published by the Free Sotware Foundation. + */ + +/* MichelMIC routine define */ +struct michel_mic_t { + uint32_t K0; // Key + uint32_t K1; // Key + uint32_t L; // Current state + uint32_t R; // Current state + uint8_t M[4]; // Message accumulator (single word) + int nBytesInM; // # bytes in M + uint8_t Result[8]; +}; + +extern +void MichaelMICFunction( struct michel_mic_t *Mic, uint8_t *Key, + uint8_t *Data, int Len, uint8_t priority, + uint8_t *Result ); -- cgit v1.1 From 021873f650658fb1d8da5f3ee7d31eba40b21a93 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:14 +0200 Subject: staging: ks7010: remove non-SDIO code and #ifdefs I couldn't find any trace of code or even products using ks7010 with something else than SDIO. So, remove the conditionals. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/Makefile | 2 +- drivers/staging/ks7010/ks7010_config.c | 6 --- drivers/staging/ks7010/ks_hostif.c | 70 ---------------------------------- drivers/staging/ks7010/ks_wlan.h | 10 ----- 4 files changed, 1 insertion(+), 87 deletions(-) diff --git a/drivers/staging/ks7010/Makefile b/drivers/staging/ks7010/Makefile index 68b7ebf..32b0efc7 100644 --- a/drivers/staging/ks7010/Makefile +++ b/drivers/staging/ks7010/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_KS7010) += ks7010.o -ccflags-y += -D_SDIO_ -DKS_WLAN_DEBUG=0 +ccflags-y += -DKS_WLAN_DEBUG=0 ks7010-y := michael_mic.o ks_hostif.o ks_wlan_net.o ks_debug.o \ ks7010_sdio.o ks7010_config.o diff --git a/drivers/staging/ks7010/ks7010_config.c b/drivers/staging/ks7010/ks7010_config.c index 4a80984..e8a4207 100644 --- a/drivers/staging/ks7010/ks7010_config.c +++ b/drivers/staging/ks7010/ks7010_config.c @@ -268,13 +268,7 @@ int ks_wlan_read_config_file(ks_wlan_private *priv) priv->reg.rate_set.size = 12; #ifndef NO_FIRMWARE_CLASS -#if (defined _PCMCIA_) - dev = &priv->ks_wlan_hw.pcmcia_dev->dev; -#elif (defined _PCI_) - dev = &priv->ks_wlan_hw.pci_dev->dev; -#elif (defined _SDIO_) dev = &priv->ks_wlan_hw.sdio_card->func->dev; -#endif if((retval = request_firmware(&fw_entry, cfg_file, dev)) !=0 ){ DPRINTK(1, "error request_firmware() file=%s ret=%d\n", cfg_file, retval); return 1; diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 402ddba..0295bb4 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -108,51 +108,12 @@ int ks_wlan_do_power_save(ks_wlan_private *priv) DPRINTK(4,"psstatus.status=%d\n",atomic_read(&priv->psstatus.status)); -#ifdef _SDIO_ if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); } else{ priv->dev_state = DEVICE_STATE_READY; } -#else - if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ - switch(atomic_read(&priv->psstatus.status)){ - case PS_ACTIVE_SET: - case PS_WAKEUP: - case PS_SAVE_SET: - case PS_SNOOZE: - break; - case PS_CONF_WAIT: - atomic_set(&priv->psstatus.confirm_wait,0); - break; - case PS_NONE: - default: - hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); - break; - } - - } - else{ - switch(atomic_read(&priv->psstatus.status)){ - case PS_ACTIVE_SET: - case PS_WAKEUP: - case PS_SAVE_SET: - break; - case PS_CONF_WAIT: - atomic_set(&priv->psstatus.confirm_wait,0); - atomic_set(&priv->psstatus.status, PS_WAKEUP); - break; - case PS_SNOOZE: - ks_wlan_hw_power_save(priv); - break; - case PS_NONE: - default: - hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); - break; - } - } -#endif return rc; } @@ -750,17 +711,11 @@ void hostif_power_mngmt_confirm(ks_wlan_private *priv) if(priv->reg.powermgt > POWMGT_ACTIVE_MODE && priv->reg.operation_mode == MODE_INFRASTRUCTURE){ -#if !defined(_SDIO_) - atomic_set(&priv->psstatus.status,PS_SAVE_SET); -#endif atomic_set(&priv->psstatus.confirm_wait, 0); priv->dev_state = DEVICE_STATE_SLEEP; ks_wlan_hw_power_save(priv); }else{ priv->dev_state = DEVICE_STATE_READY; -#if !defined(_SDIO_) - atomic_set(&priv->psstatus.status,PS_ACTIVE_SET); -#endif } } @@ -833,9 +788,6 @@ void hostif_connect_indication(ks_wlan_private *priv) /* for power save */ atomic_set(&priv->psstatus.snooze_guard, 0); atomic_set(&priv->psstatus.confirm_wait,0); -#if !defined(_SDIO_) - atomic_set(&priv->psstatus.status, PS_NONE); -#endif } ks_wlan_do_power_save(priv); @@ -894,10 +846,8 @@ void hostif_stop_confirm(ks_wlan_private *priv) union iwreq_data wrqu0; DPRINTK(3,"\n"); -#ifdef _SDIO_ if(priv->dev_state == DEVICE_STATE_SLEEP) priv->dev_state = DEVICE_STATE_READY; -#endif /* disconnect indication */ if( (priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ @@ -1178,9 +1128,6 @@ int hostif_data_request(ks_wlan_private *priv, struct sk_buff *packet) if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ /* power save wakeup */ if(!netif_queue_stopped(priv->net_dev)) netif_stop_queue(priv->net_dev); -#if !defined(_SDIO_) - schedule_work(&priv->ks_wlan_wakeup_task); -#endif } DPRINTK(4, "skb_buff length=%d\n", packet_len); @@ -1302,14 +1249,10 @@ int hostif_data_request(ks_wlan_private *priv, struct sk_buff *packet) return result; } -#if defined(_SPI_) -#define ps_confirm_wait_inc(priv) -#else #define ps_confirm_wait_inc(priv) do{if(atomic_read(&priv->psstatus.status) > PS_ACTIVE_SET){ \ atomic_inc(&priv->psstatus.confirm_wait); \ /* atomic_set(&priv->psstatus.status, PS_CONF_WAIT);*/ \ } }while(0) -#endif static void hostif_mib_get_request( ks_wlan_private *priv, unsigned long mib_attribute) @@ -2509,9 +2452,6 @@ void hostif_sme_execute(ks_wlan_private *priv, int event) /* for power save */ atomic_set(&priv->psstatus.snooze_guard, 0); atomic_set(&priv->psstatus.confirm_wait,0); -#if !defined(_SDIO_) - atomic_set(&priv->psstatus.status, PS_NONE); -#endif if ( priv->dev_state == DEVICE_STATE_PREINIT ){ priv->dev_state = DEVICE_STATE_INIT; } @@ -2571,16 +2511,6 @@ void hostif_sme_enqueue(ks_wlan_private *priv, unsigned short event) { DPRINTK(3,"\n"); -#if !defined(_SDIO_) - if(atomic_read(&priv->psstatus.status)==PS_SNOOZE && event < SME_START_CONFIRM){ /* power save wakeup*/ - schedule_work(&priv->ks_wlan_wakeup_task); - if(atomic_read(&priv->sme_task.count) <= 0){ - /* schedule_work(&priv->ks_wlan_wakeup_task); */ - DPRINTK(4,"sme task disable.\n"); - tasklet_disable(&priv->sme_task); - } - } -#endif /* enqueue sme event */ diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index c7cbde1..329a062 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -62,17 +62,7 @@ typedef void irqreturn_t; #define pci_name(x) x->slot_name #endif -#if (defined _PCMCIA_) -#include "pcmcia/ks7010_pcmcia.h" -#elif (defined _PCI_) -#include "pci/ks7010_pci.h" -#elif (defined _SDIO_) #include "ks7010_sdio.h" -#elif (defined _SPI_) -#include "spi/ks7010_spi.h" -#else -#error not defined bus type ! -#endif struct ks_wlan_parameter { uint8_t operation_mode; /* Operation Mode */ -- cgit v1.1 From c3fe667f0a99712a2f2ba2f936b35598cf806286 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:15 +0200 Subject: staging: ks7010: remove custom firmware loader FW_LOADER works fine, no need for a open coded fallback. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/Kconfig | 1 + drivers/staging/ks7010/ks7010_config.c | 62 ---------------------------------- drivers/staging/ks7010/ks7010_sdio.c | 56 ------------------------------ drivers/staging/ks7010/ks7010_sdio.h | 5 --- 4 files changed, 1 insertion(+), 123 deletions(-) diff --git a/drivers/staging/ks7010/Kconfig b/drivers/staging/ks7010/Kconfig index dfd4eed..0b92176 100644 --- a/drivers/staging/ks7010/Kconfig +++ b/drivers/staging/ks7010/Kconfig @@ -3,6 +3,7 @@ config KS7010 depends on MMC && WIRELESS select WIRELESS_EXT select WEXT_PRIV + select FW_LOADER help This is a driver for KeyStream KS7010 based SDIO WIFI cards. It is found on at least later Spectec SDW-821 (FCC-ID "S2Y-WLAN-11G-K" only, diff --git a/drivers/staging/ks7010/ks7010_config.c b/drivers/staging/ks7010/ks7010_config.c index e8a4207..7d33070 100644 --- a/drivers/staging/ks7010/ks7010_config.c +++ b/drivers/staging/ks7010/ks7010_config.c @@ -169,11 +169,7 @@ int rate_set_configuration(ks_wlan_private *priv, char *value) return rc; } -#ifndef NO_FIRMWARE_CLASS #include -#else -#define MAX_CONFIG_FILE_SIZE (1024*10) -#endif int ks_wlan_read_config_file(ks_wlan_private *priv) { struct { @@ -206,18 +202,9 @@ int ks_wlan_read_config_file(ks_wlan_private *priv) {0,"",""}, }; -#ifndef NO_FIRMWARE_CLASS const struct firmware *fw_entry; struct device *dev = NULL; int retval; -#else - struct file *srcf; - int nr_read ; - int retval; - char *cfg_buf=NULL; - int orgfsuid, orgfsgid; - mm_segment_t orgfs; -#endif char cfg_file[]=CFG_FILE; char *cur_p, *end_p; char wk_buff[256], *wk_p; @@ -267,7 +254,6 @@ int ks_wlan_read_config_file(ks_wlan_private *priv) priv->reg.tx_rate = TX_RATE_FULL_AUTO; priv->reg.rate_set.size = 12; -#ifndef NO_FIRMWARE_CLASS dev = &priv->ks_wlan_hw.sdio_card->func->dev; if((retval = request_firmware(&fw_entry, cfg_file, dev)) !=0 ){ DPRINTK(1, "error request_firmware() file=%s ret=%d\n", cfg_file, retval); @@ -277,46 +263,6 @@ int ks_wlan_read_config_file(ks_wlan_private *priv) DPRINTK(4, "success request_firmware() file=%s size=%d\n", cfg_file, fw_entry->size); cur_p = fw_entry->data; end_p = cur_p + fw_entry->size; -#else - orgfsuid=current->fsuid; - orgfsgid=current->fsgid; - orgfs=get_fs(); - set_fs(KERNEL_DS); - - srcf = filp_open(cfg_file, O_RDONLY, 0); - if (IS_ERR(srcf)) { - printk(KERN_ERR "error %ld opening %s\n", -PTR_ERR(srcf),cfg_file); - goto no_config_file; - } - - if (!(srcf->f_op && srcf->f_op->read)) { - printk(KERN_ERR "%s does not have a read method\n", cfg_file); - goto no_config_file; - } - - cfg_buf = (char *)kzalloc(MAX_CONFIG_FILE_SIZE, GFP_ATOMIC); - if (!cfg_buf) { - printk(KERN_ERR "%s does not read : out of memory \n", cfg_file); - goto no_config_file; - } - - nr_read = srcf->f_op->read(srcf, (unsigned char *)cfg_buf, MAX_CONFIG_FILE_SIZE, &srcf->f_pos); - - DPRINTK(1, "read retval=%d file=%s\n", nr_read, priv->reg.cfg_file); - retval=filp_close(srcf ,NULL); - if (retval) - DPRINTK(1, "error %d closing %s\n", -retval,priv->reg.cfg_file); - - if (nr_read < 1) { - printk(KERN_ERR "%s does not read : file is empty num=%d\n", cfg_file, nr_read); - goto no_config_file; - }else if(nr_read > MAX_CONFIG_FILE_SIZE){ - printk(KERN_ERR "%s does not read : file is too big \n", cfg_file); - goto no_config_file; - } - cur_p = cfg_buf; - end_p = cur_p + nr_read; -#endif *end_p = '\0'; while (cur_p < end_p) { @@ -524,15 +470,7 @@ int ks_wlan_read_config_file(ks_wlan_private *priv) } } -#ifndef NO_FIRMWARE_CLASS release_firmware(fw_entry); -#else -no_config_file: - kfree(cfg_buf); - set_fs(orgfs); - current->fsuid=orgfsuid; - current->fsgid=orgfsgid; -#endif DPRINTK(3,"\n operation_mode = %d\n channel = %d\n ssid = %s\n tx_rate = %d\n \ preamble = %d\n powermgt = %d\n scan_type = %d\n beacon_lost_count = %d\n rts = %d\n \ diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 7cc49a4..9300658 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -56,10 +56,6 @@ static int ks7010_sdio_read( ks_wlan_private *priv, unsigned int address, unsigned char *buffer, int length ); static int ks7010_sdio_write( ks_wlan_private *priv, unsigned int address, unsigned char *buffer, int length ); -#ifdef NO_FIRMWARE_CLASS -static char *romfile = ROM_FILE; -module_param(romfile, charp, S_IRUGO); -#endif /* macro */ #define inc_txqhead(priv) \ @@ -723,23 +719,15 @@ error_out: if(read_buf) kfree(read_buf); return rc; } -#ifndef NO_FIRMWARE_CLASS #include -#endif static int ks79xx_upload_firmware(ks_wlan_private *priv, struct ks_sdio_card *card) { unsigned int size, offset, n = 0; unsigned char *rom_buf; unsigned char rw_data =0; int retval, rc=0; -#ifndef NO_FIRMWARE_CLASS int length; const struct firmware *fw_entry = NULL; -#else - int orgfsuid, orgfsgid; - struct file *srcf; - mm_segment_t orgfs; -#endif rom_buf = NULL; @@ -758,38 +746,16 @@ static int ks79xx_upload_firmware(ks_wlan_private *priv, struct ks_sdio_card *ca goto error_out0; } -#ifndef NO_FIRMWARE_CLASS if(request_firmware(&fw_entry, priv->reg.rom_file, &priv->ks_wlan_hw.sdio_card->func->dev)!=0){ DPRINTK(1,"error request_firmware() file=%s\n", priv->reg.rom_file); return 1; } DPRINTK(4,"success request_firmware() file=%s size=%d\n", priv->reg.rom_file, fw_entry->size); length = fw_entry->size; -#else - orgfsuid=current->fsuid; - orgfsgid=current->fsgid; - current->fsuid=current->fsgid=0; - orgfs=get_fs(); - set_fs(KERNEL_DS); - - srcf = filp_open(romfile, O_RDONLY, 0); - if (IS_ERR(srcf)) { - DPRINTK(1, "error %ld opening %s\n", -PTR_ERR(srcf),romfile); - rc = 1; - goto error_out1; - } - - if (!(srcf->f_op && srcf->f_op->read)) { - DPRINTK(1, "%s does not have a read method\n", romfile); - rc = 2; - goto error_out2; - } -#endif /* Load Program */ n = 0; do { -#ifndef NO_FIRMWARE_CLASS if(length >= ROM_BUFF_SIZE){ size = ROM_BUFF_SIZE; length = length - ROM_BUFF_SIZE; @@ -801,16 +767,6 @@ static int ks79xx_upload_firmware(ks_wlan_private *priv, struct ks_sdio_card *ca DPRINTK(4, "size = %d\n",size); if(size == 0) break; memcpy(rom_buf,fw_entry->data+n,size); -#else - /* The object must have a read method */ - size = srcf->f_op->read(srcf, rom_buf, ROM_BUFF_SIZE, &srcf->f_pos); - if (size < 0) { - DPRINTK(1, "Read %s error %d\n", priv->reg.rom_file, -retval); - rc = 5; - goto error_out2; - } - else if (size == 0) break; -#endif /* Update write index */ offset = n; retval = ks7010_sdio_update_index(priv, KS7010_IRAM_ADDRESS+offset); @@ -852,20 +808,8 @@ static int ks79xx_upload_firmware(ks_wlan_private *priv, struct ks_sdio_card *ca rc = 0; -#ifdef NO_FIRMWARE_CLASS - error_out2: - retval=filp_close(srcf ,NULL); - if (retval) - DPRINTK(1, "error %d closing %s\n", -retval,priv->reg.rom_file); - - error_out1: - set_fs(orgfs); - current->fsuid=orgfsuid; - current->fsgid=orgfsgid; -#else error_out1: release_firmware(fw_entry); -#endif error_out0: sdio_release_host(card->func); if(rom_buf) diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h index 3af742f..5bf01ab 100644 --- a/drivers/staging/ks7010/ks7010_sdio.h +++ b/drivers/staging/ks7010/ks7010_sdio.h @@ -153,13 +153,8 @@ struct rx_device{ unsigned int qtail; /* rx buffer queue last pointer */ spinlock_t rx_dev_lock; }; -#ifndef NO_FIRMWARE_CLASS #define ROM_FILE "ks7010sd.rom" #define CFG_FILE "ks79xx.cfg" -#else -#define ROM_FILE "/lib/firmware/ks7010sd.rom" -#define CFG_FILE "/lib/firmware/ks79xx.cfg" -#endif #define KS_WLAN_DRIVER_VERSION_INFO "ks7010 sdio linux 007" #endif /* _KS7010_SDIO_H */ -- cgit v1.1 From 4ab274017bc31cea220a531358e8c3e2d08d87fc Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:16 +0200 Subject: staging: ks7010: remove checks for WIRELESS_EXT version We are by far newer than that anyhow. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 23 ----------------------- drivers/staging/ks7010/ks_wlan_net.c | 14 -------------- 2 files changed, 37 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 0295bb4..6bea699 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -22,12 +22,7 @@ #include /* Include Wireless Extension definition and check version */ -#ifndef WIRELESS_EXT -#include -#endif /* WIRELESS_EXT */ -#if WIRELESS_EXT > 12 #include /* New driver API */ -#endif /* WIRELESS_EXT > 12 */ extern int ks_wlan_hw_tx(ks_wlan_private *priv, void *p, unsigned long size, void (*complete_handler)(void *arg1, void *arg2), @@ -121,10 +116,8 @@ static int get_current_ap(ks_wlan_private *priv, struct link_ap_info_t *ap_info) { struct local_ap_t *ap; -#if WIRELESS_EXT > 13 union iwreq_data wrqu; struct net_device *netdev=priv->net_dev; -#endif /* WIRELESS_EXT > 13 */ int rc=0; DPRINTK(3,"\n"); @@ -190,7 +183,6 @@ int get_current_ap(ks_wlan_private *priv, struct link_ap_info_t *ap_info) ap->wpa_ie.size = 0; } -#if WIRELESS_EXT > 13 wrqu.data.length = 0; wrqu.data.flags = 0; wrqu.ap_addr.sa_family = ARPHRD_ETHER; @@ -203,7 +195,6 @@ int get_current_ap(ks_wlan_private *priv, struct link_ap_info_t *ap_info) (unsigned char)wrqu.ap_addr.sa_data[4],(unsigned char)wrqu.ap_addr.sa_data[5]); wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL); } -#endif DPRINTK(4,"\n Link AP\n"); DPRINTK(4," bssid=%02X:%02X:%02X:%02X:%02X:%02X\n \ essid=%s\n rate_set=%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X\n channel=%d\n \ @@ -338,9 +329,7 @@ void hostif_data_indication(ks_wlan_private *priv) struct ieee802_1x_hdr *aa1x_hdr; struct wpa_eapol_key *eap_key; struct michel_mic_t michel_mic; -#if WIRELESS_EXT > 14 union iwreq_data wrqu; -#endif /* WIRELESS_EXT > 14 */ DPRINTK(3,"\n"); @@ -412,7 +401,6 @@ void hostif_data_indication(ks_wlan_private *priv) mic_failure->counter = 1; } priv->wpa.mic_failure.last_failure_time = now; -#if WIRELESS_EXT > 14 /* needed parameters: count, keyid, key type, TSC */ sprintf(buf, "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=" "%02x:%02x:%02x:%02x:%02x:%02x)", @@ -424,7 +412,6 @@ void hostif_data_indication(ks_wlan_private *priv) wrqu.data.length = strlen(buf); DPRINTK(4,"IWEVENT:MICHAELMICFAILURE\n"); wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf); -#endif /* WIRELESS_EXT > 14 */ return; } } @@ -754,9 +741,7 @@ void hostif_connect_indication(ks_wlan_private *priv) unsigned int tmp=0; unsigned int old_status=priv->connect_status; struct net_device *netdev=priv->net_dev; -#if WIRELESS_EXT > 13 union iwreq_data wrqu0; -#endif /* WIRELESS_EXT > 13 */ connect_code = get_WORD(priv); switch(connect_code){ @@ -791,7 +776,6 @@ void hostif_connect_indication(ks_wlan_private *priv) } ks_wlan_do_power_save(priv); -#if WIRELESS_EXT > 13 wrqu0.data.length = 0; wrqu0.data.flags = 0; wrqu0.ap_addr.sa_family = ARPHRD_ETHER; @@ -802,7 +786,6 @@ void hostif_connect_indication(ks_wlan_private *priv) DPRINTK(3,"disconnect :: scan_ind_count=%d\n",priv->scan_ind_count); wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL); } -#endif /* WIRELESS_EXT > 13 */ priv->scan_ind_count=0; } @@ -904,7 +887,6 @@ void hostif_adhoc_set_confirm(ks_wlan_private *priv) static void hostif_associate_indication(ks_wlan_private *priv) { -#if WIRELESS_EXT > 14 struct association_request_t *assoc_req; struct association_response_t *assoc_resp; unsigned char *pb; @@ -944,29 +926,24 @@ void hostif_associate_indication(ks_wlan_private *priv) DPRINTK(3,"IWEVENT:ASSOCINFO\n"); wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf); -#endif /* WIRELESS_EXT > 14 */ } static void hostif_bss_scan_confirm(ks_wlan_private *priv) { unsigned int result_code; -#if WIRELESS_EXT > 13 struct net_device *dev = priv->net_dev; union iwreq_data wrqu; -#endif /* WIRELESS_EXT > 13 */ result_code = get_DWORD(priv); DPRINTK(2,"result=%d :: scan_ind_count=%d\n", result_code, priv->scan_ind_count); priv->sme_i.sme_flag &= ~SME_AP_SCAN; hostif_sme_enqueue(priv, SME_BSS_SCAN_CONFIRM); -#if WIRELESS_EXT > 13 wrqu.data.length = 0; wrqu.data.flags = 0; DPRINTK(3,"IWEVENT: SCAN CONFIRM\n"); wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL); -#endif /* WIRELESS_EXT > 13 */ priv->scan_ind_count=0; } diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 546a256..185630c 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -50,7 +50,6 @@ static int wep_on_off; #define WIRELESS_SPY /* enable iwspy support */ #include /* New driver API */ -#ifdef WIRELESS_EXT /* Frequency list (map channels to frequencies) */ static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484 }; @@ -74,7 +73,6 @@ static const struct iw_handler_def ks_wlan_handler_def; #define KSC_OPNOTSUPP /* Operation Not Support*/ -#endif /* WIRELESS_EXT */ /* * function prototypes @@ -174,7 +172,6 @@ int ks_wlan_setup_parameter(ks_wlan_private *priv, unsigned int commit_flag) return 0; } -#ifdef WIRELESS_EXT /* * Initial Wireless Extension code for Ks_Wlannet driver by : * Jean Tourrilhes - HPL - 17 November 00 @@ -1090,7 +1087,6 @@ static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *inf range->avg_qual.level = 186; /* -70 dBm */ range->avg_qual.noise = 0; -#if defined(WIRELESS_EXT) /* Event capability (kernel + driver) */ range->event_capa[0] = (IW_EVENT_CAPA_K_0 | IW_EVENT_CAPA_MASK(SIOCGIWAP) | @@ -1104,7 +1100,6 @@ static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *inf IW_ENC_CAPA_WPA2 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP); -#endif return 0; } @@ -1229,7 +1224,6 @@ static int ks_wlan_get_aplist(struct net_device *dev, struct iw_request_info *in return 0; } -#if defined(WIRELESS_EXT) /*------------------------------------------------------------------*/ /* Wireless Handler : Initiate Scan */ static int ks_wlan_set_scan(struct net_device *dev, struct iw_request_info *info, @@ -1452,7 +1446,6 @@ DPRINTK(2,"aplist 0\n"); return 0; } -#endif /* WIRELESS_EXT */ /*------------------------------------------------------------------*/ /* Commit handler : called after a bunch of SET operations */ @@ -1469,7 +1462,6 @@ static int ks_wlan_config_commit(struct net_device *dev, struct iw_request_info return 0; } -#ifdef WIRELESS_EXT /*------------------------------------------------------------------*/ /* Wireless handler : set association ie params */ static int ks_wlan_set_genie(struct net_device *dev, struct iw_request_info *info, @@ -1951,7 +1943,6 @@ static int ks_wlan_set_mlme(struct net_device *dev, struct iw_request_info *info return -EOPNOTSUPP; /* Not Support */ } } -#endif /* WIRELESS_EXT */ /*------------------------------------------------------------------*/ /* Private handler : get driver version */ @@ -2915,20 +2906,15 @@ static const struct iw_handler_def ks_wlan_handler_def = .get_wireless_stats = ks_get_wireless_stats, }; -#endif /* WIRELESS_EXT */ static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { int rc = 0; -#if defined(WIRELESS_EXT) struct iwreq *wrq = (struct iwreq *) rq; -#endif /* WIRELESS_EXT */ switch (cmd) { -#if defined(WIRELESS_EXT) case SIOCIWFIRSTPRIV+20: /* KS_WLAN_SET_STOP_REQ */ rc = ks_wlan_set_stop_request(dev, NULL, &(wrq->u.mode), NULL); break; -#endif /* WIRELESS_EXT >17 */ // All other calls are currently unsupported default: rc = -EOPNOTSUPP; -- cgit v1.1 From 72bf750007297c33fe2331d2125118d4885367c2 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:17 +0200 Subject: staging: ks7010: remove code for old kernel versions No need to be backwards compatible. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 9 --------- drivers/staging/ks7010/ks_wlan.h | 28 +--------------------------- drivers/staging/ks7010/ks_wlan_net.c | 3 --- 3 files changed, 1 insertion(+), 39 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 6bea699..146a135 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -2103,11 +2103,7 @@ void hostif_sme_multicast_set(ks_wlan_private *priv) struct net_device *dev = priv->net_dev; int mc_count; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) struct netdev_hw_addr *ha; -#else - struct dev_mc_list *mclist; -#endif char set_address[NIC_MAX_MCAST_LIST*ETH_ALEN]; unsigned long filter_type; int i; @@ -2131,14 +2127,9 @@ void hostif_sme_multicast_set(ks_wlan_private *priv) else { if (priv->sme_i.sme_flag & SME_MULTICAST){ mc_count = netdev_mc_count(dev); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) netdev_for_each_mc_addr(ha, dev) { memcpy(&set_address[i*ETH_ALEN], ha->addr, ETH_ALEN); } -#else - for (i = 0, mclist = dev->mc_list; mclist && i < mc_count; i++, mclist = mclist->next) - memcpy(&set_address[i*ETH_ALEN], mclist->dmi_addr, ETH_ALEN); -#endif priv->sme_i.sme_flag &= ~SME_MULTICAST; hostif_mib_set_request(priv, LOCAL_MULTICAST_ADDRESS, (ETH_ALEN*mc_count), MIB_VALUE_TYPE_OSTRING, &set_address[0]); diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index 329a062..6bd01641 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -18,9 +18,6 @@ #define WPS #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) -#include -#endif #include #include #include @@ -35,32 +32,9 @@ #include /* struct timer_list */ #include #include /* struct completion */ - -#include - -/* Workqueue / task queue backwards compatibility stuff */ -#if ((LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41)) || (defined _MVL31_) || (defined _CELF3_)) #include -#else -#include -#define work_struct tq_struct -#define INIT_WORK INIT_TQUEUE -#define schedule_work schedule_task -#endif -/* Interrupt handler backwards compatibility stuff */ -/* -#ifndef IRQ_NONE -#define IRQ_NONE -#define IRQ_HANDLED -typedef void irqreturn_t; -#endif -*/ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) -#define free_netdev(x) kfree(x) -#define pci_name(x) x->slot_name -#endif +#include #include "ks7010_sdio.h" diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 185630c..776a544 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -13,9 +13,6 @@ */ #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) -#include -#endif #include #include #include -- cgit v1.1 From e8593a8abf8cc35073b1c26bb0492f7e361b6ac1 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:18 +0200 Subject: staging: ks7010: avoid workqueue races My Spectec SDW823 card oopsed when it was already inserted during boot. When debugging this, I noticed that the card init was done in a seperate workqueue which was only activated once in probe. After removing the workqueue and calling the card init directly from probe, the OOPS went away. It turned out this is the same OOPS which happened when removing the card, so this seems possible now. Note: There is still a not-understood card-removed event during boot, but at least it doesn't crash anymore and the card will be re-probed right away. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/TODO | 1 - drivers/staging/ks7010/ks7010_sdio.c | 28 ++-------------------------- drivers/staging/ks7010/ks7010_sdio.h | 2 -- 3 files changed, 2 insertions(+), 29 deletions(-) diff --git a/drivers/staging/ks7010/TODO b/drivers/staging/ks7010/TODO index 390e821..5cbb4ca 100644 --- a/drivers/staging/ks7010/TODO +++ b/drivers/staging/ks7010/TODO @@ -28,7 +28,6 @@ Now the TODOs: should understand the change you submit. - drop using a config file and use an upstream technique for configuration - fix the 'card removal' event when card is inserted when booting -- driver crashes when removing the card - check what other upstream wireless mechanisms can be used instead of the custom ones here diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 9300658..5b78522 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -817,14 +817,8 @@ static int ks79xx_upload_firmware(ks_wlan_private *priv, struct ks_sdio_card *ca return rc; } -static void card_init_task(struct work_struct *work) +static void ks7010_card_init(struct ks_wlan_private *priv) { - struct hw_info_t *hw; - struct ks_wlan_private *priv; - - hw = container_of(work, struct hw_info_t, init_task); - priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw); - DPRINTK(5,"\ncard_init_task()\n"); /* init_waitqueue_head(&priv->confirm_wait); */ @@ -1052,23 +1046,11 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id goto error_free_read_buf; } - priv->ks_wlan_hw.ks7010sdio_init = create_singlethread_workqueue("ks7010sdio_init"); - if(!priv->ks_wlan_hw.ks7010sdio_init){ - DPRINTK(1, "create_workqueue failed !!\n"); - goto error_free_sdio_wq; - } - - INIT_WORK(&priv->ks_wlan_hw.init_task, card_init_task); INIT_DELAYED_WORK(&priv->ks_wlan_hw.rw_wq, ks7010_rw_function); - - queue_work(priv->ks_wlan_hw.ks7010sdio_init, &priv->ks_wlan_hw.init_task); + ks7010_card_init(priv); return 0; -error_free_sdio_wq: - flush_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); - destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); - priv->ks_wlan_hw.ks7010sdio_wq = NULL; error_free_read_buf: kfree(priv->ks_wlan_hw.read_buf); priv->ks_wlan_hw.read_buf = NULL; @@ -1139,12 +1121,6 @@ static void ks7910_sdio_remove(struct sdio_func *func) } DPRINTK(1, "destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq);\n"); - if(priv->ks_wlan_hw.ks7010sdio_init){ - flush_workqueue(priv->ks_wlan_hw.ks7010sdio_init); - destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_init); - } - DPRINTK(1, "destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_init);\n"); - hostif_exit(priv); DPRINTK(1, "hostif_exit\n"); diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h index 5bf01ab..9382383 100644 --- a/drivers/staging/ks7010/ks7010_sdio.h +++ b/drivers/staging/ks7010/ks7010_sdio.h @@ -96,8 +96,6 @@ struct hw_info_t { struct ks_sdio_card *sdio_card; struct completion ks7010_sdio_wait; struct workqueue_struct *ks7010sdio_wq; - struct workqueue_struct *ks7010sdio_init; - struct work_struct init_task; struct delayed_work rw_wq; unsigned char *read_buf; struct tasklet_struct rx_bh_task; -- cgit v1.1 From 19b0832759143896726e69b8d37f078849ccc70a Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:19 +0200 Subject: staging: ks7010: use long preamble as default I had a problem connecting to a network with a short preamble, so let's make the safer option the default. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_config.c b/drivers/staging/ks7010/ks7010_config.c index 7d33070..abe99a5 100644 --- a/drivers/staging/ks7010/ks7010_config.c +++ b/drivers/staging/ks7010/ks7010_config.c @@ -193,7 +193,7 @@ int ks_wlan_read_config_file(ks_wlan_private *priv) {8,"WepIndex","1"}, /* 13 */ {7,"WepType","STRING"}, /* 14 */ {3,"Wep","OFF"}, /* 15 */ - {13,"PREAMBLE_TYPE","SHORT"}, /* 16 */ + {13,"PREAMBLE_TYPE","LONG"}, /* 16 */ {8,"ScanType","ACTIVE_SCAN"}, /* 17 */ {8,"ROM_FILE", ROM_FILE}, /* 18 */ {7,"PhyType", "BG_MODE"}, /* 19 */ @@ -216,7 +216,7 @@ int ks_wlan_read_config_file(ks_wlan_private *priv) priv->reg.ssid.body[0] = '\0'; /* SSID */ priv->reg.ssid.size = 0; /* SSID size */ priv->reg.tx_rate = TX_RATE_AUTO; /* TxRate Fully Auto */ - priv->reg.preamble = SHORT_PREAMBLE; /* Preamble = SHORT */ + priv->reg.preamble = LONG_PREAMBLE; /* Preamble = LONG */ priv->reg.powermgt = POWMGT_ACTIVE_MODE; /* POWMGT_ACTIVE_MODE */ priv->reg.scan_type = ACTIVE_SCAN; /* Active */ priv->reg.beacon_lost_count = 20; /* Beacon Lost Count */ -- cgit v1.1 From 3215bb1a4ba4a6f26272497b4789093549b060e7 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:20 +0200 Subject: staging: ks7010: use kernel helper to print buffer No need for an open coded one. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/Makefile | 2 +- drivers/staging/ks7010/ks7010_sdio.c | 9 +++++---- drivers/staging/ks7010/ks_debug.c | 30 ------------------------------ drivers/staging/ks7010/ks_debug.h | 2 -- 4 files changed, 6 insertions(+), 37 deletions(-) delete mode 100644 drivers/staging/ks7010/ks_debug.c diff --git a/drivers/staging/ks7010/Makefile b/drivers/staging/ks7010/Makefile index 32b0efc7..f6a2cc8 100644 --- a/drivers/staging/ks7010/Makefile +++ b/drivers/staging/ks7010/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_KS7010) += ks7010.o ccflags-y += -DKS_WLAN_DEBUG=0 -ks7010-y := michael_mic.o ks_hostif.o ks_wlan_net.o ks_debug.o \ +ks7010-y := michael_mic.o ks_hostif.o ks_wlan_net.o \ ks7010_sdio.o ks7010_config.o diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 5b78522..1a1a43f 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -441,10 +441,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) /* length check */ if(size > 2046 || size == 0){ - - DPRINTK(5,"-INVAILED DATA dump\n"); - print_buffer(&rx_buffer->data[0],32); - +#ifdef KS_WLAN_DEBUG + if (KS_WLAN_DEBUG > 5) + print_hex_dump_bytes("INVALID DATA dump: ", DUMP_PREFIX_OFFSET, + rx_buffer->data, 32); +#endif /* rx_status update */ read_status = READ_STATUS_IDLE; retval = ks7010_sdio_write(priv, READ_STATUS, &read_status, sizeof(read_status)); diff --git a/drivers/staging/ks7010/ks_debug.c b/drivers/staging/ks7010/ks_debug.c deleted file mode 100644 index 009f5f6..0000000 --- a/drivers/staging/ks7010/ks_debug.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Driver for KeyStream 11b/g wireless LAN cards. - * - * ks_debug.c - * $Id: ks_debug.c 991 2009-09-14 01:38:58Z sekine $ - * - * Copyright (C) 2005-2008 KeyStream Corp. - * Copyright (C) 2009 Renesas Technology Corp. - * - * This program is free software; you can redistribute it and/or modify - * it undr the terms of the GNU General Public License version 2 as - * published by the Free Sotware Foundation. - */ -#include "ks_wlan.h" -#include "ks_debug.h" - -void print_buffer(unsigned char *p, int length) -{ -#ifdef KS_WLAN_DEBUG - int i; -#define HEX_OFFSET "\ - +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F" - printk(HEX_OFFSET); - for (i=0; i Date: Tue, 31 May 2016 12:56:21 +0200 Subject: staging: ks7010: delete seperate debug header Move the one debug macro to the generic wlan header. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_config.c | 1 - drivers/staging/ks7010/ks7010_sdio.c | 1 - drivers/staging/ks7010/ks_debug.h | 28 ---------------------------- drivers/staging/ks7010/ks_hostif.c | 1 - drivers/staging/ks7010/ks_wlan.h | 7 +++++++ drivers/staging/ks7010/ks_wlan_net.c | 1 - 6 files changed, 7 insertions(+), 32 deletions(-) delete mode 100644 drivers/staging/ks7010/ks_debug.h diff --git a/drivers/staging/ks7010/ks7010_config.c b/drivers/staging/ks7010/ks7010_config.c index abe99a5..7f273da 100644 --- a/drivers/staging/ks7010/ks7010_config.c +++ b/drivers/staging/ks7010/ks7010_config.c @@ -4,7 +4,6 @@ #include "ks_wlan.h" #include "ks_hostif.h" #include "ks_wlan_ioctl.h" -#include "ks_debug.h" static int wep_on_off; #define WEP_OFF 0 diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 1a1a43f..3fb432c 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -19,7 +19,6 @@ #include "ks_wlan.h" #include "ks_wlan_ioctl.h" -#include "ks_debug.h" #include "ks_hostif.h" #include "ks7010_sdio.h" diff --git a/drivers/staging/ks7010/ks_debug.h b/drivers/staging/ks7010/ks_debug.h deleted file mode 100644 index adad5f9..0000000 --- a/drivers/staging/ks7010/ks_debug.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Driver for KeyStream 11b/g wireless LAN cards. - * - * ks_debug.h - * $Id: ks_debug.h 991 2009-09-14 01:38:58Z sekine $ - * - * Copyright (C) 2005-2008 KeyStream Corp. - * Copyright (C) 2009 Renesas Technology Corp. - * - * This program is free software; you can redistribute it and/or modify - * it undr the terms of the GNU General Public License version 2 as - * published by the Free Sotware Foundation. - */ - -#ifndef _KS_DEBUG_H -#define _KS_DEBUG_H - -#include - - -#ifdef KS_WLAN_DEBUG -#define DPRINTK(n, fmt, args...) \ - if (KS_WLAN_DEBUG>(n)) printk(KERN_NOTICE "%s: "fmt, __FUNCTION__, ## args) -#else -#define DPRINTK(n, fmt, args...) -#endif - -#endif /* _KS_DEBUG_H */ diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 146a135..367d487 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -13,7 +13,6 @@ */ #include "ks_wlan.h" -#include "ks_debug.h" #include "ks_hostif.h" #include "eap_packet.h" #include "michael_mic.h" diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index 6bd01641..c460741 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -38,6 +38,13 @@ #include "ks7010_sdio.h" +#ifdef KS_WLAN_DEBUG +#define DPRINTK(n, fmt, args...) \ + if (KS_WLAN_DEBUG>(n)) printk(KERN_NOTICE "%s: "fmt, __FUNCTION__, ## args) +#else +#define DPRINTK(n, fmt, args...) +#endif + struct ks_wlan_parameter { uint8_t operation_mode; /* Operation Mode */ uint8_t channel; /* Channel */ diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 776a544..1da2768 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -40,7 +40,6 @@ static int wep_on_off; #include "ks_wlan.h" #include "ks_hostif.h" #include "ks_wlan_ioctl.h" -#include "ks_debug.h" /* Include Wireless Extension definition and check version */ #include -- cgit v1.1 From f88e6d3317907b93d7e8cbdbc0e26012cc1b1a48 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:22 +0200 Subject: staging: ks7010: really iterate over multicast addresses The loop variable was defined but not really used. Fix this. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 367d487..b0a0a53d 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -2105,7 +2105,7 @@ void hostif_sme_multicast_set(ks_wlan_private *priv) struct netdev_hw_addr *ha; char set_address[NIC_MAX_MCAST_LIST*ETH_ALEN]; unsigned long filter_type; - int i; + int i = 0; DPRINTK(3,"\n"); @@ -2128,6 +2128,7 @@ void hostif_sme_multicast_set(ks_wlan_private *priv) mc_count = netdev_mc_count(dev); netdev_for_each_mc_addr(ha, dev) { memcpy(&set_address[i*ETH_ALEN], ha->addr, ETH_ALEN); + i++; } priv->sme_i.sme_flag &= ~SME_MULTICAST; hostif_mib_set_request(priv, LOCAL_MULTICAST_ADDRESS, -- cgit v1.1 From 4fdec6ad1cdfa6559c1e1ba868d92a02f9f1e6ae Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:23 +0200 Subject: staging: ks7010: make loading config file optional We have sane defaults, so we don't need to bail out if there is no config file. Note that the config file should go away completely in favour of configuration mechanisms already upstream. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_config.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_config.c b/drivers/staging/ks7010/ks7010_config.c index 7f273da..06ff885 100644 --- a/drivers/staging/ks7010/ks7010_config.c +++ b/drivers/staging/ks7010/ks7010_config.c @@ -203,7 +203,6 @@ int ks_wlan_read_config_file(ks_wlan_private *priv) const struct firmware *fw_entry; struct device *dev = NULL; - int retval; char cfg_file[]=CFG_FILE; char *cur_p, *end_p; char wk_buff[256], *wk_p; @@ -254,10 +253,9 @@ int ks_wlan_read_config_file(ks_wlan_private *priv) priv->reg.rate_set.size = 12; dev = &priv->ks_wlan_hw.sdio_card->func->dev; - if((retval = request_firmware(&fw_entry, cfg_file, dev)) !=0 ){ - DPRINTK(1, "error request_firmware() file=%s ret=%d\n", cfg_file, retval); - return 1; - } + /* If no cfg file, stay with the defaults */ + if (request_firmware_direct(&fw_entry, cfg_file, dev)) + return 0; DPRINTK(4, "success request_firmware() file=%s size=%d\n", cfg_file, fw_entry->size); cur_p = fw_entry->data; -- cgit v1.1 From f8d72df83ca4d3b80517d721bef6d124393a35e7 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:24 +0200 Subject: staging: ks7010: fix printk format warnings Use proper type for size_t. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_config.c | 2 +- drivers/staging/ks7010/ks7010_sdio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_config.c b/drivers/staging/ks7010/ks7010_config.c index 06ff885..4b00d25 100644 --- a/drivers/staging/ks7010/ks7010_config.c +++ b/drivers/staging/ks7010/ks7010_config.c @@ -257,7 +257,7 @@ int ks_wlan_read_config_file(ks_wlan_private *priv) if (request_firmware_direct(&fw_entry, cfg_file, dev)) return 0; - DPRINTK(4, "success request_firmware() file=%s size=%d\n", cfg_file, fw_entry->size); + DPRINTK(4, "success request_firmware() file=%s size=%zu\n", cfg_file, fw_entry->size); cur_p = fw_entry->data; end_p = cur_p + fw_entry->size; *end_p = '\0'; diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 3fb432c..5036490 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -750,7 +750,7 @@ static int ks79xx_upload_firmware(ks_wlan_private *priv, struct ks_sdio_card *ca DPRINTK(1,"error request_firmware() file=%s\n", priv->reg.rom_file); return 1; } - DPRINTK(4,"success request_firmware() file=%s size=%d\n", priv->reg.rom_file, fw_entry->size); + DPRINTK(4,"success request_firmware() file=%s size=%zu\n", priv->reg.rom_file, fw_entry->size); length = fw_entry->size; /* Load Program */ -- cgit v1.1 From acd15986df6aa3fa2c56201693c3b1d245f88630 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:25 +0200 Subject: staging: ks7010: add example cfg file as a reference We want to remove it, but to do so properly, it is good to have a working example. Needs to be copied to /lib/firmware in order to be used. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks79xx.cfg | 116 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 drivers/staging/ks7010/ks79xx.cfg diff --git a/drivers/staging/ks7010/ks79xx.cfg b/drivers/staging/ks7010/ks79xx.cfg new file mode 100644 index 0000000..0f2d24d --- /dev/null +++ b/drivers/staging/ks7010/ks79xx.cfg @@ -0,0 +1,116 @@ +#ks79xx.cfg +#KS79xx configuration file +# + +# +#BeaconLostCount default 20 +BeaconLostCount=20 +# + +# +#Ap List Scan Type default ACTIVE_SCAN ACTIVE_SCAN or PASSIVE_SCAN +ScanType=ACTIVE_SCAN +# + +# +#Channel default 10 min 1 max 14 +Channel=10 +# + +# +#FragmentThreshold default 2346 min 256 max 2346 +FragmentThreshold=2346 +# + +# +#OperationMode default Infrastructure Pseudo-Ad-Hoc or 802.11-Ad-Hoc or Infrastructure +OperationMode=Infrastructure +# + +# +#PowerManagementMode default ACTIVE ACTIVE or SAVE1 or SAVE2 +PowerManagementMode=ACTIVE +# + +# +#RTSThreshold default 2347 min 0 max 2347 +RTSThreshold=2347 +# + +# +#SSID default "" max 32 character +SSID="default" +# + +# +#TxRate default Auto 1, 2, 5.5, 11 ex. TxRate=1,2 TxRate=11 TxRate=Auto ... +TxRate=Auto +# + +# +#Wep default OFF OFF or 64bit or 128bit +Wep=OFF +# + +# +#WepType default STRING STRING or HEX +WepType=STRING +# + +# +#WepIndex=1 +# + +# +#WepKeyValue1 +# character_wep_key:64bit key_length = 5; 128bit key_length = 13 +# hex_wep_key:64bit key_length = 10; 128bit key_length = 26 +# + +# +#WepKeyValue2 +# character_wep_key:64bit key_length = 5; 128bit key_length = 13 +# hex_wep_key:64bit key_length = 10; 128bit key_length = 26 +# + +# +#WepKeyValue3 +# character_wep_key:64bit key_length = 5; 128bit key_length = 13 +# hex_wep_key:64bit key_length = 10; 128bit key_length = 26 +# + +# +#WepKeyValue4 +# character_wep_key:64bit key_length = 5; 128bit key_length = 13 +# hex_wep_key:64bit key_length = 10; 128bit key_length = 26 +# + +# +#AuthenticationAlgorithm default OPEN_SYSTEM OPEN_SYSTEM or SHARED_KEY +AuthenticationAlgorithm=OPEN_SYSTEM +# + +# +#PREAMBLE_TYPE default LONG LONG or SHORT +PREAMBLE_TYPE=SHORT +# + +# +# PhyType default BG_MODE B_MODE, G_MODE or BG_MODE +PhyType=BG_MODE +# + +# +# CtsMode defalut FALSE TURE or FALSE +CtsMode=FALSE +# + +# +# PhyInformationTimer defalut 0 uint 100msec +PhyInformationTimer=0 +# + +# +#ROM_FILE default "ks7010sd.rom" +ROM_FILE="ks7010sd.rom" +# -- cgit v1.1 From feedcf1a5f3d4fc964d9f7b4d755fc0992378abf Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:26 +0200 Subject: staging: ks7010: remove unecessary typedef Let's simply specify the struct to keep in sync with kernel coding style. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_config.c | 4 +- drivers/staging/ks7010/ks7010_sdio.c | 44 ++++----- drivers/staging/ks7010/ks7010_sdio.h | 2 +- drivers/staging/ks7010/ks_hostif.c | 114 +++++++++++----------- drivers/staging/ks7010/ks_hostif.h | 10 +- drivers/staging/ks7010/ks_wlan.h | 4 +- drivers/staging/ks7010/ks_wlan_ioctl.h | 4 +- drivers/staging/ks7010/ks_wlan_net.c | 168 ++++++++++++++++----------------- 8 files changed, 175 insertions(+), 175 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_config.c b/drivers/staging/ks7010/ks7010_config.c index 4b00d25..48809bc 100644 --- a/drivers/staging/ks7010/ks7010_config.c +++ b/drivers/staging/ks7010/ks7010_config.c @@ -87,7 +87,7 @@ void analyze_hex_wep_key(struct ks_wlan_parameter *param, int wep_key_index, cha } static -int rate_set_configuration(ks_wlan_private *priv, char *value) +int rate_set_configuration(struct ks_wlan_private *priv, char *value) { int rc=0; @@ -169,7 +169,7 @@ int rate_set_configuration(ks_wlan_private *priv, char *value) } #include -int ks_wlan_read_config_file(ks_wlan_private *priv) +int ks_wlan_read_config_file(struct ks_wlan_private *priv) { struct { const int key_len; diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 5036490..fb9f0b5 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -51,9 +51,9 @@ static struct ks_sdio_model ks_sdio_models[] = { static int ks7910_sdio_probe(struct sdio_func *function, const struct sdio_device_id *device); static void ks7910_sdio_remove(struct sdio_func *function); static void ks7010_rw_function(struct work_struct *work); -static int ks7010_sdio_read( ks_wlan_private *priv, unsigned int address, +static int ks7010_sdio_read( struct ks_wlan_private *priv, unsigned int address, unsigned char *buffer, int length ); -static int ks7010_sdio_write( ks_wlan_private *priv, unsigned int address, +static int ks7010_sdio_write( struct ks_wlan_private *priv, unsigned int address, unsigned char *buffer, int length ); /* macro */ @@ -71,7 +71,7 @@ static int ks7010_sdio_write( ks_wlan_private *priv, unsigned int address, #define cnt_rxqbody(priv) \ (((priv->rx_dev.qtail + RX_DEVICE_BUFF_SIZE) - (priv->rx_dev.qhead)) % RX_DEVICE_BUFF_SIZE ) -void ks_wlan_hw_sleep_doze_request(ks_wlan_private *priv) +void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) { unsigned char rw_data; int retval; @@ -102,7 +102,7 @@ out: return; } -void ks_wlan_hw_sleep_wakeup_request(ks_wlan_private *priv) +void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv) { unsigned char rw_data; int retval; @@ -134,7 +134,7 @@ out: } -void ks_wlan_hw_wakeup_request(ks_wlan_private *priv) +void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv) { unsigned char rw_data; int retval; @@ -155,7 +155,7 @@ void ks_wlan_hw_wakeup_request(ks_wlan_private *priv) } } -int _ks_wlan_hw_power_save(ks_wlan_private *priv) +int _ks_wlan_hw_power_save(struct ks_wlan_private *priv) { int rc=0; unsigned char rw_data; @@ -220,13 +220,13 @@ int _ks_wlan_hw_power_save(ks_wlan_private *priv) return rc; } -int ks_wlan_hw_power_save(ks_wlan_private *priv) +int ks_wlan_hw_power_save(struct ks_wlan_private *priv) { queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); return 0; } -static int ks7010_sdio_read(ks_wlan_private *priv, unsigned int address, +static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address, unsigned char *buffer, int length) { int rc = -1; @@ -249,7 +249,7 @@ static int ks7010_sdio_read(ks_wlan_private *priv, unsigned int address, return rc; } -static int ks7010_sdio_write(ks_wlan_private *priv, unsigned int address, +static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address, unsigned char *buffer, int length) { int rc = -1; @@ -272,7 +272,7 @@ static int ks7010_sdio_write(ks_wlan_private *priv, unsigned int address, return rc; } -static int enqueue_txdev(ks_wlan_private *priv, unsigned char *p, unsigned long size, +static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, unsigned long size, void (*complete_handler)(void *arg1, void *arg2), void *arg1, void *arg2 ) { @@ -306,7 +306,7 @@ static int enqueue_txdev(ks_wlan_private *priv, unsigned char *p, unsigned long } /* write data */ -static int write_to_device(ks_wlan_private *priv, unsigned char *buffer, unsigned long size ) +static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer, unsigned long size ) { int rc,retval; unsigned char rw_data; @@ -338,7 +338,7 @@ static int write_to_device(ks_wlan_private *priv, unsigned char *buffer, unsigne static void tx_device_task(void *dev) { - ks_wlan_private *priv = (ks_wlan_private *)dev; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; struct tx_device_buffer *sp; int rc = 0; @@ -366,7 +366,7 @@ static void tx_device_task(void *dev) return; } -int ks_wlan_hw_tx( ks_wlan_private *priv, void *p, unsigned long size, +int ks_wlan_hw_tx( struct ks_wlan_private *priv, void *p, unsigned long size, void (*complete_handler)(void *arg1, void *arg2), void *arg1, void *arg2 ) { @@ -396,7 +396,7 @@ int ks_wlan_hw_tx( ks_wlan_private *priv, void *p, unsigned long size, static void rx_event_task(unsigned long dev) { - ks_wlan_private *priv = (ks_wlan_private *)dev; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; struct rx_device_buffer *rp; DPRINTK(4,"\n"); @@ -416,7 +416,7 @@ static void rx_event_task(unsigned long dev) static void ks_wlan_hw_rx(void *dev, uint16_t size) { - ks_wlan_private *priv = (ks_wlan_private *)dev; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; int retval; struct rx_device_buffer *rx_buffer; struct hostif_hdr *hdr; @@ -560,7 +560,7 @@ static void ks_sdio_interrupt(struct sdio_func *func) { int retval; struct ks_sdio_card *card; - ks_wlan_private *priv; + struct ks_wlan_private *priv; unsigned char status, rsize, rw_data; card = sdio_get_drvdata(func); @@ -643,7 +643,7 @@ intr_out: return; } -static int trx_device_init( ks_wlan_private *priv ) +static int trx_device_init( struct ks_wlan_private *priv ) { /* initialize values (tx) */ priv->tx_dev.qtail = priv->tx_dev.qhead = 0; @@ -660,7 +660,7 @@ static int trx_device_init( ks_wlan_private *priv ) return 0; } -static void trx_device_exit( ks_wlan_private *priv ) +static void trx_device_exit( struct ks_wlan_private *priv ) { struct tx_device_buffer *sp; @@ -677,7 +677,7 @@ static void trx_device_exit( ks_wlan_private *priv ) return; } -static int ks7010_sdio_update_index(ks_wlan_private *priv, u32 index) +static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) { int rc=0; int retval; @@ -699,7 +699,7 @@ error_out: } #define ROM_BUFF_SIZE (64*1024) -static int ks7010_sdio_data_compare(ks_wlan_private *priv, u32 address, +static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address, unsigned char *data, unsigned int size) { int rc=0; @@ -720,7 +720,7 @@ error_out: return rc; } #include -static int ks79xx_upload_firmware(ks_wlan_private *priv, struct ks_sdio_card *card) +static int ks79xx_upload_firmware(struct ks_wlan_private *priv, struct ks_sdio_card *card) { unsigned int size, offset, n = 0; unsigned char *rom_buf; @@ -886,7 +886,7 @@ extern int ks_wlan_net_stop(struct net_device *dev); static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id *device) { - ks_wlan_private *priv; + struct ks_wlan_private *priv; struct ks_sdio_card *card; struct net_device *netdev; unsigned char rw_data; diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h index 9382383..1d16673 100644 --- a/drivers/staging/ks7010/ks7010_sdio.h +++ b/drivers/staging/ks7010/ks7010_sdio.h @@ -110,7 +110,7 @@ struct ks_sdio_packet { struct ks_sdio_card { struct sdio_func *func; - struct ks_wlan_private *priv; + struct ks_wlan_private *priv; int model; const char *firmware; spinlock_t lock; diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index b0a0a53d..497b8aa 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -23,13 +23,13 @@ /* Include Wireless Extension definition and check version */ #include /* New driver API */ -extern int ks_wlan_hw_tx(ks_wlan_private *priv, void *p, unsigned long size, +extern int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, void (*complete_handler)(void *arg1, void *arg2), void *arg1, void *arg2 ); extern void send_packet_complete(void *, void *); -extern void ks_wlan_hw_wakeup_request(ks_wlan_private *priv); -extern int ks_wlan_hw_power_save(ks_wlan_private *priv); +extern void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv); +extern int ks_wlan_hw_power_save(struct ks_wlan_private *priv); /* macro */ #define inc_smeqhead(priv) \ @@ -42,7 +42,7 @@ extern int ks_wlan_hw_power_save(ks_wlan_private *priv); #define KS_WLAN_MEM_FLAG (GFP_ATOMIC) static -inline u8 get_BYTE(ks_wlan_private *priv) +inline u8 get_BYTE(struct ks_wlan_private *priv) { u8 data; data = *(priv->rxp)++; @@ -52,7 +52,7 @@ inline u8 get_BYTE(ks_wlan_private *priv) } static -inline u16 get_WORD(ks_wlan_private *priv) +inline u16 get_WORD(struct ks_wlan_private *priv) { u16 data; data = (get_BYTE(priv) & 0xff); @@ -61,7 +61,7 @@ inline u16 get_WORD(ks_wlan_private *priv) } static -inline u32 get_DWORD(ks_wlan_private *priv) +inline u32 get_DWORD(struct ks_wlan_private *priv) { u32 data; data = (get_BYTE(priv) & 0xff); @@ -73,7 +73,7 @@ inline u32 get_DWORD(ks_wlan_private *priv) void ks_wlan_hw_wakeup_task(struct work_struct *work) { - ks_wlan_private *priv = container_of(work, struct ks_wlan_private, ks_wlan_wakeup_task); + struct ks_wlan_private *priv = container_of(work, struct ks_wlan_private, ks_wlan_wakeup_task); int ps_status = atomic_read(&priv->psstatus.status); if(ps_status==PS_SNOOZE){ @@ -96,7 +96,7 @@ void ks_wlan_hw_wakeup_task(struct work_struct *work) } static -int ks_wlan_do_power_save(ks_wlan_private *priv) +int ks_wlan_do_power_save(struct ks_wlan_private *priv) { int rc=0; @@ -112,7 +112,7 @@ int ks_wlan_do_power_save(ks_wlan_private *priv) } static -int get_current_ap(ks_wlan_private *priv, struct link_ap_info_t *ap_info) +int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info) { struct local_ap_t *ap; union iwreq_data wrqu; @@ -213,7 +213,7 @@ int get_current_ap(ks_wlan_private *priv, struct link_ap_info_t *ap_info) } static -int get_ap_information(ks_wlan_private *priv, struct ap_info_t *ap_info, struct local_ap_t *ap) +int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, struct local_ap_t *ap) { unsigned char *bp; int bsize,offset; @@ -312,7 +312,7 @@ int get_ap_information(ks_wlan_private *priv, struct ap_info_t *ap_info, struct } static -void hostif_data_indication(ks_wlan_private *priv) +void hostif_data_indication(struct ks_wlan_private *priv) { unsigned int rx_ind_size; /* indicate data size */ struct sk_buff *skb; @@ -491,7 +491,7 @@ void hostif_data_indication(ks_wlan_private *priv) } static -void hostif_mib_get_confirm(ks_wlan_private *priv) +void hostif_mib_get_confirm(struct ks_wlan_private *priv) { struct net_device *dev=priv->net_dev; uint32_t mib_status; @@ -570,7 +570,7 @@ void hostif_mib_get_confirm(ks_wlan_private *priv) } static -void hostif_mib_set_confirm(ks_wlan_private *priv) +void hostif_mib_set_confirm(struct ks_wlan_private *priv) { uint32_t mib_status; /* +04 MIB Status */ uint32_t mib_attribute; /* +08 MIB attribute */ @@ -691,7 +691,7 @@ void hostif_mib_set_confirm(ks_wlan_private *priv) } static -void hostif_power_mngmt_confirm(ks_wlan_private *priv) +void hostif_power_mngmt_confirm(struct ks_wlan_private *priv) { DPRINTK(3,"\n"); @@ -707,7 +707,7 @@ void hostif_power_mngmt_confirm(ks_wlan_private *priv) } static -void hostif_sleep_confirm(ks_wlan_private *priv) +void hostif_sleep_confirm(struct ks_wlan_private *priv) { DPRINTK(3,"\n"); @@ -716,7 +716,7 @@ void hostif_sleep_confirm(ks_wlan_private *priv) } static -void hostif_start_confirm(ks_wlan_private *priv) +void hostif_start_confirm(struct ks_wlan_private *priv) { #ifdef WPS union iwreq_data wrqu; @@ -734,7 +734,7 @@ void hostif_start_confirm(ks_wlan_private *priv) } static -void hostif_connect_indication(ks_wlan_private *priv) +void hostif_connect_indication(struct ks_wlan_private *priv) { unsigned short connect_code; unsigned int tmp=0; @@ -789,7 +789,7 @@ void hostif_connect_indication(ks_wlan_private *priv) } static -void hostif_scan_indication(ks_wlan_private *priv) +void hostif_scan_indication(struct ks_wlan_private *priv) { int i; struct ap_info_t *ap_info; @@ -820,7 +820,7 @@ void hostif_scan_indication(ks_wlan_private *priv) } static -void hostif_stop_confirm(ks_wlan_private *priv) +void hostif_stop_confirm(struct ks_wlan_private *priv) { unsigned int tmp=0; unsigned int old_status=priv->connect_status; @@ -856,7 +856,7 @@ void hostif_stop_confirm(ks_wlan_private *priv) } static -void hostif_ps_adhoc_set_confirm(ks_wlan_private *priv) +void hostif_ps_adhoc_set_confirm(struct ks_wlan_private *priv) { DPRINTK(3,"\n"); priv->infra_status = 0; /* infrastructure mode cancel */ @@ -865,7 +865,7 @@ void hostif_ps_adhoc_set_confirm(ks_wlan_private *priv) } static -void hostif_infrastructure_set_confirm(ks_wlan_private *priv) +void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv) { uint16_t result_code; DPRINTK(3,"\n"); @@ -876,7 +876,7 @@ void hostif_infrastructure_set_confirm(ks_wlan_private *priv) } static -void hostif_adhoc_set_confirm(ks_wlan_private *priv) +void hostif_adhoc_set_confirm(struct ks_wlan_private *priv) { DPRINTK(3,"\n"); priv->infra_status = 1; /* infrastructure mode set */ @@ -884,7 +884,7 @@ void hostif_adhoc_set_confirm(ks_wlan_private *priv) } static -void hostif_associate_indication(ks_wlan_private *priv) +void hostif_associate_indication(struct ks_wlan_private *priv) { struct association_request_t *assoc_req; struct association_response_t *assoc_resp; @@ -928,7 +928,7 @@ void hostif_associate_indication(ks_wlan_private *priv) } static -void hostif_bss_scan_confirm(ks_wlan_private *priv) +void hostif_bss_scan_confirm(struct ks_wlan_private *priv) { unsigned int result_code; struct net_device *dev = priv->net_dev; @@ -947,7 +947,7 @@ void hostif_bss_scan_confirm(ks_wlan_private *priv) } static -void hostif_phy_information_confirm(ks_wlan_private *priv) +void hostif_phy_information_confirm(struct ks_wlan_private *priv) { struct iw_statistics *wstats = &priv->wstats; unsigned char rssi,signal,noise; @@ -983,7 +983,7 @@ void hostif_phy_information_confirm(ks_wlan_private *priv) } static -void hostif_mic_failure_confirm(ks_wlan_private *priv) +void hostif_mic_failure_confirm(struct ks_wlan_private *priv) { DPRINTK(3,"mic_failure=%u\n",priv->wpa.mic_failure.failure); hostif_sme_enqueue(priv, SME_MIC_FAILURE_CONFIRM); @@ -991,7 +991,7 @@ void hostif_mic_failure_confirm(ks_wlan_private *priv) static -void hostif_event_check(ks_wlan_private *priv) +void hostif_event_check(struct ks_wlan_private *priv) { unsigned short event; @@ -1065,7 +1065,7 @@ void hostif_event_check(ks_wlan_private *priv) #define CHECK_ALINE(size) (size%4 ? (size+(4-(size%4))):size) -int hostif_data_request(ks_wlan_private *priv, struct sk_buff *packet) +int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) { unsigned int packet_len=0; @@ -1231,7 +1231,7 @@ int hostif_data_request(ks_wlan_private *priv, struct sk_buff *packet) } }while(0) static -void hostif_mib_get_request( ks_wlan_private *priv, unsigned long mib_attribute) +void hostif_mib_get_request( struct ks_wlan_private *priv, unsigned long mib_attribute) { struct hostif_mib_get_request_t *pp; @@ -1253,7 +1253,7 @@ void hostif_mib_get_request( ks_wlan_private *priv, unsigned long mib_attribute) } static -void hostif_mib_set_request( ks_wlan_private *priv, unsigned long mib_attribute, +void hostif_mib_set_request( struct ks_wlan_private *priv, unsigned long mib_attribute, unsigned short size, unsigned short type, void *vp ) { @@ -1286,7 +1286,7 @@ void hostif_mib_set_request( ks_wlan_private *priv, unsigned long mib_attribute, } static -void hostif_start_request( ks_wlan_private *priv, unsigned char mode ) +void hostif_start_request( struct ks_wlan_private *priv, unsigned char mode ) { struct hostif_start_request_t *pp; @@ -1311,7 +1311,7 @@ void hostif_start_request( ks_wlan_private *priv, unsigned char mode ) } static -void hostif_ps_adhoc_set_request(ks_wlan_private *priv) +void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv) { struct hostif_ps_adhoc_set_request_t *pp; uint16_t capability; @@ -1352,7 +1352,7 @@ void hostif_ps_adhoc_set_request(ks_wlan_private *priv) } static -void hostif_infrastructure_set_request(ks_wlan_private *priv) +void hostif_infrastructure_set_request(struct ks_wlan_private *priv) { struct hostif_infrastructure_set_request_t *pp; uint16_t capability; @@ -1415,7 +1415,7 @@ void hostif_infrastructure_set_request(ks_wlan_private *priv) ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)),NULL, NULL, NULL); } -void hostif_infrastructure_set2_request(ks_wlan_private *priv) +void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) { struct hostif_infrastructure_set2_request_t *pp; uint16_t capability; @@ -1481,7 +1481,7 @@ void hostif_infrastructure_set2_request(ks_wlan_private *priv) } static -void hostif_adhoc_set_request(ks_wlan_private *priv) +void hostif_adhoc_set_request(struct ks_wlan_private *priv) { struct hostif_adhoc_set_request_t *pp; uint16_t capability; @@ -1524,7 +1524,7 @@ void hostif_adhoc_set_request(ks_wlan_private *priv) } static -void hostif_adhoc_set2_request(ks_wlan_private *priv) +void hostif_adhoc_set2_request(struct ks_wlan_private *priv) { struct hostif_adhoc_set2_request_t *pp; uint16_t capability; @@ -1570,7 +1570,7 @@ void hostif_adhoc_set2_request(ks_wlan_private *priv) } static -void hostif_stop_request( ks_wlan_private *priv ) +void hostif_stop_request( struct ks_wlan_private *priv ) { struct hostif_stop_request_t *pp; @@ -1591,7 +1591,7 @@ void hostif_stop_request( ks_wlan_private *priv ) } static -void hostif_phy_information_request( ks_wlan_private *priv ) +void hostif_phy_information_request( struct ks_wlan_private *priv ) { struct hostif_phy_information_request_t *pp; @@ -1619,7 +1619,7 @@ void hostif_phy_information_request( ks_wlan_private *priv ) } static -void hostif_power_mngmt_request( ks_wlan_private *priv, unsigned long mode, +void hostif_power_mngmt_request( struct ks_wlan_private *priv, unsigned long mode, unsigned long wake_up, unsigned long receiveDTIMs ) { struct hostif_power_mngmt_request_t *pp; @@ -1643,7 +1643,7 @@ void hostif_power_mngmt_request( ks_wlan_private *priv, unsigned long mode, } static -void hostif_sleep_request( ks_wlan_private *priv, unsigned long mode) +void hostif_sleep_request( struct ks_wlan_private *priv, unsigned long mode) { struct hostif_sleep_request_t *pp; @@ -1673,7 +1673,7 @@ void hostif_sleep_request( ks_wlan_private *priv, unsigned long mode) static -void hostif_bss_scan_request( ks_wlan_private *priv, unsigned long scan_type , uint8_t *scan_ssid, uint8_t scan_ssid_len) +void hostif_bss_scan_request( struct ks_wlan_private *priv, unsigned long scan_type , uint8_t *scan_ssid, uint8_t scan_ssid_len) { struct hostif_bss_scan_request_t *pp; @@ -1727,7 +1727,7 @@ void hostif_bss_scan_request( ks_wlan_private *priv, unsigned long scan_type , u } static -void hostif_mic_failure_request( ks_wlan_private *priv, unsigned short failure_count, +void hostif_mic_failure_request( struct ks_wlan_private *priv, unsigned short failure_count, unsigned short timer ) { struct hostif_mic_failure_request_t *pp; @@ -1750,7 +1750,7 @@ void hostif_mic_failure_request( ks_wlan_private *priv, unsigned short failure_c } /* Device I/O Recieve indicate */ -static void devio_rec_ind(ks_wlan_private *priv, unsigned char *p, unsigned int size) +static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p, unsigned int size) { if (priv->device_open_status) { spin_lock(&priv->dev_read_lock); /* request spin lock */ @@ -1772,7 +1772,7 @@ static void devio_rec_ind(ks_wlan_private *priv, unsigned char *p, unsigned int } } -void hostif_receive( ks_wlan_private *priv, unsigned char *p, unsigned int size ) +void hostif_receive( struct ks_wlan_private *priv, unsigned char *p, unsigned int size ) { DPRINTK(4,"\n"); @@ -1788,7 +1788,7 @@ void hostif_receive( ks_wlan_private *priv, unsigned char *p, unsigned int size static -void hostif_sme_set_wep(ks_wlan_private *priv, int type) +void hostif_sme_set_wep(struct ks_wlan_private *priv, int type) { uint32_t val; switch(type){ @@ -1844,7 +1844,7 @@ struct rsn_mode_t { } __attribute__((packed)); static -void hostif_sme_set_rsn(ks_wlan_private *priv, int type) +void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type) { struct wpa_suite_t wpa_suite; struct rsn_mode_t rsn_mode; @@ -1991,7 +1991,7 @@ void hostif_sme_set_rsn(ks_wlan_private *priv, int type) } static -void hostif_sme_mode_setup(ks_wlan_private *priv) +void hostif_sme_mode_setup(struct ks_wlan_private *priv) { unsigned char rate_size; unsigned char rate_octet[RATE_SET_MAX_SIZE]; @@ -2097,7 +2097,7 @@ void hostif_sme_mode_setup(ks_wlan_private *priv) } static -void hostif_sme_multicast_set(ks_wlan_private *priv) +void hostif_sme_multicast_set(struct ks_wlan_private *priv) { struct net_device *dev = priv->net_dev; @@ -2146,7 +2146,7 @@ void hostif_sme_multicast_set(ks_wlan_private *priv) } static -void hostif_sme_powermgt_set(ks_wlan_private *priv) +void hostif_sme_powermgt_set(struct ks_wlan_private *priv) { unsigned long mode,wake_up,receiveDTIMs ; @@ -2191,7 +2191,7 @@ void hostif_sme_powermgt_set(ks_wlan_private *priv) } static -void hostif_sme_sleep_set(ks_wlan_private *priv) +void hostif_sme_sleep_set(struct ks_wlan_private *priv) { DPRINTK(3,"\n"); switch(priv->sleep_mode){ @@ -2209,7 +2209,7 @@ void hostif_sme_sleep_set(ks_wlan_private *priv) } static -void hostif_sme_set_key(ks_wlan_private *priv, int type) +void hostif_sme_set_key(struct ks_wlan_private *priv, int type) { uint32_t val; switch(type){ @@ -2265,7 +2265,7 @@ void hostif_sme_set_key(ks_wlan_private *priv, int type) } static -void hostif_sme_set_pmksa(ks_wlan_private *priv) +void hostif_sme_set_pmksa(struct ks_wlan_private *priv) { struct pmk_cache_t { uint16_t size; @@ -2296,7 +2296,7 @@ void hostif_sme_set_pmksa(ks_wlan_private *priv) /* execute sme */ static -void hostif_sme_execute(ks_wlan_private *priv, int event) +void hostif_sme_execute(struct ks_wlan_private *priv, int event) { uint32_t val; @@ -2459,7 +2459,7 @@ void hostif_sme_execute(ks_wlan_private *priv, int event) static void hostif_sme_task( unsigned long dev ) { - ks_wlan_private *priv = (ks_wlan_private *)dev; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; DPRINTK(3,"\n"); @@ -2475,7 +2475,7 @@ void hostif_sme_task( unsigned long dev ) } /* send to Station Management Entity module */ -void hostif_sme_enqueue(ks_wlan_private *priv, unsigned short event) +void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event) { DPRINTK(3,"\n"); @@ -2500,7 +2500,7 @@ void hostif_sme_enqueue(ks_wlan_private *priv, unsigned short event) } -int hostif_init( ks_wlan_private *priv ) +int hostif_init( struct ks_wlan_private *priv ) { int rc=0; int i; @@ -2555,7 +2555,7 @@ int hostif_init( ks_wlan_private *priv ) return rc; } -void hostif_exit( ks_wlan_private *priv ) +void hostif_exit( struct ks_wlan_private *priv ) { tasklet_kill(&priv->sme_task); return; diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h index 24ebf1d..c333ce1 100644 --- a/drivers/staging/ks7010/ks_hostif.h +++ b/drivers/staging/ks7010/ks_hostif.h @@ -623,11 +623,11 @@ enum { #include "ks_wlan.h" /* function prototype */ -extern int hostif_data_request( ks_wlan_private *priv, struct sk_buff *packet ); -extern void hostif_receive( ks_wlan_private *priv, unsigned char *p, unsigned int size ); -extern void hostif_sme_enqueue(ks_wlan_private *priv, uint16_t event); -extern int hostif_init( ks_wlan_private *priv ); -extern void hostif_exit( ks_wlan_private *priv ); +extern int hostif_data_request( struct ks_wlan_private *priv, struct sk_buff *packet ); +extern void hostif_receive( struct ks_wlan_private *priv, unsigned char *p, unsigned int size ); +extern void hostif_sme_enqueue(struct ks_wlan_private *priv, uint16_t event); +extern int hostif_init( struct ks_wlan_private *priv ); +extern void hostif_exit( struct ks_wlan_private *priv ); static inline int hif_align_size(int size) diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index c460741..58e3a5a 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -414,7 +414,7 @@ struct wps_status_t { }; #endif /* WPS */ -typedef struct ks_wlan_private{ +struct ks_wlan_private { struct hw_info_t ks_wlan_hw; /* hardware information */ @@ -505,7 +505,7 @@ typedef struct ks_wlan_private{ uint sdio_error_count; /* SDIO error */ uint wakeup_count; /* for detect wakeup loop */ -} ks_wlan_private; +}; diff --git a/drivers/staging/ks7010/ks_wlan_ioctl.h b/drivers/staging/ks7010/ks_wlan_ioctl.h index e27f8fb..e7469f7 100644 --- a/drivers/staging/ks7010/ks_wlan_ioctl.h +++ b/drivers/staging/ks7010/ks_wlan_ioctl.h @@ -61,8 +61,8 @@ #include "ks_wlan.h" #include -extern int ks_wlan_read_config_file(ks_wlan_private *priv); -extern int ks_wlan_setup_parameter(ks_wlan_private *priv, unsigned int commit_flag); +extern int ks_wlan_read_config_file(struct ks_wlan_private *priv); +extern int ks_wlan_setup_parameter(struct ks_wlan_private *priv, unsigned int commit_flag); #endif /* __KERNEL__ */ diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 1da2768..ec5c452 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -73,7 +73,7 @@ static const struct iw_handler_def ks_wlan_handler_def; /* * function prototypes */ -extern int ks_wlan_hw_tx(ks_wlan_private *priv, void *p, unsigned long size, +extern int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, void (*complete_handler)(void *arg1, void *arg2), void *arg1, void *arg2 ); @@ -89,7 +89,7 @@ static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cm static atomic_t update_phyinfo; static struct timer_list update_phyinfo_timer; static -int ks_wlan_update_phy_information(ks_wlan_private *priv) +int ks_wlan_update_phy_information(struct ks_wlan_private *priv) { struct iw_statistics *wstats = &priv->wstats; @@ -126,7 +126,7 @@ void ks_wlan_update_phyinfo_timeout(unsigned long ptr) atomic_set(&update_phyinfo,0); } -int ks_wlan_setup_parameter(ks_wlan_private *priv, unsigned int commit_flag) +int ks_wlan_setup_parameter(struct ks_wlan_private *priv, unsigned int commit_flag) { DPRINTK(2,"\n"); @@ -183,7 +183,7 @@ int ks_wlan_setup_parameter(ks_wlan_private *priv, unsigned int commit_flag) static int ks_wlan_get_name(struct net_device *dev, struct iw_request_info *info, char *cwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *) netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *) netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -208,7 +208,7 @@ static int ks_wlan_get_name(struct net_device *dev, struct iw_request_info *info static int ks_wlan_set_freq(struct net_device *dev, struct iw_request_info *info, struct iw_freq *fwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); int rc = -EINPROGRESS; /* Call commit handler */ if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -250,7 +250,7 @@ static int ks_wlan_set_freq(struct net_device *dev, struct iw_request_info *info static int ks_wlan_get_freq(struct net_device *dev, struct iw_request_info *info, struct iw_freq *fwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); int f; if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -271,7 +271,7 @@ static int ks_wlan_get_freq(struct net_device *dev, struct iw_request_info *info static int ks_wlan_set_essid(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); size_t len; DPRINTK(2," %d\n", dwrq->flags); @@ -326,7 +326,7 @@ static int ks_wlan_set_essid(struct net_device *dev, struct iw_request_info *inf static int ks_wlan_get_essid(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -366,7 +366,7 @@ static int ks_wlan_get_essid(struct net_device *dev, struct iw_request_info *inf static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info, struct sockaddr *ap_addr, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); DPRINTK(2,"\n"); @@ -402,7 +402,7 @@ static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info, static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info, struct sockaddr *awrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -423,7 +423,7 @@ static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info, static int ks_wlan_set_nick(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -442,7 +442,7 @@ static int ks_wlan_set_nick(struct net_device *dev, struct iw_request_info *info static int ks_wlan_get_nick(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -458,7 +458,7 @@ static int ks_wlan_get_nick(struct net_device *dev, struct iw_request_info *info static int ks_wlan_set_rate(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); int i = 0; if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -609,7 +609,7 @@ static int ks_wlan_set_rate(struct net_device *dev, struct iw_request_info *info static int ks_wlan_get_rate(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); DPRINTK(2, "in_interrupt = %ld update_phyinfo = %d\n", in_interrupt(),atomic_read(&update_phyinfo)); @@ -633,7 +633,7 @@ static int ks_wlan_get_rate(struct net_device *dev, struct iw_request_info *info static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); int rthr = vwrq->value; if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -654,7 +654,7 @@ static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info, static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -670,7 +670,7 @@ static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info, static int ks_wlan_set_frag(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); int fthr = vwrq->value; if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -692,7 +692,7 @@ static int ks_wlan_set_frag(struct net_device *dev, struct iw_request_info *info static int ks_wlan_get_frag(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -708,7 +708,7 @@ static int ks_wlan_get_frag(struct net_device *dev, struct iw_request_info *info static int ks_wlan_set_mode(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); DPRINTK(2,"mode=%d\n",*uwrq); @@ -740,7 +740,7 @@ static int ks_wlan_set_mode(struct net_device *dev, struct iw_request_info *info static int ks_wlan_get_mode(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -764,7 +764,7 @@ static int ks_wlan_get_mode(struct net_device *dev, struct iw_request_info *info static int ks_wlan_set_encode(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); wep_key_t key; int index = (dwrq->flags & IW_ENCODE_INDEX); @@ -878,7 +878,7 @@ static int ks_wlan_set_encode(struct net_device *dev, struct iw_request_info *in static int ks_wlan_get_encode(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); char zeros[16]; int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; @@ -974,7 +974,7 @@ static int ks_wlan_get_retry(struct net_device *dev, struct iw_request_info *inf static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); struct iw_range *range = (struct iw_range *) extra; int i,k; @@ -1105,7 +1105,7 @@ static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *inf static int ks_wlan_set_power(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); short enabled; if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -1136,7 +1136,7 @@ static int ks_wlan_set_power(struct net_device *dev, struct iw_request_info *inf static int ks_wlan_get_power(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -1153,7 +1153,7 @@ static int ks_wlan_get_power(struct net_device *dev, struct iw_request_info *inf static int ks_wlan_get_iwstats(struct net_device *dev, struct iw_request_info *info, struct iw_quality *vwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -1194,7 +1194,7 @@ static int ks_wlan_get_sens(struct net_device *dev, struct iw_request_info *info static int ks_wlan_get_aplist(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); struct sockaddr *address = (struct sockaddr *) extra; struct iw_quality qual[LOCAL_APLIST_MAX]; @@ -1225,7 +1225,7 @@ static int ks_wlan_get_aplist(struct net_device *dev, struct iw_request_info *in static int ks_wlan_set_scan(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); struct iw_scan_req *req = NULL; DPRINTK(2,"\n"); @@ -1257,7 +1257,7 @@ static int ks_wlan_set_scan(struct net_device *dev, struct iw_request_info *info static inline char *ks_wlan_translate_scan(struct net_device *dev, struct iw_request_info *info, char *current_ev, char *end_buf, struct local_ap_t *ap) { - /* ks_wlan_private *priv = (ks_wlan_private *)dev->priv; */ + /* struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; */ struct iw_event iwe; /* Temporary buffer */ u16 capabilities; char *current_val; /* For rates */ @@ -1393,7 +1393,7 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev, struct iw_req static int ks_wlan_get_scan(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); int i; char *current_ev = extra; DPRINTK(2,"\n"); @@ -1448,7 +1448,7 @@ DPRINTK(2,"aplist 0\n"); static int ks_wlan_config_commit(struct net_device *dev, struct iw_request_info *info, void *zwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (!priv->need_commit) return 0; @@ -1463,7 +1463,7 @@ static int ks_wlan_config_commit(struct net_device *dev, struct iw_request_info static int ks_wlan_set_genie(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); DPRINTK(2, "\n"); @@ -1478,7 +1478,7 @@ static int ks_wlan_set_genie(struct net_device *dev, struct iw_request_info *inf static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); int index = (vwrq->flags & IW_AUTH_INDEX); int value = vwrq->value; @@ -1614,7 +1614,7 @@ static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info static int ks_wlan_get_auth_mode(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); int index = (vwrq->flags & IW_AUTH_INDEX); DPRINTK(2,"index=%d\n",index); @@ -1655,7 +1655,7 @@ static int ks_wlan_get_auth_mode(struct net_device *dev, struct iw_request_info static int ks_wlan_set_encode_ext(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); struct iw_encode_ext *enc; int index = dwrq->flags & IW_ENCODE_INDEX; unsigned int commit=0; @@ -1761,12 +1761,12 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, struct iw_request_info static int ks_wlan_get_encode_ext(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ /* WPA (not used ?? wpa_supplicant) - ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; struct iw_encode_ext *enc; enc = (struct iw_encode_ext *)extra; int index = dwrq->flags & IW_ENCODE_INDEX; @@ -1779,7 +1779,7 @@ static int ks_wlan_get_encode_ext(struct net_device *dev, struct iw_request_info static int ks_wlan_set_pmksa(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); struct iw_pmksa *pmksa ; int i; struct pmk_t *pmk; @@ -1874,7 +1874,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev, struct iw_request_info *inf static struct iw_statistics *ks_get_wireless_stats(struct net_device *dev) { - ks_wlan_private *priv = (ks_wlan_private *) netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *) netdev_priv(dev); struct iw_statistics *wstats = &priv->wstats; if(!atomic_read(&update_phyinfo)){ @@ -1901,7 +1901,7 @@ static struct iw_statistics *ks_get_wireless_stats(struct net_device *dev) static int ks_wlan_set_stop_request(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); DPRINTK(2,"\n"); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -1919,7 +1919,7 @@ static int ks_wlan_set_stop_request(struct net_device *dev, struct iw_request_in static int ks_wlan_set_mlme(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); struct iw_mlme *mlme = (struct iw_mlme *)extra; __u32 mode; @@ -1955,7 +1955,7 @@ static int ks_wlan_get_driver_version(struct net_device *dev, struct iw_request_ static int ks_wlan_get_firmware_version(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); strcpy(extra, &(priv->firmware_version[0])); dwrq->length = priv->version_size+1; return 0; @@ -1967,7 +1967,7 @@ static int ks_wlan_get_firmware_version(struct net_device *dev, struct iw_reques static int ks_wlan_set_detach(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -1988,7 +1988,7 @@ static int ks_wlan_set_detach(struct net_device *dev, struct iw_request_info *in static int ks_wlan_get_detach(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2001,7 +2001,7 @@ static int ks_wlan_get_detach(struct net_device *dev, struct iw_request_info *in static int ks_wlan_get_connect(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2015,7 +2015,7 @@ static int ks_wlan_get_connect(struct net_device *dev, struct iw_request_info *i static int ks_wlan_set_preamble(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2036,7 +2036,7 @@ static int ks_wlan_set_preamble(struct net_device *dev, struct iw_request_info * static int ks_wlan_get_preamble(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2049,7 +2049,7 @@ static int ks_wlan_get_preamble(struct net_device *dev, struct iw_request_info * static int ks_wlan_set_powermgt(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2078,7 +2078,7 @@ static int ks_wlan_set_powermgt(struct net_device *dev, struct iw_request_info * static int ks_wlan_get_powermgt(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2091,7 +2091,7 @@ static int ks_wlan_get_powermgt(struct net_device *dev, struct iw_request_info * static int ks_wlan_set_scan_type(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2110,7 +2110,7 @@ static int ks_wlan_set_scan_type(struct net_device *dev, struct iw_request_info static int ks_wlan_get_scan_type(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2123,7 +2123,7 @@ static int ks_wlan_get_scan_type(struct net_device *dev, struct iw_request_info static int ks_wlan_data_write(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; unsigned char *wbuff = NULL; if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2144,7 +2144,7 @@ static int ks_wlan_data_write(struct net_device *dev, struct iw_request_info *in static int ks_wlan_data_read(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; unsigned short read_length; if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2200,7 +2200,7 @@ static int ks_wlan_data_read(struct net_device *dev, struct iw_request_info *inf static int ks_wlan_get_wep_ascii(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; int i,j,len=0; char tmp[WEP_ASCII_BUFF_SIZE]; @@ -2242,7 +2242,7 @@ static int ks_wlan_get_wep_ascii(struct net_device *dev, struct iw_request_info static int ks_wlan_set_beacon_lost(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2265,7 +2265,7 @@ static int ks_wlan_set_beacon_lost(struct net_device *dev, struct iw_request_inf static int ks_wlan_get_beacon_lost(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2278,7 +2278,7 @@ static int ks_wlan_get_beacon_lost(struct net_device *dev, struct iw_request_inf static int ks_wlan_set_phy_type(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2300,7 +2300,7 @@ static int ks_wlan_set_phy_type(struct net_device *dev, struct iw_request_info * static int ks_wlan_get_phy_type(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2313,7 +2313,7 @@ static int ks_wlan_get_phy_type(struct net_device *dev, struct iw_request_info * static int ks_wlan_set_cts_mode(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2337,7 +2337,7 @@ static int ks_wlan_set_cts_mode(struct net_device *dev, struct iw_request_info * static int ks_wlan_get_cts_mode(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2351,7 +2351,7 @@ static int ks_wlan_set_sleep_mode(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); DPRINTK(2,"\n"); @@ -2379,7 +2379,7 @@ static int ks_wlan_get_sleep_mode(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); DPRINTK(2, "GET_SLEEP_MODE %d\n", priv->sleep_mode); *uwrq = priv->sleep_mode; @@ -2393,7 +2393,7 @@ static int ks_wlan_get_sleep_mode(struct net_device *dev, static int ks_wlan_set_phy_information_timer(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2412,7 +2412,7 @@ static int ks_wlan_set_phy_information_timer(struct net_device *dev, struct iw_r static int ks_wlan_get_phy_information_timer(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2427,7 +2427,7 @@ static int ks_wlan_get_phy_information_timer(struct net_device *dev, struct iw_r static int ks_wlan_set_wps_enable(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); DPRINTK(2,"\n"); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2446,7 +2446,7 @@ static int ks_wlan_set_wps_enable(struct net_device *dev, struct iw_request_info static int ks_wlan_get_wps_enable(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); DPRINTK(2,"\n"); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2464,7 +2464,7 @@ static int ks_wlan_set_wps_probe_req(struct net_device *dev, { uint8_t *p = extra; unsigned char len; - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); DPRINTK(2,"\n"); @@ -2498,7 +2498,7 @@ static int ks_wlan_get_wps_probe_req(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; DPRINTK(2,"\n"); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2513,7 +2513,7 @@ static int ks_wlan_get_wps_probe_req(struct net_device *dev, static int ks_wlan_set_tx_gain(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2537,7 +2537,7 @@ static int ks_wlan_set_tx_gain(struct net_device *dev, struct iw_request_info *i static int ks_wlan_get_tx_gain(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2551,7 +2551,7 @@ static int ks_wlan_get_tx_gain(struct net_device *dev, struct iw_request_info *i static int ks_wlan_set_rx_gain(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2574,7 +2574,7 @@ static int ks_wlan_set_rx_gain(struct net_device *dev, struct iw_request_info *i static int ks_wlan_get_rx_gain(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2588,7 +2588,7 @@ static int ks_wlan_get_rx_gain(struct net_device *dev, struct iw_request_info *i static int ks_wlan_set_region(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)dev->priv; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ @@ -2607,7 +2607,7 @@ static int ks_wlan_set_region(struct net_device *dev, struct iw_request_info *in static int ks_wlan_get_eeprom_cksum(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); *uwrq = priv->eeprom_checksum; return 0; @@ -2732,7 +2732,7 @@ static int ks_wlan_hostt(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) { int i,event; - ks_wlan_private *priv = (ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); for(i = 63; i >= 0; i--){ event = priv->hostt.buff[(priv->hostt.qtail -1 -i)%SME_EVENT_BUFF_SIZE] ; @@ -2924,7 +2924,7 @@ static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cm static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev) { - ks_wlan_private *priv = netdev_priv(dev); + struct ks_wlan_private *priv = netdev_priv(dev); if (priv->dev_state < DEVICE_STATE_READY) { return NULL; /* not finished initialize */ @@ -2936,7 +2936,7 @@ struct net_device_stats *ks_wlan_get_stats(struct net_device *dev) static int ks_wlan_set_mac_address(struct net_device *dev, void *addr) { - ks_wlan_private *priv = netdev_priv(dev); + struct ks_wlan_private *priv = netdev_priv(dev); struct sockaddr *mac_addr=(struct sockaddr *)addr; if (netif_running(dev)) return -EBUSY; @@ -2955,7 +2955,7 @@ int ks_wlan_set_mac_address(struct net_device *dev, void *addr) static void ks_wlan_tx_timeout(struct net_device *dev) { - ks_wlan_private *priv = netdev_priv(dev); + struct ks_wlan_private *priv = netdev_priv(dev); DPRINTK(1,"head(%d) tail(%d)!!\n",priv->tx_dev.qhead, priv->tx_dev.qtail); if(!netif_queue_stopped(dev)){ @@ -2970,7 +2970,7 @@ void ks_wlan_tx_timeout(struct net_device *dev) static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev) { - ks_wlan_private *priv = netdev_priv(dev); + struct ks_wlan_private *priv = netdev_priv(dev); int rc = 0; DPRINTK(3,"in_interrupt()=%ld\n",in_interrupt()); @@ -3000,7 +3000,7 @@ int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev) void send_packet_complete(void *arg1, void *arg2) { - ks_wlan_private *priv = (ks_wlan_private *)arg1; + struct ks_wlan_private *priv = (struct ks_wlan_private *)arg1; struct sk_buff *packet = (struct sk_buff *)arg2; DPRINTK(3,"\n"); @@ -3023,7 +3023,7 @@ void send_packet_complete(void *arg1, void *arg2) static void ks_wlan_set_multicast_list(struct net_device *dev) { - ks_wlan_private *priv = netdev_priv(dev); + struct ks_wlan_private *priv = netdev_priv(dev); DPRINTK(4,"\n"); if (priv->dev_state < DEVICE_STATE_READY) { @@ -3037,7 +3037,7 @@ void ks_wlan_set_multicast_list(struct net_device *dev) static int ks_wlan_open(struct net_device *dev) { - ks_wlan_private *priv = netdev_priv(dev); + struct ks_wlan_private *priv = netdev_priv(dev); priv->cur_rx = 0; @@ -3082,7 +3082,7 @@ static const struct net_device_ops ks_wlan_netdev_ops = { int ks_wlan_net_start(struct net_device *dev) { - ks_wlan_private *priv; + struct ks_wlan_private *priv; /* int rc; */ priv = netdev_priv(dev); @@ -3121,7 +3121,7 @@ int ks_wlan_net_start(struct net_device *dev) int ks_wlan_net_stop(struct net_device *dev) { - ks_wlan_private *priv = netdev_priv(dev); + struct ks_wlan_private *priv = netdev_priv(dev); int ret = 0; priv->device_open_status = 0; -- cgit v1.1 From 5d7696bcce37010400412bbff53996b242556923 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:27 +0200 Subject: staging: ks7010: indent eap_packet.h Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/eap_packet.h | 49 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/staging/ks7010/eap_packet.h b/drivers/staging/ks7010/eap_packet.h index b664bdd..88384fb 100644 --- a/drivers/staging/ks7010/eap_packet.h +++ b/drivers/staging/ks7010/eap_packet.h @@ -14,13 +14,13 @@ #endif struct ether_hdr { - unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ - unsigned char h_source[ETH_ALEN]; /* source ether addr */ - unsigned char h_dest_snap; - unsigned char h_source_snap; - unsigned char h_command; - unsigned char h_vendor_id[3]; - unsigned short h_proto; /* packet type ID field */ + unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ + unsigned char h_source[ETH_ALEN]; /* source ether addr */ + unsigned char h_dest_snap; + unsigned char h_source_snap; + unsigned char h_command; + unsigned char h_vendor_id[3]; + unsigned short h_proto; /* packet type ID field */ #define ETHER_PROTOCOL_TYPE_EAP 0x888e #define ETHER_PROTOCOL_TYPE_IP 0x0800 #define ETHER_PROTOCOL_TYPE_ARP 0x0806 @@ -37,15 +37,15 @@ struct ieee802_1x_hdr { #define EAPOL_VERSION 2 enum { IEEE802_1X_TYPE_EAP_PACKET = 0, - IEEE802_1X_TYPE_EAPOL_START = 1, - IEEE802_1X_TYPE_EAPOL_LOGOFF = 2, - IEEE802_1X_TYPE_EAPOL_KEY = 3, - IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4 + IEEE802_1X_TYPE_EAPOL_START = 1, + IEEE802_1X_TYPE_EAPOL_LOGOFF = 2, + IEEE802_1X_TYPE_EAPOL_KEY = 3, + IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT = 4 }; enum { EAPOL_KEY_TYPE_RC4 = 1, EAPOL_KEY_TYPE_RSN = 2, - EAPOL_KEY_TYPE_WPA = 254 }; - + EAPOL_KEY_TYPE_WPA = 254 +}; #define IEEE8021X_REPLAY_COUNTER_LEN 8 #define IEEE8021X_KEY_SIGN_LEN 16 @@ -60,11 +60,11 @@ struct ieee802_1x_eapol_key { /* does not repeat within the life of the keying material used to * encrypt the Key field; 64-bit NTP timestamp MAY be used here */ unsigned char replay_counter[IEEE8021X_REPLAY_COUNTER_LEN]; - unsigned char key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */ - unsigned char key_index; /* key flag in the most significant bit: - * 0 = broadcast (default key), - * 1 = unicast (key mapping key); key index is in the - * 7 least significant bits */ + unsigned char key_iv[IEEE8021X_KEY_IV_LEN]; /* cryptographically random number */ + unsigned char key_index; /* key flag in the most significant bit: + * 0 = broadcast (default key), + * 1 = unicast (key mapping key); key index is in the + * 7 least significant bits */ /* HMAC-MD5 message integrity check computed with MS-MPPE-Send-Key as * the key */ unsigned char key_signature[IEEE8021X_KEY_SIGN_LEN]; @@ -77,19 +77,18 @@ struct ieee802_1x_eapol_key { * RC4 key used in encryption = Key-IV + MS-MPPE-Recv-Key */ } __attribute__ ((packed)); - #define WPA_NONCE_LEN 32 #define WPA_REPLAY_COUNTER_LEN 8 struct wpa_eapol_key { unsigned char type; - unsigned short key_info; + unsigned short key_info; unsigned short key_length; unsigned char replay_counter[WPA_REPLAY_COUNTER_LEN]; unsigned char key_nonce[WPA_NONCE_LEN]; unsigned char key_iv[16]; unsigned char key_rsc[8]; - unsigned char key_id[8]; /* Reserved in IEEE 802.11i/RSN */ + unsigned char key_id[8]; /* Reserved in IEEE 802.11i/RSN */ unsigned char key_mic[16]; unsigned short key_data_length; /* followed by key_data_length bytes of key_data */ @@ -98,18 +97,18 @@ struct wpa_eapol_key { #define WPA_KEY_INFO_TYPE_MASK (WBIT(0) | WBIT(1) | WBIT(2)) #define WPA_KEY_INFO_TYPE_HMAC_MD5_RC4 WBIT(0) #define WPA_KEY_INFO_TYPE_HMAC_SHA1_AES WBIT(1) -#define WPA_KEY_INFO_KEY_TYPE WBIT(3) /* 1 = Pairwise, 0 = Group key */ +#define WPA_KEY_INFO_KEY_TYPE WBIT(3) /* 1 = Pairwise, 0 = Group key */ /* bit4..5 is used in WPA, but is reserved in IEEE 802.11i/RSN */ #define WPA_KEY_INFO_KEY_INDEX_MASK (WBIT(4) | WBIT(5)) #define WPA_KEY_INFO_KEY_INDEX_SHIFT 4 -#define WPA_KEY_INFO_INSTALL WBIT(6) /* pairwise */ -#define WPA_KEY_INFO_TXRX WBIT(6) /* group */ +#define WPA_KEY_INFO_INSTALL WBIT(6) /* pairwise */ +#define WPA_KEY_INFO_TXRX WBIT(6) /* group */ #define WPA_KEY_INFO_ACK WBIT(7) #define WPA_KEY_INFO_MIC WBIT(8) #define WPA_KEY_INFO_SECURE WBIT(9) #define WPA_KEY_INFO_ERROR WBIT(10) #define WPA_KEY_INFO_REQUEST WBIT(11) -#define WPA_KEY_INFO_ENCR_KEY_DATA WBIT(12) /* IEEE 802.11i/RSN only */ +#define WPA_KEY_INFO_ENCR_KEY_DATA WBIT(12) /* IEEE 802.11i/RSN only */ #define WPA_CAPABILITY_PREAUTH WBIT(0) -- cgit v1.1 From 84e18a94b992d3a3bcc81259dda87657fec3bf58 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:28 +0200 Subject: staging: ks7010: indent ks7010_config.c Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_config.c | 353 +++++++++++++++++---------------- 1 file changed, 184 insertions(+), 169 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_config.c b/drivers/staging/ks7010/ks7010_config.c index 48809bc..4b495cb 100644 --- a/drivers/staging/ks7010/ks7010_config.c +++ b/drivers/staging/ks7010/ks7010_config.c @@ -15,7 +15,8 @@ static int wep_type; #define WEP_KEY_HEX 1 static -void analyze_character_wep_key(struct ks_wlan_parameter *param, int wep_key_index, char *value) +void analyze_character_wep_key(struct ks_wlan_parameter *param, + int wep_key_index, char *value) { int i; unsigned char wep_key[26], key_length; @@ -23,64 +24,69 @@ void analyze_character_wep_key(struct ks_wlan_parameter *param, int wep_key_inde key_length = (wep_on_off == WEP_ON_64BIT) ? 5 : 13; /* 64bit key_length = 5; 128bit key_length = 13; */ - for (i=0; i 3) + if (wep_key_index < 0 || wep_key_index > 3) return; param->wep_key[wep_key_index].size = key_length; - for (i=0; i<(param->wep_key[wep_key_index].size); i++) { + for (i = 0; i < (param->wep_key[wep_key_index].size); i++) { param->wep_key[wep_key_index].val[i] = wep_key[i]; } } static -void analyze_hex_wep_key(struct ks_wlan_parameter *param, int wep_key_index, char *value) +void analyze_hex_wep_key(struct ks_wlan_parameter *param, int wep_key_index, + char *value) { unsigned char wep_end[26], i, j, key_length; key_length = (wep_on_off == WEP_ON_64BIT) ? 10 : 26; /* 64bit key_length = 10; 128bit key_length = 26; */ - for (i=0; i 3) - return ; + if (wep_key_index < 0 || wep_key_index > 3) + return; - param->wep_key[wep_key_index].size = key_length/2; - for (i=0; i<(param->wep_key[wep_key_index].size); i++) { + param->wep_key[wep_key_index].size = key_length / 2; + for (i = 0; i < (param->wep_key[wep_key_index].size); i++) { param->wep_key[wep_key_index].val[i] = wep_end[i]; } @@ -89,62 +95,57 @@ void analyze_hex_wep_key(struct ks_wlan_parameter *param, int wep_key_index, cha static int rate_set_configuration(struct ks_wlan_private *priv, char *value) { - int rc=0; + int rc = 0; priv->reg.tx_rate = TX_RATE_FIXED; priv->reg.rate_set.size = 1; - switch(*value){ - case '1': /* 1M 11M 12M 18M */ - if(*(value+1) == '8'){ + switch (*value) { + case '1': /* 1M 11M 12M 18M */ + if (*(value + 1) == '8') { priv->reg.rate_set.body[0] = TX_RATE_18M; - } - else if(*(value+1) == '2'){ - priv->reg.rate_set.body[0] = TX_RATE_12M|BASIC_RATE; - } - else if(*(value+1) == '1'){ - priv->reg.rate_set.body[0] = TX_RATE_11M|BASIC_RATE; - } - else{ - priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + } else if (*(value + 1) == '2') { + priv->reg.rate_set.body[0] = TX_RATE_12M | BASIC_RATE; + } else if (*(value + 1) == '1') { + priv->reg.rate_set.body[0] = TX_RATE_11M | BASIC_RATE; + } else { + priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE; } break; - case '2': /* 2M 24M */ - if(*(value+1) == '4'){ - priv->reg.rate_set.body[0] = TX_RATE_24M|BASIC_RATE; - } - else{ - priv->reg.rate_set.body[0] = TX_RATE_2M|BASIC_RATE; + case '2': /* 2M 24M */ + if (*(value + 1) == '4') { + priv->reg.rate_set.body[0] = TX_RATE_24M | BASIC_RATE; + } else { + priv->reg.rate_set.body[0] = TX_RATE_2M | BASIC_RATE; } break; - case '3': /* 36M */ + case '3': /* 36M */ priv->reg.rate_set.body[0] = TX_RATE_36M; break; - case '4': /* 48M */ + case '4': /* 48M */ priv->reg.rate_set.body[0] = TX_RATE_48M; break; - case '5': /* 5.5M 54M */ - if(*(value+1) == '4'){ + case '5': /* 5.5M 54M */ + if (*(value + 1) == '4') { priv->reg.rate_set.body[0] = TX_RATE_54M; - } - else{ - priv->reg.rate_set.body[0] = TX_RATE_5M|BASIC_RATE; + } else { + priv->reg.rate_set.body[0] = TX_RATE_5M | BASIC_RATE; } break; - case '6': /* 6M */ - priv->reg.rate_set.body[0] = TX_RATE_6M|BASIC_RATE; + case '6': /* 6M */ + priv->reg.rate_set.body[0] = TX_RATE_6M | BASIC_RATE; break; - case '9': /* 9M */ + case '9': /* 9M */ priv->reg.rate_set.body[0] = TX_RATE_9M; break; case 'K': priv->reg.rate_set.body[6] = TX_RATE_36M; priv->reg.rate_set.body[5] = TX_RATE_18M; - priv->reg.rate_set.body[4] = TX_RATE_24M|BASIC_RATE; - priv->reg.rate_set.body[3] = TX_RATE_12M|BASIC_RATE; - priv->reg.rate_set.body[2] = TX_RATE_6M|BASIC_RATE; - priv->reg.rate_set.body[1] = TX_RATE_11M|BASIC_RATE; - priv->reg.rate_set.body[0] = TX_RATE_2M|BASIC_RATE; + priv->reg.rate_set.body[4] = TX_RATE_24M | BASIC_RATE; + priv->reg.rate_set.body[3] = TX_RATE_12M | BASIC_RATE; + priv->reg.rate_set.body[2] = TX_RATE_6M | BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_11M | BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_2M | BASIC_RATE; priv->reg.tx_rate = TX_RATE_FULL_AUTO; priv->reg.rate_set.size = 7; break; @@ -154,13 +155,13 @@ int rate_set_configuration(struct ks_wlan_private *priv, char *value) priv->reg.rate_set.body[9] = TX_RATE_36M; priv->reg.rate_set.body[8] = TX_RATE_18M; priv->reg.rate_set.body[7] = TX_RATE_9M; - priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; - priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; - priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; - priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; - priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; - priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; - priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.rate_set.body[6] = TX_RATE_24M | BASIC_RATE; + priv->reg.rate_set.body[5] = TX_RATE_12M | BASIC_RATE; + priv->reg.rate_set.body[4] = TX_RATE_6M | BASIC_RATE; + priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE; + priv->reg.rate_set.body[2] = TX_RATE_5M | BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE; priv->reg.tx_rate = TX_RATE_FULL_AUTO; priv->reg.rate_set.size = 12; break; @@ -176,63 +177,63 @@ int ks_wlan_read_config_file(struct ks_wlan_private *priv) const char *key; const char *val; } cfg_tbl[] = { - {15,"BeaconLostCount", "20"}, /* 0 */ - {7,"Channel", "1"}, /* 1 */ - {17,"FragmentThreshold","2346"}, /* 2 */ - {13,"OperationMode","Infrastructure"}, /* 3 */ - {19,"PowerManagementMode","ACTIVE"}, /* 4 */ - {12,"RTSThreshold","2347"}, /* 5 */ - {4,"SSID","default"}, /* 6 */ - {6,"TxRate","Auto"}, /* 7 */ - {23,"AuthenticationAlgorithm",""}, /* 8 */ - {12,"WepKeyValue1",""}, /* 9 */ - {12,"WepKeyValue2",""}, /* 10 */ - {12,"WepKeyValue3",""}, /* 11 */ - {12,"WepKeyValue4",""}, /* 12 */ - {8,"WepIndex","1"}, /* 13 */ - {7,"WepType","STRING"}, /* 14 */ - {3,"Wep","OFF"}, /* 15 */ - {13,"PREAMBLE_TYPE","LONG"}, /* 16 */ - {8,"ScanType","ACTIVE_SCAN"}, /* 17 */ - {8,"ROM_FILE", ROM_FILE}, /* 18 */ - {7,"PhyType", "BG_MODE"}, /* 19 */ - {7,"CtsMode", "FALSE"}, /* 20 */ - {19,"PhyInformationTimer", "0"}, /* 21 */ - {0,"",""}, + {15, "BeaconLostCount", "20"}, /* 0 */ + {7, "Channel", "1"}, /* 1 */ + {17, "FragmentThreshold", "2346"}, /* 2 */ + {13, "OperationMode", "Infrastructure"}, /* 3 */ + {19, "PowerManagementMode", "ACTIVE"}, /* 4 */ + {12, "RTSThreshold", "2347"}, /* 5 */ + {4, "SSID", "default"}, /* 6 */ + {6, "TxRate", "Auto"}, /* 7 */ + {23, "AuthenticationAlgorithm", ""}, /* 8 */ + {12, "WepKeyValue1", ""}, /* 9 */ + {12, "WepKeyValue2", ""}, /* 10 */ + {12, "WepKeyValue3", ""}, /* 11 */ + {12, "WepKeyValue4", ""}, /* 12 */ + {8, "WepIndex", "1"}, /* 13 */ + {7, "WepType", "STRING"}, /* 14 */ + {3, "Wep", "OFF"}, /* 15 */ + {13, "PREAMBLE_TYPE", "LONG"}, /* 16 */ + {8, "ScanType", "ACTIVE_SCAN"}, /* 17 */ + {8, "ROM_FILE", ROM_FILE}, /* 18 */ + {7, "PhyType", "BG_MODE"}, /* 19 */ + {7, "CtsMode", "FALSE"}, /* 20 */ + {19, "PhyInformationTimer", "0"}, /* 21 */ + {0, "", ""}, }; const struct firmware *fw_entry; struct device *dev = NULL; - char cfg_file[]=CFG_FILE; + char cfg_file[] = CFG_FILE; char *cur_p, *end_p; char wk_buff[256], *wk_p; /* Initialize Variable */ priv->reg.operation_mode = MODE_INFRASTRUCTURE; /* Infrastructure */ - priv->reg.channel = 10; /* 10 */ - memset(priv->reg.bssid, 0x0, ETH_ALEN); /* BSSID */ - priv->reg.ssid.body[0] = '\0'; /* SSID */ - priv->reg.ssid.size = 0; /* SSID size */ - priv->reg.tx_rate = TX_RATE_AUTO; /* TxRate Fully Auto */ - priv->reg.preamble = LONG_PREAMBLE; /* Preamble = LONG */ - priv->reg.powermgt = POWMGT_ACTIVE_MODE; /* POWMGT_ACTIVE_MODE */ - priv->reg.scan_type = ACTIVE_SCAN; /* Active */ - priv->reg.beacon_lost_count = 20; /* Beacon Lost Count */ - priv->reg.rts = 2347UL; /* RTS Threashold */ - priv->reg.fragment = 2346UL; /* Fragmentation Threashold */ + priv->reg.channel = 10; /* 10 */ + memset(priv->reg.bssid, 0x0, ETH_ALEN); /* BSSID */ + priv->reg.ssid.body[0] = '\0'; /* SSID */ + priv->reg.ssid.size = 0; /* SSID size */ + priv->reg.tx_rate = TX_RATE_AUTO; /* TxRate Fully Auto */ + priv->reg.preamble = LONG_PREAMBLE; /* Preamble = LONG */ + priv->reg.powermgt = POWMGT_ACTIVE_MODE; /* POWMGT_ACTIVE_MODE */ + priv->reg.scan_type = ACTIVE_SCAN; /* Active */ + priv->reg.beacon_lost_count = 20; /* Beacon Lost Count */ + priv->reg.rts = 2347UL; /* RTS Threashold */ + priv->reg.fragment = 2346UL; /* Fragmentation Threashold */ strcpy(&priv->reg.rom_file[0], ROM_FILE); priv->skb = NULL; - priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; /* AuthenticationAlgorithm */ + priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; /* AuthenticationAlgorithm */ - priv->reg.privacy_invoked = 0x00; /* WEP */ - priv->reg.wep_index=0; - memset(&priv->reg.wep_key[0],0,sizeof(priv->reg.wep_key[0])); - memset(&priv->reg.wep_key[1],0,sizeof(priv->reg.wep_key[0])); - memset(&priv->reg.wep_key[2],0,sizeof(priv->reg.wep_key[0])); - memset(&priv->reg.wep_key[3],0,sizeof(priv->reg.wep_key[0])); + priv->reg.privacy_invoked = 0x00; /* WEP */ + priv->reg.wep_index = 0; + memset(&priv->reg.wep_key[0], 0, sizeof(priv->reg.wep_key[0])); + memset(&priv->reg.wep_key[1], 0, sizeof(priv->reg.wep_key[0])); + memset(&priv->reg.wep_key[2], 0, sizeof(priv->reg.wep_key[0])); + memset(&priv->reg.wep_key[3], 0, sizeof(priv->reg.wep_key[0])); priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; priv->reg.cts_mode = CTS_MODE_FALSE; @@ -242,13 +243,13 @@ int ks_wlan_read_config_file(struct ks_wlan_private *priv) priv->reg.rate_set.body[9] = TX_RATE_36M; priv->reg.rate_set.body[8] = TX_RATE_18M; priv->reg.rate_set.body[7] = TX_RATE_9M; - priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; - priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; - priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; - priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; - priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; - priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; - priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.rate_set.body[6] = TX_RATE_24M | BASIC_RATE; + priv->reg.rate_set.body[5] = TX_RATE_12M | BASIC_RATE; + priv->reg.rate_set.body[4] = TX_RATE_6M | BASIC_RATE; + priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE; + priv->reg.rate_set.body[2] = TX_RATE_5M | BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE; priv->reg.tx_rate = TX_RATE_FULL_AUTO; priv->reg.rate_set.size = 12; @@ -257,7 +258,8 @@ int ks_wlan_read_config_file(struct ks_wlan_private *priv) if (request_firmware_direct(&fw_entry, cfg_file, dev)) return 0; - DPRINTK(4, "success request_firmware() file=%s size=%zu\n", cfg_file, fw_entry->size); + DPRINTK(4, "success request_firmware() file=%s size=%zu\n", cfg_file, + fw_entry->size); cur_p = fw_entry->data; end_p = cur_p + fw_entry->size; *end_p = '\0'; @@ -266,7 +268,7 @@ int ks_wlan_read_config_file(struct ks_wlan_private *priv) int i, j, len; len = end_p - cur_p; - for (i=0; cfg_tbl[i].key_len != 0; i++) { + for (i = 0; cfg_tbl[i].key_len != 0; i++) { if (*cur_p == '#') { break; } @@ -298,58 +300,64 @@ int ks_wlan_read_config_file(struct ks_wlan_private *priv) } cur_p++; - for (j=0,wk_p=cur_p; *wk_p != '\n' && wk_p < end_p; j++,wk_p++) { + for (j = 0, wk_p = cur_p; *wk_p != '\n' && wk_p < end_p; + j++, wk_p++) { wk_buff[j] = *wk_p; } wk_buff[j] = '\0'; cur_p = wk_p; - DPRINTK(4,"%s=%s\n",cfg_tbl[i].key, wk_buff); + DPRINTK(4, "%s=%s\n", cfg_tbl[i].key, wk_buff); wk_p = wk_buff; switch (i) { - case 0: /* "BeaconLostCount", "10" */ - priv->reg.beacon_lost_count = simple_strtol(wk_buff, NULL, 10); + case 0: /* "BeaconLostCount", "10" */ + priv->reg.beacon_lost_count = + simple_strtol(wk_buff, NULL, 10); break; - case 1: /* "Channel", "1" */ - priv->reg.channel = simple_strtol(wk_buff, NULL, 10); + case 1: /* "Channel", "1" */ + priv->reg.channel = + simple_strtol(wk_buff, NULL, 10); break; - case 2: /* "FragmentThreshold","2346" */ + case 2: /* "FragmentThreshold","2346" */ j = simple_strtol(wk_buff, NULL, 10); priv->reg.fragment = (unsigned long)j; break; - case 3: /* "OperationMode","Infrastructure" */ + case 3: /* "OperationMode","Infrastructure" */ switch (*wk_buff) { case 'P': - priv->reg.operation_mode = MODE_PSEUDO_ADHOC; + priv->reg.operation_mode = + MODE_PSEUDO_ADHOC; break; case 'I': - priv->reg.operation_mode = MODE_INFRASTRUCTURE; + priv->reg.operation_mode = + MODE_INFRASTRUCTURE; break; case '8': priv->reg.operation_mode = MODE_ADHOC; break; default: - priv->reg.operation_mode = MODE_INFRASTRUCTURE; + priv->reg.operation_mode = + MODE_INFRASTRUCTURE; } break; - case 4: /* "PowerManagementMode","POWER_ACTIVE" */ + case 4: /* "PowerManagementMode","POWER_ACTIVE" */ if (!strncmp(wk_buff, "SAVE1", 5)) { priv->reg.powermgt = POWMGT_SAVE1_MODE; - } else if (!strncmp(wk_buff, "SAVE2", 5)){ + } else if (!strncmp(wk_buff, "SAVE2", 5)) { priv->reg.powermgt = POWMGT_SAVE2_MODE; } else { priv->reg.powermgt = POWMGT_ACTIVE_MODE; } break; - case 5: /* "RTSThreshold","2347" */ + case 5: /* "RTSThreshold","2347" */ j = simple_strtol(wk_buff, NULL, 10); priv->reg.rts = (unsigned long)j; break; - case 6: /* "SSID","" */ + case 6: /* "SSID","" */ if (*wk_p != '"') break; wk_p++; - for (j=0; *wk_p != '"'; j++) { + for (j = 0; *wk_p != '"'; j++) { if (wk_p == '\0') { break; } @@ -359,45 +367,51 @@ int ks_wlan_read_config_file(struct ks_wlan_private *priv) priv->reg.ssid.size = j; wk_p++; break; - case 7: /* "TxRate","Auto" */ + case 7: /* "TxRate","Auto" */ rate_set_configuration(priv, wk_p); break; - case 8: /* "AuthenticationAlgorithm","OPEN_SYSTEM" */ + case 8: /* "AuthenticationAlgorithm","OPEN_SYSTEM" */ switch (*wk_p) { - case 'O': /* Authenticate System : Open System */ - priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; + case 'O': /* Authenticate System : Open System */ + priv->reg.authenticate_type = + AUTH_TYPE_OPEN_SYSTEM; break; - case 'S': /* Authenticate System : Shared Key */ - priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; + case 'S': /* Authenticate System : Shared Key */ + priv->reg.authenticate_type = + AUTH_TYPE_SHARED_KEY; break; } break; - case 9: /* "WepKeyValue1","" */ - case 10: /* "WepKeyValue2","" */ - case 11: /* "WepKeyValue3","" */ - case 12: /* "WepKeyValue4","" */ + case 9: /* "WepKeyValue1","" */ + case 10: /* "WepKeyValue2","" */ + case 11: /* "WepKeyValue3","" */ + case 12: /* "WepKeyValue4","" */ if (wep_on_off != WEP_OFF) { switch (wep_type) { case WEP_KEY_CHARACTER: - analyze_character_wep_key(&priv->reg, (i-9), wk_p); + analyze_character_wep_key + (&priv->reg, (i - 9), wk_p); break; case WEP_KEY_HEX: - analyze_hex_wep_key(&priv->reg, (i-9), wk_p); + analyze_hex_wep_key(&priv->reg, + (i - 9), + wk_p); break; } } break; - case 13: /* "WepIndex","1"->0 (So, Zero Origin) */ - priv->reg.wep_index = simple_strtol(wk_buff, NULL, 10) - 1; + case 13: /* "WepIndex","1"->0 (So, Zero Origin) */ + priv->reg.wep_index = + simple_strtol(wk_buff, NULL, 10) - 1; break; - case 14: /* "WepType","STRING" */ + case 14: /* "WepType","STRING" */ if (!strncmp(wk_buff, "STRING", 6)) { wep_type = WEP_KEY_CHARACTER; } else { wep_type = WEP_KEY_HEX; } break; - case 15: /* "Wep","OFF" */ + case 15: /* "Wep","OFF" */ if (!strncmp(wk_buff, "OFF", 3)) { priv->reg.privacy_invoked = 0x00; wep_on_off = WEP_OFF; @@ -405,30 +419,30 @@ int ks_wlan_read_config_file(struct ks_wlan_private *priv) priv->reg.privacy_invoked = 0x01; if (*wk_buff == '6') { /* 64bit */ wep_on_off = WEP_ON_64BIT; - } else { /* 128bit */ + } else { /* 128bit */ wep_on_off = WEP_ON_128BIT; } } break; - case 16: /* "PREAMBLE_TYPE","LONG" */ + case 16: /* "PREAMBLE_TYPE","LONG" */ if (!strncmp(wk_buff, "SHORT", 5)) { priv->reg.preamble = SHORT_PREAMBLE; - } else { /* "LONG" */ + } else { /* "LONG" */ priv->reg.preamble = LONG_PREAMBLE; } break; - case 17: /* "ScanType","ACTIVE_SCAN" */ + case 17: /* "ScanType","ACTIVE_SCAN" */ if (!strncmp(wk_buff, "PASSIVE_SCAN", 12)) { priv->reg.scan_type = PASSIVE_SCAN; - } else { /* "ACTIVE_SCAN" */ + } else { /* "ACTIVE_SCAN" */ priv->reg.scan_type = ACTIVE_SCAN; } break; - case 18: // "ROM_FILE",ROMFILE + case 18: // "ROM_FILE",ROMFILE if (*wk_p != '"') break; wk_p++; - for (j=0; *wk_p != '"'; j++) { + for (j = 0; *wk_p != '"'; j++) { if (wk_p == '\0') { break; } @@ -437,25 +451,26 @@ int ks_wlan_read_config_file(struct ks_wlan_private *priv) priv->reg.rom_file[j] = '\0'; wk_p++; break; - case 19: /*"PhyType", "BG_MODE" */ + case 19: /*"PhyType", "BG_MODE" */ if (!strncmp(wk_buff, "B_MODE", 6)) { priv->reg.phy_type = D_11B_ONLY_MODE; } else if (!strncmp(wk_buff, "G_MODE", 6)) { priv->reg.phy_type = D_11G_ONLY_MODE; } else { - priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; + priv->reg.phy_type = + D_11BG_COMPATIBLE_MODE; } break; - case 20: /* "CtsMode", "FALSE" */ + case 20: /* "CtsMode", "FALSE" */ if (!strncmp(wk_buff, "TRUE", 4)) { priv->reg.cts_mode = CTS_MODE_TRUE; } else { priv->reg.cts_mode = CTS_MODE_FALSE; } break; - case 21: /* "PhyInformationTimer", "0" */ + case 21: /* "PhyInformationTimer", "0" */ j = simple_strtol(wk_buff, NULL, 10); - priv->reg.phy_info_timer = (uint16_t)j; + priv->reg.phy_info_timer = (uint16_t) j; break; default: break; @@ -469,17 +484,17 @@ int ks_wlan_read_config_file(struct ks_wlan_private *priv) } release_firmware(fw_entry); - DPRINTK(3,"\n operation_mode = %d\n channel = %d\n ssid = %s\n tx_rate = %d\n \ + DPRINTK(3, + "\n operation_mode = %d\n channel = %d\n ssid = %s\n tx_rate = %d\n \ preamble = %d\n powermgt = %d\n scan_type = %d\n beacon_lost_count = %d\n rts = %d\n \ fragment = %d\n privacy_invoked = %d\n wep_type = %d\n wep_on_off = %d\n wep_index = %d\n romfile = %s\n", - priv->reg.operation_mode,priv->reg.channel,&priv->reg.ssid.body[0],priv->reg.tx_rate, - priv->reg.preamble,priv->reg.powermgt,priv->reg.scan_type,priv->reg.beacon_lost_count, - priv->reg.rts,priv->reg.fragment,priv->reg.privacy_invoked,wep_type,wep_on_off,priv->reg.wep_index, - &priv->reg.rom_file[0] - ); - DPRINTK(3,"\n phy_type = %d\n cts_mode = %d\n tx_rate = %d\n phy_info_timer = %d\n", - priv->reg.phy_type,priv->reg.cts_mode,priv->reg.tx_rate,priv->reg.phy_info_timer ); - - return(0); + priv->reg.operation_mode, priv->reg.channel, &priv->reg.ssid.body[0], priv->reg.tx_rate, priv->reg.preamble, priv->reg.powermgt, priv->reg.scan_type, priv->reg.beacon_lost_count, priv->reg.rts, priv->reg.fragment, priv->reg.privacy_invoked, wep_type, wep_on_off, + priv->reg.wep_index, &priv->reg.rom_file[0] + ); + DPRINTK(3, + "\n phy_type = %d\n cts_mode = %d\n tx_rate = %d\n phy_info_timer = %d\n", + priv->reg.phy_type, priv->reg.cts_mode, priv->reg.tx_rate, + priv->reg.phy_info_timer); + + return (0); } - -- cgit v1.1 From 4a3e75483dfadd5164f482bc1af9c4a7e3ee67b0 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:29 +0200 Subject: staging: ks7010: indent ks7010_sdio.h Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.h | 64 +++++++++++++++++------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h index 1d16673..aea3727 100644 --- a/drivers/staging/ks7010/ks7010_sdio.h +++ b/drivers/staging/ks7010/ks7010_sdio.h @@ -21,7 +21,7 @@ #define DEVICE_ALIGNMENT 32 /* SDIO KeyStream vendor and device */ -#define SDIO_VENDOR_ID_KS_CODE_A 0x005b +#define SDIO_VENDOR_ID_KS_CODE_A 0x005b #define SDIO_VENDOR_ID_KS_CODE_B 0x0023 #define SDIO_DEVICE_ID_KS_7010 0x7910 @@ -48,8 +48,8 @@ * for network packet (less than 2048 bytes data) */ #define WSTATUS_RSIZE 0x000014 -#define WSTATUS_MASK 0x80 /* Write Status Register value */ -#define RSIZE_MASK 0x7F /* Read Data Size Register value [10:4] */ +#define WSTATUS_MASK 0x80 /* Write Status Register value */ +#define RSIZE_MASK 0x7F /* Read Data Size Register value [10:4] */ /* ARM to SD interrupt Enable */ #define INT_ENABLE 0x000020 @@ -88,52 +88,48 @@ #define KS7010_IRAM_ADDRESS 0x06000000 - /* * struct define */ struct hw_info_t { - struct ks_sdio_card *sdio_card; + struct ks_sdio_card *sdio_card; struct completion ks7010_sdio_wait; struct workqueue_struct *ks7010sdio_wq; struct delayed_work rw_wq; - unsigned char *read_buf; + unsigned char *read_buf; struct tasklet_struct rx_bh_task; }; struct ks_sdio_packet { - struct ks_sdio_packet *next; - u16 nb; - u8 buffer[0] __attribute__((aligned(4))); + struct ks_sdio_packet *next; + u16 nb; + u8 buffer[0] __attribute__ ((aligned(4))); }; - struct ks_sdio_card { - struct sdio_func *func; + struct sdio_func *func; struct ks_wlan_private *priv; - int model; - const char *firmware; - spinlock_t lock; + int model; + const char *firmware; + spinlock_t lock; }; - - /* Tx Device struct */ -#define TX_DEVICE_BUFF_SIZE 1024 +#define TX_DEVICE_BUFF_SIZE 1024 struct tx_device_buffer { - unsigned char *sendp; /* pointer of send req data */ - unsigned int size; - void (*complete_handler)(void *arg1, void *arg2); - void *arg1; - void *arg2; + unsigned char *sendp; /* pointer of send req data */ + unsigned int size; + void (*complete_handler) (void *arg1, void *arg2); + void *arg1; + void *arg2; }; -struct tx_device{ - struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE]; - unsigned int qhead; /* tx buffer queue first pointer */ - unsigned int qtail; /* tx buffer queue last pointer */ - spinlock_t tx_dev_lock; +struct tx_device { + struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE]; + unsigned int qhead; /* tx buffer queue first pointer */ + unsigned int qtail; /* tx buffer queue last pointer */ + spinlock_t tx_dev_lock; }; /* Rx Device struct */ @@ -141,15 +137,15 @@ struct tx_device{ #define RX_DEVICE_BUFF_SIZE 32 struct rx_device_buffer { - unsigned char data[RX_DATA_SIZE]; - unsigned int size; + unsigned char data[RX_DATA_SIZE]; + unsigned int size; }; -struct rx_device{ - struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE]; - unsigned int qhead; /* rx buffer queue first pointer */ - unsigned int qtail; /* rx buffer queue last pointer */ - spinlock_t rx_dev_lock; +struct rx_device { + struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE]; + unsigned int qhead; /* rx buffer queue first pointer */ + unsigned int qtail; /* rx buffer queue last pointer */ + spinlock_t rx_dev_lock; }; #define ROM_FILE "ks7010sd.rom" #define CFG_FILE "ks79xx.cfg" -- cgit v1.1 From 20c4f9c52e619a12e0a63eea708f0225b248e788 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:30 +0200 Subject: staging: ks7010: indent ks_hostif.c Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 1960 ++++++++++++++++++++---------------- 1 file changed, 1080 insertions(+), 880 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 497b8aa..f2a65c0 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -23,9 +23,10 @@ /* Include Wireless Extension definition and check version */ #include /* New driver API */ -extern int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, - void (*complete_handler)(void *arg1, void *arg2), - void *arg1, void *arg2 ); +extern int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, + unsigned long size, + void (*complete_handler) (void *arg1, void *arg2), + void *arg1, void *arg2); extern void send_packet_complete(void *, void *); extern void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv); @@ -55,7 +56,7 @@ static inline u16 get_WORD(struct ks_wlan_private *priv) { u16 data; - data = (get_BYTE(priv) & 0xff); + data = (get_BYTE(priv) & 0xff); data |= ((get_BYTE(priv) << 8) & 0xff00); return data; } @@ -64,7 +65,7 @@ static inline u32 get_DWORD(struct ks_wlan_private *priv) { u32 data; - data = (get_BYTE(priv) & 0xff); + data = (get_BYTE(priv) & 0xff); data |= ((get_BYTE(priv) << 8) & 0x0000ff00); data |= ((get_BYTE(priv) << 16) & 0x00ff0000); data |= ((get_BYTE(priv) << 24) & 0xff000000); @@ -73,24 +74,24 @@ inline u32 get_DWORD(struct ks_wlan_private *priv) void ks_wlan_hw_wakeup_task(struct work_struct *work) { - struct ks_wlan_private *priv = container_of(work, struct ks_wlan_private, ks_wlan_wakeup_task); + struct ks_wlan_private *priv = + container_of(work, struct ks_wlan_private, ks_wlan_wakeup_task); int ps_status = atomic_read(&priv->psstatus.status); - if(ps_status==PS_SNOOZE){ + if (ps_status == PS_SNOOZE) { ks_wlan_hw_wakeup_request(priv); - if(!wait_for_completion_interruptible_timeout(&priv->psstatus.wakeup_wait,HZ/50)){ /* 20ms timeout */ - DPRINTK(1,"wake up timeout !!!\n"); + if (!wait_for_completion_interruptible_timeout(&priv->psstatus.wakeup_wait, HZ / 50)) { /* 20ms timeout */ + DPRINTK(1, "wake up timeout !!!\n"); schedule_work(&priv->ks_wlan_wakeup_task); return; } - } - else{ - DPRINTK(1,"ps_status=%d\n",ps_status); + } else { + DPRINTK(1, "ps_status=%d\n", ps_status); } /* power save */ - if(atomic_read(&priv->sme_task.count) > 0){ - DPRINTK(4,"sme task enable.\n"); + if (atomic_read(&priv->sme_task.count) > 0) { + DPRINTK(4, "sme task enable.\n"); tasklet_enable(&priv->sme_task); } } @@ -98,14 +99,13 @@ void ks_wlan_hw_wakeup_task(struct work_struct *work) static int ks_wlan_do_power_save(struct ks_wlan_private *priv) { - int rc=0; + int rc = 0; - DPRINTK(4,"psstatus.status=%d\n",atomic_read(&priv->psstatus.status)); + DPRINTK(4, "psstatus.status=%d\n", atomic_read(&priv->psstatus.status)); - if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ + if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); - } - else{ + } else { priv->dev_state = DEVICE_STATE_READY; } return rc; @@ -116,26 +116,28 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info) { struct local_ap_t *ap; union iwreq_data wrqu; - struct net_device *netdev=priv->net_dev; - int rc=0; + struct net_device *netdev = priv->net_dev; + int rc = 0; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); ap = &(priv->current_ap); - if((priv->connect_status & CONNECT_STATUS_MASK)== DISCONNECT_STATUS){ - memset(ap,0,sizeof(struct local_ap_t)); + if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) { + memset(ap, 0, sizeof(struct local_ap_t)); return 1; } /* bssid */ - memcpy(&(ap->bssid[0]),&(ap_info->bssid[0]),ETH_ALEN); + memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN); /* essid */ - memcpy(&(ap->ssid.body[0]),&(priv->reg.ssid.body[0]),priv->reg.ssid.size); + memcpy(&(ap->ssid.body[0]), &(priv->reg.ssid.body[0]), + priv->reg.ssid.size); ap->ssid.size = priv->reg.ssid.size; /* rate_set */ - memcpy(&(ap->rate_set.body[0]),&(ap_info->rate_set.body[0]),ap_info->rate_set.size); + memcpy(&(ap->rate_set.body[0]), &(ap_info->rate_set.body[0]), + ap_info->rate_set.size); ap->rate_set.size = ap_info->rate_set.size; - if(ap_info->ext_rate_set.size){ + if (ap_info->ext_rate_set.size) { /* rate_set */ memcpy(&(ap->rate_set.body[ap->rate_set.size]), &(ap_info->ext_rate_set.body[0]), @@ -153,29 +155,31 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info) /* capability */ ap->capability = ap_info->capability; /* rsn */ - if((ap_info->rsn_mode & RSN_MODE_WPA2) && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)){ + if ((ap_info->rsn_mode & RSN_MODE_WPA2) + && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) { ap->rsn_ie.id = 0x30; - if(ap_info->rsn.size <= RSN_IE_BODY_MAX){ + if (ap_info->rsn.size <= RSN_IE_BODY_MAX) { ap->rsn_ie.size = ap_info->rsn.size; - memcpy(&(ap->rsn_ie.body[0]),&(ap_info->rsn.body[0]),ap_info->rsn.size); - } - else{ + memcpy(&(ap->rsn_ie.body[0]), &(ap_info->rsn.body[0]), + ap_info->rsn.size); + } else { ap->rsn_ie.size = RSN_IE_BODY_MAX; - memcpy(&(ap->rsn_ie.body[0]),&(ap_info->rsn.body[0]),RSN_IE_BODY_MAX); + memcpy(&(ap->rsn_ie.body[0]), &(ap_info->rsn.body[0]), + RSN_IE_BODY_MAX); } - } - else if((ap_info->rsn_mode & RSN_MODE_WPA) && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA)){ + } else if ((ap_info->rsn_mode & RSN_MODE_WPA) + && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA)) { ap->wpa_ie.id = 0xdd; - if(ap_info->rsn.size <= RSN_IE_BODY_MAX){ + if (ap_info->rsn.size <= RSN_IE_BODY_MAX) { ap->wpa_ie.size = ap_info->rsn.size; - memcpy(&(ap->wpa_ie.body[0]),&(ap_info->rsn.body[0]),ap_info->rsn.size); - } - else{ + memcpy(&(ap->wpa_ie.body[0]), &(ap_info->rsn.body[0]), + ap_info->rsn.size); + } else { ap->wpa_ie.size = RSN_IE_BODY_MAX; - memcpy(&(ap->wpa_ie.body[0]),&(ap_info->rsn.body[0]),RSN_IE_BODY_MAX); + memcpy(&(ap->wpa_ie.body[0]), &(ap_info->rsn.body[0]), + RSN_IE_BODY_MAX); } - } - else{ + } else { ap->rsn_ie.id = 0; ap->rsn_ie.size = 0; ap->wpa_ie.id = 0; @@ -185,45 +189,44 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info) wrqu.data.length = 0; wrqu.data.flags = 0; wrqu.ap_addr.sa_family = ARPHRD_ETHER; - if((priv->connect_status & CONNECT_STATUS_MASK)==CONNECT_STATUS){ + if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { memcpy(wrqu.ap_addr.sa_data, &(priv->current_ap.bssid[0]), ETH_ALEN); - DPRINTK(3,"IWEVENT: connect bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", - (unsigned char)wrqu.ap_addr.sa_data[0],(unsigned char)wrqu.ap_addr.sa_data[1], - (unsigned char)wrqu.ap_addr.sa_data[2],(unsigned char)wrqu.ap_addr.sa_data[3], - (unsigned char)wrqu.ap_addr.sa_data[4],(unsigned char)wrqu.ap_addr.sa_data[5]); + DPRINTK(3, + "IWEVENT: connect bssid=%02x:%02x:%02x:%02x:%02x:%02x\n", + (unsigned char)wrqu.ap_addr.sa_data[0], + (unsigned char)wrqu.ap_addr.sa_data[1], + (unsigned char)wrqu.ap_addr.sa_data[2], + (unsigned char)wrqu.ap_addr.sa_data[3], + (unsigned char)wrqu.ap_addr.sa_data[4], + (unsigned char)wrqu.ap_addr.sa_data[5]); wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL); } - DPRINTK(4,"\n Link AP\n"); - DPRINTK(4," bssid=%02X:%02X:%02X:%02X:%02X:%02X\n \ + DPRINTK(4, "\n Link AP\n"); + DPRINTK(4, " bssid=%02X:%02X:%02X:%02X:%02X:%02X\n \ essid=%s\n rate_set=%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X\n channel=%d\n \ - rssi=%d\n sq=%d\n capability=%04X\n", - ap->bssid[0],ap->bssid[1],ap->bssid[2],ap->bssid[3],ap->bssid[4], - ap->bssid[5],&(ap->ssid.body[0]),ap->rate_set.body[0],ap->rate_set.body[1], - ap->rate_set.body[2],ap->rate_set.body[3],ap->rate_set.body[4], - ap->rate_set.body[5],ap->rate_set.body[6],ap->rate_set.body[7], - ap->channel,ap->rssi,ap->sq,ap->capability); - DPRINTK(4,"\n Link AP\n rsn.mode=%d\n rsn.size=%d\n", - ap_info->rsn_mode,ap_info->rsn.size); - DPRINTK(4,"\n ext_rate_set_size=%d\n rate_set_size=%d\n", - ap_info->ext_rate_set.size,ap_info->rate_set.size); - + rssi=%d\n sq=%d\n capability=%04X\n", ap->bssid[0], ap->bssid[1], ap->bssid[2], ap->bssid[3], ap->bssid[4], ap->bssid[5], &(ap->ssid.body[0]), ap->rate_set.body[0], ap->rate_set.body[1], ap->rate_set.body[2], ap->rate_set.body[3], ap->rate_set.body[4], ap->rate_set.body[5], ap->rate_set.body[6], ap->rate_set.body[7], ap->channel, ap->rssi, ap->sq, ap->capability); + DPRINTK(4, "\n Link AP\n rsn.mode=%d\n rsn.size=%d\n", + ap_info->rsn_mode, ap_info->rsn.size); + DPRINTK(4, "\n ext_rate_set_size=%d\n rate_set_size=%d\n", + ap_info->ext_rate_set.size, ap_info->rate_set.size); return rc; } static -int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, struct local_ap_t *ap) +int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, + struct local_ap_t *ap) { unsigned char *bp; - int bsize,offset; - int rc=0; + int bsize, offset; + int rc = 0; - DPRINTK(3,"\n"); - memset(ap,0,sizeof(struct local_ap_t)); + DPRINTK(3, "\n"); + memset(ap, 0, sizeof(struct local_ap_t)); /* bssid */ - memcpy(&(ap->bssid[0]),&(ap_info->bssid[0]),ETH_ALEN); + memcpy(&(ap->bssid[0]), &(ap_info->bssid[0]), ETH_ALEN); /* rssi */ ap->rssi = ap_info->rssi; /* sq */ @@ -239,73 +242,80 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, bsize = ap_info->body_size; offset = 0; - while(bsize > offset){ + while (bsize > offset) { /* DPRINTK(4, "Element ID=%d \n",*bp); */ - switch(*bp){ - case 0: /* ssid */ - if(*(bp+1) <= SSID_MAX_SIZE){ - ap->ssid.size = *(bp+1); - } - else { - DPRINTK(1, "size over :: ssid size=%d \n",*(bp+1)); + switch (*bp) { + case 0: /* ssid */ + if (*(bp + 1) <= SSID_MAX_SIZE) { + ap->ssid.size = *(bp + 1); + } else { + DPRINTK(1, "size over :: ssid size=%d \n", + *(bp + 1)); ap->ssid.size = SSID_MAX_SIZE; } - memcpy(&(ap->ssid.body[0]),bp+2,ap->ssid.size); + memcpy(&(ap->ssid.body[0]), bp + 2, ap->ssid.size); break; - case 1: /* rate */ - case 50: /* ext rate */ - if((*(bp+1) + ap->rate_set.size) <= RATE_SET_MAX_SIZE){ - memcpy(&(ap->rate_set.body[ap->rate_set.size]),bp+2,*(bp+1)); - ap->rate_set.size += *(bp+1); - } - else{ + case 1: /* rate */ + case 50: /* ext rate */ + if ((*(bp + 1) + ap->rate_set.size) <= + RATE_SET_MAX_SIZE) { + memcpy(&(ap->rate_set.body[ap->rate_set.size]), + bp + 2, *(bp + 1)); + ap->rate_set.size += *(bp + 1); + } else { DPRINTK(1, "size over :: rate size=%d \n", - (*(bp+1) + ap->rate_set.size)); - memcpy(&(ap->rate_set.body[ap->rate_set.size]),bp+2, + (*(bp + 1) + ap->rate_set.size)); + memcpy(&(ap->rate_set.body[ap->rate_set.size]), + bp + 2, RATE_SET_MAX_SIZE - ap->rate_set.size); - ap->rate_set.size += (RATE_SET_MAX_SIZE - ap->rate_set.size); + ap->rate_set.size += + (RATE_SET_MAX_SIZE - ap->rate_set.size); } break; - case 3: /* DS parameter */ + case 3: /* DS parameter */ break; - case 48: /* RSN(WPA2) */ + case 48: /* RSN(WPA2) */ ap->rsn_ie.id = *bp; - if(*(bp+1) <= RSN_IE_BODY_MAX){ - ap->rsn_ie.size = *(bp+1); - }else{ - DPRINTK(1, "size over :: rsn size=%d \n",*(bp+1)); + if (*(bp + 1) <= RSN_IE_BODY_MAX) { + ap->rsn_ie.size = *(bp + 1); + } else { + DPRINTK(1, "size over :: rsn size=%d \n", + *(bp + 1)); ap->rsn_ie.size = RSN_IE_BODY_MAX; } - memcpy(&(ap->rsn_ie.body[0]),bp+2,ap->rsn_ie.size); + memcpy(&(ap->rsn_ie.body[0]), bp + 2, ap->rsn_ie.size); break; - case 221: /* WPA */ - if(!memcmp(bp+2, "\x00\x50\xf2\x01", 4)){ /* WPA OUI check */ + case 221: /* WPA */ + if (!memcmp(bp + 2, "\x00\x50\xf2\x01", 4)) { /* WPA OUI check */ ap->wpa_ie.id = *bp; - if(*(bp+1) <= RSN_IE_BODY_MAX){ - ap->wpa_ie.size = *(bp+1); - }else{ - DPRINTK(1, "size over :: wpa size=%d \n",*(bp+1)); + if (*(bp + 1) <= RSN_IE_BODY_MAX) { + ap->wpa_ie.size = *(bp + 1); + } else { + DPRINTK(1, + "size over :: wpa size=%d \n", + *(bp + 1)); ap->wpa_ie.size = RSN_IE_BODY_MAX; } - memcpy(&(ap->wpa_ie.body[0]),bp+2,ap->wpa_ie.size); + memcpy(&(ap->wpa_ie.body[0]), bp + 2, + ap->wpa_ie.size); } break; - case 2: /* FH parameter */ - case 4: /* CF parameter */ - case 5: /* TIM */ - case 6: /* IBSS parameter */ - case 7: /* Country */ - case 42: /* ERP information */ - case 47: /* Reserve ID 47 Broadcom AP */ + case 2: /* FH parameter */ + case 4: /* CF parameter */ + case 5: /* TIM */ + case 6: /* IBSS parameter */ + case 7: /* Country */ + case 42: /* ERP information */ + case 47: /* Reserve ID 47 Broadcom AP */ break; default: - DPRINTK(4, "unknown Element ID=%d \n",*bp); + DPRINTK(4, "unknown Element ID=%d \n", *bp); break; } - offset += 2; /* id & size field */ - offset += *(bp+1); /* +size offset */ - bp += (*(bp+1) + 2); /* pointer update */ + offset += 2; /* id & size field */ + offset += *(bp + 1); /* +size offset */ + bp += (*(bp + 1) + 2); /* pointer update */ } return rc; @@ -314,12 +324,12 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, static void hostif_data_indication(struct ks_wlan_private *priv) { - unsigned int rx_ind_size; /* indicate data size */ + unsigned int rx_ind_size; /* indicate data size */ struct sk_buff *skb; - unsigned short auth_type; - unsigned char temp[256]; + unsigned short auth_type; + unsigned char temp[256]; - unsigned char RecvMIC[8]; + unsigned char RecvMIC[8]; char buf[128]; struct ether_hdr *eth_hdr; unsigned short eth_proto; @@ -330,162 +340,193 @@ void hostif_data_indication(struct ks_wlan_private *priv) struct michel_mic_t michel_mic; union iwreq_data wrqu; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); /* min length check */ if (priv->rx_size <= ETH_HLEN) { - DPRINTK(3,"rx_size = %d\n", priv->rx_size); + DPRINTK(3, "rx_size = %d\n", priv->rx_size); priv->nstats.rx_errors++; return; } - auth_type = get_WORD(priv); /* AuthType */ - get_WORD(priv); /* Reserve Area */ + auth_type = get_WORD(priv); /* AuthType */ + get_WORD(priv); /* Reserve Area */ eth_hdr = (struct ether_hdr *)(priv->rxp); eth_proto = ntohs(eth_hdr->h_proto); - DPRINTK(3,"ether protocol = %04X\n", eth_proto); + DPRINTK(3, "ether protocol = %04X\n", eth_proto); /* source address check */ - if (!memcmp(&priv->eth_addr[0],eth_hdr->h_source, ETH_ALEN)){ + if (!memcmp(&priv->eth_addr[0], eth_hdr->h_source, ETH_ALEN)) { DPRINTK(1, "invalid : source is own mac address !!\n"); - DPRINTK(1, "eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n", - eth_hdr->h_source[0],eth_hdr->h_source[1],eth_hdr->h_source[2], - eth_hdr->h_source[3],eth_hdr->h_source[4],eth_hdr->h_source[5]); + DPRINTK(1, + "eth_hdrernet->h_dest=%02X:%02X:%02X:%02X:%02X:%02X\n", + eth_hdr->h_source[0], eth_hdr->h_source[1], + eth_hdr->h_source[2], eth_hdr->h_source[3], + eth_hdr->h_source[4], eth_hdr->h_source[5]); priv->nstats.rx_errors++; return; } /* for WPA */ - if (auth_type != TYPE_DATA && priv->wpa.rsn_enabled){ - if(memcmp(ð_hdr->h_source[0],&priv->eth_addr[0],ETH_ALEN)){ /* source address check */ - if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap){ - DPRINTK(1,"invalid data format\n"); + if (auth_type != TYPE_DATA && priv->wpa.rsn_enabled) { + if (memcmp(ð_hdr->h_source[0], &priv->eth_addr[0], ETH_ALEN)) { /* source address check */ + if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap) { + DPRINTK(1, "invalid data format\n"); priv->nstats.rx_errors++; return; } - if(((auth_type==TYPE_PMK1 && priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP)|| - (auth_type==TYPE_GMK1 && priv->wpa.group_suite == IW_AUTH_CIPHER_TKIP)|| - (auth_type==TYPE_GMK2 && priv->wpa.group_suite == IW_AUTH_CIPHER_TKIP)) - && priv->wpa.key[auth_type-1].key_len){ - DPRINTK(4,"TKIP: protocol=%04X: size=%u\n", eth_proto, priv->rx_size); + if (((auth_type == TYPE_PMK1 + && priv->wpa.pairwise_suite == + IW_AUTH_CIPHER_TKIP) || (auth_type == TYPE_GMK1 + && priv->wpa. + group_suite == + IW_AUTH_CIPHER_TKIP) + || (auth_type == TYPE_GMK2 + && priv->wpa.group_suite == + IW_AUTH_CIPHER_TKIP)) + && priv->wpa.key[auth_type - 1].key_len) { + DPRINTK(4, "TKIP: protocol=%04X: size=%u\n", + eth_proto, priv->rx_size); /* MIC save */ - memcpy(&RecvMIC[0], (priv->rxp)+((priv->rx_size)-8), 8); + memcpy(&RecvMIC[0], + (priv->rxp) + ((priv->rx_size) - 8), 8); priv->rx_size = priv->rx_size - 8; - if(auth_type > 0 && auth_type < 4){ /* auth_type check */ - MichaelMICFunction(&michel_mic, - (uint8_t*)priv->wpa.key[auth_type-1].rx_mic_key, - (uint8_t*)priv->rxp, - (int)priv->rx_size, - (uint8_t)0, /* priority */ - (uint8_t*)michel_mic.Result); + if (auth_type > 0 && auth_type < 4) { /* auth_type check */ + MichaelMICFunction(&michel_mic, (uint8_t *) priv->wpa.key[auth_type - 1].rx_mic_key, (uint8_t *) priv->rxp, (int)priv->rx_size, (uint8_t) 0, /* priority */ + (uint8_t *) + michel_mic.Result); } - if(memcmp(michel_mic.Result, RecvMIC, 8)){ + if (memcmp(michel_mic.Result, RecvMIC, 8)) { now = jiffies; mic_failure = &priv->wpa.mic_failure; /* MIC FAILURE */ - if(mic_failure->last_failure_time && - (now - mic_failure->last_failure_time)/HZ >= 60){ - mic_failure->failure=0; + if (mic_failure->last_failure_time && + (now - + mic_failure->last_failure_time) / + HZ >= 60) { + mic_failure->failure = 0; } - DPRINTK(4,"MIC FAILURE \n"); - if(mic_failure->failure==0){ - mic_failure->failure=1; - mic_failure->counter=0; - }else if(mic_failure->failure==1){ - mic_failure->failure=2; + DPRINTK(4, "MIC FAILURE \n"); + if (mic_failure->failure == 0) { + mic_failure->failure = 1; + mic_failure->counter = 0; + } else if (mic_failure->failure == 1) { + mic_failure->failure = 2; mic_failure->counter = - (uint16_t)((now - mic_failure->last_failure_time)/HZ); - if(!mic_failure->counter) /* mic_failure counter value range 1-60 */ - mic_failure->counter = 1; + (uint16_t) ((now - + mic_failure-> + last_failure_time) + / HZ); + if (!mic_failure->counter) /* mic_failure counter value range 1-60 */ + mic_failure->counter = + 1; } - priv->wpa.mic_failure.last_failure_time = now; + priv->wpa.mic_failure. + last_failure_time = now; /* needed parameters: count, keyid, key type, TSC */ - sprintf(buf, "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=" + sprintf(buf, + "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr=" "%02x:%02x:%02x:%02x:%02x:%02x)", - auth_type-1, eth_hdr->h_dest[0] & 0x01 ? "broad" : "uni", - eth_hdr->h_source[0],eth_hdr->h_source[1], - eth_hdr->h_source[2],eth_hdr->h_source[3], - eth_hdr->h_source[4],eth_hdr->h_source[5]); + auth_type - 1, + eth_hdr-> + h_dest[0] & 0x01 ? "broad" : + "uni", eth_hdr->h_source[0], + eth_hdr->h_source[1], + eth_hdr->h_source[2], + eth_hdr->h_source[3], + eth_hdr->h_source[4], + eth_hdr->h_source[5]); memset(&wrqu, 0, sizeof(wrqu)); wrqu.data.length = strlen(buf); - DPRINTK(4,"IWEVENT:MICHAELMICFAILURE\n"); - wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf); + DPRINTK(4, + "IWEVENT:MICHAELMICFAILURE\n"); + wireless_send_event(priv->net_dev, + IWEVCUSTOM, &wrqu, + buf); return; } } } } - if((priv->connect_status & FORCE_DISCONNECT)|| - priv->wpa.mic_failure.failure==2){ + if ((priv->connect_status & FORCE_DISCONNECT) || + priv->wpa.mic_failure.failure == 2) { return; } /* check 13th byte at rx data */ - switch (*(priv->rxp+12)) { - case 0xAA: /* SNAP */ + switch (*(priv->rxp + 12)) { + case 0xAA: /* SNAP */ rx_ind_size = priv->rx_size - 6; - skb = dev_alloc_skb (rx_ind_size); - DPRINTK(4,"SNAP, rx_ind_size = %d\n", rx_ind_size); - - if(skb) { - memcpy(skb_put(skb,12),priv->rxp,12); /* 8802/FDDI MAC copy */ - /* (SNAP+UI..) skip */ - memcpy(skb_put(skb,rx_ind_size-12),priv->rxp+18,rx_ind_size-12); /* copy after Type */ - - aa1x_hdr=(struct ieee802_1x_hdr *)(priv->rxp+20); - if(aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY && priv->wpa.rsn_enabled){ - eap_key = (struct wpa_eapol_key *)(aa1x_hdr+1); + skb = dev_alloc_skb(rx_ind_size); + DPRINTK(4, "SNAP, rx_ind_size = %d\n", rx_ind_size); + + if (skb) { + memcpy(skb_put(skb, 12), priv->rxp, 12); /* 8802/FDDI MAC copy */ + /* (SNAP+UI..) skip */ + memcpy(skb_put(skb, rx_ind_size - 12), priv->rxp + 18, rx_ind_size - 12); /* copy after Type */ + + aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 20); + if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY + && priv->wpa.rsn_enabled) { + eap_key = + (struct wpa_eapol_key *)(aa1x_hdr + 1); atomic_set(&priv->psstatus.snooze_guard, 1); } /* rx indication */ skb->dev = priv->net_dev; - skb->protocol = eth_type_trans (skb, skb->dev); + skb->protocol = eth_type_trans(skb, skb->dev); priv->nstats.rx_packets++; priv->nstats.rx_bytes += rx_ind_size; skb->dev->last_rx = jiffies; - netif_rx (skb); + netif_rx(skb); } else { - printk (KERN_WARNING"%s: Memory squeeze, dropping packet.\n",skb->dev->name); + printk(KERN_WARNING + "%s: Memory squeeze, dropping packet.\n", + skb->dev->name); priv->nstats.rx_dropped++; } break; - case 0xF0: /* NETBEUI/NetBIOS */ + case 0xF0: /* NETBEUI/NetBIOS */ rx_ind_size = (priv->rx_size + 2); - skb = dev_alloc_skb (rx_ind_size); - DPRINTK(3,"NETBEUI/NetBIOS rx_ind_size=%d\n", rx_ind_size); + skb = dev_alloc_skb(rx_ind_size); + DPRINTK(3, "NETBEUI/NetBIOS rx_ind_size=%d\n", rx_ind_size); - if(skb) { - memcpy(skb_put(skb,12),priv->rxp,12); /* 8802/FDDI MAC copy */ + if (skb) { + memcpy(skb_put(skb, 12), priv->rxp, 12); /* 8802/FDDI MAC copy */ - temp[0] = (((rx_ind_size-12) >> 8) & 0xff); /* NETBEUI size add */ - temp[1] = ((rx_ind_size-12) & 0xff); - memcpy(skb_put(skb,2),temp,2); + temp[0] = (((rx_ind_size - 12) >> 8) & 0xff); /* NETBEUI size add */ + temp[1] = ((rx_ind_size - 12) & 0xff); + memcpy(skb_put(skb, 2), temp, 2); - memcpy(skb_put(skb,rx_ind_size-14),priv->rxp+12,rx_ind_size-14); /* copy after Type */ + memcpy(skb_put(skb, rx_ind_size - 14), priv->rxp + 12, rx_ind_size - 14); /* copy after Type */ - aa1x_hdr=(struct ieee802_1x_hdr *)(priv->rxp+14); - if(aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY && priv->wpa.rsn_enabled){ - eap_key = (struct wpa_eapol_key *)(aa1x_hdr+1); + aa1x_hdr = (struct ieee802_1x_hdr *)(priv->rxp + 14); + if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY + && priv->wpa.rsn_enabled) { + eap_key = + (struct wpa_eapol_key *)(aa1x_hdr + 1); atomic_set(&priv->psstatus.snooze_guard, 1); } /* rx indication */ skb->dev = priv->net_dev; - skb->protocol = eth_type_trans (skb, skb->dev); + skb->protocol = eth_type_trans(skb, skb->dev); priv->nstats.rx_packets++; priv->nstats.rx_bytes += rx_ind_size; skb->dev->last_rx = jiffies; - netif_rx (skb); + netif_rx(skb); } else { - printk (KERN_WARNING"%s: Memory squeeze, dropping packet.\n",skb->dev->name); + printk(KERN_WARNING + "%s: Memory squeeze, dropping packet.\n", + skb->dev->name); priv->nstats.rx_dropped++; } break; - default: /* other rx data */ - DPRINTK(2,"invalid data format\n"); + default: /* other rx data */ + DPRINTK(2, "invalid data format\n"); priv->nstats.rx_errors++; } } @@ -493,29 +534,30 @@ void hostif_data_indication(struct ks_wlan_private *priv) static void hostif_mib_get_confirm(struct ks_wlan_private *priv) { - struct net_device *dev=priv->net_dev; - uint32_t mib_status; - uint32_t mib_attribute; - uint16_t mib_val_size; - uint16_t mib_val_type; + struct net_device *dev = priv->net_dev; + uint32_t mib_status; + uint32_t mib_attribute; + uint16_t mib_val_size; + uint16_t mib_val_type; DPRINTK(3, "\n"); - mib_status = get_DWORD(priv); /* MIB status */ - mib_attribute = get_DWORD(priv); /* MIB atttibute */ - mib_val_size = get_WORD(priv); /* MIB value size */ - mib_val_type = get_WORD(priv); /* MIB value type */ + mib_status = get_DWORD(priv); /* MIB status */ + mib_attribute = get_DWORD(priv); /* MIB atttibute */ + mib_val_size = get_WORD(priv); /* MIB value size */ + mib_val_type = get_WORD(priv); /* MIB value type */ if (mib_status != 0) { /* in case of error */ - DPRINTK(1, "attribute=%08X, status=%08X\n", mib_attribute, mib_status); + DPRINTK(1, "attribute=%08X, status=%08X\n", mib_attribute, + mib_status); return; } switch (mib_attribute) { case DOT11_MAC_ADDRESS: /* MAC address */ - DPRINTK(3," mib_attribute=DOT11_MAC_ADDRESS\n"); + DPRINTK(3, " mib_attribute=DOT11_MAC_ADDRESS\n"); hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS); memcpy(priv->eth_addr, priv->rxp, ETH_ALEN); priv->mac_address_valid = 1; @@ -527,44 +569,48 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv) dev->dev_addr[5] = priv->eth_addr[5]; dev->dev_addr[6] = 0x00; dev->dev_addr[7] = 0x00; - printk(KERN_INFO "ks_wlan: MAC ADDRESS = %02x:%02x:%02x:%02x:%02x:%02x\n", - priv->eth_addr[0],priv->eth_addr[1],priv->eth_addr[2], - priv->eth_addr[3],priv->eth_addr[4],priv->eth_addr[5]); + printk(KERN_INFO + "ks_wlan: MAC ADDRESS = %02x:%02x:%02x:%02x:%02x:%02x\n", + priv->eth_addr[0], priv->eth_addr[1], priv->eth_addr[2], + priv->eth_addr[3], priv->eth_addr[4], priv->eth_addr[5]); break; case DOT11_PRODUCT_VERSION: /* firmware version */ - DPRINTK(3," mib_attribute=DOT11_PRODUCT_VERSION\n"); + DPRINTK(3, " mib_attribute=DOT11_PRODUCT_VERSION\n"); priv->version_size = priv->rx_size; memcpy(priv->firmware_version, priv->rxp, priv->rx_size); priv->firmware_version[priv->rx_size] = '\0'; - printk(KERN_INFO "ks_wlan: firmware ver. = %s\n",priv->firmware_version); + printk(KERN_INFO "ks_wlan: firmware ver. = %s\n", + priv->firmware_version); hostif_sme_enqueue(priv, SME_GET_PRODUCT_VERSION); /* wake_up_interruptible_all(&priv->confirm_wait); */ complete(&priv->confirm_wait); break; case LOCAL_GAIN: memcpy(&priv->gain, priv->rxp, sizeof(priv->gain)); - DPRINTK(3, "TxMode=%d, RxMode=%d, TxGain=%d, RxGain=%d\n", - priv->gain.TxMode, priv->gain.RxMode, priv->gain.TxGain, priv->gain.RxGain); + DPRINTK(3, "TxMode=%d, RxMode=%d, TxGain=%d, RxGain=%d\n", + priv->gain.TxMode, priv->gain.RxMode, priv->gain.TxGain, + priv->gain.RxGain); break; case LOCAL_EEPROM_SUM: memcpy(&priv->eeprom_sum, priv->rxp, sizeof(priv->eeprom_sum)); - DPRINTK(1, "eeprom_sum.type=%x, eeprom_sum.result=%x\n", priv->eeprom_sum.type, priv->eeprom_sum.result); - if(priv->eeprom_sum.type == 0){ + DPRINTK(1, "eeprom_sum.type=%x, eeprom_sum.result=%x\n", + priv->eeprom_sum.type, priv->eeprom_sum.result); + if (priv->eeprom_sum.type == 0) { priv->eeprom_checksum = EEPROM_CHECKSUM_NONE; - }else if(priv->eeprom_sum.type == 1){ - if(priv->eeprom_sum.result == 0){ + } else if (priv->eeprom_sum.type == 1) { + if (priv->eeprom_sum.result == 0) { priv->eeprom_checksum = EEPROM_NG; printk("LOCAL_EEPROM_SUM NG\n"); - }else if(priv->eeprom_sum.result == 1){ + } else if (priv->eeprom_sum.result == 1) { priv->eeprom_checksum = EEPROM_OK; } - }else{ + } else { printk("LOCAL_EEPROM_SUM error!\n"); } break; default: - DPRINTK(1,"mib_attribute=%08x\n",(unsigned int)mib_attribute); + DPRINTK(1, "mib_attribute=%08x\n", (unsigned int)mib_attribute); break; } } @@ -572,17 +618,18 @@ void hostif_mib_get_confirm(struct ks_wlan_private *priv) static void hostif_mib_set_confirm(struct ks_wlan_private *priv) { - uint32_t mib_status; /* +04 MIB Status */ - uint32_t mib_attribute; /* +08 MIB attribute */ + uint32_t mib_status; /* +04 MIB Status */ + uint32_t mib_attribute; /* +08 MIB attribute */ - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); - mib_status = get_DWORD(priv); /* MIB Status */ - mib_attribute = get_DWORD(priv); /* MIB attribute */ + mib_status = get_DWORD(priv); /* MIB Status */ + mib_attribute = get_DWORD(priv); /* MIB attribute */ if (mib_status != 0) { /* in case of error */ - DPRINTK(1, "error :: attribute=%08X, status=%08X\n", mib_attribute, mib_status); + DPRINTK(1, "error :: attribute=%08X, status=%08X\n", + mib_attribute, mib_status); } switch (mib_attribute) { @@ -593,41 +640,46 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv) hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_CONFIRM); break; case DOT11_WEP_DEFAULT_KEY_ID: - if(!priv->wpa.wpa_enabled) + if (!priv->wpa.wpa_enabled) hostif_sme_enqueue(priv, SME_WEP_INDEX_CONFIRM); break; case DOT11_WEP_DEFAULT_KEY_VALUE1: - DPRINTK(2,"DOT11_WEP_DEFAULT_KEY_VALUE1:mib_status=%d\n",(int)mib_status); - if(priv->wpa.rsn_enabled) + DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE1:mib_status=%d\n", + (int)mib_status); + if (priv->wpa.rsn_enabled) hostif_sme_enqueue(priv, SME_SET_PMK_TSC); else hostif_sme_enqueue(priv, SME_WEP_KEY1_CONFIRM); break; case DOT11_WEP_DEFAULT_KEY_VALUE2: - DPRINTK(2,"DOT11_WEP_DEFAULT_KEY_VALUE2:mib_status=%d\n",(int)mib_status); - if(priv->wpa.rsn_enabled) + DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE2:mib_status=%d\n", + (int)mib_status); + if (priv->wpa.rsn_enabled) hostif_sme_enqueue(priv, SME_SET_GMK1_TSC); else hostif_sme_enqueue(priv, SME_WEP_KEY2_CONFIRM); break; case DOT11_WEP_DEFAULT_KEY_VALUE3: - DPRINTK(2,"DOT11_WEP_DEFAULT_KEY_VALUE3:mib_status=%d\n",(int)mib_status); - if(priv->wpa.rsn_enabled) + DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE3:mib_status=%d\n", + (int)mib_status); + if (priv->wpa.rsn_enabled) hostif_sme_enqueue(priv, SME_SET_GMK2_TSC); else hostif_sme_enqueue(priv, SME_WEP_KEY3_CONFIRM); break; case DOT11_WEP_DEFAULT_KEY_VALUE4: - DPRINTK(2,"DOT11_WEP_DEFAULT_KEY_VALUE4:mib_status=%d\n",(int)mib_status); - if(!priv->wpa.rsn_enabled) + DPRINTK(2, "DOT11_WEP_DEFAULT_KEY_VALUE4:mib_status=%d\n", + (int)mib_status); + if (!priv->wpa.rsn_enabled) hostif_sme_enqueue(priv, SME_WEP_KEY4_CONFIRM); break; case DOT11_PRIVACY_INVOKED: - if(!priv->wpa.rsn_enabled) + if (!priv->wpa.rsn_enabled) hostif_sme_enqueue(priv, SME_WEP_FLAG_CONFIRM); break; case DOT11_RSN_ENABLED: - DPRINTK(2,"DOT11_RSN_ENABLED:mib_status=%d\n",(int)mib_status); + DPRINTK(2, "DOT11_RSN_ENABLED:mib_status=%d\n", + (int)mib_status); hostif_sme_enqueue(priv, SME_RSN_ENABLED_CONFIRM); break; case LOCAL_RSN_MODE: @@ -643,49 +695,53 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv) priv->mac_address_valid = 1; break; case DOT11_RSN_CONFIG_MULTICAST_CIPHER: - DPRINTK(2,"DOT11_RSN_CONFIG_MULTICAST_CIPHER:mib_status=%d\n",(int)mib_status); + DPRINTK(2, "DOT11_RSN_CONFIG_MULTICAST_CIPHER:mib_status=%d\n", + (int)mib_status); hostif_sme_enqueue(priv, SME_RSN_MCAST_CONFIRM); break; case DOT11_RSN_CONFIG_UNICAST_CIPHER: - DPRINTK(2,"DOT11_RSN_CONFIG_UNICAST_CIPHER:mib_status=%d\n",(int)mib_status); + DPRINTK(2, "DOT11_RSN_CONFIG_UNICAST_CIPHER:mib_status=%d\n", + (int)mib_status); hostif_sme_enqueue(priv, SME_RSN_UCAST_CONFIRM); break; case DOT11_RSN_CONFIG_AUTH_SUITE: - DPRINTK(2,"DOT11_RSN_CONFIG_AUTH_SUITE:mib_status=%d\n",(int)mib_status); + DPRINTK(2, "DOT11_RSN_CONFIG_AUTH_SUITE:mib_status=%d\n", + (int)mib_status); hostif_sme_enqueue(priv, SME_RSN_AUTH_CONFIRM); break; case DOT11_PMK_TSC: - DPRINTK(2,"DOT11_PMK_TSC:mib_status=%d\n",(int)mib_status); + DPRINTK(2, "DOT11_PMK_TSC:mib_status=%d\n", (int)mib_status); break; case DOT11_GMK1_TSC: - DPRINTK(2,"DOT11_GMK1_TSC:mib_status=%d\n",(int)mib_status); - if(atomic_read(&priv->psstatus.snooze_guard)){ + DPRINTK(2, "DOT11_GMK1_TSC:mib_status=%d\n", (int)mib_status); + if (atomic_read(&priv->psstatus.snooze_guard)) { atomic_set(&priv->psstatus.snooze_guard, 0); } break; case DOT11_GMK2_TSC: - DPRINTK(2,"DOT11_GMK2_TSC:mib_status=%d\n",(int)mib_status); - if(atomic_read(&priv->psstatus.snooze_guard)){ + DPRINTK(2, "DOT11_GMK2_TSC:mib_status=%d\n", (int)mib_status); + if (atomic_read(&priv->psstatus.snooze_guard)) { atomic_set(&priv->psstatus.snooze_guard, 0); } break; case LOCAL_PMK: - DPRINTK(2,"LOCAL_PMK:mib_status=%d\n",(int)mib_status); + DPRINTK(2, "LOCAL_PMK:mib_status=%d\n", (int)mib_status); break; case LOCAL_GAIN: - DPRINTK(2,"LOCAL_GAIN:mib_status=%d\n",(int)mib_status); + DPRINTK(2, "LOCAL_GAIN:mib_status=%d\n", (int)mib_status); break; #ifdef WPS case LOCAL_WPS_ENABLE: - DPRINTK(2,"LOCAL_WPS_ENABLE:mib_status=%d\n",(int)mib_status); + DPRINTK(2, "LOCAL_WPS_ENABLE:mib_status=%d\n", (int)mib_status); break; case LOCAL_WPS_PROBE_REQ: - DPRINTK(2,"LOCAL_WPS_PROBE_REQ:mib_status=%d\n",(int)mib_status); + DPRINTK(2, "LOCAL_WPS_PROBE_REQ:mib_status=%d\n", + (int)mib_status); break; #endif /* WPS */ case LOCAL_REGION: - DPRINTK(2,"LOCAL_REGION:mib_status=%d\n",(int)mib_status); - default : + DPRINTK(2, "LOCAL_REGION:mib_status=%d\n", (int)mib_status); + default: break; } } @@ -693,14 +749,14 @@ void hostif_mib_set_confirm(struct ks_wlan_private *priv) static void hostif_power_mngmt_confirm(struct ks_wlan_private *priv) { - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); - if(priv->reg.powermgt > POWMGT_ACTIVE_MODE && - priv->reg.operation_mode == MODE_INFRASTRUCTURE){ + if (priv->reg.powermgt > POWMGT_ACTIVE_MODE && + priv->reg.operation_mode == MODE_INFRASTRUCTURE) { atomic_set(&priv->psstatus.confirm_wait, 0); priv->dev_state = DEVICE_STATE_SLEEP; ks_wlan_hw_power_save(priv); - }else{ + } else { priv->dev_state = DEVICE_STATE_READY; } @@ -709,27 +765,28 @@ void hostif_power_mngmt_confirm(struct ks_wlan_private *priv) static void hostif_sleep_confirm(struct ks_wlan_private *priv) { - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); - atomic_set(&priv->sleepstatus.doze_request,1); - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + atomic_set(&priv->sleepstatus.doze_request, 1); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 1); } static void hostif_start_confirm(struct ks_wlan_private *priv) { #ifdef WPS - union iwreq_data wrqu; - wrqu.data.length = 0; - wrqu.data.flags = 0; - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - if((priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ - memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); - DPRINTK(3,"IWEVENT: disconnect\n"); - wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); - } + union iwreq_data wrqu; + wrqu.data.length = 0; + wrqu.data.flags = 0; + wrqu.ap_addr.sa_family = ARPHRD_ETHER; + if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { + memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); + DPRINTK(3, "IWEVENT: disconnect\n"); + wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); + } #endif - DPRINTK(3," scan_ind_count=%d\n",priv->scan_ind_count); + DPRINTK(3, " scan_ind_count=%d\n", priv->scan_ind_count); hostif_sme_enqueue(priv, SME_START_CONFIRM); } @@ -737,29 +794,31 @@ static void hostif_connect_indication(struct ks_wlan_private *priv) { unsigned short connect_code; - unsigned int tmp=0; - unsigned int old_status=priv->connect_status; - struct net_device *netdev=priv->net_dev; + unsigned int tmp = 0; + unsigned int old_status = priv->connect_status; + struct net_device *netdev = priv->net_dev; union iwreq_data wrqu0; connect_code = get_WORD(priv); - switch(connect_code){ - case RESULT_CONNECT: /* connect */ - DPRINTK(3,"connect :: scan_ind_count=%d\n",priv->scan_ind_count); - if(!(priv->connect_status & FORCE_DISCONNECT)) + switch (connect_code) { + case RESULT_CONNECT: /* connect */ + DPRINTK(3, "connect :: scan_ind_count=%d\n", + priv->scan_ind_count); + if (!(priv->connect_status & FORCE_DISCONNECT)) netif_carrier_on(netdev); tmp = FORCE_DISCONNECT & priv->connect_status; priv->connect_status = tmp + CONNECT_STATUS; break; - case RESULT_DISCONNECT: /* disconnect */ - DPRINTK(3,"disconnect :: scan_ind_count=%d\n",priv->scan_ind_count); + case RESULT_DISCONNECT: /* disconnect */ + DPRINTK(3, "disconnect :: scan_ind_count=%d\n", + priv->scan_ind_count); netif_carrier_off(netdev); tmp = FORCE_DISCONNECT & priv->connect_status; priv->connect_status = tmp + DISCONNECT_STATUS; break; default: - DPRINTK(1,"unknown connect_code=%d :: scan_ind_count=%d\n", - connect_code,priv->scan_ind_count); + DPRINTK(1, "unknown connect_code=%d :: scan_ind_count=%d\n", + connect_code, priv->scan_ind_count); netif_carrier_off(netdev); tmp = FORCE_DISCONNECT & priv->connect_status; priv->connect_status = tmp + DISCONNECT_STATUS; @@ -767,25 +826,26 @@ void hostif_connect_indication(struct ks_wlan_private *priv) } get_current_ap(priv, (struct link_ap_info_t *)priv->rxp); - if((priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS && - (old_status & CONNECT_STATUS_MASK)==DISCONNECT_STATUS ){ + if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS && + (old_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) { /* for power save */ atomic_set(&priv->psstatus.snooze_guard, 0); - atomic_set(&priv->psstatus.confirm_wait,0); + atomic_set(&priv->psstatus.confirm_wait, 0); } ks_wlan_do_power_save(priv); wrqu0.data.length = 0; wrqu0.data.flags = 0; wrqu0.ap_addr.sa_family = ARPHRD_ETHER; - if((priv->connect_status & CONNECT_STATUS_MASK)== DISCONNECT_STATUS && - (old_status & CONNECT_STATUS_MASK)==CONNECT_STATUS ){ + if ((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS && + (old_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { memset(wrqu0.ap_addr.sa_data, '\0', ETH_ALEN); - DPRINTK(3,"IWEVENT: disconnect\n"); - DPRINTK(3,"disconnect :: scan_ind_count=%d\n",priv->scan_ind_count); + DPRINTK(3, "IWEVENT: disconnect\n"); + DPRINTK(3, "disconnect :: scan_ind_count=%d\n", + priv->scan_ind_count); wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL); } - priv->scan_ind_count=0; + priv->scan_ind_count = 0; } static @@ -794,45 +854,52 @@ void hostif_scan_indication(struct ks_wlan_private *priv) int i; struct ap_info_t *ap_info; - DPRINTK(3,"scan_ind_count = %d\n", priv->scan_ind_count); + DPRINTK(3, "scan_ind_count = %d\n", priv->scan_ind_count); ap_info = (struct ap_info_t *)(priv->rxp); - if(priv->scan_ind_count!=0){ - for(i=0;iaplist.size;i++){ /* bssid check */ - if(!memcmp(&(ap_info->bssid[0]),&(priv->aplist.ap[i].bssid[0]),ETH_ALEN)){ - if(ap_info->frame_type == FRAME_TYPE_PROBE_RESP) - get_ap_information(priv,ap_info,&(priv->aplist.ap[i])); + if (priv->scan_ind_count != 0) { + for (i = 0; i < priv->aplist.size; i++) { /* bssid check */ + if (!memcmp + (&(ap_info->bssid[0]), + &(priv->aplist.ap[i].bssid[0]), ETH_ALEN)) { + if (ap_info->frame_type == + FRAME_TYPE_PROBE_RESP) + get_ap_information(priv, ap_info, + &(priv->aplist. + ap[i])); return; } } } priv->scan_ind_count++; - if(priv->scan_ind_count < LOCAL_APLIST_MAX+1){ - DPRINTK(4," scan_ind_count=%d :: aplist.size=%d\n", priv->scan_ind_count, priv->aplist.size); - get_ap_information(priv,(struct ap_info_t *)(priv->rxp),&(priv->aplist.ap[priv->scan_ind_count-1])); + if (priv->scan_ind_count < LOCAL_APLIST_MAX + 1) { + DPRINTK(4, " scan_ind_count=%d :: aplist.size=%d\n", + priv->scan_ind_count, priv->aplist.size); + get_ap_information(priv, (struct ap_info_t *)(priv->rxp), + &(priv->aplist. + ap[priv->scan_ind_count - 1])); priv->aplist.size = priv->scan_ind_count; + } else { + DPRINTK(4, " count over :: scan_ind_count=%d\n", + priv->scan_ind_count); } - else{ - DPRINTK(4," count over :: scan_ind_count=%d\n", priv->scan_ind_count); - } - } static void hostif_stop_confirm(struct ks_wlan_private *priv) { - unsigned int tmp=0; - unsigned int old_status=priv->connect_status; - struct net_device *netdev=priv->net_dev; + unsigned int tmp = 0; + unsigned int old_status = priv->connect_status; + struct net_device *netdev = priv->net_dev; union iwreq_data wrqu0; - DPRINTK(3,"\n"); - if(priv->dev_state == DEVICE_STATE_SLEEP) + DPRINTK(3, "\n"); + if (priv->dev_state == DEVICE_STATE_SLEEP) priv->dev_state = DEVICE_STATE_READY; /* disconnect indication */ - if( (priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ + if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { netif_carrier_off(netdev); tmp = FORCE_DISCONNECT & priv->connect_status; priv->connect_status = tmp | DISCONNECT_STATUS; @@ -841,15 +908,17 @@ void hostif_stop_confirm(struct ks_wlan_private *priv) wrqu0.data.length = 0; wrqu0.data.flags = 0; wrqu0.ap_addr.sa_family = ARPHRD_ETHER; - if((priv->connect_status & CONNECT_STATUS_MASK)== DISCONNECT_STATUS && - (old_status & CONNECT_STATUS_MASK)==CONNECT_STATUS ){ + if ((priv->connect_status & CONNECT_STATUS_MASK) == + DISCONNECT_STATUS + && (old_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { memset(wrqu0.ap_addr.sa_data, '\0', ETH_ALEN); - DPRINTK(3,"IWEVENT: disconnect\n"); + DPRINTK(3, "IWEVENT: disconnect\n"); printk("IWEVENT: disconnect\n"); - DPRINTK(3,"disconnect :: scan_ind_count=%d\n",priv->scan_ind_count); + DPRINTK(3, "disconnect :: scan_ind_count=%d\n", + priv->scan_ind_count); wireless_send_event(netdev, SIOCGIWAP, &wrqu0, NULL); } - priv->scan_ind_count=0; + priv->scan_ind_count = 0; } hostif_sme_enqueue(priv, SME_STOP_CONFIRM); @@ -858,8 +927,8 @@ void hostif_stop_confirm(struct ks_wlan_private *priv) static void hostif_ps_adhoc_set_confirm(struct ks_wlan_private *priv) { - DPRINTK(3,"\n"); - priv->infra_status = 0; /* infrastructure mode cancel */ + DPRINTK(3, "\n"); + priv->infra_status = 0; /* infrastructure mode cancel */ hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); } @@ -868,18 +937,18 @@ static void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv) { uint16_t result_code; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); result_code = get_WORD(priv); - DPRINTK(3,"result code = %d\n",result_code); - priv->infra_status = 1; /* infrastructure mode set */ + DPRINTK(3, "result code = %d\n", result_code); + priv->infra_status = 1; /* infrastructure mode set */ hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); } static void hostif_adhoc_set_confirm(struct ks_wlan_private *priv) { - DPRINTK(3,"\n"); - priv->infra_status = 1; /* infrastructure mode set */ + DPRINTK(3, "\n"); + priv->infra_status = 1; /* infrastructure mode set */ hostif_sme_enqueue(priv, SME_MODE_SET_CONFIRM); } @@ -897,33 +966,33 @@ void hostif_associate_indication(struct ks_wlan_private *priv) static const char associnfo_leader0[] = "ASSOCINFO(ReqIEs="; static const char associnfo_leader1[] = " RespIEs="; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); assoc_req = (struct association_request_t *)(priv->rxp); - assoc_resp = (struct association_response_t *)(assoc_req+1); - pb = (unsigned char *)(assoc_resp+1); + assoc_resp = (struct association_response_t *)(assoc_req + 1); + pb = (unsigned char *)(assoc_resp + 1); memset(&wrqu, 0, sizeof(wrqu)); - memcpy(pbuf,associnfo_leader0,sizeof(associnfo_leader0)-1); - wrqu.data.length += sizeof(associnfo_leader0)-1; - pbuf += sizeof(associnfo_leader0)-1; + memcpy(pbuf, associnfo_leader0, sizeof(associnfo_leader0) - 1); + wrqu.data.length += sizeof(associnfo_leader0) - 1; + pbuf += sizeof(associnfo_leader0) - 1; for (i = 0; i < assoc_req->reqIEs_size; i++) - pbuf += sprintf(pbuf, "%02x", *(pb+i)); - wrqu.data.length += (assoc_req->reqIEs_size)*2; + pbuf += sprintf(pbuf, "%02x", *(pb + i)); + wrqu.data.length += (assoc_req->reqIEs_size) * 2; - memcpy(pbuf,associnfo_leader1,sizeof(associnfo_leader1)-1); - wrqu.data.length += sizeof(associnfo_leader1)-1; - pbuf += sizeof(associnfo_leader1)-1; + memcpy(pbuf, associnfo_leader1, sizeof(associnfo_leader1) - 1); + wrqu.data.length += sizeof(associnfo_leader1) - 1; + pbuf += sizeof(associnfo_leader1) - 1; pb += assoc_req->reqIEs_size; for (i = 0; i < assoc_resp->respIEs_size; i++) - pbuf += sprintf(pbuf, "%02x", *(pb+i)); - wrqu.data.length += (assoc_resp->respIEs_size)*2; + pbuf += sprintf(pbuf, "%02x", *(pb + i)); + wrqu.data.length += (assoc_resp->respIEs_size) * 2; pbuf += sprintf(pbuf, ")"); wrqu.data.length += 1; - DPRINTK(3,"IWEVENT:ASSOCINFO\n"); + DPRINTK(3, "IWEVENT:ASSOCINFO\n"); wireless_send_event(priv->net_dev, IWEVCUSTOM, &wrqu, buf); } @@ -934,28 +1003,29 @@ void hostif_bss_scan_confirm(struct ks_wlan_private *priv) struct net_device *dev = priv->net_dev; union iwreq_data wrqu; result_code = get_DWORD(priv); - DPRINTK(2,"result=%d :: scan_ind_count=%d\n", result_code, priv->scan_ind_count); + DPRINTK(2, "result=%d :: scan_ind_count=%d\n", result_code, + priv->scan_ind_count); priv->sme_i.sme_flag &= ~SME_AP_SCAN; hostif_sme_enqueue(priv, SME_BSS_SCAN_CONFIRM); wrqu.data.length = 0; wrqu.data.flags = 0; - DPRINTK(3,"IWEVENT: SCAN CONFIRM\n"); + DPRINTK(3, "IWEVENT: SCAN CONFIRM\n"); wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL); - priv->scan_ind_count=0; + priv->scan_ind_count = 0; } static void hostif_phy_information_confirm(struct ks_wlan_private *priv) { struct iw_statistics *wstats = &priv->wstats; - unsigned char rssi,signal,noise; + unsigned char rssi, signal, noise; unsigned char LinkSpeed; unsigned int TransmittedFrameCount, ReceivedFragmentCount; unsigned int FailedCount, FCSErrorCount; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); rssi = get_BYTE(priv); signal = get_BYTE(priv); noise = get_BYTE(priv); @@ -969,14 +1039,12 @@ void hostif_phy_information_confirm(struct ks_wlan_private *priv) priv->current_rate = (LinkSpeed & RATE_MASK); wstats->qual.qual = signal; wstats->qual.level = 256 - rssi; - wstats->qual.noise = 0; /* invalid noise value */ + wstats->qual.noise = 0; /* invalid noise value */ wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; - DPRINTK(3,"\n rssi=%u\n signal=%u\n LinkSpeed=%ux500Kbps\n \ + DPRINTK(3, "\n rssi=%u\n signal=%u\n LinkSpeed=%ux500Kbps\n \ TransmittedFrameCount=%u\n ReceivedFragmentCount=%u\n FailedCount=%u\n \ - FCSErrorCount=%u\n", - rssi,signal,LinkSpeed,TransmittedFrameCount, - ReceivedFragmentCount,FailedCount,FCSErrorCount); + FCSErrorCount=%u\n", rssi, signal, LinkSpeed, TransmittedFrameCount, ReceivedFragmentCount, FailedCount, FCSErrorCount); /* wake_up_interruptible_all(&priv->confirm_wait); */ complete(&priv->confirm_wait); @@ -985,18 +1053,17 @@ void hostif_phy_information_confirm(struct ks_wlan_private *priv) static void hostif_mic_failure_confirm(struct ks_wlan_private *priv) { - DPRINTK(3,"mic_failure=%u\n",priv->wpa.mic_failure.failure); + DPRINTK(3, "mic_failure=%u\n", priv->wpa.mic_failure.failure); hostif_sme_enqueue(priv, SME_MIC_FAILURE_CONFIRM); } - static void hostif_event_check(struct ks_wlan_private *priv) { unsigned short event; DPRINTK(4, "\n"); - event = get_WORD(priv); /* get event */ + event = get_WORD(priv); /* get event */ switch (event) { case HIF_DATA_IND: hostif_data_indication(priv); @@ -1060,56 +1127,59 @@ void hostif_event_check(struct ks_wlan_private *priv) /* add event to hostt buffer */ priv->hostt.buff[priv->hostt.qtail] = event; - priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE; + priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE; } #define CHECK_ALINE(size) (size%4 ? (size+(4-(size%4))):size) int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) { - unsigned int packet_len=0; + unsigned int packet_len = 0; - unsigned char *buffer=NULL; - unsigned int length=0; + unsigned char *buffer = NULL; + unsigned int length = 0; struct hostif_data_request_t *pp; - unsigned char *p; - int result=0; + unsigned char *p; + int result = 0; unsigned short eth_proto; struct ether_hdr *eth_hdr; struct michel_mic_t michel_mic; - unsigned short keyinfo=0; + unsigned short keyinfo = 0; struct ieee802_1x_hdr *aa1x_hdr; struct wpa_eapol_key *eap_key; struct ethhdr *eth; packet_len = packet->len; if (packet_len > ETH_FRAME_LEN) { - DPRINTK(1,"bad length packet_len=%d \n", packet_len); + DPRINTK(1, "bad length packet_len=%d \n", packet_len); dev_kfree_skb(packet); return -1; } - if(((priv->connect_status & CONNECT_STATUS_MASK)== DISCONNECT_STATUS) || - (priv->connect_status & FORCE_DISCONNECT) || priv->wpa.mic_failure.stop){ - DPRINTK(3," DISCONNECT\n"); - if(netif_queue_stopped(priv->net_dev)) + if (((priv->connect_status & CONNECT_STATUS_MASK) == DISCONNECT_STATUS) + || (priv->connect_status & FORCE_DISCONNECT) + || priv->wpa.mic_failure.stop) { + DPRINTK(3, " DISCONNECT\n"); + if (netif_queue_stopped(priv->net_dev)) netif_wake_queue(priv->net_dev); - if(packet) + if (packet) dev_kfree_skb(packet); return 0; } /* for PowerSave */ - if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ /* power save wakeup */ - if(!netif_queue_stopped(priv->net_dev)) + if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) { /* power save wakeup */ + if (!netif_queue_stopped(priv->net_dev)) netif_stop_queue(priv->net_dev); } DPRINTK(4, "skb_buff length=%d\n", packet_len); - pp = (struct hostif_data_request_t *)kmalloc(hif_align_size(sizeof(*pp)+6+packet_len+8),KS_WLAN_MEM_FLAG ); + pp = (struct hostif_data_request_t *) + kmalloc(hif_align_size(sizeof(*pp) + 6 + packet_len + 8), + KS_WLAN_MEM_FLAG); - if (pp==NULL) { + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); dev_kfree_skb(packet); return -2; @@ -1122,34 +1192,34 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) /* packet check */ eth = (struct ethhdr *)packet->data; - if (memcmp(&priv->eth_addr[0],eth->h_source, ETH_ALEN)){ + if (memcmp(&priv->eth_addr[0], eth->h_source, ETH_ALEN)) { DPRINTK(1, "invalid mac address !!\n"); DPRINTK(1, "ethernet->h_source=%02X:%02X:%02X:%02X:%02X:%02X\n", - eth->h_source[0],eth->h_source[1],eth->h_source[2], - eth->h_source[3],eth->h_source[4],eth->h_source[5]); + eth->h_source[0], eth->h_source[1], eth->h_source[2], + eth->h_source[3], eth->h_source[4], eth->h_source[5]); return -3; } /* MAC address copy */ - memcpy(p, buffer, 12); /* DST/SRC MAC address */ + memcpy(p, buffer, 12); /* DST/SRC MAC address */ p += 12; buffer += 12; length -= 12; /* EtherType/Length check */ - if (*(buffer+1) + (*buffer << 8) > 1500) { + if (*(buffer + 1) + (*buffer << 8) > 1500) { /* ProtocolEAP = *(buffer+1) + (*buffer << 8); */ - /* DPRINTK(2, "Send [SNAP]Type %x\n",ProtocolEAP); */ + /* DPRINTK(2, "Send [SNAP]Type %x\n",ProtocolEAP); */ /* SAP/CTL/OUI(6 byte) add */ - *p++ = 0xAA; /* DSAP */ - *p++ = 0xAA; /* SSAP */ - *p++ = 0x03; /* CTL */ - *p++ = 0x00; /* OUI ("000000") */ - *p++ = 0x00; /* OUI ("000000") */ - *p++ = 0x00; /* OUI ("000000") */ + *p++ = 0xAA; /* DSAP */ + *p++ = 0xAA; /* SSAP */ + *p++ = 0x03; /* CTL */ + *p++ = 0x00; /* OUI ("000000") */ + *p++ = 0x00; /* OUI ("000000") */ + *p++ = 0x00; /* OUI ("000000") */ packet_len += 6; } else { - DPRINTK(4,"DIX\n"); - /* Length(2 byte) delete */ + DPRINTK(4, "DIX\n"); + /* Length(2 byte) delete */ buffer += 2; length -= 2; packet_len -= 2; @@ -1165,61 +1235,68 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) eth_proto = ntohs(eth_hdr->h_proto); /* for MIC FAILUER REPORT check */ - if(eth_proto == ETHER_PROTOCOL_TYPE_EAP && priv->wpa.mic_failure.failure>0){ - aa1x_hdr=(struct ieee802_1x_hdr *)(eth_hdr+1); - if(aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY){ - eap_key = (struct wpa_eapol_key *)(aa1x_hdr+1); - keyinfo=ntohs(eap_key->key_info); + if (eth_proto == ETHER_PROTOCOL_TYPE_EAP + && priv->wpa.mic_failure.failure > 0) { + aa1x_hdr = (struct ieee802_1x_hdr *)(eth_hdr + 1); + if (aa1x_hdr->type == IEEE802_1X_TYPE_EAPOL_KEY) { + eap_key = (struct wpa_eapol_key *)(aa1x_hdr + 1); + keyinfo = ntohs(eap_key->key_info); } } - if (priv->wpa.rsn_enabled && priv->wpa.key[0].key_len){ - if(eth_proto == ETHER_PROTOCOL_TYPE_EAP && !(priv->wpa.key[1].key_len) && - !(priv->wpa.key[2].key_len) && !(priv->wpa.key[3].key_len)){ - pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH); /* no encryption */ - } - else{ - if(priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP){ - MichaelMICFunction( &michel_mic, - (uint8_t*)priv->wpa.key[0].tx_mic_key, - (uint8_t*)&pp->data[0], - (int)packet_len, - (uint8_t)0, /* priority */ - (uint8_t*)michel_mic.Result ); + if (priv->wpa.rsn_enabled && priv->wpa.key[0].key_len) { + if (eth_proto == ETHER_PROTOCOL_TYPE_EAP + && !(priv->wpa.key[1].key_len) + && !(priv->wpa.key[2].key_len) + && !(priv->wpa.key[3].key_len)) { + pp->auth_type = cpu_to_le16((uint16_t) TYPE_AUTH); /* no encryption */ + } else { + if (priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP) { + MichaelMICFunction(&michel_mic, (uint8_t *) priv->wpa.key[0].tx_mic_key, (uint8_t *) & pp->data[0], (int)packet_len, (uint8_t) 0, /* priority */ + (uint8_t *) michel_mic. + Result); memcpy(p, michel_mic.Result, 8); length += 8; packet_len += 8; p += 8; - pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA); + pp->auth_type = + cpu_to_le16((uint16_t) TYPE_DATA); - }else if(priv->wpa.pairwise_suite == IW_AUTH_CIPHER_CCMP){ - pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA); + } else if (priv->wpa.pairwise_suite == + IW_AUTH_CIPHER_CCMP) { + pp->auth_type = + cpu_to_le16((uint16_t) TYPE_DATA); } } - } - else{ - if(eth_proto == ETHER_PROTOCOL_TYPE_EAP) - pp->auth_type = cpu_to_le16((uint16_t)TYPE_AUTH); + } else { + if (eth_proto == ETHER_PROTOCOL_TYPE_EAP) + pp->auth_type = cpu_to_le16((uint16_t) TYPE_AUTH); else - pp->auth_type = cpu_to_le16((uint16_t)TYPE_DATA); + pp->auth_type = cpu_to_le16((uint16_t) TYPE_DATA); } /* header value set */ - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size)+packet_len)); - pp->header.event = cpu_to_le16((uint16_t)HIF_DATA_REQ); + pp->header.size = + cpu_to_le16((uint16_t) + (sizeof(*pp) - sizeof(pp->header.size) + packet_len)); + pp->header.event = cpu_to_le16((uint16_t) HIF_DATA_REQ); /* tx request */ - result = ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + packet_len), - (void *)send_packet_complete, (void *)priv, (void *)packet); + result = + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + packet_len), + (void *)send_packet_complete, (void *)priv, + (void *)packet); /* MIC FAILUER REPORT check */ - if(eth_proto == ETHER_PROTOCOL_TYPE_EAP && priv->wpa.mic_failure.failure>0){ - if(keyinfo & WPA_KEY_INFO_ERROR && keyinfo & WPA_KEY_INFO_REQUEST){ - DPRINTK(3," MIC ERROR Report SET : %04X\n", keyinfo); + if (eth_proto == ETHER_PROTOCOL_TYPE_EAP + && priv->wpa.mic_failure.failure > 0) { + if (keyinfo & WPA_KEY_INFO_ERROR + && keyinfo & WPA_KEY_INFO_REQUEST) { + DPRINTK(3, " MIC ERROR Report SET : %04X\n", keyinfo); hostif_sme_enqueue(priv, SME_MIC_FAILURE_REQUEST); } - if(priv->wpa.mic_failure.failure==2) - priv->wpa.mic_failure.stop=1; + if (priv->wpa.mic_failure.failure == 2) + priv->wpa.mic_failure.stop = 1; } return result; @@ -1231,83 +1308,92 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *packet) } }while(0) static -void hostif_mib_get_request( struct ks_wlan_private *priv, unsigned long mib_attribute) +void hostif_mib_get_request(struct ks_wlan_private *priv, + unsigned long mib_attribute) { struct hostif_mib_get_request_t *pp; DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_mib_get_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { - DPRINTK(3,"allocate memory failed..\n"); + pp = (struct hostif_mib_get_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { + DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_MIB_GET_REQ); - pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_MIB_GET_REQ); + pp->mib_attribute = cpu_to_le32((uint32_t) mib_attribute); /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static -void hostif_mib_set_request( struct ks_wlan_private *priv, unsigned long mib_attribute, - unsigned short size, unsigned short type, - void *vp ) +void hostif_mib_set_request(struct ks_wlan_private *priv, + unsigned long mib_attribute, unsigned short size, + unsigned short type, void *vp) { struct hostif_mib_set_request_t *pp; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); if (priv->dev_state < DEVICE_STATE_BOOT) { - DPRINTK(3,"DeviceRemove\n"); + DPRINTK(3, "DeviceRemove\n"); return; } /* make primitive */ - pp = (struct hostif_mib_set_request_t *)kmalloc(hif_align_size(sizeof(*pp)+size), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_mib_set_request_t *) + kmalloc(hif_align_size(sizeof(*pp) + size), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size)+size)); - pp->header.event = cpu_to_le16((uint16_t)HIF_MIB_SET_REQ); - pp->mib_attribute = cpu_to_le32((uint32_t)mib_attribute); - pp->mib_value.size = cpu_to_le16((uint16_t)size); - pp->mib_value.type = cpu_to_le16((uint16_t)type); + pp->header.size = + cpu_to_le16((uint16_t) + (sizeof(*pp) - sizeof(pp->header.size) + size)); + pp->header.event = cpu_to_le16((uint16_t) HIF_MIB_SET_REQ); + pp->mib_attribute = cpu_to_le32((uint32_t) mib_attribute); + pp->mib_value.size = cpu_to_le16((uint16_t) size); + pp->mib_value.type = cpu_to_le16((uint16_t) type); memcpy(&pp->mib_value.body, vp, size); /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + size), NULL, NULL, + NULL); } static -void hostif_start_request( struct ks_wlan_private *priv, unsigned char mode ) +void hostif_start_request(struct ks_wlan_private *priv, unsigned char mode) { struct hostif_start_request_t *pp; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_start_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_start_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_START_REQ); - pp->mode = cpu_to_le16((uint16_t)mode); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_START_REQ); + pp->mode = cpu_to_le16((uint16_t) mode); /* send to device request */ ps_confirm_wait_inc(priv); ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); priv->aplist.size = 0; - priv->scan_ind_count=0; + priv->scan_ind_count = 0; } static @@ -1316,35 +1402,38 @@ void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv) struct hostif_ps_adhoc_set_request_t *pp; uint16_t capability; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_ps_adhoc_set_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_ps_adhoc_set_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } memset(pp, 0, sizeof(*pp)); - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_PS_ADH_SET_REQ); - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); - pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel)); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_PS_ADH_SET_REQ); + pp->phy_type = cpu_to_le16((uint16_t) (priv->reg.phy_type)); + pp->cts_mode = cpu_to_le16((uint16_t) (priv->reg.cts_mode)); + pp->scan_type = cpu_to_le16((uint16_t) (priv->reg.scan_type)); + pp->channel = cpu_to_le16((uint16_t) (priv->reg.channel)); pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], + priv->reg.rate_set.size); capability = 0x0000; - if (priv->reg.preamble==SHORT_PREAMBLE) { + if (priv->reg.preamble == SHORT_PREAMBLE) { /* short preamble */ capability |= BSS_CAP_SHORT_PREAMBLE; } - capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ - if(priv->reg.phy_type != D_11B_ONLY_MODE){ - capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ - capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM */ + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if (priv->reg.phy_type != D_11B_ONLY_MODE) { + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM */ } - pp->capability = cpu_to_le16((uint16_t)capability); + pp->capability = cpu_to_le16((uint16_t) capability); /* send to device request */ ps_confirm_wait_inc(priv); @@ -1357,38 +1446,42 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv) struct hostif_infrastructure_set_request_t *pp; uint16_t capability; - DPRINTK(3, "ssid.size=%d \n",priv->reg.ssid.size); + DPRINTK(3, "ssid.size=%d \n", priv->reg.ssid.size); /* make primitive */ - pp = (struct hostif_infrastructure_set_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_infrastructure_set_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_INFRA_SET_REQ); - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_INFRA_SET_REQ); + pp->phy_type = cpu_to_le16((uint16_t) (priv->reg.phy_type)); + pp->cts_mode = cpu_to_le16((uint16_t) (priv->reg.cts_mode)); + pp->scan_type = cpu_to_le16((uint16_t) (priv->reg.scan_type)); pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], + priv->reg.rate_set.size); pp->ssid.size = priv->reg.ssid.size; memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); capability = 0x0000; - if (priv->reg.preamble==SHORT_PREAMBLE) { + if (priv->reg.preamble == SHORT_PREAMBLE) { /* short preamble */ capability |= BSS_CAP_SHORT_PREAMBLE; } - capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ - if(priv->reg.phy_type != D_11B_ONLY_MODE){ - capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ - capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if (priv->reg.phy_type != D_11B_ONLY_MODE) { + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ } - pp->capability = cpu_to_le16((uint16_t)capability); - pp->beacon_lost_count = cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count)); - pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type)); + pp->capability = cpu_to_le16((uint16_t) capability); + pp->beacon_lost_count = + cpu_to_le16((uint16_t) (priv->reg.beacon_lost_count)); + pp->auth_type = cpu_to_le16((uint16_t) (priv->reg.authenticate_type)); pp->channel_list.body[0] = 1; pp->channel_list.body[1] = 8; @@ -1403,16 +1496,16 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv) pp->channel_list.body[10] = 6; pp->channel_list.body[11] = 13; pp->channel_list.body[12] = 7; - if(priv->reg.phy_type == D_11G_ONLY_MODE){ + if (priv->reg.phy_type == D_11G_ONLY_MODE) { pp->channel_list.size = 13; - }else{ + } else { pp->channel_list.body[13] = 14; pp->channel_list.size = 14; } /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)),NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) @@ -1420,38 +1513,42 @@ void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) struct hostif_infrastructure_set2_request_t *pp; uint16_t capability; - DPRINTK(2, "ssid.size=%d \n",priv->reg.ssid.size); + DPRINTK(2, "ssid.size=%d \n", priv->reg.ssid.size); /* make primitive */ - pp = (struct hostif_infrastructure_set2_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_infrastructure_set2_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_INFRA_SET2_REQ); - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_INFRA_SET2_REQ); + pp->phy_type = cpu_to_le16((uint16_t) (priv->reg.phy_type)); + pp->cts_mode = cpu_to_le16((uint16_t) (priv->reg.cts_mode)); + pp->scan_type = cpu_to_le16((uint16_t) (priv->reg.scan_type)); pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], + priv->reg.rate_set.size); pp->ssid.size = priv->reg.ssid.size; memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); capability = 0x0000; - if (priv->reg.preamble==SHORT_PREAMBLE) { + if (priv->reg.preamble == SHORT_PREAMBLE) { /* short preamble */ capability |= BSS_CAP_SHORT_PREAMBLE; } - capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ - if(priv->reg.phy_type != D_11B_ONLY_MODE){ - capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ - capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if (priv->reg.phy_type != D_11B_ONLY_MODE) { + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ } - pp->capability = cpu_to_le16((uint16_t)capability); - pp->beacon_lost_count = cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count)); - pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type)); + pp->capability = cpu_to_le16((uint16_t) capability); + pp->beacon_lost_count = + cpu_to_le16((uint16_t) (priv->reg.beacon_lost_count)); + pp->auth_type = cpu_to_le16((uint16_t) (priv->reg.authenticate_type)); pp->channel_list.body[0] = 1; pp->channel_list.body[1] = 8; @@ -1466,9 +1563,9 @@ void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) pp->channel_list.body[10] = 6; pp->channel_list.body[11] = 13; pp->channel_list.body[12] = 7; - if(priv->reg.phy_type == D_11G_ONLY_MODE){ + if (priv->reg.phy_type == D_11G_ONLY_MODE) { pp->channel_list.size = 13; - }else{ + } else { pp->channel_list.body[13] = 14; pp->channel_list.size = 14; } @@ -1477,7 +1574,7 @@ void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)),NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static @@ -1489,38 +1586,41 @@ void hostif_adhoc_set_request(struct ks_wlan_private *priv) DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_adhoc_set_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_adhoc_set_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } memset(pp, 0, sizeof(*pp)); - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_ADH_SET_REQ); - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); - pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel)); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_ADH_SET_REQ); + pp->phy_type = cpu_to_le16((uint16_t) (priv->reg.phy_type)); + pp->cts_mode = cpu_to_le16((uint16_t) (priv->reg.cts_mode)); + pp->scan_type = cpu_to_le16((uint16_t) (priv->reg.scan_type)); + pp->channel = cpu_to_le16((uint16_t) (priv->reg.channel)); pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], + priv->reg.rate_set.size); pp->ssid.size = priv->reg.ssid.size; memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); capability = 0x0000; - if (priv->reg.preamble==SHORT_PREAMBLE) { + if (priv->reg.preamble == SHORT_PREAMBLE) { /* short preamble */ capability |= BSS_CAP_SHORT_PREAMBLE; } - capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ - if(priv->reg.phy_type != D_11B_ONLY_MODE){ - capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ - capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if (priv->reg.phy_type != D_11B_ONLY_MODE) { + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ } - pp->capability = cpu_to_le16((uint16_t)capability); + pp->capability = cpu_to_le16((uint16_t) capability); /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static @@ -1532,33 +1632,36 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv) DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_adhoc_set2_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_adhoc_set2_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } memset(pp, 0, sizeof(*pp)); - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_ADH_SET_REQ); - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_ADH_SET_REQ); + pp->phy_type = cpu_to_le16((uint16_t) (priv->reg.phy_type)); + pp->cts_mode = cpu_to_le16((uint16_t) (priv->reg.cts_mode)); + pp->scan_type = cpu_to_le16((uint16_t) (priv->reg.scan_type)); pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], priv->reg.rate_set.size); + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], + priv->reg.rate_set.size); pp->ssid.size = priv->reg.ssid.size; memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); capability = 0x0000; - if (priv->reg.preamble==SHORT_PREAMBLE) { + if (priv->reg.preamble == SHORT_PREAMBLE) { /* short preamble */ capability |= BSS_CAP_SHORT_PREAMBLE; } - capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ - if(priv->reg.phy_type != D_11B_ONLY_MODE){ - capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ - capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ + capability &= ~(BSS_CAP_PBCC); /* pbcc not support */ + if (priv->reg.phy_type != D_11B_ONLY_MODE) { + capability |= BSS_CAP_SHORT_SLOT_TIME; /* ShortSlotTime support */ + capability &= ~(BSS_CAP_DSSS_OFDM); /* DSSS OFDM not support */ } - pp->capability = cpu_to_le16((uint16_t)capability); + pp->capability = cpu_to_le16((uint16_t) capability); pp->channel_list.body[0] = priv->reg.channel; pp->channel_list.size = 1; @@ -1566,130 +1669,146 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv) /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static -void hostif_stop_request( struct ks_wlan_private *priv ) +void hostif_stop_request(struct ks_wlan_private *priv) { struct hostif_stop_request_t *pp; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_stop_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { - DPRINTK(3,"allocate memory failed..\n"); + pp = (struct hostif_stop_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { + DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_STOP_REQ); /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static -void hostif_phy_information_request( struct ks_wlan_private *priv ) +void hostif_phy_information_request(struct ks_wlan_private *priv) { struct hostif_phy_information_request_t *pp; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); /* make primitive */ - pp = (struct hostif_phy_information_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { + pp = (struct hostif_phy_information_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_PHY_INFO_REQ); - if(priv->reg.phy_info_timer){ - pp->type = cpu_to_le16((uint16_t)TIME_TYPE); - pp->time = cpu_to_le16((uint16_t)(priv->reg.phy_info_timer)); - }else{ - pp->type = cpu_to_le16((uint16_t)NORMAL_TYPE); - pp->time = cpu_to_le16((uint16_t)0); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_PHY_INFO_REQ); + if (priv->reg.phy_info_timer) { + pp->type = cpu_to_le16((uint16_t) TIME_TYPE); + pp->time = cpu_to_le16((uint16_t) (priv->reg.phy_info_timer)); + } else { + pp->type = cpu_to_le16((uint16_t) NORMAL_TYPE); + pp->time = cpu_to_le16((uint16_t) 0); } /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static -void hostif_power_mngmt_request( struct ks_wlan_private *priv, unsigned long mode, - unsigned long wake_up, unsigned long receiveDTIMs ) +void hostif_power_mngmt_request(struct ks_wlan_private *priv, + unsigned long mode, unsigned long wake_up, + unsigned long receiveDTIMs) { struct hostif_power_mngmt_request_t *pp; - DPRINTK(3,"mode=%lu wake_up=%lu receiveDTIMs=%lu\n",mode,wake_up,receiveDTIMs); + DPRINTK(3, "mode=%lu wake_up=%lu receiveDTIMs=%lu\n", mode, wake_up, + receiveDTIMs); /* make primitive */ - pp = (struct hostif_power_mngmt_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { - DPRINTK(3,"allocate memory failed..\n"); + pp = (struct hostif_power_mngmt_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { + DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_POWERMGT_REQ); - pp->mode = cpu_to_le32((uint32_t)mode); - pp->wake_up = cpu_to_le32((uint32_t)wake_up); - pp->receiveDTIMs = cpu_to_le32((uint32_t)receiveDTIMs); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_POWERMGT_REQ); + pp->mode = cpu_to_le32((uint32_t) mode); + pp->wake_up = cpu_to_le32((uint32_t) wake_up); + pp->receiveDTIMs = cpu_to_le32((uint32_t) receiveDTIMs); /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } static -void hostif_sleep_request( struct ks_wlan_private *priv, unsigned long mode) +void hostif_sleep_request(struct ks_wlan_private *priv, unsigned long mode) { struct hostif_sleep_request_t *pp; - DPRINTK(3,"mode=%lu \n",mode); + DPRINTK(3, "mode=%lu \n", mode); - if(mode == SLP_SLEEP){ + if (mode == SLP_SLEEP) { /* make primitive */ - pp = (struct hostif_sleep_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { - DPRINTK(3,"allocate memory failed..\n"); + pp = (struct hostif_sleep_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { + DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_SLEEP_REQ); + pp->header.size = + cpu_to_le16((uint16_t) + (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_SLEEP_REQ); /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); - }else if(mode == SLP_ACTIVE){ - atomic_set(&priv->sleepstatus.wakeup_request,1); - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); - }else{ - DPRINTK(3,"invalid mode %ld \n", mode); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, + NULL); + } else if (mode == SLP_ACTIVE) { + atomic_set(&priv->sleepstatus.wakeup_request, 1); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 1); + } else { + DPRINTK(3, "invalid mode %ld \n", mode); return; } } - static -void hostif_bss_scan_request( struct ks_wlan_private *priv, unsigned long scan_type , uint8_t *scan_ssid, uint8_t scan_ssid_len) +void hostif_bss_scan_request(struct ks_wlan_private *priv, + unsigned long scan_type, uint8_t * scan_ssid, + uint8_t scan_ssid_len) { struct hostif_bss_scan_request_t *pp; - DPRINTK(2,"\n"); + DPRINTK(2, "\n"); /* make primitive */ - pp = (struct hostif_bss_scan_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { - DPRINTK(3,"allocate memory failed..\n"); + pp = (struct hostif_bss_scan_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { + DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_SCAN_REQ); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_SCAN_REQ); pp->scan_type = scan_type; - pp->ch_time_min = cpu_to_le32((uint32_t)110); /* default value */ - pp->ch_time_max = cpu_to_le32((uint32_t)130); /* default value */ + pp->ch_time_min = cpu_to_le32((uint32_t) 110); /* default value */ + pp->ch_time_max = cpu_to_le32((uint32_t) 130); /* default value */ pp->channel_list.body[0] = 1; pp->channel_list.body[1] = 8; pp->channel_list.body[2] = 2; @@ -1703,57 +1822,60 @@ void hostif_bss_scan_request( struct ks_wlan_private *priv, unsigned long scan_t pp->channel_list.body[10] = 6; pp->channel_list.body[11] = 13; pp->channel_list.body[12] = 7; - if(priv->reg.phy_type == D_11G_ONLY_MODE){ + if (priv->reg.phy_type == D_11G_ONLY_MODE) { pp->channel_list.size = 13; - }else{ + } else { pp->channel_list.body[13] = 14; pp->channel_list.size = 14; } pp->ssid.size = 0; /* specified SSID SCAN */ - if(scan_ssid_len > 0 && scan_ssid_len <= 32){ + if (scan_ssid_len > 0 && scan_ssid_len <= 32) { pp->ssid.size = scan_ssid_len; memcpy(&pp->ssid.body[0], scan_ssid, scan_ssid_len); } - /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); priv->aplist.size = 0; - priv->scan_ind_count=0; + priv->scan_ind_count = 0; } static -void hostif_mic_failure_request( struct ks_wlan_private *priv, unsigned short failure_count, - unsigned short timer ) +void hostif_mic_failure_request(struct ks_wlan_private *priv, + unsigned short failure_count, + unsigned short timer) { struct hostif_mic_failure_request_t *pp; - DPRINTK(3,"count=%d :: timer=%d\n",failure_count,timer); + DPRINTK(3, "count=%d :: timer=%d\n", failure_count, timer); /* make primitive */ - pp = (struct hostif_mic_failure_request_t *)kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG ); - if (pp==NULL) { - DPRINTK(3,"allocate memory failed..\n"); + pp = (struct hostif_mic_failure_request_t *) + kmalloc(hif_align_size(sizeof(*pp)), KS_WLAN_MEM_FLAG); + if (pp == NULL) { + DPRINTK(3, "allocate memory failed..\n"); return; } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_MIC_FAILURE_REQ); - pp->failure_count = cpu_to_le16((uint16_t)failure_count); - pp->timer = cpu_to_le16((uint16_t)timer); + pp->header.size = + cpu_to_le16((uint16_t) (sizeof(*pp) - sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_MIC_FAILURE_REQ); + pp->failure_count = cpu_to_le16((uint16_t) failure_count); + pp->timer = cpu_to_le16((uint16_t) timer); /* send to device request */ ps_confirm_wait_inc(priv); - ks_wlan_hw_tx( priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); + ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp)), NULL, NULL, NULL); } /* Device I/O Recieve indicate */ -static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p, unsigned int size) +static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p, + unsigned int size) { if (priv->device_open_status) { - spin_lock(&priv->dev_read_lock); /* request spin lock */ + spin_lock(&priv->dev_read_lock); /* request spin lock */ priv->dev_data[atomic_read(&priv->rec_count)] = p; priv->dev_size[atomic_read(&priv->rec_count)] = size; @@ -1762,86 +1884,92 @@ static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p, unsign atomic_inc(&priv->event_count); } atomic_inc(&priv->rec_count); - if (atomic_read(&priv->rec_count)==DEVICE_STOCK_COUNT) + if (atomic_read(&priv->rec_count) == DEVICE_STOCK_COUNT) atomic_set(&priv->rec_count, 0); - wake_up_interruptible_all(&priv->devread_wait); + wake_up_interruptible_all(&priv->devread_wait); /* release spin lock */ spin_unlock(&priv->dev_read_lock); } } -void hostif_receive( struct ks_wlan_private *priv, unsigned char *p, unsigned int size ) +void hostif_receive(struct ks_wlan_private *priv, unsigned char *p, + unsigned int size) { - DPRINTK(4,"\n"); + DPRINTK(4, "\n"); devio_rec_ind(priv, p, size); priv->rxp = p; priv->rx_size = size; - if (get_WORD(priv) == priv->rx_size) { /* length check !! */ - hostif_event_check(priv); /* event check */ + if (get_WORD(priv) == priv->rx_size) { /* length check !! */ + hostif_event_check(priv); /* event check */ } } - static void hostif_sme_set_wep(struct ks_wlan_private *priv, int type) { uint32_t val; - switch(type){ + switch (type) { case SME_WEP_INDEX_REQUEST: - val = cpu_to_le32((uint32_t)(priv->reg.wep_index)); + val = cpu_to_le32((uint32_t) (priv->reg.wep_index)); hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID, - sizeof(val), MIB_VALUE_TYPE_INT, - &val ); + sizeof(val), MIB_VALUE_TYPE_INT, &val); break; case SME_WEP_KEY1_REQUEST: - if(!priv->wpa.wpa_enabled) - hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE1, - priv->reg.wep_key[0].size, MIB_VALUE_TYPE_OSTRING, - &priv->reg.wep_key[0].val[0] ); + if (!priv->wpa.wpa_enabled) + hostif_mib_set_request(priv, + DOT11_WEP_DEFAULT_KEY_VALUE1, + priv->reg.wep_key[0].size, + MIB_VALUE_TYPE_OSTRING, + &priv->reg.wep_key[0].val[0]); break; case SME_WEP_KEY2_REQUEST: - if(!priv->wpa.wpa_enabled) - hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE2, - priv->reg.wep_key[1].size, MIB_VALUE_TYPE_OSTRING, + if (!priv->wpa.wpa_enabled) + hostif_mib_set_request(priv, + DOT11_WEP_DEFAULT_KEY_VALUE2, + priv->reg.wep_key[1].size, + MIB_VALUE_TYPE_OSTRING, &priv->reg.wep_key[1].val[0]); break; case SME_WEP_KEY3_REQUEST: - if(!priv->wpa.wpa_enabled) - hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE3, - priv->reg.wep_key[2].size, MIB_VALUE_TYPE_OSTRING, - &priv->reg.wep_key[2].val[0] ); + if (!priv->wpa.wpa_enabled) + hostif_mib_set_request(priv, + DOT11_WEP_DEFAULT_KEY_VALUE3, + priv->reg.wep_key[2].size, + MIB_VALUE_TYPE_OSTRING, + &priv->reg.wep_key[2].val[0]); break; case SME_WEP_KEY4_REQUEST: - if(!priv->wpa.wpa_enabled) - hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE4, - priv->reg.wep_key[3].size, MIB_VALUE_TYPE_OSTRING, + if (!priv->wpa.wpa_enabled) + hostif_mib_set_request(priv, + DOT11_WEP_DEFAULT_KEY_VALUE4, + priv->reg.wep_key[3].size, + MIB_VALUE_TYPE_OSTRING, &priv->reg.wep_key[3].val[0]); break; case SME_WEP_FLAG_REQUEST: - val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked)); + val = cpu_to_le32((uint32_t) (priv->reg.privacy_invoked)); hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED, - sizeof(val), MIB_VALUE_TYPE_BOOL, - &val ); + sizeof(val), MIB_VALUE_TYPE_BOOL, &val); break; } - return ; + return; } struct wpa_suite_t { unsigned short size; unsigned char suite[4][CIPHER_ID_LEN]; -} __attribute__((packed)); +} __attribute__ ((packed)); struct rsn_mode_t { uint32_t rsn_mode; uint16_t rsn_capability; -} __attribute__((packed)); +} __attribute__ ((packed)); static void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type) @@ -1850,140 +1978,172 @@ void hostif_sme_set_rsn(struct ks_wlan_private *priv, int type) struct rsn_mode_t rsn_mode; uint32_t val; - memset(&wpa_suite,0,sizeof(wpa_suite)); + memset(&wpa_suite, 0, sizeof(wpa_suite)); - switch(type){ + switch (type) { case SME_RSN_UCAST_REQUEST: - wpa_suite.size=cpu_to_le16((uint16_t)1); - switch(priv->wpa.pairwise_suite){ + wpa_suite.size = cpu_to_le16((uint16_t) 1); + switch (priv->wpa.pairwise_suite) { case IW_AUTH_CIPHER_NONE: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_NONE,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_NONE,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_NONE, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_WEP40: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_WEP40,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_WEP40,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_TKIP: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_TKIP,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_TKIP,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_CCMP: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_CCMP,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_CCMP,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_WEP104: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_WEP104,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_WEP104,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN); break; } hostif_mib_set_request(priv, DOT11_RSN_CONFIG_UNICAST_CIPHER, - sizeof(wpa_suite.size)+CIPHER_ID_LEN*wpa_suite.size, + sizeof(wpa_suite.size) + + CIPHER_ID_LEN * wpa_suite.size, MIB_VALUE_TYPE_OSTRING, &wpa_suite); break; case SME_RSN_MCAST_REQUEST: - switch(priv->wpa.group_suite){ + switch (priv->wpa.group_suite) { case IW_AUTH_CIPHER_NONE: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_NONE,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_NONE, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_NONE,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_NONE, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_WEP40: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_WEP40,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_WEP40, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_WEP40,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_WEP40, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_TKIP: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_TKIP,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_TKIP, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_TKIP,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_TKIP, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_CCMP: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_CCMP,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_CCMP, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_CCMP,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_CCMP, CIPHER_ID_LEN); break; case IW_AUTH_CIPHER_WEP104: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA2_WEP104,CIPHER_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA2_WEP104, CIPHER_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],CIPHER_ID_WPA_WEP104,CIPHER_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + CIPHER_ID_WPA_WEP104, CIPHER_ID_LEN); break; } hostif_mib_set_request(priv, DOT11_RSN_CONFIG_MULTICAST_CIPHER, CIPHER_ID_LEN, MIB_VALUE_TYPE_OSTRING, - &wpa_suite.suite[0][0] ); + &wpa_suite.suite[0][0]); break; case SME_RSN_AUTH_REQUEST: - wpa_suite.size=cpu_to_le16((uint16_t)1); - switch(priv->wpa.key_mgmt_suite){ + wpa_suite.size = cpu_to_le16((uint16_t) 1); + switch (priv->wpa.key_mgmt_suite) { case IW_AUTH_KEY_MGMT_802_1X: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA2_1X,KEY_MGMT_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA2_1X, KEY_MGMT_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA_1X,KEY_MGMT_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA_1X, KEY_MGMT_ID_LEN); break; case IW_AUTH_KEY_MGMT_PSK: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA2_PSK,KEY_MGMT_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA2_PSK, KEY_MGMT_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA_PSK,KEY_MGMT_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA_PSK, KEY_MGMT_ID_LEN); break; case 0: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA2_NONE,KEY_MGMT_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA2_NONE, KEY_MGMT_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA_NONE,KEY_MGMT_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA_NONE, KEY_MGMT_ID_LEN); break; case 4: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA2_WPANONE,KEY_MGMT_ID_LEN); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA2_WPANONE, + KEY_MGMT_ID_LEN); else - memcpy(&wpa_suite.suite[0][0],KEY_MGMT_ID_WPA_WPANONE,KEY_MGMT_ID_LEN); + memcpy(&wpa_suite.suite[0][0], + KEY_MGMT_ID_WPA_WPANONE, + KEY_MGMT_ID_LEN); break; } hostif_mib_set_request(priv, DOT11_RSN_CONFIG_AUTH_SUITE, - sizeof(wpa_suite.size)+KEY_MGMT_ID_LEN*wpa_suite.size, + sizeof(wpa_suite.size) + + KEY_MGMT_ID_LEN * wpa_suite.size, MIB_VALUE_TYPE_OSTRING, &wpa_suite); break; case SME_RSN_ENABLED_REQUEST: - val = cpu_to_le32((uint32_t)(priv->wpa.rsn_enabled)); + val = cpu_to_le32((uint32_t) (priv->wpa.rsn_enabled)); hostif_mib_set_request(priv, DOT11_RSN_ENABLED, - sizeof(val), MIB_VALUE_TYPE_BOOL, - &val ); + sizeof(val), MIB_VALUE_TYPE_BOOL, &val); break; case SME_RSN_MODE_REQUEST: - if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2){ - rsn_mode.rsn_mode = cpu_to_le32((uint32_t)RSN_MODE_WPA2); - rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0); - } - else if(priv->wpa.version == IW_AUTH_WPA_VERSION_WPA){ - rsn_mode.rsn_mode = cpu_to_le32((uint32_t)RSN_MODE_WPA); - rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0); - } - else{ - rsn_mode.rsn_mode = cpu_to_le32((uint32_t)RSN_MODE_NONE); - rsn_mode.rsn_capability = cpu_to_le16((uint16_t)0); + if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2) { + rsn_mode.rsn_mode = + cpu_to_le32((uint32_t) RSN_MODE_WPA2); + rsn_mode.rsn_capability = cpu_to_le16((uint16_t) 0); + } else if (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA) { + rsn_mode.rsn_mode = + cpu_to_le32((uint32_t) RSN_MODE_WPA); + rsn_mode.rsn_capability = cpu_to_le16((uint16_t) 0); + } else { + rsn_mode.rsn_mode = + cpu_to_le32((uint32_t) RSN_MODE_NONE); + rsn_mode.rsn_capability = cpu_to_le16((uint16_t) 0); } - hostif_mib_set_request(priv, LOCAL_RSN_MODE,sizeof(rsn_mode), - MIB_VALUE_TYPE_OSTRING,&rsn_mode ); + hostif_mib_set_request(priv, LOCAL_RSN_MODE, sizeof(rsn_mode), + MIB_VALUE_TYPE_OSTRING, &rsn_mode); break; } @@ -1995,64 +2155,70 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv) { unsigned char rate_size; unsigned char rate_octet[RATE_SET_MAX_SIZE]; - int i=0; + int i = 0; - /* rate setting if rate segging is auto for changing phy_type (#94)*/ - if(priv->reg.tx_rate == TX_RATE_FULL_AUTO){ - if(priv->reg.phy_type == D_11B_ONLY_MODE){ + /* rate setting if rate segging is auto for changing phy_type (#94) */ + if (priv->reg.tx_rate == TX_RATE_FULL_AUTO) { + if (priv->reg.phy_type == D_11B_ONLY_MODE) { priv->reg.rate_set.body[3] = TX_RATE_11M; priv->reg.rate_set.body[2] = TX_RATE_5M; - priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; - priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE; priv->reg.rate_set.size = 4; - }else{ /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ + } else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ priv->reg.rate_set.body[11] = TX_RATE_54M; priv->reg.rate_set.body[10] = TX_RATE_48M; priv->reg.rate_set.body[9] = TX_RATE_36M; priv->reg.rate_set.body[8] = TX_RATE_18M; priv->reg.rate_set.body[7] = TX_RATE_9M; - priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; - priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; - priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; - priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; - priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; - priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; - priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.rate_set.body[6] = TX_RATE_24M | BASIC_RATE; + priv->reg.rate_set.body[5] = TX_RATE_12M | BASIC_RATE; + priv->reg.rate_set.body[4] = TX_RATE_6M | BASIC_RATE; + priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE; + priv->reg.rate_set.body[2] = TX_RATE_5M | BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE; priv->reg.rate_set.size = 12; } } /* rate mask by phy setting */ - if(priv->reg.phy_type == D_11B_ONLY_MODE){ - for(i=0;ireg.rate_set.size;i++){ - if(IS_11B_RATE(priv->reg.rate_set.body[i])){ - if((priv->reg.rate_set.body[i] & RATE_MASK) >= TX_RATE_5M) - rate_octet[i] = priv->reg.rate_set.body[i] & RATE_MASK ; + if (priv->reg.phy_type == D_11B_ONLY_MODE) { + for (i = 0; i < priv->reg.rate_set.size; i++) { + if (IS_11B_RATE(priv->reg.rate_set.body[i])) { + if ((priv->reg.rate_set.body[i] & RATE_MASK) >= + TX_RATE_5M) + rate_octet[i] = + priv->reg.rate_set. + body[i] & RATE_MASK; else - rate_octet[i] = priv->reg.rate_set.body[i]; - } - else + rate_octet[i] = + priv->reg.rate_set.body[i]; + } else break; } - }else{ /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ - for(i=0;ireg.rate_set.size;i++){ - if(IS_11BG_RATE(priv->reg.rate_set.body[i])){ - if(IS_OFDM_EXT_RATE(priv->reg.rate_set.body[i])) - rate_octet[i] = priv->reg.rate_set.body[i] & RATE_MASK ; + } else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ + for (i = 0; i < priv->reg.rate_set.size; i++) { + if (IS_11BG_RATE(priv->reg.rate_set.body[i])) { + if (IS_OFDM_EXT_RATE + (priv->reg.rate_set.body[i])) + rate_octet[i] = + priv->reg.rate_set. + body[i] & RATE_MASK; else - rate_octet[i] = priv->reg.rate_set.body[i]; - } - else + rate_octet[i] = + priv->reg.rate_set.body[i]; + } else break; } } rate_size = i; - if(rate_size==0){ - if(priv->reg.phy_type == D_11G_ONLY_MODE) - rate_octet[0]=TX_RATE_6M | BASIC_RATE; + if (rate_size == 0) { + if (priv->reg.phy_type == D_11G_ONLY_MODE) + rate_octet[0] = TX_RATE_6M | BASIC_RATE; else - rate_octet[0]=TX_RATE_2M | BASIC_RATE; + rate_octet[0] = TX_RATE_2M | BASIC_RATE; rate_size = 1; } @@ -2060,84 +2226,93 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv) priv->reg.rate_set.size = rate_size; memcpy(&priv->reg.rate_set.body[0], &rate_octet[0], rate_size); - switch ( priv->reg.operation_mode ) { + switch (priv->reg.operation_mode) { case MODE_PSEUDO_ADHOC: /* Pseudo Ad-Hoc mode */ hostif_ps_adhoc_set_request(priv); break; case MODE_INFRASTRUCTURE: /* Infrastructure mode */ - if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) { + if (!is_valid_ether_addr((u8 *) priv->reg.bssid)) { hostif_infrastructure_set_request(priv); - } - else { + } else { hostif_infrastructure_set2_request(priv); - DPRINTK(2, "Infra bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", - priv->reg.bssid[0],priv->reg.bssid[1],priv->reg.bssid[2], - priv->reg.bssid[3],priv->reg.bssid[4],priv->reg.bssid[5]); + DPRINTK(2, + "Infra bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", + priv->reg.bssid[0], priv->reg.bssid[1], + priv->reg.bssid[2], priv->reg.bssid[3], + priv->reg.bssid[4], priv->reg.bssid[5]); } break; case MODE_ADHOC: /* IEEE802.11 Ad-Hoc mode */ - if (!is_valid_ether_addr((u8 *)priv->reg.bssid)) { + if (!is_valid_ether_addr((u8 *) priv->reg.bssid)) { hostif_adhoc_set_request(priv); - } - else { + } else { hostif_adhoc_set2_request(priv); - DPRINTK(2, "Adhoc bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", - priv->reg.bssid[0],priv->reg.bssid[1],priv->reg.bssid[2], - priv->reg.bssid[3],priv->reg.bssid[4],priv->reg.bssid[5]); + DPRINTK(2, + "Adhoc bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", + priv->reg.bssid[0], priv->reg.bssid[1], + priv->reg.bssid[2], priv->reg.bssid[3], + priv->reg.bssid[4], priv->reg.bssid[5]); } break; default: break; } - return ; + return; } static void hostif_sme_multicast_set(struct ks_wlan_private *priv) { - struct net_device *dev = priv->net_dev; + struct net_device *dev = priv->net_dev; int mc_count; struct netdev_hw_addr *ha; - char set_address[NIC_MAX_MCAST_LIST*ETH_ALEN]; + char set_address[NIC_MAX_MCAST_LIST * ETH_ALEN]; unsigned long filter_type; int i = 0; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); spin_lock(&priv->multicast_spin); - memset(set_address, 0, NIC_MAX_MCAST_LIST*ETH_ALEN); - - if (dev->flags & IFF_PROMISC ){ - filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_PROMISC); - hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, sizeof(filter_type), - MIB_VALUE_TYPE_BOOL, &filter_type); - } - else if ((netdev_mc_count(dev) > NIC_MAX_MCAST_LIST) || (dev->flags & IFF_ALLMULTI)){ - filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCASTALL); - hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, sizeof(filter_type), - MIB_VALUE_TYPE_BOOL, &filter_type); - } - else { - if (priv->sme_i.sme_flag & SME_MULTICAST){ + memset(set_address, 0, NIC_MAX_MCAST_LIST * ETH_ALEN); + + if (dev->flags & IFF_PROMISC) { + filter_type = cpu_to_le32((uint32_t) MCAST_FILTER_PROMISC); + hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, + sizeof(filter_type), MIB_VALUE_TYPE_BOOL, + &filter_type); + } else if ((netdev_mc_count(dev) > NIC_MAX_MCAST_LIST) + || (dev->flags & IFF_ALLMULTI)) { + filter_type = cpu_to_le32((uint32_t) MCAST_FILTER_MCASTALL); + hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, + sizeof(filter_type), MIB_VALUE_TYPE_BOOL, + &filter_type); + } else { + if (priv->sme_i.sme_flag & SME_MULTICAST) { mc_count = netdev_mc_count(dev); netdev_for_each_mc_addr(ha, dev) { - memcpy(&set_address[i*ETH_ALEN], ha->addr, ETH_ALEN); + memcpy(&set_address[i * ETH_ALEN], ha->addr, + ETH_ALEN); i++; } priv->sme_i.sme_flag &= ~SME_MULTICAST; hostif_mib_set_request(priv, LOCAL_MULTICAST_ADDRESS, - (ETH_ALEN*mc_count), MIB_VALUE_TYPE_OSTRING, &set_address[0]); - }else { - filter_type = cpu_to_le32((uint32_t)MCAST_FILTER_MCAST); + (ETH_ALEN * mc_count), + MIB_VALUE_TYPE_OSTRING, + &set_address[0]); + } else { + filter_type = + cpu_to_le32((uint32_t) MCAST_FILTER_MCAST); priv->sme_i.sme_flag |= SME_MULTICAST; - hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, sizeof(filter_type), - MIB_VALUE_TYPE_BOOL, &filter_type); + hostif_mib_set_request(priv, LOCAL_MULTICAST_FILTER, + sizeof(filter_type), + MIB_VALUE_TYPE_BOOL, + &filter_type); } } @@ -2148,17 +2323,17 @@ void hostif_sme_multicast_set(struct ks_wlan_private *priv) static void hostif_sme_powermgt_set(struct ks_wlan_private *priv) { - unsigned long mode,wake_up,receiveDTIMs ; + unsigned long mode, wake_up, receiveDTIMs; - DPRINTK(3,"\n"); - switch(priv->reg.powermgt){ + DPRINTK(3, "\n"); + switch (priv->reg.powermgt) { case POWMGT_ACTIVE_MODE: mode = POWER_ACTIVE; wake_up = 0; receiveDTIMs = 0; break; case POWMGT_SAVE1_MODE: - if(priv->reg.operation_mode == MODE_INFRASTRUCTURE){ + if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) { mode = POWER_SAVE; wake_up = 0; receiveDTIMs = 0; @@ -2169,7 +2344,7 @@ void hostif_sme_powermgt_set(struct ks_wlan_private *priv) } break; case POWMGT_SAVE2_MODE: - if(priv->reg.operation_mode == MODE_INFRASTRUCTURE){ + if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) { mode = POWER_SAVE; wake_up = 0; receiveDTIMs = 1; @@ -2193,8 +2368,8 @@ void hostif_sme_powermgt_set(struct ks_wlan_private *priv) static void hostif_sme_sleep_set(struct ks_wlan_private *priv) { - DPRINTK(3,"\n"); - switch(priv->sleep_mode){ + DPRINTK(3, "\n"); + switch (priv->sleep_mode) { case SLP_SLEEP: hostif_sleep_request(priv, priv->sleep_mode); break; @@ -2212,53 +2387,55 @@ static void hostif_sme_set_key(struct ks_wlan_private *priv, int type) { uint32_t val; - switch(type){ + switch (type) { case SME_SET_FLAG: - val = cpu_to_le32((uint32_t)(priv->reg.privacy_invoked)); + val = cpu_to_le32((uint32_t) (priv->reg.privacy_invoked)); hostif_mib_set_request(priv, DOT11_PRIVACY_INVOKED, - sizeof(val), MIB_VALUE_TYPE_BOOL, - &val ); + sizeof(val), MIB_VALUE_TYPE_BOOL, &val); break; case SME_SET_TXKEY: - val = cpu_to_le32((uint32_t)(priv->wpa.txkey)); + val = cpu_to_le32((uint32_t) (priv->wpa.txkey)); hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_ID, - sizeof(val), MIB_VALUE_TYPE_INT, - &val ); + sizeof(val), MIB_VALUE_TYPE_INT, &val); break; case SME_SET_KEY1: hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE1, - priv->wpa.key[0].key_len, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[0].key_val[0] ); + priv->wpa.key[0].key_len, + MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[0].key_val[0]); break; case SME_SET_KEY2: hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE2, - priv->wpa.key[1].key_len, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[1].key_val[0] ); + priv->wpa.key[1].key_len, + MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[1].key_val[0]); break; case SME_SET_KEY3: hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE3, - priv->wpa.key[2].key_len, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[2].key_val[0] ); + priv->wpa.key[2].key_len, + MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[2].key_val[0]); break; case SME_SET_KEY4: hostif_mib_set_request(priv, DOT11_WEP_DEFAULT_KEY_VALUE4, - priv->wpa.key[3].key_len, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[3].key_val[0] ); + priv->wpa.key[3].key_len, + MIB_VALUE_TYPE_OSTRING, + &priv->wpa.key[3].key_val[0]); break; case SME_SET_PMK_TSC: hostif_mib_set_request(priv, DOT11_PMK_TSC, WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[0].rx_seq[0] ); + &priv->wpa.key[0].rx_seq[0]); break; case SME_SET_GMK1_TSC: hostif_mib_set_request(priv, DOT11_GMK1_TSC, WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[1].rx_seq[0] ); + &priv->wpa.key[1].rx_seq[0]); break; case SME_SET_GMK2_TSC: hostif_mib_set_request(priv, DOT11_GMK2_TSC, WPA_RX_SEQ_LEN, MIB_VALUE_TYPE_OSTRING, - &priv->wpa.key[2].rx_seq[0] ); + &priv->wpa.key[2].rx_seq[0]); break; } return; @@ -2270,28 +2447,31 @@ void hostif_sme_set_pmksa(struct ks_wlan_private *priv) struct pmk_cache_t { uint16_t size; struct { - uint8_t bssid[ETH_ALEN]; - uint8_t pmkid[IW_PMKID_LEN]; - } __attribute__((packed)) list[PMK_LIST_MAX]; - } __attribute__((packed)) pmkcache; + uint8_t bssid[ETH_ALEN]; + uint8_t pmkid[IW_PMKID_LEN]; + } __attribute__ ((packed)) list[PMK_LIST_MAX]; + } __attribute__ ((packed)) pmkcache; struct pmk_t *pmk; struct list_head *ptr; int i; - DPRINTK(4,"pmklist.size=%d\n",priv->pmklist.size); - i=0; - list_for_each(ptr, &priv->pmklist.head){ + DPRINTK(4, "pmklist.size=%d\n", priv->pmklist.size); + i = 0; + list_for_each(ptr, &priv->pmklist.head) { pmk = list_entry(ptr, struct pmk_t, list); - if(ibssid, ETH_ALEN); - memcpy(pmkcache.list[i].pmkid, pmk->pmkid, IW_PMKID_LEN); + memcpy(pmkcache.list[i].pmkid, pmk->pmkid, + IW_PMKID_LEN); i++; } } - pmkcache.size = cpu_to_le16((uint16_t)(priv->pmklist.size)); + pmkcache.size = cpu_to_le16((uint16_t) (priv->pmklist.size)); hostif_mib_set_request(priv, LOCAL_PMK, - sizeof(priv->pmklist.size)+(ETH_ALEN+IW_PMKID_LEN)*(priv->pmklist.size), - MIB_VALUE_TYPE_OSTRING,&pmkcache ); + sizeof(priv->pmklist.size) + (ETH_ALEN + + IW_PMKID_LEN) * + (priv->pmklist.size), MIB_VALUE_TYPE_OSTRING, + &pmkcache); } /* execute sme */ @@ -2300,10 +2480,10 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) { uint32_t val; - DPRINTK(3,"event=%d\n",event); + DPRINTK(3, "event=%d\n", event); switch (event) { case SME_START: - if ( priv->dev_state == DEVICE_STATE_BOOT ){ + if (priv->dev_state == DEVICE_STATE_BOOT) { hostif_mib_get_request(priv, DOT11_MAC_ADDRESS); } break; @@ -2312,10 +2492,12 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) break; case SME_MACADDRESS_SET_REQUEST: hostif_mib_set_request(priv, LOCAL_CURRENTADDRESS, ETH_ALEN, - MIB_VALUE_TYPE_OSTRING, &priv->eth_addr[0]); + MIB_VALUE_TYPE_OSTRING, + &priv->eth_addr[0]); break; case SME_BSS_SCAN_REQUEST: - hostif_bss_scan_request(priv, priv->reg.scan_type, priv->scan_ssid, priv->scan_ssid_len); + hostif_bss_scan_request(priv, priv->reg.scan_type, + priv->scan_ssid, priv->scan_ssid_len); break; case SME_POW_MNGMT_REQUEST: hostif_sme_powermgt_set(priv); @@ -2324,30 +2506,36 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) hostif_phy_information_request(priv); break; case SME_MIC_FAILURE_REQUEST: - if(priv->wpa.mic_failure.failure == 1){ - hostif_mic_failure_request(priv, priv->wpa.mic_failure.failure-1, 0); - }else if(priv->wpa.mic_failure.failure == 2){ - hostif_mic_failure_request(priv, priv->wpa.mic_failure.failure-1, - priv->wpa.mic_failure.counter); - }else - DPRINTK(4,"SME_MIC_FAILURE_REQUEST: failure count=%u error?\n", + if (priv->wpa.mic_failure.failure == 1) { + hostif_mic_failure_request(priv, + priv->wpa.mic_failure. + failure - 1, 0); + } else if (priv->wpa.mic_failure.failure == 2) { + hostif_mic_failure_request(priv, + priv->wpa.mic_failure. + failure - 1, + priv->wpa.mic_failure. + counter); + } else + DPRINTK(4, + "SME_MIC_FAILURE_REQUEST: failure count=%u error?\n", priv->wpa.mic_failure.failure); break; case SME_MIC_FAILURE_CONFIRM: - if(priv->wpa.mic_failure.failure == 2){ - if(priv->wpa.mic_failure.stop) + if (priv->wpa.mic_failure.failure == 2) { + if (priv->wpa.mic_failure.stop) priv->wpa.mic_failure.stop = 0; priv->wpa.mic_failure.failure = 0; - hostif_start_request( priv, priv->reg.operation_mode ); + hostif_start_request(priv, priv->reg.operation_mode); } break; case SME_GET_MAC_ADDRESS: - if ( priv->dev_state == DEVICE_STATE_BOOT ){ + if (priv->dev_state == DEVICE_STATE_BOOT) { hostif_mib_get_request(priv, DOT11_PRODUCT_VERSION); } break; case SME_GET_PRODUCT_VERSION: - if ( priv->dev_state == DEVICE_STATE_BOOT ){ + if (priv->dev_state == DEVICE_STATE_BOOT) { priv->dev_state = DEVICE_STATE_PREINIT; } break; @@ -2355,33 +2543,40 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) hostif_stop_request(priv); break; case SME_RTS_THRESHOLD_REQUEST: - val = cpu_to_le32((uint32_t)(priv->reg.rts)); + val = cpu_to_le32((uint32_t) (priv->reg.rts)); hostif_mib_set_request(priv, DOT11_RTS_THRESHOLD, - sizeof(val), MIB_VALUE_TYPE_INT, - &val ); + sizeof(val), MIB_VALUE_TYPE_INT, &val); break; case SME_FRAGMENTATION_THRESHOLD_REQUEST: - val = cpu_to_le32((uint32_t)(priv->reg.fragment)); + val = cpu_to_le32((uint32_t) (priv->reg.fragment)); hostif_mib_set_request(priv, DOT11_FRAGMENTATION_THRESHOLD, - sizeof(val), MIB_VALUE_TYPE_INT, - &val ); + sizeof(val), MIB_VALUE_TYPE_INT, &val); break; - case SME_WEP_INDEX_REQUEST: case SME_WEP_KEY1_REQUEST: - case SME_WEP_KEY2_REQUEST: case SME_WEP_KEY3_REQUEST: - case SME_WEP_KEY4_REQUEST: case SME_WEP_FLAG_REQUEST: - hostif_sme_set_wep(priv,event); + case SME_WEP_INDEX_REQUEST: + case SME_WEP_KEY1_REQUEST: + case SME_WEP_KEY2_REQUEST: + case SME_WEP_KEY3_REQUEST: + case SME_WEP_KEY4_REQUEST: + case SME_WEP_FLAG_REQUEST: + hostif_sme_set_wep(priv, event); break; - case SME_RSN_UCAST_REQUEST: case SME_RSN_MCAST_REQUEST: - case SME_RSN_AUTH_REQUEST: case SME_RSN_ENABLED_REQUEST: + case SME_RSN_UCAST_REQUEST: + case SME_RSN_MCAST_REQUEST: + case SME_RSN_AUTH_REQUEST: + case SME_RSN_ENABLED_REQUEST: case SME_RSN_MODE_REQUEST: - hostif_sme_set_rsn(priv,event); + hostif_sme_set_rsn(priv, event); break; - case SME_SET_FLAG: case SME_SET_TXKEY: - case SME_SET_KEY1: case SME_SET_KEY2: - case SME_SET_KEY3: case SME_SET_KEY4: - case SME_SET_PMK_TSC: case SME_SET_GMK1_TSC: + case SME_SET_FLAG: + case SME_SET_TXKEY: + case SME_SET_KEY1: + case SME_SET_KEY2: + case SME_SET_KEY3: + case SME_SET_KEY4: + case SME_SET_PMK_TSC: + case SME_SET_GMK1_TSC: case SME_SET_GMK2_TSC: - hostif_sme_set_key(priv,event); + hostif_sme_set_key(priv, event); break; case SME_SET_PMKSA: hostif_sme_set_pmksa(priv); @@ -2390,7 +2585,8 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) case SME_WPS_ENABLE_REQUEST: hostif_mib_set_request(priv, LOCAL_WPS_ENABLE, sizeof(priv->wps.wps_enabled), - MIB_VALUE_TYPE_INT, &priv->wps.wps_enabled ); + MIB_VALUE_TYPE_INT, + &priv->wps.wps_enabled); break; case SME_WPS_PROBE_REQUEST: hostif_mib_set_request(priv, LOCAL_WPS_PROBE_REQ, @@ -2403,8 +2599,8 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) break; case SME_SET_GAIN: hostif_mib_set_request(priv, LOCAL_GAIN, - sizeof(priv->gain), MIB_VALUE_TYPE_OSTRING, - &priv->gain); + sizeof(priv->gain), + MIB_VALUE_TYPE_OSTRING, &priv->gain); break; case SME_GET_GAIN: hostif_mib_get_request(priv, LOCAL_GAIN); @@ -2414,13 +2610,13 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) hostif_mib_get_request(priv, LOCAL_EEPROM_SUM); break; case SME_START_REQUEST: - hostif_start_request( priv, priv->reg.operation_mode ); + hostif_start_request(priv, priv->reg.operation_mode); break; case SME_START_CONFIRM: /* for power save */ atomic_set(&priv->psstatus.snooze_guard, 0); - atomic_set(&priv->psstatus.confirm_wait,0); - if ( priv->dev_state == DEVICE_STATE_PREINIT ){ + atomic_set(&priv->psstatus.confirm_wait, 0); + if (priv->dev_state == DEVICE_STATE_PREINIT) { priv->dev_state = DEVICE_STATE_INIT; } /* wake_up_interruptible_all(&priv->confirm_wait); */ @@ -2430,10 +2626,9 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) hostif_sme_sleep_set(priv); break; case SME_SET_REGION: - val = cpu_to_le32((uint32_t)(priv->region)); + val = cpu_to_le32((uint32_t) (priv->region)); hostif_mib_set_request(priv, LOCAL_REGION, - sizeof(val), MIB_VALUE_TYPE_INT, - &val ); + sizeof(val), MIB_VALUE_TYPE_INT, &val); break; case SME_MULTICAST_CONFIRM: case SME_BSS_SCAN_CONFIRM: @@ -2442,11 +2637,16 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) case SME_STOP_CONFIRM: case SME_RTS_THRESHOLD_CONFIRM: case SME_FRAGMENTATION_THRESHOLD_CONFIRM: - case SME_WEP_INDEX_CONFIRM: case SME_WEP_KEY1_CONFIRM: - case SME_WEP_KEY2_CONFIRM: case SME_WEP_KEY3_CONFIRM: - case SME_WEP_KEY4_CONFIRM: case SME_WEP_FLAG_CONFIRM: - case SME_RSN_UCAST_CONFIRM: case SME_RSN_MCAST_CONFIRM: - case SME_RSN_AUTH_CONFIRM: case SME_RSN_ENABLED_CONFIRM: + case SME_WEP_INDEX_CONFIRM: + case SME_WEP_KEY1_CONFIRM: + case SME_WEP_KEY2_CONFIRM: + case SME_WEP_KEY3_CONFIRM: + case SME_WEP_KEY4_CONFIRM: + case SME_WEP_FLAG_CONFIRM: + case SME_RSN_UCAST_CONFIRM: + case SME_RSN_MCAST_CONFIRM: + case SME_RSN_AUTH_CONFIRM: + case SME_RSN_ENABLED_CONFIRM: case SME_RSN_MODE_CONFIRM: case SME_MODE_SET_CONFIRM: break; @@ -2457,18 +2657,21 @@ void hostif_sme_execute(struct ks_wlan_private *priv, int event) } static -void hostif_sme_task( unsigned long dev ) +void hostif_sme_task(unsigned long dev) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); - if(priv->dev_state >= DEVICE_STATE_BOOT){ - if (0 < cnt_smeqbody(priv) && priv->dev_state >= DEVICE_STATE_BOOT) { - hostif_sme_execute(priv, priv->sme_i.event_buff[priv->sme_i.qhead]); + if (priv->dev_state >= DEVICE_STATE_BOOT) { + if (0 < cnt_smeqbody(priv) + && priv->dev_state >= DEVICE_STATE_BOOT) { + hostif_sme_execute(priv, + priv->sme_i.event_buff[priv->sme_i. + qhead]); inc_smeqhead(priv); if (0 < cnt_smeqbody(priv)) - tasklet_schedule(&priv->sme_task); + tasklet_schedule(&priv->sme_task); } } return; @@ -2477,9 +2680,7 @@ void hostif_sme_task( unsigned long dev ) /* send to Station Management Entity module */ void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event) { - DPRINTK(3,"\n"); - - + DPRINTK(3, "\n"); /* enqueue sme event */ if (cnt_smeqbody(priv) < (SME_EVENT_BUFF_SIZE - 1)) { @@ -2500,16 +2701,16 @@ void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event) } -int hostif_init( struct ks_wlan_private *priv ) +int hostif_init(struct ks_wlan_private *priv) { - int rc=0; + int rc = 0; int i; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); - priv->aplist.size =0; - for(i=0;iaplist.ap[i]),0,sizeof(struct local_ap_t)); + priv->aplist.size = 0; + for (i = 0; i < LOCAL_APLIST_MAX; i++) + memset(&(priv->aplist.ap[i]), 0, sizeof(struct local_ap_t)); priv->infra_status = 0; priv->current_rate = 4; priv->connect_status = DISCONNECT_STATUS; @@ -2517,7 +2718,7 @@ int hostif_init( struct ks_wlan_private *priv ) spin_lock_init(&priv->multicast_spin); spin_lock_init(&priv->dev_read_lock); - init_waitqueue_head (&priv->devread_wait); + init_waitqueue_head(&priv->devread_wait); priv->dev_count = 0; atomic_set(&priv->event_count, 0); atomic_set(&priv->rec_count, 0); @@ -2539,7 +2740,7 @@ int hostif_init( struct ks_wlan_private *priv ) priv->wpa.mic_failure.stop = 0; memset(&(priv->pmklist), 0, sizeof(priv->pmklist)); INIT_LIST_HEAD(&priv->pmklist.head); - for(i=0;ipmklist.pmk[i].list); priv->sme_i.sme_status = SME_IDLE; @@ -2547,7 +2748,7 @@ int hostif_init( struct ks_wlan_private *priv ) #ifdef KS_WLAN_DEBUG priv->sme_i.max_event_count = 0; #endif - spin_lock_init(&priv->sme_i.sme_spin); + spin_lock_init(&priv->sme_i.sme_spin); priv->sme_i.sme_flag = 0; tasklet_init(&priv->sme_task, hostif_sme_task, (unsigned long)priv); @@ -2555,9 +2756,8 @@ int hostif_init( struct ks_wlan_private *priv ) return rc; } -void hostif_exit( struct ks_wlan_private *priv ) +void hostif_exit(struct ks_wlan_private *priv) { tasklet_kill(&priv->sme_task); return; } - -- cgit v1.1 From e3d7482607befe01c08cf0030c91d4f15a44db1d Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:31 +0200 Subject: staging: ks7010: indent ks_hostif.h Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.h | 525 ++++++++++++++++++------------------- 1 file changed, 262 insertions(+), 263 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h index c333ce1..01de478 100644 --- a/drivers/staging/ks7010/ks_hostif.h +++ b/drivers/staging/ks7010/ks_hostif.h @@ -62,141 +62,140 @@ */ struct hostif_hdr { - uint16_t size; - uint16_t event; -} __attribute__((packed)); + uint16_t size; + uint16_t event; +} __attribute__ ((packed)); struct hostif_data_request_t { struct hostif_hdr header; - uint16_t auth_type; + uint16_t auth_type; #define TYPE_DATA 0x0000 #define TYPE_AUTH 0x0001 - uint16_t reserved; - uint8_t data[0]; -} __attribute__((packed)); + uint16_t reserved; + uint8_t data[0]; +} __attribute__ ((packed)); struct hostif_data_indication_t { struct hostif_hdr header; - uint16_t auth_type; + uint16_t auth_type; /* #define TYPE_DATA 0x0000 */ #define TYPE_PMK1 0x0001 #define TYPE_GMK1 0x0002 #define TYPE_GMK2 0x0003 - uint16_t reserved; - uint8_t data[0]; -} __attribute__((packed)); + uint16_t reserved; + uint8_t data[0]; +} __attribute__ ((packed)); #define CHANNEL_LIST_MAX_SIZE 14 struct channel_list_t { - uint8_t size; - uint8_t body[CHANNEL_LIST_MAX_SIZE]; - uint8_t pad; -} __attribute__((packed)); + uint8_t size; + uint8_t body[CHANNEL_LIST_MAX_SIZE]; + uint8_t pad; +} __attribute__ ((packed)); /* MIB Attribute */ -#define DOT11_MAC_ADDRESS 0x21010100 /* MAC Address (R) */ -#define DOT11_PRODUCT_VERSION 0x31024100 /* FirmWare Version (R)*/ -#define DOT11_RTS_THRESHOLD 0x21020100 /* RTS Threshold (R/W) */ -#define DOT11_FRAGMENTATION_THRESHOLD 0x21050100 /* Fragment Threshold (R/W) */ -#define DOT11_PRIVACY_INVOKED 0x15010100 /* WEP ON/OFF (W) */ -#define DOT11_WEP_DEFAULT_KEY_ID 0x15020100 /* WEP Index (W) */ -#define DOT11_WEP_DEFAULT_KEY_VALUE1 0x13020101 /* WEP Key#1(TKIP AES: PairwiseTemporalKey) (W) */ -#define DOT11_WEP_DEFAULT_KEY_VALUE2 0x13020102 /* WEP Key#2(TKIP AES: GroupKey1) (W) */ -#define DOT11_WEP_DEFAULT_KEY_VALUE3 0x13020103 /* WEP Key#3(TKIP AES: GroupKey2) (W) */ -#define DOT11_WEP_DEFAULT_KEY_VALUE4 0x13020104 /* WEP Key#4 (W) */ -#define DOT11_WEP_LIST 0x13020100 /* WEP LIST */ -#define DOT11_DESIRED_SSID 0x11090100 /* SSID */ -#define DOT11_CURRENT_CHANNEL 0x45010100 /* channel set */ -#define DOT11_OPERATION_RATE_SET 0x11110100 /* rate set */ - -#define LOCAL_AP_SEARCH_INTEAVAL 0xF1010100 /* AP search interval (R/W) */ -#define LOCAL_CURRENTADDRESS 0xF1050100 /* MAC Adress change (W) */ -#define LOCAL_MULTICAST_ADDRESS 0xF1060100 /* Multicast Adress (W) */ -#define LOCAL_MULTICAST_FILTER 0xF1060200 /* Multicast Adress Filter enable/disable (W) */ -#define LOCAL_SEARCHED_AP_LIST 0xF1030100 /* AP list (R) */ -#define LOCAL_LINK_AP_STATUS 0xF1040100 /* Link AP status (R) */ -#define LOCAL_PACKET_STATISTICS 0xF1020100 /* tx,rx packets statistics */ -#define LOCAL_AP_SCAN_LIST_TYPE_SET 0xF1030200 /* AP_SCAN_LIST_TYPE */ - -#define DOT11_RSN_ENABLED 0x15070100 /* WPA enable/disable (W) */ -#define LOCAL_RSN_MODE 0x56010100 /* RSN mode WPA/WPA2 (W) */ -#define DOT11_RSN_CONFIG_MULTICAST_CIPHER 0x51040100 /* GroupKeyCipherSuite (W) */ -#define DOT11_RSN_CONFIG_UNICAST_CIPHER 0x52020100 /* PairwiseKeyCipherSuite (W) */ -#define DOT11_RSN_CONFIG_AUTH_SUITE 0x53020100 /* AuthenticationKeyManagementSuite (W) */ -#define DOT11_RSN_CONFIG_VERSION 0x51020100 /* RSN version (W) */ -#define LOCAL_RSN_CONFIG_ALL 0x5F010100 /* RSN CONFIG ALL (W) */ -#define DOT11_PMK_TSC 0x55010100 /* PMK_TSC (W) */ -#define DOT11_GMK1_TSC 0x55010101 /* GMK1_TSC (W) */ -#define DOT11_GMK2_TSC 0x55010102 /* GMK2_TSC (W) */ -#define DOT11_GMK3_TSC 0x55010103 /* GMK3_TSC */ -#define LOCAL_PMK 0x58010100 /* Pairwise Master Key cache (W) */ - -#define LOCAL_REGION 0xF10A0100 /* Region setting */ +#define DOT11_MAC_ADDRESS 0x21010100 /* MAC Address (R) */ +#define DOT11_PRODUCT_VERSION 0x31024100 /* FirmWare Version (R) */ +#define DOT11_RTS_THRESHOLD 0x21020100 /* RTS Threshold (R/W) */ +#define DOT11_FRAGMENTATION_THRESHOLD 0x21050100 /* Fragment Threshold (R/W) */ +#define DOT11_PRIVACY_INVOKED 0x15010100 /* WEP ON/OFF (W) */ +#define DOT11_WEP_DEFAULT_KEY_ID 0x15020100 /* WEP Index (W) */ +#define DOT11_WEP_DEFAULT_KEY_VALUE1 0x13020101 /* WEP Key#1(TKIP AES: PairwiseTemporalKey) (W) */ +#define DOT11_WEP_DEFAULT_KEY_VALUE2 0x13020102 /* WEP Key#2(TKIP AES: GroupKey1) (W) */ +#define DOT11_WEP_DEFAULT_KEY_VALUE3 0x13020103 /* WEP Key#3(TKIP AES: GroupKey2) (W) */ +#define DOT11_WEP_DEFAULT_KEY_VALUE4 0x13020104 /* WEP Key#4 (W) */ +#define DOT11_WEP_LIST 0x13020100 /* WEP LIST */ +#define DOT11_DESIRED_SSID 0x11090100 /* SSID */ +#define DOT11_CURRENT_CHANNEL 0x45010100 /* channel set */ +#define DOT11_OPERATION_RATE_SET 0x11110100 /* rate set */ + +#define LOCAL_AP_SEARCH_INTEAVAL 0xF1010100 /* AP search interval (R/W) */ +#define LOCAL_CURRENTADDRESS 0xF1050100 /* MAC Adress change (W) */ +#define LOCAL_MULTICAST_ADDRESS 0xF1060100 /* Multicast Adress (W) */ +#define LOCAL_MULTICAST_FILTER 0xF1060200 /* Multicast Adress Filter enable/disable (W) */ +#define LOCAL_SEARCHED_AP_LIST 0xF1030100 /* AP list (R) */ +#define LOCAL_LINK_AP_STATUS 0xF1040100 /* Link AP status (R) */ +#define LOCAL_PACKET_STATISTICS 0xF1020100 /* tx,rx packets statistics */ +#define LOCAL_AP_SCAN_LIST_TYPE_SET 0xF1030200 /* AP_SCAN_LIST_TYPE */ + +#define DOT11_RSN_ENABLED 0x15070100 /* WPA enable/disable (W) */ +#define LOCAL_RSN_MODE 0x56010100 /* RSN mode WPA/WPA2 (W) */ +#define DOT11_RSN_CONFIG_MULTICAST_CIPHER 0x51040100 /* GroupKeyCipherSuite (W) */ +#define DOT11_RSN_CONFIG_UNICAST_CIPHER 0x52020100 /* PairwiseKeyCipherSuite (W) */ +#define DOT11_RSN_CONFIG_AUTH_SUITE 0x53020100 /* AuthenticationKeyManagementSuite (W) */ +#define DOT11_RSN_CONFIG_VERSION 0x51020100 /* RSN version (W) */ +#define LOCAL_RSN_CONFIG_ALL 0x5F010100 /* RSN CONFIG ALL (W) */ +#define DOT11_PMK_TSC 0x55010100 /* PMK_TSC (W) */ +#define DOT11_GMK1_TSC 0x55010101 /* GMK1_TSC (W) */ +#define DOT11_GMK2_TSC 0x55010102 /* GMK2_TSC (W) */ +#define DOT11_GMK3_TSC 0x55010103 /* GMK3_TSC */ +#define LOCAL_PMK 0x58010100 /* Pairwise Master Key cache (W) */ + +#define LOCAL_REGION 0xF10A0100 /* Region setting */ #ifdef WPS -#define LOCAL_WPS_ENABLE 0xF10B0100 /* WiFi Protected Setup */ -#define LOCAL_WPS_PROBE_REQ 0xF10C0100 /* WPS Probe Request */ +#define LOCAL_WPS_ENABLE 0xF10B0100 /* WiFi Protected Setup */ +#define LOCAL_WPS_PROBE_REQ 0xF10C0100 /* WPS Probe Request */ #endif /* WPS */ -#define LOCAL_GAIN 0xF10D0100 /* Carrer sense threshold for demo ato show */ -#define LOCAL_EEPROM_SUM 0xF10E0100 /* EEPROM checksum information */ +#define LOCAL_GAIN 0xF10D0100 /* Carrer sense threshold for demo ato show */ +#define LOCAL_EEPROM_SUM 0xF10E0100 /* EEPROM checksum information */ struct hostif_mib_get_request_t { struct hostif_hdr header; - uint32_t mib_attribute; -} __attribute__((packed)); - + uint32_t mib_attribute; +} __attribute__ ((packed)); struct hostif_mib_value_t { - uint16_t size; - uint16_t type; + uint16_t size; + uint16_t type; #define MIB_VALUE_TYPE_NULL 0 #define MIB_VALUE_TYPE_INT 1 #define MIB_VALUE_TYPE_BOOL 2 #define MIB_VALUE_TYPE_COUNT32 3 #define MIB_VALUE_TYPE_OSTRING 4 - uint8_t body[0]; -} __attribute__((packed)); + uint8_t body[0]; +} __attribute__ ((packed)); struct hostif_mib_get_confirm_t { struct hostif_hdr header; - uint32_t mib_status; + uint32_t mib_status; #define MIB_SUCCESS 0 #define MIB_INVALID 1 #define MIB_READ_ONLY 2 #define MIB_WRITE_ONLY 3 - uint32_t mib_attribute; + uint32_t mib_attribute; struct hostif_mib_value_t mib_value; -} __attribute__((packed)); +} __attribute__ ((packed)); struct hostif_mib_set_request_t { struct hostif_hdr header; - uint32_t mib_attribute; + uint32_t mib_attribute; struct hostif_mib_value_t mib_value; -} __attribute__((packed)); +} __attribute__ ((packed)); struct hostif_mib_set_confirm_t { struct hostif_hdr header; - uint32_t mib_status; - uint32_t mib_attribute; -} __attribute__((packed)); + uint32_t mib_status; + uint32_t mib_attribute; +} __attribute__ ((packed)); struct hostif_power_mngmt_request_t { struct hostif_hdr header; - uint32_t mode; + uint32_t mode; #define POWER_ACTIVE 1 #define POWER_SAVE 2 - uint32_t wake_up; + uint32_t wake_up; #define SLEEP_FALSE 0 -#define SLEEP_TRUE 1 /* not used */ - uint32_t receiveDTIMs; +#define SLEEP_TRUE 1 /* not used */ + uint32_t receiveDTIMs; #define DTIM_FALSE 0 #define DTIM_TRUE 1 -} __attribute__((packed)); +} __attribute__ ((packed)); /* power management mode */ enum { - POWMGT_ACTIVE_MODE=0, + POWMGT_ACTIVE_MODE = 0, POWMGT_SAVE1_MODE, POWMGT_SAVE2_MODE }; @@ -209,84 +208,83 @@ enum { struct hostif_power_mngmt_confirm_t { struct hostif_hdr header; - uint16_t result_code; -} __attribute__((packed)); + uint16_t result_code; +} __attribute__ ((packed)); struct hostif_start_request_t { struct hostif_hdr header; - uint16_t mode; + uint16_t mode; #define MODE_PSEUDO_ADHOC 0 #define MODE_INFRASTRUCTURE 1 -#define MODE_AP 2 /* not used */ +#define MODE_AP 2 /* not used */ #define MODE_ADHOC 3 -} __attribute__((packed)); +} __attribute__ ((packed)); struct hostif_start_confirm_t { struct hostif_hdr header; - uint16_t result_code; -} __attribute__((packed)); + uint16_t result_code; +} __attribute__ ((packed)); #define SSID_MAX_SIZE 32 struct ssid_t { - uint8_t size; - uint8_t body[SSID_MAX_SIZE]; - uint8_t ssid_pad; -} __attribute__((packed)); + uint8_t size; + uint8_t body[SSID_MAX_SIZE]; + uint8_t ssid_pad; +} __attribute__ ((packed)); #define RATE_SET_MAX_SIZE 16 struct rate_set8_t { - uint8_t size; - uint8_t body[8]; - uint8_t rate_pad; -} __attribute__((packed)); + uint8_t size; + uint8_t body[8]; + uint8_t rate_pad; +} __attribute__ ((packed)); struct FhParms_t { - uint16_t dwellTime; - uint8_t hopSet; - uint8_t hopPattern; - uint8_t hopIndex; -} __attribute__((packed)); + uint16_t dwellTime; + uint8_t hopSet; + uint8_t hopPattern; + uint8_t hopIndex; +} __attribute__ ((packed)); struct DsParms_t { - uint8_t channel; -} __attribute__((packed)); + uint8_t channel; +} __attribute__ ((packed)); struct CfParms_t { - uint8_t count; - uint8_t period; - uint16_t maxDuration; - uint16_t durRemaining; -} __attribute__((packed)); + uint8_t count; + uint8_t period; + uint16_t maxDuration; + uint16_t durRemaining; +} __attribute__ ((packed)); struct IbssParms_t { - uint16_t atimWindow; -} __attribute__((packed)); - + uint16_t atimWindow; +} __attribute__ ((packed)); struct rsn_t { - uint8_t size; + uint8_t size; #define RSN_BODY_SIZE 64 - uint8_t body[RSN_BODY_SIZE]; -} __attribute__((packed)); + uint8_t body[RSN_BODY_SIZE]; +} __attribute__ ((packed)); struct ErpParams_t { uint8_t erp_info; -} __attribute__((packed)); - -struct rate_set16_t{ - uint8_t size; - uint8_t body[16]; - uint8_t rate_pad; -} __attribute__((packed)); - -struct ap_info_t{ - uint8_t bssid[6]; /* +00 */ - uint8_t rssi; /* +06 */ - uint8_t sq; /* +07 */ - uint8_t noise; /* +08 */ - uint8_t pad0; /* +09 */ - uint16_t beacon_period; /* +10 */ - uint16_t capability; /* +12 */ +} __attribute__ ((packed)); + +struct rate_set16_t { + uint8_t size; + uint8_t body[16]; + uint8_t rate_pad; +} __attribute__ ((packed)); + +struct ap_info_t { + uint8_t bssid[6]; /* +00 */ + uint8_t rssi; /* +06 */ + uint8_t sq; /* +07 */ + uint8_t noise; /* +08 */ + uint8_t pad0; /* +09 */ + uint16_t beacon_period; /* +10 */ + uint16_t capability; /* +12 */ #define BSS_CAP_ESS (1<<0) #define BSS_CAP_IBSS (1<<1) #define BSS_CAP_CF_POLABLE (1<<2) @@ -297,178 +295,176 @@ struct ap_info_t{ #define BSS_CAP_CHANNEL_AGILITY (1<<7) #define BSS_CAP_SHORT_SLOT_TIME (1<<10) #define BSS_CAP_DSSS_OFDM (1<<13) - uint8_t frame_type; /* +14 */ - uint8_t ch_info; /* +15 */ + uint8_t frame_type; /* +14 */ + uint8_t ch_info; /* +15 */ #define FRAME_TYPE_BEACON 0x80 #define FRAME_TYPE_PROBE_RESP 0x50 - uint16_t body_size; /* +16 */ - uint8_t body[1024]; /* +18 */ - /* +1032 */ -} __attribute__((packed)); - -struct link_ap_info_t{ - uint8_t bssid[6]; /* +00 */ - uint8_t rssi; /* +06 */ - uint8_t sq; /* +07 */ - uint8_t noise; /* +08 */ - uint8_t pad0; /* +09 */ - uint16_t beacon_period; /* +10 */ - uint16_t capability; /* +12 */ - struct rate_set8_t rate_set; /* +14 */ - struct FhParms_t fh_parameter; /* +24 */ - struct DsParms_t ds_parameter; /* +29 */ - struct CfParms_t cf_parameter; /* +30 */ + uint16_t body_size; /* +16 */ + uint8_t body[1024]; /* +18 */ + /* +1032 */ +} __attribute__ ((packed)); + +struct link_ap_info_t { + uint8_t bssid[6]; /* +00 */ + uint8_t rssi; /* +06 */ + uint8_t sq; /* +07 */ + uint8_t noise; /* +08 */ + uint8_t pad0; /* +09 */ + uint16_t beacon_period; /* +10 */ + uint16_t capability; /* +12 */ + struct rate_set8_t rate_set; /* +14 */ + struct FhParms_t fh_parameter; /* +24 */ + struct DsParms_t ds_parameter; /* +29 */ + struct CfParms_t cf_parameter; /* +30 */ struct IbssParms_t ibss_parameter; /* +36 */ struct ErpParams_t erp_parameter; /* +38 */ - uint8_t pad1; /* +39 */ - struct rate_set8_t ext_rate_set; /* +40 */ - uint8_t DTIM_period; /* +50 */ - uint8_t rsn_mode; /* +51 */ + uint8_t pad1; /* +39 */ + struct rate_set8_t ext_rate_set; /* +40 */ + uint8_t DTIM_period; /* +50 */ + uint8_t rsn_mode; /* +51 */ #define RSN_MODE_NONE 0 #define RSN_MODE_WPA 1 #define RSN_MODE_WPA2 2 struct { - uint8_t size; /* +52 */ - uint8_t body[128]; /* +53 */ - } __attribute__((packed)) rsn; -} __attribute__((packed)); + uint8_t size; /* +52 */ + uint8_t body[128]; /* +53 */ + } __attribute__ ((packed)) rsn; +} __attribute__ ((packed)); struct hostif_connect_indication_t { struct hostif_hdr header; - uint16_t connect_code; + uint16_t connect_code; #define RESULT_CONNECT 0 #define RESULT_DISCONNECT 1 struct link_ap_info_t link_ap_info; -} __attribute__((packed)); +} __attribute__ ((packed)); struct hostif_stop_request_t { struct hostif_hdr header; -} __attribute__((packed)); +} __attribute__ ((packed)); struct hostif_stop_confirm_t { struct hostif_hdr header; - uint16_t result_code; -} __attribute__((packed)); + uint16_t result_code; +} __attribute__ ((packed)); struct hostif_ps_adhoc_set_request_t { struct hostif_hdr header; - uint16_t phy_type; + uint16_t phy_type; #define D_11B_ONLY_MODE 0 #define D_11G_ONLY_MODE 1 #define D_11BG_COMPATIBLE_MODE 2 #define D_11A_ONLY_MODE 3 - uint16_t cts_mode; + uint16_t cts_mode; #define CTS_MODE_FALSE 0 #define CTS_MODE_TRUE 1 - uint16_t channel; + uint16_t channel; struct rate_set16_t rate_set; - uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 - * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ - uint16_t scan_type; -} __attribute__((packed)); + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t scan_type; +} __attribute__ ((packed)); struct hostif_ps_adhoc_set_confirm_t { struct hostif_hdr header; - uint16_t result_code; -} __attribute__((packed)); + uint16_t result_code; +} __attribute__ ((packed)); struct hostif_infrastructure_set_request_t { struct hostif_hdr header; - uint16_t phy_type; - uint16_t cts_mode; + uint16_t phy_type; + uint16_t cts_mode; struct rate_set16_t rate_set; struct ssid_t ssid; - uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 - * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ - uint16_t beacon_lost_count; - uint16_t auth_type; + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t beacon_lost_count; + uint16_t auth_type; #define AUTH_TYPE_OPEN_SYSTEM 0 #define AUTH_TYPE_SHARED_KEY 1 struct channel_list_t channel_list; - uint16_t scan_type; -} __attribute__((packed)); + uint16_t scan_type; +} __attribute__ ((packed)); struct hostif_infrastructure_set2_request_t { struct hostif_hdr header; - uint16_t phy_type; - uint16_t cts_mode; + uint16_t phy_type; + uint16_t cts_mode; struct rate_set16_t rate_set; struct ssid_t ssid; - uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 - * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ - uint16_t beacon_lost_count; - uint16_t auth_type; + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t beacon_lost_count; + uint16_t auth_type; #define AUTH_TYPE_OPEN_SYSTEM 0 #define AUTH_TYPE_SHARED_KEY 1 struct channel_list_t channel_list; - uint16_t scan_type; - uint8_t bssid[ETH_ALEN]; -} __attribute__((packed)); - + uint16_t scan_type; + uint8_t bssid[ETH_ALEN]; +} __attribute__ ((packed)); struct hostif_infrastructure_set_confirm_t { struct hostif_hdr header; - uint16_t result_code; -} __attribute__((packed)); + uint16_t result_code; +} __attribute__ ((packed)); struct hostif_adhoc_set_request_t { struct hostif_hdr header; - uint16_t phy_type; - uint16_t cts_mode; - uint16_t channel; + uint16_t phy_type; + uint16_t cts_mode; + uint16_t channel; struct rate_set16_t rate_set; struct ssid_t ssid; - uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 - * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ - uint16_t scan_type; -} __attribute__((packed)); + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t scan_type; +} __attribute__ ((packed)); struct hostif_adhoc_set2_request_t { struct hostif_hdr header; - uint16_t phy_type; - uint16_t cts_mode; - uint16_t reserved; + uint16_t phy_type; + uint16_t cts_mode; + uint16_t reserved; struct rate_set16_t rate_set; struct ssid_t ssid; - uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 - * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ - uint16_t scan_type; + uint16_t capability; /* bit5:preamble bit6:pbcc pbcc not supported always 0 + * bit10:ShortSlotTime bit13:DSSS-OFDM DSSS-OFDM not supported always 0 */ + uint16_t scan_type; struct channel_list_t channel_list; - uint8_t bssid[ETH_ALEN]; -} __attribute__((packed)); + uint8_t bssid[ETH_ALEN]; +} __attribute__ ((packed)); struct hostif_adhoc_set_confirm_t { struct hostif_hdr header; - uint16_t result_code; -} __attribute__((packed)); - + uint16_t result_code; +} __attribute__ ((packed)); struct last_associate_t { - uint8_t type; - uint8_t status; -} __attribute__((packed)); + uint8_t type; + uint8_t status; +} __attribute__ ((packed)); struct association_request_t { - uint8_t type; + uint8_t type; #define FRAME_TYPE_ASSOC_REQ 0x00 #define FRAME_TYPE_REASSOC_REQ 0x20 - uint8_t pad; - uint16_t capability; - uint16_t listen_interval; - uint8_t ap_address[6]; - uint16_t reqIEs_size; -} __attribute__((packed)); + uint8_t pad; + uint16_t capability; + uint16_t listen_interval; + uint8_t ap_address[6]; + uint16_t reqIEs_size; +} __attribute__ ((packed)); struct association_response_t { - uint8_t type; + uint8_t type; #define FRAME_TYPE_ASSOC_RESP 0x10 #define FRAME_TYPE_REASSOC_RESP 0x30 - uint8_t pad; - uint16_t capability; - uint16_t status; - uint16_t association_id; - uint16_t respIEs_size; -} __attribute__((packed)); + uint8_t pad; + uint16_t capability; + uint16_t status; + uint16_t association_id; + uint16_t respIEs_size; +} __attribute__ ((packed)); struct hostif_associate_indication_t { struct hostif_hdr header; @@ -476,68 +472,68 @@ struct hostif_associate_indication_t { struct association_response_t assoc_resp; /* followed by (reqIEs_size + respIEs_size) octets of data */ /* reqIEs data *//* respIEs data */ -} __attribute__((packed)); +} __attribute__ ((packed)); struct hostif_bss_scan_request_t { struct hostif_hdr header; - uint8_t scan_type; + uint8_t scan_type; #define ACTIVE_SCAN 0 #define PASSIVE_SCAN 1 - uint8_t pad[3]; + uint8_t pad[3]; uint32_t ch_time_min; uint32_t ch_time_max; struct channel_list_t channel_list; struct ssid_t ssid; -} __attribute__((packed)); +} __attribute__ ((packed)); struct hostif_bss_scan_confirm_t { struct hostif_hdr header; - uint16_t result_code; - uint16_t reserved; -} __attribute__((packed)); + uint16_t result_code; + uint16_t reserved; +} __attribute__ ((packed)); struct hostif_phy_information_request_t { struct hostif_hdr header; - uint16_t type; + uint16_t type; #define NORMAL_TYPE 0 #define TIME_TYPE 1 - uint16_t time; /* unit 100ms */ -} __attribute__((packed)); + uint16_t time; /* unit 100ms */ +} __attribute__ ((packed)); struct hostif_phy_information_confirm_t { struct hostif_hdr header; - uint8_t rssi; - uint8_t sq; - uint8_t noise; - uint8_t link_speed; - uint32_t tx_frame; - uint32_t rx_frame; - uint32_t tx_error; - uint32_t rx_error; -} __attribute__((packed)); + uint8_t rssi; + uint8_t sq; + uint8_t noise; + uint8_t link_speed; + uint32_t tx_frame; + uint32_t rx_frame; + uint32_t tx_error; + uint32_t rx_error; +} __attribute__ ((packed)); /* sleep mode */ #define SLP_ACTIVE 0 #define SLP_SLEEP 1 struct hostif_sleep_request_t { struct hostif_hdr header; -} __attribute__((packed)); +} __attribute__ ((packed)); struct hostif_sleep_confirm_t { struct hostif_hdr header; - uint16_t result_code; -} __attribute__((packed)); + uint16_t result_code; +} __attribute__ ((packed)); struct hostif_mic_failure_request_t { struct hostif_hdr header; - uint16_t failure_count; - uint16_t timer; -} __attribute__((packed)); + uint16_t failure_count; + uint16_t timer; +} __attribute__ ((packed)); struct hostif_mic_failure_confirm_t { struct hostif_hdr header; - uint16_t result_code; -} __attribute__((packed)); + uint16_t result_code; +} __attribute__ ((packed)); #define BASIC_RATE 0x80 #define RATE_MASK 0x7F @@ -557,13 +553,13 @@ struct hostif_mic_failure_confirm_t { #define TX_RATE_FIXED 5 /* 11b rate */ -#define TX_RATE_1M (uint8_t)(10/5) /* 11b 11g basic rate */ -#define TX_RATE_2M (uint8_t)(20/5) /* 11b 11g basic rate */ -#define TX_RATE_5M (uint8_t)(55/5) /* 11g basic rate */ +#define TX_RATE_1M (uint8_t)(10/5) /* 11b 11g basic rate */ +#define TX_RATE_2M (uint8_t)(20/5) /* 11b 11g basic rate */ +#define TX_RATE_5M (uint8_t)(55/5) /* 11g basic rate */ #define TX_RATE_11M (uint8_t)(110/5) /* 11g basic rate */ /* 11g rate */ -#define TX_RATE_6M (uint8_t)(60/5) /* 11g basic rate */ +#define TX_RATE_6M (uint8_t)(60/5) /* 11g basic rate */ #define TX_RATE_12M (uint8_t)(120/5) /* 11g basic rate */ #define TX_RATE_24M (uint8_t)(240/5) /* 11g basic rate */ #define TX_RATE_9M (uint8_t)(90/5) @@ -587,13 +583,13 @@ struct hostif_mic_failure_confirm_t { ((A&RATE_MASK)==TX_RATE_54M)) enum { - CONNECT_STATUS=0, + CONNECT_STATUS = 0, DISCONNECT_STATUS }; /* preamble type */ enum { - LONG_PREAMBLE=0, + LONG_PREAMBLE = 0, SHORT_PREAMBLE }; @@ -623,26 +619,29 @@ enum { #include "ks_wlan.h" /* function prototype */ -extern int hostif_data_request( struct ks_wlan_private *priv, struct sk_buff *packet ); -extern void hostif_receive( struct ks_wlan_private *priv, unsigned char *p, unsigned int size ); +extern int hostif_data_request(struct ks_wlan_private *priv, + struct sk_buff *packet); +extern void hostif_receive(struct ks_wlan_private *priv, unsigned char *p, + unsigned int size); extern void hostif_sme_enqueue(struct ks_wlan_private *priv, uint16_t event); -extern int hostif_init( struct ks_wlan_private *priv ); -extern void hostif_exit( struct ks_wlan_private *priv ); +extern int hostif_init(struct ks_wlan_private *priv); +extern void hostif_exit(struct ks_wlan_private *priv); static inline int hif_align_size(int size) { #ifdef KS_ATOM - if( size < 1024 ) + if (size < 1024) size = 1024; #endif #ifdef DEVICE_ALIGNMENT - return (size%DEVICE_ALIGNMENT) ? size + DEVICE_ALIGNMENT - (size % DEVICE_ALIGNMENT) : size; + return (size % DEVICE_ALIGNMENT) ? size + DEVICE_ALIGNMENT - + (size % DEVICE_ALIGNMENT) : size; #else return size; #endif } -#endif /* __KERNEL__ */ +#endif /* __KERNEL__ */ #endif /* _KS_HOSTIF_H_ */ -- cgit v1.1 From d6e25e7048eb6a9f086f3cbf4a42a7a6a5b66bae Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:32 +0200 Subject: staging: ks7010: indent ks_wlan.h Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan.h | 246 +++++++++++++++++++-------------------- 1 file changed, 121 insertions(+), 125 deletions(-) diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index 58e3a5a..f0f9f8e 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -22,16 +22,16 @@ #include #include -#include /* spinlock_t */ -#include /* wait_queue_head_t */ -#include /* pid_t */ -#include /* struct net_device_stats, struct sk_buff */ +#include /* spinlock_t */ +#include /* wait_queue_head_t */ +#include /* pid_t */ +#include /* struct net_device_stats, struct sk_buff */ #include #include -#include /* struct atmic_t */ +#include /* struct atmic_t */ #include /* struct timer_list */ #include -#include /* struct completion */ +#include /* struct completion */ #include #include @@ -46,37 +46,37 @@ #endif struct ks_wlan_parameter { - uint8_t operation_mode; /* Operation Mode */ - uint8_t channel; /* Channel */ - uint8_t tx_rate; /* Transmit Rate */ + uint8_t operation_mode; /* Operation Mode */ + uint8_t channel; /* Channel */ + uint8_t tx_rate; /* Transmit Rate */ struct { uint8_t size; uint8_t body[16]; } rate_set; - uint8_t bssid[ETH_ALEN]; /* BSSID */ + uint8_t bssid[ETH_ALEN]; /* BSSID */ struct { uint8_t size; - uint8_t body[32+1]; - } ssid; /* SSID */ - uint8_t preamble; /* Preamble */ - uint8_t powermgt; /* PowerManagementMode */ - uint32_t scan_type; /* AP List Scan Type */ + uint8_t body[32 + 1]; + } ssid; /* SSID */ + uint8_t preamble; /* Preamble */ + uint8_t powermgt; /* PowerManagementMode */ + uint32_t scan_type; /* AP List Scan Type */ #define BEACON_LOST_COUNT_MIN 0 #define BEACON_LOST_COUNT_MAX 65535 - uint32_t beacon_lost_count; /* Beacon Lost Count */ - uint32_t rts; /* RTS Threashold */ - uint32_t fragment; /* Fragmentation Threashold */ - uint32_t privacy_invoked; - uint32_t wep_index; + uint32_t beacon_lost_count; /* Beacon Lost Count */ + uint32_t rts; /* RTS Threashold */ + uint32_t fragment; /* Fragmentation Threashold */ + uint32_t privacy_invoked; + uint32_t wep_index; struct { uint8_t size; - uint8_t val[13*2+1]; + uint8_t val[13 * 2 + 1]; } wep_key[4]; - uint16_t authenticate_type; - uint16_t phy_type; /* 11b/11g/11bg mode type*/ - uint16_t cts_mode; /* for 11g/11bg mode cts mode */ - uint16_t phy_info_timer; /* phy information timer */ - char rom_file[256]; + uint16_t authenticate_type; + uint16_t phy_type; /* 11b/11g/11bg mode type */ + uint16_t cts_mode; /* for 11g/11bg mode cts mode */ + uint16_t phy_info_timer; /* phy information timer */ + char rom_file[256]; }; enum { @@ -157,7 +157,6 @@ enum { SME_START_REQUEST, SME_GET_EEPROM_CKSUM, - SME_MIC_FAILURE_CONFIRM, SME_START_CONFIRM, @@ -187,7 +186,7 @@ enum { SME_WEP_SET_CONFIRM, SME_TERMINATE, - SME_EVENT_SIZE /* end */ + SME_EVENT_SIZE /* end */ }; /* SME Status */ @@ -200,58 +199,58 @@ enum { #define SME_EVENT_BUFF_SIZE 128 -struct sme_info{ - int sme_status; - int event_buff[SME_EVENT_BUFF_SIZE]; - unsigned int qhead; - unsigned int qtail; +struct sme_info { + int sme_status; + int event_buff[SME_EVENT_BUFF_SIZE]; + unsigned int qhead; + unsigned int qtail; #ifdef KS_WLAN_DEBUG - /* for debug */ + /* for debug */ unsigned int max_event_count; #endif - spinlock_t sme_spin; + spinlock_t sme_spin; unsigned long sme_flag; }; -struct hostt_t{ - int buff[SME_EVENT_BUFF_SIZE]; - unsigned int qhead; - unsigned int qtail; +struct hostt_t { + int buff[SME_EVENT_BUFF_SIZE]; + unsigned int qhead; + unsigned int qtail; }; #define RSN_IE_BODY_MAX 64 struct rsn_ie_t { - uint8_t id; /* 0xdd = WPA or 0x30 = RSN */ - uint8_t size; /* max ? 255 ? */ - uint8_t body[RSN_IE_BODY_MAX]; -} __attribute__((packed)); + uint8_t id; /* 0xdd = WPA or 0x30 = RSN */ + uint8_t size; /* max ? 255 ? */ + uint8_t body[RSN_IE_BODY_MAX]; +} __attribute__ ((packed)); #ifdef WPS #define WPS_IE_BODY_MAX 255 struct wps_ie_t { - uint8_t id; /* 221 'dd 00 50 F2 04' */ - uint8_t size; /* max ? 255 ? */ + uint8_t id; /* 221 'dd 00 50 F2 04' */ + uint8_t size; /* max ? 255 ? */ uint8_t body[WPS_IE_BODY_MAX]; -} __attribute__((packed)); +} __attribute__ ((packed)); #endif /* WPS */ struct local_ap_t { - uint8_t bssid[6]; - uint8_t rssi; - uint8_t sq; + uint8_t bssid[6]; + uint8_t rssi; + uint8_t sq; struct { - uint8_t size; - uint8_t body[32]; - uint8_t ssid_pad; + uint8_t size; + uint8_t body[32]; + uint8_t ssid_pad; } ssid; struct { - uint8_t size; - uint8_t body[16]; - uint8_t rate_pad; + uint8_t size; + uint8_t body[16]; + uint8_t rate_pad; } rate_set; - uint16_t capability; - uint8_t channel; - uint8_t noise; + uint16_t capability; + uint8_t channel; + uint8_t noise; struct rsn_ie_t wpa_ie; struct rsn_ie_t rsn_ie; #ifdef WPS @@ -263,19 +262,19 @@ struct local_ap_t { #define LOCAL_CURRENT_AP LOCAL_APLIST_MAX struct local_aplist_t { int size; - struct local_ap_t ap[LOCAL_APLIST_MAX+1]; + struct local_ap_t ap[LOCAL_APLIST_MAX + 1]; }; -struct local_gain_t{ - uint8_t TxMode; - uint8_t RxMode; - uint8_t TxGain; - uint8_t RxGain; +struct local_gain_t { + uint8_t TxMode; + uint8_t RxMode; + uint8_t TxGain; + uint8_t RxGain; }; -struct local_eeprom_sum_t{ - uint8_t type; - uint8_t result; +struct local_eeprom_sum_t { + uint8_t type; + uint8_t result; }; enum { @@ -285,7 +284,6 @@ enum { EEPROM_NG, }; - /* Power Save Status */ enum { PS_NONE, @@ -297,22 +295,22 @@ enum { }; struct power_save_status_t { - atomic_t status; /* initialvalue 0 */ + atomic_t status; /* initialvalue 0 */ struct completion wakeup_wait; - atomic_t confirm_wait; - atomic_t snooze_guard; + atomic_t confirm_wait; + atomic_t snooze_guard; }; struct sleep_status_t { - atomic_t status; /* initialvalue 0 */ - atomic_t doze_request; - atomic_t wakeup_request; + atomic_t status; /* initialvalue 0 */ + atomic_t doze_request; + atomic_t wakeup_request; }; /* WPA */ struct scan_ext_t { unsigned int flag; - char ssid[IW_ESSID_MAX_SIZE+1]; + char ssid[IW_ESSID_MAX_SIZE + 1]; }; enum { @@ -337,7 +335,7 @@ enum { #define CIPHER_ID_LEN 4 -enum { +enum { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_WPANONE, @@ -358,26 +356,26 @@ enum { #define MIC_KEY_SIZE 8 struct wpa_key_t { - uint32_t ext_flags; /* IW_ENCODE_EXT_xxx */ - uint8_t tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ - uint8_t rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ - struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast - * (group) keys or unicast address for - * individual keys */ - uint16_t alg; - uint16_t key_len; /* WEP: 5 or 13, TKIP: 32, CCMP: 16 */ - uint8_t key_val[IW_ENCODING_TOKEN_MAX]; - uint8_t tx_mic_key[MIC_KEY_SIZE]; - uint8_t rx_mic_key[MIC_KEY_SIZE]; + uint32_t ext_flags; /* IW_ENCODE_EXT_xxx */ + uint8_t tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ + uint8_t rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ + struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast + * (group) keys or unicast address for + * individual keys */ + uint16_t alg; + uint16_t key_len; /* WEP: 5 or 13, TKIP: 32, CCMP: 16 */ + uint8_t key_val[IW_ENCODING_TOKEN_MAX]; + uint8_t tx_mic_key[MIC_KEY_SIZE]; + uint8_t rx_mic_key[MIC_KEY_SIZE]; }; #define WPA_KEY_INDEX_MAX 4 #define WPA_RX_SEQ_LEN 6 struct mic_failure_t { - uint16_t failure; /* MIC Failure counter 0 or 1 or 2 */ - uint16_t counter; /* 1sec counter 0-60 */ - uint32_t last_failure_time; - int stop; /* stop flag */ + uint16_t failure; /* MIC Failure counter 0 or 1 or 2 */ + uint16_t counter; /* 1sec counter 0-60 */ + uint32_t last_failure_time; + int stop; /* stop flag */ }; struct wpa_status_t { @@ -401,36 +399,36 @@ struct pmk_list_t { struct list_head head; struct pmk_t { struct list_head list; - uint8_t bssid[ETH_ALEN]; - uint8_t pmkid[IW_PMKID_LEN]; + uint8_t bssid[ETH_ALEN]; + uint8_t pmkid[IW_PMKID_LEN]; } pmk[PMK_LIST_MAX]; }; #ifdef WPS struct wps_status_t { - int wps_enabled; - int ielen; - uint8_t ie[255]; + int wps_enabled; + int ielen; + uint8_t ie[255]; }; #endif /* WPS */ struct ks_wlan_private { - struct hw_info_t ks_wlan_hw; /* hardware information */ + struct hw_info_t ks_wlan_hw; /* hardware information */ struct net_device *net_dev; - int reg_net; /* register_netdev */ + int reg_net; /* register_netdev */ struct net_device_stats nstats; struct iw_statistics wstats; struct completion confirm_wait; - /* trx device & sme */ + /* trx device & sme */ struct tx_device tx_dev; struct rx_device rx_dev; - struct sme_info sme_i; + struct sme_info sme_i; u8 *rxp; - unsigned int rx_size; + unsigned int rx_size; struct tasklet_struct sme_task; struct work_struct ks_wlan_wakeup_task; int scan_ind_count; @@ -443,33 +441,33 @@ struct ks_wlan_private { struct sleep_status_t sleepstatus; struct wpa_status_t wpa; struct pmk_list_t pmklist; - /* wireless parameter */ + /* wireless parameter */ struct ks_wlan_parameter reg; uint8_t current_rate; - char nick[IW_ESSID_MAX_SIZE+1]; - - spinlock_t multicast_spin; + char nick[IW_ESSID_MAX_SIZE + 1]; + + spinlock_t multicast_spin; spinlock_t dev_read_lock; - wait_queue_head_t devread_wait; + wait_queue_head_t devread_wait; - unsigned int need_commit; /* for ioctl */ + unsigned int need_commit; /* for ioctl */ - /* DeviceIoControl */ + /* DeviceIoControl */ int device_open_status; atomic_t event_count; - atomic_t rec_count; - int dev_count; + atomic_t rec_count; + int dev_count; #define DEVICE_STOCK_COUNT 20 unsigned char *dev_data[DEVICE_STOCK_COUNT]; int dev_size[DEVICE_STOCK_COUNT]; - /* ioctl : IOCTL_FIRMWARE_VERSION */ - unsigned char firmware_version[128+1]; + /* ioctl : IOCTL_FIRMWARE_VERSION */ + unsigned char firmware_version[128 + 1]; int version_size; - int mac_address_valid; /* Mac Address Status */ + int mac_address_valid; /* Mac Address Status */ int dev_state; @@ -478,35 +476,33 @@ struct ks_wlan_private { /* spinlock_t lock; */ #define FORCE_DISCONNECT 0x80000000 #define CONNECT_STATUS_MASK 0x7FFFFFFF - uint32_t connect_status; /* connect status */ - int infra_status; /* Infractructure status */ + uint32_t connect_status; /* connect status */ + int infra_status; /* Infractructure status */ - uint8_t data_buff[0x1000]; + uint8_t data_buff[0x1000]; uint8_t scan_ssid_len; - uint8_t scan_ssid[IW_ESSID_MAX_SIZE+1]; + uint8_t scan_ssid[IW_ESSID_MAX_SIZE + 1]; struct local_gain_t gain; #ifdef WPS struct net_device *l2_dev; - int l2_fd; + int l2_fd; struct wps_status_t wps; #endif /* WPS */ - uint8_t sleep_mode; + uint8_t sleep_mode; uint8_t region; struct local_eeprom_sum_t eeprom_sum; uint8_t eeprom_checksum; - struct hostt_t hostt; + struct hostt_t hostt; unsigned long last_doze; unsigned long last_wakeup; - uint sdio_error_count; /* SDIO error */ - uint wakeup_count; /* for detect wakeup loop */ - -}; - + uint sdio_error_count; /* SDIO error */ + uint wakeup_count; /* for detect wakeup loop */ +}; #endif /* _KS_WLAN_H */ -- cgit v1.1 From 2086ffac7b91dfeac1d9ddf44ce6ab547df58499 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:33 +0200 Subject: staging: ks7010: indent ks_wlan_ioctl.h Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_ioctl.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/ks7010/ks_wlan_ioctl.h b/drivers/staging/ks7010/ks_wlan_ioctl.h index e7469f7..cc4669e 100644 --- a/drivers/staging/ks7010/ks_wlan_ioctl.h +++ b/drivers/staging/ks7010/ks_wlan_ioctl.h @@ -36,8 +36,8 @@ #define KS_WLAN_GET_SCAN_TYPE SIOCIWFIRSTPRIV+13 #define KS_WLAN_SET_RX_GAIN SIOCIWFIRSTPRIV+14 #define KS_WLAN_GET_RX_GAIN SIOCIWFIRSTPRIV+15 -#define KS_WLAN_HOSTT SIOCIWFIRSTPRIV+16 /* unused */ -//#define KS_WLAN_SET_REGION SIOCIWFIRSTPRIV+17 +#define KS_WLAN_HOSTT SIOCIWFIRSTPRIV+16 /* unused */ +//#define KS_WLAN_SET_REGION SIOCIWFIRSTPRIV+17 #define KS_WLAN_SET_BEACON_LOST SIOCIWFIRSTPRIV+18 #define KS_WLAN_GET_BEACON_LOST SIOCIWFIRSTPRIV+19 @@ -51,8 +51,8 @@ #define KS_WLAN_GET_CTS_MODE SIOCIWFIRSTPRIV+25 /* SIOCIWFIRSTPRIV+26 */ /* SIOCIWFIRSTPRIV+27 */ -#define KS_WLAN_SET_SLEEP_MODE SIOCIWFIRSTPRIV+28 /* sleep mode */ -#define KS_WLAN_GET_SLEEP_MODE SIOCIWFIRSTPRIV+29 /* sleep mode */ +#define KS_WLAN_SET_SLEEP_MODE SIOCIWFIRSTPRIV+28 /* sleep mode */ +#define KS_WLAN_GET_SLEEP_MODE SIOCIWFIRSTPRIV+29 /* sleep mode */ /* SIOCIWFIRSTPRIV+30 */ /* SIOCIWFIRSTPRIV+31 */ @@ -62,7 +62,8 @@ #include extern int ks_wlan_read_config_file(struct ks_wlan_private *priv); -extern int ks_wlan_setup_parameter(struct ks_wlan_private *priv, unsigned int commit_flag); +extern int ks_wlan_setup_parameter(struct ks_wlan_private *priv, + unsigned int commit_flag); #endif /* __KERNEL__ */ -- cgit v1.1 From 1df655478eeb909192bd6f2eafe62d46d83a25e0 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:34 +0200 Subject: staging: ks7010: indent ks_wlan_net.c Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 2654 ++++++++++++++++++++-------------- 1 file changed, 1531 insertions(+), 1123 deletions(-) diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index ec5c452..3e28283 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -43,62 +43,63 @@ static int wep_on_off; /* Include Wireless Extension definition and check version */ #include -#define WIRELESS_SPY /* enable iwspy support */ +#define WIRELESS_SPY /* enable iwspy support */ #include /* New driver API */ /* Frequency list (map channels to frequencies) */ static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, - 2447, 2452, 2457, 2462, 2467, 2472, 2484 }; + 2447, 2452, 2457, 2462, 2467, 2472, 2484 +}; /* A few details needed for WEP (Wireless Equivalent Privacy) */ #define MAX_KEY_SIZE 13 /* 128 (?) bits */ #define MIN_KEY_SIZE 5 /* 40 bits RC4 - WEP */ typedef struct wep_key_t { - u16 len; - u8 key[16]; /* 40-bit and 104-bit keys */ + u16 len; + u8 key[16]; /* 40-bit and 104-bit keys */ } wep_key_t; /* Backward compatibility */ #ifndef IW_ENCODE_NOKEY -#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */ +#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */ #define IW_ENCODE_MODE (IW_ENCODE_DISABLED | IW_ENCODE_RESTRICTED | IW_ENCODE_OPEN) #endif /* IW_ENCODE_NOKEY */ /* List of Wireless Handlers (new API) */ -static const struct iw_handler_def ks_wlan_handler_def; - -#define KSC_OPNOTSUPP /* Operation Not Support*/ +static const struct iw_handler_def ks_wlan_handler_def; +#define KSC_OPNOTSUPP /* Operation Not Support */ /* * function prototypes */ -extern int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, - void (*complete_handler)(void *arg1, void *arg2), - void *arg1, - void *arg2 ); -static int ks_wlan_open (struct net_device *dev); -static void ks_wlan_tx_timeout (struct net_device *dev); -static int ks_wlan_start_xmit (struct sk_buff *skb, struct net_device *dev); -static int ks_wlan_close (struct net_device *dev); -static void ks_wlan_set_multicast_list (struct net_device *dev); -static struct net_device_stats *ks_wlan_get_stats (struct net_device *dev); +extern int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, + unsigned long size, + void (*complete_handler) (void *arg1, void *arg2), + void *arg1, void *arg2); +static int ks_wlan_open(struct net_device *dev); +static void ks_wlan_tx_timeout(struct net_device *dev); +static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev); +static int ks_wlan_close(struct net_device *dev); +static void ks_wlan_set_multicast_list(struct net_device *dev); +static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev); static int ks_wlan_set_mac_address(struct net_device *dev, void *addr); -static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); +static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, + int cmd); static atomic_t update_phyinfo; static struct timer_list update_phyinfo_timer; static int ks_wlan_update_phy_information(struct ks_wlan_private *priv) { - struct iw_statistics *wstats = &priv->wstats; + struct iw_statistics *wstats = &priv->wstats; DPRINTK(4, "in_interrupt = %ld\n", in_interrupt()); if (priv->dev_state < DEVICE_STATE_READY) { - return -1; /* not finished initialize */ - } - if(atomic_read(&update_phyinfo)) + return -1; /* not finished initialize */ + } + if (atomic_read(&update_phyinfo)) return 1; /* The status */ @@ -108,12 +109,13 @@ int ks_wlan_update_phy_information(struct ks_wlan_private *priv) hostif_sme_enqueue(priv, SME_PHY_INFO_REQUEST); /* interruptible_sleep_on_timeout(&priv->confirm_wait, HZ/2); */ - if(!wait_for_completion_interruptible_timeout(&priv->confirm_wait,HZ/2)){ - DPRINTK(1,"wait time out!!\n"); + if (!wait_for_completion_interruptible_timeout + (&priv->confirm_wait, HZ / 2)) { + DPRINTK(1, "wait time out!!\n"); } atomic_inc(&update_phyinfo); - update_phyinfo_timer.expires = jiffies + HZ; /* 1sec */ + update_phyinfo_timer.expires = jiffies + HZ; /* 1sec */ add_timer(&update_phyinfo_timer); return 0; @@ -123,42 +125,43 @@ static void ks_wlan_update_phyinfo_timeout(unsigned long ptr) { DPRINTK(4, "in_interrupt = %ld\n", in_interrupt()); - atomic_set(&update_phyinfo,0); + atomic_set(&update_phyinfo, 0); } -int ks_wlan_setup_parameter(struct ks_wlan_private *priv, unsigned int commit_flag) +int ks_wlan_setup_parameter(struct ks_wlan_private *priv, + unsigned int commit_flag) { - DPRINTK(2,"\n"); + DPRINTK(2, "\n"); hostif_sme_enqueue(priv, SME_STOP_REQUEST); - if(commit_flag & SME_RTS) + if (commit_flag & SME_RTS) hostif_sme_enqueue(priv, SME_RTS_THRESHOLD_REQUEST); - if(commit_flag & SME_FRAG) + if (commit_flag & SME_FRAG) hostif_sme_enqueue(priv, SME_FRAGMENTATION_THRESHOLD_REQUEST); - if(commit_flag & SME_WEP_INDEX) + if (commit_flag & SME_WEP_INDEX) hostif_sme_enqueue(priv, SME_WEP_INDEX_REQUEST); - if(commit_flag & SME_WEP_VAL1) + if (commit_flag & SME_WEP_VAL1) hostif_sme_enqueue(priv, SME_WEP_KEY1_REQUEST); - if(commit_flag & SME_WEP_VAL2) + if (commit_flag & SME_WEP_VAL2) hostif_sme_enqueue(priv, SME_WEP_KEY2_REQUEST); - if(commit_flag & SME_WEP_VAL3) + if (commit_flag & SME_WEP_VAL3) hostif_sme_enqueue(priv, SME_WEP_KEY3_REQUEST); - if(commit_flag & SME_WEP_VAL4) + if (commit_flag & SME_WEP_VAL4) hostif_sme_enqueue(priv, SME_WEP_KEY4_REQUEST); - if(commit_flag & SME_WEP_FLAG) + if (commit_flag & SME_WEP_FLAG) hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST); - if(commit_flag & SME_RSN){ + if (commit_flag & SME_RSN) { hostif_sme_enqueue(priv, SME_RSN_ENABLED_REQUEST); hostif_sme_enqueue(priv, SME_RSN_MODE_REQUEST); } - if(commit_flag & SME_RSN_MULTICAST) + if (commit_flag & SME_RSN_MULTICAST) hostif_sme_enqueue(priv, SME_RSN_MCAST_REQUEST); - if(commit_flag & SME_RSN_UNICAST) + if (commit_flag & SME_RSN_UNICAST) hostif_sme_enqueue(priv, SME_RSN_UCAST_REQUEST); - if(commit_flag & SME_RSN_AUTH) + if (commit_flag & SME_RSN_AUTH) hostif_sme_enqueue(priv, SME_RSN_AUTH_REQUEST); hostif_sme_enqueue(priv, SME_MODE_SET_REQUEST); @@ -180,23 +183,24 @@ int ks_wlan_setup_parameter(struct ks_wlan_private *priv, unsigned int commit_fl /*------------------------------------------------------------------*/ /* Wireless Handler : get protocol name */ -static int ks_wlan_get_name(struct net_device *dev, struct iw_request_info *info, - char *cwrq, char *extra) +static int ks_wlan_get_name(struct net_device *dev, + struct iw_request_info *info, char *cwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *) netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ if (priv->dev_state < DEVICE_STATE_READY) { strcpy(cwrq, "NOT READY!"); - } - else if(priv->reg.phy_type == D_11B_ONLY_MODE){ + } else if (priv->reg.phy_type == D_11B_ONLY_MODE) { strcpy(cwrq, "IEEE 802.11b"); - } - else if(priv->reg.phy_type == D_11G_ONLY_MODE){ + } else if (priv->reg.phy_type == D_11G_ONLY_MODE) { strcpy(cwrq, "IEEE 802.11g"); - } - else { + } else { strcpy(cwrq, "IEEE 802.11b/g"); } @@ -205,39 +209,45 @@ static int ks_wlan_get_name(struct net_device *dev, struct iw_request_info *info /*------------------------------------------------------------------*/ /* Wireless Handler : set frequency */ -static int ks_wlan_set_freq(struct net_device *dev, struct iw_request_info *info, - struct iw_freq *fwrq, char *extra) +static int ks_wlan_set_freq(struct net_device *dev, + struct iw_request_info *info, struct iw_freq *fwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - int rc = -EINPROGRESS; /* Call commit handler */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + int rc = -EINPROGRESS; /* Call commit handler */ - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ /* If setting by frequency, convert to a channel */ - if((fwrq->e == 1) && - (fwrq->m >= (int) 2.412e8) && - (fwrq->m <= (int) 2.487e8)) { + if ((fwrq->e == 1) && + (fwrq->m >= (int)2.412e8) && (fwrq->m <= (int)2.487e8)) { int f = fwrq->m / 100000; int c = 0; - while((c < 14) && (f != frequency_list[c])) + while ((c < 14) && (f != frequency_list[c])) c++; /* Hack to fall through... */ fwrq->e = 0; fwrq->m = c + 1; } /* Setting by channel number */ - if((fwrq->m > 1000) || (fwrq->e > 0)) + if ((fwrq->m > 1000) || (fwrq->e > 0)) rc = -EOPNOTSUPP; else { int channel = fwrq->m; /* We should do a better check than that, * based on the card capability !!! */ - if((channel < 1) || (channel > 14)) { - printk(KERN_DEBUG "%s: New channel value of %d is invalid!\n", dev->name, fwrq->m); + if ((channel < 1) || (channel > 14)) { + printk(KERN_DEBUG + "%s: New channel value of %d is invalid!\n", + dev->name, fwrq->m); rc = -EINVAL; } else { /* Yes ! We can set it !!! */ - priv->reg.channel = (u8)(channel); + priv->reg.channel = (u8) (channel); priv->need_commit |= SME_MODE_SET; } } @@ -247,20 +257,23 @@ static int ks_wlan_set_freq(struct net_device *dev, struct iw_request_info *info /*------------------------------------------------------------------*/ /* Wireless Handler : get frequency */ -static int ks_wlan_get_freq(struct net_device *dev, struct iw_request_info *info, - struct iw_freq *fwrq, char *extra) +static int ks_wlan_get_freq(struct net_device *dev, + struct iw_request_info *info, struct iw_freq *fwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); int f; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ - f = (int)priv->current_ap.channel; + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; } - else + /* for SLEEP MODE */ + if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { + f = (int)priv->current_ap.channel; + } else f = (int)priv->reg.channel; - fwrq->m = frequency_list[f-1] * 100000; + fwrq->m = frequency_list[f - 1] * 100000; fwrq->e = 1; return 0; @@ -268,18 +281,23 @@ static int ks_wlan_get_freq(struct net_device *dev, struct iw_request_info *info /*------------------------------------------------------------------*/ /* Wireless Handler : set ESSID */ -static int ks_wlan_set_essid(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_set_essid(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); size_t len; - DPRINTK(2," %d\n", dwrq->flags); + DPRINTK(2, " %d\n", dwrq->flags); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ /* Check if we asked for `any' */ - if(dwrq->flags == 0) { + if (dwrq->flags == 0) { /* Just send an empty SSID list */ memset(priv->reg.ssid.body, 0, sizeof(priv->reg.ssid.body)); priv->reg.ssid.size = 0; @@ -291,13 +309,13 @@ static int ks_wlan_set_essid(struct net_device *dev, struct iw_request_info *inf len--; /* Check the size of the string */ - if(len > IW_ESSID_MAX_SIZE) { + if (len > IW_ESSID_MAX_SIZE) { return -EINVAL; } #else /* Check the size of the string */ - if(dwrq->length > IW_ESSID_MAX_SIZE+1) { - return -E2BIG ; + if (dwrq->length > IW_ESSID_MAX_SIZE + 1) { + return -E2BIG; } #endif @@ -315,25 +333,29 @@ static int ks_wlan_set_essid(struct net_device *dev, struct iw_request_info *inf /* Write it to the card */ priv->need_commit |= SME_MODE_SET; -// return -EINPROGRESS; /* Call commit handler */ +// return -EINPROGRESS; /* Call commit handler */ ks_wlan_setup_parameter(priv, priv->need_commit); - priv->need_commit=0; - return 0; + priv->need_commit = 0; + return 0; } /*------------------------------------------------------------------*/ /* Wireless Handler : get ESSID */ -static int ks_wlan_get_essid(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_get_essid(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ /* Note : if dwrq->flags != 0, we should * get the relevant SSID from the SSID list... */ - - if(priv->reg.ssid.size){ + if (priv->reg.ssid.size) { /* Get the current SSID */ memcpy(extra, priv->reg.ssid.body, priv->reg.ssid.size); #if 0 @@ -345,17 +367,17 @@ static int ks_wlan_get_essid(struct net_device *dev, struct iw_request_info *inf #if 1 dwrq->length = priv->reg.ssid.size; #else - dwrq->length = priv->reg.ssid.size+1; + dwrq->length = priv->reg.ssid.size + 1; #endif - dwrq->flags = 1; /* active */ - }else{ + dwrq->flags = 1; /* active */ + } else { #if 1 dwrq->length = 0; #else extra[0] = '\0'; dwrq->length = 1; #endif - dwrq->flags = 0; /* ANY */ + dwrq->flags = 0; /* ANY */ } return 0; @@ -366,33 +388,35 @@ static int ks_wlan_get_essid(struct net_device *dev, struct iw_request_info *inf static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info, struct sockaddr *ap_addr, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - DPRINTK(2,"\n"); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + DPRINTK(2, "\n"); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ if (priv->reg.operation_mode == MODE_ADHOC || - priv->reg.operation_mode == MODE_INFRASTRUCTURE) { - memcpy(priv->reg.bssid, (u8 *)&ap_addr->sa_data, ETH_ALEN); + priv->reg.operation_mode == MODE_INFRASTRUCTURE) { + memcpy(priv->reg.bssid, (u8 *) & ap_addr->sa_data, ETH_ALEN); - if (is_valid_ether_addr((u8 *)priv->reg.bssid)) { + if (is_valid_ether_addr((u8 *) priv->reg.bssid)) { priv->need_commit |= SME_MODE_SET; } - } - else { + } else { memset(priv->reg.bssid, 0x0, ETH_ALEN); return -EOPNOTSUPP; } DPRINTK(2, "bssid = %02x:%02x:%02x:%02x:%02x:%02x\n", - priv->reg.bssid[0],priv->reg.bssid[1],priv->reg.bssid[2], - priv->reg.bssid[3],priv->reg.bssid[4],priv->reg.bssid[5]); + priv->reg.bssid[0], priv->reg.bssid[1], priv->reg.bssid[2], + priv->reg.bssid[3], priv->reg.bssid[4], priv->reg.bssid[5]); /* Write it to the card */ if (priv->need_commit) { priv->need_commit |= SME_MODE_SET; - return -EINPROGRESS; /* Call commit handler */ + return -EINPROGRESS; /* Call commit handler */ } return 0; } @@ -402,14 +426,16 @@ static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info, static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info, struct sockaddr *awrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS){ - memcpy(awrq->sa_data, &(priv->current_ap.bssid[0]), ETH_ALEN); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; } - else{ + /* for SLEEP MODE */ + if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { + memcpy(awrq->sa_data, &(priv->current_ap.bssid[0]), ETH_ALEN); + } else { memset(awrq->sa_data, 0, ETH_ALEN); } @@ -420,15 +446,20 @@ static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info, /*------------------------------------------------------------------*/ /* Wireless Handler : set Nickname */ -static int ks_wlan_set_nick(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_set_nick(struct net_device *dev, + struct iw_request_info *info, struct iw_point *dwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ /* Check the size of the string */ - if(dwrq->length > 16 + 1) { + if (dwrq->length > 16 + 1) { return -E2BIG; } memset(priv->nick, 0, sizeof(priv->nick)); @@ -439,13 +470,17 @@ static int ks_wlan_set_nick(struct net_device *dev, struct iw_request_info *info /*------------------------------------------------------------------*/ /* Wireless Handler : get Nickname */ -static int ks_wlan_get_nick(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_get_nick(struct net_device *dev, + struct iw_request_info *info, struct iw_point *dwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ strncpy(extra, priv->nick, 16); extra[16] = '\0'; dwrq->length = strlen(extra) + 1; @@ -455,144 +490,228 @@ static int ks_wlan_get_nick(struct net_device *dev, struct iw_request_info *info /*------------------------------------------------------------------*/ /* Wireless Handler : set Bit-Rate */ -static int ks_wlan_set_rate(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) +static int ks_wlan_set_rate(struct net_device *dev, + struct iw_request_info *info, struct iw_param *vwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); int i = 0; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - if(priv->reg.phy_type == D_11B_ONLY_MODE){ - if(vwrq->fixed == 1) { - switch(vwrq->value){ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (priv->reg.phy_type == D_11B_ONLY_MODE) { + if (vwrq->fixed == 1) { + switch (vwrq->value) { case 11000000: - case 5500000: - priv->reg.rate_set.body[0] = (uint8_t)(vwrq->value/500000); + case 5500000: + priv->reg.rate_set.body[0] = + (uint8_t) (vwrq->value / 500000); break; - case 2000000: - case 1000000: - priv->reg.rate_set.body[0] = ((uint8_t)(vwrq->value/500000))|BASIC_RATE; + case 2000000: + case 1000000: + priv->reg.rate_set.body[0] = + ((uint8_t) (vwrq->value / 500000)) | + BASIC_RATE; break; default: return -EINVAL; } priv->reg.tx_rate = TX_RATE_FIXED; priv->reg.rate_set.size = 1; - }else{ /* vwrq->fixed == 0 */ - if(vwrq->value > 0){ - switch(vwrq->value){ + } else { /* vwrq->fixed == 0 */ + if (vwrq->value > 0) { + switch (vwrq->value) { case 11000000: - priv->reg.rate_set.body[3] = TX_RATE_11M; i++; - case 5500000: - priv->reg.rate_set.body[2] = TX_RATE_5M; i++; - case 2000000: - priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; i++; - case 1000000: - priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; i++; + priv->reg.rate_set.body[3] = + TX_RATE_11M; + i++; + case 5500000: + priv->reg.rate_set.body[2] = TX_RATE_5M; + i++; + case 2000000: + priv->reg.rate_set.body[1] = + TX_RATE_2M | BASIC_RATE; + i++; + case 1000000: + priv->reg.rate_set.body[0] = + TX_RATE_1M | BASIC_RATE; + i++; break; default: return -EINVAL; } priv->reg.tx_rate = TX_RATE_MANUAL_AUTO; priv->reg.rate_set.size = i; - }else{ + } else { priv->reg.rate_set.body[3] = TX_RATE_11M; priv->reg.rate_set.body[2] = TX_RATE_5M; - priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; - priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.rate_set.body[1] = + TX_RATE_2M | BASIC_RATE; + priv->reg.rate_set.body[0] = + TX_RATE_1M | BASIC_RATE; priv->reg.tx_rate = TX_RATE_FULL_AUTO; priv->reg.rate_set.size = 4; } } - }else{ /* D_11B_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ - if(vwrq->fixed == 1) { - switch(vwrq->value){ + } else { /* D_11B_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ + if (vwrq->fixed == 1) { + switch (vwrq->value) { case 54000000: case 48000000: case 36000000: case 18000000: - case 9000000: - priv->reg.rate_set.body[0] = (uint8_t)(vwrq->value/500000); + case 9000000: + priv->reg.rate_set.body[0] = + (uint8_t) (vwrq->value / 500000); break; case 24000000: case 12000000: case 11000000: - case 6000000: - case 5500000: - case 2000000: - case 1000000: - priv->reg.rate_set.body[0] = ((uint8_t)(vwrq->value/500000))|BASIC_RATE; + case 6000000: + case 5500000: + case 2000000: + case 1000000: + priv->reg.rate_set.body[0] = + ((uint8_t) (vwrq->value / 500000)) | + BASIC_RATE; break; default: return -EINVAL; } priv->reg.tx_rate = TX_RATE_FIXED; priv->reg.rate_set.size = 1; - }else{ /* vwrq->fixed == 0 */ - if(vwrq->value > 0){ - switch(vwrq->value){ + } else { /* vwrq->fixed == 0 */ + if (vwrq->value > 0) { + switch (vwrq->value) { case 54000000: - priv->reg.rate_set.body[11] = TX_RATE_54M; i++; + priv->reg.rate_set.body[11] = + TX_RATE_54M; + i++; case 48000000: - priv->reg.rate_set.body[10] = TX_RATE_48M; i++; + priv->reg.rate_set.body[10] = + TX_RATE_48M; + i++; case 36000000: - priv->reg.rate_set.body[9] = TX_RATE_36M; i++; - case 24000000: case 18000000: case 12000000: - case 11000000: case 9000000: case 6000000: - if(vwrq->value == 24000000){ - priv->reg.rate_set.body[8] = TX_RATE_18M; i++; - priv->reg.rate_set.body[7] = TX_RATE_9M; i++; - priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; i++; - priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; i++; - priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; - priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; - }else if(vwrq->value == 18000000){ - priv->reg.rate_set.body[7] = TX_RATE_18M; i++; - priv->reg.rate_set.body[6] = TX_RATE_9M; i++; - priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; i++; - priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; - priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; - }else if(vwrq->value == 12000000){ - priv->reg.rate_set.body[6] = TX_RATE_9M; i++; - priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; i++; - priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; - priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; - }else if(vwrq->value == 11000000){ - priv->reg.rate_set.body[5] = TX_RATE_9M; i++; - priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; i++; - priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; i++; - }else if(vwrq->value == 9000000){ - priv->reg.rate_set.body[4] = TX_RATE_9M; i++; - priv->reg.rate_set.body[3] = TX_RATE_6M|BASIC_RATE; i++; - }else{ /* vwrq->value == 6000000 */ - priv->reg.rate_set.body[3] = TX_RATE_6M|BASIC_RATE; i++; + priv->reg.rate_set.body[9] = + TX_RATE_36M; + i++; + case 24000000: + case 18000000: + case 12000000: + case 11000000: + case 9000000: + case 6000000: + if (vwrq->value == 24000000) { + priv->reg.rate_set.body[8] = + TX_RATE_18M; + i++; + priv->reg.rate_set.body[7] = + TX_RATE_9M; + i++; + priv->reg.rate_set.body[6] = + TX_RATE_24M | BASIC_RATE; + i++; + priv->reg.rate_set.body[5] = + TX_RATE_12M | BASIC_RATE; + i++; + priv->reg.rate_set.body[4] = + TX_RATE_6M | BASIC_RATE; + i++; + priv->reg.rate_set.body[3] = + TX_RATE_11M | BASIC_RATE; + i++; + } else if (vwrq->value == 18000000) { + priv->reg.rate_set.body[7] = + TX_RATE_18M; + i++; + priv->reg.rate_set.body[6] = + TX_RATE_9M; + i++; + priv->reg.rate_set.body[5] = + TX_RATE_12M | BASIC_RATE; + i++; + priv->reg.rate_set.body[4] = + TX_RATE_6M | BASIC_RATE; + i++; + priv->reg.rate_set.body[3] = + TX_RATE_11M | BASIC_RATE; + i++; + } else if (vwrq->value == 12000000) { + priv->reg.rate_set.body[6] = + TX_RATE_9M; + i++; + priv->reg.rate_set.body[5] = + TX_RATE_12M | BASIC_RATE; + i++; + priv->reg.rate_set.body[4] = + TX_RATE_6M | BASIC_RATE; + i++; + priv->reg.rate_set.body[3] = + TX_RATE_11M | BASIC_RATE; + i++; + } else if (vwrq->value == 11000000) { + priv->reg.rate_set.body[5] = + TX_RATE_9M; + i++; + priv->reg.rate_set.body[4] = + TX_RATE_6M | BASIC_RATE; + i++; + priv->reg.rate_set.body[3] = + TX_RATE_11M | BASIC_RATE; + i++; + } else if (vwrq->value == 9000000) { + priv->reg.rate_set.body[4] = + TX_RATE_9M; + i++; + priv->reg.rate_set.body[3] = + TX_RATE_6M | BASIC_RATE; + i++; + } else { /* vwrq->value == 6000000 */ + priv->reg.rate_set.body[3] = + TX_RATE_6M | BASIC_RATE; + i++; } - case 5500000: - priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; i++; - case 2000000: - priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; i++; - case 1000000: - priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; i++; + case 5500000: + priv->reg.rate_set.body[2] = + TX_RATE_5M | BASIC_RATE; + i++; + case 2000000: + priv->reg.rate_set.body[1] = + TX_RATE_2M | BASIC_RATE; + i++; + case 1000000: + priv->reg.rate_set.body[0] = + TX_RATE_1M | BASIC_RATE; + i++; break; default: return -EINVAL; } priv->reg.tx_rate = TX_RATE_MANUAL_AUTO; priv->reg.rate_set.size = i; - }else{ + } else { priv->reg.rate_set.body[11] = TX_RATE_54M; priv->reg.rate_set.body[10] = TX_RATE_48M; priv->reg.rate_set.body[9] = TX_RATE_36M; priv->reg.rate_set.body[8] = TX_RATE_18M; priv->reg.rate_set.body[7] = TX_RATE_9M; - priv->reg.rate_set.body[6] = TX_RATE_24M|BASIC_RATE; - priv->reg.rate_set.body[5] = TX_RATE_12M|BASIC_RATE; - priv->reg.rate_set.body[4] = TX_RATE_6M|BASIC_RATE; - priv->reg.rate_set.body[3] = TX_RATE_11M|BASIC_RATE; - priv->reg.rate_set.body[2] = TX_RATE_5M|BASIC_RATE; - priv->reg.rate_set.body[1] = TX_RATE_2M|BASIC_RATE; - priv->reg.rate_set.body[0] = TX_RATE_1M|BASIC_RATE; + priv->reg.rate_set.body[6] = + TX_RATE_24M | BASIC_RATE; + priv->reg.rate_set.body[5] = + TX_RATE_12M | BASIC_RATE; + priv->reg.rate_set.body[4] = + TX_RATE_6M | BASIC_RATE; + priv->reg.rate_set.body[3] = + TX_RATE_11M | BASIC_RATE; + priv->reg.rate_set.body[2] = + TX_RATE_5M | BASIC_RATE; + priv->reg.rate_set.body[1] = + TX_RATE_2M | BASIC_RATE; + priv->reg.rate_set.body[0] = + TX_RATE_1M | BASIC_RATE; priv->reg.tx_rate = TX_RATE_FULL_AUTO; priv->reg.rate_set.size = 12; } @@ -606,21 +725,25 @@ static int ks_wlan_set_rate(struct net_device *dev, struct iw_request_info *info /*------------------------------------------------------------------*/ /* Wireless Handler : get Bit-Rate */ -static int ks_wlan_get_rate(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) +static int ks_wlan_get_rate(struct net_device *dev, + struct iw_request_info *info, struct iw_param *vwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); DPRINTK(2, "in_interrupt = %ld update_phyinfo = %d\n", - in_interrupt(),atomic_read(&update_phyinfo)); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + in_interrupt(), atomic_read(&update_phyinfo)); - if(!atomic_read(&update_phyinfo)){ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (!atomic_read(&update_phyinfo)) { ks_wlan_update_phy_information(priv); } vwrq->value = ((priv->current_rate) & RATE_MASK) * 500000; - if(priv->reg.tx_rate == TX_RATE_FIXED) + if (priv->reg.tx_rate == TX_RATE_FIXED) vwrq->fixed = 1; else vwrq->fixed = 0; @@ -633,14 +756,17 @@ static int ks_wlan_get_rate(struct net_device *dev, struct iw_request_info *info static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); int rthr = vwrq->value; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - if(vwrq->disabled) + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (vwrq->disabled) rthr = 2347; - if((rthr < 0) || (rthr > 2347)) { + if ((rthr < 0) || (rthr > 2347)) { return -EINVAL; } priv->reg.rts = rthr; @@ -654,10 +780,13 @@ static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info, static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ vwrq->value = priv->reg.rts; vwrq->disabled = (vwrq->value >= 2347); vwrq->fixed = 1; @@ -667,17 +796,21 @@ static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info, /*------------------------------------------------------------------*/ /* Wireless Handler : set Fragmentation threshold */ -static int ks_wlan_set_frag(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) +static int ks_wlan_set_frag(struct net_device *dev, + struct iw_request_info *info, struct iw_param *vwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); int fthr = vwrq->value; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - if(vwrq->disabled) + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (vwrq->disabled) fthr = 2346; - if((fthr < 256) || (fthr > 2346)) { + if ((fthr < 256) || (fthr > 2346)) { return -EINVAL; } fthr &= ~0x1; /* Get an even value - is it really needed ??? */ @@ -689,13 +822,17 @@ static int ks_wlan_set_frag(struct net_device *dev, struct iw_request_info *info /*------------------------------------------------------------------*/ /* Wireless Handler : get Fragmentation threshold */ -static int ks_wlan_get_frag(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) +static int ks_wlan_get_frag(struct net_device *dev, + struct iw_request_info *info, struct iw_param *vwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ vwrq->value = priv->reg.fragment; vwrq->disabled = (vwrq->value >= 2346); vwrq->fixed = 1; @@ -705,16 +842,20 @@ static int ks_wlan_get_frag(struct net_device *dev, struct iw_request_info *info /*------------------------------------------------------------------*/ /* Wireless Handler : set Mode of Operation */ -static int ks_wlan_set_mode(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_mode(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - DPRINTK(2,"mode=%d\n",*uwrq); + DPRINTK(2, "mode=%d\n", *uwrq); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - switch(*uwrq) { + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + switch (*uwrq) { case IW_MODE_ADHOC: priv->reg.operation_mode = MODE_ADHOC; priv->need_commit |= SME_MODE_SET; @@ -732,28 +873,33 @@ static int ks_wlan_set_mode(struct net_device *dev, struct iw_request_info *info return -EINVAL; } - return -EINPROGRESS; /* Call commit handler */ + return -EINPROGRESS; /* Call commit handler */ } /*------------------------------------------------------------------*/ /* Wireless Handler : get Mode of Operation */ -static int ks_wlan_get_mode(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_mode(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ /* If not managed, assume it's ad-hoc */ switch (priv->reg.operation_mode) { - case MODE_INFRASTRUCTURE: - *uwrq = IW_MODE_INFRA; - break; - case MODE_ADHOC: - *uwrq = IW_MODE_ADHOC; - break; - default: - *uwrq = IW_MODE_ADHOC; + case MODE_INFRASTRUCTURE: + *uwrq = IW_MODE_INFRA; + break; + case MODE_ADHOC: + *uwrq = IW_MODE_ADHOC; + break; + default: + *uwrq = IW_MODE_ADHOC; } return 0; @@ -761,24 +907,29 @@ static int ks_wlan_get_mode(struct net_device *dev, struct iw_request_info *info /*------------------------------------------------------------------*/ /* Wireless Handler : set Encryption Key */ -static int ks_wlan_set_encode(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_set_encode(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); wep_key_t key; int index = (dwrq->flags & IW_ENCODE_INDEX); int current_index = priv->reg.wep_index; int i; - DPRINTK(2,"flags=%04X\n",dwrq->flags); + DPRINTK(2, "flags=%04X\n", dwrq->flags); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ /* index check */ - if((index<0) || (index>4)) + if ((index < 0) || (index > 4)) return -EINVAL; - else if (index==0) + else if (index == 0) index = current_index; else index--; @@ -786,10 +937,10 @@ static int ks_wlan_set_encode(struct net_device *dev, struct iw_request_info *in /* Is WEP supported ? */ /* Basic checking: do we have a key to set ? */ if (dwrq->length > 0) { - if (dwrq->length > MAX_KEY_SIZE) { /* Check the size of the key */ + if (dwrq->length > MAX_KEY_SIZE) { /* Check the size of the key */ return -EINVAL; } - if (dwrq->length > MIN_KEY_SIZE) { /* Set the length */ + if (dwrq->length > MIN_KEY_SIZE) { /* Set the length */ key.len = MAX_KEY_SIZE; priv->reg.privacy_invoked = 0x01; priv->need_commit |= SME_WEP_FLAG; @@ -800,94 +951,97 @@ static int ks_wlan_set_encode(struct net_device *dev, struct iw_request_info *in priv->reg.privacy_invoked = 0x01; priv->need_commit |= SME_WEP_FLAG; wep_on_off = WEP_ON_64BIT; - } else { /* Disable the key */ + } else { /* Disable the key */ key.len = 0; } } /* Check if the key is not marked as invalid */ - if(!(dwrq->flags & IW_ENCODE_NOKEY)) { + if (!(dwrq->flags & IW_ENCODE_NOKEY)) { /* Cleanup */ memset(key.key, 0, MAX_KEY_SIZE); /* Copy the key in the driver */ - if(copy_from_user(key.key,dwrq->pointer,dwrq->length)) { + if (copy_from_user + (key.key, dwrq->pointer, dwrq->length)) { key.len = 0; return -EFAULT; } /* Send the key to the card */ priv->reg.wep_key[index].size = key.len; - for (i=0; i<(priv->reg.wep_key[index].size); i++) { + for (i = 0; i < (priv->reg.wep_key[index].size); i++) { priv->reg.wep_key[index].val[i] = key.key[i]; } - priv->need_commit |= (SME_WEP_VAL1<need_commit |= (SME_WEP_VAL1 << index); priv->reg.wep_index = index; priv->need_commit |= SME_WEP_INDEX; } } else { - if(dwrq->flags & IW_ENCODE_DISABLED){ + if (dwrq->flags & IW_ENCODE_DISABLED) { priv->reg.wep_key[0].size = 0; priv->reg.wep_key[1].size = 0; priv->reg.wep_key[2].size = 0; priv->reg.wep_key[3].size = 0; priv->reg.privacy_invoked = 0x00; - if(priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY){ + if (priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY) { priv->need_commit |= SME_MODE_SET; } priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; wep_on_off = WEP_OFF; priv->need_commit |= SME_WEP_FLAG; - }else{ + } else { /* Do we want to just set the transmit key index ? */ - if ((index>=0) && (index<4)) { - /* set_wep_key(priv, index, 0, 0, 1); xxx */ - if(priv->reg.wep_key[index].size){ + if ((index >= 0) && (index < 4)) { + /* set_wep_key(priv, index, 0, 0, 1); xxx */ + if (priv->reg.wep_key[index].size) { priv->reg.wep_index = index; priv->need_commit |= SME_WEP_INDEX; - } - else + } else return -EINVAL; } } } /* Commit the changes if needed */ - if(dwrq->flags & IW_ENCODE_MODE) + if (dwrq->flags & IW_ENCODE_MODE) priv->need_commit |= SME_WEP_FLAG; - if(dwrq->flags & IW_ENCODE_OPEN) { - if(priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY){ + if (dwrq->flags & IW_ENCODE_OPEN) { + if (priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY) { priv->need_commit |= SME_MODE_SET; } priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; - } else if(dwrq->flags & IW_ENCODE_RESTRICTED) { - if(priv->reg.authenticate_type == AUTH_TYPE_OPEN_SYSTEM){ + } else if (dwrq->flags & IW_ENCODE_RESTRICTED) { + if (priv->reg.authenticate_type == AUTH_TYPE_OPEN_SYSTEM) { priv->need_commit |= SME_MODE_SET; } priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; } - -// return -EINPROGRESS; /* Call commit handler */ - if(priv->need_commit){ +// return -EINPROGRESS; /* Call commit handler */ + if (priv->need_commit) { ks_wlan_setup_parameter(priv, priv->need_commit); - priv->need_commit=0; + priv->need_commit = 0; } return 0; } /*------------------------------------------------------------------*/ /* Wireless Handler : get Encryption Key */ -static int ks_wlan_get_encode(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_get_encode(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); char zeros[16]; int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ dwrq->flags = IW_ENCODE_DISABLED; /* Check encryption mode */ - switch(priv->reg.authenticate_type) { + switch (priv->reg.authenticate_type) { case AUTH_TYPE_OPEN_SYSTEM: dwrq->flags = IW_ENCODE_OPEN; break; @@ -896,29 +1050,30 @@ static int ks_wlan_get_encode(struct net_device *dev, struct iw_request_info *in break; } - memset(zeros,0, sizeof(zeros)); + memset(zeros, 0, sizeof(zeros)); /* Which key do we want ? -1 -> tx index */ - if((index < 0) || (index >= 4)) + if ((index < 0) || (index >= 4)) index = priv->reg.wep_index; - if (priv->reg.privacy_invoked){ + if (priv->reg.privacy_invoked) { dwrq->flags &= ~IW_ENCODE_DISABLED; /* dwrq->flags |= IW_ENCODE_NOKEY; */ } dwrq->flags |= index + 1; - DPRINTK(2,"encoding flag = 0x%04X\n",dwrq->flags); + DPRINTK(2, "encoding flag = 0x%04X\n", dwrq->flags); /* Copy the key to the user buffer */ - if((index >= 0) && (index < 4)) + if ((index >= 0) && (index < 4)) dwrq->length = priv->reg.wep_key[index].size; if (dwrq->length > 16) { - dwrq->length=0; + dwrq->length = 0; } -#if 1 /* IW_ENCODE_NOKEY; */ +#if 1 /* IW_ENCODE_NOKEY; */ if (dwrq->length) { - if((index >= 0) && (index < 4)) - memcpy(extra,priv->reg.wep_key[index].val,dwrq->length); + if ((index >= 0) && (index < 4)) + memcpy(extra, priv->reg.wep_key[index].val, + dwrq->length); } else - memcpy(extra,zeros,dwrq->length); + memcpy(extra, zeros, dwrq->length); #endif return 0; } @@ -926,19 +1081,24 @@ static int ks_wlan_get_encode(struct net_device *dev, struct iw_request_info *in #ifndef KSC_OPNOTSUPP /*------------------------------------------------------------------*/ /* Wireless Handler : set Tx-Power */ -static int ks_wlan_set_txpow(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) +static int ks_wlan_set_txpow(struct net_device *dev, + struct iw_request_info *info, + struct iw_param *vwrq, char *extra) { - return -EOPNOTSUPP; /* Not Support */ + return -EOPNOTSUPP; /* Not Support */ } /*------------------------------------------------------------------*/ /* Wireless Handler : get Tx-Power */ -static int ks_wlan_get_txpow(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) +static int ks_wlan_get_txpow(struct net_device *dev, + struct iw_request_info *info, + struct iw_param *vwrq, char *extra) { - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ /* Not Support */ vwrq->value = 0; vwrq->disabled = (vwrq->value == 0); @@ -948,19 +1108,24 @@ static int ks_wlan_get_txpow(struct net_device *dev, struct iw_request_info *inf /*------------------------------------------------------------------*/ /* Wireless Handler : set Retry limits */ -static int ks_wlan_set_retry(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) +static int ks_wlan_set_retry(struct net_device *dev, + struct iw_request_info *info, + struct iw_param *vwrq, char *extra) { - return -EOPNOTSUPP; /* Not Support */ + return -EOPNOTSUPP; /* Not Support */ } /*------------------------------------------------------------------*/ /* Wireless Handler : get Retry limits */ -static int ks_wlan_get_retry(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) +static int ks_wlan_get_retry(struct net_device *dev, + struct iw_request_info *info, + struct iw_param *vwrq, char *extra) { - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ /* Not Support */ vwrq->value = 0; vwrq->disabled = (vwrq->value == 0); @@ -971,17 +1136,21 @@ static int ks_wlan_get_retry(struct net_device *dev, struct iw_request_info *inf /*------------------------------------------------------------------*/ /* Wireless Handler : get range info */ -static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_get_range(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - struct iw_range *range = (struct iw_range *) extra; - int i,k; - - DPRINTK(2,"\n"); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + struct iw_range *range = (struct iw_range *)extra; + int i, k; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + DPRINTK(2, "\n"); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ dwrq->length = sizeof(struct iw_range); memset(range, 0, sizeof(*range)); range->min_nwid = 0x0000; @@ -990,15 +1159,14 @@ static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *inf /* Should be based on cap_rid.country to give only * what the current card support */ k = 0; - for(i = 0; i < 13; i++) { /* channel 1 -- 13*/ - range->freq[k].i = i + 1; /* List index */ + for (i = 0; i < 13; i++) { /* channel 1 -- 13 */ + range->freq[k].i = i + 1; /* List index */ range->freq[k].m = frequency_list[i] * 100000; range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ } range->num_frequency = k; - if(priv->reg.phy_type == D_11B_ONLY_MODE || - priv->reg.phy_type == D_11BG_COMPATIBLE_MODE){ /* channel 14 */ - range->freq[13].i = 14; /* List index */ + if (priv->reg.phy_type == D_11B_ONLY_MODE || priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) { /* channel 14 */ + range->freq[13].i = 14; /* List index */ range->freq[13].m = frequency_list[13] * 100000; range->freq[13].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ range->num_frequency = 14; @@ -1008,16 +1176,15 @@ static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *inf range->max_qual.qual = 100; range->max_qual.level = 256 - 128; /* 0 dBm? */ range->max_qual.noise = 256 - 128; - range->sensitivity = 1; + range->sensitivity = 1; - if(priv->reg.phy_type == D_11B_ONLY_MODE){ + if (priv->reg.phy_type == D_11B_ONLY_MODE) { range->bitrate[0] = 1e6; range->bitrate[1] = 2e6; range->bitrate[2] = 5.5e6; range->bitrate[3] = 11e6; range->num_bitrates = 4; - } - else{ /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ + } else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ range->bitrate[0] = 1e6; range->bitrate[1] = 2e6; range->bitrate[2] = 5.5e6; @@ -1026,10 +1193,10 @@ static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *inf range->bitrate[4] = 6e6; range->bitrate[5] = 9e6; range->bitrate[6] = 12e6; - if(IW_MAX_BITRATES < 9){ + if (IW_MAX_BITRATES < 9) { range->bitrate[7] = 54e6; range->num_bitrates = 8; - }else{ + } else { range->bitrate[7] = 18e6; range->bitrate[8] = 24e6; range->bitrate[9] = 36e6; @@ -1043,7 +1210,7 @@ static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *inf /* Set an indication of the max TCP throughput * in bit/s that we can expect using this interface. * May be use for QoS stuff... Jean II */ - if(i > 2) + if (i > 2) range->throughput = 5000 * 1000; else range->throughput = 1500 * 1000; @@ -1053,9 +1220,9 @@ static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *inf range->min_frag = 256; range->max_frag = 2346; - range->encoding_size[0] = 5; /* WEP: RC4 40 bits */ - range->encoding_size[1] = 13; /* WEP: RC4 ~128 bits */ - range->num_encoding_sizes = 2; + range->encoding_size[0] = 5; /* WEP: RC4 40 bits */ + range->encoding_size[1] = 13; /* WEP: RC4 ~128 bits */ + range->num_encoding_sizes = 2; range->max_encoding_tokens = 4; /* power management not support */ @@ -1064,7 +1231,7 @@ static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *inf range->pm_capa = 0; /* Transmit Power - values are in dBm( or mW) */ - range->txpower[0]=-256; + range->txpower[0] = -256; range->num_txpower = 1; range->txpower_capa = IW_TXPOW_DBM; /* range->txpower_capa = IW_TXPOW_MWATT; */ @@ -1073,8 +1240,8 @@ static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *inf range->we_version_compiled = WIRELESS_EXT; range->retry_capa = IW_RETRY_ON; - range->retry_flags = IW_RETRY_ON; - range->r_time_flags = IW_RETRY_ON; + range->retry_flags = IW_RETRY_ON; + range->r_time_flags = IW_RETRY_ON; /* Experimental measurements - boundary 11/5.5 Mb/s */ /* Note : with or without the (local->rssi), results @@ -1092,39 +1259,41 @@ static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *inf IW_EVENT_CAPA_MASK(IWEVMICHAELMICFAILURE)); /* encode extension (WPA) capability */ - range->enc_capa = (IW_ENC_CAPA_WPA | + range->enc_capa = (IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | - IW_ENC_CAPA_CIPHER_TKIP | - IW_ENC_CAPA_CIPHER_CCMP); + IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP); return 0; } - /*------------------------------------------------------------------*/ /* Wireless Handler : set Power Management */ -static int ks_wlan_set_power(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) +static int ks_wlan_set_power(struct net_device *dev, + struct iw_request_info *info, + struct iw_param *vwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); short enabled; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ enabled = vwrq->disabled ? 0 : 1; - if(enabled == 0 ){ /* 0 */ + if (enabled == 0) { /* 0 */ priv->reg.powermgt = POWMGT_ACTIVE_MODE; - }else if(enabled){ /* 1 */ - if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) - priv->reg.powermgt = POWMGT_SAVE1_MODE; - else - return -EINVAL; - }else if(enabled){ /* 2 */ - if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) + } else if (enabled) { /* 1 */ + if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) + priv->reg.powermgt = POWMGT_SAVE1_MODE; + else + return -EINVAL; + } else if (enabled) { /* 2 */ + if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) priv->reg.powermgt = POWMGT_SAVE2_MODE; else return -EINVAL; - }else - return -EINVAL; + } else + return -EINVAL; hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); @@ -1133,33 +1302,41 @@ static int ks_wlan_set_power(struct net_device *dev, struct iw_request_info *inf /*------------------------------------------------------------------*/ /* Wireless Handler : get Power Management */ -static int ks_wlan_get_power(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) +static int ks_wlan_get_power(struct net_device *dev, + struct iw_request_info *info, + struct iw_param *vwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if(priv->reg.powermgt > 0) - vwrq->disabled = 0; + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (priv->reg.powermgt > 0) + vwrq->disabled = 0; else - vwrq->disabled = 1; + vwrq->disabled = 1; return 0; } /*------------------------------------------------------------------*/ /* Wireless Handler : get wirless statistics */ -static int ks_wlan_get_iwstats(struct net_device *dev, struct iw_request_info *info, - struct iw_quality *vwrq, char *extra) +static int ks_wlan_get_iwstats(struct net_device *dev, + struct iw_request_info *info, + struct iw_quality *vwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - vwrq->qual = 0; /* not supported */ - vwrq->level = priv->wstats.qual.level; - vwrq->noise = 0; /* not supported */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + vwrq->qual = 0; /* not supported */ + vwrq->level = priv->wstats.qual.level; + vwrq->noise = 0; /* not supported */ vwrq->updated = 0; return 0; @@ -1168,16 +1345,18 @@ static int ks_wlan_get_iwstats(struct net_device *dev, struct iw_request_info *i #ifndef KSC_OPNOTSUPP /*------------------------------------------------------------------*/ /* Wireless Handler : set Sensitivity */ -static int ks_wlan_set_sens(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) +static int ks_wlan_set_sens(struct net_device *dev, + struct iw_request_info *info, struct iw_param *vwrq, + char *extra) { - return -EOPNOTSUPP; /* Not Support */ + return -EOPNOTSUPP; /* Not Support */ } /*------------------------------------------------------------------*/ /* Wireless Handler : get Sensitivity */ -static int ks_wlan_get_sens(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) +static int ks_wlan_get_sens(struct net_device *dev, + struct iw_request_info *info, struct iw_param *vwrq, + char *extra) { /* Not Support */ vwrq->value = 0; @@ -1187,33 +1366,37 @@ static int ks_wlan_get_sens(struct net_device *dev, struct iw_request_info *info } #endif /* KSC_OPNOTSUPP */ - /*------------------------------------------------------------------*/ /* Wireless Handler : get AP List */ /* Note : this is deprecated in favor of IWSCAN */ -static int ks_wlan_get_aplist(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_get_aplist(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - struct sockaddr *address = (struct sockaddr *) extra; + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + struct sockaddr *address = (struct sockaddr *)extra; struct iw_quality qual[LOCAL_APLIST_MAX]; int i; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ for (i = 0; i < priv->aplist.size; i++) { - memcpy(address[i].sa_data, &(priv->aplist.ap[i].bssid[0]), ETH_ALEN); + memcpy(address[i].sa_data, &(priv->aplist.ap[i].bssid[0]), + ETH_ALEN); address[i].sa_family = ARPHRD_ETHER; qual[i].level = 256 - priv->aplist.ap[i].rssi; qual[i].qual = priv->aplist.ap[i].sq; - qual[i].noise = 0; /* invalid noise value */ + qual[i].noise = 0; /* invalid noise value */ qual[i].updated = 7; } - if (i){ - dwrq->flags = 1; /* Should be define'd */ - memcpy(extra + sizeof(struct sockaddr)*i, - &qual, sizeof(struct iw_quality)*i); + if (i) { + dwrq->flags = 1; /* Should be define'd */ + memcpy(extra + sizeof(struct sockaddr) * i, + &qual, sizeof(struct iw_quality) * i); } dwrq->length = i; @@ -1222,25 +1405,30 @@ static int ks_wlan_get_aplist(struct net_device *dev, struct iw_request_info *in /*------------------------------------------------------------------*/ /* Wireless Handler : Initiate Scan */ -static int ks_wlan_set_scan(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +static int ks_wlan_set_scan(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); struct iw_scan_req *req = NULL; - DPRINTK(2,"\n"); + DPRINTK(2, "\n"); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ /* specified SSID SCAN */ - if(wrqu->data.length == sizeof(struct iw_scan_req) && wrqu->data.flags & IW_SCAN_THIS_ESSID){ - req = (struct iw_scan_req *) extra; + if (wrqu->data.length == sizeof(struct iw_scan_req) + && wrqu->data.flags & IW_SCAN_THIS_ESSID) { + req = (struct iw_scan_req *)extra; priv->scan_ssid_len = req->essid_len; memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len); - }else{ + } else { priv->scan_ssid_len = 0; } - priv->sme_i.sme_flag |= SME_AP_SCAN; hostif_sme_enqueue(priv, SME_BSS_SCAN_REQUEST); @@ -1254,68 +1442,82 @@ static int ks_wlan_set_scan(struct net_device *dev, struct iw_request_info *info * Translate scan data returned from the card to a card independent * format that the Wireless Tools will understand - Jean II */ -static inline char *ks_wlan_translate_scan(struct net_device *dev, struct iw_request_info *info, char *current_ev, - char *end_buf, struct local_ap_t *ap) +static inline char *ks_wlan_translate_scan(struct net_device *dev, + struct iw_request_info *info, + char *current_ev, char *end_buf, + struct local_ap_t *ap) { /* struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; */ - struct iw_event iwe; /* Temporary buffer */ + struct iw_event iwe; /* Temporary buffer */ u16 capabilities; char *current_val; /* For rates */ int i; static const char rsn_leader[] = "rsn_ie="; static const char wpa_leader[] = "wpa_ie="; - char buf0[RSN_IE_BODY_MAX*2 + 30]; - char buf1[RSN_IE_BODY_MAX*2 + 30]; + char buf0[RSN_IE_BODY_MAX * 2 + 30]; + char buf1[RSN_IE_BODY_MAX * 2 + 30]; char *pbuf; /* First entry *MUST* be the AP MAC address */ iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; memcpy(iwe.u.ap_addr.sa_data, ap->bssid, ETH_ALEN); - current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_ADDR_LEN); + current_ev = + iwe_stream_add_event(info, current_ev, end_buf, &iwe, + IW_EV_ADDR_LEN); /* Other entries will be displayed in the order we give them */ /* Add the ESSID */ iwe.u.data.length = ap->ssid.size; - if(iwe.u.data.length > 32) + if (iwe.u.data.length > 32) iwe.u.data.length = 32; iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; - current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, &(ap->ssid.body[0])); + current_ev = + iwe_stream_add_point(info, current_ev, end_buf, &iwe, + &(ap->ssid.body[0])); /* Add mode */ iwe.cmd = SIOCGIWMODE; capabilities = le16_to_cpu(ap->capability); - if(capabilities & (BSS_CAP_ESS | BSS_CAP_IBSS)) { - if(capabilities & BSS_CAP_ESS) + if (capabilities & (BSS_CAP_ESS | BSS_CAP_IBSS)) { + if (capabilities & BSS_CAP_ESS) iwe.u.mode = IW_MODE_INFRA; else iwe.u.mode = IW_MODE_ADHOC; - current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN); + current_ev = + iwe_stream_add_event(info, current_ev, end_buf, &iwe, + IW_EV_UINT_LEN); } /* Add frequency */ iwe.cmd = SIOCGIWFREQ; iwe.u.freq.m = ap->channel; - iwe.u.freq.m = frequency_list[iwe.u.freq.m-1] * 100000; + iwe.u.freq.m = frequency_list[iwe.u.freq.m - 1] * 100000; iwe.u.freq.e = 1; - current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_FREQ_LEN); + current_ev = + iwe_stream_add_event(info, current_ev, end_buf, &iwe, + IW_EV_FREQ_LEN); /* Add quality statistics */ iwe.cmd = IWEVQUAL; iwe.u.qual.level = 256 - ap->rssi; iwe.u.qual.qual = ap->sq; - iwe.u.qual.noise = 0; /* invalid noise value */ - current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); + iwe.u.qual.noise = 0; /* invalid noise value */ + current_ev = + iwe_stream_add_event(info, current_ev, end_buf, &iwe, + IW_EV_QUAL_LEN); /* Add encryption capability */ iwe.cmd = SIOCGIWENCODE; - if(capabilities & BSS_CAP_PRIVACY) + if (capabilities & BSS_CAP_PRIVACY) iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; else iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.length = 0; - current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, &(ap->ssid.body[0])); + current_ev = + iwe_stream_add_point(info, current_ev, end_buf, &iwe, + &(ap->ssid.body[0])); /* Rate : stuffing multiple values in a single event require a bit * more of magic - Jean II */ @@ -1326,62 +1528,68 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev, struct iw_req iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; /* Max 16 values */ - for(i = 0 ; i < 16 ; i++) { + for (i = 0; i < 16; i++) { /* NULL terminated */ - if(i >= ap->rate_set.size) + if (i >= ap->rate_set.size) break; /* Bit rate given in 500 kb/s units (+ 0x80) */ iwe.u.bitrate.value = ((ap->rate_set.body[i] & 0x7f) * 500000); /* Add new value to event */ - current_val = iwe_stream_add_value(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); + current_val = + iwe_stream_add_value(info, current_ev, current_val, end_buf, + &iwe, IW_EV_PARAM_LEN); } /* Check if we added any event */ - if((current_val - current_ev) > IW_EV_LCP_LEN) + if ((current_val - current_ev) > IW_EV_LCP_LEN) current_ev = current_val; #define GENERIC_INFO_ELEM_ID 0xdd #define RSN_INFO_ELEM_ID 0x30 - if (ap->rsn_ie.id == RSN_INFO_ELEM_ID && ap->rsn_ie.size != 0) { - pbuf = &buf0[0]; - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - memcpy(buf0,rsn_leader,sizeof(rsn_leader)-1); - iwe.u.data.length += sizeof(rsn_leader)-1; - pbuf += sizeof(rsn_leader)-1; + if (ap->rsn_ie.id == RSN_INFO_ELEM_ID && ap->rsn_ie.size != 0) { + pbuf = &buf0[0]; + memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVCUSTOM; + memcpy(buf0, rsn_leader, sizeof(rsn_leader) - 1); + iwe.u.data.length += sizeof(rsn_leader) - 1; + pbuf += sizeof(rsn_leader) - 1; - pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.id); - pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.size); - iwe.u.data.length += 4; + pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.id); + pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.size); + iwe.u.data.length += 4; - for (i = 0; i < ap->rsn_ie.size; i++) - pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.body[i]); - iwe.u.data.length += (ap->rsn_ie.size)*2; + for (i = 0; i < ap->rsn_ie.size; i++) + pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.body[i]); + iwe.u.data.length += (ap->rsn_ie.size) * 2; - DPRINTK(4,"ap->rsn.size=%d\n",ap->rsn_ie.size); + DPRINTK(4, "ap->rsn.size=%d\n", ap->rsn_ie.size); - current_ev = iwe_stream_add_point(info, current_ev, end_buf,&iwe, &buf0[0]); - } - if (ap->wpa_ie.id == GENERIC_INFO_ELEM_ID && ap->wpa_ie.size != 0) { - pbuf = &buf1[0]; - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - memcpy(buf1,wpa_leader,sizeof(wpa_leader)-1); - iwe.u.data.length += sizeof(wpa_leader)-1; - pbuf += sizeof(wpa_leader)-1; - - pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.id); - pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.size); - iwe.u.data.length += 4; - - for (i = 0; i < ap->wpa_ie.size; i++) - pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.body[i]); - iwe.u.data.length += (ap->wpa_ie.size)*2; - - DPRINTK(4,"ap->rsn.size=%d\n",ap->wpa_ie.size); - DPRINTK(4,"iwe.u.data.length=%d\n",iwe.u.data.length); - - current_ev = iwe_stream_add_point(info, current_ev, end_buf,&iwe, &buf1[0]); - } + current_ev = + iwe_stream_add_point(info, current_ev, end_buf, &iwe, + &buf0[0]); + } + if (ap->wpa_ie.id == GENERIC_INFO_ELEM_ID && ap->wpa_ie.size != 0) { + pbuf = &buf1[0]; + memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVCUSTOM; + memcpy(buf1, wpa_leader, sizeof(wpa_leader) - 1); + iwe.u.data.length += sizeof(wpa_leader) - 1; + pbuf += sizeof(wpa_leader) - 1; + + pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.id); + pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.size); + iwe.u.data.length += 4; + + for (i = 0; i < ap->wpa_ie.size; i++) + pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.body[i]); + iwe.u.data.length += (ap->wpa_ie.size) * 2; + + DPRINTK(4, "ap->rsn.size=%d\n", ap->wpa_ie.size); + DPRINTK(4, "iwe.u.data.length=%d\n", iwe.u.data.length); + + current_ev = + iwe_stream_add_point(info, current_ev, end_buf, &iwe, + &buf1[0]); + } /* The other data in the scan result are not really * interesting, so for now drop it - Jean II */ @@ -1390,49 +1598,53 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev, struct iw_req /*------------------------------------------------------------------*/ /* Wireless Handler : Read Scan Results */ -static int ks_wlan_get_scan(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_get_scan(struct net_device *dev, + struct iw_request_info *info, struct iw_point *dwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); int i; char *current_ev = extra; - DPRINTK(2,"\n"); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + DPRINTK(2, "\n"); - if(priv->sme_i.sme_flag & SME_AP_SCAN) { -DPRINTK(2,"flag AP_SCAN\n"); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (priv->sme_i.sme_flag & SME_AP_SCAN) { + DPRINTK(2, "flag AP_SCAN\n"); return -EAGAIN; } - if(priv->aplist.size == 0) { + if (priv->aplist.size == 0) { /* Client error, no scan results... * The caller need to restart the scan. */ -DPRINTK(2,"aplist 0\n"); + DPRINTK(2, "aplist 0\n"); return -ENODATA; } #if 0 /* current connect ap */ - if((priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ + if ((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { if ((extra + dwrq->length) - current_ev <= IW_EV_ADDR_LEN) { dwrq->length = 0; return -E2BIG; } current_ev = ks_wlan_translate_scan(dev, current_ev, -// extra + IW_SCAN_MAX_DATA, +// extra + IW_SCAN_MAX_DATA, extra + dwrq->length, &(priv->current_ap)); } #endif /* Read and parse all entries */ - for(i=0; i < priv->aplist.size; i++) { + for (i = 0; i < priv->aplist.size; i++) { if ((extra + dwrq->length) - current_ev <= IW_EV_ADDR_LEN) { dwrq->length = 0; return -E2BIG; } /* Translate to WE format this entry */ current_ev = ks_wlan_translate_scan(dev, info, current_ev, -// extra + IW_SCAN_MAX_DATA, +// extra + IW_SCAN_MAX_DATA, extra + dwrq->length, &(priv->aplist.ap[i])); } @@ -1445,53 +1657,63 @@ DPRINTK(2,"aplist 0\n"); /*------------------------------------------------------------------*/ /* Commit handler : called after a bunch of SET operations */ -static int ks_wlan_config_commit(struct net_device *dev, struct iw_request_info *info, - void *zwrq, char *extra) +static int ks_wlan_config_commit(struct net_device *dev, + struct iw_request_info *info, void *zwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); if (!priv->need_commit) return 0; ks_wlan_setup_parameter(priv, priv->need_commit); - priv->need_commit=0; + priv->need_commit = 0; return 0; } /*------------------------------------------------------------------*/ /* Wireless handler : set association ie params */ -static int ks_wlan_set_genie(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_set_genie(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); DPRINTK(2, "\n"); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ return 0; -// return -EOPNOTSUPP; +// return -EOPNOTSUPP; } /*------------------------------------------------------------------*/ /* Wireless handler : set authentication mode params */ -static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info *info, +static int ks_wlan_set_auth_mode(struct net_device *dev, + struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); int index = (vwrq->flags & IW_AUTH_INDEX); int value = vwrq->value; - DPRINTK(2,"index=%d:value=%08X\n",index,value); + DPRINTK(2, "index=%d:value=%08X\n", index, value); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - switch(index){ - case IW_AUTH_WPA_VERSION: /* 0 */ - switch(value){ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + switch (index) { + case IW_AUTH_WPA_VERSION: /* 0 */ + switch (value) { case IW_AUTH_WPA_VERSION_DISABLED: priv->wpa.version = value; - if(priv->wpa.rsn_enabled){ + if (priv->wpa.rsn_enabled) { priv->wpa.rsn_enabled = 0; } priv->need_commit |= SME_RSN; @@ -1499,7 +1721,7 @@ static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info case IW_AUTH_WPA_VERSION_WPA: case IW_AUTH_WPA_VERSION_WPA2: priv->wpa.version = value; - if(!(priv->wpa.rsn_enabled)){ + if (!(priv->wpa.rsn_enabled)) { priv->wpa.rsn_enabled = 1; } priv->need_commit |= SME_RSN; @@ -1508,10 +1730,10 @@ static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info return -EOPNOTSUPP; } break; - case IW_AUTH_CIPHER_PAIRWISE: /* 1 */ - switch(value){ + case IW_AUTH_CIPHER_PAIRWISE: /* 1 */ + switch (value) { case IW_AUTH_CIPHER_NONE: - if(priv->reg.privacy_invoked){ + if (priv->reg.privacy_invoked) { priv->reg.privacy_invoked = 0x00; priv->need_commit |= SME_WEP_FLAG; } @@ -1520,7 +1742,7 @@ static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info case IW_AUTH_CIPHER_TKIP: case IW_AUTH_CIPHER_CCMP: case IW_AUTH_CIPHER_WEP104: - if(!priv->reg.privacy_invoked){ + if (!priv->reg.privacy_invoked) { priv->reg.privacy_invoked = 0x01; priv->need_commit |= SME_WEP_FLAG; } @@ -1531,10 +1753,10 @@ static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info return -EOPNOTSUPP; } break; - case IW_AUTH_CIPHER_GROUP: /* 2 */ - switch(value){ + case IW_AUTH_CIPHER_GROUP: /* 2 */ + switch (value) { case IW_AUTH_CIPHER_NONE: - if(priv->reg.privacy_invoked){ + if (priv->reg.privacy_invoked) { priv->reg.privacy_invoked = 0x00; priv->need_commit |= SME_WEP_FLAG; } @@ -1543,7 +1765,7 @@ static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info case IW_AUTH_CIPHER_TKIP: case IW_AUTH_CIPHER_CCMP: case IW_AUTH_CIPHER_WEP104: - if(!priv->reg.privacy_invoked){ + if (!priv->reg.privacy_invoked) { priv->reg.privacy_invoked = 0x01; priv->need_commit |= SME_WEP_FLAG; } @@ -1554,12 +1776,12 @@ static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info return -EOPNOTSUPP; } break; - case IW_AUTH_KEY_MGMT: /* 3 */ - switch(value){ + case IW_AUTH_KEY_MGMT: /* 3 */ + switch (value) { case IW_AUTH_KEY_MGMT_802_1X: case IW_AUTH_KEY_MGMT_PSK: - case 0: /* NONE or 802_1X_NO_WPA */ - case 4: /* WPA_NONE */ + case 0: /* NONE or 802_1X_NO_WPA */ + case 4: /* WPA_NONE */ priv->wpa.key_mgmt_suite = value; priv->need_commit |= SME_RSN_AUTH; break; @@ -1567,8 +1789,8 @@ static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info return -EOPNOTSUPP; } break; - case IW_AUTH_80211_AUTH_ALG: /* 6 */ - switch(value){ + case IW_AUTH_80211_AUTH_ALG: /* 6 */ + switch (value) { case IW_AUTH_ALG_OPEN_SYSTEM: priv->wpa.auth_alg = value; priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; @@ -1583,45 +1805,50 @@ static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info } priv->need_commit |= SME_MODE_SET; break; - case IW_AUTH_WPA_ENABLED: /* 7 */ + case IW_AUTH_WPA_ENABLED: /* 7 */ priv->wpa.wpa_enabled = value; break; - case IW_AUTH_PRIVACY_INVOKED: /* 10 */ - if((value && !priv->reg.privacy_invoked)|| - (!value && priv->reg.privacy_invoked)){ - priv->reg.privacy_invoked = value?0x01:0x00; + case IW_AUTH_PRIVACY_INVOKED: /* 10 */ + if ((value && !priv->reg.privacy_invoked) || + (!value && priv->reg.privacy_invoked)) { + priv->reg.privacy_invoked = value ? 0x01 : 0x00; priv->need_commit |= SME_WEP_FLAG; } break; - case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* 4 */ - case IW_AUTH_TKIP_COUNTERMEASURES: /* 5 */ - case IW_AUTH_DROP_UNENCRYPTED: /* 8 */ - case IW_AUTH_ROAMING_CONTROL: /* 9 */ + case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* 4 */ + case IW_AUTH_TKIP_COUNTERMEASURES: /* 5 */ + case IW_AUTH_DROP_UNENCRYPTED: /* 8 */ + case IW_AUTH_ROAMING_CONTROL: /* 9 */ default: break; } /* return -EINPROGRESS; */ - if(priv->need_commit){ + if (priv->need_commit) { ks_wlan_setup_parameter(priv, priv->need_commit); - priv->need_commit=0; + priv->need_commit = 0; } return 0; } /*------------------------------------------------------------------*/ /* Wireless handler : get authentication mode params */ -static int ks_wlan_get_auth_mode(struct net_device *dev, struct iw_request_info *info, +static int ks_wlan_get_auth_mode(struct net_device *dev, + struct iw_request_info *info, struct iw_param *vwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); int index = (vwrq->flags & IW_AUTH_INDEX); - DPRINTK(2,"index=%d\n",index); + DPRINTK(2, "index=%d\n", index); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ /* WPA (not used ?? wpa_supplicant) */ - switch(index){ + switch (index) { case IW_AUTH_WPA_VERSION: vwrq->value = priv->wpa.version; break; @@ -1640,7 +1867,7 @@ static int ks_wlan_get_auth_mode(struct net_device *dev, struct iw_request_info case IW_AUTH_WPA_ENABLED: vwrq->value = priv->wpa.rsn_enabled; break; - case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* OK??? */ + case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* OK??? */ case IW_AUTH_TKIP_COUNTERMEASURES: case IW_AUTH_DROP_UNENCRYPTED: default: @@ -1652,36 +1879,41 @@ static int ks_wlan_get_auth_mode(struct net_device *dev, struct iw_request_info /*------------------------------------------------------------------*/ /* Wireless Handler : set encoding token & mode (WPA)*/ -static int ks_wlan_set_encode_ext(struct net_device *dev, struct iw_request_info *info, +static int ks_wlan_set_encode_ext(struct net_device *dev, + struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); struct iw_encode_ext *enc; int index = dwrq->flags & IW_ENCODE_INDEX; - unsigned int commit=0; + unsigned int commit = 0; enc = (struct iw_encode_ext *)extra; - DPRINTK(2,"flags=%04X:: ext_flags=%08X\n",dwrq->flags, enc->ext_flags); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + DPRINTK(2, "flags=%04X:: ext_flags=%08X\n", dwrq->flags, + enc->ext_flags); - if(index<1||index>4) + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (index < 1 || index > 4) return -EINVAL; else index--; - if(dwrq->flags & IW_ENCODE_DISABLED){ - priv->wpa.key[index].key_len=0; + if (dwrq->flags & IW_ENCODE_DISABLED) { + priv->wpa.key[index].key_len = 0; } - if(enc){ - priv->wpa.key[index].ext_flags=enc->ext_flags; - if(enc->ext_flags&IW_ENCODE_EXT_SET_TX_KEY){ - priv->wpa.txkey=index; + if (enc) { + priv->wpa.key[index].ext_flags = enc->ext_flags; + if (enc->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { + priv->wpa.txkey = index; commit |= SME_WEP_INDEX; - }else if(enc->ext_flags&IW_ENCODE_EXT_RX_SEQ_VALID){ - if(enc->rx_seq) + } else if (enc->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { + if (enc->rx_seq) memcpy(&priv->wpa.key[index].rx_seq[0], enc->rx_seq, IW_ENCODE_SEQ_MAX_SIZE); else @@ -1689,11 +1921,11 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, struct iw_request_info } memcpy(&priv->wpa.key[index].addr.sa_data[0], - &enc->addr.sa_data[0], ETH_ALEN); + &enc->addr.sa_data[0], ETH_ALEN); switch (enc->alg) { case IW_ENCODE_ALG_NONE: - if(priv->reg.privacy_invoked){ + if (priv->reg.privacy_invoked) { priv->reg.privacy_invoked = 0x00; commit |= SME_WEP_FLAG; } @@ -1702,11 +1934,11 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, struct iw_request_info break; case IW_ENCODE_ALG_WEP: case IW_ENCODE_ALG_CCMP: - if(!priv->reg.privacy_invoked){ + if (!priv->reg.privacy_invoked) { priv->reg.privacy_invoked = 0x01; commit |= SME_WEP_FLAG; } - if(enc->key && enc->key_len){ + if (enc->key && enc->key_len) { memcpy(&priv->wpa.key[index].key_val[0], &enc->key[0], enc->key_len); priv->wpa.key[index].key_len = enc->key_len; @@ -1714,24 +1946,25 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, struct iw_request_info } break; case IW_ENCODE_ALG_TKIP: - if(!priv->reg.privacy_invoked){ + if (!priv->reg.privacy_invoked) { priv->reg.privacy_invoked = 0x01; commit |= SME_WEP_FLAG; } - if(enc->key && enc->key_len == 32){ + if (enc->key && enc->key_len == 32) { memcpy(&priv->wpa.key[index].key_val[0], - &enc->key[0], enc->key_len-16); - priv->wpa.key[index].key_len = enc->key_len-16; - if(priv->wpa.key_mgmt_suite==4){ /* WPA_NONE */ - memcpy(&priv->wpa.key[index].tx_mic_key[0], - &enc->key[16],8); - memcpy(&priv->wpa.key[index].rx_mic_key[0], - &enc->key[16],8); - }else{ - memcpy(&priv->wpa.key[index].tx_mic_key[0], - &enc->key[16],8); - memcpy(&priv->wpa.key[index].rx_mic_key[0], - &enc->key[24],8); + &enc->key[0], enc->key_len - 16); + priv->wpa.key[index].key_len = + enc->key_len - 16; + if (priv->wpa.key_mgmt_suite == 4) { /* WPA_NONE */ + memcpy(&priv->wpa.key[index]. + tx_mic_key[0], &enc->key[16], 8); + memcpy(&priv->wpa.key[index]. + rx_mic_key[0], &enc->key[16], 8); + } else { + memcpy(&priv->wpa.key[index]. + tx_mic_key[0], &enc->key[16], 8); + memcpy(&priv->wpa.key[index]. + rx_mic_key[0], &enc->key[24], 8); } commit |= (SME_WEP_VAL1 << index); } @@ -1739,17 +1972,16 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, struct iw_request_info default: return -EINVAL; } - priv->wpa.key[index].alg=enc->alg; - } - else + priv->wpa.key[index].alg = enc->alg; + } else return -EINVAL; - if(commit){ - if(commit&SME_WEP_INDEX) + if (commit) { + if (commit & SME_WEP_INDEX) hostif_sme_enqueue(priv, SME_SET_TXKEY); - if(commit&SME_WEP_VAL_MASK) - hostif_sme_enqueue(priv, SME_SET_KEY1+index); - if(commit&SME_WEP_FLAG) + if (commit & SME_WEP_VAL_MASK) + hostif_sme_enqueue(priv, SME_SET_KEY1 + index); + if (commit & SME_WEP_FLAG) hostif_sme_enqueue(priv, SME_WEP_FLAG_REQUEST); } @@ -1758,101 +1990,121 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, struct iw_request_info /*------------------------------------------------------------------*/ /* Wireless Handler : get encoding token & mode (WPA)*/ -static int ks_wlan_get_encode_ext(struct net_device *dev, struct iw_request_info *info, +static int ks_wlan_get_encode_ext(struct net_device *dev, + struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ /* WPA (not used ?? wpa_supplicant) - struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; - struct iw_encode_ext *enc; - enc = (struct iw_encode_ext *)extra; - int index = dwrq->flags & IW_ENCODE_INDEX; - WPA (not used ?? wpa_supplicant) */ + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; + struct iw_encode_ext *enc; + enc = (struct iw_encode_ext *)extra; + int index = dwrq->flags & IW_ENCODE_INDEX; + WPA (not used ?? wpa_supplicant) */ return 0; } /*------------------------------------------------------------------*/ /* Wireless Handler : PMKSA cache operation (WPA2) */ -static int ks_wlan_set_pmksa(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_set_pmksa(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - struct iw_pmksa *pmksa ; + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + struct iw_pmksa *pmksa; int i; struct pmk_t *pmk; struct list_head *ptr; - DPRINTK(2,"\n"); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + DPRINTK(2, "\n"); - if(!extra){ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (!extra) { return -EINVAL; } pmksa = (struct iw_pmksa *)extra; - DPRINTK(2,"cmd=%d\n",pmksa->cmd); + DPRINTK(2, "cmd=%d\n", pmksa->cmd); - switch(pmksa->cmd){ + switch (pmksa->cmd) { case IW_PMKSA_ADD: - if(list_empty(&priv->pmklist.head)){ /* new list */ - for(i=0;ipmklist.head)) { /* new list */ + for (i = 0; i < PMK_LIST_MAX; i++) { pmk = &priv->pmklist.pmk[i]; - if(!memcmp("\x00\x00\x00\x00\x00\x00",pmk->bssid,ETH_ALEN)) + if (!memcmp + ("\x00\x00\x00\x00\x00\x00", pmk->bssid, + ETH_ALEN)) break; } memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); - list_add(&pmk->list,&priv->pmklist.head); + list_add(&pmk->list, &priv->pmklist.head); priv->pmklist.size++; - } - else { /* search cache data */ - list_for_each(ptr, &priv->pmklist.head){ + } else { /* search cache data */ + list_for_each(ptr, &priv->pmklist.head) { pmk = list_entry(ptr, struct pmk_t, list); - if(!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)){ /* match address! list move to head. */ - memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); - list_move(&pmk->list, &priv->pmklist.head); + if (!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)) { /* match address! list move to head. */ + memcpy(pmk->pmkid, pmksa->pmkid, + IW_PMKID_LEN); + list_move(&pmk->list, + &priv->pmklist.head); break; } } - if(ptr == &priv->pmklist.head){ /* not find address. */ - if(PMK_LIST_MAX > priv->pmklist.size){ /* new cache data */ - for(i=0;ipmklist.head) { /* not find address. */ + if (PMK_LIST_MAX > priv->pmklist.size) { /* new cache data */ + for (i = 0; i < PMK_LIST_MAX; i++) { pmk = &priv->pmklist.pmk[i]; - if(!memcmp("\x00\x00\x00\x00\x00\x00",pmk->bssid,ETH_ALEN)) + if (!memcmp + ("\x00\x00\x00\x00\x00\x00", + pmk->bssid, ETH_ALEN)) break; } - memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); - memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); - list_add(&pmk->list,&priv->pmklist.head); + memcpy(pmk->bssid, pmksa->bssid.sa_data, + ETH_ALEN); + memcpy(pmk->pmkid, pmksa->pmkid, + IW_PMKID_LEN); + list_add(&pmk->list, + &priv->pmklist.head); priv->pmklist.size++; - } - else{ /* overwrite old cache data */ - pmk = list_entry(priv->pmklist.head.prev, struct pmk_t, list); - memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); - memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); - list_move(&pmk->list,&priv->pmklist.head); + } else { /* overwrite old cache data */ + pmk = + list_entry(priv->pmklist.head.prev, + struct pmk_t, list); + memcpy(pmk->bssid, pmksa->bssid.sa_data, + ETH_ALEN); + memcpy(pmk->pmkid, pmksa->pmkid, + IW_PMKID_LEN); + list_move(&pmk->list, + &priv->pmklist.head); } } } break; case IW_PMKSA_REMOVE: - if(list_empty(&priv->pmklist.head)){ /* list empty */ + if (list_empty(&priv->pmklist.head)) { /* list empty */ return -EINVAL; - } - else{ /* search cache data */ - list_for_each(ptr, &priv->pmklist.head){ + } else { /* search cache data */ + list_for_each(ptr, &priv->pmklist.head) { pmk = list_entry(ptr, struct pmk_t, list); - if(!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)){ /* match address! list del. */ + if (!memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN)) { /* match address! list del. */ memset(pmk->bssid, 0, ETH_ALEN); memset(pmk->pmkid, 0, IW_PMKID_LEN); list_del_init(&pmk->list); break; } } - if(ptr == &priv->pmklist.head){ /* not find address. */ + if (ptr == &priv->pmklist.head) { /* not find address. */ return 0; } } @@ -1860,7 +2112,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev, struct iw_request_info *inf case IW_PMKSA_FLUSH: memset(&(priv->pmklist), 0, sizeof(priv->pmklist)); INIT_LIST_HEAD(&priv->pmklist.head); - for(i=0;ipmklist.pmk[i].list); break; default: @@ -1874,40 +2126,45 @@ static int ks_wlan_set_pmksa(struct net_device *dev, struct iw_request_info *inf static struct iw_statistics *ks_get_wireless_stats(struct net_device *dev) { - struct ks_wlan_private *priv = (struct ks_wlan_private *) netdev_priv(dev); - struct iw_statistics *wstats = &priv->wstats; + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + struct iw_statistics *wstats = &priv->wstats; - if(!atomic_read(&update_phyinfo)){ + if (!atomic_read(&update_phyinfo)) { if (priv->dev_state < DEVICE_STATE_READY) - return NULL; /* not finished initialize */ + return NULL; /* not finished initialize */ else return wstats; } /* Packets discarded in the wireless adapter due to wireless * specific problems */ - wstats->discard.nwid = 0; /* Rx invalid nwid */ - wstats->discard.code = 0; /* Rx invalid crypt */ - wstats->discard.fragment = 0; /* Rx invalid frag */ - wstats->discard.retries = 0; /* Tx excessive retries */ - wstats->discard.misc = 0; /* Invalid misc */ - wstats->miss.beacon = 0; /* Missed beacon */ + wstats->discard.nwid = 0; /* Rx invalid nwid */ + wstats->discard.code = 0; /* Rx invalid crypt */ + wstats->discard.fragment = 0; /* Rx invalid frag */ + wstats->discard.retries = 0; /* Tx excessive retries */ + wstats->discard.misc = 0; /* Invalid misc */ + wstats->miss.beacon = 0; /* Missed beacon */ - return wstats; + return wstats; } /*------------------------------------------------------------------*/ /* Private handler : set stop request */ -static int ks_wlan_set_stop_request(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_stop_request(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - DPRINTK(2,"\n"); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + DPRINTK(2, "\n"); - if(!(*uwrq)) - return -EINVAL; + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (!(*uwrq)) + return -EINVAL; hostif_sme_enqueue(priv, SME_STOP_REQUEST); return 0; @@ -1916,17 +2173,21 @@ static int ks_wlan_set_stop_request(struct net_device *dev, struct iw_request_in /*------------------------------------------------------------------*/ /* Wireless Handler : set MLME */ #include -static int ks_wlan_set_mlme(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_set_mlme(struct net_device *dev, + struct iw_request_info *info, struct iw_point *dwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); struct iw_mlme *mlme = (struct iw_mlme *)extra; __u32 mode; DPRINTK(2, ":%d :%d\n", mlme->cmd, mlme->reason_code); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ switch (mlme->cmd) { case IW_MLME_DEAUTH: if (mlme->reason_code == WLAN_REASON_MIC_FAILURE) { @@ -1936,75 +2197,88 @@ static int ks_wlan_set_mlme(struct net_device *dev, struct iw_request_info *info mode = 1; return ks_wlan_set_stop_request(dev, NULL, &mode, NULL); default: - return -EOPNOTSUPP; /* Not Support */ + return -EOPNOTSUPP; /* Not Support */ } } /*------------------------------------------------------------------*/ /* Private handler : get driver version */ -static int ks_wlan_get_driver_version(struct net_device *dev, struct iw_request_info *info, +static int ks_wlan_get_driver_version(struct net_device *dev, + struct iw_request_info *info, struct iw_point *dwrq, char *extra) { strcpy(extra, KS_WLAN_DRIVER_VERSION_INFO); - dwrq->length = strlen(KS_WLAN_DRIVER_VERSION_INFO)+1; + dwrq->length = strlen(KS_WLAN_DRIVER_VERSION_INFO) + 1; return 0; } /*------------------------------------------------------------------*/ /* Private handler : get firemware version */ -static int ks_wlan_get_firmware_version(struct net_device *dev, struct iw_request_info *info, +static int ks_wlan_get_firmware_version(struct net_device *dev, + struct iw_request_info *info, struct iw_point *dwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); strcpy(extra, &(priv->firmware_version[0])); - dwrq->length = priv->version_size+1; + dwrq->length = priv->version_size + 1; return 0; } #if 0 /*------------------------------------------------------------------*/ /* Private handler : set force disconnect status */ -static int ks_wlan_set_detach(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_detach(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - if(*uwrq == CONNECT_STATUS){ /* 0 */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (*uwrq == CONNECT_STATUS) { /* 0 */ priv->connect_status &= ~FORCE_DISCONNECT; - if((priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) + if ((priv->connect_status & CONNECT_STATUS_MASK) == + CONNECT_STATUS) netif_carrier_on(dev); - }else if(*uwrq == DISCONNECT_STATUS){ /* 1 */ + } else if (*uwrq == DISCONNECT_STATUS) { /* 1 */ priv->connect_status |= FORCE_DISCONNECT; netif_carrier_off(dev); - }else - return -EINVAL; + } else + return -EINVAL; return 0; } /*------------------------------------------------------------------*/ /* Private handler : get force disconnect status */ -static int ks_wlan_get_detach(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_detach(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - *uwrq = ((priv->connect_status & FORCE_DISCONNECT) ? 1 : 0 ); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + *uwrq = ((priv->connect_status & FORCE_DISCONNECT) ? 1 : 0); return 0; } /*------------------------------------------------------------------*/ /* Private handler : get connect status */ -static int ks_wlan_get_connect(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_connect(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ *uwrq = (priv->connect_status & CONNECT_STATUS_MASK); return 0; } @@ -2012,61 +2286,73 @@ static int ks_wlan_get_connect(struct net_device *dev, struct iw_request_info *i /*------------------------------------------------------------------*/ /* Private handler : set preamble */ -static int ks_wlan_set_preamble(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_preamble(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if(*uwrq == LONG_PREAMBLE){ /* 0 */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (*uwrq == LONG_PREAMBLE) { /* 0 */ priv->reg.preamble = LONG_PREAMBLE; - }else if(*uwrq == SHORT_PREAMBLE){ /* 1 */ + } else if (*uwrq == SHORT_PREAMBLE) { /* 1 */ priv->reg.preamble = SHORT_PREAMBLE; - }else - return -EINVAL; + } else + return -EINVAL; priv->need_commit |= SME_MODE_SET; - return -EINPROGRESS; /* Call commit handler */ + return -EINPROGRESS; /* Call commit handler */ } /*------------------------------------------------------------------*/ /* Private handler : get preamble */ -static int ks_wlan_get_preamble(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_preamble(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ *uwrq = priv->reg.preamble; return 0; } /*------------------------------------------------------------------*/ /* Private handler : set power save mode */ -static int ks_wlan_set_powermgt(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_powermgt(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if(*uwrq == POWMGT_ACTIVE_MODE){ /* 0 */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (*uwrq == POWMGT_ACTIVE_MODE) { /* 0 */ priv->reg.powermgt = POWMGT_ACTIVE_MODE; - }else if(*uwrq == POWMGT_SAVE1_MODE){ /* 1 */ - if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) - priv->reg.powermgt = POWMGT_SAVE1_MODE; - else - return -EINVAL; - }else if(*uwrq == POWMGT_SAVE2_MODE){ /* 2 */ - if(priv->reg.operation_mode == MODE_INFRASTRUCTURE) + } else if (*uwrq == POWMGT_SAVE1_MODE) { /* 1 */ + if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) + priv->reg.powermgt = POWMGT_SAVE1_MODE; + else + return -EINVAL; + } else if (*uwrq == POWMGT_SAVE2_MODE) { /* 2 */ + if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) priv->reg.powermgt = POWMGT_SAVE2_MODE; else return -EINVAL; - }else - return -EINVAL; + } else + return -EINVAL; hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); @@ -2075,100 +2361,119 @@ static int ks_wlan_set_powermgt(struct net_device *dev, struct iw_request_info * /*------------------------------------------------------------------*/ /* Private handler : get power save made */ -static int ks_wlan_get_powermgt(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_powermgt(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ *uwrq = priv->reg.powermgt; return 0; } /*------------------------------------------------------------------*/ /* Private handler : set scan type */ -static int ks_wlan_set_scan_type(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_scan_type(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if(*uwrq == ACTIVE_SCAN){ /* 0 */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (*uwrq == ACTIVE_SCAN) { /* 0 */ priv->reg.scan_type = ACTIVE_SCAN; - }else if(*uwrq == PASSIVE_SCAN){ /* 1 */ + } else if (*uwrq == PASSIVE_SCAN) { /* 1 */ priv->reg.scan_type = PASSIVE_SCAN; - }else - return -EINVAL; + } else + return -EINVAL; return 0; } /*------------------------------------------------------------------*/ /* Private handler : get scan type */ -static int ks_wlan_get_scan_type(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_scan_type(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ *uwrq = priv->reg.scan_type; return 0; } + #if 0 /*------------------------------------------------------------------*/ /* Private handler : write raw data to device */ -static int ks_wlan_data_write(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_data_write(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, char *extra) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; unsigned char *wbuff = NULL; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ wbuff = (unsigned char *)kmalloc(dwrq->length, GFP_ATOMIC); - if(!wbuff) - return -EFAULT; + if (!wbuff) + return -EFAULT; memcpy(wbuff, extra, dwrq->length); /* write to device */ - ks_wlan_hw_tx( priv, wbuff, dwrq->length, NULL, NULL, NULL); + ks_wlan_hw_tx(priv, wbuff, dwrq->length, NULL, NULL, NULL); return 0; } /*------------------------------------------------------------------*/ /* Private handler : read raw data form device */ -static int ks_wlan_data_read(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) +static int ks_wlan_data_read(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, char *extra) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; unsigned short read_length; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - if(!atomic_read(&priv->event_count)){ - if (priv->dev_state < DEVICE_STATE_BOOT) { /* Remove device */ - read_length = 4; - memset(extra,0xff,read_length); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (!atomic_read(&priv->event_count)) { + if (priv->dev_state < DEVICE_STATE_BOOT) { /* Remove device */ + read_length = 4; + memset(extra, 0xff, read_length); dwrq->length = read_length; return 0; } read_length = 0; - memset(extra,0,1); + memset(extra, 0, 1); dwrq->length = 0; return 0; } - if(atomic_read(&priv->event_count)>0) - atomic_dec(&priv->event_count); + if (atomic_read(&priv->event_count) > 0) + atomic_dec(&priv->event_count); spin_lock(&priv->dev_read_lock); /* request spin lock */ - /* Copy length max size 0x07ff */ - if(priv->dev_size[priv->dev_count] > 2047) + /* Copy length max size 0x07ff */ + if (priv->dev_size[priv->dev_count] > 2047) read_length = 2047; else read_length = priv->dev_size[priv->dev_count]; @@ -2176,15 +2481,15 @@ static int ks_wlan_data_read(struct net_device *dev, struct iw_request_info *inf /* Copy data */ memcpy(extra, &(priv->dev_data[priv->dev_count][0]), read_length); - spin_unlock(&priv->dev_read_lock); /* release spin lock */ + spin_unlock(&priv->dev_read_lock); /* release spin lock */ /* Initialize */ priv->dev_data[priv->dev_count] = 0; priv->dev_size[priv->dev_count] = 0; priv->dev_count++; - if(priv->dev_count == DEVICE_STOCK_COUNT) - priv->dev_count=0; + if (priv->dev_count == DEVICE_STOCK_COUNT) + priv->dev_count = 0; /* Set read size */ dwrq->length = read_length; @@ -2197,150 +2502,180 @@ static int ks_wlan_data_read(struct net_device *dev, struct iw_request_info *inf /*------------------------------------------------------------------*/ /* Private handler : get wep string */ #define WEP_ASCII_BUFF_SIZE (17+64*4+1) -static int ks_wlan_get_wep_ascii(struct net_device *dev, struct iw_request_info *info, +static int ks_wlan_get_wep_ascii(struct net_device *dev, + struct iw_request_info *info, struct iw_point *dwrq, char *extra) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; - int i,j,len=0; + int i, j, len = 0; char tmp[WEP_ASCII_BUFF_SIZE]; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - strcpy(tmp," WEP keys ASCII \n"); - len+=strlen(" WEP keys ASCII \n"); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + strcpy(tmp, " WEP keys ASCII \n"); + len += strlen(" WEP keys ASCII \n"); - for(i=0;i<4;i++){ - strcpy(tmp+len,"\t["); - len+=strlen("\t["); - tmp[len] = '1'+i; + for (i = 0; i < 4; i++) { + strcpy(tmp + len, "\t["); + len += strlen("\t["); + tmp[len] = '1' + i; len++; - strcpy(tmp+len,"] "); - len+=strlen("] "); - if(priv->reg.wep_key[i].size){ - strcpy(tmp+len,(priv->reg.wep_key[i].size < 6 ? "(40bits) [" : "(104bits) [")); - len+=strlen((priv->reg.wep_key[i].size < 6 ? "(40bits) [" : "(104bits) [")); - for(j=0;jreg.wep_key[i].size;j++,len++) - tmp[len]=(isprint(priv->reg.wep_key[i].val[j]) ? priv->reg.wep_key[i].val[j] : ' '); - - strcpy(tmp+len,"]\n"); - len+=strlen("]\n"); - } - else{ - strcpy(tmp+len,"off\n"); - len+=strlen("off\n"); + strcpy(tmp + len, "] "); + len += strlen("] "); + if (priv->reg.wep_key[i].size) { + strcpy(tmp + len, + (priv->reg.wep_key[i].size < + 6 ? "(40bits) [" : "(104bits) [")); + len += + strlen((priv->reg.wep_key[i].size < + 6 ? "(40bits) [" : "(104bits) [")); + for (j = 0; j < priv->reg.wep_key[i].size; j++, len++) + tmp[len] = + (isprint(priv->reg.wep_key[i].val[j]) ? + priv->reg.wep_key[i].val[j] : ' '); + + strcpy(tmp + len, "]\n"); + len += strlen("]\n"); + } else { + strcpy(tmp + len, "off\n"); + len += strlen("off\n"); } } memcpy(extra, tmp, len); - dwrq->length = len+1; + dwrq->length = len + 1; return 0; } #endif /*------------------------------------------------------------------*/ /* Private handler : set beacon lost count */ -static int ks_wlan_set_beacon_lost(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_beacon_lost(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - if(*uwrq >= BEACON_LOST_COUNT_MIN && - *uwrq <= BEACON_LOST_COUNT_MAX){ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (*uwrq >= BEACON_LOST_COUNT_MIN && *uwrq <= BEACON_LOST_COUNT_MAX) { priv->reg.beacon_lost_count = *uwrq; - }else - return -EINVAL; + } else + return -EINVAL; - if(priv->reg.operation_mode == MODE_INFRASTRUCTURE){ + if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) { priv->need_commit |= SME_MODE_SET; - return -EINPROGRESS; /* Call commit handler */ - } - else + return -EINPROGRESS; /* Call commit handler */ + } else return 0; } /*------------------------------------------------------------------*/ /* Private handler : get beacon lost count */ -static int ks_wlan_get_beacon_lost(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_beacon_lost(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ *uwrq = priv->reg.beacon_lost_count; return 0; } /*------------------------------------------------------------------*/ /* Private handler : set phy type */ -static int ks_wlan_set_phy_type(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_phy_type(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - if(*uwrq == D_11B_ONLY_MODE){ /* 0 */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (*uwrq == D_11B_ONLY_MODE) { /* 0 */ priv->reg.phy_type = D_11B_ONLY_MODE; - }else if(*uwrq == D_11G_ONLY_MODE){ /* 1 */ + } else if (*uwrq == D_11G_ONLY_MODE) { /* 1 */ priv->reg.phy_type = D_11G_ONLY_MODE; - }else if(*uwrq == D_11BG_COMPATIBLE_MODE){ /* 2 */ + } else if (*uwrq == D_11BG_COMPATIBLE_MODE) { /* 2 */ priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; - }else - return -EINVAL; + } else + return -EINVAL; priv->need_commit |= SME_MODE_SET; - return -EINPROGRESS; /* Call commit handler */ + return -EINPROGRESS; /* Call commit handler */ } /*------------------------------------------------------------------*/ /* Private handler : get phy type */ -static int ks_wlan_get_phy_type(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_phy_type(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ *uwrq = priv->reg.phy_type; return 0; } /*------------------------------------------------------------------*/ /* Private handler : set cts mode */ -static int ks_wlan_set_cts_mode(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_cts_mode(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if(*uwrq == CTS_MODE_FALSE){ /* 0 */ + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (*uwrq == CTS_MODE_FALSE) { /* 0 */ priv->reg.cts_mode = CTS_MODE_FALSE; - }else if(*uwrq == CTS_MODE_TRUE){ /* 1 */ - if(priv->reg.phy_type == D_11G_ONLY_MODE || - priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) + } else if (*uwrq == CTS_MODE_TRUE) { /* 1 */ + if (priv->reg.phy_type == D_11G_ONLY_MODE || + priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) priv->reg.cts_mode = CTS_MODE_TRUE; else priv->reg.cts_mode = CTS_MODE_FALSE; - }else - return -EINVAL; + } else + return -EINVAL; priv->need_commit |= SME_MODE_SET; - return -EINPROGRESS; /* Call commit handler */ + return -EINPROGRESS; /* Call commit handler */ } /*------------------------------------------------------------------*/ /* Private handler : get cts mode */ -static int ks_wlan_get_cts_mode(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_cts_mode(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ *uwrq = priv->reg.cts_mode; return 0; } @@ -2348,38 +2683,41 @@ static int ks_wlan_get_cts_mode(struct net_device *dev, struct iw_request_info * /*------------------------------------------------------------------*/ /* Private handler : set sleep mode */ static int ks_wlan_set_sleep_mode(struct net_device *dev, - struct iw_request_info *info, - __u32 *uwrq, char *extra) + struct iw_request_info *info, + __u32 * uwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - DPRINTK(2,"\n"); + DPRINTK(2, "\n"); - if(*uwrq == SLP_SLEEP){ + if (*uwrq == SLP_SLEEP) { priv->sleep_mode = *uwrq; printk("SET_SLEEP_MODE %d\n", priv->sleep_mode); hostif_sme_enqueue(priv, SME_STOP_REQUEST); hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); - }else if(*uwrq == SLP_ACTIVE) { + } else if (*uwrq == SLP_ACTIVE) { priv->sleep_mode = *uwrq; printk("SET_SLEEP_MODE %d\n", priv->sleep_mode); hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); - }else{ + } else { printk("SET_SLEEP_MODE %d errror\n", *uwrq); - return -EINVAL; + return -EINVAL; } return 0; } + /*------------------------------------------------------------------*/ /* Private handler : get sleep mode */ static int ks_wlan_get_sleep_mode(struct net_device *dev, - struct iw_request_info *info, - __u32 *uwrq, char *extra) + struct iw_request_info *info, + __u32 * uwrq, char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); DPRINTK(2, "GET_SLEEP_MODE %d\n", priv->sleep_mode); *uwrq = priv->sleep_mode; @@ -2390,17 +2728,20 @@ static int ks_wlan_get_sleep_mode(struct net_device *dev, #if 0 /*------------------------------------------------------------------*/ /* Private handler : set phy information timer */ -static int ks_wlan_set_phy_information_timer(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_phy_information_timer(struct net_device *dev, + struct iw_request_info *info, + __u32 * uwrq, char *extra) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - if(*uwrq >= 0 && *uwrq <= 0xFFFF) /* 0-65535 */ - priv->reg.phy_info_timer = (uint16_t)*uwrq; + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (*uwrq >= 0 && *uwrq <= 0xFFFF) /* 0-65535 */ + priv->reg.phy_info_timer = (uint16_t) * uwrq; else - return -EINVAL; + return -EINVAL; hostif_sme_enqueue(priv, SME_PHY_INFO_REQUEST); @@ -2409,13 +2750,16 @@ static int ks_wlan_set_phy_information_timer(struct net_device *dev, struct iw_r /*------------------------------------------------------------------*/ /* Private handler : get phy information timer */ -static int ks_wlan_get_phy_information_timer(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_phy_information_timer(struct net_device *dev, + struct iw_request_info *info, + __u32 * uwrq, char *extra) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ *uwrq = priv->reg.phy_info_timer; return 0; } @@ -2424,38 +2768,48 @@ static int ks_wlan_get_phy_information_timer(struct net_device *dev, struct iw_r #ifdef WPS /*------------------------------------------------------------------*/ /* Private handler : set WPS enable */ -static int ks_wlan_set_wps_enable(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_wps_enable(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - DPRINTK(2,"\n"); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + DPRINTK(2, "\n"); - if(*uwrq == 0 || *uwrq == 1) + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (*uwrq == 0 || *uwrq == 1) priv->wps.wps_enabled = *uwrq; else - return -EINVAL; + return -EINVAL; hostif_sme_enqueue(priv, SME_WPS_ENABLE_REQUEST); return 0; } + /*------------------------------------------------------------------*/ /* Private handler : get WPS enable */ -static int ks_wlan_get_wps_enable(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_wps_enable(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - DPRINTK(2,"\n"); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + DPRINTK(2, "\n"); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ *uwrq = priv->wps.wps_enabled; printk("return=%d\n", *uwrq); return 0; } + /*------------------------------------------------------------------*/ /* Private handler : set WPS probe req */ static int ks_wlan_set_wps_probe_req(struct net_device *dev, @@ -2464,45 +2818,52 @@ static int ks_wlan_set_wps_probe_req(struct net_device *dev, { uint8_t *p = extra; unsigned char len; - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - DPRINTK(2,"\n"); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + DPRINTK(2, "\n"); - DPRINTK(2,"dwrq->length=%d\n", dwrq->length); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + DPRINTK(2, "dwrq->length=%d\n", dwrq->length); /* length check */ - if(p[1] + 2 != dwrq->length || dwrq->length > 256 ){ + if (p[1] + 2 != dwrq->length || dwrq->length > 256) { return -EINVAL; } - priv->wps.ielen = p[1] + 2 + 1; /* IE header + IE + sizeof(len) */ - len = p[1] + 2; /* IE header + IE */ + priv->wps.ielen = p[1] + 2 + 1; /* IE header + IE + sizeof(len) */ + len = p[1] + 2; /* IE header + IE */ memcpy(priv->wps.ie, &len, sizeof(len)); - p = memcpy(priv->wps.ie+1, p, len); + p = memcpy(priv->wps.ie + 1, p, len); - DPRINTK(2,"%d(%#x): %02X %02X %02X %02X ... %02X %02X %02X\n", + DPRINTK(2, "%d(%#x): %02X %02X %02X %02X ... %02X %02X %02X\n", priv->wps.ielen, priv->wps.ielen, p[0], p[1], p[2], p[3], - p[priv->wps.ielen-3], p[priv->wps.ielen-2], p[priv->wps.ielen-1]); + p[priv->wps.ielen - 3], p[priv->wps.ielen - 2], + p[priv->wps.ielen - 1]); hostif_sme_enqueue(priv, SME_WPS_PROBE_REQUEST); return 0; } + #if 0 /*------------------------------------------------------------------*/ /* Private handler : get WPS probe req */ static int ks_wlan_get_wps_probe_req(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) + __u32 * uwrq, char *extra) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; - DPRINTK(2,"\n"); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + DPRINTK(2, "\n"); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ return 0; } #endif @@ -2510,37 +2871,44 @@ static int ks_wlan_get_wps_probe_req(struct net_device *dev, /*------------------------------------------------------------------*/ /* Private handler : set tx gain control value */ -static int ks_wlan_set_tx_gain(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_tx_gain(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - if(*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ - priv->gain.TxGain = (uint8_t)*uwrq; + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ + priv->gain.TxGain = (uint8_t) * uwrq; else - return -EINVAL; + return -EINVAL; - if(priv->gain.TxGain < 0xFF) + if (priv->gain.TxGain < 0xFF) priv->gain.TxMode = 1; else priv->gain.TxMode = 0; - hostif_sme_enqueue(priv, SME_SET_GAIN); - return 0; + return 0; } /*------------------------------------------------------------------*/ /* Private handler : get tx gain control value */ -static int ks_wlan_get_tx_gain(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_tx_gain(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ *uwrq = priv->gain.TxGain; hostif_sme_enqueue(priv, SME_GET_GAIN); return 0; @@ -2548,180 +2916,195 @@ static int ks_wlan_get_tx_gain(struct net_device *dev, struct iw_request_info *i /*------------------------------------------------------------------*/ /* Private handler : set rx gain control value */ -static int ks_wlan_set_rx_gain(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_rx_gain(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - if(*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ - priv->gain.RxGain = (uint8_t)*uwrq; + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ + priv->gain.RxGain = (uint8_t) * uwrq; else - return -EINVAL; + return -EINVAL; - if(priv->gain.RxGain < 0xFF) + if (priv->gain.RxGain < 0xFF) priv->gain.RxMode = 1; else priv->gain.RxMode = 0; hostif_sme_enqueue(priv, SME_SET_GAIN); - return 0; + return 0; } /*------------------------------------------------------------------*/ /* Private handler : get rx gain control value */ -static int ks_wlan_get_rx_gain(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_rx_gain(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); - - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ *uwrq = priv->gain.RxGain; hostif_sme_enqueue(priv, SME_GET_GAIN); return 0; } + #if 0 /*------------------------------------------------------------------*/ /* Private handler : set region value */ -static int ks_wlan_set_region(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_set_region(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; - if (priv->sleep_mode == SLP_SLEEP){ return -EPERM; } /* for SLEEP MODE */ - - if(*uwrq >= 0x9 && *uwrq <= 0xF) /* 0x9-0xf */ - priv->region = (uint8_t)*uwrq; + if (priv->sleep_mode == SLP_SLEEP) { + return -EPERM; + } + /* for SLEEP MODE */ + if (*uwrq >= 0x9 && *uwrq <= 0xF) /* 0x9-0xf */ + priv->region = (uint8_t) * uwrq; else - return -EINVAL; + return -EINVAL; hostif_sme_enqueue(priv, SME_SET_REGION); - return 0; + return 0; } #endif /*------------------------------------------------------------------*/ /* Private handler : get eeprom checksum result */ -static int ks_wlan_get_eeprom_cksum(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) +static int ks_wlan_get_eeprom_cksum(struct net_device *dev, + struct iw_request_info *info, __u32 * uwrq, + char *extra) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); *uwrq = priv->eeprom_checksum; return 0; } -static void print_hif_event(int event){ +static void print_hif_event(int event) +{ - switch(event){ - case HIF_DATA_REQ : + switch (event) { + case HIF_DATA_REQ: printk("HIF_DATA_REQ\n"); break; - case HIF_DATA_IND : + case HIF_DATA_IND: printk("HIF_DATA_IND\n"); break; - case HIF_MIB_GET_REQ : + case HIF_MIB_GET_REQ: printk("HIF_MIB_GET_REQ\n"); break; - case HIF_MIB_GET_CONF : + case HIF_MIB_GET_CONF: printk("HIF_MIB_GET_CONF\n"); break; - case HIF_MIB_SET_REQ : + case HIF_MIB_SET_REQ: printk("HIF_MIB_SET_REQ\n"); break; - case HIF_MIB_SET_CONF : + case HIF_MIB_SET_CONF: printk("HIF_MIB_SET_CONF\n"); break; - case HIF_POWERMGT_REQ : + case HIF_POWERMGT_REQ: printk("HIF_POWERMGT_REQ\n"); break; - case HIF_POWERMGT_CONF : + case HIF_POWERMGT_CONF: printk("HIF_POWERMGT_CONF\n"); break; - case HIF_START_REQ : + case HIF_START_REQ: printk("HIF_START_REQ\n"); break; - case HIF_START_CONF : + case HIF_START_CONF: printk("HIF_START_CONF\n"); break; - case HIF_CONNECT_IND : + case HIF_CONNECT_IND: printk("HIF_CONNECT_IND\n"); break; - case HIF_STOP_REQ : + case HIF_STOP_REQ: printk("HIF_STOP_REQ\n"); break; - case HIF_STOP_CONF : + case HIF_STOP_CONF: printk("HIF_STOP_CONF\n"); break; - case HIF_PS_ADH_SET_REQ : + case HIF_PS_ADH_SET_REQ: printk("HIF_PS_ADH_SET_REQ\n"); break; case HIF_PS_ADH_SET_CONF: printk("HIF_PS_ADH_SET_CONF\n"); break; - case HIF_INFRA_SET_REQ : + case HIF_INFRA_SET_REQ: printk("HIF_INFRA_SET_REQ\n"); break; - case HIF_INFRA_SET_CONF : + case HIF_INFRA_SET_CONF: printk("HIF_INFRA_SET_CONF\n"); break; - case HIF_ADH_SET_REQ : + case HIF_ADH_SET_REQ: printk("HIF_ADH_SET_REQ\n"); break; - case HIF_ADH_SET_CONF : + case HIF_ADH_SET_CONF: printk("HIF_ADH_SET_CONF\n"); break; - case HIF_AP_SET_REQ : + case HIF_AP_SET_REQ: printk("HIF_AP_SET_REQ\n"); break; - case HIF_AP_SET_CONF : + case HIF_AP_SET_CONF: printk("HIF_AP_SET_CONF\n"); break; - case HIF_ASSOC_INFO_IND : + case HIF_ASSOC_INFO_IND: printk("HIF_ASSOC_INFO_IND\n"); break; case HIF_MIC_FAILURE_REQ: printk("HIF_MIC_FAILURE_REQ\n"); break; - case HIF_MIC_FAILURE_CONF : + case HIF_MIC_FAILURE_CONF: printk("HIF_MIC_FAILURE_CONF\n"); break; - case HIF_SCAN_REQ : + case HIF_SCAN_REQ: printk("HIF_SCAN_REQ\n"); break; - case HIF_SCAN_CONF : + case HIF_SCAN_CONF: printk("HIF_SCAN_CONF\n"); break; - case HIF_PHY_INFO_REQ : + case HIF_PHY_INFO_REQ: printk("HIF_PHY_INFO_REQ\n"); break; - case HIF_PHY_INFO_CONF : + case HIF_PHY_INFO_CONF: printk("HIF_PHY_INFO_CONF\n"); break; - case HIF_SLEEP_REQ : + case HIF_SLEEP_REQ: printk("HIF_SLEEP_REQ\n"); break; - case HIF_SLEEP_CONF : + case HIF_SLEEP_CONF: printk("HIF_SLEEP_CONF\n"); break; - case HIF_PHY_INFO_IND : + case HIF_PHY_INFO_IND: printk("HIF_PHY_INFO_IND\n"); break; - case HIF_SCAN_IND : + case HIF_SCAN_IND: printk("HIF_SCAN_IND\n"); break; - case HIF_INFRA_SET2_REQ : + case HIF_INFRA_SET2_REQ: printk("HIF_INFRA_SET2_REQ\n"); break; case HIF_INFRA_SET2_CONF: printk("HIF_INFRA_SET2_CONF\n"); break; - case HIF_ADH_SET2_REQ : + case HIF_ADH_SET2_REQ: printk("HIF_ADH_SET2_REQ\n"); break; - case HIF_ADH_SET2_CONF : + case HIF_ADH_SET2_CONF: printk("HIF_ADH_SET2_CONF\n"); } } @@ -2729,13 +3112,16 @@ static void print_hif_event(int event){ /*------------------------------------------------------------------*/ /* Private handler : get host command history */ static int ks_wlan_hostt(struct net_device *dev, struct iw_request_info *info, - __u32 *uwrq, char *extra) + __u32 * uwrq, char *extra) { - int i,event; - struct ks_wlan_private *priv = (struct ks_wlan_private *)netdev_priv(dev); + int i, event; + struct ks_wlan_private *priv = + (struct ks_wlan_private *)netdev_priv(dev); - for(i = 63; i >= 0; i--){ - event = priv->hostt.buff[(priv->hostt.qtail -1 -i)%SME_EVENT_BUFF_SIZE] ; + for (i = 63; i >= 0; i--) { + event = + priv->hostt.buff[(priv->hostt.qtail - 1 - i) % + SME_EVENT_BUFF_SIZE]; print_hif_event(event); } return 0; @@ -2745,190 +3131,213 @@ static int ks_wlan_hostt(struct net_device *dev, struct iw_request_info *info, static const struct iw_priv_args ks_wlan_private_args[] = { /*{ cmd, set_args, get_args, name[16] } */ - { KS_WLAN_GET_DRIVER_VERSION, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128+1), "GetDriverVer" }, - { KS_WLAN_GET_FIRM_VERSION, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128+1), "GetFirmwareVer" }, + {KS_WLAN_GET_DRIVER_VERSION, IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_CHAR | (128 + 1), "GetDriverVer"}, + {KS_WLAN_GET_FIRM_VERSION, IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_CHAR | (128 + 1), "GetFirmwareVer"}, #ifdef WPS - { KS_WLAN_SET_WPS_ENABLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetWPSEnable" }, - { KS_WLAN_GET_WPS_ENABLE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetW" }, - { KS_WLAN_SET_WPS_PROBE_REQ, IW_PRIV_TYPE_BYTE | 2047, IW_PRIV_TYPE_NONE, "SetWPSProbeReq" }, + {KS_WLAN_SET_WPS_ENABLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, "SetWPSEnable"}, + {KS_WLAN_GET_WPS_ENABLE, IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetW"}, + {KS_WLAN_SET_WPS_PROBE_REQ, IW_PRIV_TYPE_BYTE | 2047, IW_PRIV_TYPE_NONE, + "SetWPSProbeReq"}, #endif /* WPS */ - { KS_WLAN_SET_PREAMBLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetPreamble" }, - { KS_WLAN_GET_PREAMBLE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPreamble" }, - { KS_WLAN_SET_POWER_SAVE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetPowerSave" }, - { KS_WLAN_GET_POWER_SAVE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPowerSave" }, - { KS_WLAN_SET_SCAN_TYPE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetScanType" }, - { KS_WLAN_GET_SCAN_TYPE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetScanType" }, - { KS_WLAN_SET_RX_GAIN, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetRxGain" }, - { KS_WLAN_GET_RX_GAIN, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetRxGain" }, - { KS_WLAN_HOSTT, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128+1), "hostt" }, - { KS_WLAN_SET_BEACON_LOST, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetBeaconLost" }, - { KS_WLAN_GET_BEACON_LOST, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetBeaconLost" }, - { KS_WLAN_SET_SLEEP_MODE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetSleepMode" }, - { KS_WLAN_GET_SLEEP_MODE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetSleepMode" }, - { KS_WLAN_SET_TX_GAIN, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetTxGain" }, - { KS_WLAN_GET_TX_GAIN, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetTxGain" }, - { KS_WLAN_SET_PHY_TYPE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetPhyType" }, - { KS_WLAN_GET_PHY_TYPE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPhyType" }, - { KS_WLAN_SET_CTS_MODE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetCtsMode" }, - { KS_WLAN_GET_CTS_MODE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetCtsMode" }, - { KS_WLAN_GET_EEPROM_CKSUM, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetChecksum" }, + {KS_WLAN_SET_PREAMBLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, "SetPreamble"}, + {KS_WLAN_GET_PREAMBLE, IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPreamble"}, + {KS_WLAN_SET_POWER_SAVE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, "SetPowerSave"}, + {KS_WLAN_GET_POWER_SAVE, IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPowerSave"}, + {KS_WLAN_SET_SCAN_TYPE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, "SetScanType"}, + {KS_WLAN_GET_SCAN_TYPE, IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetScanType"}, + {KS_WLAN_SET_RX_GAIN, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, "SetRxGain"}, + {KS_WLAN_GET_RX_GAIN, IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetRxGain"}, + {KS_WLAN_HOSTT, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128 + 1), + "hostt"}, + {KS_WLAN_SET_BEACON_LOST, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, "SetBeaconLost"}, + {KS_WLAN_GET_BEACON_LOST, IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetBeaconLost"}, + {KS_WLAN_SET_SLEEP_MODE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, "SetSleepMode"}, + {KS_WLAN_GET_SLEEP_MODE, IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetSleepMode"}, + {KS_WLAN_SET_TX_GAIN, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, "SetTxGain"}, + {KS_WLAN_GET_TX_GAIN, IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetTxGain"}, + {KS_WLAN_SET_PHY_TYPE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, "SetPhyType"}, + {KS_WLAN_GET_PHY_TYPE, IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetPhyType"}, + {KS_WLAN_SET_CTS_MODE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + IW_PRIV_TYPE_NONE, "SetCtsMode"}, + {KS_WLAN_GET_CTS_MODE, IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetCtsMode"}, + {KS_WLAN_GET_EEPROM_CKSUM, IW_PRIV_TYPE_NONE, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetChecksum"}, }; -static const iw_handler ks_wlan_handler[] = -{ + +static const iw_handler ks_wlan_handler[] = { (iw_handler) ks_wlan_config_commit, /* SIOCSIWCOMMIT */ - (iw_handler) ks_wlan_get_name, /* SIOCGIWNAME */ - (iw_handler) NULL, /* SIOCSIWNWID */ - (iw_handler) NULL, /* SIOCGIWNWID */ - (iw_handler) ks_wlan_set_freq, /* SIOCSIWFREQ */ - (iw_handler) ks_wlan_get_freq, /* SIOCGIWFREQ */ - (iw_handler) ks_wlan_set_mode, /* SIOCSIWMODE */ - (iw_handler) ks_wlan_get_mode, /* SIOCGIWMODE */ + (iw_handler) ks_wlan_get_name, /* SIOCGIWNAME */ + (iw_handler) NULL, /* SIOCSIWNWID */ + (iw_handler) NULL, /* SIOCGIWNWID */ + (iw_handler) ks_wlan_set_freq, /* SIOCSIWFREQ */ + (iw_handler) ks_wlan_get_freq, /* SIOCGIWFREQ */ + (iw_handler) ks_wlan_set_mode, /* SIOCSIWMODE */ + (iw_handler) ks_wlan_get_mode, /* SIOCGIWMODE */ #ifndef KSC_OPNOTSUPP - (iw_handler) ks_wlan_set_sens, /* SIOCSIWSENS */ - (iw_handler) ks_wlan_get_sens, /* SIOCGIWSENS */ + (iw_handler) ks_wlan_set_sens, /* SIOCSIWSENS */ + (iw_handler) ks_wlan_get_sens, /* SIOCGIWSENS */ #else /* KSC_OPNOTSUPP */ - (iw_handler) NULL, /* SIOCSIWSENS */ - (iw_handler) NULL, /* SIOCGIWSENS */ + (iw_handler) NULL, /* SIOCSIWSENS */ + (iw_handler) NULL, /* SIOCGIWSENS */ #endif /* KSC_OPNOTSUPP */ - (iw_handler) NULL, /* SIOCSIWRANGE */ - (iw_handler) ks_wlan_get_range, /* SIOCGIWRANGE */ - (iw_handler) NULL, /* SIOCSIWPRIV */ - (iw_handler) NULL, /* SIOCGIWPRIV */ - (iw_handler) NULL, /* SIOCSIWSTATS */ + (iw_handler) NULL, /* SIOCSIWRANGE */ + (iw_handler) ks_wlan_get_range, /* SIOCGIWRANGE */ + (iw_handler) NULL, /* SIOCSIWPRIV */ + (iw_handler) NULL, /* SIOCGIWPRIV */ + (iw_handler) NULL, /* SIOCSIWSTATS */ (iw_handler) ks_wlan_get_iwstats, /* SIOCGIWSTATS */ - (iw_handler) NULL, /* SIOCSIWSPY */ - (iw_handler) NULL, /* SIOCGIWSPY */ - (iw_handler) NULL, /* SIOCSIWTHRSPY */ - (iw_handler) NULL, /* SIOCGIWTHRSPY */ - (iw_handler) ks_wlan_set_wap, /* SIOCSIWAP */ - (iw_handler) ks_wlan_get_wap, /* SIOCGIWAP */ -// (iw_handler) NULL, /* SIOCSIWMLME */ - (iw_handler) ks_wlan_set_mlme, /* SIOCSIWMLME */ + (iw_handler) NULL, /* SIOCSIWSPY */ + (iw_handler) NULL, /* SIOCGIWSPY */ + (iw_handler) NULL, /* SIOCSIWTHRSPY */ + (iw_handler) NULL, /* SIOCGIWTHRSPY */ + (iw_handler) ks_wlan_set_wap, /* SIOCSIWAP */ + (iw_handler) ks_wlan_get_wap, /* SIOCGIWAP */ +// (iw_handler) NULL, /* SIOCSIWMLME */ + (iw_handler) ks_wlan_set_mlme, /* SIOCSIWMLME */ (iw_handler) ks_wlan_get_aplist, /* SIOCGIWAPLIST */ - (iw_handler) ks_wlan_set_scan, /* SIOCSIWSCAN */ - (iw_handler) ks_wlan_get_scan, /* SIOCGIWSCAN */ - (iw_handler) ks_wlan_set_essid, /* SIOCSIWESSID */ - (iw_handler) ks_wlan_get_essid, /* SIOCGIWESSID */ - (iw_handler) ks_wlan_set_nick, /* SIOCSIWNICKN */ - (iw_handler) ks_wlan_get_nick, /* SIOCGIWNICKN */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) ks_wlan_set_rate, /* SIOCSIWRATE */ - (iw_handler) ks_wlan_get_rate, /* SIOCGIWRATE */ - (iw_handler) ks_wlan_set_rts, /* SIOCSIWRTS */ - (iw_handler) ks_wlan_get_rts, /* SIOCGIWRTS */ - (iw_handler) ks_wlan_set_frag, /* SIOCSIWFRAG */ - (iw_handler) ks_wlan_get_frag, /* SIOCGIWFRAG */ + (iw_handler) ks_wlan_set_scan, /* SIOCSIWSCAN */ + (iw_handler) ks_wlan_get_scan, /* SIOCGIWSCAN */ + (iw_handler) ks_wlan_set_essid, /* SIOCSIWESSID */ + (iw_handler) ks_wlan_get_essid, /* SIOCGIWESSID */ + (iw_handler) ks_wlan_set_nick, /* SIOCSIWNICKN */ + (iw_handler) ks_wlan_get_nick, /* SIOCGIWNICKN */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) ks_wlan_set_rate, /* SIOCSIWRATE */ + (iw_handler) ks_wlan_get_rate, /* SIOCGIWRATE */ + (iw_handler) ks_wlan_set_rts, /* SIOCSIWRTS */ + (iw_handler) ks_wlan_get_rts, /* SIOCGIWRTS */ + (iw_handler) ks_wlan_set_frag, /* SIOCSIWFRAG */ + (iw_handler) ks_wlan_get_frag, /* SIOCGIWFRAG */ #ifndef KSC_OPNOTSUPP - (iw_handler) ks_wlan_set_txpow, /* SIOCSIWTXPOW */ - (iw_handler) ks_wlan_get_txpow, /* SIOCGIWTXPOW */ - (iw_handler) ks_wlan_set_retry, /* SIOCSIWRETRY */ - (iw_handler) ks_wlan_get_retry, /* SIOCGIWRETRY */ + (iw_handler) ks_wlan_set_txpow, /* SIOCSIWTXPOW */ + (iw_handler) ks_wlan_get_txpow, /* SIOCGIWTXPOW */ + (iw_handler) ks_wlan_set_retry, /* SIOCSIWRETRY */ + (iw_handler) ks_wlan_get_retry, /* SIOCGIWRETRY */ #else /* KSC_OPNOTSUPP */ - (iw_handler) NULL, /* SIOCSIWTXPOW */ - (iw_handler) NULL, /* SIOCGIWTXPOW */ - (iw_handler) NULL, /* SIOCSIWRETRY */ - (iw_handler) NULL, /* SIOCGIWRETRY */ + (iw_handler) NULL, /* SIOCSIWTXPOW */ + (iw_handler) NULL, /* SIOCGIWTXPOW */ + (iw_handler) NULL, /* SIOCSIWRETRY */ + (iw_handler) NULL, /* SIOCGIWRETRY */ #endif /* KSC_OPNOTSUPP */ (iw_handler) ks_wlan_set_encode, /* SIOCSIWENCODE */ (iw_handler) ks_wlan_get_encode, /* SIOCGIWENCODE */ - (iw_handler) ks_wlan_set_power, /* SIOCSIWPOWER */ - (iw_handler) ks_wlan_get_power, /* SIOCGIWPOWER */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ -// (iw_handler) NULL, /* SIOCSIWGENIE */ - (iw_handler) ks_wlan_set_genie, /* SIOCSIWGENIE */ - (iw_handler) NULL, /* SIOCGIWGENIE */ + (iw_handler) ks_wlan_set_power, /* SIOCSIWPOWER */ + (iw_handler) ks_wlan_get_power, /* SIOCGIWPOWER */ + (iw_handler) NULL, /* -- hole -- */ + (iw_handler) NULL, /* -- hole -- */ +// (iw_handler) NULL, /* SIOCSIWGENIE */ + (iw_handler) ks_wlan_set_genie, /* SIOCSIWGENIE */ + (iw_handler) NULL, /* SIOCGIWGENIE */ (iw_handler) ks_wlan_set_auth_mode, /* SIOCSIWAUTH */ (iw_handler) ks_wlan_get_auth_mode, /* SIOCGIWAUTH */ (iw_handler) ks_wlan_set_encode_ext, /* SIOCSIWENCODEEXT */ (iw_handler) ks_wlan_get_encode_ext, /* SIOCGIWENCODEEXT */ - (iw_handler) ks_wlan_set_pmksa, /* SIOCSIWPMKSA */ - (iw_handler) NULL, /* -- hole -- */ + (iw_handler) ks_wlan_set_pmksa, /* SIOCSIWPMKSA */ + (iw_handler) NULL, /* -- hole -- */ }; /* private_handler */ -static const iw_handler ks_wlan_private_handler[] = -{ - (iw_handler) NULL, /* 0 */ +static const iw_handler ks_wlan_private_handler[] = { + (iw_handler) NULL, /* 0 */ (iw_handler) ks_wlan_get_driver_version, /* 1 KS_WLAN_GET_DRIVER_VERSION */ - (iw_handler) NULL, /* 2 */ + (iw_handler) NULL, /* 2 */ (iw_handler) ks_wlan_get_firmware_version, /* 3 KS_WLAN_GET_FIRM_VERSION */ #ifdef WPS - (iw_handler) ks_wlan_set_wps_enable, /* 4 KS_WLAN_SET_WPS_ENABLE */ - (iw_handler) ks_wlan_get_wps_enable, /* 5 KS_WLAN_GET_WPS_ENABLE */ - (iw_handler) ks_wlan_set_wps_probe_req, /* 6 KS_WLAN_SET_WPS_PROBE_REQ */ + (iw_handler) ks_wlan_set_wps_enable, /* 4 KS_WLAN_SET_WPS_ENABLE */ + (iw_handler) ks_wlan_get_wps_enable, /* 5 KS_WLAN_GET_WPS_ENABLE */ + (iw_handler) ks_wlan_set_wps_probe_req, /* 6 KS_WLAN_SET_WPS_PROBE_REQ */ #else - (iw_handler) NULL, /* 4 */ - (iw_handler) NULL, /* 5 */ - (iw_handler) NULL, /* 6 */ + (iw_handler) NULL, /* 4 */ + (iw_handler) NULL, /* 5 */ + (iw_handler) NULL, /* 6 */ #endif /* WPS */ - (iw_handler) ks_wlan_get_eeprom_cksum, /* 7 KS_WLAN_GET_CONNECT */ - (iw_handler) ks_wlan_set_preamble, /* 8 KS_WLAN_SET_PREAMBLE */ - (iw_handler) ks_wlan_get_preamble, /* 9 KS_WLAN_GET_PREAMBLE */ - (iw_handler) ks_wlan_set_powermgt, /* 10 KS_WLAN_SET_POWER_SAVE */ - (iw_handler) ks_wlan_get_powermgt, /* 11 KS_WLAN_GET_POWER_SAVE */ - (iw_handler) ks_wlan_set_scan_type, /* 12 KS_WLAN_SET_SCAN_TYPE */ - (iw_handler) ks_wlan_get_scan_type, /* 13 KS_WLAN_GET_SCAN_TYPE */ - (iw_handler) ks_wlan_set_rx_gain, /* 14 KS_WLAN_SET_RX_GAIN */ - (iw_handler) ks_wlan_get_rx_gain, /* 15 KS_WLAN_GET_RX_GAIN */ - (iw_handler) ks_wlan_hostt, /* 16 KS_WLAN_HOSTT */ - (iw_handler) NULL, /* 17 */ - (iw_handler) ks_wlan_set_beacon_lost, /* 18 KS_WLAN_SET_BECAN_LOST */ - (iw_handler) ks_wlan_get_beacon_lost, /* 19 KS_WLAN_GET_BECAN_LOST */ - (iw_handler) ks_wlan_set_tx_gain, /* 20 KS_WLAN_SET_TX_GAIN */ - (iw_handler) ks_wlan_get_tx_gain, /* 21 KS_WLAN_GET_TX_GAIN */ - (iw_handler) ks_wlan_set_phy_type, /* 22 KS_WLAN_SET_PHY_TYPE */ - (iw_handler) ks_wlan_get_phy_type, /* 23 KS_WLAN_GET_PHY_TYPE */ - (iw_handler) ks_wlan_set_cts_mode, /* 24 KS_WLAN_SET_CTS_MODE */ - (iw_handler) ks_wlan_get_cts_mode, /* 25 KS_WLAN_GET_CTS_MODE */ - (iw_handler) NULL, /* 26 */ - (iw_handler) NULL, /* 27 */ - (iw_handler) ks_wlan_set_sleep_mode, /* 28 KS_WLAN_SET_SLEEP_MODE */ - (iw_handler) ks_wlan_get_sleep_mode, /* 29 KS_WLAN_GET_SLEEP_MODE */ - (iw_handler) NULL, /* 30 */ - (iw_handler) NULL, /* 31 */ + (iw_handler) ks_wlan_get_eeprom_cksum, /* 7 KS_WLAN_GET_CONNECT */ + (iw_handler) ks_wlan_set_preamble, /* 8 KS_WLAN_SET_PREAMBLE */ + (iw_handler) ks_wlan_get_preamble, /* 9 KS_WLAN_GET_PREAMBLE */ + (iw_handler) ks_wlan_set_powermgt, /* 10 KS_WLAN_SET_POWER_SAVE */ + (iw_handler) ks_wlan_get_powermgt, /* 11 KS_WLAN_GET_POWER_SAVE */ + (iw_handler) ks_wlan_set_scan_type, /* 12 KS_WLAN_SET_SCAN_TYPE */ + (iw_handler) ks_wlan_get_scan_type, /* 13 KS_WLAN_GET_SCAN_TYPE */ + (iw_handler) ks_wlan_set_rx_gain, /* 14 KS_WLAN_SET_RX_GAIN */ + (iw_handler) ks_wlan_get_rx_gain, /* 15 KS_WLAN_GET_RX_GAIN */ + (iw_handler) ks_wlan_hostt, /* 16 KS_WLAN_HOSTT */ + (iw_handler) NULL, /* 17 */ + (iw_handler) ks_wlan_set_beacon_lost, /* 18 KS_WLAN_SET_BECAN_LOST */ + (iw_handler) ks_wlan_get_beacon_lost, /* 19 KS_WLAN_GET_BECAN_LOST */ + (iw_handler) ks_wlan_set_tx_gain, /* 20 KS_WLAN_SET_TX_GAIN */ + (iw_handler) ks_wlan_get_tx_gain, /* 21 KS_WLAN_GET_TX_GAIN */ + (iw_handler) ks_wlan_set_phy_type, /* 22 KS_WLAN_SET_PHY_TYPE */ + (iw_handler) ks_wlan_get_phy_type, /* 23 KS_WLAN_GET_PHY_TYPE */ + (iw_handler) ks_wlan_set_cts_mode, /* 24 KS_WLAN_SET_CTS_MODE */ + (iw_handler) ks_wlan_get_cts_mode, /* 25 KS_WLAN_GET_CTS_MODE */ + (iw_handler) NULL, /* 26 */ + (iw_handler) NULL, /* 27 */ + (iw_handler) ks_wlan_set_sleep_mode, /* 28 KS_WLAN_SET_SLEEP_MODE */ + (iw_handler) ks_wlan_get_sleep_mode, /* 29 KS_WLAN_GET_SLEEP_MODE */ + (iw_handler) NULL, /* 30 */ + (iw_handler) NULL, /* 31 */ }; -static const struct iw_handler_def ks_wlan_handler_def = -{ - .num_standard = sizeof(ks_wlan_handler)/sizeof(iw_handler), - .num_private = sizeof(ks_wlan_private_handler)/sizeof(iw_handler), - .num_private_args = sizeof(ks_wlan_private_args)/sizeof(struct iw_priv_args), - .standard = (iw_handler *) ks_wlan_handler, - .private = (iw_handler *) ks_wlan_private_handler, - .private_args = (struct iw_priv_args *) ks_wlan_private_args, +static const struct iw_handler_def ks_wlan_handler_def = { + .num_standard = sizeof(ks_wlan_handler) / sizeof(iw_handler), + .num_private = sizeof(ks_wlan_private_handler) / sizeof(iw_handler), + .num_private_args = + sizeof(ks_wlan_private_args) / sizeof(struct iw_priv_args), + .standard = (iw_handler *) ks_wlan_handler, + .private = (iw_handler *) ks_wlan_private_handler, + .private_args = (struct iw_priv_args *)ks_wlan_private_args, .get_wireless_stats = ks_get_wireless_stats, }; - -static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, + int cmd) { int rc = 0; - struct iwreq *wrq = (struct iwreq *) rq; + struct iwreq *wrq = (struct iwreq *)rq; switch (cmd) { - case SIOCIWFIRSTPRIV+20: /* KS_WLAN_SET_STOP_REQ */ + case SIOCIWFIRSTPRIV + 20: /* KS_WLAN_SET_STOP_REQ */ rc = ks_wlan_set_stop_request(dev, NULL, &(wrq->u.mode), NULL); break; - // All other calls are currently unsupported + // All other calls are currently unsupported default: rc = -EOPNOTSUPP; } - DPRINTK(5,"return=%d\n",rc); + DPRINTK(5, "return=%d\n", rc); return rc; } - static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev) { struct ks_wlan_private *priv = netdev_priv(dev); if (priv->dev_state < DEVICE_STATE_READY) { - return NULL; /* not finished initialize */ - } + return NULL; /* not finished initialize */ + } return &priv->nstats; } @@ -2937,7 +3346,7 @@ static int ks_wlan_set_mac_address(struct net_device *dev, void *addr) { struct ks_wlan_private *priv = netdev_priv(dev); - struct sockaddr *mac_addr=(struct sockaddr *)addr; + struct sockaddr *mac_addr = (struct sockaddr *)addr; if (netif_running(dev)) return -EBUSY; memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len); @@ -2945,20 +3354,21 @@ int ks_wlan_set_mac_address(struct net_device *dev, void *addr) priv->mac_address_valid = 0; hostif_sme_enqueue(priv, SME_MACADDRESS_SET_REQUEST); - printk(KERN_INFO "ks_wlan: MAC ADDRESS = %02x:%02x:%02x:%02x:%02x:%02x\n", - priv->eth_addr[0],priv->eth_addr[1],priv->eth_addr[2], - priv->eth_addr[3],priv->eth_addr[4],priv->eth_addr[5]); + printk(KERN_INFO + "ks_wlan: MAC ADDRESS = %02x:%02x:%02x:%02x:%02x:%02x\n", + priv->eth_addr[0], priv->eth_addr[1], priv->eth_addr[2], + priv->eth_addr[3], priv->eth_addr[4], priv->eth_addr[5]); return 0; } - static void ks_wlan_tx_timeout(struct net_device *dev) { - struct ks_wlan_private *priv = netdev_priv(dev); + struct ks_wlan_private *priv = netdev_priv(dev); - DPRINTK(1,"head(%d) tail(%d)!!\n",priv->tx_dev.qhead, priv->tx_dev.qtail); - if(!netif_queue_stopped(dev)){ + DPRINTK(1, "head(%d) tail(%d)!!\n", priv->tx_dev.qhead, + priv->tx_dev.qtail); + if (!netif_queue_stopped(dev)) { netif_stop_queue(dev); } priv->nstats.tx_errors++; @@ -2973,26 +3383,26 @@ int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev) struct ks_wlan_private *priv = netdev_priv(dev); int rc = 0; - DPRINTK(3,"in_interrupt()=%ld\n",in_interrupt()); + DPRINTK(3, "in_interrupt()=%ld\n", in_interrupt()); - if ( skb == NULL ) { - printk( KERN_ERR "ks_wlan: skb == NULL!!!\n" ); + if (skb == NULL) { + printk(KERN_ERR "ks_wlan: skb == NULL!!!\n"); return 0; } if (priv->dev_state < DEVICE_STATE_READY) { dev_kfree_skb(skb); - return 0; /* not finished initialize */ - } + return 0; /* not finished initialize */ + } - if(netif_running(dev)) + if (netif_running(dev)) netif_stop_queue(dev); rc = hostif_data_request(priv, skb); dev->trans_start = jiffies; - DPRINTK(4,"rc=%d\n",rc); - if (rc){ - rc=0; + DPRINTK(4, "rc=%d\n", rc); + if (rc) { + rc = 0; } return rc; @@ -3003,17 +3413,17 @@ void send_packet_complete(void *arg1, void *arg2) struct ks_wlan_private *priv = (struct ks_wlan_private *)arg1; struct sk_buff *packet = (struct sk_buff *)arg2; - DPRINTK(3,"\n"); + DPRINTK(3, "\n"); - priv->nstats.tx_bytes += packet->len; + priv->nstats.tx_bytes += packet->len; priv->nstats.tx_packets++; - if(netif_queue_stopped(priv->net_dev)) - netif_wake_queue(priv->net_dev); + if (netif_queue_stopped(priv->net_dev)) + netif_wake_queue(priv->net_dev); - if(packet){ + if (packet) { dev_kfree_skb(packet); - packet=NULL; + packet = NULL; } } @@ -3025,9 +3435,9 @@ void ks_wlan_set_multicast_list(struct net_device *dev) { struct ks_wlan_private *priv = netdev_priv(dev); - DPRINTK(4,"\n"); + DPRINTK(4, "\n"); if (priv->dev_state < DEVICE_STATE_READY) { - return ; /* not finished initialize */ + return; /* not finished initialize */ } hostif_sme_enqueue(priv, SME_MULTICAST_REQUEST); @@ -3041,12 +3451,11 @@ int ks_wlan_open(struct net_device *dev) priv->cur_rx = 0; - if(!priv->mac_address_valid){ + if (!priv->mac_address_valid) { printk(KERN_ERR "ks_wlan : %s Not READY !!\n", dev->name); return -EBUSY; - } - else - netif_start_queue (dev); + } else + netif_start_queue(dev); return 0; } @@ -3055,7 +3464,7 @@ static int ks_wlan_close(struct net_device *dev) { - netif_stop_queue (dev); + netif_stop_queue(dev); DPRINTK(4, "%s: Shutting down ethercard, status was 0x%4.4x.\n", dev->name, 0x00); @@ -3063,21 +3472,21 @@ int ks_wlan_close(struct net_device *dev) return 0; } - /* Operational parameters that usually are not changed. */ /* Time in jiffies before concluding the transmitter is hung. */ #define TX_TIMEOUT (3*HZ) -static const unsigned char dummy_addr[] = {0x00,0x0b,0xe3,0x00,0x00,0x00}; +static const unsigned char dummy_addr[] = + { 0x00, 0x0b, 0xe3, 0x00, 0x00, 0x00 }; static const struct net_device_ops ks_wlan_netdev_ops = { - .ndo_start_xmit = ks_wlan_start_xmit, - .ndo_open = ks_wlan_open, - .ndo_stop = ks_wlan_close, - .ndo_do_ioctl = ks_wlan_netdev_ioctl, - .ndo_set_mac_address = ks_wlan_set_mac_address, - .ndo_get_stats = ks_wlan_get_stats, - .ndo_tx_timeout = ks_wlan_tx_timeout, - .ndo_set_rx_mode = ks_wlan_set_multicast_list, + .ndo_start_xmit = ks_wlan_start_xmit, + .ndo_open = ks_wlan_open, + .ndo_stop = ks_wlan_close, + .ndo_do_ioctl = ks_wlan_netdev_ioctl, + .ndo_set_mac_address = ks_wlan_set_mac_address, + .ndo_get_stats = ks_wlan_get_stats, + .ndo_tx_timeout = ks_wlan_tx_timeout, + .ndo_set_rx_mode = ks_wlan_set_multicast_list, }; int ks_wlan_net_start(struct net_device *dev) @@ -3092,9 +3501,9 @@ int ks_wlan_net_start(struct net_device *dev) priv->device_open_status = 1; /* phy information update timer */ - atomic_set(&update_phyinfo,0); + atomic_set(&update_phyinfo, 0); init_timer(&update_phyinfo_timer); - update_phyinfo_timer.function=ks_wlan_update_phyinfo_timeout; + update_phyinfo_timer.function = ks_wlan_update_phyinfo_timeout; update_phyinfo_timer.data = (unsigned long)priv; /* dummy address set */ @@ -3118,7 +3527,6 @@ int ks_wlan_net_start(struct net_device *dev) return 0; } - int ks_wlan_net_stop(struct net_device *dev) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -3127,7 +3535,7 @@ int ks_wlan_net_stop(struct net_device *dev) priv->device_open_status = 0; del_timer_sync(&update_phyinfo_timer); - if(netif_running(dev)) + if (netif_running(dev)) netif_stop_queue(dev); return ret; -- cgit v1.1 From cab898fbb0065c4252261e5a20328d5af5afaa8c Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:35 +0200 Subject: staging: ks7010: indent michael_mic.c Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/michael_mic.c | 43 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c index ec8769a..adb17df 100644 --- a/drivers/staging/ks7010/michael_mic.c +++ b/drivers/staging/ks7010/michael_mic.c @@ -34,11 +34,11 @@ A->nBytesInM = 0; static -void MichaelInitializeFunction( struct michel_mic_t *Mic, uint8_t *key ) +void MichaelInitializeFunction(struct michel_mic_t *Mic, uint8_t * key) { // Set the key - Mic->K0 = getUInt32( key , 0 ); - Mic->K1 = getUInt32( key , 4 ); + Mic->K0 = getUInt32(key, 0); + Mic->K1 = getUInt32(key, 4); //clear(); MichaelClear(Mic); @@ -56,11 +56,10 @@ do{ \ L += R; \ }while(0) - static -void MichaelAppend( struct michel_mic_t *Mic, uint8_t *src, int nBytes ) +void MichaelAppend(struct michel_mic_t *Mic, uint8_t * src, int nBytes) { - int addlen ; + int addlen; if (Mic->nBytesInM) { addlen = 4 - Mic->nBytesInM; if (addlen > nBytes) @@ -73,13 +72,13 @@ void MichaelAppend( struct michel_mic_t *Mic, uint8_t *src, int nBytes ) if (Mic->nBytesInM < 4) return; - Mic->L ^= getUInt32(Mic->M,0); + Mic->L ^= getUInt32(Mic->M, 0); MichaelBlockFunction(Mic->L, Mic->R); Mic->nBytesInM = 0; } - while(nBytes >= 4){ - Mic->L ^= getUInt32(src,0); + while (nBytes >= 4) { + Mic->L ^= getUInt32(src, 0); MichaelBlockFunction(Mic->L, Mic->R); src += 4; nBytes -= 4; @@ -92,7 +91,7 @@ void MichaelAppend( struct michel_mic_t *Mic, uint8_t *src, int nBytes ) } static -void MichaelGetMIC( struct michel_mic_t *Mic, uint8_t *dst ) +void MichaelGetMIC(struct michel_mic_t *Mic, uint8_t * dst) { uint8_t *data = Mic->M; switch (Mic->nBytesInM) { @@ -107,24 +106,24 @@ void MichaelGetMIC( struct michel_mic_t *Mic, uint8_t *dst ) break; case 3: Mic->L ^= data[0] | (data[1] << 8) | (data[2] << 16) | - 0x5a000000; + 0x5a000000; break; } MichaelBlockFunction(Mic->L, Mic->R); MichaelBlockFunction(Mic->L, Mic->R); // The appendByte function has already computed the result. - putUInt32( dst, 0, Mic->L ); - putUInt32( dst, 4, Mic->R ); + putUInt32(dst, 0, Mic->L); + putUInt32(dst, 4, Mic->R); // Reset to the empty message. MichaelClear(Mic); } -void MichaelMICFunction( struct michel_mic_t *Mic, uint8_t *Key, - uint8_t *Data, int Len, uint8_t priority, - uint8_t *Result ) +void MichaelMICFunction(struct michel_mic_t *Mic, uint8_t * Key, + uint8_t * Data, int Len, uint8_t priority, + uint8_t * Result) { - uint8_t pad_data[4] = {priority,0,0,0}; + uint8_t pad_data[4] = { priority, 0, 0, 0 }; // Compute the MIC value /* * IEEE802.11i page 47 @@ -135,9 +134,9 @@ void MichaelMICFunction( struct michel_mic_t *Mic, uint8_t *Key, * |DA|SA|Priority|0 |Data|M0|M1|M2|M3|M4|M5|M6|M7| * +--+--+--------+--+----+--+--+--+--+--+--+--+--+ */ - MichaelInitializeFunction( Mic, Key ) ; - MichaelAppend( Mic, (uint8_t*)Data, 12 ); /* |DA|SA| */ - MichaelAppend( Mic, pad_data, 4 ); /* |Priority|0|0|0| */ - MichaelAppend( Mic, (uint8_t*)(Data+12), Len -12 ); /* |Data| */ - MichaelGetMIC( Mic, Result ) ; + MichaelInitializeFunction(Mic, Key); + MichaelAppend(Mic, (uint8_t *) Data, 12); /* |DA|SA| */ + MichaelAppend(Mic, pad_data, 4); /* |Priority|0|0|0| */ + MichaelAppend(Mic, (uint8_t *) (Data + 12), Len - 12); /* |Data| */ + MichaelGetMIC(Mic, Result); } -- cgit v1.1 From 79c2df5866a14fcac4235332fddb4d5a2d99d76d Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:36 +0200 Subject: staging: ks7010: indent michael_mic.h Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/michael_mic.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/ks7010/michael_mic.h b/drivers/staging/ks7010/michael_mic.h index f14f160..57ecbe3 100644 --- a/drivers/staging/ks7010/michael_mic.h +++ b/drivers/staging/ks7010/michael_mic.h @@ -16,14 +16,14 @@ struct michel_mic_t { uint32_t K0; // Key uint32_t K1; // Key - uint32_t L; // Current state - uint32_t R; // Current state - uint8_t M[4]; // Message accumulator (single word) - int nBytesInM; // # bytes in M - uint8_t Result[8]; + uint32_t L; // Current state + uint32_t R; // Current state + uint8_t M[4]; // Message accumulator (single word) + int nBytesInM; // # bytes in M + uint8_t Result[8]; }; extern -void MichaelMICFunction( struct michel_mic_t *Mic, uint8_t *Key, - uint8_t *Data, int Len, uint8_t priority, - uint8_t *Result ); +void MichaelMICFunction(struct michel_mic_t *Mic, uint8_t * Key, + uint8_t * Data, int Len, uint8_t priority, + uint8_t * Result); -- cgit v1.1 From cdf6ecc5eed103190f1df9cdd09659ef2cc7d23a Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:37 +0200 Subject: staging: ks7010: indent ks7010_sdio.c Unlike the previous patches which are plain indent outcomes, this has some manual fixups to be not overly strict with the 80 char limit. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 807 ++++++++++++++++++++--------------- 1 file changed, 460 insertions(+), 347 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index fb9f0b5..ed4d579 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -30,31 +30,32 @@ static int reg_net = 0; static const struct sdio_device_id if_sdio_ids[] = { - { SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_A, SDIO_DEVICE_ID_KS_7010) }, - { SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_B, SDIO_DEVICE_ID_KS_7010) }, + {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_A, SDIO_DEVICE_ID_KS_7010)}, + {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_B, SDIO_DEVICE_ID_KS_7010)}, { /* all zero */ } }; struct ks_sdio_model { - int model; - const char *firmware; + int model; + const char *firmware; }; static struct ks_sdio_model ks_sdio_models[] = { - { - /* ks7010 */ - .model = 0x10, - .firmware = "ks7010sd.rom", - }, + { + /* ks7010 */ + .model = 0x10, + .firmware = "ks7010sd.rom", + }, }; -static int ks7910_sdio_probe(struct sdio_func *function, const struct sdio_device_id *device); +static int ks7910_sdio_probe(struct sdio_func *function, + const struct sdio_device_id *device); static void ks7910_sdio_remove(struct sdio_func *function); static void ks7010_rw_function(struct work_struct *work); -static int ks7010_sdio_read( struct ks_wlan_private *priv, unsigned int address, - unsigned char *buffer, int length ); -static int ks7010_sdio_write( struct ks_wlan_private *priv, unsigned int address, - unsigned char *buffer, int length ); +static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address, + unsigned char *buffer, int length); +static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address, + unsigned char *buffer, int length); /* macro */ #define inc_txqhead(priv) \ @@ -79,25 +80,25 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) DPRINTK(4, "\n"); /* clear request */ - atomic_set(&priv->sleepstatus.doze_request,0); + atomic_set(&priv->sleepstatus.doze_request, 0); - if( atomic_read(&priv->sleepstatus.status) == 0){ + if (atomic_read(&priv->sleepstatus.status) == 0) { rw_data = GCR_B_DOZE; - retval = ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); - if(retval){ + retval = + ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); + if (retval) { DPRINTK(1, " error : GCR_B=%02X\n", rw_data); goto out; } DPRINTK(4, "PMG SET!! : GCR_B=%02X\n", rw_data); - DPRINTK(3,"sleep_mode=SLP_SLEEP\n"); + DPRINTK(3, "sleep_mode=SLP_SLEEP\n"); atomic_set(&priv->sleepstatus.status, 1); - priv->last_doze = jiffies; - } - else{ - DPRINTK(1,"sleep_mode=%d\n",priv->sleep_mode); + priv->last_doze = jiffies; + } else { + DPRINTK(1, "sleep_mode=%d\n", priv->sleep_mode); } -out: + out: priv->sleep_mode = atomic_read(&priv->sleepstatus.status); return; } @@ -110,110 +111,126 @@ void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv) DPRINTK(4, "\n"); /* clear request */ - atomic_set(&priv->sleepstatus.wakeup_request,0); + atomic_set(&priv->sleepstatus.wakeup_request, 0); - if( atomic_read(&priv->sleepstatus.status) == 1){ + if (atomic_read(&priv->sleepstatus.status) == 1) { rw_data = WAKEUP_REQ; - retval = ks7010_sdio_write(priv, WAKEUP, &rw_data, sizeof(rw_data)); - if(retval){ + retval = + ks7010_sdio_write(priv, WAKEUP, &rw_data, sizeof(rw_data)); + if (retval) { DPRINTK(1, " error : WAKEUP=%02X\n", rw_data); goto out; } DPRINTK(4, "wake up : WAKEUP=%02X\n", rw_data); atomic_set(&priv->sleepstatus.status, 0); - priv->last_wakeup = jiffies; + priv->last_wakeup = jiffies; ++priv->wakeup_count; - } - else{ - DPRINTK(1,"sleep_mode=%d\n",priv->sleep_mode); + } else { + DPRINTK(1, "sleep_mode=%d\n", priv->sleep_mode); } -out: + out: priv->sleep_mode = atomic_read(&priv->sleepstatus.status); return; } - void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv) { unsigned char rw_data; int retval; DPRINTK(4, "\n"); - if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ + if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) { rw_data = WAKEUP_REQ; - retval = ks7010_sdio_write(priv, WAKEUP, &rw_data, sizeof(rw_data)); - if(retval){ + retval = + ks7010_sdio_write(priv, WAKEUP, &rw_data, sizeof(rw_data)); + if (retval) { DPRINTK(1, " error : WAKEUP=%02X\n", rw_data); } DPRINTK(4, "wake up : WAKEUP=%02X\n", rw_data); - priv->last_wakeup = jiffies; + priv->last_wakeup = jiffies; ++priv->wakeup_count; - } - else{ - DPRINTK(1,"psstatus=%d\n",atomic_read(&priv->psstatus.status)); + } else { + DPRINTK(1, "psstatus=%d\n", + atomic_read(&priv->psstatus.status)); } } int _ks_wlan_hw_power_save(struct ks_wlan_private *priv) { - int rc=0; + int rc = 0; unsigned char rw_data; int retval; - if(priv->reg.powermgt == POWMGT_ACTIVE_MODE) + if (priv->reg.powermgt == POWMGT_ACTIVE_MODE) return rc; - if(priv->reg.operation_mode == MODE_INFRASTRUCTURE && - (priv->connect_status & CONNECT_STATUS_MASK)== CONNECT_STATUS){ + if (priv->reg.operation_mode == MODE_INFRASTRUCTURE && + (priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) { //DPRINTK(1,"psstatus.status=%d\n",atomic_read(&priv->psstatus.status)); - if (priv->dev_state == DEVICE_STATE_SLEEP) { - switch(atomic_read(&priv->psstatus.status)){ - case PS_SNOOZE: /* 4 */ - break; - default: - DPRINTK(5,"\n\ - psstatus.status=%d\n\ - psstatus.confirm_wait=%d\n\ - psstatus.snooze_guard=%d\n\ - cnt_txqbody=%d\n", - atomic_read(&priv->psstatus.status), - atomic_read(&priv->psstatus.confirm_wait), - atomic_read(&priv->psstatus.snooze_guard), - cnt_txqbody(priv)); - - if(!atomic_read(&priv->psstatus.confirm_wait)&& - !atomic_read(&priv->psstatus.snooze_guard)&& - !cnt_txqbody(priv)){ - retval = ks7010_sdio_read(priv, INT_PENDING, &rw_data, sizeof(rw_data)); - if(retval){ - DPRINTK(1, " error : INT_PENDING=%02X\n", rw_data); - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); - break; - } - if(!rw_data){ - rw_data = GCR_B_DOZE; - retval = ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); - if(retval){ - DPRINTK(1, " error : GCR_B=%02X\n", rw_data); - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + if (priv->dev_state == DEVICE_STATE_SLEEP) { + switch (atomic_read(&priv->psstatus.status)) { + case PS_SNOOZE: /* 4 */ + break; + default: + DPRINTK(5, "\npsstatus.status=%d\npsstatus.confirm_wait=%d\npsstatus.snooze_guard=%d\ncnt_txqbody=%d\n", + atomic_read(&priv->psstatus.status), + atomic_read(&priv->psstatus.confirm_wait), + atomic_read(&priv->psstatus.snooze_guard), + cnt_txqbody(priv)); + + if (!atomic_read(&priv->psstatus.confirm_wait) + && !atomic_read(&priv->psstatus.snooze_guard) + && !cnt_txqbody(priv)) { + retval = + ks7010_sdio_read(priv, INT_PENDING, + &rw_data, + sizeof(rw_data)); + if (retval) { + DPRINTK(1, + " error : INT_PENDING=%02X\n", + rw_data); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 1); break; } - DPRINTK(4, "PMG SET!! : GCR_B=%02X\n", rw_data); - atomic_set(&priv->psstatus.status, PS_SNOOZE); - DPRINTK(3,"psstatus.status=PS_SNOOZE\n"); - } - else{ - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + if (!rw_data) { + rw_data = GCR_B_DOZE; + retval = + ks7010_sdio_write(priv, + GCR_B, + &rw_data, + sizeof(rw_data)); + if (retval) { + DPRINTK(1, + " error : GCR_B=%02X\n", + rw_data); + queue_delayed_work + (priv->ks_wlan_hw.ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 1); + break; + } + DPRINTK(4, + "PMG SET!! : GCR_B=%02X\n", + rw_data); + atomic_set(&priv->psstatus. + status, PS_SNOOZE); + DPRINTK(3, + "psstatus.status=PS_SNOOZE\n"); + } else { + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 1); + } + } else { + queue_delayed_work(priv->ks_wlan_hw. + ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, + 0); } + break; } - else{ - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); - } - break; } - } } @@ -222,7 +239,8 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv) int ks_wlan_hw_power_save(struct ks_wlan_private *priv) { - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 1); return 0; } @@ -234,16 +252,16 @@ static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address, card = priv->ks_wlan_hw.sdio_card; - if (length == 1) /* CMD52 */ + if (length == 1) /* CMD52 */ *buffer = sdio_readb(card->func, address, &rc); - else /* CMD53 multi-block transfer */ + else /* CMD53 multi-block transfer */ rc = sdio_memcpy_fromio(card->func, buffer, address, length); - if(rc != 0){ + if (rc != 0) { printk("sdio error erorr=%d size=%d\n", rc, length); ++priv->sdio_error_count; - }else{ - priv->sdio_error_count=0; + } else { + priv->sdio_error_count = 0; } return rc; @@ -257,40 +275,42 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address, card = priv->ks_wlan_hw.sdio_card; - if (length == 1) /* CMD52 */ - sdio_writeb(card->func, *buffer, (unsigned int) address, &rc); - else /* CMD53 */ - rc = sdio_memcpy_toio(card->func, (unsigned int) address, buffer, length); + if (length == 1) /* CMD52 */ + sdio_writeb(card->func, *buffer, (unsigned int)address, &rc); + else /* CMD53 */ + rc = sdio_memcpy_toio(card->func, (unsigned int)address, buffer, + length); - if(rc != 0){ + if (rc != 0) { printk("sdio error erorr=%d size=%d\n", rc, length); ++priv->sdio_error_count; - }else{ - priv->sdio_error_count=0; + } else { + priv->sdio_error_count = 0; } return rc; } -static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, unsigned long size, - void (*complete_handler)(void *arg1, void *arg2), - void *arg1, void *arg2 ) +static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, + unsigned long size, + void (*complete_handler) (void *arg1, void *arg2), + void *arg1, void *arg2) { struct tx_device_buffer *sp; if (priv->dev_state < DEVICE_STATE_BOOT) { kfree(p); if (complete_handler != NULL) - (*complete_handler)(arg1, arg2); + (*complete_handler) (arg1, arg2); return 1; } - if ((TX_DEVICE_BUFF_SIZE - 1) <= cnt_txqbody(priv)) { + if ((TX_DEVICE_BUFF_SIZE - 1) <= cnt_txqbody(priv)) { /* in case of buffer overflow */ - DPRINTK(1,"tx buffer overflow\n"); + DPRINTK(1, "tx buffer overflow\n"); kfree(p); if (complete_handler != NULL) - (*complete_handler)(arg1, arg2); + (*complete_handler) (arg1, arg2); return 1; } @@ -306,29 +326,31 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, unsigne } /* write data */ -static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer, unsigned long size ) +static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer, + unsigned long size) { - int rc,retval; + int rc, retval; unsigned char rw_data; struct hostif_hdr *hdr; hdr = (struct hostif_hdr *)buffer; - rc=0; + rc = 0; - DPRINTK(4,"size=%d\n", hdr->size); - if(hdr->event < HIF_DATA_REQ || HIF_REQ_MAX < hdr->event){ - DPRINTK(1,"unknown event=%04X\n",hdr->event); + DPRINTK(4, "size=%d\n", hdr->size); + if (hdr->event < HIF_DATA_REQ || HIF_REQ_MAX < hdr->event) { + DPRINTK(1, "unknown event=%04X\n", hdr->event); return 0; } retval = ks7010_sdio_write(priv, DATA_WINDOW, buffer, size); - if(retval){ + if (retval) { DPRINTK(1, " write error : retval=%d\n", retval); return -4; } rw_data = WRITE_STATUS_BUSY; - retval = ks7010_sdio_write(priv, WRITE_STATUS, &rw_data, sizeof(rw_data)); - if(retval){ + retval = + ks7010_sdio_write(priv, WRITE_STATUS, &rw_data, sizeof(rw_data)); + if (retval) { DPRINTK(1, " error : WRITE_STATUS=%02X\n", rw_data); return -3; } @@ -339,74 +361,80 @@ static int write_to_device(struct ks_wlan_private *priv, unsigned char *buffer, static void tx_device_task(void *dev) { struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; - struct tx_device_buffer *sp; + struct tx_device_buffer *sp; int rc = 0; DPRINTK(4, "\n"); - if(cnt_txqbody(priv)>0 && atomic_read(&priv->psstatus.status) != PS_SNOOZE){ + if (cnt_txqbody(priv) > 0 + && atomic_read(&priv->psstatus.status) != PS_SNOOZE) { sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead]; - if(priv->dev_state >= DEVICE_STATE_BOOT){ + if (priv->dev_state >= DEVICE_STATE_BOOT) { rc = write_to_device(priv, sp->sendp, sp->size); - if(rc){ - DPRINTK(1, "write_to_device error !!(%d)\n", rc); - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + if (rc) { + DPRINTK(1, "write_to_device error !!(%d)\n", + rc); + queue_delayed_work(priv->ks_wlan_hw. + ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 1); return; } } - kfree(sp->sendp); /* allocated memory free */ - if(sp->complete_handler != NULL) /* TX Complete */ - (*sp->complete_handler)(sp->arg1, sp->arg2); + kfree(sp->sendp); /* allocated memory free */ + if (sp->complete_handler != NULL) /* TX Complete */ + (*sp->complete_handler) (sp->arg1, sp->arg2); inc_txqhead(priv); - if(cnt_txqbody(priv)>0){ - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); + if (cnt_txqbody(priv) > 0) { + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 0); } } return; } -int ks_wlan_hw_tx( struct ks_wlan_private *priv, void *p, unsigned long size, - void (*complete_handler)(void *arg1, void *arg2), - void *arg1, void *arg2 ) +int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, + void (*complete_handler) (void *arg1, void *arg2), + void *arg1, void *arg2) { - int result=0; + int result = 0; struct hostif_hdr *hdr; hdr = (struct hostif_hdr *)p; - if(hdr->event < HIF_DATA_REQ || HIF_REQ_MAX < hdr->event){ - DPRINTK(1,"unknown event=%04X\n",hdr->event); + if (hdr->event < HIF_DATA_REQ || HIF_REQ_MAX < hdr->event) { + DPRINTK(1, "unknown event=%04X\n", hdr->event); return 0; } /* add event to hostt buffer */ priv->hostt.buff[priv->hostt.qtail] = hdr->event; - priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE; + priv->hostt.qtail = (priv->hostt.qtail + 1) % SME_EVENT_BUFF_SIZE; - DPRINTK(4, "event=%04X\n",hdr->event); + DPRINTK(4, "event=%04X\n", hdr->event); spin_lock(&priv->tx_dev.tx_dev_lock); result = enqueue_txdev(priv, p, size, complete_handler, arg1, arg2); spin_unlock(&priv->tx_dev.tx_dev_lock); - if(cnt_txqbody(priv)>0){ - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); + if (cnt_txqbody(priv) > 0) { + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 0); } return result; } static void rx_event_task(unsigned long dev) { - struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; - struct rx_device_buffer *rp; + struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; + struct rx_device_buffer *rp; - DPRINTK(4,"\n"); + DPRINTK(4, "\n"); - if(cnt_rxqbody(priv) > 0 && priv->dev_state >= DEVICE_STATE_BOOT){ + if (cnt_rxqbody(priv) > 0 && priv->dev_state >= DEVICE_STATE_BOOT) { rp = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qhead]; hostif_receive(priv, rp->data, rp->size); inc_rxqhead(priv); - if(cnt_rxqbody(priv) > 0){ + if (cnt_rxqbody(priv) > 0) { tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task); } } @@ -420,35 +448,40 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) int retval; struct rx_device_buffer *rx_buffer; struct hostif_hdr *hdr; - unsigned char read_status; - unsigned short event=0; + unsigned char read_status; + unsigned short event = 0; - DPRINTK(4,"\n"); + DPRINTK(4, "\n"); /* receive data */ - if (cnt_rxqbody(priv) >= (RX_DEVICE_BUFF_SIZE-1)) { + if (cnt_rxqbody(priv) >= (RX_DEVICE_BUFF_SIZE - 1)) { /* in case of buffer overflow */ - DPRINTK(1,"rx buffer overflow \n"); + DPRINTK(1, "rx buffer overflow \n"); goto error_out; } rx_buffer = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qtail]; - retval = ks7010_sdio_read(priv, DATA_WINDOW, &rx_buffer->data[0], hif_align_size(size)); - if(retval){ + retval = + ks7010_sdio_read(priv, DATA_WINDOW, &rx_buffer->data[0], + hif_align_size(size)); + if (retval) { goto error_out; } /* length check */ - if(size > 2046 || size == 0){ + if (size > 2046 || size == 0) { #ifdef KS_WLAN_DEBUG if (KS_WLAN_DEBUG > 5) - print_hex_dump_bytes("INVALID DATA dump: ", DUMP_PREFIX_OFFSET, + print_hex_dump_bytes("INVALID DATA dump: ", + DUMP_PREFIX_OFFSET, rx_buffer->data, 32); #endif /* rx_status update */ read_status = READ_STATUS_IDLE; - retval = ks7010_sdio_write(priv, READ_STATUS, &read_status, sizeof(read_status)); - if(retval){ + retval = + ks7010_sdio_write(priv, READ_STATUS, &read_status, + sizeof(read_status)); + if (retval) { DPRINTK(1, " error : READ_STATUS=%02X\n", read_status); } goto error_out; @@ -461,14 +494,16 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) /* read status update */ read_status = READ_STATUS_IDLE; - retval = ks7010_sdio_write(priv, READ_STATUS, &read_status, sizeof(read_status)); - if(retval){ + retval = + ks7010_sdio_write(priv, READ_STATUS, &read_status, + sizeof(read_status)); + if (retval) { DPRINTK(1, " error : READ_STATUS=%02X\n", read_status); } DPRINTK(4, "READ_STATUS=%02X\n", read_status); - if(atomic_read(&priv->psstatus.confirm_wait)){ - if(IS_HIF_CONF(event)){ + if (atomic_read(&priv->psstatus.confirm_wait)) { + if (IS_HIF_CONF(event)) { DPRINTK(4, "IS_HIF_CONF true !!\n"); atomic_dec(&priv->psstatus.confirm_wait); } @@ -477,7 +512,7 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) /* rx_event_task((void *)priv); */ tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task); -error_out: + error_out: return; } @@ -491,71 +526,74 @@ static void ks7010_rw_function(struct work_struct *work) hw = container_of(work, struct hw_info_t, rw_wq.work); priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw); - DPRINTK(4,"\n"); - + DPRINTK(4, "\n"); - /* wiat after DOZE */ - if(time_after(priv->last_doze + ((30*HZ)/1000), jiffies )){ - DPRINTK(4, "wait after DOZE \n"); - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + /* wiat after DOZE */ + if (time_after(priv->last_doze + ((30 * HZ) / 1000), jiffies)) { + DPRINTK(4, "wait after DOZE \n"); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 1); return; } /* wiat after WAKEUP */ - while(time_after(priv->last_wakeup + ((30*HZ)/1000), jiffies )){ + while (time_after(priv->last_wakeup + ((30 * HZ) / 1000), jiffies)) { DPRINTK(4, "wait after WAKEUP \n"); /* queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, (priv->last_wakeup + ((30*HZ)/1000) - jiffies));*/ - printk("wake: %lu %lu\n", priv->last_wakeup + (30* HZ)/1000, jiffies); + printk("wake: %lu %lu\n", priv->last_wakeup + (30 * HZ) / 1000, + jiffies); msleep(30); } sdio_claim_host(priv->ks_wlan_hw.sdio_card->func); /* power save wakeup */ - if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ - if(cnt_txqbody(priv)>0){ + if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) { + if (cnt_txqbody(priv) > 0) { ks_wlan_hw_wakeup_request(priv); - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 1); + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 1); } goto err_out; } /* sleep mode doze */ - if(atomic_read(&priv->sleepstatus.doze_request)==1){ + if (atomic_read(&priv->sleepstatus.doze_request) == 1) { ks_wlan_hw_sleep_doze_request(priv); goto err_out; } /* sleep mode wakeup */ - if(atomic_read(&priv->sleepstatus.wakeup_request)==1){ + if (atomic_read(&priv->sleepstatus.wakeup_request) == 1) { ks_wlan_hw_sleep_wakeup_request(priv); goto err_out; } /* read (WriteStatus/ReadDataSize FN1:00_0014) */ - retval = ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data, sizeof(rw_data)); - if(retval){ - DPRINTK(1, " error : WSTATUS_RSIZE=%02X psstatus=%d\n", rw_data,atomic_read(&priv->psstatus.status)); + retval = + ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data, sizeof(rw_data)); + if (retval) { + DPRINTK(1, " error : WSTATUS_RSIZE=%02X psstatus=%d\n", rw_data, + atomic_read(&priv->psstatus.status)); goto err_out; } DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data); - if(rw_data&RSIZE_MASK){ /* Read schedule */ - ks_wlan_hw_rx((void *)priv, (uint16_t)(((rw_data&RSIZE_MASK)<<4))); + if (rw_data & RSIZE_MASK) { /* Read schedule */ + ks_wlan_hw_rx((void *)priv, + (uint16_t) (((rw_data & RSIZE_MASK) << 4))); } - if((rw_data&WSTATUS_MASK)){ + if ((rw_data & WSTATUS_MASK)) { tx_device_task((void *)priv); } _ks_wlan_hw_power_save(priv); -err_out: + err_out: sdio_release_host(priv->ks_wlan_hw.sdio_card->func); return; } - - static void ks_sdio_interrupt(struct sdio_func *func) { int retval; @@ -567,10 +605,12 @@ static void ks_sdio_interrupt(struct sdio_func *func) priv = card->priv; DPRINTK(4, "\n"); - if(priv->dev_state >= DEVICE_STATE_BOOT){ - retval = ks7010_sdio_read(priv, INT_PENDING, &status, sizeof(status)); - if(retval){ - DPRINTK(1, "read INT_PENDING Failed!!(%d)\n",retval); + if (priv->dev_state >= DEVICE_STATE_BOOT) { + retval = + ks7010_sdio_read(priv, INT_PENDING, &status, + sizeof(status)); + if (retval) { + DPRINTK(1, "read INT_PENDING Failed!!(%d)\n", retval); goto intr_out; } DPRINTK(4, "INT_PENDING=%02X\n", rw_data); @@ -580,70 +620,89 @@ static void ks_sdio_interrupt(struct sdio_func *func) /* read (General Communication B register) */ /* bit5 -> Write Status Idle */ /* bit2 -> Read Status Busy */ - if(status&INT_GCR_B || atomic_read(&priv->psstatus.status)==PS_SNOOZE){ - retval = ks7010_sdio_read(priv, GCR_B, &rw_data, sizeof(rw_data)); - if(retval){ + if (status & INT_GCR_B + || atomic_read(&priv->psstatus.status) == PS_SNOOZE) { + retval = + ks7010_sdio_read(priv, GCR_B, &rw_data, + sizeof(rw_data)); + if (retval) { DPRINTK(1, " error : GCR_B=%02X\n", rw_data); goto intr_out; } /* DPRINTK(1, "GCR_B=%02X\n", rw_data); */ - if(rw_data == GCR_B_ACTIVE){ - if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ - atomic_set(&priv->psstatus.status, PS_WAKEUP); - priv->wakeup_count=0; + if (rw_data == GCR_B_ACTIVE) { + if (atomic_read(&priv->psstatus.status) == + PS_SNOOZE) { + atomic_set(&priv->psstatus.status, + PS_WAKEUP); + priv->wakeup_count = 0; } complete(&priv->psstatus.wakeup_wait); } - } - do{ + do { /* read (WriteStatus/ReadDataSize FN1:00_0014) */ - retval = ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data, sizeof(rw_data)); - if(retval){ - DPRINTK(1, " error : WSTATUS_RSIZE=%02X\n", rw_data); + retval = + ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data, + sizeof(rw_data)); + if (retval) { + DPRINTK(1, " error : WSTATUS_RSIZE=%02X\n", + rw_data); goto intr_out; } DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data); - rsize=rw_data&RSIZE_MASK; - if(rsize){ /* Read schedule */ - ks_wlan_hw_rx((void *)priv, (uint16_t)(((rsize)<<4))); + rsize = rw_data & RSIZE_MASK; + if (rsize) { /* Read schedule */ + ks_wlan_hw_rx((void *)priv, + (uint16_t) (((rsize) << 4))); } - if(rw_data&WSTATUS_MASK){ + if (rw_data & WSTATUS_MASK) { #if 0 - if(status&INT_WRITE_STATUS && !cnt_txqbody(priv)){ + if (status & INT_WRITE_STATUS + && !cnt_txqbody(priv)) { /* dummy write for interrupt clear */ - rw_data =0; - retval = ks7010_sdio_write(priv, DATA_WINDOW, &rw_data, sizeof(rw_data)); + rw_data = 0; + retval = + ks7010_sdio_write(priv, DATA_WINDOW, + &rw_data, + sizeof(rw_data)); if (retval) { - DPRINTK(1, "write DATA_WINDOW Failed!!(%d)\n",retval); + DPRINTK(1, + "write DATA_WINDOW Failed!!(%d)\n", + retval); } status &= ~INT_WRITE_STATUS; - } - else{ + } else { #endif - if(atomic_read(&priv->psstatus.status)==PS_SNOOZE){ - if(cnt_txqbody(priv)){ + if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) { + if (cnt_txqbody(priv)) { ks_wlan_hw_wakeup_request(priv); - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq, 1); + queue_delayed_work + (priv->ks_wlan_hw. + ks7010sdio_wq, + &priv->ks_wlan_hw. + rw_wq, 1); return; } - } - else{ + } else { tx_device_task((void *)priv); } -// } +#if 0 + } +#endif } - }while(rsize); + } while (rsize); } -intr_out: - queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq, 0); + intr_out: + queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq, + &priv->ks_wlan_hw.rw_wq, 0); return; } -static int trx_device_init( struct ks_wlan_private *priv ) +static int trx_device_init(struct ks_wlan_private *priv) { /* initialize values (tx) */ priv->tx_dev.qtail = priv->tx_dev.qhead = 0; @@ -655,21 +714,22 @@ static int trx_device_init( struct ks_wlan_private *priv ) spin_lock_init(&priv->tx_dev.tx_dev_lock); spin_lock_init(&priv->rx_dev.rx_dev_lock); - tasklet_init(&priv->ks_wlan_hw.rx_bh_task, rx_event_task, (unsigned long)priv); + tasklet_init(&priv->ks_wlan_hw.rx_bh_task, rx_event_task, + (unsigned long)priv); return 0; } -static void trx_device_exit( struct ks_wlan_private *priv ) +static void trx_device_exit(struct ks_wlan_private *priv) { - struct tx_device_buffer *sp; + struct tx_device_buffer *sp; /* tx buffer clear */ - while (cnt_txqbody(priv)>0) { + while (cnt_txqbody(priv) > 0) { sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead]; - kfree(sp->sendp); /* allocated memory free */ - if (sp->complete_handler != NULL) /* TX Complete */ - (*sp->complete_handler)(sp->arg1, sp->arg2); + kfree(sp->sendp); /* allocated memory free */ + if (sp->complete_handler != NULL) /* TX Complete */ + (*sp->complete_handler) (sp->arg1, sp->arg2); inc_txqhead(priv); } @@ -677,24 +737,35 @@ static void trx_device_exit( struct ks_wlan_private *priv ) return; } + static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) { - int rc=0; + int rc = 0; int retval; unsigned char *data_buf; data_buf = NULL; data_buf = kmalloc(sizeof(u32), GFP_KERNEL); - if(!data_buf){ rc = 1; goto error_out; } + if (!data_buf) { + rc = 1; + goto error_out; + } memcpy(data_buf, &index, sizeof(index)); retval = ks7010_sdio_write(priv, WRITE_INDEX, data_buf, sizeof(index)); - if(retval){ rc = 2; goto error_out; } + if (retval) { + rc = 2; + goto error_out; + } retval = ks7010_sdio_write(priv, READ_INDEX, data_buf, sizeof(index)); - if(retval){ rc = 3; goto error_out; } -error_out: - if(data_buf) kfree(data_buf); + if (retval) { + rc = 3; + goto error_out; + } + error_out: + if (data_buf) + kfree(data_buf); return rc; } @@ -702,30 +773,41 @@ error_out: static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address, unsigned char *data, unsigned int size) { - int rc=0; + int rc = 0; int retval; unsigned char *read_buf; read_buf = NULL; read_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL); - if(!read_buf){ rc = 1; goto error_out; } + if (!read_buf) { + rc = 1; + goto error_out; + } retval = ks7010_sdio_read(priv, address, read_buf, size); - if(retval){ rc = 2; goto error_out; } + if (retval) { + rc = 2; + goto error_out; + } retval = memcmp(data, read_buf, size); - if(retval){ - DPRINTK(0, "data compare error (%d) \n",retval); rc = 3; goto error_out; + if (retval) { + DPRINTK(0, "data compare error (%d) \n", retval); + rc = 3; + goto error_out; } -error_out: - if(read_buf) kfree(read_buf); + error_out: + if (read_buf) + kfree(read_buf); return rc; } + #include -static int ks79xx_upload_firmware(struct ks_wlan_private *priv, struct ks_sdio_card *card) +static int ks79xx_upload_firmware(struct ks_wlan_private *priv, + struct ks_sdio_card *card) { - unsigned int size, offset, n = 0; - unsigned char *rom_buf; - unsigned char rw_data =0; - int retval, rc=0; + unsigned int size, offset, n = 0; + unsigned char *rom_buf; + unsigned char rw_data = 0; + int retval, rc = 0; int length; const struct firmware *fw_entry = NULL; @@ -733,76 +815,99 @@ static int ks79xx_upload_firmware(struct ks_wlan_private *priv, struct ks_sdio_c /* buffer allocate */ rom_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL); - if(!rom_buf){ rc = 3; goto error_out0; } - + if (!rom_buf) { + rc = 3; + goto error_out0; + } sdio_claim_host(card->func); /* Firmware running ? */ retval = ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data)); - if(rw_data == GCR_A_RUN){ - DPRINTK( 0, "MAC firmware running ...\n"); + if (rw_data == GCR_A_RUN) { + DPRINTK(0, "MAC firmware running ...\n"); rc = 0; goto error_out0; } - if(request_firmware(&fw_entry, priv->reg.rom_file, &priv->ks_wlan_hw.sdio_card->func->dev)!=0){ - DPRINTK(1,"error request_firmware() file=%s\n", priv->reg.rom_file); + if (request_firmware + (&fw_entry, priv->reg.rom_file, + &priv->ks_wlan_hw.sdio_card->func->dev) != 0) { + DPRINTK(1, "error request_firmware() file=%s\n", + priv->reg.rom_file); return 1; } - DPRINTK(4,"success request_firmware() file=%s size=%zu\n", priv->reg.rom_file, fw_entry->size); + DPRINTK(4, "success request_firmware() file=%s size=%zu\n", + priv->reg.rom_file, fw_entry->size); length = fw_entry->size; /* Load Program */ n = 0; - do { - if(length >= ROM_BUFF_SIZE){ + do { + if (length >= ROM_BUFF_SIZE) { size = ROM_BUFF_SIZE; length = length - ROM_BUFF_SIZE; + } else { + size = length; + length = 0; } - else{ - size=length; - length=0; - } - DPRINTK(4, "size = %d\n",size); - if(size == 0) break; - memcpy(rom_buf,fw_entry->data+n,size); + DPRINTK(4, "size = %d\n", size); + if (size == 0) + break; + memcpy(rom_buf, fw_entry->data + n, size); /* Update write index */ offset = n; - retval = ks7010_sdio_update_index(priv, KS7010_IRAM_ADDRESS+offset); - if(retval){ rc = 6; goto error_out1; } + retval = + ks7010_sdio_update_index(priv, + KS7010_IRAM_ADDRESS + offset); + if (retval) { + rc = 6; + goto error_out1; + } /* Write data */ retval = ks7010_sdio_write(priv, DATA_WINDOW, rom_buf, size); - if(retval){ rc = 8; goto error_out1; } + if (retval) { + rc = 8; + goto error_out1; + } /* compare */ - retval = ks7010_sdio_data_compare(priv, DATA_WINDOW, rom_buf, size); - if(retval){ rc = 9; goto error_out1; } + retval = + ks7010_sdio_data_compare(priv, DATA_WINDOW, rom_buf, size); + if (retval) { + rc = 9; + goto error_out1; + } n += size; - }while(size); + } while (size); /* Remap request */ rw_data = GCR_A_REMAP; retval = ks7010_sdio_write(priv, GCR_A, &rw_data, sizeof(rw_data)); - if(retval){ + if (retval) { rc = 11; goto error_out1; } - DPRINTK( 4, " REMAP Request : GCR_A=%02X\n", rw_data); + DPRINTK(4, " REMAP Request : GCR_A=%02X\n", rw_data); /* Firmware running check */ for (n = 0; n < 50; ++n) { - mdelay(10);/* wait_ms(10); */ - retval = ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data)); - if(retval){ rc = 11; goto error_out1; } - if(rw_data == GCR_A_RUN) break; + mdelay(10); /* wait_ms(10); */ + retval = + ks7010_sdio_read(priv, GCR_A, &rw_data, sizeof(rw_data)); + if (retval) { + rc = 11; + goto error_out1; + } + if (rw_data == GCR_A_RUN) + break; } - DPRINTK(4, "firmware wakeup (%d)!!!!\n",n); + DPRINTK(4, "firmware wakeup (%d)!!!!\n", n); if ((50) <= n) { DPRINTK(1, "firmware can't start\n"); - rc = 12; + rc = 12; goto error_out1; } @@ -812,30 +917,31 @@ static int ks79xx_upload_firmware(struct ks_wlan_private *priv, struct ks_sdio_c release_firmware(fw_entry); error_out0: sdio_release_host(card->func); - if(rom_buf) + if (rom_buf) kfree(rom_buf); return rc; } static void ks7010_card_init(struct ks_wlan_private *priv) { - DPRINTK(5,"\ncard_init_task()\n"); + DPRINTK(5, "\ncard_init_task()\n"); /* init_waitqueue_head(&priv->confirm_wait); */ init_completion(&priv->confirm_wait); - DPRINTK(5,"init_completion()\n"); + DPRINTK(5, "init_completion()\n"); /* get mac address & firmware version */ hostif_sme_enqueue(priv, SME_START); - DPRINTK(5,"hostif_sme_enqueu()\n"); + DPRINTK(5, "hostif_sme_enqueu()\n"); - if(!wait_for_completion_interruptible_timeout(&priv->confirm_wait,5*HZ)){ - DPRINTK(1,"wait time out!! SME_START\n"); + if (!wait_for_completion_interruptible_timeout + (&priv->confirm_wait, 5 * HZ)) { + DPRINTK(1, "wait time out!! SME_START\n"); } - if(priv->mac_address_valid && priv->version_size){ + if (priv->mac_address_valid && priv->version_size) { priv->dev_state = DEVICE_STATE_PREINIT; } @@ -858,57 +964,56 @@ static void ks7010_card_init(struct ks_wlan_private *priv) hostif_sme_enqueue(priv, SME_MODE_SET_REQUEST); hostif_sme_enqueue(priv, SME_START_REQUEST); - if(!wait_for_completion_interruptible_timeout(&priv->confirm_wait,5*HZ)){ - DPRINTK(1,"wait time out!! wireless parameter set\n"); + if (!wait_for_completion_interruptible_timeout + (&priv->confirm_wait, 5 * HZ)) { + DPRINTK(1, "wait time out!! wireless parameter set\n"); } - if(priv->dev_state >= DEVICE_STATE_PREINIT){ + if (priv->dev_state >= DEVICE_STATE_PREINIT) { DPRINTK(1, "DEVICE READY!!\n"); priv->dev_state = DEVICE_STATE_READY; - reg_net = register_netdev (priv->net_dev); - DPRINTK(3, "register_netdev=%d\n",reg_net); - } - else { - DPRINTK(1, "dev_state=%d\n",priv->dev_state); + reg_net = register_netdev(priv->net_dev); + DPRINTK(3, "register_netdev=%d\n", reg_net); + } else { + DPRINTK(1, "dev_state=%d\n", priv->dev_state); } } static struct sdio_driver ks7010_sdio_driver = { - .name = "ks7910_sdio", - .id_table = if_sdio_ids, - .probe = ks7910_sdio_probe, - .remove = ks7910_sdio_remove, + .name = "ks7910_sdio", + .id_table = if_sdio_ids, + .probe = ks7910_sdio_probe, + .remove = ks7910_sdio_remove, }; - extern int ks_wlan_net_start(struct net_device *dev); extern int ks_wlan_net_stop(struct net_device *dev); -static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id *device) +static int ks7910_sdio_probe(struct sdio_func *func, + const struct sdio_device_id *device) { struct ks_wlan_private *priv; struct ks_sdio_card *card; struct net_device *netdev; unsigned char rw_data; - int i=0, ret; + int i = 0, ret; DPRINTK(5, "ks7910_sdio_probe()\n"); priv = NULL; - netdev=NULL; - + netdev = NULL; /* initilize ks_sdio_card */ card = kzalloc(sizeof(struct ks_sdio_card), GFP_KERNEL); if (!card) return -ENOMEM; - card->func = func; + card->func = func; card->model = 0x10; spin_lock_init(&card->lock); /* select model */ - for (i = 0;i < ARRAY_SIZE(ks_sdio_models);i++) { + for (i = 0; i < ARRAY_SIZE(ks_sdio_models); i++) { if (card->model == ks_sdio_models[i].model) break; } @@ -920,7 +1025,6 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id card->firmware = ks_sdio_models[i].firmware; - /*** Initialize SDIO ***/ sdio_claim_host(func); @@ -929,7 +1033,8 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id /* function blocksize set */ ret = sdio_set_block_size(func, KS7010_IO_BLOCK_SIZE); - DPRINTK(5, "multi_block=%d sdio_set_block_size()=%d %d\n", func->card->cccr.multi_block, func->cur_blksize, ret); + DPRINTK(5, "multi_block=%d sdio_set_block_size()=%d %d\n", + func->card->cccr.multi_block, func->cur_blksize, ret); /* Allocate the slot current */ @@ -940,10 +1045,10 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id goto error_free_card; /* interrupt disable */ - sdio_writeb(func, 0, INT_ENABLE, &ret); + sdio_writeb(func, 0, INT_ENABLE, &ret); if (ret) goto error_free_card; - sdio_writeb(func, 0xff, INT_PENDING, &ret); + sdio_writeb(func, 0xff, INT_PENDING, &ret); if (ret) goto error_disable_func; @@ -957,18 +1062,16 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id sdio_set_drvdata(func, card); DPRINTK(5, "class = 0x%X, vendor = 0x%X, " - "device = 0x%X\n", - func->class, func->vendor, func->device); - + "device = 0x%X\n", func->class, func->vendor, func->device); /* private memory allocate */ netdev = alloc_etherdev(sizeof(*priv)); if (netdev == NULL) { - printk (KERN_ERR "ks79xx : Unable to alloc new net device\n"); + printk(KERN_ERR "ks79xx : Unable to alloc new net device\n"); goto error_release_irq; } if (dev_alloc_name(netdev, netdev->name) < 0) { - printk (KERN_ERR "ks79xx : Couldn't get name!\n"); + printk(KERN_ERR "ks79xx : Couldn't get name!\n"); goto error_free_netdev; } @@ -982,7 +1085,7 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id init_completion(&priv->ks_wlan_hw.ks7010_sdio_wait); priv->ks_wlan_hw.read_buf = NULL; priv->ks_wlan_hw.read_buf = kmalloc(RX_DATA_SIZE, GFP_KERNEL); - if(!priv->ks_wlan_hw.read_buf){ + if (!priv->ks_wlan_hw.read_buf) { goto error_free_netdev; } priv->dev_state = DEVICE_STATE_PREBOOT; @@ -995,25 +1098,29 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id memset(&priv->wstats, 0, sizeof(priv->wstats)); /* sleep mode */ - atomic_set(&priv->sleepstatus.doze_request,0); - atomic_set(&priv->sleepstatus.wakeup_request,0); - atomic_set(&priv->sleepstatus.wakeup_request,0); + atomic_set(&priv->sleepstatus.doze_request, 0); + atomic_set(&priv->sleepstatus.wakeup_request, 0); + atomic_set(&priv->sleepstatus.wakeup_request, 0); trx_device_init(priv); hostif_init(priv); - ks_wlan_net_start(netdev); + ks_wlan_net_start(netdev); /* Read config file */ ret = ks_wlan_read_config_file(priv); if (ret) { - printk(KERN_ERR "ks79xx: read configuration file failed !! retern code = %d\n", ret); + printk(KERN_ERR + "ks79xx: read configuration file failed !! retern code = %d\n", + ret); goto error_free_read_buf; } /* Upload firmware */ - ret = ks79xx_upload_firmware(priv, card); /* firmware load */ - if(ret){ - printk(KERN_ERR "ks79xx: firmware load failed !! retern code = %d\n", ret); + ret = ks79xx_upload_firmware(priv, card); /* firmware load */ + if (ret) { + printk(KERN_ERR + "ks79xx: firmware load failed !! retern code = %d\n", + ret); goto error_free_read_buf; } @@ -1023,25 +1130,24 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id sdio_claim_host(func); ret = ks7010_sdio_write(priv, INT_PENDING, &rw_data, sizeof(rw_data)); sdio_release_host(func); - if(ret){ + if (ret) { DPRINTK(1, " error : INT_PENDING=%02X\n", rw_data); } DPRINTK(4, " clear Interrupt : INT_PENDING=%02X\n", rw_data); - /* enable ks7010sdio interrupt (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS) */ - rw_data = (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS); + rw_data = (INT_GCR_B | INT_READ_STATUS | INT_WRITE_STATUS); sdio_claim_host(func); ret = ks7010_sdio_write(priv, INT_ENABLE, &rw_data, sizeof(rw_data)); sdio_release_host(func); - if(ret){ + if (ret) { DPRINTK(1, " error : INT_ENABLE=%02X\n", rw_data); } DPRINTK(4, " enable Interrupt : INT_ENABLE=%02X\n", rw_data); priv->dev_state = DEVICE_STATE_BOOT; priv->ks_wlan_hw.ks7010sdio_wq = create_workqueue("ks7010sdio_wq"); - if(!priv->ks_wlan_hw.ks7010sdio_wq){ + if (!priv->ks_wlan_hw.ks7010sdio_wq) { DPRINTK(1, "create_workqueue failed !!\n"); goto error_free_read_buf; } @@ -1051,22 +1157,22 @@ static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id return 0; -error_free_read_buf: + error_free_read_buf: kfree(priv->ks_wlan_hw.read_buf); priv->ks_wlan_hw.read_buf = NULL; -error_free_netdev: + error_free_netdev: free_netdev(priv->net_dev); card->priv = NULL; -error_release_irq: + error_release_irq: sdio_claim_host(func); sdio_release_irq(func); -error_disable_func: + error_disable_func: sdio_disable_func(func); -error_free_card: + error_free_card: sdio_release_host(func); sdio_set_drvdata(func, NULL); kfree(card); -error: + error: return -ENODEV; } @@ -1080,56 +1186,62 @@ static void ks7910_sdio_remove(struct sdio_func *func) card = sdio_get_drvdata(func); - if(card == NULL) + if (card == NULL) return; DPRINTK(1, "priv = card->priv\n"); priv = card->priv; netdev = priv->net_dev; - if(priv){ + if (priv) { ks_wlan_net_stop(netdev); DPRINTK(1, "ks_wlan_net_stop\n"); /* interrupt disable */ sdio_claim_host(func); - sdio_writeb(func, 0, INT_ENABLE, &ret); - sdio_writeb(func, 0xff, INT_PENDING, &ret); + sdio_writeb(func, 0, INT_ENABLE, &ret); + sdio_writeb(func, 0xff, INT_PENDING, &ret); sdio_release_host(func); DPRINTK(1, "interrupt disable\n"); /* send stop request to MAC */ { struct hostif_stop_request_t *pp; - pp = (struct hostif_stop_request_t *)kzalloc(hif_align_size(sizeof(*pp)), GFP_KERNEL ); - if (pp==NULL) { - DPRINTK(3,"allocate memory failed..\n"); - return; /* to do goto ni suru*/ + pp = (struct hostif_stop_request_t *) + kzalloc(hif_align_size(sizeof(*pp)), GFP_KERNEL); + if (pp == NULL) { + DPRINTK(3, "allocate memory failed..\n"); + return; /* to do goto ni suru */ } - pp->header.size = cpu_to_le16((uint16_t)(sizeof(*pp)-sizeof(pp->header.size))); - pp->header.event = cpu_to_le16((uint16_t)HIF_STOP_REQ); + pp->header.size = + cpu_to_le16((uint16_t) + (sizeof(*pp) - + sizeof(pp->header.size))); + pp->header.event = cpu_to_le16((uint16_t) HIF_STOP_REQ); sdio_claim_host(func); - write_to_device(priv, (unsigned char *) pp, hif_align_size(sizeof(*pp))); + write_to_device(priv, (unsigned char *)pp, + hif_align_size(sizeof(*pp))); sdio_release_host(func); kfree(pp); } DPRINTK(1, "STOP Req\n"); - if(priv->ks_wlan_hw.ks7010sdio_wq){ + if (priv->ks_wlan_hw.ks7010sdio_wq) { flush_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq); } - DPRINTK(1, "destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq);\n"); + DPRINTK(1, + "destroy_workqueue(priv->ks_wlan_hw.ks7010sdio_wq);\n"); hostif_exit(priv); DPRINTK(1, "hostif_exit\n"); - if(!reg_net) + if (!reg_net) unregister_netdev(netdev); DPRINTK(1, "unregister_netdev\n"); trx_device_exit(priv); - if(priv->ks_wlan_hw.read_buf){ + if (priv->ks_wlan_hw.read_buf) { kfree(priv->ks_wlan_hw.read_buf); } free_netdev(priv->net_dev); @@ -1148,26 +1260,27 @@ static void ks7910_sdio_remove(struct sdio_func *func) kfree(card); DPRINTK(1, "kfree()\n"); - - DPRINTK(5," Bye !!\n"); + DPRINTK(5, " Bye !!\n"); return; } -static int __init ks7010_sdio_init( void ) +static int __init ks7010_sdio_init(void) { int status; /* register with bus driver core */ status = sdio_register_driver(&ks7010_sdio_driver); - if(status != 0){ - DPRINTK(1,"ks79xx_sdio : failed to register with bus driver, %d\n", status ); + if (status != 0) { + DPRINTK(1, + "ks79xx_sdio : failed to register with bus driver, %d\n", + status); } return status; } -static void __exit ks7010_sdio_exit( void ) +static void __exit ks7010_sdio_exit(void) { - DPRINTK(5," \n"); + DPRINTK(5, " \n"); sdio_unregister_driver(&ks7010_sdio_driver); return; } -- cgit v1.1 From 2801d7a289bd435ae4920a792c5497a6450686ef Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:38 +0200 Subject: staging: ks7010: remove supported card table with one element There is only this card supported, no need to iterate over the table. The resulting firmware filename wasn't used anyway, but came from the config file or hardcoded default. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 31 ++----------------------------- drivers/staging/ks7010/ks7010_sdio.h | 2 -- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index ed4d579..8e8476b 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -35,19 +35,6 @@ static const struct sdio_device_id if_sdio_ids[] = { { /* all zero */ } }; -struct ks_sdio_model { - int model; - const char *firmware; -}; - -static struct ks_sdio_model ks_sdio_models[] = { - { - /* ks7010 */ - .model = 0x10, - .firmware = "ks7010sd.rom", - }, -}; - static int ks7910_sdio_probe(struct sdio_func *function, const struct sdio_device_id *device); static void ks7910_sdio_remove(struct sdio_func *function); @@ -996,7 +983,7 @@ static int ks7910_sdio_probe(struct sdio_func *func, struct ks_sdio_card *card; struct net_device *netdev; unsigned char rw_data; - int i = 0, ret; + int ret; DPRINTK(5, "ks7910_sdio_probe()\n"); @@ -1009,22 +996,8 @@ static int ks7910_sdio_probe(struct sdio_func *func, return -ENOMEM; card->func = func; - card->model = 0x10; spin_lock_init(&card->lock); - /* select model */ - for (i = 0; i < ARRAY_SIZE(ks_sdio_models); i++) { - if (card->model == ks_sdio_models[i].model) - break; - } - - if (i == ARRAY_SIZE(ks_sdio_models)) { - DPRINTK(5, "unkown card model 0x%x\n", card->model); - goto error; - } - - card->firmware = ks_sdio_models[i].firmware; - /*** Initialize SDIO ***/ sdio_claim_host(func); @@ -1172,7 +1145,7 @@ static int ks7910_sdio_probe(struct sdio_func *func, sdio_release_host(func); sdio_set_drvdata(func, NULL); kfree(card); - error: + return -ENODEV; } diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h index aea3727..2d7be5d 100644 --- a/drivers/staging/ks7010/ks7010_sdio.h +++ b/drivers/staging/ks7010/ks7010_sdio.h @@ -109,8 +109,6 @@ struct ks_sdio_packet { struct ks_sdio_card { struct sdio_func *func; struct ks_wlan_private *priv; - int model; - const char *firmware; spinlock_t lock; }; -- cgit v1.1 From e1240140f9e9a749eb938e7a6866355a6ed1b8d1 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:39 +0200 Subject: staging: ks7010: fix module annotations List all authors, beautify description, match license to what is stated in file headers, add firmware information. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 8e8476b..8c0d1bb 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -1261,9 +1261,7 @@ static void __exit ks7010_sdio_exit(void) module_init(ks7010_sdio_init); module_exit(ks7010_sdio_exit); -MODULE_AUTHOR("Qi-Hardware based on KeyStream driver"); -MODULE_DESCRIPTION("Driver for KeyStream, KS7010 based SDIO cards. "); -#ifdef MODULE_LICENSE -MODULE_LICENSE("GPL"); -#endif -MODULE_SUPPORTED_DEVICE("KS7910"); +MODULE_AUTHOR("Sang Engineering, Qi-Hardware, KeyStream"); +MODULE_DESCRIPTION("Driver for KeyStream KS7010 based SDIO cards"); +MODULE_LICENSE("GPL v2"); +MODULE_FIRMWARE(ROM_FILE); -- cgit v1.1 From 4e66308e7dc43e15237cedb4079b830858a597aa Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:40 +0200 Subject: staging: ks7010: adapt to new trans_start handling trans_start is gone from netdevice, so use the new helper function to set the mark. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 3e28283..ac3354b 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -3398,7 +3398,7 @@ int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev) netif_stop_queue(dev); rc = hostif_data_request(priv, skb); - dev->trans_start = jiffies; + netif_trans_update(dev); DPRINTK(4, "rc=%d\n", rc); if (rc) { -- cgit v1.1 From 6b0cb0b02ec8c03a16d1bdff4ae79b27874138e1 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:41 +0200 Subject: staging: ks7010: simplify module_init/exit The printouts are not needed, the driver core has enough debug output for this if wanted. So, use a helper to save boilerplate code. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 8c0d1bb..a8a14f9 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -1237,30 +1237,7 @@ static void ks7910_sdio_remove(struct sdio_func *func) return; } -static int __init ks7010_sdio_init(void) -{ - int status; - - /* register with bus driver core */ - status = sdio_register_driver(&ks7010_sdio_driver); - if (status != 0) { - DPRINTK(1, - "ks79xx_sdio : failed to register with bus driver, %d\n", - status); - } - return status; -} - -static void __exit ks7010_sdio_exit(void) -{ - DPRINTK(5, " \n"); - sdio_unregister_driver(&ks7010_sdio_driver); - return; -} - -module_init(ks7010_sdio_init); -module_exit(ks7010_sdio_exit); - +module_driver(ks7010_sdio_driver, sdio_register_driver, sdio_unregister_driver); MODULE_AUTHOR("Sang Engineering, Qi-Hardware, KeyStream"); MODULE_DESCRIPTION("Driver for KeyStream KS7010 based SDIO cards"); MODULE_LICENSE("GPL v2"); -- cgit v1.1 From 9adca34b7eea096db6757ee7263fbc002e64c5eb Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:42 +0200 Subject: staging: ks7010: drop counting sd errors They were counted but never really used anywhere. Also change the printk to a debug print, since it mostly shows on the expected -ENOMEDIUM on card removal. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 20 ++++++-------------- drivers/staging/ks7010/ks_wlan.h | 2 -- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index a8a14f9..c166022 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -234,8 +234,8 @@ int ks_wlan_hw_power_save(struct ks_wlan_private *priv) static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address, unsigned char *buffer, int length) { - int rc = -1; struct ks_sdio_card *card; + int rc; card = priv->ks_wlan_hw.sdio_card; @@ -244,12 +244,8 @@ static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address, else /* CMD53 multi-block transfer */ rc = sdio_memcpy_fromio(card->func, buffer, address, length); - if (rc != 0) { - printk("sdio error erorr=%d size=%d\n", rc, length); - ++priv->sdio_error_count; - } else { - priv->sdio_error_count = 0; - } + if (rc != 0) + DPRINTK(1, "sdio error=%d size=%d\n", rc, length); return rc; } @@ -257,8 +253,8 @@ static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address, static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address, unsigned char *buffer, int length) { - int rc = -1; struct ks_sdio_card *card; + int rc; card = priv->ks_wlan_hw.sdio_card; @@ -268,12 +264,8 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address, rc = sdio_memcpy_toio(card->func, (unsigned int)address, buffer, length); - if (rc != 0) { - printk("sdio error erorr=%d size=%d\n", rc, length); - ++priv->sdio_error_count; - } else { - priv->sdio_error_count = 0; - } + if (rc != 0) + DPRINTK(1, "sdio error=%d size=%d\n", rc, length); return rc; } diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index f0f9f8e..a2126c2 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -500,9 +500,7 @@ struct ks_wlan_private { unsigned long last_doze; unsigned long last_wakeup; - uint sdio_error_count; /* SDIO error */ uint wakeup_count; /* for detect wakeup loop */ - }; #endif /* _KS_WLAN_H */ -- cgit v1.1 From c5d9a03031a645a8c63fdaa6a650113f8bd55b2b Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 31 May 2016 12:56:43 +0200 Subject: staging: ks7010: cleanup file headers Remove svn-ids and fix typos in the licence declaration. Add my copyright to the sdio code which I worked on mainly. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/eap_packet.h | 6 ------ drivers/staging/ks7010/ks7010_sdio.c | 8 +++----- drivers/staging/ks7010/ks7010_sdio.h | 8 ++------ drivers/staging/ks7010/ks_hostif.c | 7 ++----- drivers/staging/ks7010/ks_hostif.h | 7 ++----- drivers/staging/ks7010/ks_wlan.h | 7 ++----- drivers/staging/ks7010/ks_wlan_ioctl.h | 7 ++----- drivers/staging/ks7010/ks_wlan_net.c | 7 ++----- drivers/staging/ks7010/michael_mic.c | 7 ++----- drivers/staging/ks7010/michael_mic.h | 7 ++----- 10 files changed, 19 insertions(+), 52 deletions(-) diff --git a/drivers/staging/ks7010/eap_packet.h b/drivers/staging/ks7010/eap_packet.h index 88384fb..16a392a 100644 --- a/drivers/staging/ks7010/eap_packet.h +++ b/drivers/staging/ks7010/eap_packet.h @@ -1,9 +1,3 @@ -/* - * - * eap_packet.h - * $Id: eap_packet.h 991 2009-09-14 01:38:58Z sekine $ - * - */ #ifndef EAP_PACKET_H #define EAP_PACKET_H diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index c166022..c340254 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -1,15 +1,13 @@ /* * Driver for KeyStream, KS7010 based SDIO cards. * - * ks7010_sdio.c - * $Id: ks7010_sdio.c 996 2009-09-14 02:54:21Z sekine $ - * * Copyright (C) 2006-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. + * Copyright (C) 2016 Sang Engineering, Wolfram Sang * * This program is free software; you can redistribute it and/or modify - * it undr the terms of the GNU General Public License version 2 as - * published by the Free Sotware Foundation. + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. */ #include diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h index 2d7be5d..987cfa7 100644 --- a/drivers/staging/ks7010/ks7010_sdio.h +++ b/drivers/staging/ks7010/ks7010_sdio.h @@ -1,16 +1,12 @@ /* - * * Driver for KeyStream, KS7010 based SDIO cards. - * - * ks7010_sdio.h - * $Id: ks7010_sdio.h 1019 2009-09-28 05:41:07Z sekine $ * * Copyright (C) 2006-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. * * This program is free software; you can redistribute it and/or modify - * it undr the terms of the GNU General Public License version 2 as - * published by the Free Sotware Foundation. + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. */ #ifndef _KS7010_SDIO_H #define _KS7010_SDIO_H diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index f2a65c0..a8822fe 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -1,15 +1,12 @@ /* * Driver for KeyStream wireless LAN cards. * - * ks_hostif.c - * $Id: ks_hostif.c 996 2009-09-14 02:54:21Z sekine $ - * * Copyright (C) 2005-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. * * This program is free software; you can redistribute it and/or modify - * it undr the terms of the GNU General Public License version 2 as - * published by the Free Sotware Foundation. + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. */ #include "ks_wlan.h" diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h index 01de478..dc806b5b 100644 --- a/drivers/staging/ks7010/ks_hostif.h +++ b/drivers/staging/ks7010/ks_hostif.h @@ -1,15 +1,12 @@ /* * Driver for KeyStream wireless LAN * - * ks_hostif.h - * $Id: ks_hostif.h 994 2009-09-14 01:51:16Z sekine $ - * * Copyright (c) 2005-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. * * This program is free software; you can redistribute it and/or modify - * it undr the terms of the GNU General Public License version 2 as - * published by the Free Sotware Foundation. + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. */ #ifndef _KS_HOSTIF_H_ diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index a2126c2..c42d99c 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -1,15 +1,12 @@ /* * Driver for KeyStream IEEE802.11 b/g wireless LAN cards. - * - * ks_wlan.h - * $Id: ks_wlan.h 994 2009-09-14 01:51:16Z sekine $ * * Copyright (C) 2006-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. * * This program is free software; you can redistribute it and/or modify - * it undr the terms of the GNU General Public License version 2 as - * published by the Free Sotware Foundation. + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. */ #ifndef _KS_WLAN_H diff --git a/drivers/staging/ks7010/ks_wlan_ioctl.h b/drivers/staging/ks7010/ks_wlan_ioctl.h index cc4669e..f1fb2dd 100644 --- a/drivers/staging/ks7010/ks_wlan_ioctl.h +++ b/drivers/staging/ks7010/ks_wlan_ioctl.h @@ -1,15 +1,12 @@ /* * Driver for KeyStream 11b/g wireless LAN * - * ks_wlan_ioctl.h - * $Id: ks_wlan_ioctl.h 996 2009-09-14 02:54:21Z sekine $ - * * Copyright (c) 2005-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. * * This program is free software; you can redistribute it and/or modify - * it undr the terms of the GNU General Public License version 2 as - * published by the Free Sotware Foundation. + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. */ #ifndef _KS_WLAN_IOCTL_H diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index ac3354b..8ef0f11 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1,15 +1,12 @@ /* * Driver for KeyStream 11b/g wireless LAN * - * ks_wlan_net.c - * $Id: ks_wlan_net.c 1020 2009-09-28 05:48:31Z sekine $ - * * Copyright (C) 2005-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. * * This program is free software; you can redistribute it and/or modify - * it undr the terms of the GNU General Public License version 2 as - * published by the Free Sotware Foundation. + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. */ #include diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c index adb17df..e14c109 100644 --- a/drivers/staging/ks7010/michael_mic.c +++ b/drivers/staging/ks7010/michael_mic.c @@ -1,15 +1,12 @@ /* * Driver for KeyStream wireless LAN * - * michael_mic.c - * $Id: michael_mic.c 991 2009-09-14 01:38:58Z sekine $ - * * Copyright (C) 2005-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. * * This program is free software; you can redistribute it and/or modify - * it undr the terms of the GNU General Public License version 2 as - * published by the Free Sotware Foundation. + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. */ #include diff --git a/drivers/staging/ks7010/michael_mic.h b/drivers/staging/ks7010/michael_mic.h index 57ecbe3..c7e4eb2 100644 --- a/drivers/staging/ks7010/michael_mic.h +++ b/drivers/staging/ks7010/michael_mic.h @@ -1,15 +1,12 @@ /* * Driver for KeyStream wireless LAN - * - * michael_mic.h - * $Id: michael_mic.h 991 2009-09-14 01:38:58Z sekine $ * * Copyright (C) 2005-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. * * This program is free software; you can redistribute it and/or modify - * it undr the terms of the GNU General Public License version 2 as - * published by the Free Sotware Foundation. + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. */ /* MichelMIC routine define */ -- cgit v1.1 From 9c4dfdaa256715b08ef907c3533288f606fe78a0 Mon Sep 17 00:00:00 2001 From: Tim Sell Date: Thu, 12 May 2016 09:14:40 -0400 Subject: staging: unisys: visorhba: delete processing of vdiskmgmt commands We never issue SCSI commands of type CMD_VDISKMGMT_TYPE, so there is no need to have code that processes their completions. Signed-off-by: Tim Sell Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorhba/visorhba_main.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 6a4570d..085d782 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -706,13 +706,6 @@ static void visorhba_serverdown_complete(struct visorhba_devdata *devdata) wake_up_all((wait_queue_head_t *) cmdrsp->scsitaskmgmt.notify_handle); break; - case CMD_VDISKMGMT_TYPE: - cmdrsp = pendingdel->sent; - cmdrsp->vdiskmgmt.notifyresult_handle - = VDISK_MGMT_FAILED; - wake_up_all((wait_queue_head_t *) - cmdrsp->vdiskmgmt.notify_handle); - break; default: break; } @@ -878,16 +871,6 @@ complete_scsi_command(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) scsicmd->scsi_done(scsicmd); } -/* DELETE VDISK TASK MGMT COMMANDS */ -static inline void complete_vdiskmgmt_command(struct uiscmdrsp *cmdrsp) -{ - /* copy the result of the taskmgmt and - * wake up the error handler that is waiting for this - */ - cmdrsp->vdiskmgmt.notifyresult_handle = cmdrsp->vdiskmgmt.result; - wake_up_all((wait_queue_head_t *)cmdrsp->vdiskmgmt.notify_handle); -} - /** * complete_taskmgmt_command - complete task management * @cmdrsp: Response from the IOVM @@ -1003,11 +986,6 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct visorhba_devdata *devdata) */ cmdrsp->disknotify.v_hba = NULL; process_disk_notify(shost, cmdrsp); - } else if (cmdrsp->cmdtype == CMD_VDISKMGMT_TYPE) { - if (!del_scsipending_ent(devdata, - cmdrsp->vdiskmgmt.handle)) - break; - complete_vdiskmgmt_command(cmdrsp); } /* cmdrsp is now available for resuse */ } -- cgit v1.1 From a7d656063e55f8227a54fad99270b26472719ff1 Mon Sep 17 00:00:00 2001 From: Tim Sell Date: Thu, 12 May 2016 09:14:41 -0400 Subject: staging: unisys: visorhba: correct scsi task mgmt completion handling This patch is necessary to enable ANY task mgmt command to complete successfully via visorhba. When issuing a task mgmt command (CMD_SCSITASKMGMT_TYPE) to the IO partition (back-end), forward_taskmgmt_command() includes pointers within the command area that will be used to wake up the issuing process and provide the result when the command completes: cmdrsp->scsitaskmgmt.notify_handle = (u64)¬ifyevent; cmdrsp->scsitaskmgmt.notifyresult_handle = (u64)¬ifyresult; 'notify_handle' is a pointer to a 'wait_queue_head_t' variable, and 'notifyresult' is a pointer to an int. Both of these are just local stack variables in the issuing process. The way it's supposed to happen is that when the IO partition completes the command, in our completion handling we get copies of those pointers back from the IO partition, where we stash the result of the command at '*notifyresult' (which should not be 0xffff, because that is the initial value that the caller is looking to see a change in), and wake up the wait queue at '*notify_handle'. There are several places we do that dance, but prior to this patch, we always do it WRONG, like: cmdrsp->scsitaskmgmt.notifyresult_handle = TASK_MGMT_FAILED; wake_up_all((wait_queue_head_t *)cmdrsp->scsitaskmgmt.notify_handle); The wake_up_all() part is correct (albeit with the help of the sloppy pointer casting, but that's irrelevant to the bug), but the assignment of 'notifyresult_handle' is WRONG, and SHOULD read: *(int *)(cmdrsp->scsitaskmgmt.notifyresult_handle) = TASK_MGMT_FAILED; Without this change, the caller is NEVER going to notice a change in his local value of 'notifyresult' when he does the: if (!wait_event_timeout(notifyevent, notifyresult != 0xffff, msecs_to_jiffies(45000))) and hence will be timing out EVERY taskmgmt command. This patch also eliminates the need for sloppy casting of pointers back-and-forth between u64 values, with the help of idr_alloc() to provide handles for us. It is the generated int handles we pass to the IO partition to denote our completion context, and these are validated and converted back to the required pointers when the task mgmt commands are returned back to us by the IO partition. == Testing == You must enable dynamic debugging in visorhba (build kernel with 'CONFIG_DYNAMIC_DEBUG=y', provide kernel parameter 'visorhba.dyndbg=+p') to see kernel messages involved with visorhba scsi task mgmt commands, which were added in this patch in the form of a few dev_dbg() / pr_debug() messages. In order to inject faults necessary to get visorhba to actully issue scsi task mgmt commands, you will need to compile a kernel with CONFIG_FAIL_IO_TIMEOUT and friends, in the "Kernel hacking" section: * Enable "Fault-injection framework" * Enable "Fault-injection capability for disk IO" * Enable "Fault-injection capability for faking disk interrupts" * Enable "Debugfs entries for fault-injection capabilities" When running a kernel with those options, you can manually inject a fault that will force a scsi task mgmt command to be issued like this: # mount -t debugfs nodev /sys/kernel/debug # cd /sys/kernel/debug/fail_io_timeout # cat interval 1 # cat probability 0 # cat times 1 # echo 100 >probability # cd /sys/block/sda # l | grep fail -rw-r--r-- 1 root root 4096 May 5 10:53 io-timeout-fail -rw-r--r-- 1 root root 4096 May 5 10:54 make-it-fail # echo 1 >io-timeout-fail # echo 1 >make-it-fail To test this patch, after performing the above steps, I did something to force a block device i/o, then shortly afterwards examined the kernel log. There I found evidence that visorhba had successfully issued a task mgmt command, and that it completed successfully: [ 333.352612] FAULT_INJECTION: forcing a failure. name fail_io_timeout, interval 1, probability 100, space 0, times 1 [ 333.352617] CPU: 0 PID: 295 Comm: vhba_incoming Tainted: G C 4.6.0-rc3-ARCH+ #2 [ 333.352619] Hardware name: Dell Inc. PowerEdge T110/ , BIOS 1.23 12/15/2009 [ 333.352620] 0000000000000000 ffff88001d1a7dd0 ffffffff8125beeb ffffffff818507c0 [ 333.352623] 0000000000000064 ffff88001d1a7df0 ffffffff8128047a ffff8800113462b0 [ 333.352625] ffff88000e523000 ffff88001d1a7e00 ffffffff81241c79 ffff88001d1a7e18 [ 333.352627] Call Trace: [ 333.352634] [] dump_stack+0x4d/0x72 [ 333.352637] [] should_fail+0x11a/0x120 [ 333.352641] [] blk_should_fake_timeout+0x29/0x30 [ 333.352643] [] blk_complete_request+0x16/0x30 [ 333.352654] [] scsi_done+0x26/0x80 [scsi_mod] [ 333.352657] [] process_incoming_rsps+0x2bc/0x770 [visorhba] [ 333.352661] [] ? wait_woken+0x80/0x80 [ 333.352663] [] ? add_scsipending_entry+0x100/0x100 [visorhba] [ 333.352666] [] kthread+0xc9/0xe0 [ 333.352669] [] ret_from_fork+0x22/0x40 [ 333.352671] [] ? kthread_create_on_node+0x180/0x180 [ 364.025672] sd 0:0:1:1: visorhba: initiating type=1 taskmgmt command [ 364.029721] visorhba: notifying initiator with result=0x1 [ 364.029726] sd 0:0:1:1: visorhba: taskmgmt type=1 success; result=0x1 Signed-off-by: Tim Sell Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorhba/visorhba_main.c | 138 +++++++++++++++++++----- 1 file changed, 111 insertions(+), 27 deletions(-) diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 085d782..c4a9f32 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -133,6 +134,12 @@ struct visorhba_devdata { int devnum; struct task_struct *thread; int thread_wait_ms; + + /* + * allows us to pass int handles back-and-forth between us and + * iovm, instead of raw pointers + */ + struct idr idr; }; struct visorhba_devices_open { @@ -269,6 +276,62 @@ static struct uiscmdrsp *get_scsipending_cmdrsp(struct visorhba_devdata *ddata, } /** + * simple_idr_get - associate a provided pointer with an int value + * 1 <= value <= INT_MAX, and return this int value; + * the pointer value can be obtained later by passing + * this int value to idr_find() + * @idrtable: the data object maintaining the pointer<-->int mappings + * @p: the pointer value to be remembered + * @lock: a spinlock used when exclusive access to idrtable is needed + */ +static unsigned int simple_idr_get(struct idr *idrtable, void *p, + spinlock_t *lock) +{ + int id; + unsigned long flags; + + idr_preload(GFP_KERNEL); + spin_lock_irqsave(lock, flags); + id = idr_alloc(idrtable, p, 1, INT_MAX, GFP_NOWAIT); + spin_unlock_irqrestore(lock, flags); + idr_preload_end(); + if (id < 0) + return 0; /* failure */ + return (unsigned int)(id); /* idr_alloc() guarantees > 0 */ +} + +/** + * setup_scsitaskmgmt_handles - stash the necessary handles so that the + * completion processing logic for a taskmgmt + * cmd will be able to find who to wake up + * and where to stash the result + */ +static void setup_scsitaskmgmt_handles(struct idr *idrtable, spinlock_t *lock, + struct uiscmdrsp *cmdrsp, + wait_queue_head_t *event, int *result) +{ + /* specify the event that has to be triggered when this */ + /* cmd is complete */ + cmdrsp->scsitaskmgmt.notify_handle = + simple_idr_get(idrtable, event, lock); + cmdrsp->scsitaskmgmt.notifyresult_handle = + simple_idr_get(idrtable, result, lock); +} + +/** + * cleanup_scsitaskmgmt_handles - forget handles created by + * setup_scsitaskmgmt_handles() + */ +static void cleanup_scsitaskmgmt_handles(struct idr *idrtable, + struct uiscmdrsp *cmdrsp) +{ + if (cmdrsp->scsitaskmgmt.notify_handle) + idr_remove(idrtable, cmdrsp->scsitaskmgmt.notify_handle); + if (cmdrsp->scsitaskmgmt.notifyresult_handle) + idr_remove(idrtable, cmdrsp->scsitaskmgmt.notifyresult_handle); +} + +/** * forward_taskmgmt_command - send taskmegmt command to the Service * Partition * @tasktype: Type of taskmgmt command @@ -303,10 +366,8 @@ static int forward_taskmgmt_command(enum task_mgmt_types tasktype, /* issue TASK_MGMT_ABORT_TASK */ cmdrsp->cmdtype = CMD_SCSITASKMGMT_TYPE; - /* specify the event that has to be triggered when this */ - /* cmd is complete */ - cmdrsp->scsitaskmgmt.notify_handle = (u64)¬ifyevent; - cmdrsp->scsitaskmgmt.notifyresult_handle = (u64)¬ifyresult; + setup_scsitaskmgmt_handles(&devdata->idr, &devdata->privlock, cmdrsp, + ¬ifyevent, ¬ifyresult); /* save destination */ cmdrsp->scsitaskmgmt.tasktype = tasktype; @@ -315,6 +376,8 @@ static int forward_taskmgmt_command(enum task_mgmt_types tasktype, cmdrsp->scsitaskmgmt.vdest.lun = scsidev->lun; cmdrsp->scsitaskmgmt.handle = scsicmd_id; + dev_dbg(&scsidev->sdev_gendev, + "visorhba: initiating type=%d taskmgmt command\n", tasktype); if (!visorchannel_signalinsert(devdata->dev->visorchannel, IOCHAN_TO_IOPART, cmdrsp)) @@ -327,17 +390,23 @@ static int forward_taskmgmt_command(enum task_mgmt_types tasktype, msecs_to_jiffies(45000))) goto err_del_scsipending_ent; + dev_dbg(&scsidev->sdev_gendev, + "visorhba: taskmgmt type=%d success; result=0x%x\n", + tasktype, notifyresult); if (tasktype == TASK_MGMT_ABORT_TASK) scsicmd->result = DID_ABORT << 16; else scsicmd->result = DID_RESET << 16; scsicmd->scsi_done(scsicmd); - + cleanup_scsitaskmgmt_handles(&devdata->idr, cmdrsp); return SUCCESS; err_del_scsipending_ent: + dev_dbg(&scsidev->sdev_gendev, + "visorhba: taskmgmt type=%d not executed\n", tasktype); del_scsipending_ent(devdata, scsicmd_id); + cleanup_scsitaskmgmt_handles(&devdata->idr, cmdrsp); return FAILED; } @@ -667,6 +736,35 @@ static ssize_t info_debugfs_read(struct file *file, char __user *buf, } /** + * complete_taskmgmt_command - complete task management + * @cmdrsp: Response from the IOVM + * + * Service Partition returned the result of the task management + * command. Wake up anyone waiting for it. + * Returns void + */ +static inline void complete_taskmgmt_command +(struct idr *idrtable, struct uiscmdrsp *cmdrsp, int result) +{ + wait_queue_head_t *wq = + idr_find(idrtable, cmdrsp->scsitaskmgmt.notify_handle); + int *scsi_result_ptr = + idr_find(idrtable, cmdrsp->scsitaskmgmt.notifyresult_handle); + + if (unlikely(!(wq && scsi_result_ptr))) { + pr_err("visorhba: no completion context; cmd will time out\n"); + return; + } + + /* copy the result of the taskmgmt and + * wake up the error handler that is waiting for this + */ + pr_debug("visorhba: notifying initiator with result=0x%x\n", result); + *scsi_result_ptr = result; + wake_up_all(wq); +} + +/** * visorhba_serverdown_complete - Called when we are done cleaning up * from serverdown * @work: work structure for this serverdown request @@ -701,10 +799,8 @@ static void visorhba_serverdown_complete(struct visorhba_devdata *devdata) break; case CMD_SCSITASKMGMT_TYPE: cmdrsp = pendingdel->sent; - cmdrsp->scsitaskmgmt.notifyresult_handle - = TASK_MGMT_FAILED; - wake_up_all((wait_queue_head_t *) - cmdrsp->scsitaskmgmt.notify_handle); + complete_taskmgmt_command(&devdata->idr, cmdrsp, + TASK_MGMT_FAILED); break; default: break; @@ -871,23 +967,6 @@ complete_scsi_command(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) scsicmd->scsi_done(scsicmd); } -/** - * complete_taskmgmt_command - complete task management - * @cmdrsp: Response from the IOVM - * - * Service Partition returned the result of the task management - * command. Wake up anyone waiting for it. - * Returns void - */ -static inline void complete_taskmgmt_command(struct uiscmdrsp *cmdrsp) -{ - /* copy the result of the taskgmgt and - * wake up the error handler that is waiting for this - */ - cmdrsp->vdiskmgmt.notifyresult_handle = cmdrsp->vdiskmgmt.result; - wake_up_all((wait_queue_head_t *)cmdrsp->scsitaskmgmt.notify_handle); -} - static struct work_struct dar_work_queue; static struct diskaddremove *dar_work_queue_head; static spinlock_t dar_work_queue_lock; /* Lock to protet dar_work_queue_head */ @@ -978,7 +1057,8 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct visorhba_devdata *devdata) if (!del_scsipending_ent(devdata, cmdrsp->scsitaskmgmt.handle)) break; - complete_taskmgmt_command(cmdrsp); + complete_taskmgmt_command(&devdata->idr, cmdrsp, + cmdrsp->scsitaskmgmt.result); } else if (cmdrsp->cmdtype == CMD_NOTIFYGUEST_TYPE) { /* The vHba pointer has no meaning in a * guest partition. Let's be safe and set it @@ -1140,6 +1220,8 @@ static int visorhba_probe(struct visor_device *dev) if (err) goto err_scsi_remove_host; + idr_init(&devdata->idr); + devdata->thread_wait_ms = 2; devdata->thread = visor_thread_start(process_incoming_rsps, devdata, "vhba_incoming"); @@ -1176,6 +1258,8 @@ static void visorhba_remove(struct visor_device *dev) scsi_remove_host(scsihost); scsi_host_put(scsihost); + idr_destroy(&devdata->idr); + dev_set_drvdata(&dev->device, NULL); } -- cgit v1.1 From bf817f2f40d79dd0dfd7d800e174d8bac5257935 Mon Sep 17 00:00:00 2001 From: Tim Sell Date: Thu, 12 May 2016 09:14:42 -0400 Subject: staging: unisys: visorhba: remove unused (and broken) logic The handling of CMD_NOTIFYGUEST_TYPE messages from the IO partition appears to be only partially implemented, but fortunately it is never used in our current environment. This patch deletes the unused code. Signed-off-by: Tim Sell Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorhba/visorhba_main.c | 78 ++----------------------- 1 file changed, 4 insertions(+), 74 deletions(-) diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index c4a9f32..5ea6bb2 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -100,14 +100,6 @@ struct scsipending { char cmdtype; /* Type of pointer that is being stored */ }; -/* Work Data for dar_work_queue */ -struct diskaddremove { - u8 add; /* 0-remove, 1-add */ - struct Scsi_Host *shost; /* Scsi Host for this visorhba instance */ - u32 channel, id, lun; /* Disk Path */ - struct diskaddremove *next; -}; - /* Each scsi_host has a host_data area that contains this struct. */ struct visorhba_devdata { struct Scsi_Host *scsihost; @@ -967,62 +959,6 @@ complete_scsi_command(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd) scsicmd->scsi_done(scsicmd); } -static struct work_struct dar_work_queue; -static struct diskaddremove *dar_work_queue_head; -static spinlock_t dar_work_queue_lock; /* Lock to protet dar_work_queue_head */ -static unsigned short dar_work_queue_sched; - -/** - * queue_disk_add_remove - IOSP has sent us a add/remove request - * @dar: disk add/remove request - * - * Queue the work needed to add/remove a disk. - * Returns void - */ -static inline void queue_disk_add_remove(struct diskaddremove *dar) -{ - unsigned long flags; - - spin_lock_irqsave(&dar_work_queue_lock, flags); - if (!dar_work_queue_head) { - dar_work_queue_head = dar; - dar->next = NULL; - } else { - dar->next = dar_work_queue_head; - dar_work_queue_head = dar; - } - if (!dar_work_queue_sched) { - schedule_work(&dar_work_queue); - dar_work_queue_sched = 1; - } - spin_unlock_irqrestore(&dar_work_queue_lock, flags); -} - -/** - * process_disk_notify - IOSP has sent a process disk notify event - * @shost: Scsi hot - * @cmdrsp: Response from the IOSP - * - * Queue it to the work queue. - * Return void. - */ -static void process_disk_notify(struct Scsi_Host *shost, - struct uiscmdrsp *cmdrsp) -{ - struct diskaddremove *dar; - - dar = kzalloc(sizeof(*dar), GFP_ATOMIC); - if (!dar) - return; - - dar->add = cmdrsp->disknotify.add; - dar->shost = shost; - dar->channel = cmdrsp->disknotify.channel; - dar->id = cmdrsp->disknotify.id; - dar->lun = cmdrsp->disknotify.lun; - queue_disk_add_remove(dar); -} - /** * drain_queue - pull responses out of iochannel * @cmdrsp: Response from the IOSP @@ -1035,7 +971,6 @@ static void drain_queue(struct uiscmdrsp *cmdrsp, struct visorhba_devdata *devdata) { struct scsi_cmnd *scsicmd; - struct Scsi_Host *shost = devdata->scsihost; while (1) { if (!visorchannel_signalremove(devdata->dev->visorchannel, @@ -1059,15 +994,10 @@ drain_queue(struct uiscmdrsp *cmdrsp, struct visorhba_devdata *devdata) break; complete_taskmgmt_command(&devdata->idr, cmdrsp, cmdrsp->scsitaskmgmt.result); - } else if (cmdrsp->cmdtype == CMD_NOTIFYGUEST_TYPE) { - /* The vHba pointer has no meaning in a - * guest partition. Let's be safe and set it - * to NULL now. Do not use it here! - */ - cmdrsp->disknotify.v_hba = NULL; - process_disk_notify(shost, cmdrsp); - } - /* cmdrsp is now available for resuse */ + } else if (cmdrsp->cmdtype == CMD_NOTIFYGUEST_TYPE) + dev_err_once(&devdata->dev->device, + "ignoring unsupported NOTIFYGUEST\n"); + /* cmdrsp is now available for re-use */ } } -- cgit v1.1 From 5e1073d3f4017980f256b06725229014829b821d Mon Sep 17 00:00:00 2001 From: Tim Sell Date: Thu, 12 May 2016 09:14:43 -0400 Subject: staging: unisys: visorhba: simplify and enhance debugfs interface debugfs info for each visorhba device is now presented by a file named of the following form within the debugfs tree: visorhba/vbus:dev/info where is the vbus number, and is the relative device number. Also, the debugfs presentation function was converted to use the seq_file interface, so that it could access the device context without resorting to a global array. This also simplified the function. Signed-off-by: Tim Sell Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorhba/visorhba_main.c | 136 +++++++++++------------- 1 file changed, 65 insertions(+), 71 deletions(-) diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 5ea6bb2..6a21514 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -51,14 +52,7 @@ static int visorhba_pause(struct visor_device *dev, static int visorhba_resume(struct visor_device *dev, visorbus_state_complete_func complete_func); -static ssize_t info_debugfs_read(struct file *file, char __user *buf, - size_t len, loff_t *offset); -static int set_no_disk_inquiry_result(unsigned char *buf, - size_t len, bool is_lun0); static struct dentry *visorhba_debugfs_dir; -static const struct file_operations debugfs_info_fops = { - .read = info_debugfs_read, -}; /* GUIDS for HBA channel type supported by this driver */ static struct visor_channeltype_descriptor visorhba_channel_types[] = { @@ -132,6 +126,9 @@ struct visorhba_devdata { * iovm, instead of raw pointers */ struct idr idr; + + struct dentry *debugfs_dir; + struct dentry *debugfs_info; }; struct visorhba_devices_open { @@ -667,66 +664,49 @@ static struct scsi_host_template visorhba_driver_template = { }; /** - * info_debugfs_read - debugfs interface to dump visorhba states - * @file: Debug file - * @buf: buffer to send back to user - * @len: len that can be written to buf - * @offset: offset into buf + * info_debugfs_show - debugfs interface to dump visorhba states * - * Dumps information about the visorhba driver and devices - * TODO: Make this per vhba - * Returns bytes_read + * This presents a file in the debugfs tree named: + * /visorhba/vbus:dev/info */ -static ssize_t info_debugfs_read(struct file *file, char __user *buf, - size_t len, loff_t *offset) +static int info_debugfs_show(struct seq_file *seq, void *v) { - ssize_t bytes_read = 0; - int str_pos = 0; - u64 phys_flags_addr; - int i; - struct visorhba_devdata *devdata; - char *vbuf; - - if (len > MAX_BUF) - len = MAX_BUF; - vbuf = kzalloc(len, GFP_KERNEL); - if (!vbuf) - return -ENOMEM; - - for (i = 0; i < VISORHBA_OPEN_MAX; i++) { - if (!visorhbas_open[i].devdata) - continue; - - devdata = visorhbas_open[i].devdata; - - str_pos += scnprintf(vbuf + str_pos, - len - str_pos, "max_buff_len:%u\n", - devdata->max_buff_len); - - str_pos += scnprintf(vbuf + str_pos, len - str_pos, - "\ninterrupts_rcvd = %llu, interrupts_disabled = %llu\n", - devdata->interrupts_rcvd, - devdata->interrupts_disabled); - str_pos += scnprintf(vbuf + str_pos, - len - str_pos, "\ninterrupts_notme = %llu,\n", - devdata->interrupts_notme); - phys_flags_addr = virt_to_phys((__force void *) - devdata->flags_addr); - str_pos += scnprintf(vbuf + str_pos, len - str_pos, - "flags_addr = %p, phys_flags_addr=0x%016llx, FeatureFlags=%llu\n", - devdata->flags_addr, phys_flags_addr, - (__le64)readq(devdata->flags_addr)); - str_pos += scnprintf(vbuf + str_pos, - len - str_pos, "acquire_failed_cnt:%llu\n", - devdata->acquire_failed_cnt); - str_pos += scnprintf(vbuf + str_pos, len - str_pos, "\n"); + struct visorhba_devdata *devdata = seq->private; + + seq_printf(seq, "max_buff_len = %u\n", devdata->max_buff_len); + seq_printf(seq, "interrupts_rcvd = %llu\n", devdata->interrupts_rcvd); + seq_printf(seq, "interrupts_disabled = %llu\n", + devdata->interrupts_disabled); + seq_printf(seq, "interrupts_notme = %llu\n", + devdata->interrupts_notme); + seq_printf(seq, "flags_addr = %p\n", devdata->flags_addr); + if (devdata->flags_addr) { + u64 phys_flags_addr = + virt_to_phys((__force void *)devdata->flags_addr); + seq_printf(seq, "phys_flags_addr = 0x%016llx\n", + phys_flags_addr); + seq_printf(seq, "FeatureFlags = %llu\n", + (__le64)readq(devdata->flags_addr)); } + seq_printf(seq, "acquire_failed_cnt = %llu\n", + devdata->acquire_failed_cnt); - bytes_read = simple_read_from_buffer(buf, len, offset, vbuf, str_pos); - kfree(vbuf); - return bytes_read; + return 0; } +static int info_debugfs_open(struct inode *inode, struct file *file) +{ + return single_open(file, info_debugfs_show, inode->i_private); +} + +static const struct file_operations info_debugfs_fops = { + .owner = THIS_MODULE, + .open = info_debugfs_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + /** * complete_taskmgmt_command - complete task management * @cmdrsp: Response from the IOVM @@ -1134,6 +1114,21 @@ static int visorhba_probe(struct visor_device *dev) devdata->dev = dev; dev_set_drvdata(&dev->device, devdata); + devdata->debugfs_dir = debugfs_create_dir(dev_name(&dev->device), + visorhba_debugfs_dir); + if (!devdata->debugfs_dir) { + err = -ENOMEM; + goto err_scsi_remove_host; + } + devdata->debugfs_info = + debugfs_create_file("info", S_IRUSR | S_IRGRP, + devdata->debugfs_dir, devdata, + &info_debugfs_fops); + if (!devdata->debugfs_info) { + err = -ENOMEM; + goto err_debugfs_dir; + } + init_waitqueue_head(&devdata->rsp_queue); spin_lock_init(&devdata->privlock); devdata->serverdown = false; @@ -1144,11 +1139,11 @@ static int visorhba_probe(struct visor_device *dev) channel_header.features); err = visorbus_read_channel(dev, channel_offset, &features, 8); if (err) - goto err_scsi_remove_host; + goto err_debugfs_info; features |= ULTRA_IO_CHANNEL_IS_POLLING; err = visorbus_write_channel(dev, channel_offset, &features, 8); if (err) - goto err_scsi_remove_host; + goto err_debugfs_info; idr_init(&devdata->idr); @@ -1160,6 +1155,12 @@ static int visorhba_probe(struct visor_device *dev) return 0; +err_debugfs_info: + debugfs_remove(devdata->debugfs_info); + +err_debugfs_dir: + debugfs_remove_recursive(devdata->debugfs_dir); + err_scsi_remove_host: scsi_remove_host(scsihost); @@ -1191,6 +1192,8 @@ static void visorhba_remove(struct visor_device *dev) idr_destroy(&devdata->idr); dev_set_drvdata(&dev->device, NULL); + debugfs_remove(devdata->debugfs_info); + debugfs_remove_recursive(devdata->debugfs_dir); } /** @@ -1201,21 +1204,12 @@ static void visorhba_remove(struct visor_device *dev) */ static int visorhba_init(void) { - struct dentry *ret; int rc = -ENOMEM; visorhba_debugfs_dir = debugfs_create_dir("visorhba", NULL); if (!visorhba_debugfs_dir) return -ENOMEM; - ret = debugfs_create_file("info", S_IRUSR, visorhba_debugfs_dir, NULL, - &debugfs_info_fops); - - if (!ret) { - rc = -EIO; - goto cleanup_debugfs; - } - rc = visorbus_register_visor_driver(&visorhba_driver); if (rc) goto cleanup_debugfs; -- cgit v1.1 From d91184a9c6824205eb6072227bfc1f0beee2ade5 Mon Sep 17 00:00:00 2001 From: Tim Sell Date: Thu, 12 May 2016 09:14:44 -0400 Subject: staging: unisys: visorhba: visorhbas_open[] no longer used, so deleted The prior patch which simplified the visorhba debugfs interface made it so visorhbas_open[] and VISORHBA_OPEN_MAX were no longer needed, so they have now been deleted. Signed-off-by: Tim Sell Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorhba/visorhba_main.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 6a21514..11985bb 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -35,7 +35,6 @@ #define MAX_BUF 8192 #define MAX_PENDING_REQUESTS (MIN_NUMSIGNALS * 2) #define VISORHBA_ERROR_COUNT 30 -#define VISORHBA_OPEN_MAX 1 static int visorhba_queue_command_lck(struct scsi_cmnd *scsicmd, void (*visorhba_cmnd_done) @@ -135,8 +134,6 @@ struct visorhba_devices_open { struct visorhba_devdata *devdata; }; -static struct visorhba_devices_open visorhbas_open[VISORHBA_OPEN_MAX]; - #define for_each_vdisk_match(iter, list, match) \ for (iter = &list->head; iter->next; iter = iter->next) \ if ((iter->channel == match->channel) && \ @@ -1075,7 +1072,7 @@ static int visorhba_probe(struct visor_device *dev) struct Scsi_Host *scsihost; struct vhba_config_max max; struct visorhba_devdata *devdata = NULL; - int i, err, channel_offset; + int err, channel_offset; u64 features; scsihost = scsi_host_alloc(&visorhba_driver_template, @@ -1104,13 +1101,6 @@ static int visorhba_probe(struct visor_device *dev) goto err_scsi_host_put; devdata = (struct visorhba_devdata *)scsihost->hostdata; - for (i = 0; i < VISORHBA_OPEN_MAX; i++) { - if (!visorhbas_open[i].devdata) { - visorhbas_open[i].devdata = devdata; - break; - } - } - devdata->dev = dev; dev_set_drvdata(&dev->device, devdata); -- cgit v1.1 From 6d8c96cbc161168726480ab01ad5c53fd6b2e04a Mon Sep 17 00:00:00 2001 From: David Binder Date: Thu, 12 May 2016 09:14:45 -0400 Subject: staging: unisys: visornic: simplify visornic if statements Changes the conditional logic by looking for the absence of work to do, instead of the opposite. Signed-off-by: David Binder Reviewed-by: Tim Sell Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visornic/visornic_main.c | 41 +++++++++++++------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c index fd7c9a6..992543a 100644 --- a/drivers/staging/unisys/visornic/visornic_main.c +++ b/drivers/staging/unisys/visornic/visornic_main.c @@ -1000,25 +1000,28 @@ visornic_set_multi(struct net_device *netdev) struct uiscmdrsp *cmdrsp; struct visornic_devdata *devdata = netdev_priv(netdev); - /* any filtering changes */ - if (devdata->old_flags != netdev->flags) { - if ((netdev->flags & IFF_PROMISC) != - (devdata->old_flags & IFF_PROMISC)) { - cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC); - if (!cmdrsp) - return; - cmdrsp->cmdtype = CMD_NET_TYPE; - cmdrsp->net.type = NET_RCV_PROMISC; - cmdrsp->net.enbdis.context = netdev; - cmdrsp->net.enbdis.enable = - netdev->flags & IFF_PROMISC; - visorchannel_signalinsert(devdata->dev->visorchannel, - IOCHAN_TO_IOPART, - cmdrsp); - kfree(cmdrsp); - } - devdata->old_flags = netdev->flags; - } + if (devdata->old_flags == netdev->flags) + return; + + if ((netdev->flags & IFF_PROMISC) == + (devdata->old_flags & IFF_PROMISC)) + goto out_save_flags; + + cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC); + if (!cmdrsp) + return; + cmdrsp->cmdtype = CMD_NET_TYPE; + cmdrsp->net.type = NET_RCV_PROMISC; + cmdrsp->net.enbdis.context = netdev; + cmdrsp->net.enbdis.enable = + netdev->flags & IFF_PROMISC; + visorchannel_signalinsert(devdata->dev->visorchannel, + IOCHAN_TO_IOPART, + cmdrsp); + kfree(cmdrsp); + +out_save_flags: + devdata->old_flags = netdev->flags; } /** -- cgit v1.1 From d12324e37d4f384b93df65d5188a1875ee80ed4c Mon Sep 17 00:00:00 2001 From: David Binder Date: Thu, 12 May 2016 09:14:46 -0400 Subject: staging: unisys: visornic: cleanup error handling Adjusts goto labels to prevent attempts to free unallocated resources. Signed-off-by: David Binder Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visornic/visornic_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c index 992543a..f556100 100644 --- a/drivers/staging/unisys/visornic/visornic_main.c +++ b/drivers/staging/unisys/visornic/visornic_main.c @@ -1796,7 +1796,7 @@ static int visornic_probe(struct visor_device *dev) sizeof(struct sk_buff *), GFP_KERNEL); if (!devdata->rcvbuf) { err = -ENOMEM; - goto cleanup_rcvbuf; + goto cleanup_netdev; } /* set the net_xmit outstanding threshold */ @@ -1817,12 +1817,12 @@ static int visornic_probe(struct visor_device *dev) devdata->cmdrsp_rcv = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC); if (!devdata->cmdrsp_rcv) { err = -ENOMEM; - goto cleanup_cmdrsp_rcv; + goto cleanup_rcvbuf; } devdata->xmit_cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC); if (!devdata->xmit_cmdrsp) { err = -ENOMEM; - goto cleanup_xmit_cmdrsp; + goto cleanup_cmdrsp_rcv; } INIT_WORK(&devdata->timeout_reset, visornic_timeout_reset); devdata->server_down = false; -- cgit v1.1 From ab2c3d75451819b4d28ec6dececd299ac03d39ec Mon Sep 17 00:00:00 2001 From: David Binder Date: Thu, 12 May 2016 09:14:47 -0400 Subject: staging: unisys: visorhba: return 0 literal Returns 0 instead of variable rc in visorhba_init(). Signed-off-by: David Binder Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorhba/visorhba_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 11985bb..5ef1d30 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -1204,7 +1204,7 @@ static int visorhba_init(void) if (rc) goto cleanup_debugfs; - return rc; + return 0; cleanup_debugfs: debugfs_remove_recursive(visorhba_debugfs_dir); -- cgit v1.1 From 186896fdf0fd7d4617435986ed79f817eecd3c0f Mon Sep 17 00:00:00 2001 From: David Binder Date: Thu, 12 May 2016 09:14:48 -0400 Subject: staging: unisys: visornic: check for error instead of success Changes the conditional logic to check for an error code instead of a success code. Signed-off-by: David Binder Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visornic/visornic_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c index f556100..af81d31 100644 --- a/drivers/staging/unisys/visornic/visornic_main.c +++ b/drivers/staging/unisys/visornic/visornic_main.c @@ -2091,8 +2091,10 @@ static int visornic_init(void) goto cleanup_debugfs; err = visorbus_register_visor_driver(&visornic_driver); - if (!err) - return 0; + if (err) + goto cleanup_debugfs; + + return 0; cleanup_debugfs: debugfs_remove_recursive(visornic_debugfs_dir); -- cgit v1.1 From e1834bd0f6e2e00b04dc992d15051fb43790814e Mon Sep 17 00:00:00 2001 From: David Binder Date: Fri, 13 May 2016 23:17:15 -0400 Subject: staging: unisys: visornic: remove extraneous error check Removes an extraneous error check in devdata_initialize(), and updates the function comment accordingly. Signed-off-by: David Binder Reviewed-by: Tim Sell Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visornic/visornic_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c index af81d31..4e3e67c 100644 --- a/drivers/staging/unisys/visornic/visornic_main.c +++ b/drivers/staging/unisys/visornic/visornic_main.c @@ -1342,13 +1342,11 @@ visornic_rx(struct uiscmdrsp *cmdrsp) * * Setup initial values for the visornic based on channel and default * values. - * Returns a pointer to the devdata if successful, else NULL + * Returns a pointer to the devdata structure */ static struct visornic_devdata * devdata_initialize(struct visornic_devdata *devdata, struct visor_device *dev) { - if (!devdata) - return NULL; devdata->dev = dev; devdata->incarnation_id = get_jiffies_64(); return devdata; -- cgit v1.1 From 403ecd636424f98fa08440c6d8d1d95d66d2ad10 Mon Sep 17 00:00:00 2001 From: Tim Sell Date: Fri, 13 May 2016 23:17:16 -0400 Subject: staging: unisys: visorhba: "Prefer 'unsigned int'" checkpatch warnings This patch fixes a few checkpatch warnings in visorhba: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' Signed-off-by: Tim Sell Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorhba/visorhba_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 5ef1d30..48551fe 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -1087,9 +1087,9 @@ static int visorhba_probe(struct visor_device *dev) if (err < 0) goto err_scsi_host_put; - scsihost->max_id = (unsigned)max.max_id; - scsihost->max_lun = (unsigned)max.max_lun; - scsihost->cmd_per_lun = (unsigned)max.cmd_per_lun; + scsihost->max_id = (unsigned int)max.max_id; + scsihost->max_lun = (unsigned int)max.max_lun; + scsihost->cmd_per_lun = (unsigned int)max.cmd_per_lun; scsihost->max_sectors = (unsigned short)(max.max_io_size >> 9); scsihost->sg_tablesize = -- cgit v1.1 From 2efffad3148838842ce4ddbcb719bd1d07905d0c Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Fri, 13 May 2016 23:17:17 -0400 Subject: staging: unisys: visorinput change -1 return value This patch changes the vague -1 return value to -EINVAL Signed-off-by: Erik Arfvidson Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorinput/visorinput.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorinput/visorinput.c b/drivers/staging/unisys/visorinput/visorinput.c index 12a3570..d67cd763 100644 --- a/drivers/staging/unisys/visorinput/visorinput.c +++ b/drivers/staging/unisys/visorinput/visorinput.c @@ -506,7 +506,7 @@ calc_button(int x) case 3: return BTN_RIGHT; default: - return -1; + return -EINVAL; } } -- cgit v1.1 From ba78c4707c8757ef8aacee7f26002c38c49caa8f Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Fri, 13 May 2016 23:17:18 -0400 Subject: staging: unisys: visorhba change -1 return value This patch changes the vague -1 return value to -EBUSY Signed-off-by: Erik Arfvidson Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorhba/visorhba_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 48551fe..120ba20 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -184,7 +184,7 @@ static void visor_thread_stop(struct task_struct *task) * Partition so that it can be handled when it completes. If new is * NULL it is assumed the entry refers only to the cmdrsp. * Returns insert_location where entry was added, - * SCSI_MLQUEUE_DEVICE_BUSY if it can't + * -EBUSY if it can't */ static int add_scsipending_entry(struct visorhba_devdata *devdata, char cmdtype, void *new) @@ -199,7 +199,7 @@ static int add_scsipending_entry(struct visorhba_devdata *devdata, insert_location = (insert_location + 1) % MAX_PENDING_REQUESTS; if (insert_location == (int)devdata->nextinsert) { spin_unlock_irqrestore(&devdata->privlock, flags); - return -1; + return -EBUSY; } } -- cgit v1.1 From c294ea31aa785afe2144fc933fd59106506c1c53 Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Fri, 13 May 2016 23:17:19 -0400 Subject: staging: unisys: visorbus change -1 return values This patch changes the vague -1 return values to -EFAULT since it would be the most appropriate, given that this error would only occur in an unexpected bad offset field. Resulting in a bad address. Signed-off-by: Erik Arfvidson Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorbus_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 3a147db..d32b898 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -876,10 +876,10 @@ write_vbus_chp_info(struct visorchannel *chan, int off = sizeof(struct channel_header) + hdr_info->chp_info_offset; if (hdr_info->chp_info_offset == 0) - return -1; + return -EFAULT; if (visorchannel_write(chan, off, info, sizeof(*info)) < 0) - return -1; + return -EFAULT; return 0; } @@ -895,10 +895,10 @@ write_vbus_bus_info(struct visorchannel *chan, int off = sizeof(struct channel_header) + hdr_info->bus_info_offset; if (hdr_info->bus_info_offset == 0) - return -1; + return -EFAULT; if (visorchannel_write(chan, off, info, sizeof(*info)) < 0) - return -1; + return -EFAULT; return 0; } @@ -915,10 +915,10 @@ write_vbus_dev_info(struct visorchannel *chan, (hdr_info->device_info_struct_bytes * devix); if (hdr_info->dev_info_offset == 0) - return -1; + return -EFAULT; if (visorchannel_write(chan, off, info, sizeof(*info)) < 0) - return -1; + return -EFAULT; return 0; } -- cgit v1.1 From 119296eaa8a5dd8c3dbd5051202a06ae9a1d04fc Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Fri, 13 May 2016 23:17:20 -0400 Subject: staging: unisys: visorchipset change -1 return value This patch changes the vague -1 return value to -EINVAL Signed-off-by: Erik Arfvidson Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/visorchipset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 5ba5936..d248c94 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -1613,7 +1613,7 @@ parahotplug_request_complete(int id, u16 active) } spin_unlock(¶hotplug_request_list_lock); - return -1; + return -EINVAL; } /* -- cgit v1.1 From 35b214155601cdbb97bc2d97524b5f0df176348d Mon Sep 17 00:00:00 2001 From: Erik Arfvidson Date: Fri, 13 May 2016 23:17:21 -0400 Subject: staging: unisys: iovmcall_gnuc.h change -1 return values This patch changes the vague -1 return values to -EPERM. This operation is not supported is a good alternative to -1 because the return is basically telling the caller that the processor doesn't support vmcall operations. Signed-off-by: Erik Arfvidson Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorbus/iovmcall_gnuc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorbus/iovmcall_gnuc.h b/drivers/staging/unisys/visorbus/iovmcall_gnuc.h index b08b6ec..98ea7f3 100644 --- a/drivers/staging/unisys/visorbus/iovmcall_gnuc.h +++ b/drivers/staging/unisys/visorbus/iovmcall_gnuc.h @@ -22,7 +22,7 @@ __unisys_vmcall_gnuc(unsigned long tuple, unsigned long reg_ebx, cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx); if (!(cpuid_ecx & 0x80000000)) - return -1; + return -EPERM; __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) : "a"(tuple), "b"(reg_ebx), "c"(reg_ecx)); @@ -40,7 +40,7 @@ __unisys_extended_vmcall_gnuc(unsigned long long tuple, cpuid(0x00000001, &cpuid_eax, &cpuid_ebx, &cpuid_ecx, &cpuid_edx); if (!(cpuid_ecx & 0x80000000)) - return -1; + return -EPERM; __asm__ __volatile__(".byte 0x00f, 0x001, 0x0c1" : "=a"(result) : "a"(tuple), "b"(reg_ebx), "c"(reg_ecx), "d"(reg_edx)); -- cgit v1.1 From 73e81350ad7a45117c17fb3ec433a266b3fa7d78 Mon Sep 17 00:00:00 2001 From: David Binder Date: Fri, 13 May 2016 23:17:22 -0400 Subject: staging: unisys: visornic: change return statements Changes return statements in visornic_rx() to use literals instead of a variable. Also changes function description to reflect the correct return type. Signed-off-by: David Binder Signed-off-by: David Kershner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visornic/visornic_main.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c index 4e3e67c..a28388d 100644 --- a/drivers/staging/unisys/visornic/visornic_main.c +++ b/drivers/staging/unisys/visornic/visornic_main.c @@ -1137,7 +1137,7 @@ repost_return(struct uiscmdrsp *cmdrsp, struct visornic_devdata *devdata, * * Got a receive packet back from the IO Part, handle it and send * it up the stack. - * Returns void + * Returns 1 iff an skb was receieved, otherwise 0 */ static int visornic_rx(struct uiscmdrsp *cmdrsp) @@ -1148,7 +1148,6 @@ visornic_rx(struct uiscmdrsp *cmdrsp) int cc, currsize, off; struct ethhdr *eth; unsigned long flags; - int rx_count = 0; /* post new rcv buf to the other end using the cmdrsp we have at hand * post it without holding lock - but we'll use the signal lock to @@ -1180,7 +1179,7 @@ visornic_rx(struct uiscmdrsp *cmdrsp) */ spin_unlock_irqrestore(&devdata->priv_lock, flags); repost_return(cmdrsp, devdata, skb, netdev); - return rx_count; + return 0; } spin_unlock_irqrestore(&devdata->priv_lock, flags); @@ -1199,7 +1198,7 @@ visornic_rx(struct uiscmdrsp *cmdrsp) if (repost_return(cmdrsp, devdata, skb, netdev) < 0) dev_err(&devdata->netdev->dev, "repost_return failed"); - return rx_count; + return 0; } /* length rcvd is greater than firstfrag in this skb rcv buf */ skb->tail += RCVPOST_BUF_SIZE; /* amount in skb->data */ @@ -1215,7 +1214,7 @@ visornic_rx(struct uiscmdrsp *cmdrsp) if (repost_return(cmdrsp, devdata, skb, netdev) < 0) dev_err(&devdata->netdev->dev, "repost_return failed"); - return rx_count; + return 0; } skb->tail += skb->len; skb->data_len = 0; /* nothing rcvd in frag_list */ @@ -1234,7 +1233,7 @@ visornic_rx(struct uiscmdrsp *cmdrsp) if (cmdrsp->net.rcv.rcvbuf[0] != skb) { if (repost_return(cmdrsp, devdata, skb, netdev) < 0) dev_err(&devdata->netdev->dev, "repost_return failed"); - return rx_count; + return 0; } if (cmdrsp->net.rcv.numrcvbufs > 1) { @@ -1316,10 +1315,9 @@ visornic_rx(struct uiscmdrsp *cmdrsp) /* drop packet - don't forward it up to OS */ devdata->n_rcv_packets_not_accepted++; repost_return(cmdrsp, devdata, skb, netdev); - return rx_count; + return 0; } while (0); - rx_count++; netif_receive_skb(skb); /* netif_rx returns various values, but "in practice most drivers * ignore the return value @@ -1332,7 +1330,7 @@ visornic_rx(struct uiscmdrsp *cmdrsp) * new rcv buffer. */ repost_return(cmdrsp, devdata, skb, netdev); - return rx_count; + return 1; } /** -- cgit v1.1 From 67b1a24e883c8ca716ca3524b2ca1ca5579a48be Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 8 Jun 2016 18:50:12 -0400 Subject: staging: lustre: llite: remove lloop device The lloop device was original developed to work around the lack of direct I/O for the default loop back device. Also the lloop device greatly out performed the default loop back device. The lloop hasn't been worked on for some time and now it no longer out performs the loop device and loop now supports direct I/O. Since this is the case we can delete this device. Signed-off-by: James Simmons Reviewed-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/Kconfig | 6 - drivers/staging/lustre/lustre/llite/Makefile | 3 - drivers/staging/lustre/lustre/llite/lloop.c | 883 --------------------------- 3 files changed, 892 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/llite/lloop.c diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig index 8ac7cd4..9f5d75f 100644 --- a/drivers/staging/lustre/lustre/Kconfig +++ b/drivers/staging/lustre/lustre/Kconfig @@ -54,9 +54,3 @@ config LUSTRE_TRANSLATE_ERRNOS bool depends on LUSTRE_FS && !X86 default y - -config LUSTRE_LLITE_LLOOP - tristate "Lustre virtual block device" - depends on LUSTRE_FS && BLOCK - depends on !PPC_64K_PAGES && !ARM64_64K_PAGES && !MICROBLAZE_64K_PAGES && !PAGE_SIZE_64KB && !IA64_PAGE_SIZE_64KB && !PARISC_PAGE_SIZE_64KB - default m diff --git a/drivers/staging/lustre/lustre/llite/Makefile b/drivers/staging/lustre/lustre/llite/Makefile index 2ce10ff..19701e7 100644 --- a/drivers/staging/lustre/lustre/llite/Makefile +++ b/drivers/staging/lustre/lustre/llite/Makefile @@ -1,5 +1,4 @@ obj-$(CONFIG_LUSTRE_FS) += lustre.o -obj-$(CONFIG_LUSTRE_LLITE_LLOOP) += llite_lloop.o lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \ rw.o namei.o symlink.o llite_mmap.o \ xattr.o xattr_cache.o remote_perm.o llite_rmtacl.o \ @@ -7,5 +6,3 @@ lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \ glimpse.o lcommon_cl.o lcommon_misc.o \ vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o vvp_req.o \ lproc_llite.o - -llite_lloop-y := lloop.o diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c deleted file mode 100644 index 813a9a3..0000000 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ /dev/null @@ -1,883 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -/* - * linux/drivers/block/loop.c - * - * Written by Theodore Ts'o, 3/29/93 - * - * Copyright 1993 by Theodore Ts'o. Redistribution of this file is - * permitted under the GNU General Public License. - * - * Modularized and updated for 1.1.16 kernel - Mitch Dsouza 28th May 1994 - * Adapted for 1.3.59 kernel - Andries Brouwer, 1 Feb 1996 - * - * Fixed do_loop_request() re-entrancy - Vincent.Renardias@waw.com Mar 20, 1997 - * - * Added devfs support - Richard Gooch 16-Jan-1998 - * - * Handle sparse backing files correctly - Kenn Humborg, Jun 28, 1998 - * - * Loadable modules and other fixes by AK, 1998 - * - * Maximum number of loop devices now dynamic via max_loop module parameter. - * Russell Kroll 19990701 - * - * Maximum number of loop devices when compiled-in now selectable by passing - * max_loop=<1-255> to the kernel on boot. - * Erik I. Bols?, , Oct 31, 1999 - * - * Completely rewrite request handling to be make_request_fn style and - * non blocking, pushing work to a helper thread. Lots of fixes from - * Al Viro too. - * Jens Axboe , Nov 2000 - * - * Support up to 256 loop devices - * Heinz Mauelshagen , Feb 2002 - * - * Support for falling back on the write file operation when the address space - * operations prepare_write and/or commit_write are not available on the - * backing filesystem. - * Anton Altaparmakov, 16 Feb 2005 - * - * Still To Fix: - * - Advisory locking is ignored here. - * - Should use an own CAP_* category instead of CAP_SYS_ADMIN - * - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* for invalidate_bdev() */ -#include -#include -#include -#include -#include - -#include "../include/lustre_lib.h" -#include "../include/lustre_lite.h" -#include "llite_internal.h" - -#define LLOOP_MAX_SEGMENTS LNET_MAX_IOV - -/* Possible states of device */ -enum { - LLOOP_UNBOUND, - LLOOP_BOUND, - LLOOP_RUNDOWN, -}; - -struct lloop_device { - int lo_number; - int lo_refcnt; - loff_t lo_offset; - loff_t lo_sizelimit; - int lo_flags; - struct file *lo_backing_file; - struct block_device *lo_device; - unsigned lo_blocksize; - - gfp_t old_gfp_mask; - - spinlock_t lo_lock; - struct bio *lo_bio; - struct bio *lo_biotail; - int lo_state; - struct semaphore lo_sem; - struct mutex lo_ctl_mutex; - atomic_t lo_pending; - wait_queue_head_t lo_bh_wait; - - struct request_queue *lo_queue; - - const struct lu_env *lo_env; - struct cl_io lo_io; - struct ll_dio_pages lo_pvec; - - /* data to handle bio for lustre. */ - struct lo_request_data { - struct page *lrd_pages[LLOOP_MAX_SEGMENTS]; - loff_t lrd_offsets[LLOOP_MAX_SEGMENTS]; - } lo_requests[1]; -}; - -/* - * Loop flags - */ -enum { - LO_FLAGS_READ_ONLY = 1, -}; - -static int lloop_major; -#define MAX_LOOP_DEFAULT 16 -static int max_loop = MAX_LOOP_DEFAULT; -static struct lloop_device *loop_dev; -static struct gendisk **disks; -static struct mutex lloop_mutex; -static void *ll_iocontrol_magic; - -static loff_t get_loop_size(struct lloop_device *lo, struct file *file) -{ - loff_t size, offset, loopsize; - - /* Compute loopsize in bytes */ - size = i_size_read(file->f_mapping->host); - offset = lo->lo_offset; - loopsize = size - offset; - if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize) - loopsize = lo->lo_sizelimit; - - /* - * Unfortunately, if we want to do I/O on the device, - * the number of 512-byte sectors has to fit into a sector_t. - */ - return loopsize >> 9; -} - -static int do_bio_lustrebacked(struct lloop_device *lo, struct bio *head) -{ - const struct lu_env *env = lo->lo_env; - struct cl_io *io = &lo->lo_io; - struct inode *inode = file_inode(lo->lo_backing_file); - struct cl_object *obj = ll_i2info(inode)->lli_clob; - pgoff_t offset; - int ret; - int rw; - u32 page_count = 0; - struct bio_vec bvec; - struct bvec_iter iter; - struct bio *bio; - ssize_t bytes; - - struct ll_dio_pages *pvec = &lo->lo_pvec; - struct page **pages = pvec->ldp_pages; - loff_t *offsets = pvec->ldp_offsets; - - truncate_inode_pages(inode->i_mapping, 0); - - /* initialize the IO */ - memset(io, 0, sizeof(*io)); - io->ci_obj = obj; - ret = cl_io_init(env, io, CIT_MISC, obj); - if (ret) - return io->ci_result; - io->ci_lockreq = CILR_NEVER; - - rw = head->bi_rw; - for (bio = head; bio ; bio = bio->bi_next) { - LASSERT(rw == bio->bi_rw); - - offset = (pgoff_t)(bio->bi_iter.bi_sector << 9) + lo->lo_offset; - bio_for_each_segment(bvec, bio, iter) { - BUG_ON(bvec.bv_offset != 0); - BUG_ON(bvec.bv_len != PAGE_SIZE); - - pages[page_count] = bvec.bv_page; - offsets[page_count] = offset; - page_count++; - offset += bvec.bv_len; - } - LASSERT(page_count <= LLOOP_MAX_SEGMENTS); - } - - ll_stats_ops_tally(ll_i2sbi(inode), - (rw == WRITE) ? LPROC_LL_BRW_WRITE : LPROC_LL_BRW_READ, - page_count); - - pvec->ldp_size = page_count << PAGE_SHIFT; - pvec->ldp_nr = page_count; - - /* FIXME: in ll_direct_rw_pages, it has to allocate many cl_page{}s to - * write those pages into OST. Even worse case is that more pages - * would be asked to write out to swap space, and then finally get here - * again. - * Unfortunately this is NOT easy to fix. - * Thoughts on solution: - * 0. Define a reserved pool for cl_pages, which could be a list of - * pre-allocated cl_pages; - * 1. Define a new operation in cl_object_operations{}, says clo_depth, - * which measures how many layers for this lustre object. Generally - * speaking, the depth would be 2, one for llite, and one for lovsub. - * However, for SNS, there will be more since we need additional page - * to store parity; - * 2. Reserve the # of (page_count * depth) cl_pages from the reserved - * pool. Afterwards, the clio would allocate the pages from reserved - * pool, this guarantees we needn't allocate the cl_pages from - * generic cl_page slab cache. - * Of course, if there is NOT enough pages in the pool, we might - * be asked to write less pages once, this purely depends on - * implementation. Anyway, we should be careful to avoid deadlocking. - */ - inode_lock(inode); - bytes = ll_direct_rw_pages(env, io, rw, inode, pvec); - inode_unlock(inode); - cl_io_fini(env, io); - return (bytes == pvec->ldp_size) ? 0 : (int)bytes; -} - -/* - * Add bio to back of pending list - */ -static void loop_add_bio(struct lloop_device *lo, struct bio *bio) -{ - unsigned long flags; - - spin_lock_irqsave(&lo->lo_lock, flags); - if (lo->lo_biotail) { - lo->lo_biotail->bi_next = bio; - lo->lo_biotail = bio; - } else { - lo->lo_bio = lo->lo_biotail = bio; - } - spin_unlock_irqrestore(&lo->lo_lock, flags); - - atomic_inc(&lo->lo_pending); - if (waitqueue_active(&lo->lo_bh_wait)) - wake_up(&lo->lo_bh_wait); -} - -/* - * Grab first pending buffer - */ -static unsigned int loop_get_bio(struct lloop_device *lo, struct bio **req) -{ - struct bio *first; - struct bio **bio; - unsigned int count = 0; - unsigned int page_count = 0; - int rw; - - spin_lock_irq(&lo->lo_lock); - first = lo->lo_bio; - if (unlikely(!first)) { - spin_unlock_irq(&lo->lo_lock); - return 0; - } - - /* TODO: need to split the bio, too bad. */ - LASSERT(first->bi_vcnt <= LLOOP_MAX_SEGMENTS); - - rw = first->bi_rw; - bio = &lo->lo_bio; - while (*bio && (*bio)->bi_rw == rw) { - CDEBUG(D_INFO, "bio sector %llu size %u count %u vcnt%u\n", - (unsigned long long)(*bio)->bi_iter.bi_sector, - (*bio)->bi_iter.bi_size, - page_count, (*bio)->bi_vcnt); - if (page_count + (*bio)->bi_vcnt > LLOOP_MAX_SEGMENTS) - break; - - page_count += (*bio)->bi_vcnt; - count++; - bio = &(*bio)->bi_next; - } - if (*bio) { - /* Some of bios can't be mergeable. */ - lo->lo_bio = *bio; - *bio = NULL; - } else { - /* Hit the end of queue */ - lo->lo_biotail = NULL; - lo->lo_bio = NULL; - } - *req = first; - spin_unlock_irq(&lo->lo_lock); - return count; -} - -static blk_qc_t loop_make_request(struct request_queue *q, struct bio *old_bio) -{ - struct lloop_device *lo = q->queuedata; - int rw = bio_rw(old_bio); - int inactive; - - blk_queue_split(q, &old_bio, q->bio_split); - - if (!lo) - goto err; - - CDEBUG(D_INFO, "submit bio sector %llu size %u\n", - (unsigned long long)old_bio->bi_iter.bi_sector, - old_bio->bi_iter.bi_size); - - spin_lock_irq(&lo->lo_lock); - inactive = lo->lo_state != LLOOP_BOUND; - spin_unlock_irq(&lo->lo_lock); - if (inactive) - goto err; - - if (rw == WRITE) { - if (lo->lo_flags & LO_FLAGS_READ_ONLY) - goto err; - } else if (rw == READA) { - rw = READ; - } else if (rw != READ) { - CERROR("lloop: unknown command (%x)\n", rw); - goto err; - } - loop_add_bio(lo, old_bio); - return BLK_QC_T_NONE; -err: - bio_io_error(old_bio); - return BLK_QC_T_NONE; -} - -static inline void loop_handle_bio(struct lloop_device *lo, struct bio *bio) -{ - int ret; - - ret = do_bio_lustrebacked(lo, bio); - while (bio) { - struct bio *tmp = bio->bi_next; - - bio->bi_next = NULL; - bio->bi_error = ret; - bio_endio(bio); - bio = tmp; - } -} - -static inline int loop_active(struct lloop_device *lo) -{ - return atomic_read(&lo->lo_pending) || - (lo->lo_state == LLOOP_RUNDOWN); -} - -/* - * worker thread that handles reads/writes to file backed loop devices, - * to avoid blocking in our make_request_fn. - */ -static int loop_thread(void *data) -{ - struct lloop_device *lo = data; - struct bio *bio; - unsigned int count; - unsigned long times = 0; - unsigned long total_count = 0; - - struct lu_env *env; - int refcheck; - int ret = 0; - - set_user_nice(current, MIN_NICE); - - lo->lo_state = LLOOP_BOUND; - - env = cl_env_get(&refcheck); - if (IS_ERR(env)) { - ret = PTR_ERR(env); - goto out; - } - - lo->lo_env = env; - memset(&lo->lo_pvec, 0, sizeof(lo->lo_pvec)); - lo->lo_pvec.ldp_pages = lo->lo_requests[0].lrd_pages; - lo->lo_pvec.ldp_offsets = lo->lo_requests[0].lrd_offsets; - - /* - * up sem, we are running - */ - up(&lo->lo_sem); - - for (;;) { - wait_event(lo->lo_bh_wait, loop_active(lo)); - if (!atomic_read(&lo->lo_pending)) { - int exiting = 0; - - spin_lock_irq(&lo->lo_lock); - exiting = (lo->lo_state == LLOOP_RUNDOWN); - spin_unlock_irq(&lo->lo_lock); - if (exiting) - break; - } - - bio = NULL; - count = loop_get_bio(lo, &bio); - if (!count) { - CWARN("lloop(minor: %d): missing bio\n", lo->lo_number); - continue; - } - - total_count += count; - if (total_count < count) { /* overflow */ - total_count = count; - times = 1; - } else { - times++; - } - if ((times & 127) == 0) { - CDEBUG(D_INFO, "total: %lu, count: %lu, avg: %lu\n", - total_count, times, total_count / times); - } - - LASSERT(bio); - LASSERT(count <= atomic_read(&lo->lo_pending)); - loop_handle_bio(lo, bio); - atomic_sub(count, &lo->lo_pending); - } - cl_env_put(env, &refcheck); - -out: - up(&lo->lo_sem); - return ret; -} - -static int loop_set_fd(struct lloop_device *lo, struct file *unused, - struct block_device *bdev, struct file *file) -{ - struct inode *inode; - struct address_space *mapping; - int lo_flags = 0; - int error; - loff_t size; - - if (!try_module_get(THIS_MODULE)) - return -ENODEV; - - error = -EBUSY; - if (lo->lo_state != LLOOP_UNBOUND) - goto out; - - mapping = file->f_mapping; - inode = mapping->host; - - error = -EINVAL; - if (!S_ISREG(inode->i_mode) || inode->i_sb->s_magic != LL_SUPER_MAGIC) - goto out; - - if (!(file->f_mode & FMODE_WRITE)) - lo_flags |= LO_FLAGS_READ_ONLY; - - size = get_loop_size(lo, file); - - if ((loff_t)(sector_t)size != size) { - error = -EFBIG; - goto out; - } - - /* remove all pages in cache so as dirty pages not to be existent. */ - truncate_inode_pages(mapping, 0); - - set_device_ro(bdev, (lo_flags & LO_FLAGS_READ_ONLY) != 0); - - lo->lo_blocksize = PAGE_SIZE; - lo->lo_device = bdev; - lo->lo_flags = lo_flags; - lo->lo_backing_file = file; - lo->lo_sizelimit = 0; - lo->old_gfp_mask = mapping_gfp_mask(mapping); - mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS)); - - lo->lo_bio = lo->lo_biotail = NULL; - - /* - * set queue make_request_fn, and add limits based on lower level - * device - */ - blk_queue_make_request(lo->lo_queue, loop_make_request); - lo->lo_queue->queuedata = lo; - - /* queue parameters */ - CLASSERT(PAGE_SIZE < (1 << (sizeof(unsigned short) * 8))); - blk_queue_logical_block_size(lo->lo_queue, - (unsigned short)PAGE_SIZE); - blk_queue_max_hw_sectors(lo->lo_queue, - LLOOP_MAX_SEGMENTS << (PAGE_SHIFT - 9)); - blk_queue_max_segments(lo->lo_queue, LLOOP_MAX_SEGMENTS); - - set_capacity(disks[lo->lo_number], size); - bd_set_size(bdev, size << 9); - - set_blocksize(bdev, lo->lo_blocksize); - - kthread_run(loop_thread, lo, "lloop%d", lo->lo_number); - down(&lo->lo_sem); - return 0; - -out: - /* This is safe: open() is still holding a reference. */ - module_put(THIS_MODULE); - return error; -} - -static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev, - int count) -{ - struct file *filp = lo->lo_backing_file; - gfp_t gfp = lo->old_gfp_mask; - - if (lo->lo_state != LLOOP_BOUND) - return -ENXIO; - - if (lo->lo_refcnt > count) /* we needed one fd for the ioctl */ - return -EBUSY; - - if (!filp) - return -EINVAL; - - spin_lock_irq(&lo->lo_lock); - lo->lo_state = LLOOP_RUNDOWN; - spin_unlock_irq(&lo->lo_lock); - wake_up(&lo->lo_bh_wait); - - down(&lo->lo_sem); - lo->lo_backing_file = NULL; - lo->lo_device = NULL; - lo->lo_offset = 0; - lo->lo_sizelimit = 0; - lo->lo_flags = 0; - invalidate_bdev(bdev); - set_capacity(disks[lo->lo_number], 0); - bd_set_size(bdev, 0); - mapping_set_gfp_mask(filp->f_mapping, gfp); - lo->lo_state = LLOOP_UNBOUND; - fput(filp); - /* This is safe: open() is still holding a reference. */ - module_put(THIS_MODULE); - return 0; -} - -static int lo_open(struct block_device *bdev, fmode_t mode) -{ - struct lloop_device *lo = bdev->bd_disk->private_data; - - mutex_lock(&lo->lo_ctl_mutex); - lo->lo_refcnt++; - mutex_unlock(&lo->lo_ctl_mutex); - - return 0; -} - -static void lo_release(struct gendisk *disk, fmode_t mode) -{ - struct lloop_device *lo = disk->private_data; - - mutex_lock(&lo->lo_ctl_mutex); - --lo->lo_refcnt; - mutex_unlock(&lo->lo_ctl_mutex); -} - -/* lloop device node's ioctl function. */ -static int lo_ioctl(struct block_device *bdev, fmode_t mode, - unsigned int cmd, unsigned long arg) -{ - struct lloop_device *lo = bdev->bd_disk->private_data; - struct inode *inode = NULL; - int err = 0; - - mutex_lock(&lloop_mutex); - switch (cmd) { - case LL_IOC_LLOOP_DETACH: { - err = loop_clr_fd(lo, bdev, 2); - if (err == 0) - blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ - break; - } - - case LL_IOC_LLOOP_INFO: { - struct lu_fid fid; - - if (!lo->lo_backing_file) { - err = -ENOENT; - break; - } - if (!inode) - inode = file_inode(lo->lo_backing_file); - if (lo->lo_state == LLOOP_BOUND) - fid = ll_i2info(inode)->lli_fid; - else - fid_zero(&fid); - - if (copy_to_user((void __user *)arg, &fid, sizeof(fid))) - err = -EFAULT; - break; - } - - default: - err = -EINVAL; - break; - } - mutex_unlock(&lloop_mutex); - - return err; -} - -static struct block_device_operations lo_fops = { - .owner = THIS_MODULE, - .open = lo_open, - .release = lo_release, - .ioctl = lo_ioctl, -}; - -/* dynamic iocontrol callback. - * This callback is registered in lloop_init and will be called by - * ll_iocontrol_call. - * - * This is a llite regular file ioctl function. It takes the responsibility - * of attaching or detaching a file by a lloop's device number. - */ -static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file, - unsigned int cmd, unsigned long arg, - void *magic, int *rcp) -{ - struct lloop_device *lo = NULL; - struct block_device *bdev = NULL; - int err = 0; - dev_t dev; - - if (magic != ll_iocontrol_magic) - return LLIOC_CONT; - - if (!disks) { - err = -ENODEV; - goto out1; - } - - CWARN("Enter llop_ioctl\n"); - - mutex_lock(&lloop_mutex); - switch (cmd) { - case LL_IOC_LLOOP_ATTACH: { - struct lloop_device *lo_free = NULL; - int i; - - for (i = 0; i < max_loop; i++, lo = NULL) { - lo = &loop_dev[i]; - if (lo->lo_state == LLOOP_UNBOUND) { - if (!lo_free) - lo_free = lo; - continue; - } - if (file_inode(lo->lo_backing_file) == file_inode(file)) - break; - } - if (lo || !lo_free) { - err = -EBUSY; - goto out; - } - - lo = lo_free; - dev = MKDEV(lloop_major, lo->lo_number); - - /* quit if the used pointer is writable */ - if (put_user((long)old_encode_dev(dev), (long __user *)arg)) { - err = -EFAULT; - goto out; - } - - bdev = blkdev_get_by_dev(dev, file->f_mode, NULL); - if (IS_ERR(bdev)) { - err = PTR_ERR(bdev); - goto out; - } - - get_file(file); - err = loop_set_fd(lo, NULL, bdev, file); - if (err) { - fput(file); - blkdev_put(bdev, 0); - } - - break; - } - - case LL_IOC_LLOOP_DETACH_BYDEV: { - int minor; - - dev = old_decode_dev(arg); - if (MAJOR(dev) != lloop_major) { - err = -EINVAL; - goto out; - } - - minor = MINOR(dev); - if (minor > max_loop - 1) { - err = -EINVAL; - goto out; - } - - lo = &loop_dev[minor]; - if (lo->lo_state != LLOOP_BOUND) { - err = -EINVAL; - goto out; - } - - bdev = lo->lo_device; - err = loop_clr_fd(lo, bdev, 1); - if (err == 0) - blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ - - break; - } - - default: - err = -EINVAL; - break; - } - -out: - mutex_unlock(&lloop_mutex); -out1: - if (rcp) - *rcp = err; - return LLIOC_STOP; -} - -static int __init lloop_init(void) -{ - int i; - unsigned int cmdlist[] = { - LL_IOC_LLOOP_ATTACH, - LL_IOC_LLOOP_DETACH_BYDEV, - }; - - if (max_loop < 1 || max_loop > 256) { - max_loop = MAX_LOOP_DEFAULT; - CWARN("lloop: invalid max_loop (must be between 1 and 256), using default (%u)\n", - max_loop); - } - - lloop_major = register_blkdev(0, "lloop"); - if (lloop_major < 0) - return -EIO; - - CDEBUG(D_CONFIG, "registered lloop major %d with %u minors\n", - lloop_major, max_loop); - - ll_iocontrol_magic = ll_iocontrol_register(lloop_ioctl, 2, cmdlist); - if (!ll_iocontrol_magic) - goto out_mem1; - - loop_dev = kcalloc(max_loop, sizeof(*loop_dev), GFP_KERNEL); - if (!loop_dev) - goto out_mem1; - - disks = kcalloc(max_loop, sizeof(*disks), GFP_KERNEL); - if (!disks) - goto out_mem2; - - for (i = 0; i < max_loop; i++) { - disks[i] = alloc_disk(1); - if (!disks[i]) - goto out_mem3; - } - - mutex_init(&lloop_mutex); - - for (i = 0; i < max_loop; i++) { - struct lloop_device *lo = &loop_dev[i]; - struct gendisk *disk = disks[i]; - - lo->lo_queue = blk_alloc_queue(GFP_KERNEL); - if (!lo->lo_queue) - goto out_mem4; - - mutex_init(&lo->lo_ctl_mutex); - sema_init(&lo->lo_sem, 0); - init_waitqueue_head(&lo->lo_bh_wait); - lo->lo_number = i; - spin_lock_init(&lo->lo_lock); - disk->major = lloop_major; - disk->first_minor = i; - disk->fops = &lo_fops; - sprintf(disk->disk_name, "lloop%d", i); - disk->private_data = lo; - disk->queue = lo->lo_queue; - } - - /* We cannot fail after we call this, so another loop!*/ - for (i = 0; i < max_loop; i++) - add_disk(disks[i]); - return 0; - -out_mem4: - while (i--) - blk_cleanup_queue(loop_dev[i].lo_queue); - i = max_loop; -out_mem3: - while (i--) - put_disk(disks[i]); - kfree(disks); -out_mem2: - kfree(loop_dev); -out_mem1: - unregister_blkdev(lloop_major, "lloop"); - ll_iocontrol_unregister(ll_iocontrol_magic); - CERROR("lloop: ran out of memory\n"); - return -ENOMEM; -} - -static void lloop_exit(void) -{ - int i; - - ll_iocontrol_unregister(ll_iocontrol_magic); - for (i = 0; i < max_loop; i++) { - del_gendisk(disks[i]); - blk_cleanup_queue(loop_dev[i].lo_queue); - put_disk(disks[i]); - } - - unregister_blkdev(lloop_major, "lloop"); - - kfree(disks); - kfree(loop_dev); -} - -module_param(max_loop, int, 0444); -MODULE_PARM_DESC(max_loop, "maximum of lloop_device"); -MODULE_AUTHOR("OpenSFS, Inc. "); -MODULE_DESCRIPTION("Lustre virtual block device"); -MODULE_VERSION(LUSTRE_VERSION_STRING); -MODULE_LICENSE("GPL"); - -module_init(lloop_init); -module_exit(lloop_exit); -- cgit v1.1 From 21ca52bb749e66cf755a8b8d6345a8fbbc17ce91 Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Wed, 8 Jun 2016 13:20:42 +0530 Subject: staging: lustre: lnet: Replace semaphore ln_rc_signal with completion The semaphore ln_rc_signal is used as completion, so convert it to struct completion. Semaphores are going away in the future. Signed-off-by: Binoy Jayan Acked-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/lnet/lib-types.h | 3 ++- drivers/staging/lustre/lnet/lnet/router.c | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 24c4a08..7967b01 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -38,6 +38,7 @@ #include #include #include +#include #include "types.h" #include "lnetctl.h" @@ -610,7 +611,7 @@ typedef struct { /* rcd ready for free */ struct list_head ln_rcd_zombie; /* serialise startup/shutdown */ - struct semaphore ln_rc_signal; + struct completion ln_rc_signal; struct mutex ln_api_mutex; struct mutex ln_lnd_mutex; diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index b01dc42..0635432 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -18,6 +18,7 @@ */ #define DEBUG_SUBSYSTEM S_LNET +#include #include "../../include/linux/lnet/lib-lnet.h" #define LNET_NRB_TINY_MIN 512 /* min value for each CPT */ @@ -1065,7 +1066,7 @@ lnet_router_checker_start(void) return -EINVAL; } - sema_init(&the_lnet.ln_rc_signal, 0); + init_completion(&the_lnet.ln_rc_signal); rc = LNetEQAlloc(0, lnet_router_checker_event, &the_lnet.ln_rc_eqh); if (rc) { @@ -1079,7 +1080,7 @@ lnet_router_checker_start(void) rc = PTR_ERR(task); CERROR("Can't start router checker thread: %d\n", rc); /* block until event callback signals exit */ - down(&the_lnet.ln_rc_signal); + wait_for_completion(&the_lnet.ln_rc_signal); rc = LNetEQFree(the_lnet.ln_rc_eqh); LASSERT(!rc); the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN; @@ -1112,7 +1113,7 @@ lnet_router_checker_stop(void) wake_up(&the_lnet.ln_rc_waitq); /* block until event callback signals exit */ - down(&the_lnet.ln_rc_signal); + wait_for_completion(&the_lnet.ln_rc_signal); LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN); rc = LNetEQFree(the_lnet.ln_rc_eqh); @@ -1295,7 +1296,7 @@ rescan: lnet_prune_rc_data(1); /* wait for UNLINK */ the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN; - up(&the_lnet.ln_rc_signal); + complete(&the_lnet.ln_rc_signal); /* The unlink event callback will signal final completion */ return 0; } -- cgit v1.1 From 9e18265443d3a76462eafc3a0863c217aeaf62ac Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Tue, 7 Jun 2016 21:18:04 -0700 Subject: iio: proximity: lidar: switch to iio_device_claim_*_mode helpers Switch from using indio_dev->mlock to the iio_device_claim_*_mode helper functions. Signed-off-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c index 4f502386..c0b0e82 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -203,22 +203,19 @@ static int lidar_read_raw(struct iio_dev *indio_dev, struct lidar_data *data = iio_priv(indio_dev); int ret = -EINVAL; - mutex_lock(&indio_dev->mlock); - - if (iio_buffer_enabled(indio_dev) && mask == IIO_CHAN_INFO_RAW) { - ret = -EBUSY; - goto error_busy; - } - switch (mask) { case IIO_CHAN_INFO_RAW: { u16 reg; + if (iio_device_claim_direct_mode(indio_dev)) + return -EBUSY; + ret = lidar_get_measurement(data, ®); if (!ret) { *val = reg; ret = IIO_VAL_INT; } + iio_device_release_direct_mode(indio_dev); break; } case IIO_CHAN_INFO_SCALE: @@ -228,9 +225,6 @@ static int lidar_read_raw(struct iio_dev *indio_dev, break; } -error_busy: - mutex_unlock(&indio_dev->mlock); - return ret; } -- cgit v1.1 From b67869791084662e7428e4598129651c29c93667 Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Mon, 6 Jun 2016 22:09:21 -0700 Subject: iio: light: tcs3414: use iio helper function to guarantee direct mode Replace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same. This allows removal of an unused lock in the device private global data. Also prevents a possible race around a buffer being enabled whilst a read is going on. Signed-off-by: Alison Schofield Cc: Daniel Baluta Acked-by: Peter Meerwald-Stadler Signed-off-by: Jonathan Cameron --- drivers/iio/light/tcs3414.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/iio/light/tcs3414.c b/drivers/iio/light/tcs3414.c index f90f8c5..8a15fb5 100644 --- a/drivers/iio/light/tcs3414.c +++ b/drivers/iio/light/tcs3414.c @@ -53,7 +53,6 @@ struct tcs3414_data { struct i2c_client *client; - struct mutex lock; u8 control; u8 gain; u8 timing; @@ -134,16 +133,16 @@ static int tcs3414_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: - if (iio_buffer_enabled(indio_dev)) - return -EBUSY; - mutex_lock(&data->lock); + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; ret = tcs3414_req_data(data); if (ret < 0) { - mutex_unlock(&data->lock); + iio_device_release_direct_mode(indio_dev); return ret; } ret = i2c_smbus_read_word_data(data->client, chan->address); - mutex_unlock(&data->lock); + iio_device_release_direct_mode(indio_dev); if (ret < 0) return ret; *val = ret; @@ -288,7 +287,6 @@ static int tcs3414_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 = &tcs3414_info; -- cgit v1.1 From 95bd363bbc0bc22d9c14945e307fc30484c57166 Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Mon, 6 Jun 2016 22:10:23 -0700 Subject: iio: light: tcs3472: use iio helper function to guarantee direct mode Replace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same. This allows removal of an unused lock in the device private global data. Also prevents a previous race condition when a buffer is enabled whilst a raw read is going on. Signed-off-by: Alison Schofield Cc: Daniel Baluta Acked-by: Peter Meerwald-Stadler Signed-off-by: Jonathan Cameron --- drivers/iio/light/tcs3472.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c index 1b530bf..b29312f 100644 --- a/drivers/iio/light/tcs3472.c +++ b/drivers/iio/light/tcs3472.c @@ -52,7 +52,6 @@ struct tcs3472_data { struct i2c_client *client; - struct mutex lock; u8 enable; u8 control; u8 atime; @@ -117,17 +116,16 @@ static int tcs3472_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: - if (iio_buffer_enabled(indio_dev)) - return -EBUSY; - - mutex_lock(&data->lock); + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; ret = tcs3472_req_data(data); if (ret < 0) { - mutex_unlock(&data->lock); + iio_device_release_direct_mode(indio_dev); return ret; } ret = i2c_smbus_read_word_data(data->client, chan->address); - mutex_unlock(&data->lock); + iio_device_release_direct_mode(indio_dev); if (ret < 0) return ret; *val = ret; @@ -263,7 +261,6 @@ 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; -- cgit v1.1 From ae148e51071455519d52051ad8ee5e5776e17966 Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Mon, 6 Jun 2016 22:08:33 -0700 Subject: iio: light: isl29125: use iio helper function to guarantee direct mode Replace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same. This allows removal of an unused lock in the device private global data. Signed-off-by: Alison Schofield Cc: Daniel Baluta Acked-by: Peter Meerwald-Stadler Signed-off-by: Jonathan Cameron --- drivers/iio/light/isl29125.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c index e2945a2..a6b9d66 100644 --- a/drivers/iio/light/isl29125.c +++ b/drivers/iio/light/isl29125.c @@ -50,7 +50,6 @@ struct isl29125_data { struct i2c_client *client; - struct mutex lock; u8 conf1; u16 buffer[8]; /* 3x 16-bit, padding, 8 bytes timestamp */ }; @@ -128,11 +127,11 @@ static int isl29125_read_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_RAW: - if (iio_buffer_enabled(indio_dev)) - return -EBUSY; - mutex_lock(&data->lock); + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; ret = isl29125_read_data(data, chan->scan_index); - mutex_unlock(&data->lock); + iio_device_release_direct_mode(indio_dev); if (ret < 0) return ret; *val = ret; @@ -259,7 +258,6 @@ static int isl29125_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 = &isl29125_info; -- cgit v1.1 From dfc07df0f91a4eabfd3d974e5b1b6b4cfde99e6f Mon Sep 17 00:00:00 2001 From: Alison Schofield Date: Tue, 7 Jun 2016 17:19:05 -0700 Subject: iio: light: gp2ap020a00f: use iio helper function to lock direct mode Replace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same. Includes a tiny bit of refactoring (single case -> if) and simplified return flow. Also prevents a theoretical race condition by effectively taking the lock a little earlier than before. Signed-off-by: Alison Schofield Cc: Daniel Baluta Acked-by: Jacek Anaszewski Signed-off-by: Jonathan Cameron --- drivers/iio/light/gp2ap020a00f.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c index 6d41086..af73af3 100644 --- a/drivers/iio/light/gp2ap020a00f.c +++ b/drivers/iio/light/gp2ap020a00f.c @@ -1287,22 +1287,14 @@ static int gp2ap020a00f_read_raw(struct iio_dev *indio_dev, struct gp2ap020a00f_data *data = iio_priv(indio_dev); int err = -EINVAL; - mutex_lock(&data->lock); - - switch (mask) { - case IIO_CHAN_INFO_RAW: - if (iio_buffer_enabled(indio_dev)) { - err = -EBUSY; - goto error_unlock; - } + if (mask == IIO_CHAN_INFO_RAW) { + err = iio_device_claim_direct_mode(indio_dev); + if (err) + return err; err = gp2ap020a00f_read_channel(data, chan, val); - break; + iio_device_release_direct_mode(indio_dev); } - -error_unlock: - mutex_unlock(&data->lock); - return err < 0 ? err : IIO_VAL_INT; } -- cgit v1.1 From 40836bc3d791fda0ac930879a2f1b5b4238fd80e Mon Sep 17 00:00:00 2001 From: Martin Kepplinger Date: Fri, 3 Jun 2016 14:51:50 +0200 Subject: iio: mma8452: update contact information for Martin Kepplinger Signed-off-by: Martin Kepplinger Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 458c827..9e679af 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -8,7 +8,7 @@ * MMA8653FC (10 bit) * FXLS8471Q (14 bit) * - * Copyright 2015 Martin Kepplinger + * Copyright 2015 Martin Kepplinger * Copyright 2014 Peter Meerwald * * This file is subject to the terms and conditions of version 2 of -- cgit v1.1 From 16df666a99b9518980d0b6be3c3ffdcce6b28bf1 Mon Sep 17 00:00:00 2001 From: Martin Kepplinger Date: Fri, 3 Jun 2016 14:51:51 +0200 Subject: iio: mma8452: update device description in header comments Signed-off-by: Martin Kepplinger Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 9e679af..4be2a18 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -1,12 +1,14 @@ /* * mma8452.c - Support for following Freescale 3-axis accelerometers: * - * MMA8451Q (14 bit) - * MMA8452Q (12 bit) - * MMA8453Q (10 bit) - * MMA8652FC (12 bit) - * MMA8653FC (10 bit) - * FXLS8471Q (14 bit) + * device name digital output 7-bit I2C slave address (pin selectable) + * --------------------------------------------------------------------- + * MMA8451Q 14 bit 0x1c / 0x1d + * MMA8452Q 12 bit 0x1c / 0x1d + * MMA8453Q 10 bit 0x1c / 0x1d + * MMA8652FC 12 bit 0x1d + * MMA8653FC 10 bit 0x1d + * FXLS8471Q 14 bit 0x1e / 0x1d / 0x1c / 0x1f * * Copyright 2015 Martin Kepplinger * Copyright 2014 Peter Meerwald @@ -15,8 +17,6 @@ * the GNU General Public License. See the file COPYING in the main * directory of this archive for more details. * - * 7-bit I2C slave address 0x1c/0x1d (pin selectable) - * * TODO: orientation events */ -- cgit v1.1 From f26ab1aad53bdc2c2fedb506fc2e1d2333a8680b Mon Sep 17 00:00:00 2001 From: Martin Kepplinger Date: Fri, 3 Jun 2016 14:51:52 +0200 Subject: iio: mma8452: update Freescale company information NXP took over Freescale, so add NXP to the driver descriptions Signed-off-by: Martin Kepplinger Signed-off-by: Jonathan Cameron --- drivers/iio/accel/Kconfig | 4 ++-- drivers/iio/accel/mma8452.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index 3132587..89d7820 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -157,12 +157,12 @@ config MMA7660 will be called mma7660. config MMA8452 - tristate "Freescale MMA8452Q and similar Accelerometers Driver" + tristate "Freescale / NXP MMA8452Q and similar Accelerometers Driver" depends on I2C select IIO_BUFFER select IIO_TRIGGERED_BUFFER help - Say yes here to build support for the following Freescale 3-axis + Say yes here to build support for the following Freescale / NXP 3-axis accelerometers: MMA8451Q, MMA8452Q, MMA8453Q, MMA8652FC, MMA8653FC, FXLS8471Q. diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 4be2a18..799fe64 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -1,5 +1,5 @@ /* - * mma8452.c - Support for following Freescale 3-axis accelerometers: + * mma8452.c - Support for following Freescale / NXP 3-axis accelerometers: * * device name digital output 7-bit I2C slave address (pin selectable) * --------------------------------------------------------------------- @@ -108,7 +108,7 @@ struct mma8452_data { }; /** - * struct mma_chip_info - chip specific data for Freescale's accelerometers + * struct mma_chip_info - chip specific data * @chip_id: WHO_AM_I register's value * @channels: struct iio_chan_spec matching the device's * capabilities @@ -1693,5 +1693,5 @@ static struct i2c_driver mma8452_driver = { module_i2c_driver(mma8452_driver); MODULE_AUTHOR("Peter Meerwald "); -MODULE_DESCRIPTION("Freescale MMA8452 accelerometer driver"); +MODULE_DESCRIPTION("Freescale / NXP MMA8452 accelerometer driver"); MODULE_LICENSE("GPL"); -- cgit v1.1 From 47146eb837863be27e162d9fbbe2af6bb5560499 Mon Sep 17 00:00:00 2001 From: "Markezana, William" Date: Mon, 6 Jun 2016 08:12:11 +0000 Subject: iio: ms5637 Add Measurement Specialties explicit MS5805 and MS5837 support Signed-off-by: William Markezana Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/ms5637.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/iio/pressure/ms5637.c b/drivers/iio/pressure/ms5637.c index 8fb6f7a..953ffbc 100644 --- a/drivers/iio/pressure/ms5637.c +++ b/drivers/iio/pressure/ms5637.c @@ -1,6 +1,6 @@ /* - * ms5637.c - Support for Measurement-Specialties ms5637 and ms8607 - * pressure & temperature sensor + * ms5637.c - Support for Measurement-Specialties MS5637, MS5805 + * MS5837 and MS8607 pressure & temperature sensor * * Copyright (c) 2015 Measurement-Specialties * @@ -11,6 +11,10 @@ * Datasheet: * http://www.meas-spec.com/downloads/MS5637-02BA03.pdf * Datasheet: + * http://www.meas-spec.com/downloads/MS5805-02BA01.pdf + * Datasheet: + * http://www.meas-spec.com/downloads/MS5837-30BA.pdf + * Datasheet: * http://www.meas-spec.com/downloads/MS8607-02BA01.pdf */ @@ -170,7 +174,9 @@ static int ms5637_probe(struct i2c_client *client, static const struct i2c_device_id ms5637_id[] = { {"ms5637", 0}, - {"ms8607-temppressure", 1}, + {"ms5805", 0}, + {"ms5837", 0}, + {"ms8607-temppressure", 0}, {} }; MODULE_DEVICE_TABLE(i2c, ms5637_id); -- cgit v1.1 From 6c55c418f071dc7df2dfeb66398d009139cc5ef1 Mon Sep 17 00:00:00 2001 From: Adriana Reus Date: Mon, 6 Jun 2016 13:02:41 +0300 Subject: mailmap: update Adriana Reus email address Set current email address instead of previous employers email address. Signed-off-by: Adriana Reus Signed-off-by: Jonathan Cameron --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index 7e6c533..fd011ff 100644 --- a/.mailmap +++ b/.mailmap @@ -11,6 +11,7 @@ Aaron Durbin Adam Oldham Adam Radford Adrian Bunk +Adriana Reus Alan Cox Alan Cox Aleksey Gorelov -- cgit v1.1 From b9155073ff5de8ca6f1c40b64abca702a237c4d1 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Sun, 5 Jun 2016 20:37:57 -0700 Subject: mailmap: update Matt Ranostay email address Set current email address to replace previous employers email addresses. Cc: Jonathan Cameron Cc: Daniel Baluta Cc: linux-iio@vger.kernel.org Signed-off-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- .mailmap | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.mailmap b/.mailmap index fd011ff..2b81945 100644 --- a/.mailmap +++ b/.mailmap @@ -84,6 +84,8 @@ Leonid I Ananiev Linas Vepstas Mark Brown Matthieu CASTET +Matt Ranostay Matthew Ranostay +Matt Ranostay Mayuresh Janorkar Michael Buesch Michel Dänzer -- cgit v1.1 From deb4d1fdcb5af079896f7ca5e8067e69485f6bdd Mon Sep 17 00:00:00 2001 From: Crestez Dan Leonard Date: Fri, 3 Jun 2016 21:56:29 +0300 Subject: iio: generic_buffer: Fix --trigger-num option Initialize trig_num to -1 and handle trig_num=0 as a valid id. Fixes: 7c7e9dad (iio: iio_generic_buffer: Add --trigger-num option) Signed-off-by: Crestez Dan Leonard Signed-off-by: Jonathan Cameron --- tools/iio/iio_generic_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c index e8c3052..0e8a1f7 100644 --- a/tools/iio/iio_generic_buffer.c +++ b/tools/iio/iio_generic_buffer.c @@ -341,7 +341,7 @@ int main(int argc, char **argv) char *data = NULL; ssize_t read_size; - int dev_num = -1, trig_num; + int dev_num = -1, trig_num = -1; char *buffer_access = NULL; int scan_size; int noevents = 0; @@ -456,7 +456,7 @@ int main(int argc, char **argv) if (notrigger) { printf("trigger-less mode selected\n"); - } if (trig_num > 0) { + } if (trig_num >= 0) { char *trig_dev_name; ret = asprintf(&trig_dev_name, "%strigger%d", iio_dir, trig_num); if (ret < 0) { -- cgit v1.1 From ed7bdf5c9c15f8b23af4d00975f9976734eadb14 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 13 Jun 2016 22:44:57 +0200 Subject: staging: lustre: hide call to Posix ACL in ifdef A call to forget_cached_acl() was recently added to the lustre file system, but this is only available when CONFIG_FS_POSIX_ACL is enabled, otherwise the build now fails with: lustre/llite/file.c: In function 'll_get_acl': lustre/llite/file.c:3134:2: error: implicit declaration of function 'forget_cached_acl' [-Werror=implicit-function-declaration] forget_cached_acl(inode, type); This adds one more #ifdef for this call, corresponding to the other 22 such checks for ACL in lustre. Signed-off-by: Arnd Bergmann Fixes: b788dc51e425 ("staging: lustre: llite: drop acl from cache") Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index bafa0b7..26c6cd6 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -3131,7 +3131,9 @@ struct posix_acl *ll_get_acl(struct inode *inode, int type) spin_lock(&lli->lli_lock); /* VFS' acl_permission_check->check_acl will release the refcount */ acl = posix_acl_dup(lli->lli_posix_acl); +#ifdef CONFIG_FS_POSIX_ACL forget_cached_acl(inode, type); +#endif spin_unlock(&lli->lli_lock); return acl; -- cgit v1.1 From 04a6284fb0b7a8e618e126695195d3aa64b626fd Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Thu, 9 Jun 2016 22:35:11 -0400 Subject: staging/lustre/osc: Fix Multiple Assignment Warnings Fix all multiple assignments on lustre/osc directory. Signed-off-by: Nathaniel Clark Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_cache.c | 6 ++++-- drivers/staging/lustre/lustre/osc/osc_io.c | 12 ++++++++---- drivers/staging/lustre/lustre/osc/osc_lock.c | 3 ++- drivers/staging/lustre/lustre/osc/osc_request.c | 6 ++++-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 5a14bea..2ca5045 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -2773,7 +2773,8 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, ext->oe_sync = 1; ext->oe_urgent = 1; ext->oe_start = start; - ext->oe_end = ext->oe_max_end = end; + ext->oe_end = end; + ext->oe_max_end = end; ext->oe_obj = obj; ext->oe_srvlock = !!(brw_flags & OBD_BRW_SRVLOCK); ext->oe_nr_pages = page_count; @@ -3308,7 +3309,8 @@ int osc_lock_discard_pages(const struct lu_env *env, struct osc_object *osc, goto out; cb = mode == CLM_READ ? check_and_discard_cb : discard_cb; - info->oti_fn_index = info->oti_next_index = start; + info->oti_fn_index = start; + info->oti_next_index = start; do { res = osc_page_gang_lookup(env, io, osc, info->oti_next_index, end, cb, osc); diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index d534b0e..d3bce45 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -221,7 +221,8 @@ static void osc_page_touch_at(const struct lu_env *env, kms > loi->loi_kms ? "" : "not ", loi->loi_kms, kms, loi->loi_lvb.lvb_size); - attr->cat_mtime = attr->cat_ctime = LTIME_S(CURRENT_TIME); + attr->cat_ctime = LTIME_S(CURRENT_TIME); + attr->cat_mtime = attr->cat_ctime; valid = CAT_MTIME | CAT_CTIME; if (kms > loi->loi_kms) { attr->cat_kms = kms; @@ -458,7 +459,8 @@ static int osc_io_setattr_start(const struct lu_env *env, unsigned int cl_valid = 0; if (ia_valid & ATTR_SIZE) { - attr->cat_size = attr->cat_kms = size; + attr->cat_size = size; + attr->cat_kms = size; cl_valid = CAT_SIZE | CAT_KMS; } if (ia_valid & ATTR_MTIME_SET) { @@ -526,7 +528,8 @@ static void osc_io_setattr_end(const struct lu_env *env, if (cbargs->opc_rpc_sent) { wait_for_completion(&cbargs->opc_sync); - result = io->ci_result = cbargs->opc_rc; + result = cbargs->opc_rc; + io->ci_result = cbargs->opc_rc; } if (result == 0) { if (oio->oi_lockless) { @@ -575,7 +578,8 @@ static int osc_io_write_start(const struct lu_env *env, OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1); cl_object_attr_lock(obj); - attr->cat_mtime = attr->cat_ctime = ktime_get_real_seconds(); + attr->cat_ctime = ktime_get_real_seconds(); + attr->cat_mtime = attr->cat_ctime; rc = cl_object_attr_set(env, obj, attr, CAT_MTIME | CAT_CTIME); cl_object_attr_unlock(obj); diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 16f9cd9..d30ed2f 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -1120,7 +1120,8 @@ static void osc_lock_set_writer(const struct lu_env *env, } } else { LASSERT(cl_io_is_mkwrite(io)); - io_start = io_end = io->u.ci_fault.ft_index; + io_start = io->u.ci_fault.ft_index; + io_end = io->u.ci_fault.ft_index; } if (descr->cld_mode >= CLM_WRITE && diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 47417f8..7b1fc7e 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -474,7 +474,8 @@ static int osc_real_create(struct obd_export *exp, struct obdo *oa, DEBUG_REQ(D_HA, req, "delorphan from OST integration"); /* Don't resend the delorphan req */ - req->rq_no_resend = req->rq_no_delay = 1; + req->rq_no_resend = 1; + req->rq_no_delay = 1; } rc = ptlrpc_queue_wait(req); @@ -2775,7 +2776,8 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); memcpy(tmp, key, keylen); - req->rq_no_delay = req->rq_no_resend = 1; + req->rq_no_delay = 1; + req->rq_no_resend = 1; ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); if (rc) -- cgit v1.1 From a30dd801fad1ff961c8eb28850b3b8d013316743 Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Thu, 9 Jun 2016 22:35:12 -0400 Subject: staging/lustre/fid: Fix Multiple Assignments Fix all multiple assignments on lustre/fid directory. Signed-off-by: Nathaniel Clark Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/fid/fid_request.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index 3a4df62..9db21ba 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -98,8 +98,10 @@ static int seq_client_rpc(struct lu_client_seq *seq, * request here, otherwise if MDT0 is failed(umounted), * it can not release the export of MDT0 */ - if (seq->lcs_type == LUSTRE_SEQ_DATA) - req->rq_no_delay = req->rq_no_resend = 1; + if (seq->lcs_type == LUSTRE_SEQ_DATA) { + req->rq_no_delay = 1; + req->rq_no_resend = 1; + } debug_mask = D_CONSOLE; } else { if (seq->lcs_type == LUSTRE_SEQ_METADATA) { -- cgit v1.1 From 95c9c00886a8c2c053bc2e5f6ebf3b8b3490d608 Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Thu, 9 Jun 2016 22:35:13 -0400 Subject: staging/lustre/ldlm: Fix Multiple Assignments Fix all multiple assignments on lustre/ldlm directory. Signed-off-by: Nathaniel Clark Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 3 ++- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index b4ffbe2..b6a90b0 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -345,7 +345,8 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) * Set cl_chksum* to CRC32 for now to avoid returning screwed info * through procfs. */ - cli->cl_cksum_type = cli->cl_supp_cksum_types = OBD_CKSUM_CRC32; + cli->cl_cksum_type = OBD_CKSUM_CRC32; + cli->cl_supp_cksum_types = OBD_CKSUM_CRC32; atomic_set(&cli->cl_resends, OSC_DEFAULT_RESENDS); /* This value may be reduced at connect time in diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index ab739f0..3303ffa 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -1011,9 +1011,11 @@ static int ldlm_setup(void) blp->blp_min_threads = LDLM_NTHRS_INIT; blp->blp_max_threads = LDLM_NTHRS_MAX; } else { - blp->blp_min_threads = blp->blp_max_threads = - min_t(int, LDLM_NTHRS_MAX, max_t(int, LDLM_NTHRS_INIT, - ldlm_num_threads)); + blp->blp_min_threads = min_t(int, LDLM_NTHRS_MAX, + max_t(int, LDLM_NTHRS_INIT, + ldlm_num_threads)); + + blp->blp_max_threads = blp->blp_min_threads; } for (i = 0; i < blp->blp_min_threads; i++) { -- cgit v1.1 From 7551b8b5a97d5b6b2cab52ed7deabdb5f90fe787 Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Thu, 9 Jun 2016 22:35:14 -0400 Subject: staging/lustre/llite: Fix Multiple Assignments Fix all multiple assignments on lustre/llite directory. Signed-off-by: Nathaniel Clark Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 3 ++- drivers/staging/lustre/lustre/llite/namei.c | 3 ++- drivers/staging/lustre/lustre/llite/vvp_io.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 96c7e9f..b260f60 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -864,7 +864,8 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) try_module_get(THIS_MODULE); /* client additional sb info */ - lsi->lsi_llsbi = sbi = ll_init_sbi(sb); + sbi = ll_init_sbi(sb); + lsi->lsi_llsbi = sbi; if (!sbi) { module_put(THIS_MODULE); kfree(cfg); diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 5eba0eb..95643bc 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -318,7 +318,8 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *dentry) if (hlist_empty(&inode->i_dentry)) return NULL; - discon_alias = invalid_alias = NULL; + discon_alias = NULL; + invalid_alias = NULL; ll_lock_dcache(inode); hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) { diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index e26e0f8..763d336 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -954,7 +954,8 @@ static int vvp_io_write_start(const struct lu_env *env, * out-of-order writes. */ ll_merge_attr(env, inode); - pos = io->u.ci_wr.wr.crw_pos = i_size_read(inode); + pos = i_size_read(inode); + io->u.ci_wr.wr.crw_pos = pos; vio->vui_iocb->ki_pos = pos; } else { LASSERT(vio->vui_iocb->ki_pos == pos); -- cgit v1.1 From a3f16d017f10e89b5544f56b885eb4ce1b8d8811 Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Thu, 9 Jun 2016 22:35:15 -0400 Subject: staging/lustre/lov: Fix Multiple Assignments Fix all multiple assignments on lustre/lov directory. Signed-off-by: Nathaniel Clark Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_obd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index e15ef2e..c179b31 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -1772,7 +1772,8 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key, fm_start = fiemap->fm_start; fm_length = fiemap->fm_length; /* Calculate start stripe, last stripe and length of mapping */ - actual_start_stripe = start_stripe = lov_stripe_number(lsm, fm_start); + start_stripe = lov_stripe_number(lsm, fm_start); + actual_start_stripe = start_stripe; fm_end = (fm_length == ~0ULL ? fm_key->oa.o_size : fm_start + fm_length - 1); /* If fm_length != ~0ULL but fm_start+fm_length-1 exceeds file size */ @@ -2095,11 +2096,9 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, u32 count; int i, rc = 0, err; struct lov_tgt_desc *tgt; - unsigned incr, check_uuid, - do_inactive, no_set; - unsigned next_id = 0, mds_con = 0; + unsigned int incr = 0, check_uuid = 0, do_inactive = 0, no_set = 0; + unsigned int next_id = 0, mds_con = 0; - incr = check_uuid = do_inactive = no_set = 0; if (!set) { no_set = 1; set = ptlrpc_prep_set(); -- cgit v1.1 From 89c60364978977411efc4b5292d77d2dadd2cb50 Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Thu, 9 Jun 2016 22:35:16 -0400 Subject: staging/lustre/obdclass: Fix Multiple Assignments Fix all multiple assignments on lustre/obdclass directory. Signed-off-by: Nathaniel Clark Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/llog.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 79194d8..55a9755 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -123,8 +123,10 @@ static int llog_read_header(const struct lu_env *env, handle->lgh_last_idx = 0; /* header is record with index 0 */ llh->llh_count = 1; /* for the header record */ llh->llh_hdr.lrh_type = LLOG_HDR_MAGIC; - llh->llh_hdr.lrh_len = llh->llh_tail.lrt_len = LLOG_CHUNK_SIZE; - llh->llh_hdr.lrh_index = llh->llh_tail.lrt_index = 0; + llh->llh_hdr.lrh_len = LLOG_CHUNK_SIZE; + llh->llh_tail.lrt_len = LLOG_CHUNK_SIZE; + llh->llh_hdr.lrh_index = 0; + llh->llh_tail.lrt_index = 0; llh->llh_timestamp = ktime_get_real_seconds(); if (uuid) memcpy(&llh->llh_tgtuuid, uuid, -- cgit v1.1 From 3d2b8f5719bb3db99d5ed4a84ab8a7b899ce796a Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Thu, 9 Jun 2016 22:35:17 -0400 Subject: staging/lustre/ptlrpc: Fix Multiple Assignments Fix all multiple assignments on lustre/ptlrpc directory. Signed-off-by: Nathaniel Clark Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/client.c | 6 ++++-- drivers/staging/lustre/lustre/ptlrpc/import.c | 3 ++- drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 3 ++- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 3 ++- drivers/staging/lustre/lustre/ptlrpc/sec_null.c | 3 ++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 4b7912a..8336ed1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -3024,8 +3024,10 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, req->rq_interpret_reply = work_interpreter; /* don't want reply */ req->rq_receiving_reply = 0; - req->rq_req_unlink = req->rq_reply_unlink = 0; - req->rq_no_delay = req->rq_no_resend = 1; + req->rq_req_unlink = 0; + req->rq_reply_unlink = 0; + req->rq_no_delay = 1; + req->rq_no_resend = 1; req->rq_pill.rc_fmt = (void *)&worker_format; spin_lock_init(&req->rq_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index a4f7544..a236e38 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -698,7 +698,8 @@ int ptlrpc_connect_import(struct obd_import *imp) lustre_msg_add_op_flags(request->rq_reqmsg, MSG_CONNECT_NEXT_VER); - request->rq_no_resend = request->rq_no_delay = 1; + request->rq_no_resend = 1; + request->rq_no_delay = 1; request->rq_send_state = LUSTRE_IMP_CONNECTING; /* Allow a slightly larger reply for future growth compatibility */ req_capsule_set_size(&request->rq_pill, &RMF_CONNECT_DATA, RCL_SERVER, diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 64c0f1e..ff40be2 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -872,7 +872,8 @@ ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s, if (i > srhi->srhi_idx) { /* reset iterator for a new CPT */ srhi->srhi_req = NULL; - seq = srhi->srhi_seq = 0; + seq = 0; + srhi->srhi_seq = 0; } else { /* the next sequence */ seq = srhi->srhi_seq + (1 << svc->srv_cpt_bits); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 8a86931..d9d4ca2 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -57,7 +57,8 @@ ptlrpc_prep_ping(struct obd_import *imp) LUSTRE_OBD_VERSION, OBD_PING); if (req) { ptlrpc_request_set_replen(req); - req->rq_no_resend = req->rq_no_delay = 1; + req->rq_no_resend = 1; + req->rq_no_delay = 1; } return req; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c index 40e5349..af92e9e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c @@ -265,7 +265,8 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec, memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen); kvfree(req->rq_reqbuf); - req->rq_reqbuf = req->rq_reqmsg = newbuf; + req->rq_reqbuf = newbuf; + req->rq_reqmsg = newbuf; req->rq_reqbuf_len = alloc_size; if (req->rq_import) -- cgit v1.1 From 77447a863f6a006c60c664349fe869d0e147f6ed Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Thu, 9 Jun 2016 22:35:18 -0400 Subject: staging/lustre/lmv: Fix Multiple Assignments Fix all multiple assignments on lustre/lmv directory. Signed-off-by: Nathaniel Clark Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 9e31f6b..1d9875e 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -2686,7 +2686,7 @@ static int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt = lmv->tgts[0]; int rc = 0, i; - __u64 curspace, curinodes; + __u64 curspace = 0, curinodes = 0; if (!tgt || !tgt->ltd_exp || !tgt->ltd_active || !lmv->desc.ld_tgt_count) { @@ -2699,7 +2699,6 @@ static int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, return rc; } - curspace = curinodes = 0; for (i = 0; i < lmv->desc.ld_tgt_count; i++) { int err; -- cgit v1.1 From 8d9de3f4859a24f06f7d136e32112cdf2fb893d9 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Fri, 10 Jun 2016 16:13:39 -0400 Subject: staging: lustre: o2iblnd: remove typedefs Remove all remaining typedefs in o2iblnd driver. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 339 +++++++++---------- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 299 +++++++++-------- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 368 ++++++++++----------- .../lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c | 2 +- 4 files changed, 504 insertions(+), 504 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 4bb32f1..3f3a9c1 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -44,7 +44,7 @@ static lnd_t the_o2iblnd; -kib_data_t kiblnd_data; +struct kib_data kiblnd_data; static __u32 kiblnd_cksum(void *ptr, int nob) { @@ -98,40 +98,40 @@ static char *kiblnd_msgtype2str(int type) static int kiblnd_msgtype2size(int type) { - const int hdr_size = offsetof(kib_msg_t, ibm_u); + const int hdr_size = offsetof(struct kib_msg, ibm_u); switch (type) { case IBLND_MSG_CONNREQ: case IBLND_MSG_CONNACK: - return hdr_size + sizeof(kib_connparams_t); + return hdr_size + sizeof(struct kib_connparams); case IBLND_MSG_NOOP: return hdr_size; case IBLND_MSG_IMMEDIATE: - return offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[0]); + return offsetof(struct kib_msg, ibm_u.immediate.ibim_payload[0]); case IBLND_MSG_PUT_REQ: - return hdr_size + sizeof(kib_putreq_msg_t); + return hdr_size + sizeof(struct kib_putreq_msg); case IBLND_MSG_PUT_ACK: - return hdr_size + sizeof(kib_putack_msg_t); + return hdr_size + sizeof(struct kib_putack_msg); case IBLND_MSG_GET_REQ: - return hdr_size + sizeof(kib_get_msg_t); + return hdr_size + sizeof(struct kib_get_msg); case IBLND_MSG_PUT_NAK: case IBLND_MSG_PUT_DONE: case IBLND_MSG_GET_DONE: - return hdr_size + sizeof(kib_completion_msg_t); + return hdr_size + sizeof(struct kib_completion_msg); default: return -1; } } -static int kiblnd_unpack_rd(kib_msg_t *msg, int flip) +static int kiblnd_unpack_rd(struct kib_msg *msg, int flip) { - kib_rdma_desc_t *rd; + struct kib_rdma_desc *rd; int nob; int n; int i; @@ -156,7 +156,7 @@ static int kiblnd_unpack_rd(kib_msg_t *msg, int flip) return 1; } - nob = offsetof(kib_msg_t, ibm_u) + + nob = offsetof(struct kib_msg, ibm_u) + kiblnd_rd_msg_size(rd, msg->ibm_type, n); if (msg->ibm_nob < nob) { @@ -176,10 +176,10 @@ static int kiblnd_unpack_rd(kib_msg_t *msg, int flip) return 0; } -void kiblnd_pack_msg(lnet_ni_t *ni, kib_msg_t *msg, int version, +void kiblnd_pack_msg(lnet_ni_t *ni, struct kib_msg *msg, int version, int credits, lnet_nid_t dstnid, __u64 dststamp) { - kib_net_t *net = ni->ni_data; + struct kib_net *net = ni->ni_data; /* * CAVEAT EMPTOR! all message fields not set here should have been @@ -202,9 +202,9 @@ void kiblnd_pack_msg(lnet_ni_t *ni, kib_msg_t *msg, int version, } } -int kiblnd_unpack_msg(kib_msg_t *msg, int nob) +int kiblnd_unpack_msg(struct kib_msg *msg, int nob) { - const int hdr_size = offsetof(kib_msg_t, ibm_u); + const int hdr_size = offsetof(struct kib_msg, ibm_u); __u32 msg_cksum; __u16 version; int msg_nob; @@ -315,10 +315,10 @@ int kiblnd_unpack_msg(kib_msg_t *msg, int nob) return 0; } -int kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid) +int kiblnd_create_peer(lnet_ni_t *ni, struct kib_peer **peerp, lnet_nid_t nid) { - kib_peer_t *peer; - kib_net_t *net = ni->ni_data; + struct kib_peer *peer; + struct kib_net *net = ni->ni_data; int cpt = lnet_cpt_of_nid(nid); unsigned long flags; @@ -357,9 +357,9 @@ int kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid) return 0; } -void kiblnd_destroy_peer(kib_peer_t *peer) +void kiblnd_destroy_peer(struct kib_peer *peer) { - kib_net_t *net = peer->ibp_ni->ni_data; + struct kib_net *net = peer->ibp_ni->ni_data; LASSERT(net); LASSERT(!atomic_read(&peer->ibp_refcount)); @@ -378,7 +378,7 @@ void kiblnd_destroy_peer(kib_peer_t *peer) atomic_dec(&net->ibn_npeers); } -kib_peer_t *kiblnd_find_peer_locked(lnet_nid_t nid) +struct kib_peer *kiblnd_find_peer_locked(lnet_nid_t nid) { /* * the caller is responsible for accounting the additional reference @@ -386,10 +386,10 @@ kib_peer_t *kiblnd_find_peer_locked(lnet_nid_t nid) */ struct list_head *peer_list = kiblnd_nid2peerlist(nid); struct list_head *tmp; - kib_peer_t *peer; + struct kib_peer *peer; list_for_each(tmp, peer_list) { - peer = list_entry(tmp, kib_peer_t, ibp_list); + peer = list_entry(tmp, struct kib_peer, ibp_list); LASSERT(!kiblnd_peer_idle(peer)); if (peer->ibp_nid != nid) @@ -404,7 +404,7 @@ kib_peer_t *kiblnd_find_peer_locked(lnet_nid_t nid) return NULL; } -void kiblnd_unlink_peer_locked(kib_peer_t *peer) +void kiblnd_unlink_peer_locked(struct kib_peer *peer) { LASSERT(list_empty(&peer->ibp_conns)); @@ -417,7 +417,7 @@ void kiblnd_unlink_peer_locked(kib_peer_t *peer) static int kiblnd_get_peer_info(lnet_ni_t *ni, int index, lnet_nid_t *nidp, int *count) { - kib_peer_t *peer; + struct kib_peer *peer; struct list_head *ptmp; int i; unsigned long flags; @@ -426,7 +426,7 @@ static int kiblnd_get_peer_info(lnet_ni_t *ni, int index, for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++) { list_for_each(ptmp, &kiblnd_data.kib_peers[i]) { - peer = list_entry(ptmp, kib_peer_t, ibp_list); + peer = list_entry(ptmp, struct kib_peer, ibp_list); LASSERT(!kiblnd_peer_idle(peer)); if (peer->ibp_ni != ni) @@ -448,17 +448,17 @@ static int kiblnd_get_peer_info(lnet_ni_t *ni, int index, return -ENOENT; } -static void kiblnd_del_peer_locked(kib_peer_t *peer) +static void kiblnd_del_peer_locked(struct kib_peer *peer) { struct list_head *ctmp; struct list_head *cnxt; - kib_conn_t *conn; + struct kib_conn *conn; if (list_empty(&peer->ibp_conns)) { kiblnd_unlink_peer_locked(peer); } else { list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) { - conn = list_entry(ctmp, kib_conn_t, ibc_list); + conn = list_entry(ctmp, struct kib_conn, ibc_list); kiblnd_close_conn_locked(conn, 0); } @@ -475,7 +475,7 @@ static int kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid) LIST_HEAD(zombies); struct list_head *ptmp; struct list_head *pnxt; - kib_peer_t *peer; + struct kib_peer *peer; int lo; int hi; int i; @@ -494,7 +494,7 @@ static int kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid) for (i = lo; i <= hi; i++) { list_for_each_safe(ptmp, pnxt, &kiblnd_data.kib_peers[i]) { - peer = list_entry(ptmp, kib_peer_t, ibp_list); + peer = list_entry(ptmp, struct kib_peer, ibp_list); LASSERT(!kiblnd_peer_idle(peer)); if (peer->ibp_ni != ni) @@ -522,11 +522,11 @@ static int kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid) return rc; } -static kib_conn_t *kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index) +static struct kib_conn *kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index) { - kib_peer_t *peer; + struct kib_peer *peer; struct list_head *ptmp; - kib_conn_t *conn; + struct kib_conn *conn; struct list_head *ctmp; int i; unsigned long flags; @@ -535,7 +535,7 @@ static kib_conn_t *kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index) for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++) { list_for_each(ptmp, &kiblnd_data.kib_peers[i]) { - peer = list_entry(ptmp, kib_peer_t, ibp_list); + peer = list_entry(ptmp, struct kib_peer, ibp_list); LASSERT(!kiblnd_peer_idle(peer)); if (peer->ibp_ni != ni) @@ -545,7 +545,7 @@ static kib_conn_t *kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index) if (index-- > 0) continue; - conn = list_entry(ctmp, kib_conn_t, + conn = list_entry(ctmp, struct kib_conn, ibc_list); kiblnd_conn_addref(conn); read_unlock_irqrestore( @@ -594,7 +594,7 @@ static void kiblnd_setup_mtu_locked(struct rdma_cm_id *cmid) cmid->route.path_rec->mtu = mtu; } -static int kiblnd_get_completion_vector(kib_conn_t *conn, int cpt) +static int kiblnd_get_completion_vector(struct kib_conn *conn, int cpt) { cpumask_t *mask; int vectors; @@ -621,7 +621,7 @@ static int kiblnd_get_completion_vector(kib_conn_t *conn, int cpt) return 1; } -kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid, +struct kib_conn *kiblnd_create_conn(struct kib_peer *peer, struct rdma_cm_id *cmid, int state, int version) { /* @@ -634,12 +634,12 @@ kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid, * its ref on 'cmid'). */ rwlock_t *glock = &kiblnd_data.kib_global_lock; - kib_net_t *net = peer->ibp_ni->ni_data; - kib_dev_t *dev; + struct kib_net *net = peer->ibp_ni->ni_data; + struct kib_dev *dev; struct ib_qp_init_attr *init_qp_attr; struct kib_sched_info *sched; struct ib_cq_init_attr cq_attr = {}; - kib_conn_t *conn; + struct kib_conn *conn; struct ib_cq *cq; unsigned long flags; int cpt; @@ -723,7 +723,7 @@ kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid, write_unlock_irqrestore(glock, flags); LIBCFS_CPT_ALLOC(conn->ibc_rxs, lnet_cpt_table(), cpt, - IBLND_RX_MSGS(conn) * sizeof(kib_rx_t)); + IBLND_RX_MSGS(conn) * sizeof(struct kib_rx)); if (!conn->ibc_rxs) { CERROR("Cannot allocate RX buffers\n"); goto failed_2; @@ -833,10 +833,10 @@ kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid, return NULL; } -void kiblnd_destroy_conn(kib_conn_t *conn, bool free_conn) +void kiblnd_destroy_conn(struct kib_conn *conn, bool free_conn) { struct rdma_cm_id *cmid = conn->ibc_cmid; - kib_peer_t *peer = conn->ibc_peer; + struct kib_peer *peer = conn->ibc_peer; int rc; LASSERT(!in_interrupt()); @@ -879,7 +879,7 @@ void kiblnd_destroy_conn(kib_conn_t *conn, bool free_conn) if (conn->ibc_rxs) { LIBCFS_FREE(conn->ibc_rxs, - IBLND_RX_MSGS(conn) * sizeof(kib_rx_t)); + IBLND_RX_MSGS(conn) * sizeof(struct kib_rx)); } if (conn->ibc_connvars) @@ -890,7 +890,7 @@ void kiblnd_destroy_conn(kib_conn_t *conn, bool free_conn) /* See CAVEAT EMPTOR above in kiblnd_create_conn */ if (conn->ibc_state != IBLND_CONN_INIT) { - kib_net_t *net = peer->ibp_ni->ni_data; + struct kib_net *net = peer->ibp_ni->ni_data; kiblnd_peer_decref(peer); rdma_destroy_id(cmid); @@ -900,15 +900,15 @@ void kiblnd_destroy_conn(kib_conn_t *conn, bool free_conn) LIBCFS_FREE(conn, sizeof(*conn)); } -int kiblnd_close_peer_conns_locked(kib_peer_t *peer, int why) +int kiblnd_close_peer_conns_locked(struct kib_peer *peer, int why) { - kib_conn_t *conn; + struct kib_conn *conn; struct list_head *ctmp; struct list_head *cnxt; int count = 0; list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) { - conn = list_entry(ctmp, kib_conn_t, ibc_list); + conn = list_entry(ctmp, struct kib_conn, ibc_list); CDEBUG(D_NET, "Closing conn -> %s, version: %x, reason: %d\n", libcfs_nid2str(peer->ibp_nid), @@ -921,16 +921,16 @@ int kiblnd_close_peer_conns_locked(kib_peer_t *peer, int why) return count; } -int kiblnd_close_stale_conns_locked(kib_peer_t *peer, +int kiblnd_close_stale_conns_locked(struct kib_peer *peer, int version, __u64 incarnation) { - kib_conn_t *conn; + struct kib_conn *conn; struct list_head *ctmp; struct list_head *cnxt; int count = 0; list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) { - conn = list_entry(ctmp, kib_conn_t, ibc_list); + conn = list_entry(ctmp, struct kib_conn, ibc_list); if (conn->ibc_version == version && conn->ibc_incarnation == incarnation) @@ -951,7 +951,7 @@ int kiblnd_close_stale_conns_locked(kib_peer_t *peer, static int kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid) { - kib_peer_t *peer; + struct kib_peer *peer; struct list_head *ptmp; struct list_head *pnxt; int lo; @@ -972,7 +972,7 @@ static int kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid) for (i = lo; i <= hi; i++) { list_for_each_safe(ptmp, pnxt, &kiblnd_data.kib_peers[i]) { - peer = list_entry(ptmp, kib_peer_t, ibp_list); + peer = list_entry(ptmp, struct kib_peer, ibp_list); LASSERT(!kiblnd_peer_idle(peer)); if (peer->ibp_ni != ni) @@ -1016,7 +1016,7 @@ static int kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg) break; } case IOC_LIBCFS_GET_CONN: { - kib_conn_t *conn; + struct kib_conn *conn; rc = 0; conn = kiblnd_get_conn_by_idx(ni, data->ioc_count); @@ -1052,7 +1052,7 @@ static void kiblnd_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when) unsigned long last_alive = 0; unsigned long now = cfs_time_current(); rwlock_t *glock = &kiblnd_data.kib_global_lock; - kib_peer_t *peer; + struct kib_peer *peer; unsigned long flags; read_lock_irqsave(glock, flags); @@ -1078,7 +1078,7 @@ static void kiblnd_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when) last_alive ? cfs_duration_sec(now - last_alive) : -1); } -static void kiblnd_free_pages(kib_pages_t *p) +static void kiblnd_free_pages(struct kib_pages *p) { int npages = p->ibp_npages; int i; @@ -1088,22 +1088,22 @@ static void kiblnd_free_pages(kib_pages_t *p) __free_page(p->ibp_pages[i]); } - LIBCFS_FREE(p, offsetof(kib_pages_t, ibp_pages[npages])); + LIBCFS_FREE(p, offsetof(struct kib_pages, ibp_pages[npages])); } -int kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages) +int kiblnd_alloc_pages(struct kib_pages **pp, int cpt, int npages) { - kib_pages_t *p; + struct kib_pages *p; int i; LIBCFS_CPT_ALLOC(p, lnet_cpt_table(), cpt, - offsetof(kib_pages_t, ibp_pages[npages])); + offsetof(struct kib_pages, ibp_pages[npages])); if (!p) { CERROR("Can't allocate descriptor for %d pages\n", npages); return -ENOMEM; } - memset(p, 0, offsetof(kib_pages_t, ibp_pages[npages])); + memset(p, 0, offsetof(struct kib_pages, ibp_pages[npages])); p->ibp_npages = npages; for (i = 0; i < npages; i++) { @@ -1121,9 +1121,9 @@ int kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages) return 0; } -void kiblnd_unmap_rx_descs(kib_conn_t *conn) +void kiblnd_unmap_rx_descs(struct kib_conn *conn) { - kib_rx_t *rx; + struct kib_rx *rx; int i; LASSERT(conn->ibc_rxs); @@ -1145,9 +1145,9 @@ void kiblnd_unmap_rx_descs(kib_conn_t *conn) conn->ibc_rx_pages = NULL; } -void kiblnd_map_rx_descs(kib_conn_t *conn) +void kiblnd_map_rx_descs(struct kib_conn *conn) { - kib_rx_t *rx; + struct kib_rx *rx; struct page *pg; int pg_off; int ipg; @@ -1158,7 +1158,7 @@ void kiblnd_map_rx_descs(kib_conn_t *conn) rx = &conn->ibc_rxs[i]; rx->rx_conn = conn; - rx->rx_msg = (kib_msg_t *)(((char *)page_address(pg)) + pg_off); + rx->rx_msg = (struct kib_msg *)(((char *)page_address(pg)) + pg_off); rx->rx_msgaddr = kiblnd_dma_map_single(conn->ibc_hdev->ibh_ibdev, rx->rx_msg, @@ -1183,10 +1183,10 @@ void kiblnd_map_rx_descs(kib_conn_t *conn) } } -static void kiblnd_unmap_tx_pool(kib_tx_pool_t *tpo) +static void kiblnd_unmap_tx_pool(struct kib_tx_pool *tpo) { - kib_hca_dev_t *hdev = tpo->tpo_hdev; - kib_tx_t *tx; + struct kib_hca_dev *hdev = tpo->tpo_hdev; + struct kib_tx *tx; int i; LASSERT(!tpo->tpo_pool.po_allocated); @@ -1206,9 +1206,9 @@ static void kiblnd_unmap_tx_pool(kib_tx_pool_t *tpo) tpo->tpo_hdev = NULL; } -static kib_hca_dev_t *kiblnd_current_hdev(kib_dev_t *dev) +static struct kib_hca_dev *kiblnd_current_hdev(struct kib_dev *dev) { - kib_hca_dev_t *hdev; + struct kib_hca_dev *hdev; unsigned long flags; int i = 0; @@ -1232,14 +1232,14 @@ static kib_hca_dev_t *kiblnd_current_hdev(kib_dev_t *dev) return hdev; } -static void kiblnd_map_tx_pool(kib_tx_pool_t *tpo) +static void kiblnd_map_tx_pool(struct kib_tx_pool *tpo) { - kib_pages_t *txpgs = tpo->tpo_tx_pages; - kib_pool_t *pool = &tpo->tpo_pool; - kib_net_t *net = pool->po_owner->ps_net; - kib_dev_t *dev; + struct kib_pages *txpgs = tpo->tpo_tx_pages; + struct kib_pool *pool = &tpo->tpo_pool; + struct kib_net *net = pool->po_owner->ps_net; + struct kib_dev *dev; struct page *page; - kib_tx_t *tx; + struct kib_tx *tx; int page_offset; int ipage; int i; @@ -1260,7 +1260,7 @@ static void kiblnd_map_tx_pool(kib_tx_pool_t *tpo) page = txpgs->ibp_pages[ipage]; tx = &tpo->tpo_tx_descs[i]; - tx->tx_msg = (kib_msg_t *)(((char *)page_address(page)) + + tx->tx_msg = (struct kib_msg *)(((char *)page_address(page)) + page_offset); tx->tx_msgaddr = kiblnd_dma_map_single( @@ -1283,11 +1283,11 @@ static void kiblnd_map_tx_pool(kib_tx_pool_t *tpo) } } -struct ib_mr *kiblnd_find_rd_dma_mr(struct lnet_ni *ni, kib_rdma_desc_t *rd, +struct ib_mr *kiblnd_find_rd_dma_mr(struct lnet_ni *ni, struct kib_rdma_desc *rd, int negotiated_nfrags) { - kib_net_t *net = ni->ni_data; - kib_hca_dev_t *hdev = net->ibn_dev->ibd_hdev; + struct kib_net *net = ni->ni_data; + struct kib_hca_dev *hdev = net->ibn_dev->ibd_hdev; struct lnet_ioctl_config_o2iblnd_tunables *tunables; __u16 nfrags; int mod; @@ -1304,7 +1304,7 @@ struct ib_mr *kiblnd_find_rd_dma_mr(struct lnet_ni *ni, kib_rdma_desc_t *rd, return hdev->ibh_mrs; } -static void kiblnd_destroy_fmr_pool(kib_fmr_pool_t *fpo) +static void kiblnd_destroy_fmr_pool(struct kib_fmr_pool *fpo) { LASSERT(!fpo->fpo_map_count); @@ -1335,7 +1335,7 @@ static void kiblnd_destroy_fmr_pool(kib_fmr_pool_t *fpo) static void kiblnd_destroy_fmr_pool_list(struct list_head *head) { - kib_fmr_pool_t *fpo, *tmp; + struct kib_fmr_pool *fpo, *tmp; list_for_each_entry_safe(fpo, tmp, head, fpo_list) { list_del(&fpo->fpo_list); @@ -1361,7 +1361,7 @@ kiblnd_fmr_flush_trigger(struct lnet_ioctl_config_o2iblnd_tunables *tunables, return max(IBLND_FMR_POOL_FLUSH, size); } -static int kiblnd_alloc_fmr_pool(kib_fmr_poolset_t *fps, kib_fmr_pool_t *fpo) +static int kiblnd_alloc_fmr_pool(struct kib_fmr_poolset *fps, struct kib_fmr_pool *fpo) { struct ib_fmr_pool_param param = { .max_pages_per_fmr = LNET_MAX_PAYLOAD / PAGE_SIZE, @@ -1388,7 +1388,7 @@ static int kiblnd_alloc_fmr_pool(kib_fmr_poolset_t *fps, kib_fmr_pool_t *fpo) return rc; } -static int kiblnd_alloc_freg_pool(kib_fmr_poolset_t *fps, kib_fmr_pool_t *fpo) +static int kiblnd_alloc_freg_pool(struct kib_fmr_poolset *fps, struct kib_fmr_pool *fpo) { struct kib_fast_reg_descriptor *frd, *tmp; int i, rc; @@ -1438,12 +1438,12 @@ out: return rc; } -static int kiblnd_create_fmr_pool(kib_fmr_poolset_t *fps, - kib_fmr_pool_t **pp_fpo) +static int kiblnd_create_fmr_pool(struct kib_fmr_poolset *fps, + struct kib_fmr_pool **pp_fpo) { - kib_dev_t *dev = fps->fps_net->ibn_dev; + struct kib_dev *dev = fps->fps_net->ibn_dev; struct ib_device_attr *dev_attr; - kib_fmr_pool_t *fpo; + struct kib_fmr_pool *fpo; int rc; LIBCFS_CPT_ALLOC(fpo, lnet_cpt_table(), fps->fps_cpt, sizeof(*fpo)); @@ -1488,7 +1488,7 @@ out_fpo: return rc; } -static void kiblnd_fail_fmr_poolset(kib_fmr_poolset_t *fps, +static void kiblnd_fail_fmr_poolset(struct kib_fmr_poolset *fps, struct list_head *zombies) { if (!fps->fps_net) /* intialized? */ @@ -1497,8 +1497,8 @@ static void kiblnd_fail_fmr_poolset(kib_fmr_poolset_t *fps, spin_lock(&fps->fps_lock); while (!list_empty(&fps->fps_pool_list)) { - kib_fmr_pool_t *fpo = list_entry(fps->fps_pool_list.next, - kib_fmr_pool_t, fpo_list); + struct kib_fmr_pool *fpo = list_entry(fps->fps_pool_list.next, + struct kib_fmr_pool, fpo_list); fpo->fpo_failed = 1; list_del(&fpo->fpo_list); if (!fpo->fpo_map_count) @@ -1510,7 +1510,7 @@ static void kiblnd_fail_fmr_poolset(kib_fmr_poolset_t *fps, spin_unlock(&fps->fps_lock); } -static void kiblnd_fini_fmr_poolset(kib_fmr_poolset_t *fps) +static void kiblnd_fini_fmr_poolset(struct kib_fmr_poolset *fps) { if (fps->fps_net) { /* initialized? */ kiblnd_destroy_fmr_pool_list(&fps->fps_failed_pool_list); @@ -1519,11 +1519,11 @@ static void kiblnd_fini_fmr_poolset(kib_fmr_poolset_t *fps) } static int -kiblnd_init_fmr_poolset(kib_fmr_poolset_t *fps, int cpt, int ncpts, - kib_net_t *net, +kiblnd_init_fmr_poolset(struct kib_fmr_poolset *fps, int cpt, int ncpts, + struct kib_net *net, struct lnet_ioctl_config_o2iblnd_tunables *tunables) { - kib_fmr_pool_t *fpo; + struct kib_fmr_pool *fpo; int rc; memset(fps, 0, sizeof(*fps)); @@ -1546,7 +1546,7 @@ kiblnd_init_fmr_poolset(kib_fmr_poolset_t *fps, int cpt, int ncpts, return rc; } -static int kiblnd_fmr_pool_is_idle(kib_fmr_pool_t *fpo, unsigned long now) +static int kiblnd_fmr_pool_is_idle(struct kib_fmr_pool *fpo, unsigned long now) { if (fpo->fpo_map_count) /* still in use */ return 0; @@ -1556,10 +1556,10 @@ static int kiblnd_fmr_pool_is_idle(kib_fmr_pool_t *fpo, unsigned long now) } static int -kiblnd_map_tx_pages(kib_tx_t *tx, kib_rdma_desc_t *rd) +kiblnd_map_tx_pages(struct kib_tx *tx, struct kib_rdma_desc *rd) { __u64 *pages = tx->tx_pages; - kib_hca_dev_t *hdev; + struct kib_hca_dev *hdev; int npages; int size; int i; @@ -1577,13 +1577,13 @@ kiblnd_map_tx_pages(kib_tx_t *tx, kib_rdma_desc_t *rd) return npages; } -void kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status) +void kiblnd_fmr_pool_unmap(struct kib_fmr *fmr, int status) { LIST_HEAD(zombies); - kib_fmr_pool_t *fpo = fmr->fmr_pool; - kib_fmr_poolset_t *fps; + struct kib_fmr_pool *fpo = fmr->fmr_pool; + struct kib_fmr_poolset *fps; unsigned long now = cfs_time_current(); - kib_fmr_pool_t *tmp; + struct kib_fmr_pool *tmp; int rc; if (!fpo) @@ -1633,14 +1633,14 @@ void kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status) kiblnd_destroy_fmr_pool_list(&zombies); } -int kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, kib_tx_t *tx, - kib_rdma_desc_t *rd, __u32 nob, __u64 iov, - kib_fmr_t *fmr) +int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx, + struct kib_rdma_desc *rd, __u32 nob, __u64 iov, + struct kib_fmr *fmr) { __u64 *pages = tx->tx_pages; bool is_rx = (rd != tx->tx_rd); bool tx_pages_mapped = 0; - kib_fmr_pool_t *fpo; + struct kib_fmr_pool *fpo; int npages = 0; __u64 version; int rc; @@ -1780,7 +1780,7 @@ int kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, kib_tx_t *tx, goto again; } -static void kiblnd_fini_pool(kib_pool_t *pool) +static void kiblnd_fini_pool(struct kib_pool *pool) { LASSERT(list_empty(&pool->po_free_list)); LASSERT(!pool->po_allocated); @@ -1788,7 +1788,7 @@ static void kiblnd_fini_pool(kib_pool_t *pool) CDEBUG(D_NET, "Finalize %s pool\n", pool->po_owner->ps_name); } -static void kiblnd_init_pool(kib_poolset_t *ps, kib_pool_t *pool, int size) +static void kiblnd_init_pool(struct kib_poolset *ps, struct kib_pool *pool, int size) { CDEBUG(D_NET, "Initialize %s pool\n", ps->ps_name); @@ -1801,10 +1801,10 @@ static void kiblnd_init_pool(kib_poolset_t *ps, kib_pool_t *pool, int size) static void kiblnd_destroy_pool_list(struct list_head *head) { - kib_pool_t *pool; + struct kib_pool *pool; while (!list_empty(head)) { - pool = list_entry(head->next, kib_pool_t, po_list); + pool = list_entry(head->next, struct kib_pool, po_list); list_del(&pool->po_list); LASSERT(pool->po_owner); @@ -1812,15 +1812,15 @@ static void kiblnd_destroy_pool_list(struct list_head *head) } } -static void kiblnd_fail_poolset(kib_poolset_t *ps, struct list_head *zombies) +static void kiblnd_fail_poolset(struct kib_poolset *ps, struct list_head *zombies) { if (!ps->ps_net) /* intialized? */ return; spin_lock(&ps->ps_lock); while (!list_empty(&ps->ps_pool_list)) { - kib_pool_t *po = list_entry(ps->ps_pool_list.next, - kib_pool_t, po_list); + struct kib_pool *po = list_entry(ps->ps_pool_list.next, + struct kib_pool, po_list); po->po_failed = 1; list_del(&po->po_list); if (!po->po_allocated) @@ -1831,7 +1831,7 @@ static void kiblnd_fail_poolset(kib_poolset_t *ps, struct list_head *zombies) spin_unlock(&ps->ps_lock); } -static void kiblnd_fini_poolset(kib_poolset_t *ps) +static void kiblnd_fini_poolset(struct kib_poolset *ps) { if (ps->ps_net) { /* initialized? */ kiblnd_destroy_pool_list(&ps->ps_failed_pool_list); @@ -1839,14 +1839,14 @@ static void kiblnd_fini_poolset(kib_poolset_t *ps) } } -static int kiblnd_init_poolset(kib_poolset_t *ps, int cpt, - kib_net_t *net, char *name, int size, +static int kiblnd_init_poolset(struct kib_poolset *ps, int cpt, + struct kib_net *net, char *name, int size, kib_ps_pool_create_t po_create, kib_ps_pool_destroy_t po_destroy, kib_ps_node_init_t nd_init, kib_ps_node_fini_t nd_fini) { - kib_pool_t *pool; + struct kib_pool *pool; int rc; memset(ps, 0, sizeof(*ps)); @@ -1874,7 +1874,7 @@ static int kiblnd_init_poolset(kib_poolset_t *ps, int cpt, return rc; } -static int kiblnd_pool_is_idle(kib_pool_t *pool, unsigned long now) +static int kiblnd_pool_is_idle(struct kib_pool *pool, unsigned long now) { if (pool->po_allocated) /* still in use */ return 0; @@ -1883,11 +1883,11 @@ static int kiblnd_pool_is_idle(kib_pool_t *pool, unsigned long now) return cfs_time_aftereq(now, pool->po_deadline); } -void kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node) +void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node) { LIST_HEAD(zombies); - kib_poolset_t *ps = pool->po_owner; - kib_pool_t *tmp; + struct kib_poolset *ps = pool->po_owner; + struct kib_pool *tmp; unsigned long now = cfs_time_current(); spin_lock(&ps->ps_lock); @@ -1913,10 +1913,10 @@ void kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node) kiblnd_destroy_pool_list(&zombies); } -struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps) +struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps) { struct list_head *node; - kib_pool_t *pool; + struct kib_pool *pool; unsigned int interval = 1; unsigned long time_before; unsigned int trips = 0; @@ -1986,9 +1986,9 @@ struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps) goto again; } -static void kiblnd_destroy_tx_pool(kib_pool_t *pool) +static void kiblnd_destroy_tx_pool(struct kib_pool *pool) { - kib_tx_pool_t *tpo = container_of(pool, kib_tx_pool_t, tpo_pool); + struct kib_tx_pool *tpo = container_of(pool, struct kib_tx_pool, tpo_pool); int i; LASSERT(!pool->po_allocated); @@ -2002,7 +2002,7 @@ static void kiblnd_destroy_tx_pool(kib_pool_t *pool) goto out; for (i = 0; i < pool->po_size; i++) { - kib_tx_t *tx = &tpo->tpo_tx_descs[i]; + struct kib_tx *tx = &tpo->tpo_tx_descs[i]; list_del(&tx->tx_list); if (tx->tx_pages) @@ -2023,12 +2023,12 @@ static void kiblnd_destroy_tx_pool(kib_pool_t *pool) sizeof(*tx->tx_sge)); if (tx->tx_rd) LIBCFS_FREE(tx->tx_rd, - offsetof(kib_rdma_desc_t, + offsetof(struct kib_rdma_desc, rd_frags[IBLND_MAX_RDMA_FRAGS])); } LIBCFS_FREE(tpo->tpo_tx_descs, - pool->po_size * sizeof(kib_tx_t)); + pool->po_size * sizeof(struct kib_tx)); out: kiblnd_fini_pool(pool); LIBCFS_FREE(tpo, sizeof(*tpo)); @@ -2041,13 +2041,13 @@ static int kiblnd_tx_pool_size(int ncpts) return max(IBLND_TX_POOL, ntx); } -static int kiblnd_create_tx_pool(kib_poolset_t *ps, int size, - kib_pool_t **pp_po) +static int kiblnd_create_tx_pool(struct kib_poolset *ps, int size, + struct kib_pool **pp_po) { int i; int npg; - kib_pool_t *pool; - kib_tx_pool_t *tpo; + struct kib_pool *pool; + struct kib_tx_pool *tpo; LIBCFS_CPT_ALLOC(tpo, lnet_cpt_table(), ps->ps_cpt, sizeof(*tpo)); if (!tpo) { @@ -2068,17 +2068,17 @@ static int kiblnd_create_tx_pool(kib_poolset_t *ps, int size, } LIBCFS_CPT_ALLOC(tpo->tpo_tx_descs, lnet_cpt_table(), ps->ps_cpt, - size * sizeof(kib_tx_t)); + size * sizeof(struct kib_tx)); if (!tpo->tpo_tx_descs) { CERROR("Can't allocate %d tx descriptors\n", size); ps->ps_pool_destroy(pool); return -ENOMEM; } - memset(tpo->tpo_tx_descs, 0, size * sizeof(kib_tx_t)); + memset(tpo->tpo_tx_descs, 0, size * sizeof(struct kib_tx)); for (i = 0; i < size; i++) { - kib_tx_t *tx = &tpo->tpo_tx_descs[i]; + struct kib_tx *tx = &tpo->tpo_tx_descs[i]; tx->tx_pool = tpo; if (ps->ps_net->ibn_fmr_ps) { @@ -2110,7 +2110,7 @@ static int kiblnd_create_tx_pool(kib_poolset_t *ps, int size, break; LIBCFS_CPT_ALLOC(tx->tx_rd, lnet_cpt_table(), ps->ps_cpt, - offsetof(kib_rdma_desc_t, + offsetof(struct kib_rdma_desc, rd_frags[IBLND_MAX_RDMA_FRAGS])); if (!tx->tx_rd) break; @@ -2126,22 +2126,23 @@ static int kiblnd_create_tx_pool(kib_poolset_t *ps, int size, return -ENOMEM; } -static void kiblnd_tx_init(kib_pool_t *pool, struct list_head *node) +static void kiblnd_tx_init(struct kib_pool *pool, struct list_head *node) { - kib_tx_poolset_t *tps = container_of(pool->po_owner, kib_tx_poolset_t, - tps_poolset); - kib_tx_t *tx = list_entry(node, kib_tx_t, tx_list); + struct kib_tx_poolset *tps = container_of(pool->po_owner, + struct kib_tx_poolset, + tps_poolset); + struct kib_tx *tx = list_entry(node, struct kib_tx, tx_list); tx->tx_cookie = tps->tps_next_tx_cookie++; } -static void kiblnd_net_fini_pools(kib_net_t *net) +static void kiblnd_net_fini_pools(struct kib_net *net) { int i; cfs_cpt_for_each(i, lnet_cpt_table()) { - kib_tx_poolset_t *tps; - kib_fmr_poolset_t *fps; + struct kib_tx_poolset *tps; + struct kib_fmr_poolset *fps; if (net->ibn_tx_ps) { tps = net->ibn_tx_ps[i]; @@ -2165,7 +2166,7 @@ static void kiblnd_net_fini_pools(kib_net_t *net) } } -static int kiblnd_net_init_pools(kib_net_t *net, lnet_ni_t *ni, __u32 *cpts, +static int kiblnd_net_init_pools(struct kib_net *net, lnet_ni_t *ni, __u32 *cpts, int ncpts) { struct lnet_ioctl_config_o2iblnd_tunables *tunables; @@ -2207,7 +2208,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, lnet_ni_t *ni, __u32 *cpts, * number of CPTs that exist, i.e net->ibn_fmr_ps[cpt]. */ net->ibn_fmr_ps = cfs_percpt_alloc(lnet_cpt_table(), - sizeof(kib_fmr_poolset_t)); + sizeof(struct kib_fmr_poolset)); if (!net->ibn_fmr_ps) { CERROR("Failed to allocate FMR pool array\n"); rc = -ENOMEM; @@ -2235,7 +2236,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, lnet_ni_t *ni, __u32 *cpts, * number of CPTs that exist, i.e net->ibn_tx_ps[cpt]. */ net->ibn_tx_ps = cfs_percpt_alloc(lnet_cpt_table(), - sizeof(kib_tx_poolset_t)); + sizeof(struct kib_tx_poolset)); if (!net->ibn_tx_ps) { CERROR("Failed to allocate tx pool array\n"); rc = -ENOMEM; @@ -2264,7 +2265,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, lnet_ni_t *ni, __u32 *cpts, return rc; } -static int kiblnd_hdev_get_attr(kib_hca_dev_t *hdev) +static int kiblnd_hdev_get_attr(struct kib_hca_dev *hdev) { /* * It's safe to assume a HCA can handle a page size @@ -2284,7 +2285,7 @@ static int kiblnd_hdev_get_attr(kib_hca_dev_t *hdev) return -EINVAL; } -static void kiblnd_hdev_cleanup_mrs(kib_hca_dev_t *hdev) +static void kiblnd_hdev_cleanup_mrs(struct kib_hca_dev *hdev) { if (!hdev->ibh_mrs) return; @@ -2294,7 +2295,7 @@ static void kiblnd_hdev_cleanup_mrs(kib_hca_dev_t *hdev) hdev->ibh_mrs = NULL; } -void kiblnd_hdev_destroy(kib_hca_dev_t *hdev) +void kiblnd_hdev_destroy(struct kib_hca_dev *hdev) { kiblnd_hdev_cleanup_mrs(hdev); @@ -2307,7 +2308,7 @@ void kiblnd_hdev_destroy(kib_hca_dev_t *hdev) LIBCFS_FREE(hdev, sizeof(*hdev)); } -static int kiblnd_hdev_setup_mrs(kib_hca_dev_t *hdev) +static int kiblnd_hdev_setup_mrs(struct kib_hca_dev *hdev) { struct ib_mr *mr; int rc; @@ -2336,7 +2337,7 @@ static int kiblnd_dummy_callback(struct rdma_cm_id *cmid, return 0; } -static int kiblnd_dev_need_failover(kib_dev_t *dev) +static int kiblnd_dev_need_failover(struct kib_dev *dev) { struct rdma_cm_id *cmid; struct sockaddr_in srcaddr; @@ -2390,15 +2391,15 @@ static int kiblnd_dev_need_failover(kib_dev_t *dev) return rc; } -int kiblnd_dev_failover(kib_dev_t *dev) +int kiblnd_dev_failover(struct kib_dev *dev) { LIST_HEAD(zombie_tpo); LIST_HEAD(zombie_ppo); LIST_HEAD(zombie_fpo); struct rdma_cm_id *cmid = NULL; - kib_hca_dev_t *hdev = NULL; + struct kib_hca_dev *hdev = NULL; struct ib_pd *pd; - kib_net_t *net; + struct kib_net *net; struct sockaddr_in addr; unsigned long flags; int rc = 0; @@ -2523,7 +2524,7 @@ int kiblnd_dev_failover(kib_dev_t *dev) return rc; } -void kiblnd_destroy_dev(kib_dev_t *dev) +void kiblnd_destroy_dev(struct kib_dev *dev) { LASSERT(!dev->ibd_nnets); LASSERT(list_empty(&dev->ibd_nets)); @@ -2537,10 +2538,10 @@ void kiblnd_destroy_dev(kib_dev_t *dev) LIBCFS_FREE(dev, sizeof(*dev)); } -static kib_dev_t *kiblnd_create_dev(char *ifname) +static struct kib_dev *kiblnd_create_dev(char *ifname) { struct net_device *netdev; - kib_dev_t *dev; + struct kib_dev *dev; __u32 netmask; __u32 ip; int up; @@ -2655,7 +2656,7 @@ static void kiblnd_base_shutdown(void) static void kiblnd_shutdown(lnet_ni_t *ni) { - kib_net_t *net = ni->ni_data; + struct kib_net *net = ni->ni_data; rwlock_t *g_lock = &kiblnd_data.kib_global_lock; int i; unsigned long flags; @@ -2852,7 +2853,7 @@ static int kiblnd_start_schedulers(struct kib_sched_info *sched) return rc; } -static int kiblnd_dev_start_threads(kib_dev_t *dev, int newdev, __u32 *cpts, +static int kiblnd_dev_start_threads(struct kib_dev *dev, int newdev, __u32 *cpts, int ncpts) { int cpt; @@ -2878,10 +2879,10 @@ static int kiblnd_dev_start_threads(kib_dev_t *dev, int newdev, __u32 *cpts, return 0; } -static kib_dev_t *kiblnd_dev_search(char *ifname) +static struct kib_dev *kiblnd_dev_search(char *ifname) { - kib_dev_t *alias = NULL; - kib_dev_t *dev; + struct kib_dev *alias = NULL; + struct kib_dev *dev; char *colon; char *colon2; @@ -2913,8 +2914,8 @@ static kib_dev_t *kiblnd_dev_search(char *ifname) static int kiblnd_startup(lnet_ni_t *ni) { char *ifname; - kib_dev_t *ibdev = NULL; - kib_net_t *net; + struct kib_dev *ibdev = NULL; + struct kib_net *net; struct timespec64 tv; unsigned long flags; int rc; @@ -3021,11 +3022,11 @@ static void __exit ko2iblnd_exit(void) static int __init ko2iblnd_init(void) { - CLASSERT(sizeof(kib_msg_t) <= IBLND_MSG_SIZE); - CLASSERT(offsetof(kib_msg_t, + CLASSERT(sizeof(struct kib_msg) <= IBLND_MSG_SIZE); + CLASSERT(offsetof(struct kib_msg, ibm_u.get.ibgm_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) <= IBLND_MSG_SIZE); - CLASSERT(offsetof(kib_msg_t, + CLASSERT(offsetof(struct kib_msg, ibm_u.putack.ibpam_rd.rd_frags[IBLND_MAX_RDMA_FRAGS]) <= IBLND_MSG_SIZE); diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index 45bbe93..4bac2b7 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -78,12 +78,12 @@ #define IBLND_N_SCHED 2 #define IBLND_N_SCHED_HIGH 4 -typedef struct { +struct kib_tunables { int *kib_dev_failover; /* HCA failover */ unsigned int *kib_service; /* IB service number */ int *kib_min_reconnect_interval; /* first failed connection retry... */ int *kib_max_reconnect_interval; /* exponentially increasing to this */ - int *kib_cksum; /* checksum kib_msg_t? */ + int *kib_cksum; /* checksum struct kib_msg? */ int *kib_timeout; /* comms timeout (seconds) */ int *kib_keepalive; /* keepalive timeout (seconds) */ int *kib_ntx; /* # tx descs */ @@ -94,15 +94,15 @@ typedef struct { int *kib_require_priv_port; /* accept only privileged ports */ int *kib_use_priv_port; /* use privileged port for active connect */ int *kib_nscheds; /* # threads on each CPT */ -} kib_tunables_t; +}; -extern kib_tunables_t kiblnd_tunables; +extern struct kib_tunables kiblnd_tunables; #define IBLND_MSG_QUEUE_SIZE_V1 8 /* V1 only : # messages/RDMAs in-flight */ #define IBLND_CREDIT_HIGHWATER_V1 7 /* V1 only : when eagerly to return credits */ #define IBLND_CREDITS_DEFAULT 8 /* default # of peer credits */ -#define IBLND_CREDITS_MAX ((typeof(((kib_msg_t *) 0)->ibm_credits)) - 1) /* Max # of peer credits */ +#define IBLND_CREDITS_MAX ((typeof(((struct kib_msg *) 0)->ibm_credits)) - 1) /* Max # of peer credits */ /* when eagerly to return credits */ #define IBLND_CREDITS_HIGHWATER(t, v) ((v) == IBLND_MSG_VERSION_1 ? \ @@ -150,7 +150,7 @@ struct kib_hca_dev; #define KIB_IFNAME_SIZE 256 #endif -typedef struct { +struct kib_dev { struct list_head ibd_list; /* chain on kib_devs */ struct list_head ibd_fail_list; /* chain on kib_failed_devs */ __u32 ibd_ifip; /* IPoIB interface IP */ @@ -165,9 +165,9 @@ typedef struct { unsigned int ibd_can_failover; /* IPoIB interface is a bonding master */ struct list_head ibd_nets; struct kib_hca_dev *ibd_hdev; -} kib_dev_t; +}; -typedef struct kib_hca_dev { +struct kib_hca_dev { struct rdma_cm_id *ibh_cmid; /* listener cmid */ struct ib_device *ibh_ibdev; /* IB device */ int ibh_page_shift; /* page shift of current HCA */ @@ -177,19 +177,19 @@ typedef struct kib_hca_dev { __u64 ibh_mr_size; /* size of MR */ struct ib_mr *ibh_mrs; /* global MR */ struct ib_pd *ibh_pd; /* PD */ - kib_dev_t *ibh_dev; /* owner */ + struct kib_dev *ibh_dev; /* owner */ atomic_t ibh_ref; /* refcount */ -} kib_hca_dev_t; +}; /** # of seconds to keep pool alive */ #define IBLND_POOL_DEADLINE 300 /** # of seconds to retry if allocation failed */ #define IBLND_POOL_RETRY 1 -typedef struct { +struct kib_pages { int ibp_npages; /* # pages */ struct page *ibp_pages[0]; /* page array */ -} kib_pages_t; +}; struct kib_pool; struct kib_poolset; @@ -204,7 +204,7 @@ struct kib_net; #define IBLND_POOL_NAME_LEN 32 -typedef struct kib_poolset { +struct kib_poolset { spinlock_t ps_lock; /* serialize */ struct kib_net *ps_net; /* network it belongs to */ char ps_name[IBLND_POOL_NAME_LEN]; /* pool set name */ @@ -220,31 +220,31 @@ typedef struct kib_poolset { kib_ps_pool_destroy_t ps_pool_destroy; /* destroy a pool */ kib_ps_node_init_t ps_node_init; /* initialize new allocated node */ kib_ps_node_fini_t ps_node_fini; /* finalize node */ -} kib_poolset_t; +}; -typedef struct kib_pool { +struct kib_pool { struct list_head po_list; /* chain on pool list */ struct list_head po_free_list; /* pre-allocated node */ - kib_poolset_t *po_owner; /* pool_set of this pool */ + struct kib_poolset *po_owner; /* pool_set of this pool */ unsigned long po_deadline; /* deadline of this pool */ int po_allocated; /* # of elements in use */ int po_failed; /* pool is created on failed HCA */ int po_size; /* # of pre-allocated elements */ -} kib_pool_t; +}; -typedef struct { - kib_poolset_t tps_poolset; /* pool-set */ +struct kib_tx_poolset { + struct kib_poolset tps_poolset; /* pool-set */ __u64 tps_next_tx_cookie; /* cookie of TX */ -} kib_tx_poolset_t; +}; -typedef struct { - kib_pool_t tpo_pool; /* pool */ - struct kib_hca_dev *tpo_hdev; /* device for this pool */ - struct kib_tx *tpo_tx_descs; /* all the tx descriptors */ - kib_pages_t *tpo_tx_pages; /* premapped tx msg pages */ -} kib_tx_pool_t; +struct kib_tx_pool { + struct kib_pool tpo_pool; /* pool */ + struct kib_hca_dev *tpo_hdev; /* device for this pool */ + struct kib_tx *tpo_tx_descs; /* all the tx descriptors */ + struct kib_pages *tpo_tx_pages; /* premapped tx msg pages */ +}; -typedef struct { +struct kib_fmr_poolset { spinlock_t fps_lock; /* serialize */ struct kib_net *fps_net; /* IB network */ struct list_head fps_pool_list; /* FMR pool list */ @@ -257,7 +257,7 @@ typedef struct { int fps_increasing; /* is allocating new pool */ unsigned long fps_next_retry; /* time stamp for retry if*/ /* failed to allocate */ -} kib_fmr_poolset_t; +}; struct kib_fast_reg_descriptor { /* For fast registration */ struct list_head frd_list; @@ -267,10 +267,10 @@ struct kib_fast_reg_descriptor { /* For fast registration */ bool frd_valid; }; -typedef struct { - struct list_head fpo_list; /* chain on pool list */ - struct kib_hca_dev *fpo_hdev; /* device for this pool */ - kib_fmr_poolset_t *fpo_owner; /* owner of this pool */ +struct kib_fmr_pool { + struct list_head fpo_list; /* chain on pool list */ + struct kib_hca_dev *fpo_hdev; /* device for this pool */ + struct kib_fmr_poolset *fpo_owner; /* owner of this pool */ union { struct { struct ib_fmr_pool *fpo_fmr_pool; /* IB FMR pool */ @@ -284,17 +284,17 @@ typedef struct { int fpo_failed; /* fmr pool is failed */ int fpo_map_count; /* # of mapped FMR */ int fpo_is_fmr; -} kib_fmr_pool_t; +}; -typedef struct { - kib_fmr_pool_t *fmr_pool; /* pool of FMR */ +struct kib_fmr { + struct kib_fmr_pool *fmr_pool; /* pool of FMR */ struct ib_pool_fmr *fmr_pfmr; /* IB pool fmr */ struct kib_fast_reg_descriptor *fmr_frd; u32 fmr_key; -} kib_fmr_t; +}; -typedef struct kib_net { - struct list_head ibn_list; /* chain on kib_dev_t::ibd_nets */ +struct kib_net { + struct list_head ibn_list; /* chain on struct kib_dev::ibd_nets */ __u64 ibn_incarnation;/* my epoch */ int ibn_init; /* initialisation state */ int ibn_shutdown; /* shutting down? */ @@ -302,11 +302,11 @@ typedef struct kib_net { atomic_t ibn_npeers; /* # peers extant */ atomic_t ibn_nconns; /* # connections extant */ - kib_tx_poolset_t **ibn_tx_ps; /* tx pool-set */ - kib_fmr_poolset_t **ibn_fmr_ps; /* fmr pool-set */ + struct kib_tx_poolset **ibn_tx_ps; /* tx pool-set */ + struct kib_fmr_poolset **ibn_fmr_ps; /* fmr pool-set */ - kib_dev_t *ibn_dev; /* underlying IB device */ -} kib_net_t; + struct kib_dev *ibn_dev; /* underlying IB device */ +}; #define KIB_THREAD_SHIFT 16 #define KIB_THREAD_ID(cpt, tid) ((cpt) << KIB_THREAD_SHIFT | (tid)) @@ -322,7 +322,7 @@ struct kib_sched_info { int ibs_cpt; /* CPT id */ }; -typedef struct { +struct kib_data { int kib_init; /* initialisation state */ int kib_shutdown; /* shut down? */ struct list_head kib_devs; /* IB devices extant */ @@ -349,7 +349,7 @@ typedef struct { spinlock_t kib_connd_lock; /* serialise */ struct ib_qp_attr kib_error_qpa; /* QP->ERROR */ struct kib_sched_info **kib_scheds; /* percpt data for schedulers */ -} kib_data_t; +}; #define IBLND_INIT_NOTHING 0 #define IBLND_INIT_DATA 1 @@ -360,51 +360,51 @@ typedef struct { * These are sent in sender's byte order (i.e. receiver flips). */ -typedef struct kib_connparams { +struct kib_connparams { __u16 ibcp_queue_depth; __u16 ibcp_max_frags; __u32 ibcp_max_msg_size; -} WIRE_ATTR kib_connparams_t; +} WIRE_ATTR; -typedef struct { +struct kib_immediate_msg { lnet_hdr_t ibim_hdr; /* portals header */ char ibim_payload[0]; /* piggy-backed payload */ -} WIRE_ATTR kib_immediate_msg_t; +} WIRE_ATTR; -typedef struct { +struct kib_rdma_frag { __u32 rf_nob; /* # bytes this frag */ __u64 rf_addr; /* CAVEAT EMPTOR: misaligned!! */ -} WIRE_ATTR kib_rdma_frag_t; +} WIRE_ATTR; -typedef struct { +struct kib_rdma_desc { __u32 rd_key; /* local/remote key */ __u32 rd_nfrags; /* # fragments */ - kib_rdma_frag_t rd_frags[0]; /* buffer frags */ -} WIRE_ATTR kib_rdma_desc_t; + struct kib_rdma_frag rd_frags[0]; /* buffer frags */ +} WIRE_ATTR; -typedef struct { +struct kib_putreq_msg { lnet_hdr_t ibprm_hdr; /* portals header */ __u64 ibprm_cookie; /* opaque completion cookie */ -} WIRE_ATTR kib_putreq_msg_t; +} WIRE_ATTR; -typedef struct { +struct kib_putack_msg { __u64 ibpam_src_cookie; /* reflected completion cookie */ __u64 ibpam_dst_cookie; /* opaque completion cookie */ - kib_rdma_desc_t ibpam_rd; /* sender's sink buffer */ -} WIRE_ATTR kib_putack_msg_t; + struct kib_rdma_desc ibpam_rd; /* sender's sink buffer */ +} WIRE_ATTR; -typedef struct { +struct kib_get_msg { lnet_hdr_t ibgm_hdr; /* portals header */ __u64 ibgm_cookie; /* opaque completion cookie */ - kib_rdma_desc_t ibgm_rd; /* rdma descriptor */ -} WIRE_ATTR kib_get_msg_t; + struct kib_rdma_desc ibgm_rd; /* rdma descriptor */ +} WIRE_ATTR; -typedef struct { +struct kib_completion_msg { __u64 ibcm_cookie; /* opaque completion cookie */ __s32 ibcm_status; /* < 0 failure: >= 0 length */ -} WIRE_ATTR kib_completion_msg_t; +} WIRE_ATTR; -typedef struct { +struct kib_msg { /* First 2 fields fixed FOR ALL TIME */ __u32 ibm_magic; /* I'm an ibnal message */ __u16 ibm_version; /* this is my version number */ @@ -419,14 +419,14 @@ typedef struct { __u64 ibm_dststamp; /* destination's incarnation */ union { - kib_connparams_t connparams; - kib_immediate_msg_t immediate; - kib_putreq_msg_t putreq; - kib_putack_msg_t putack; - kib_get_msg_t get; - kib_completion_msg_t completion; + struct kib_connparams connparams; + struct kib_immediate_msg immediate; + struct kib_putreq_msg putreq; + struct kib_putack_msg putack; + struct kib_get_msg get; + struct kib_completion_msg completion; } WIRE_ATTR ibm_u; -} WIRE_ATTR kib_msg_t; +} WIRE_ATTR; #define IBLND_MSG_MAGIC LNET_PROTO_IB_MAGIC /* unique magic */ @@ -445,14 +445,14 @@ typedef struct { #define IBLND_MSG_GET_REQ 0xd6 /* getreq (sink->src) */ #define IBLND_MSG_GET_DONE 0xd7 /* completion (src->sink: all OK) */ -typedef struct { +struct kib_rej { __u32 ibr_magic; /* sender's magic */ __u16 ibr_version; /* sender's version */ __u8 ibr_why; /* reject reason */ __u8 ibr_padding; /* padding */ __u64 ibr_incarnation; /* incarnation of peer */ - kib_connparams_t ibr_cp; /* connection parameters */ -} WIRE_ATTR kib_rej_t; + struct kib_connparams ibr_cp; /* connection parameters */ +} WIRE_ATTR; /* connection rejection reasons */ #define IBLND_REJECT_CONN_RACE 1 /* You lost connection race */ @@ -467,28 +467,26 @@ typedef struct { /***********************************************************************/ -typedef struct kib_rx /* receive message */ -{ +struct kib_rx { /* receive message */ struct list_head rx_list; /* queue for attention */ struct kib_conn *rx_conn; /* owning conn */ int rx_nob; /* # bytes received (-1 while posted) */ enum ib_wc_status rx_status; /* completion status */ - kib_msg_t *rx_msg; /* message buffer (host vaddr) */ + struct kib_msg *rx_msg; /* message buffer (host vaddr) */ __u64 rx_msgaddr; /* message buffer (I/O addr) */ DECLARE_PCI_UNMAP_ADDR(rx_msgunmap); /* for dma_unmap_single() */ struct ib_recv_wr rx_wrq; /* receive work item... */ struct ib_sge rx_sge; /* ...and its memory */ -} kib_rx_t; +}; #define IBLND_POSTRX_DONT_POST 0 /* don't post */ #define IBLND_POSTRX_NO_CREDIT 1 /* post: no credits */ #define IBLND_POSTRX_PEER_CREDIT 2 /* post: give peer back 1 credit */ #define IBLND_POSTRX_RSRVD_CREDIT 3 /* post: give self back 1 reserved credit */ -typedef struct kib_tx /* transmit message */ -{ +struct kib_tx { /* transmit message */ struct list_head tx_list; /* queue on idle_txs ibc_tx_queue etc. */ - kib_tx_pool_t *tx_pool; /* pool I'm from */ + struct kib_tx_pool *tx_pool; /* pool I'm from */ struct kib_conn *tx_conn; /* owning conn */ short tx_sending; /* # tx callbacks outstanding */ short tx_queued; /* queued for sending */ @@ -497,28 +495,28 @@ typedef struct kib_tx /* transmit message */ unsigned long tx_deadline; /* completion deadline */ __u64 tx_cookie; /* completion cookie */ lnet_msg_t *tx_lntmsg[2]; /* lnet msgs to finalize on completion */ - kib_msg_t *tx_msg; /* message buffer (host vaddr) */ + struct kib_msg *tx_msg; /* message buffer (host vaddr) */ __u64 tx_msgaddr; /* message buffer (I/O addr) */ DECLARE_PCI_UNMAP_ADDR(tx_msgunmap); /* for dma_unmap_single() */ int tx_nwrq; /* # send work items */ struct ib_rdma_wr *tx_wrq; /* send work items... */ struct ib_sge *tx_sge; /* ...and their memory */ - kib_rdma_desc_t *tx_rd; /* rdma descriptor */ + struct kib_rdma_desc *tx_rd; /* rdma descriptor */ int tx_nfrags; /* # entries in... */ struct scatterlist *tx_frags; /* dma_map_sg descriptor */ __u64 *tx_pages; /* rdma phys page addrs */ - kib_fmr_t fmr; /* FMR */ + struct kib_fmr fmr; /* FMR */ int tx_dmadir; /* dma direction */ -} kib_tx_t; +}; -typedef struct kib_connvars { - kib_msg_t cv_msg; /* connection-in-progress variables */ -} kib_connvars_t; +struct kib_connvars { + struct kib_msg cv_msg; /* connection-in-progress variables */ +}; -typedef struct kib_conn { +struct kib_conn { struct kib_sched_info *ibc_sched; /* scheduler information */ struct kib_peer *ibc_peer; /* owning peer */ - kib_hca_dev_t *ibc_hdev; /* HCA bound on */ + struct kib_hca_dev *ibc_hdev; /* HCA bound on */ struct list_head ibc_list; /* stash on peer's conn list */ struct list_head ibc_sched_list; /* schedule for attention */ __u16 ibc_version; /* version of connection */ @@ -553,14 +551,14 @@ typedef struct kib_conn { /* reserve an ACK/DONE msg */ struct list_head ibc_active_txs; /* active tx awaiting completion */ spinlock_t ibc_lock; /* serialise */ - kib_rx_t *ibc_rxs; /* the rx descs */ - kib_pages_t *ibc_rx_pages; /* premapped rx msg pages */ + struct kib_rx *ibc_rxs; /* the rx descs */ + struct kib_pages *ibc_rx_pages; /* premapped rx msg pages */ struct rdma_cm_id *ibc_cmid; /* CM id */ struct ib_cq *ibc_cq; /* completion queue */ - kib_connvars_t *ibc_connvars; /* in-progress connection state */ -} kib_conn_t; + struct kib_connvars *ibc_connvars; /* in-progress connection state */ +}; #define IBLND_CONN_INIT 0 /* being initialised */ #define IBLND_CONN_ACTIVE_CONNECT 1 /* active sending req */ @@ -569,7 +567,7 @@ typedef struct kib_conn { #define IBLND_CONN_CLOSING 4 /* being closed */ #define IBLND_CONN_DISCONNECTED 5 /* disconnected */ -typedef struct kib_peer { +struct kib_peer { struct list_head ibp_list; /* stash on global peer list */ lnet_nid_t ibp_nid; /* who's on the other end(s) */ lnet_ni_t *ibp_ni; /* LNet interface */ @@ -596,11 +594,11 @@ typedef struct kib_peer { __u16 ibp_max_frags; /* max_peer_credits */ __u16 ibp_queue_depth; -} kib_peer_t; +}; -extern kib_data_t kiblnd_data; +extern struct kib_data kiblnd_data; -void kiblnd_hdev_destroy(kib_hca_dev_t *hdev); +void kiblnd_hdev_destroy(struct kib_hca_dev *hdev); int kiblnd_msg_queue_size(int version, struct lnet_ni *ni); @@ -645,14 +643,14 @@ kiblnd_concurrent_sends(int version, struct lnet_ni *ni) } static inline void -kiblnd_hdev_addref_locked(kib_hca_dev_t *hdev) +kiblnd_hdev_addref_locked(struct kib_hca_dev *hdev) { LASSERT(atomic_read(&hdev->ibh_ref) > 0); atomic_inc(&hdev->ibh_ref); } static inline void -kiblnd_hdev_decref(kib_hca_dev_t *hdev) +kiblnd_hdev_decref(struct kib_hca_dev *hdev) { LASSERT(atomic_read(&hdev->ibh_ref) > 0); if (atomic_dec_and_test(&hdev->ibh_ref)) @@ -660,7 +658,7 @@ kiblnd_hdev_decref(kib_hca_dev_t *hdev) } static inline int -kiblnd_dev_can_failover(kib_dev_t *dev) +kiblnd_dev_can_failover(struct kib_dev *dev) { if (!list_empty(&dev->ibd_fail_list)) /* already scheduled */ return 0; @@ -716,7 +714,7 @@ do { \ } while (0) static inline bool -kiblnd_peer_connecting(kib_peer_t *peer) +kiblnd_peer_connecting(struct kib_peer *peer) { return peer->ibp_connecting || peer->ibp_reconnecting || @@ -724,7 +722,7 @@ kiblnd_peer_connecting(kib_peer_t *peer) } static inline bool -kiblnd_peer_idle(kib_peer_t *peer) +kiblnd_peer_idle(struct kib_peer *peer) { return !kiblnd_peer_connecting(peer) && list_empty(&peer->ibp_conns); } @@ -739,23 +737,23 @@ kiblnd_nid2peerlist(lnet_nid_t nid) } static inline int -kiblnd_peer_active(kib_peer_t *peer) +kiblnd_peer_active(struct kib_peer *peer) { /* Am I in the peer hash table? */ return !list_empty(&peer->ibp_list); } -static inline kib_conn_t * -kiblnd_get_conn_locked(kib_peer_t *peer) +static inline struct kib_conn * +kiblnd_get_conn_locked(struct kib_peer *peer) { LASSERT(!list_empty(&peer->ibp_conns)); /* just return the first connection */ - return list_entry(peer->ibp_conns.next, kib_conn_t, ibc_list); + return list_entry(peer->ibp_conns.next, struct kib_conn, ibc_list); } static inline int -kiblnd_send_keepalive(kib_conn_t *conn) +kiblnd_send_keepalive(struct kib_conn *conn) { return (*kiblnd_tunables.kib_keepalive > 0) && cfs_time_after(jiffies, conn->ibc_last_send + @@ -764,7 +762,7 @@ kiblnd_send_keepalive(kib_conn_t *conn) } static inline int -kiblnd_need_noop(kib_conn_t *conn) +kiblnd_need_noop(struct kib_conn *conn) { struct lnet_ioctl_config_o2iblnd_tunables *tunables; lnet_ni_t *ni = conn->ibc_peer->ibp_ni; @@ -800,14 +798,14 @@ kiblnd_need_noop(kib_conn_t *conn) } static inline void -kiblnd_abort_receives(kib_conn_t *conn) +kiblnd_abort_receives(struct kib_conn *conn) { ib_modify_qp(conn->ibc_cmid->qp, &kiblnd_data.kib_error_qpa, IB_QP_STATE); } static inline const char * -kiblnd_queue2str(kib_conn_t *conn, struct list_head *q) +kiblnd_queue2str(struct kib_conn *conn, struct list_head *q) { if (q == &conn->ibc_tx_queue) return "tx_queue"; @@ -858,21 +856,21 @@ kiblnd_wreqid2type(__u64 wreqid) } static inline void -kiblnd_set_conn_state(kib_conn_t *conn, int state) +kiblnd_set_conn_state(struct kib_conn *conn, int state) { conn->ibc_state = state; mb(); } static inline void -kiblnd_init_msg(kib_msg_t *msg, int type, int body_nob) +kiblnd_init_msg(struct kib_msg *msg, int type, int body_nob) { msg->ibm_type = type; - msg->ibm_nob = offsetof(kib_msg_t, ibm_u) + body_nob; + msg->ibm_nob = offsetof(struct kib_msg, ibm_u) + body_nob; } static inline int -kiblnd_rd_size(kib_rdma_desc_t *rd) +kiblnd_rd_size(struct kib_rdma_desc *rd) { int i; int size; @@ -884,25 +882,25 @@ kiblnd_rd_size(kib_rdma_desc_t *rd) } static inline __u64 -kiblnd_rd_frag_addr(kib_rdma_desc_t *rd, int index) +kiblnd_rd_frag_addr(struct kib_rdma_desc *rd, int index) { return rd->rd_frags[index].rf_addr; } static inline __u32 -kiblnd_rd_frag_size(kib_rdma_desc_t *rd, int index) +kiblnd_rd_frag_size(struct kib_rdma_desc *rd, int index) { return rd->rd_frags[index].rf_nob; } static inline __u32 -kiblnd_rd_frag_key(kib_rdma_desc_t *rd, int index) +kiblnd_rd_frag_key(struct kib_rdma_desc *rd, int index) { return rd->rd_key; } static inline int -kiblnd_rd_consume_frag(kib_rdma_desc_t *rd, int index, __u32 nob) +kiblnd_rd_consume_frag(struct kib_rdma_desc *rd, int index, __u32 nob) { if (nob < rd->rd_frags[index].rf_nob) { rd->rd_frags[index].rf_addr += nob; @@ -915,14 +913,14 @@ kiblnd_rd_consume_frag(kib_rdma_desc_t *rd, int index, __u32 nob) } static inline int -kiblnd_rd_msg_size(kib_rdma_desc_t *rd, int msgtype, int n) +kiblnd_rd_msg_size(struct kib_rdma_desc *rd, int msgtype, int n) { LASSERT(msgtype == IBLND_MSG_GET_REQ || msgtype == IBLND_MSG_PUT_ACK); return msgtype == IBLND_MSG_GET_REQ ? - offsetof(kib_get_msg_t, ibgm_rd.rd_frags[n]) : - offsetof(kib_putack_msg_t, ibpam_rd.rd_frags[n]); + offsetof(struct kib_get_msg, ibgm_rd.rd_frags[n]) : + offsetof(struct kib_putack_msg, ibpam_rd.rd_frags[n]); } static inline __u64 @@ -981,17 +979,17 @@ static inline unsigned int kiblnd_sg_dma_len(struct ib_device *dev, #define KIBLND_CONN_PARAM(e) ((e)->param.conn.private_data) #define KIBLND_CONN_PARAM_LEN(e) ((e)->param.conn.private_data_len) -struct ib_mr *kiblnd_find_rd_dma_mr(struct lnet_ni *ni, kib_rdma_desc_t *rd, +struct ib_mr *kiblnd_find_rd_dma_mr(struct lnet_ni *ni, struct kib_rdma_desc *rd, int negotiated_nfrags); -void kiblnd_map_rx_descs(kib_conn_t *conn); -void kiblnd_unmap_rx_descs(kib_conn_t *conn); -void kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node); -struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps); +void kiblnd_map_rx_descs(struct kib_conn *conn); +void kiblnd_unmap_rx_descs(struct kib_conn *conn); +void kiblnd_pool_free_node(struct kib_pool *pool, struct list_head *node); +struct list_head *kiblnd_pool_alloc_node(struct kib_poolset *ps); -int kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, kib_tx_t *tx, - kib_rdma_desc_t *rd, __u32 nob, __u64 iov, - kib_fmr_t *fmr); -void kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status); +int kiblnd_fmr_pool_map(struct kib_fmr_poolset *fps, struct kib_tx *tx, + struct kib_rdma_desc *rd, __u32 nob, __u64 iov, + struct kib_fmr *fmr); +void kiblnd_fmr_pool_unmap(struct kib_fmr *fmr, int status); int kiblnd_tunables_setup(struct lnet_ni *ni); void kiblnd_tunables_init(void); @@ -1001,30 +999,31 @@ int kiblnd_scheduler(void *arg); int kiblnd_thread_start(int (*fn)(void *arg), void *arg, char *name); int kiblnd_failover_thread(void *arg); -int kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages); +int kiblnd_alloc_pages(struct kib_pages **pp, int cpt, int npages); int kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event); int kiblnd_translate_mtu(int value); -int kiblnd_dev_failover(kib_dev_t *dev); -int kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid); -void kiblnd_destroy_peer(kib_peer_t *peer); -bool kiblnd_reconnect_peer(kib_peer_t *peer); -void kiblnd_destroy_dev(kib_dev_t *dev); -void kiblnd_unlink_peer_locked(kib_peer_t *peer); -kib_peer_t *kiblnd_find_peer_locked(lnet_nid_t nid); -int kiblnd_close_stale_conns_locked(kib_peer_t *peer, +int kiblnd_dev_failover(struct kib_dev *dev); +int kiblnd_create_peer(lnet_ni_t *ni, struct kib_peer **peerp, lnet_nid_t nid); +void kiblnd_destroy_peer(struct kib_peer *peer); +bool kiblnd_reconnect_peer(struct kib_peer *peer); +void kiblnd_destroy_dev(struct kib_dev *dev); +void kiblnd_unlink_peer_locked(struct kib_peer *peer); +struct kib_peer *kiblnd_find_peer_locked(lnet_nid_t nid); +int kiblnd_close_stale_conns_locked(struct kib_peer *peer, int version, __u64 incarnation); -int kiblnd_close_peer_conns_locked(kib_peer_t *peer, int why); +int kiblnd_close_peer_conns_locked(struct kib_peer *peer, int why); -kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid, - int state, int version); -void kiblnd_destroy_conn(kib_conn_t *conn, bool free_conn); -void kiblnd_close_conn(kib_conn_t *conn, int error); -void kiblnd_close_conn_locked(kib_conn_t *conn, int error); +struct kib_conn *kiblnd_create_conn(struct kib_peer *peer, + struct rdma_cm_id *cmid, + int state, int version); +void kiblnd_destroy_conn(struct kib_conn *conn, bool free_conn); +void kiblnd_close_conn(struct kib_conn *conn, int error); +void kiblnd_close_conn_locked(struct kib_conn *conn, int error); -void kiblnd_launch_tx(lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid); +void kiblnd_launch_tx(lnet_ni_t *ni, struct kib_tx *tx, lnet_nid_t nid); void kiblnd_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int status); @@ -1032,10 +1031,10 @@ void kiblnd_qp_event(struct ib_event *event, void *arg); void kiblnd_cq_event(struct ib_event *event, void *arg); void kiblnd_cq_completion(struct ib_cq *cq, void *arg); -void kiblnd_pack_msg(lnet_ni_t *ni, kib_msg_t *msg, int version, +void kiblnd_pack_msg(lnet_ni_t *ni, struct kib_msg *msg, int version, int credits, lnet_nid_t dstnid, __u64 dststamp); -int kiblnd_unpack_msg(kib_msg_t *msg, int nob); -int kiblnd_post_rx(kib_rx_t *rx, int credit); +int kiblnd_unpack_msg(struct kib_msg *msg, int nob); +int kiblnd_post_rx(struct kib_rx *rx, int credit); int kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg); int kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed, diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index 0f7e3a1..b3cf62f 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -40,22 +40,22 @@ #include "o2iblnd.h" -static void kiblnd_peer_alive(kib_peer_t *peer); -static void kiblnd_peer_connect_failed(kib_peer_t *peer, int active, int error); -static void kiblnd_check_sends(kib_conn_t *conn); -static void kiblnd_init_tx_msg(lnet_ni_t *ni, kib_tx_t *tx, +static void kiblnd_peer_alive(struct kib_peer *peer); +static void kiblnd_peer_connect_failed(struct kib_peer *peer, int active, int error); +static void kiblnd_check_sends(struct kib_conn *conn); +static void kiblnd_init_tx_msg(lnet_ni_t *ni, struct kib_tx *tx, int type, int body_nob); -static int kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type, - int resid, kib_rdma_desc_t *dstrd, __u64 dstcookie); -static void kiblnd_queue_tx_locked(kib_tx_t *tx, kib_conn_t *conn); -static void kiblnd_queue_tx(kib_tx_t *tx, kib_conn_t *conn); -static void kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx); +static int kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, + int resid, struct kib_rdma_desc *dstrd, __u64 dstcookie); +static void kiblnd_queue_tx_locked(struct kib_tx *tx, struct kib_conn *conn); +static void kiblnd_queue_tx(struct kib_tx *tx, struct kib_conn *conn); +static void kiblnd_unmap_tx(lnet_ni_t *ni, struct kib_tx *tx); static void -kiblnd_tx_done(lnet_ni_t *ni, kib_tx_t *tx) +kiblnd_tx_done(lnet_ni_t *ni, struct kib_tx *tx) { lnet_msg_t *lntmsg[2]; - kib_net_t *net = ni->ni_data; + struct kib_net *net = ni->ni_data; int rc; int i; @@ -97,10 +97,10 @@ kiblnd_tx_done(lnet_ni_t *ni, kib_tx_t *tx) void kiblnd_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int status) { - kib_tx_t *tx; + struct kib_tx *tx; while (!list_empty(txlist)) { - tx = list_entry(txlist->next, kib_tx_t, tx_list); + tx = list_entry(txlist->next, struct kib_tx, tx_list); list_del(&tx->tx_list); /* complete now */ @@ -110,19 +110,19 @@ kiblnd_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int status) } } -static kib_tx_t * +static struct kib_tx * kiblnd_get_idle_tx(lnet_ni_t *ni, lnet_nid_t target) { - kib_net_t *net = (kib_net_t *)ni->ni_data; + struct kib_net *net = (struct kib_net *)ni->ni_data; struct list_head *node; - kib_tx_t *tx; - kib_tx_poolset_t *tps; + struct kib_tx *tx; + struct kib_tx_poolset *tps; tps = net->ibn_tx_ps[lnet_cpt_of_nid(target)]; node = kiblnd_pool_alloc_node(&tps->tps_poolset); if (!node) return NULL; - tx = list_entry(node, kib_tx_t, tx_list); + tx = list_entry(node, struct kib_tx, tx_list); LASSERT(!tx->tx_nwrq); LASSERT(!tx->tx_queued); @@ -138,9 +138,9 @@ kiblnd_get_idle_tx(lnet_ni_t *ni, lnet_nid_t target) } static void -kiblnd_drop_rx(kib_rx_t *rx) +kiblnd_drop_rx(struct kib_rx *rx) { - kib_conn_t *conn = rx->rx_conn; + struct kib_conn *conn = rx->rx_conn; struct kib_sched_info *sched = conn->ibc_sched; unsigned long flags; @@ -153,10 +153,10 @@ kiblnd_drop_rx(kib_rx_t *rx) } int -kiblnd_post_rx(kib_rx_t *rx, int credit) +kiblnd_post_rx(struct kib_rx *rx, int credit) { - kib_conn_t *conn = rx->rx_conn; - kib_net_t *net = conn->ibc_peer->ibp_ni->ni_data; + struct kib_conn *conn = rx->rx_conn; + struct kib_net *net = conn->ibc_peer->ibp_ni->ni_data; struct ib_recv_wr *bad_wrq = NULL; struct ib_mr *mr = conn->ibc_hdev->ibh_mrs; int rc; @@ -223,13 +223,13 @@ out: return rc; } -static kib_tx_t * -kiblnd_find_waiting_tx_locked(kib_conn_t *conn, int txtype, __u64 cookie) +static struct kib_tx * +kiblnd_find_waiting_tx_locked(struct kib_conn *conn, int txtype, __u64 cookie) { struct list_head *tmp; list_for_each(tmp, &conn->ibc_active_txs) { - kib_tx_t *tx = list_entry(tmp, kib_tx_t, tx_list); + struct kib_tx *tx = list_entry(tmp, struct kib_tx, tx_list); LASSERT(!tx->tx_queued); LASSERT(tx->tx_sending || tx->tx_waiting); @@ -249,9 +249,9 @@ kiblnd_find_waiting_tx_locked(kib_conn_t *conn, int txtype, __u64 cookie) } static void -kiblnd_handle_completion(kib_conn_t *conn, int txtype, int status, __u64 cookie) +kiblnd_handle_completion(struct kib_conn *conn, int txtype, int status, __u64 cookie) { - kib_tx_t *tx; + struct kib_tx *tx; lnet_ni_t *ni = conn->ibc_peer->ibp_ni; int idle; @@ -287,10 +287,10 @@ kiblnd_handle_completion(kib_conn_t *conn, int txtype, int status, __u64 cookie) } static void -kiblnd_send_completion(kib_conn_t *conn, int type, int status, __u64 cookie) +kiblnd_send_completion(struct kib_conn *conn, int type, int status, __u64 cookie) { lnet_ni_t *ni = conn->ibc_peer->ibp_ni; - kib_tx_t *tx = kiblnd_get_idle_tx(ni, conn->ibc_peer->ibp_nid); + struct kib_tx *tx = kiblnd_get_idle_tx(ni, conn->ibc_peer->ibp_nid); if (!tx) { CERROR("Can't get tx for completion %x for %s\n", @@ -300,19 +300,19 @@ kiblnd_send_completion(kib_conn_t *conn, int type, int status, __u64 cookie) tx->tx_msg->ibm_u.completion.ibcm_status = status; tx->tx_msg->ibm_u.completion.ibcm_cookie = cookie; - kiblnd_init_tx_msg(ni, tx, type, sizeof(kib_completion_msg_t)); + kiblnd_init_tx_msg(ni, tx, type, sizeof(struct kib_completion_msg)); kiblnd_queue_tx(tx, conn); } static void -kiblnd_handle_rx(kib_rx_t *rx) +kiblnd_handle_rx(struct kib_rx *rx) { - kib_msg_t *msg = rx->rx_msg; - kib_conn_t *conn = rx->rx_conn; + struct kib_msg *msg = rx->rx_msg; + struct kib_conn *conn = rx->rx_conn; lnet_ni_t *ni = conn->ibc_peer->ibp_ni; int credits = msg->ibm_credits; - kib_tx_t *tx; + struct kib_tx *tx; int rc = 0; int rc2; int post_credit; @@ -467,12 +467,12 @@ kiblnd_handle_rx(kib_rx_t *rx) } static void -kiblnd_rx_complete(kib_rx_t *rx, int status, int nob) +kiblnd_rx_complete(struct kib_rx *rx, int status, int nob) { - kib_msg_t *msg = rx->rx_msg; - kib_conn_t *conn = rx->rx_conn; + struct kib_msg *msg = rx->rx_msg; + struct kib_conn *conn = rx->rx_conn; lnet_ni_t *ni = conn->ibc_peer->ibp_ni; - kib_net_t *net = ni->ni_data; + struct kib_net *net = ni->ni_data; int rc; int err = -EIO; @@ -561,10 +561,10 @@ kiblnd_kvaddr_to_page(unsigned long vaddr) } static int -kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, __u32 nob) +kiblnd_fmr_map_tx(struct kib_net *net, struct kib_tx *tx, struct kib_rdma_desc *rd, __u32 nob) { - kib_hca_dev_t *hdev; - kib_fmr_poolset_t *fps; + struct kib_hca_dev *hdev; + struct kib_fmr_poolset *fps; int cpt; int rc; @@ -593,9 +593,9 @@ kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, __u32 nob) return 0; } -static void kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx) +static void kiblnd_unmap_tx(lnet_ni_t *ni, struct kib_tx *tx) { - kib_net_t *net = ni->ni_data; + struct kib_net *net = ni->ni_data; LASSERT(net); @@ -609,11 +609,11 @@ static void kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx) } } -static int kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, +static int kiblnd_map_tx(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc *rd, int nfrags) { - kib_net_t *net = ni->ni_data; - kib_hca_dev_t *hdev = net->ibn_dev->ibd_hdev; + struct kib_net *net = ni->ni_data; + struct kib_hca_dev *hdev = net->ibn_dev->ibd_hdev; struct ib_mr *mr = NULL; __u32 nob; int i; @@ -651,10 +651,10 @@ static int kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, } static int -kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, +kiblnd_setup_rd_iov(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc *rd, unsigned int niov, struct kvec *iov, int offset, int nob) { - kib_net_t *net = ni->ni_data; + struct kib_net *net = ni->ni_data; struct page *page; struct scatterlist *sg; unsigned long vaddr; @@ -708,10 +708,10 @@ kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, } static int -kiblnd_setup_rd_kiov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, +kiblnd_setup_rd_kiov(lnet_ni_t *ni, struct kib_tx *tx, struct kib_rdma_desc *rd, int nkiov, lnet_kiov_t *kiov, int offset, int nob) { - kib_net_t *net = ni->ni_data; + struct kib_net *net = ni->ni_data; struct scatterlist *sg; int fragnob; @@ -752,11 +752,11 @@ kiblnd_setup_rd_kiov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd, } static int -kiblnd_post_tx_locked(kib_conn_t *conn, kib_tx_t *tx, int credit) +kiblnd_post_tx_locked(struct kib_conn *conn, struct kib_tx *tx, int credit) __must_hold(&conn->ibc_lock) { - kib_msg_t *msg = tx->tx_msg; - kib_peer_t *peer = conn->ibc_peer; + struct kib_msg *msg = tx->tx_msg; + struct kib_peer *peer = conn->ibc_peer; struct lnet_ni *ni = peer->ibp_ni; int ver = conn->ibc_version; int rc; @@ -909,11 +909,11 @@ kiblnd_post_tx_locked(kib_conn_t *conn, kib_tx_t *tx, int credit) } static void -kiblnd_check_sends(kib_conn_t *conn) +kiblnd_check_sends(struct kib_conn *conn) { int ver = conn->ibc_version; lnet_ni_t *ni = conn->ibc_peer->ibp_ni; - kib_tx_t *tx; + struct kib_tx *tx; /* Don't send anything until after the connection is established */ if (conn->ibc_state < IBLND_CONN_ESTABLISHED) { @@ -932,7 +932,7 @@ kiblnd_check_sends(kib_conn_t *conn) while (conn->ibc_reserved_credits > 0 && !list_empty(&conn->ibc_tx_queue_rsrvd)) { tx = list_entry(conn->ibc_tx_queue_rsrvd.next, - kib_tx_t, tx_list); + struct kib_tx, tx_list); list_del(&tx->tx_list); list_add_tail(&tx->tx_list, &conn->ibc_tx_queue); conn->ibc_reserved_credits--; @@ -956,16 +956,16 @@ kiblnd_check_sends(kib_conn_t *conn) if (!list_empty(&conn->ibc_tx_queue_nocred)) { credit = 0; tx = list_entry(conn->ibc_tx_queue_nocred.next, - kib_tx_t, tx_list); + struct kib_tx, tx_list); } else if (!list_empty(&conn->ibc_tx_noops)) { LASSERT(!IBLND_OOB_CAPABLE(ver)); credit = 1; tx = list_entry(conn->ibc_tx_noops.next, - kib_tx_t, tx_list); + struct kib_tx, tx_list); } else if (!list_empty(&conn->ibc_tx_queue)) { credit = 1; tx = list_entry(conn->ibc_tx_queue.next, - kib_tx_t, tx_list); + struct kib_tx, tx_list); } else { break; } @@ -978,10 +978,10 @@ kiblnd_check_sends(kib_conn_t *conn) } static void -kiblnd_tx_complete(kib_tx_t *tx, int status) +kiblnd_tx_complete(struct kib_tx *tx, int status) { int failed = (status != IB_WC_SUCCESS); - kib_conn_t *conn = tx->tx_conn; + struct kib_conn *conn = tx->tx_conn; int idle; LASSERT(tx->tx_sending > 0); @@ -1033,12 +1033,12 @@ kiblnd_tx_complete(kib_tx_t *tx, int status) } static void -kiblnd_init_tx_msg(lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob) +kiblnd_init_tx_msg(lnet_ni_t *ni, struct kib_tx *tx, int type, int body_nob) { - kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev; + struct kib_hca_dev *hdev = tx->tx_pool->tpo_hdev; struct ib_sge *sge = &tx->tx_sge[tx->tx_nwrq]; struct ib_rdma_wr *wrq = &tx->tx_wrq[tx->tx_nwrq]; - int nob = offsetof(kib_msg_t, ibm_u) + body_nob; + int nob = offsetof(struct kib_msg, ibm_u) + body_nob; struct ib_mr *mr = hdev->ibh_mrs; LASSERT(tx->tx_nwrq >= 0); @@ -1065,11 +1065,11 @@ kiblnd_init_tx_msg(lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob) } static int -kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type, - int resid, kib_rdma_desc_t *dstrd, __u64 dstcookie) +kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, + int resid, struct kib_rdma_desc *dstrd, __u64 dstcookie) { - kib_msg_t *ibmsg = tx->tx_msg; - kib_rdma_desc_t *srcrd = tx->tx_rd; + struct kib_msg *ibmsg = tx->tx_msg; + struct kib_rdma_desc *srcrd = tx->tx_rd; struct ib_sge *sge = &tx->tx_sge[0]; struct ib_rdma_wr *wrq, *next; int rc = resid; @@ -1143,13 +1143,13 @@ kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type, ibmsg->ibm_u.completion.ibcm_status = rc; ibmsg->ibm_u.completion.ibcm_cookie = dstcookie; kiblnd_init_tx_msg(conn->ibc_peer->ibp_ni, tx, - type, sizeof(kib_completion_msg_t)); + type, sizeof(struct kib_completion_msg)); return rc; } static void -kiblnd_queue_tx_locked(kib_tx_t *tx, kib_conn_t *conn) +kiblnd_queue_tx_locked(struct kib_tx *tx, struct kib_conn *conn) { struct list_head *q; @@ -1204,7 +1204,7 @@ kiblnd_queue_tx_locked(kib_tx_t *tx, kib_conn_t *conn) } static void -kiblnd_queue_tx(kib_tx_t *tx, kib_conn_t *conn) +kiblnd_queue_tx(struct kib_tx *tx, struct kib_conn *conn) { spin_lock(&conn->ibc_lock); kiblnd_queue_tx_locked(tx, conn); @@ -1251,11 +1251,11 @@ static int kiblnd_resolve_addr(struct rdma_cm_id *cmid, } static void -kiblnd_connect_peer(kib_peer_t *peer) +kiblnd_connect_peer(struct kib_peer *peer) { struct rdma_cm_id *cmid; - kib_dev_t *dev; - kib_net_t *net = peer->ibp_ni->ni_data; + struct kib_dev *dev; + struct kib_net *net = peer->ibp_ni->ni_data; struct sockaddr_in srcaddr; struct sockaddr_in dstaddr; int rc; @@ -1319,7 +1319,7 @@ kiblnd_connect_peer(kib_peer_t *peer) } bool -kiblnd_reconnect_peer(kib_peer_t *peer) +kiblnd_reconnect_peer(struct kib_peer *peer) { rwlock_t *glock = &kiblnd_data.kib_global_lock; char *reason = NULL; @@ -1369,11 +1369,11 @@ no_reconnect: } void -kiblnd_launch_tx(lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid) +kiblnd_launch_tx(lnet_ni_t *ni, struct kib_tx *tx, lnet_nid_t nid) { - kib_peer_t *peer; - kib_peer_t *peer2; - kib_conn_t *conn; + struct kib_peer *peer; + struct kib_peer *peer2; + struct kib_conn *conn; rwlock_t *g_lock = &kiblnd_data.kib_global_lock; unsigned long flags; int rc; @@ -1476,7 +1476,7 @@ kiblnd_launch_tx(lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid) peer->ibp_connecting = 1; /* always called with a ref on ni, which prevents ni being shutdown */ - LASSERT(!((kib_net_t *)ni->ni_data)->ibn_shutdown); + LASSERT(!((struct kib_net *)ni->ni_data)->ibn_shutdown); if (tx) list_add_tail(&tx->tx_list, &peer->ibp_tx_queue); @@ -1503,9 +1503,9 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) lnet_kiov_t *payload_kiov = lntmsg->msg_kiov; unsigned int payload_offset = lntmsg->msg_offset; unsigned int payload_nob = lntmsg->msg_len; - kib_msg_t *ibmsg; - kib_rdma_desc_t *rd; - kib_tx_t *tx; + struct kib_msg *ibmsg; + struct kib_rdma_desc *rd; + struct kib_tx *tx; int nob; int rc; @@ -1536,7 +1536,7 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) break; /* send IMMEDIATE */ /* is the REPLY message too small for RDMA? */ - nob = offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[lntmsg->msg_md->md_length]); + nob = offsetof(struct kib_msg, ibm_u.immediate.ibim_payload[lntmsg->msg_md->md_length]); if (nob <= IBLND_MSG_SIZE) break; /* send IMMEDIATE */ @@ -1566,7 +1566,7 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) return -EIO; } - nob = offsetof(kib_get_msg_t, ibgm_rd.rd_frags[rd->rd_nfrags]); + nob = offsetof(struct kib_get_msg, ibgm_rd.rd_frags[rd->rd_nfrags]); ibmsg->ibm_u.get.ibgm_cookie = tx->tx_cookie; ibmsg->ibm_u.get.ibgm_hdr = *hdr; @@ -1588,7 +1588,7 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) case LNET_MSG_REPLY: case LNET_MSG_PUT: /* Is the payload small enough not to need RDMA? */ - nob = offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[payload_nob]); + nob = offsetof(struct kib_msg, ibm_u.immediate.ibim_payload[payload_nob]); if (nob <= IBLND_MSG_SIZE) break; /* send IMMEDIATE */ @@ -1618,7 +1618,7 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) ibmsg = tx->tx_msg; ibmsg->ibm_u.putreq.ibprm_hdr = *hdr; ibmsg->ibm_u.putreq.ibprm_cookie = tx->tx_cookie; - kiblnd_init_tx_msg(ni, tx, IBLND_MSG_PUT_REQ, sizeof(kib_putreq_msg_t)); + kiblnd_init_tx_msg(ni, tx, IBLND_MSG_PUT_REQ, sizeof(struct kib_putreq_msg)); tx->tx_lntmsg[0] = lntmsg; /* finalise lntmsg on completion */ tx->tx_waiting = 1; /* waiting for PUT_{ACK,NAK} */ @@ -1628,7 +1628,7 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) /* send IMMEDIATE */ - LASSERT(offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[payload_nob]) + LASSERT(offsetof(struct kib_msg, ibm_u.immediate.ibim_payload[payload_nob]) <= IBLND_MSG_SIZE); tx = kiblnd_get_idle_tx(ni, target.nid); @@ -1643,16 +1643,16 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) if (payload_kiov) lnet_copy_kiov2flat(IBLND_MSG_SIZE, ibmsg, - offsetof(kib_msg_t, ibm_u.immediate.ibim_payload), + offsetof(struct kib_msg, ibm_u.immediate.ibim_payload), payload_niov, payload_kiov, payload_offset, payload_nob); else lnet_copy_iov2flat(IBLND_MSG_SIZE, ibmsg, - offsetof(kib_msg_t, ibm_u.immediate.ibim_payload), + offsetof(struct kib_msg, ibm_u.immediate.ibim_payload), payload_niov, payload_iov, payload_offset, payload_nob); - nob = offsetof(kib_immediate_msg_t, ibim_payload[payload_nob]); + nob = offsetof(struct kib_immediate_msg, ibim_payload[payload_nob]); kiblnd_init_tx_msg(ni, tx, IBLND_MSG_IMMEDIATE, nob); tx->tx_lntmsg[0] = lntmsg; /* finalise lntmsg on completion */ @@ -1661,7 +1661,7 @@ kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) } static void -kiblnd_reply(lnet_ni_t *ni, kib_rx_t *rx, lnet_msg_t *lntmsg) +kiblnd_reply(lnet_ni_t *ni, struct kib_rx *rx, lnet_msg_t *lntmsg) { lnet_process_id_t target = lntmsg->msg_target; unsigned int niov = lntmsg->msg_niov; @@ -1669,7 +1669,7 @@ kiblnd_reply(lnet_ni_t *ni, kib_rx_t *rx, lnet_msg_t *lntmsg) lnet_kiov_t *kiov = lntmsg->msg_kiov; unsigned int offset = lntmsg->msg_offset; unsigned int nob = lntmsg->msg_len; - kib_tx_t *tx; + struct kib_tx *tx; int rc; tx = kiblnd_get_idle_tx(ni, rx->rx_conn->ibc_peer->ibp_nid); @@ -1726,10 +1726,10 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed, unsigned int niov, struct kvec *iov, lnet_kiov_t *kiov, unsigned int offset, unsigned int mlen, unsigned int rlen) { - kib_rx_t *rx = private; - kib_msg_t *rxmsg = rx->rx_msg; - kib_conn_t *conn = rx->rx_conn; - kib_tx_t *tx; + struct kib_rx *rx = private; + struct kib_msg *rxmsg = rx->rx_msg; + struct kib_conn *conn = rx->rx_conn; + struct kib_tx *tx; int nob; int post_credit = IBLND_POSTRX_PEER_CREDIT; int rc = 0; @@ -1744,7 +1744,7 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed, LBUG(); case IBLND_MSG_IMMEDIATE: - nob = offsetof(kib_msg_t, ibm_u.immediate.ibim_payload[rlen]); + nob = offsetof(struct kib_msg, ibm_u.immediate.ibim_payload[rlen]); if (nob > rx->rx_nob) { CERROR("Immediate message from %s too big: %d(%d)\n", libcfs_nid2str(rxmsg->ibm_u.immediate.ibim_hdr.src_nid), @@ -1756,19 +1756,19 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed, if (kiov) lnet_copy_flat2kiov(niov, kiov, offset, IBLND_MSG_SIZE, rxmsg, - offsetof(kib_msg_t, ibm_u.immediate.ibim_payload), + offsetof(struct kib_msg, ibm_u.immediate.ibim_payload), mlen); else lnet_copy_flat2iov(niov, iov, offset, IBLND_MSG_SIZE, rxmsg, - offsetof(kib_msg_t, ibm_u.immediate.ibim_payload), + offsetof(struct kib_msg, ibm_u.immediate.ibim_payload), mlen); lnet_finalize(ni, lntmsg, 0); break; case IBLND_MSG_PUT_REQ: { - kib_msg_t *txmsg; - kib_rdma_desc_t *rd; + struct kib_msg *txmsg; + struct kib_rdma_desc *rd; if (!mlen) { lnet_finalize(ni, lntmsg, 0); @@ -1804,7 +1804,7 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed, break; } - nob = offsetof(kib_putack_msg_t, ibpam_rd.rd_frags[rd->rd_nfrags]); + nob = offsetof(struct kib_putack_msg, ibpam_rd.rd_frags[rd->rd_nfrags]); txmsg->ibm_u.putack.ibpam_src_cookie = rxmsg->ibm_u.putreq.ibprm_cookie; txmsg->ibm_u.putack.ibpam_dst_cookie = tx->tx_cookie; @@ -1855,7 +1855,7 @@ kiblnd_thread_fini(void) } static void -kiblnd_peer_alive(kib_peer_t *peer) +kiblnd_peer_alive(struct kib_peer *peer) { /* This is racy, but everyone's only writing cfs_time_current() */ peer->ibp_last_alive = cfs_time_current(); @@ -1863,7 +1863,7 @@ kiblnd_peer_alive(kib_peer_t *peer) } static void -kiblnd_peer_notify(kib_peer_t *peer) +kiblnd_peer_notify(struct kib_peer *peer) { int error = 0; unsigned long last_alive = 0; @@ -1886,7 +1886,7 @@ kiblnd_peer_notify(kib_peer_t *peer) } void -kiblnd_close_conn_locked(kib_conn_t *conn, int error) +kiblnd_close_conn_locked(struct kib_conn *conn, int error) { /* * This just does the immediate housekeeping. 'error' is zero for a @@ -1896,8 +1896,8 @@ kiblnd_close_conn_locked(kib_conn_t *conn, int error) * already dealing with it (either to set it up or tear it down). * Caller holds kib_global_lock exclusively in irq context */ - kib_peer_t *peer = conn->ibc_peer; - kib_dev_t *dev; + struct kib_peer *peer = conn->ibc_peer; + struct kib_dev *dev; unsigned long flags; LASSERT(error || conn->ibc_state >= IBLND_CONN_ESTABLISHED); @@ -1926,7 +1926,7 @@ kiblnd_close_conn_locked(kib_conn_t *conn, int error) list_empty(&conn->ibc_active_txs) ? "" : "(waiting)"); } - dev = ((kib_net_t *)peer->ibp_ni->ni_data)->ibn_dev; + dev = ((struct kib_net *)peer->ibp_ni->ni_data)->ibn_dev; list_del(&conn->ibc_list); /* connd (see below) takes over ibc_list's ref */ @@ -1956,7 +1956,7 @@ kiblnd_close_conn_locked(kib_conn_t *conn, int error) } void -kiblnd_close_conn(kib_conn_t *conn, int error) +kiblnd_close_conn(struct kib_conn *conn, int error) { unsigned long flags; @@ -1968,11 +1968,11 @@ kiblnd_close_conn(kib_conn_t *conn, int error) } static void -kiblnd_handle_early_rxs(kib_conn_t *conn) +kiblnd_handle_early_rxs(struct kib_conn *conn) { unsigned long flags; - kib_rx_t *rx; - kib_rx_t *tmp; + struct kib_rx *rx; + struct kib_rx *tmp; LASSERT(!in_interrupt()); LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED); @@ -1990,17 +1990,17 @@ kiblnd_handle_early_rxs(kib_conn_t *conn) } static void -kiblnd_abort_txs(kib_conn_t *conn, struct list_head *txs) +kiblnd_abort_txs(struct kib_conn *conn, struct list_head *txs) { LIST_HEAD(zombies); struct list_head *tmp; struct list_head *nxt; - kib_tx_t *tx; + struct kib_tx *tx; spin_lock(&conn->ibc_lock); list_for_each_safe(tmp, nxt, txs) { - tx = list_entry(tmp, kib_tx_t, tx_list); + tx = list_entry(tmp, struct kib_tx, tx_list); if (txs == &conn->ibc_active_txs) { LASSERT(!tx->tx_queued); @@ -2025,7 +2025,7 @@ kiblnd_abort_txs(kib_conn_t *conn, struct list_head *txs) } static void -kiblnd_finalise_conn(kib_conn_t *conn) +kiblnd_finalise_conn(struct kib_conn *conn) { LASSERT(!in_interrupt()); LASSERT(conn->ibc_state > IBLND_CONN_INIT); @@ -2053,7 +2053,7 @@ kiblnd_finalise_conn(kib_conn_t *conn) } static void -kiblnd_peer_connect_failed(kib_peer_t *peer, int active, int error) +kiblnd_peer_connect_failed(struct kib_peer *peer, int active, int error) { LIST_HEAD(zombies); unsigned long flags; @@ -2107,11 +2107,11 @@ kiblnd_peer_connect_failed(kib_peer_t *peer, int active, int error) } static void -kiblnd_connreq_done(kib_conn_t *conn, int status) +kiblnd_connreq_done(struct kib_conn *conn, int status) { - kib_peer_t *peer = conn->ibc_peer; - kib_tx_t *tx; - kib_tx_t *tmp; + struct kib_peer *peer = conn->ibc_peer; + struct kib_tx *tx; + struct kib_tx *tmp; struct list_head txs; unsigned long flags; int active; @@ -2217,7 +2217,7 @@ kiblnd_connreq_done(kib_conn_t *conn, int status) } static void -kiblnd_reject(struct rdma_cm_id *cmid, kib_rej_t *rej) +kiblnd_reject(struct rdma_cm_id *cmid, struct kib_rej *rej) { int rc; @@ -2231,17 +2231,17 @@ static int kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob) { rwlock_t *g_lock = &kiblnd_data.kib_global_lock; - kib_msg_t *reqmsg = priv; - kib_msg_t *ackmsg; - kib_dev_t *ibdev; - kib_peer_t *peer; - kib_peer_t *peer2; - kib_conn_t *conn; + struct kib_msg *reqmsg = priv; + struct kib_msg *ackmsg; + struct kib_dev *ibdev; + struct kib_peer *peer; + struct kib_peer *peer2; + struct kib_conn *conn; lnet_ni_t *ni = NULL; - kib_net_t *net = NULL; + struct kib_net *net = NULL; lnet_nid_t nid; struct rdma_conn_param cp; - kib_rej_t rej; + struct kib_rej rej; int version = IBLND_MSG_VERSION; unsigned long flags; int rc; @@ -2250,7 +2250,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob) LASSERT(!in_interrupt()); /* cmid inherits 'context' from the corresponding listener id */ - ibdev = (kib_dev_t *)cmid->context; + ibdev = (struct kib_dev *)cmid->context; LASSERT(ibdev); memset(&rej, 0, sizeof(rej)); @@ -2268,7 +2268,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob) goto failed; } - if (priv_nob < offsetof(kib_msg_t, ibm_type)) { + if (priv_nob < offsetof(struct kib_msg, ibm_type)) { CERROR("Short connection request\n"); goto failed; } @@ -2303,7 +2303,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob) ni = lnet_net2ni(LNET_NIDNET(reqmsg->ibm_dstnid)); if (ni) { - net = (kib_net_t *)ni->ni_data; + net = (struct kib_net *)ni->ni_data; rej.ibr_incarnation = net->ibn_incarnation; } @@ -2541,11 +2541,11 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob) } static void -kiblnd_check_reconnect(kib_conn_t *conn, int version, - __u64 incarnation, int why, kib_connparams_t *cp) +kiblnd_check_reconnect(struct kib_conn *conn, int version, + __u64 incarnation, int why, struct kib_connparams *cp) { rwlock_t *glock = &kiblnd_data.kib_global_lock; - kib_peer_t *peer = conn->ibc_peer; + struct kib_peer *peer = conn->ibc_peer; char *reason; int msg_size = IBLND_MSG_SIZE; int frag_num = -1; @@ -2654,9 +2654,9 @@ out: } static void -kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob) +kiblnd_rejected(struct kib_conn *conn, int reason, void *priv, int priv_nob) { - kib_peer_t *peer = conn->ibc_peer; + struct kib_peer *peer = conn->ibc_peer; LASSERT(!in_interrupt()); LASSERT(conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT); @@ -2674,9 +2674,9 @@ kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob) break; case IB_CM_REJ_CONSUMER_DEFINED: - if (priv_nob >= offsetof(kib_rej_t, ibr_padding)) { - kib_rej_t *rej = priv; - kib_connparams_t *cp = NULL; + if (priv_nob >= offsetof(struct kib_rej, ibr_padding)) { + struct kib_rej *rej = priv; + struct kib_connparams *cp = NULL; int flip = 0; __u64 incarnation = -1; @@ -2699,7 +2699,7 @@ kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob) flip = 1; } - if (priv_nob >= sizeof(kib_rej_t) && + if (priv_nob >= sizeof(struct kib_rej) && rej->ibr_version > IBLND_MSG_VERSION_1) { /* * priv_nob is always 148 in current version @@ -2782,12 +2782,12 @@ kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob) } static void -kiblnd_check_connreply(kib_conn_t *conn, void *priv, int priv_nob) +kiblnd_check_connreply(struct kib_conn *conn, void *priv, int priv_nob) { - kib_peer_t *peer = conn->ibc_peer; + struct kib_peer *peer = conn->ibc_peer; lnet_ni_t *ni = peer->ibp_ni; - kib_net_t *net = ni->ni_data; - kib_msg_t *msg = priv; + struct kib_net *net = ni->ni_data; + struct kib_msg *msg = priv; int ver = conn->ibc_version; int rc = kiblnd_unpack_msg(msg, priv_nob); unsigned long flags; @@ -2884,9 +2884,9 @@ kiblnd_check_connreply(kib_conn_t *conn, void *priv, int priv_nob) static int kiblnd_active_connect(struct rdma_cm_id *cmid) { - kib_peer_t *peer = (kib_peer_t *)cmid->context; - kib_conn_t *conn; - kib_msg_t *msg; + struct kib_peer *peer = (struct kib_peer *)cmid->context; + struct kib_conn *conn; + struct kib_msg *msg; struct rdma_conn_param cp; int version; __u64 incarnation; @@ -2951,8 +2951,8 @@ kiblnd_active_connect(struct rdma_cm_id *cmid) int kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) { - kib_peer_t *peer; - kib_conn_t *conn; + struct kib_peer *peer; + struct kib_conn *conn; int rc; switch (event->event) { @@ -2970,7 +2970,7 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) return rc; case RDMA_CM_EVENT_ADDR_ERROR: - peer = (kib_peer_t *)cmid->context; + peer = (struct kib_peer *)cmid->context; CNETERR("%s: ADDR ERROR %d\n", libcfs_nid2str(peer->ibp_nid), event->status); kiblnd_peer_connect_failed(peer, 1, -EHOSTUNREACH); @@ -2978,7 +2978,7 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) return -EHOSTUNREACH; /* rc destroys cmid */ case RDMA_CM_EVENT_ADDR_RESOLVED: - peer = (kib_peer_t *)cmid->context; + peer = (struct kib_peer *)cmid->context; CDEBUG(D_NET, "%s Addr resolved: %d\n", libcfs_nid2str(peer->ibp_nid), event->status); @@ -3001,7 +3001,7 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) return rc; /* rc destroys cmid */ case RDMA_CM_EVENT_ROUTE_ERROR: - peer = (kib_peer_t *)cmid->context; + peer = (struct kib_peer *)cmid->context; CNETERR("%s: ROUTE ERROR %d\n", libcfs_nid2str(peer->ibp_nid), event->status); kiblnd_peer_connect_failed(peer, 1, -EHOSTUNREACH); @@ -3009,7 +3009,7 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) return -EHOSTUNREACH; /* rc destroys cmid */ case RDMA_CM_EVENT_ROUTE_RESOLVED: - peer = (kib_peer_t *)cmid->context; + peer = (struct kib_peer *)cmid->context; CDEBUG(D_NET, "%s Route resolved: %d\n", libcfs_nid2str(peer->ibp_nid), event->status); @@ -3023,7 +3023,7 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) return event->status; /* rc destroys cmid */ case RDMA_CM_EVENT_UNREACHABLE: - conn = (kib_conn_t *)cmid->context; + conn = (struct kib_conn *)cmid->context; LASSERT(conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT || conn->ibc_state == IBLND_CONN_PASSIVE_WAIT); CNETERR("%s: UNREACHABLE %d\n", @@ -3033,7 +3033,7 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) return 0; case RDMA_CM_EVENT_CONNECT_ERROR: - conn = (kib_conn_t *)cmid->context; + conn = (struct kib_conn *)cmid->context; LASSERT(conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT || conn->ibc_state == IBLND_CONN_PASSIVE_WAIT); CNETERR("%s: CONNECT ERROR %d\n", @@ -3043,7 +3043,7 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) return 0; case RDMA_CM_EVENT_REJECTED: - conn = (kib_conn_t *)cmid->context; + conn = (struct kib_conn *)cmid->context; switch (conn->ibc_state) { default: LBUG(); @@ -3065,7 +3065,7 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) return 0; case RDMA_CM_EVENT_ESTABLISHED: - conn = (kib_conn_t *)cmid->context; + conn = (struct kib_conn *)cmid->context; switch (conn->ibc_state) { default: LBUG(); @@ -3091,7 +3091,7 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) CDEBUG(D_NET, "Ignore TIMEWAIT_EXIT event\n"); return 0; case RDMA_CM_EVENT_DISCONNECTED: - conn = (kib_conn_t *)cmid->context; + conn = (struct kib_conn *)cmid->context; if (conn->ibc_state < IBLND_CONN_ESTABLISHED) { CERROR("%s DISCONNECTED\n", libcfs_nid2str(conn->ibc_peer->ibp_nid)); @@ -3120,13 +3120,13 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event) } static int -kiblnd_check_txs_locked(kib_conn_t *conn, struct list_head *txs) +kiblnd_check_txs_locked(struct kib_conn *conn, struct list_head *txs) { - kib_tx_t *tx; + struct kib_tx *tx; struct list_head *ttmp; list_for_each(ttmp, txs) { - tx = list_entry(ttmp, kib_tx_t, tx_list); + tx = list_entry(ttmp, struct kib_tx, tx_list); if (txs != &conn->ibc_active_txs) { LASSERT(tx->tx_queued); @@ -3147,7 +3147,7 @@ kiblnd_check_txs_locked(kib_conn_t *conn, struct list_head *txs) } static int -kiblnd_conn_timed_out_locked(kib_conn_t *conn) +kiblnd_conn_timed_out_locked(struct kib_conn *conn) { return kiblnd_check_txs_locked(conn, &conn->ibc_tx_queue) || kiblnd_check_txs_locked(conn, &conn->ibc_tx_noops) || @@ -3163,10 +3163,10 @@ kiblnd_check_conns(int idx) LIST_HEAD(checksends); struct list_head *peers = &kiblnd_data.kib_peers[idx]; struct list_head *ptmp; - kib_peer_t *peer; - kib_conn_t *conn; - kib_conn_t *temp; - kib_conn_t *tmp; + struct kib_peer *peer; + struct kib_conn *conn; + struct kib_conn *temp; + struct kib_conn *tmp; struct list_head *ctmp; unsigned long flags; @@ -3178,13 +3178,13 @@ kiblnd_check_conns(int idx) read_lock_irqsave(&kiblnd_data.kib_global_lock, flags); list_for_each(ptmp, peers) { - peer = list_entry(ptmp, kib_peer_t, ibp_list); + peer = list_entry(ptmp, struct kib_peer, ibp_list); list_for_each(ctmp, &peer->ibp_conns) { int timedout; int sendnoop; - conn = list_entry(ctmp, kib_conn_t, ibc_list); + conn = list_entry(ctmp, struct kib_conn, ibc_list); LASSERT(conn->ibc_state == IBLND_CONN_ESTABLISHED); @@ -3242,7 +3242,7 @@ kiblnd_check_conns(int idx) } static void -kiblnd_disconnect_conn(kib_conn_t *conn) +kiblnd_disconnect_conn(struct kib_conn *conn) { LASSERT(!in_interrupt()); LASSERT(current == kiblnd_data.kib_connd); @@ -3271,7 +3271,7 @@ kiblnd_connd(void *arg) spinlock_t *lock= &kiblnd_data.kib_connd_lock; wait_queue_t wait; unsigned long flags; - kib_conn_t *conn; + struct kib_conn *conn; int timeout; int i; int dropped_lock; @@ -3291,10 +3291,10 @@ kiblnd_connd(void *arg) dropped_lock = 0; if (!list_empty(&kiblnd_data.kib_connd_zombies)) { - kib_peer_t *peer = NULL; + struct kib_peer *peer = NULL; conn = list_entry(kiblnd_data.kib_connd_zombies.next, - kib_conn_t, ibc_list); + struct kib_conn, ibc_list); list_del(&conn->ibc_list); if (conn->ibc_reconnect) { peer = conn->ibc_peer; @@ -3321,7 +3321,7 @@ kiblnd_connd(void *arg) if (!list_empty(&kiblnd_data.kib_connd_conns)) { conn = list_entry(kiblnd_data.kib_connd_conns.next, - kib_conn_t, ibc_list); + struct kib_conn, ibc_list); list_del(&conn->ibc_list); spin_unlock_irqrestore(lock, flags); @@ -3345,7 +3345,7 @@ kiblnd_connd(void *arg) break; conn = list_entry(kiblnd_data.kib_reconn_list.next, - kib_conn_t, ibc_list); + struct kib_conn, ibc_list); list_del(&conn->ibc_list); spin_unlock_irqrestore(lock, flags); @@ -3416,7 +3416,7 @@ kiblnd_connd(void *arg) void kiblnd_qp_event(struct ib_event *event, void *arg) { - kib_conn_t *conn = arg; + struct kib_conn *conn = arg; switch (event->event) { case IB_EVENT_COMM_EST: @@ -3478,7 +3478,7 @@ kiblnd_cq_completion(struct ib_cq *cq, void *arg) * occurred. But in this case, !ibc_nrx && !ibc_nsends_posted * and this CQ is about to be destroyed so I NOOP. */ - kib_conn_t *conn = arg; + struct kib_conn *conn = arg; struct kib_sched_info *sched = conn->ibc_sched; unsigned long flags; @@ -3505,7 +3505,7 @@ kiblnd_cq_completion(struct ib_cq *cq, void *arg) void kiblnd_cq_event(struct ib_event *event, void *arg) { - kib_conn_t *conn = arg; + struct kib_conn *conn = arg; CERROR("%s: async CQ event type %d\n", libcfs_nid2str(conn->ibc_peer->ibp_nid), event->event); @@ -3516,7 +3516,7 @@ kiblnd_scheduler(void *arg) { long id = (long)arg; struct kib_sched_info *sched; - kib_conn_t *conn; + struct kib_conn *conn; wait_queue_t wait; unsigned long flags; struct ib_wc wc; @@ -3551,7 +3551,7 @@ kiblnd_scheduler(void *arg) did_something = 0; if (!list_empty(&sched->ibs_conns)) { - conn = list_entry(sched->ibs_conns.next, kib_conn_t, + conn = list_entry(sched->ibs_conns.next, struct kib_conn, ibc_sched_list); /* take over kib_sched_conns' ref on conn... */ LASSERT(conn->ibc_scheduled); @@ -3651,7 +3651,7 @@ int kiblnd_failover_thread(void *arg) { rwlock_t *glock = &kiblnd_data.kib_global_lock; - kib_dev_t *dev; + struct kib_dev *dev; wait_queue_t wait; unsigned long flags; int rc; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c index f8fdd4a..fdc2f3b 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c @@ -145,7 +145,7 @@ static int use_privileged_port = 1; module_param(use_privileged_port, int, 0644); MODULE_PARM_DESC(use_privileged_port, "use privileged port when initiating connection"); -kib_tunables_t kiblnd_tunables = { +struct kib_tunables kiblnd_tunables = { .kib_dev_failover = &dev_failover, .kib_service = &service, .kib_cksum = &cksum, -- cgit v1.1 From ff13fd40f2ffe4fc471d68fb7955f38a32852c20 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Fri, 10 Jun 2016 16:14:23 -0400 Subject: staging: lustre: socklnd: remove typedefs Remove all remaining typedefs in socklnd driver. Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 302 ++++++++++----------- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 209 +++++++------- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 200 +++++++------- .../lustre/lnet/klnds/socklnd/socklnd_lib.c | 34 +-- .../lustre/lnet/klnds/socklnd/socklnd_modparams.c | 2 +- .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 68 ++--- 6 files changed, 406 insertions(+), 409 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 406c0e7..0fdc37c 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -44,14 +44,14 @@ #include "socklnd.h" static lnd_t the_ksocklnd; -ksock_nal_data_t ksocknal_data; +struct ksock_nal_data ksocknal_data; -static ksock_interface_t * +static struct ksock_interface * ksocknal_ip2iface(lnet_ni_t *ni, __u32 ip) { - ksock_net_t *net = ni->ni_data; + struct ksock_net *net = ni->ni_data; int i; - ksock_interface_t *iface; + struct ksock_interface *iface; for (i = 0; i < net->ksnn_ninterfaces; i++) { LASSERT(i < LNET_MAX_INTERFACES); @@ -64,10 +64,10 @@ ksocknal_ip2iface(lnet_ni_t *ni, __u32 ip) return NULL; } -static ksock_route_t * +static struct ksock_route * ksocknal_create_route(__u32 ipaddr, int port) { - ksock_route_t *route; + struct ksock_route *route; LIBCFS_ALLOC(route, sizeof(*route)); if (!route) @@ -89,7 +89,7 @@ ksocknal_create_route(__u32 ipaddr, int port) } void -ksocknal_destroy_route(ksock_route_t *route) +ksocknal_destroy_route(struct ksock_route *route) { LASSERT(!atomic_read(&route->ksnr_refcount)); @@ -100,11 +100,11 @@ ksocknal_destroy_route(ksock_route_t *route) } static int -ksocknal_create_peer(ksock_peer_t **peerp, lnet_ni_t *ni, lnet_process_id_t id) +ksocknal_create_peer(struct ksock_peer **peerp, lnet_ni_t *ni, lnet_process_id_t id) { int cpt = lnet_cpt_of_nid(id.nid); - ksock_net_t *net = ni->ni_data; - ksock_peer_t *peer; + struct ksock_net *net = ni->ni_data; + struct ksock_peer *peer; LASSERT(id.nid != LNET_NID_ANY); LASSERT(id.pid != LNET_PID_ANY); @@ -148,9 +148,9 @@ ksocknal_create_peer(ksock_peer_t **peerp, lnet_ni_t *ni, lnet_process_id_t id) } void -ksocknal_destroy_peer(ksock_peer_t *peer) +ksocknal_destroy_peer(struct ksock_peer *peer) { - ksock_net_t *net = peer->ksnp_ni->ni_data; + struct ksock_net *net = peer->ksnp_ni->ni_data; CDEBUG(D_NET, "peer %s %p deleted\n", libcfs_id2str(peer->ksnp_id), peer); @@ -175,15 +175,15 @@ ksocknal_destroy_peer(ksock_peer_t *peer) spin_unlock_bh(&net->ksnn_lock); } -ksock_peer_t * +struct ksock_peer * ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id) { struct list_head *peer_list = ksocknal_nid2peerlist(id.nid); struct list_head *tmp; - ksock_peer_t *peer; + struct ksock_peer *peer; list_for_each(tmp, peer_list) { - peer = list_entry(tmp, ksock_peer_t, ksnp_list); + peer = list_entry(tmp, struct ksock_peer, ksnp_list); LASSERT(!peer->ksnp_closing); @@ -202,10 +202,10 @@ ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id) return NULL; } -ksock_peer_t * +struct ksock_peer * ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id) { - ksock_peer_t *peer; + struct ksock_peer *peer; read_lock(&ksocknal_data.ksnd_global_lock); peer = ksocknal_find_peer_locked(ni, id); @@ -217,11 +217,11 @@ ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id) } static void -ksocknal_unlink_peer_locked(ksock_peer_t *peer) +ksocknal_unlink_peer_locked(struct ksock_peer *peer) { int i; __u32 ip; - ksock_interface_t *iface; + struct ksock_interface *iface; for (i = 0; i < peer->ksnp_n_passive_ips; i++) { LASSERT(i < LNET_MAX_INTERFACES); @@ -253,9 +253,9 @@ ksocknal_get_peer_info(lnet_ni_t *ni, int index, lnet_process_id_t *id, __u32 *myip, __u32 *peer_ip, int *port, int *conn_count, int *share_count) { - ksock_peer_t *peer; + struct ksock_peer *peer; struct list_head *ptmp; - ksock_route_t *route; + struct ksock_route *route; struct list_head *rtmp; int i; int j; @@ -265,7 +265,7 @@ ksocknal_get_peer_info(lnet_ni_t *ni, int index, for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) { - peer = list_entry(ptmp, ksock_peer_t, ksnp_list); + peer = list_entry(ptmp, struct ksock_peer, ksnp_list); if (peer->ksnp_ni != ni) continue; @@ -303,7 +303,7 @@ ksocknal_get_peer_info(lnet_ni_t *ni, int index, if (index-- > 0) continue; - route = list_entry(rtmp, ksock_route_t, + route = list_entry(rtmp, struct ksock_route, ksnr_list); *id = peer->ksnp_id; @@ -323,11 +323,11 @@ ksocknal_get_peer_info(lnet_ni_t *ni, int index, } static void -ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn) +ksocknal_associate_route_conn_locked(struct ksock_route *route, struct ksock_conn *conn) { - ksock_peer_t *peer = route->ksnr_peer; + struct ksock_peer *peer = route->ksnr_peer; int type = conn->ksnc_type; - ksock_interface_t *iface; + struct ksock_interface *iface; conn->ksnc_route = route; ksocknal_route_addref(route); @@ -369,11 +369,11 @@ ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn) } static void -ksocknal_add_route_locked(ksock_peer_t *peer, ksock_route_t *route) +ksocknal_add_route_locked(struct ksock_peer *peer, struct ksock_route *route) { struct list_head *tmp; - ksock_conn_t *conn; - ksock_route_t *route2; + struct ksock_conn *conn; + struct ksock_route *route2; LASSERT(!peer->ksnp_closing); LASSERT(!route->ksnr_peer); @@ -383,7 +383,7 @@ ksocknal_add_route_locked(ksock_peer_t *peer, ksock_route_t *route) /* LASSERT(unique) */ list_for_each(tmp, &peer->ksnp_routes) { - route2 = list_entry(tmp, ksock_route_t, ksnr_list); + route2 = list_entry(tmp, struct ksock_route, ksnr_list); if (route2->ksnr_ipaddr == route->ksnr_ipaddr) { CERROR("Duplicate route %s %pI4h\n", @@ -399,7 +399,7 @@ ksocknal_add_route_locked(ksock_peer_t *peer, ksock_route_t *route) list_add_tail(&route->ksnr_list, &peer->ksnp_routes); list_for_each(tmp, &peer->ksnp_conns) { - conn = list_entry(tmp, ksock_conn_t, ksnc_list); + conn = list_entry(tmp, struct ksock_conn, ksnc_list); if (conn->ksnc_ipaddr != route->ksnr_ipaddr) continue; @@ -410,11 +410,11 @@ ksocknal_add_route_locked(ksock_peer_t *peer, ksock_route_t *route) } static void -ksocknal_del_route_locked(ksock_route_t *route) +ksocknal_del_route_locked(struct ksock_route *route) { - ksock_peer_t *peer = route->ksnr_peer; - ksock_interface_t *iface; - ksock_conn_t *conn; + struct ksock_peer *peer = route->ksnr_peer; + struct ksock_interface *iface; + struct ksock_conn *conn; struct list_head *ctmp; struct list_head *cnxt; @@ -422,7 +422,7 @@ ksocknal_del_route_locked(ksock_route_t *route) /* Close associated conns */ list_for_each_safe(ctmp, cnxt, &peer->ksnp_conns) { - conn = list_entry(ctmp, ksock_conn_t, ksnc_list); + conn = list_entry(ctmp, struct ksock_conn, ksnc_list); if (conn->ksnc_route != route) continue; @@ -455,10 +455,10 @@ int ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port) { struct list_head *tmp; - ksock_peer_t *peer; - ksock_peer_t *peer2; - ksock_route_t *route; - ksock_route_t *route2; + struct ksock_peer *peer; + struct ksock_peer *peer2; + struct ksock_route *route; + struct ksock_route *route2; int rc; if (id.nid == LNET_NID_ANY || @@ -479,7 +479,7 @@ ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port) write_lock_bh(&ksocknal_data.ksnd_global_lock); /* always called with a ref on ni, so shutdown can't have started */ - LASSERT(!((ksock_net_t *) ni->ni_data)->ksnn_shutdown); + LASSERT(!((struct ksock_net *) ni->ni_data)->ksnn_shutdown); peer2 = ksocknal_find_peer_locked(ni, id); if (peer2) { @@ -493,7 +493,7 @@ ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port) route2 = NULL; list_for_each(tmp, &peer->ksnp_routes) { - route2 = list_entry(tmp, ksock_route_t, ksnr_list); + route2 = list_entry(tmp, struct ksock_route, ksnr_list); if (route2->ksnr_ipaddr == ipaddr) break; @@ -514,10 +514,10 @@ ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port) } static void -ksocknal_del_peer_locked(ksock_peer_t *peer, __u32 ip) +ksocknal_del_peer_locked(struct ksock_peer *peer, __u32 ip) { - ksock_conn_t *conn; - ksock_route_t *route; + struct ksock_conn *conn; + struct ksock_route *route; struct list_head *tmp; struct list_head *nxt; int nshared; @@ -528,7 +528,7 @@ ksocknal_del_peer_locked(ksock_peer_t *peer, __u32 ip) ksocknal_peer_addref(peer); list_for_each_safe(tmp, nxt, &peer->ksnp_routes) { - route = list_entry(tmp, ksock_route_t, ksnr_list); + route = list_entry(tmp, struct ksock_route, ksnr_list); /* no match */ if (!(!ip || route->ksnr_ipaddr == ip)) @@ -541,7 +541,7 @@ ksocknal_del_peer_locked(ksock_peer_t *peer, __u32 ip) nshared = 0; list_for_each_safe(tmp, nxt, &peer->ksnp_routes) { - route = list_entry(tmp, ksock_route_t, ksnr_list); + route = list_entry(tmp, struct ksock_route, ksnr_list); nshared += route->ksnr_share_count; } @@ -551,7 +551,7 @@ ksocknal_del_peer_locked(ksock_peer_t *peer, __u32 ip) * left */ list_for_each_safe(tmp, nxt, &peer->ksnp_routes) { - route = list_entry(tmp, ksock_route_t, ksnr_list); + route = list_entry(tmp, struct ksock_route, ksnr_list); /* we should only be removing auto-entries */ LASSERT(!route->ksnr_share_count); @@ -559,7 +559,7 @@ ksocknal_del_peer_locked(ksock_peer_t *peer, __u32 ip) } list_for_each_safe(tmp, nxt, &peer->ksnp_conns) { - conn = list_entry(tmp, ksock_conn_t, ksnc_list); + conn = list_entry(tmp, struct ksock_conn, ksnc_list); ksocknal_close_conn_locked(conn, 0); } @@ -575,7 +575,7 @@ ksocknal_del_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip) LIST_HEAD(zombies); struct list_head *ptmp; struct list_head *pnxt; - ksock_peer_t *peer; + struct ksock_peer *peer; int lo; int hi; int i; @@ -593,7 +593,7 @@ ksocknal_del_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip) for (i = lo; i <= hi; i++) { list_for_each_safe(ptmp, pnxt, &ksocknal_data.ksnd_peers[i]) { - peer = list_entry(ptmp, ksock_peer_t, ksnp_list); + peer = list_entry(ptmp, struct ksock_peer, ksnp_list); if (peer->ksnp_ni != ni) continue; @@ -628,12 +628,12 @@ ksocknal_del_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip) return rc; } -static ksock_conn_t * +static struct ksock_conn * ksocknal_get_conn_by_idx(lnet_ni_t *ni, int index) { - ksock_peer_t *peer; + struct ksock_peer *peer; struct list_head *ptmp; - ksock_conn_t *conn; + struct ksock_conn *conn; struct list_head *ctmp; int i; @@ -641,7 +641,7 @@ ksocknal_get_conn_by_idx(lnet_ni_t *ni, int index) for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) { - peer = list_entry(ptmp, ksock_peer_t, ksnp_list); + peer = list_entry(ptmp, struct ksock_peer, ksnp_list); LASSERT(!peer->ksnp_closing); @@ -652,7 +652,7 @@ ksocknal_get_conn_by_idx(lnet_ni_t *ni, int index) if (index-- > 0) continue; - conn = list_entry(ctmp, ksock_conn_t, + conn = list_entry(ctmp, struct ksock_conn, ksnc_list); ksocknal_conn_addref(conn); read_unlock(&ksocknal_data.ksnd_global_lock); @@ -665,11 +665,11 @@ ksocknal_get_conn_by_idx(lnet_ni_t *ni, int index) return NULL; } -static ksock_sched_t * +static struct ksock_sched * ksocknal_choose_scheduler_locked(unsigned int cpt) { struct ksock_sched_info *info = ksocknal_data.ksnd_sched_info[cpt]; - ksock_sched_t *sched; + struct ksock_sched *sched; int i; LASSERT(info->ksi_nthreads > 0); @@ -691,7 +691,7 @@ ksocknal_choose_scheduler_locked(unsigned int cpt) static int ksocknal_local_ipvec(lnet_ni_t *ni, __u32 *ipaddrs) { - ksock_net_t *net = ni->ni_data; + struct ksock_net *net = ni->ni_data; int i; int nip; @@ -719,7 +719,7 @@ ksocknal_local_ipvec(lnet_ni_t *ni, __u32 *ipaddrs) } static int -ksocknal_match_peerip(ksock_interface_t *iface, __u32 *ips, int nips) +ksocknal_match_peerip(struct ksock_interface *iface, __u32 *ips, int nips) { int best_netmatch = 0; int best_xor = 0; @@ -751,12 +751,12 @@ ksocknal_match_peerip(ksock_interface_t *iface, __u32 *ips, int nips) } static int -ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips) +ksocknal_select_ips(struct ksock_peer *peer, __u32 *peerips, int n_peerips) { rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; - ksock_net_t *net = peer->ksnp_ni->ni_data; - ksock_interface_t *iface; - ksock_interface_t *best_iface; + struct ksock_net *net = peer->ksnp_ni->ni_data; + struct ksock_interface *iface; + struct ksock_interface *best_iface; int n_ips; int i; int j; @@ -862,17 +862,17 @@ ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips) } static void -ksocknal_create_routes(ksock_peer_t *peer, int port, +ksocknal_create_routes(struct ksock_peer *peer, int port, __u32 *peer_ipaddrs, int npeer_ipaddrs) { - ksock_route_t *newroute = NULL; + struct ksock_route *newroute = NULL; rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; lnet_ni_t *ni = peer->ksnp_ni; - ksock_net_t *net = ni->ni_data; + struct ksock_net *net = ni->ni_data; struct list_head *rtmp; - ksock_route_t *route; - ksock_interface_t *iface; - ksock_interface_t *best_iface; + struct ksock_route *route; + struct ksock_interface *iface; + struct ksock_interface *best_iface; int best_netmatch; int this_netmatch; int best_nroutes; @@ -919,7 +919,7 @@ ksocknal_create_routes(ksock_peer_t *peer, int port, /* Already got a route? */ route = NULL; list_for_each(rtmp, &peer->ksnp_routes) { - route = list_entry(rtmp, ksock_route_t, ksnr_list); + route = list_entry(rtmp, struct ksock_route, ksnr_list); if (route->ksnr_ipaddr == newroute->ksnr_ipaddr) break; @@ -941,7 +941,7 @@ ksocknal_create_routes(ksock_peer_t *peer, int port, /* Using this interface already? */ list_for_each(rtmp, &peer->ksnp_routes) { - route = list_entry(rtmp, ksock_route_t, + route = list_entry(rtmp, struct ksock_route, ksnr_list); if (route->ksnr_myipaddr == iface->ksni_ipaddr) @@ -985,7 +985,7 @@ ksocknal_create_routes(ksock_peer_t *peer, int port, int ksocknal_accept(lnet_ni_t *ni, struct socket *sock) { - ksock_connreq_t *cr; + struct ksock_connreq *cr; int rc; __u32 peer_ip; int peer_port; @@ -1014,9 +1014,9 @@ ksocknal_accept(lnet_ni_t *ni, struct socket *sock) } static int -ksocknal_connecting(ksock_peer_t *peer, __u32 ipaddr) +ksocknal_connecting(struct ksock_peer *peer, __u32 ipaddr) { - ksock_route_t *route; + struct ksock_route *route; list_for_each_entry(route, &peer->ksnp_routes, ksnr_list) { if (route->ksnr_ipaddr == ipaddr) @@ -1026,7 +1026,7 @@ ksocknal_connecting(ksock_peer_t *peer, __u32 ipaddr) } int -ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route, +ksocknal_create_conn(lnet_ni_t *ni, struct ksock_route *route, struct socket *sock, int type) { rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock; @@ -1034,15 +1034,15 @@ ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route, lnet_process_id_t peerid; struct list_head *tmp; __u64 incarnation; - ksock_conn_t *conn; - ksock_conn_t *conn2; - ksock_peer_t *peer = NULL; - ksock_peer_t *peer2; - ksock_sched_t *sched; + struct ksock_conn *conn; + struct ksock_conn *conn2; + struct ksock_peer *peer = NULL; + struct ksock_peer *peer2; + struct ksock_sched *sched; ksock_hello_msg_t *hello; int cpt; - ksock_tx_t *tx; - ksock_tx_t *txtmp; + struct ksock_tx *tx; + struct ksock_tx *txtmp; int rc; int active; char *warn = NULL; @@ -1150,7 +1150,7 @@ ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route, write_lock_bh(global_lock); /* called with a ref on ni, so shutdown can't have started */ - LASSERT(!((ksock_net_t *) ni->ni_data)->ksnn_shutdown); + LASSERT(!((struct ksock_net *) ni->ni_data)->ksnn_shutdown); peer2 = ksocknal_find_peer_locked(ni, peerid); if (!peer2) { @@ -1233,7 +1233,7 @@ ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route, */ if (conn->ksnc_ipaddr != conn->ksnc_myipaddr) { list_for_each(tmp, &peer->ksnp_conns) { - conn2 = list_entry(tmp, ksock_conn_t, ksnc_list); + conn2 = list_entry(tmp, struct ksock_conn, ksnc_list); if (conn2->ksnc_ipaddr != conn->ksnc_ipaddr || conn2->ksnc_myipaddr != conn->ksnc_myipaddr || @@ -1273,7 +1273,7 @@ ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route, * continually create duplicate routes. */ list_for_each(tmp, &peer->ksnp_routes) { - route = list_entry(tmp, ksock_route_t, ksnr_list); + route = list_entry(tmp, struct ksock_route, ksnr_list); if (route->ksnr_ipaddr != conn->ksnc_ipaddr) continue; @@ -1432,16 +1432,16 @@ failed_0: } void -ksocknal_close_conn_locked(ksock_conn_t *conn, int error) +ksocknal_close_conn_locked(struct ksock_conn *conn, int error) { /* * This just does the immmediate housekeeping, and queues the * connection for the reaper to terminate. * Caller holds ksnd_global_lock exclusively in irq context */ - ksock_peer_t *peer = conn->ksnc_peer; - ksock_route_t *route; - ksock_conn_t *conn2; + struct ksock_peer *peer = conn->ksnc_peer; + struct ksock_route *route; + struct ksock_conn *conn2; struct list_head *tmp; LASSERT(!peer->ksnp_error); @@ -1459,7 +1459,7 @@ ksocknal_close_conn_locked(ksock_conn_t *conn, int error) conn2 = NULL; list_for_each(tmp, &peer->ksnp_conns) { - conn2 = list_entry(tmp, ksock_conn_t, ksnc_list); + conn2 = list_entry(tmp, struct ksock_conn, ksnc_list); if (conn2->ksnc_route == route && conn2->ksnc_type == conn->ksnc_type) @@ -1484,7 +1484,7 @@ ksocknal_close_conn_locked(ksock_conn_t *conn, int error) /* No more connections to this peer */ if (!list_empty(&peer->ksnp_tx_queue)) { - ksock_tx_t *tx; + struct ksock_tx *tx; LASSERT(conn->ksnc_proto == &ksocknal_protocol_v3x); @@ -1524,7 +1524,7 @@ ksocknal_close_conn_locked(ksock_conn_t *conn, int error) } void -ksocknal_peer_failed(ksock_peer_t *peer) +ksocknal_peer_failed(struct ksock_peer *peer) { int notify = 0; unsigned long last_alive = 0; @@ -1552,12 +1552,12 @@ ksocknal_peer_failed(ksock_peer_t *peer) } void -ksocknal_finalize_zcreq(ksock_conn_t *conn) +ksocknal_finalize_zcreq(struct ksock_conn *conn) { - ksock_peer_t *peer = conn->ksnc_peer; - ksock_tx_t *tx; - ksock_tx_t *temp; - ksock_tx_t *tmp; + struct ksock_peer *peer = conn->ksnc_peer; + struct ksock_tx *tx; + struct ksock_tx *temp; + struct ksock_tx *tmp; LIST_HEAD(zlist); /* @@ -1589,7 +1589,7 @@ ksocknal_finalize_zcreq(ksock_conn_t *conn) } void -ksocknal_terminate_conn(ksock_conn_t *conn) +ksocknal_terminate_conn(struct ksock_conn *conn) { /* * This gets called by the reaper (guaranteed thread context) to @@ -1597,8 +1597,8 @@ ksocknal_terminate_conn(ksock_conn_t *conn) * ksnc_refcount will eventually hit zero, and then the reaper will * destroy it. */ - ksock_peer_t *peer = conn->ksnc_peer; - ksock_sched_t *sched = conn->ksnc_scheduler; + struct ksock_peer *peer = conn->ksnc_peer; + struct ksock_sched *sched = conn->ksnc_scheduler; int failed = 0; LASSERT(conn->ksnc_closing); @@ -1656,7 +1656,7 @@ ksocknal_terminate_conn(ksock_conn_t *conn) } void -ksocknal_queue_zombie_conn(ksock_conn_t *conn) +ksocknal_queue_zombie_conn(struct ksock_conn *conn) { /* Queue the conn for the reaper to destroy */ @@ -1670,7 +1670,7 @@ ksocknal_queue_zombie_conn(ksock_conn_t *conn) } void -ksocknal_destroy_conn(ksock_conn_t *conn) +ksocknal_destroy_conn(struct ksock_conn *conn) { unsigned long last_rcv; @@ -1730,15 +1730,15 @@ ksocknal_destroy_conn(ksock_conn_t *conn) } int -ksocknal_close_peer_conns_locked(ksock_peer_t *peer, __u32 ipaddr, int why) +ksocknal_close_peer_conns_locked(struct ksock_peer *peer, __u32 ipaddr, int why) { - ksock_conn_t *conn; + struct ksock_conn *conn; struct list_head *ctmp; struct list_head *cnxt; int count = 0; list_for_each_safe(ctmp, cnxt, &peer->ksnp_conns) { - conn = list_entry(ctmp, ksock_conn_t, ksnc_list); + conn = list_entry(ctmp, struct ksock_conn, ksnc_list); if (!ipaddr || conn->ksnc_ipaddr == ipaddr) { count++; @@ -1750,9 +1750,9 @@ ksocknal_close_peer_conns_locked(ksock_peer_t *peer, __u32 ipaddr, int why) } int -ksocknal_close_conn_and_siblings(ksock_conn_t *conn, int why) +ksocknal_close_conn_and_siblings(struct ksock_conn *conn, int why) { - ksock_peer_t *peer = conn->ksnc_peer; + struct ksock_peer *peer = conn->ksnc_peer; __u32 ipaddr = conn->ksnc_ipaddr; int count; @@ -1768,7 +1768,7 @@ ksocknal_close_conn_and_siblings(ksock_conn_t *conn, int why) int ksocknal_close_matching_conns(lnet_process_id_t id, __u32 ipaddr) { - ksock_peer_t *peer; + struct ksock_peer *peer; struct list_head *ptmp; struct list_head *pnxt; int lo; @@ -1789,7 +1789,7 @@ ksocknal_close_matching_conns(lnet_process_id_t id, __u32 ipaddr) for (i = lo; i <= hi; i++) { list_for_each_safe(ptmp, pnxt, &ksocknal_data.ksnd_peers[i]) { - peer = list_entry(ptmp, ksock_peer_t, ksnp_list); + peer = list_entry(ptmp, struct ksock_peer, ksnp_list); if (!((id.nid == LNET_NID_ANY || id.nid == peer->ksnp_id.nid) && (id.pid == LNET_PID_ANY || id.pid == peer->ksnp_id.pid))) @@ -1844,7 +1844,7 @@ ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when) int connect = 1; unsigned long last_alive = 0; unsigned long now = cfs_time_current(); - ksock_peer_t *peer = NULL; + struct ksock_peer *peer = NULL; rwlock_t *glock = &ksocknal_data.ksnd_global_lock; lnet_process_id_t id = { .nid = nid, @@ -1856,11 +1856,11 @@ ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when) peer = ksocknal_find_peer_locked(ni, id); if (peer) { struct list_head *tmp; - ksock_conn_t *conn; + struct ksock_conn *conn; int bufnob; list_for_each(tmp, &peer->ksnp_conns) { - conn = list_entry(tmp, ksock_conn_t, ksnc_list); + conn = list_entry(tmp, struct ksock_conn, ksnc_list); bufnob = conn->ksnc_sock->sk->sk_wmem_queued; if (bufnob < conn->ksnc_tx_bufnob) { @@ -1902,12 +1902,12 @@ ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when) } static void -ksocknal_push_peer(ksock_peer_t *peer) +ksocknal_push_peer(struct ksock_peer *peer) { int index; int i; struct list_head *tmp; - ksock_conn_t *conn; + struct ksock_conn *conn; for (index = 0; ; index++) { read_lock(&ksocknal_data.ksnd_global_lock); @@ -1917,7 +1917,7 @@ ksocknal_push_peer(ksock_peer_t *peer) list_for_each(tmp, &peer->ksnp_conns) { if (i++ == index) { - conn = list_entry(tmp, ksock_conn_t, + conn = list_entry(tmp, struct ksock_conn, ksnc_list); ksocknal_conn_addref(conn); break; @@ -1954,7 +1954,7 @@ static int ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id) int peer_off; /* searching offset in peer hash table */ for (peer_off = 0; ; peer_off++) { - ksock_peer_t *peer; + struct ksock_peer *peer; int i = 0; read_lock(&ksocknal_data.ksnd_global_lock); @@ -1986,15 +1986,15 @@ static int ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id) static int ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask) { - ksock_net_t *net = ni->ni_data; - ksock_interface_t *iface; + struct ksock_net *net = ni->ni_data; + struct ksock_interface *iface; int rc; int i; int j; struct list_head *ptmp; - ksock_peer_t *peer; + struct ksock_peer *peer; struct list_head *rtmp; - ksock_route_t *route; + struct ksock_route *route; if (!ipaddress || !netmask) return -EINVAL; @@ -2017,7 +2017,7 @@ ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask) for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) { - peer = list_entry(ptmp, ksock_peer_t, + peer = list_entry(ptmp, struct ksock_peer, ksnp_list); for (j = 0; j < peer->ksnp_n_passive_ips; j++) @@ -2025,7 +2025,7 @@ ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask) iface->ksni_npeers++; list_for_each(rtmp, &peer->ksnp_routes) { - route = list_entry(rtmp, ksock_route_t, + route = list_entry(rtmp, struct ksock_route, ksnr_list); if (route->ksnr_myipaddr == ipaddress) @@ -2044,12 +2044,12 @@ ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask) } static void -ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr) +ksocknal_peer_del_interface_locked(struct ksock_peer *peer, __u32 ipaddr) { struct list_head *tmp; struct list_head *nxt; - ksock_route_t *route; - ksock_conn_t *conn; + struct ksock_route *route; + struct ksock_conn *conn; int i; int j; @@ -2063,7 +2063,7 @@ ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr) } list_for_each_safe(tmp, nxt, &peer->ksnp_routes) { - route = list_entry(tmp, ksock_route_t, ksnr_list); + route = list_entry(tmp, struct ksock_route, ksnr_list); if (route->ksnr_myipaddr != ipaddr) continue; @@ -2077,7 +2077,7 @@ ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr) } list_for_each_safe(tmp, nxt, &peer->ksnp_conns) { - conn = list_entry(tmp, ksock_conn_t, ksnc_list); + conn = list_entry(tmp, struct ksock_conn, ksnc_list); if (conn->ksnc_myipaddr == ipaddr) ksocknal_close_conn_locked(conn, 0); @@ -2087,11 +2087,11 @@ ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr) static int ksocknal_del_interface(lnet_ni_t *ni, __u32 ipaddress) { - ksock_net_t *net = ni->ni_data; + struct ksock_net *net = ni->ni_data; int rc = -ENOENT; struct list_head *tmp; struct list_head *nxt; - ksock_peer_t *peer; + struct ksock_peer *peer; __u32 this_ip; int i; int j; @@ -2115,7 +2115,7 @@ ksocknal_del_interface(lnet_ni_t *ni, __u32 ipaddress) for (j = 0; j < ksocknal_data.ksnd_peer_hash_size; j++) { list_for_each_safe(tmp, nxt, &ksocknal_data.ksnd_peers[j]) { - peer = list_entry(tmp, ksock_peer_t, ksnp_list); + peer = list_entry(tmp, struct ksock_peer, ksnp_list); if (peer->ksnp_ni != ni) continue; @@ -2139,8 +2139,8 @@ ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg) switch (cmd) { case IOC_LIBCFS_GET_INTERFACE: { - ksock_net_t *net = ni->ni_data; - ksock_interface_t *iface; + struct ksock_net *net = ni->ni_data; + struct ksock_interface *iface; read_lock(&ksocknal_data.ksnd_global_lock); @@ -2209,7 +2209,7 @@ ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg) int txmem; int rxmem; int nagle; - ksock_conn_t *conn = ksocknal_get_conn_by_idx(ni, data->ioc_count); + struct ksock_conn *conn = ksocknal_get_conn_by_idx(ni, data->ioc_count); if (!conn) return -ENOENT; @@ -2284,8 +2284,8 @@ ksocknal_free_buffers(void) if (!list_empty(&ksocknal_data.ksnd_idle_noop_txs)) { struct list_head zlist; - ksock_tx_t *tx; - ksock_tx_t *temp; + struct ksock_tx *tx; + struct ksock_tx *temp; list_add(&zlist, &ksocknal_data.ksnd_idle_noop_txs); list_del_init(&ksocknal_data.ksnd_idle_noop_txs); @@ -2304,7 +2304,7 @@ static void ksocknal_base_shutdown(void) { struct ksock_sched_info *info; - ksock_sched_t *sched; + struct ksock_sched *sched; int i; int j; @@ -2446,7 +2446,7 @@ ksocknal_base_startup(void) goto failed; cfs_percpt_for_each(info, i, ksocknal_data.ksnd_sched_info) { - ksock_sched_t *sched; + struct ksock_sched *sched; int nthrs; nthrs = cfs_cpt_weight(lnet_cpt_table(), i); @@ -2534,7 +2534,7 @@ ksocknal_base_startup(void) static void ksocknal_debug_peerhash(lnet_ni_t *ni) { - ksock_peer_t *peer = NULL; + struct ksock_peer *peer = NULL; struct list_head *tmp; int i; @@ -2542,7 +2542,7 @@ ksocknal_debug_peerhash(lnet_ni_t *ni) for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) { list_for_each(tmp, &ksocknal_data.ksnd_peers[i]) { - peer = list_entry(tmp, ksock_peer_t, ksnp_list); + peer = list_entry(tmp, struct ksock_peer, ksnp_list); if (peer->ksnp_ni == ni) break; @@ -2552,8 +2552,8 @@ ksocknal_debug_peerhash(lnet_ni_t *ni) } if (peer) { - ksock_route_t *route; - ksock_conn_t *conn; + struct ksock_route *route; + struct ksock_conn *conn; CWARN("Active peer on shutdown: %s, ref %d, scnt %d, closing %d, accepting %d, err %d, zcookie %llu, txq %d, zc_req %d\n", libcfs_id2str(peer->ksnp_id), @@ -2565,7 +2565,7 @@ ksocknal_debug_peerhash(lnet_ni_t *ni) !list_empty(&peer->ksnp_zc_req_list)); list_for_each(tmp, &peer->ksnp_routes) { - route = list_entry(tmp, ksock_route_t, ksnr_list); + route = list_entry(tmp, struct ksock_route, ksnr_list); CWARN("Route: ref %d, schd %d, conn %d, cnted %d, del %d\n", atomic_read(&route->ksnr_refcount), route->ksnr_scheduled, route->ksnr_connecting, @@ -2573,7 +2573,7 @@ ksocknal_debug_peerhash(lnet_ni_t *ni) } list_for_each(tmp, &peer->ksnp_conns) { - conn = list_entry(tmp, ksock_conn_t, ksnc_list); + conn = list_entry(tmp, struct ksock_conn, ksnc_list); CWARN("Conn: ref %d, sref %d, t %d, c %d\n", atomic_read(&conn->ksnc_conn_refcount), atomic_read(&conn->ksnc_sock_refcount), @@ -2587,7 +2587,7 @@ ksocknal_debug_peerhash(lnet_ni_t *ni) void ksocknal_shutdown(lnet_ni_t *ni) { - ksock_net_t *net = ni->ni_data; + struct ksock_net *net = ni->ni_data; int i; lnet_process_id_t anyid = {0}; @@ -2637,7 +2637,7 @@ ksocknal_shutdown(lnet_ni_t *ni) } static int -ksocknal_enumerate_interfaces(ksock_net_t *net) +ksocknal_enumerate_interfaces(struct ksock_net *net) { char **names; int i; @@ -2694,7 +2694,7 @@ ksocknal_enumerate_interfaces(ksock_net_t *net) } static int -ksocknal_search_new_ipif(ksock_net_t *net) +ksocknal_search_new_ipif(struct ksock_net *net) { int new_ipif = 0; int i; @@ -2703,7 +2703,7 @@ ksocknal_search_new_ipif(ksock_net_t *net) char *ifnam = &net->ksnn_interfaces[i].ksni_name[0]; char *colon = strchr(ifnam, ':'); int found = 0; - ksock_net_t *tmp; + struct ksock_net *tmp; int j; if (colon) /* ignore alias device */ @@ -2760,7 +2760,7 @@ ksocknal_start_schedulers(struct ksock_sched_info *info) for (i = 0; i < nthrs; i++) { long id; char name[20]; - ksock_sched_t *sched; + struct ksock_sched *sched; id = KSOCK_THREAD_ID(info->ksi_cpt, info->ksi_nthreads + i); sched = &info->ksi_scheds[KSOCK_THREAD_SID(id)]; @@ -2782,7 +2782,7 @@ ksocknal_start_schedulers(struct ksock_sched_info *info) } static int -ksocknal_net_start_threads(ksock_net_t *net, __u32 *cpts, int ncpts) +ksocknal_net_start_threads(struct ksock_net *net, __u32 *cpts, int ncpts) { int newif = ksocknal_search_new_ipif(net); int rc; @@ -2810,7 +2810,7 @@ ksocknal_net_start_threads(ksock_net_t *net, __u32 *cpts, int ncpts) int ksocknal_startup(lnet_ni_t *ni) { - ksock_net_t *net; + struct ksock_net *net; int rc; int i; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index a60d72f..a56632b 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -77,8 +77,7 @@ struct ksock_sched_info; -typedef struct /* per scheduler state */ -{ +struct ksock_sched { /* per scheduler state */ spinlock_t kss_lock; /* serialise */ struct list_head kss_rx_conns; /* conn waiting to be read */ struct list_head kss_tx_conns; /* conn waiting to be written */ @@ -89,13 +88,13 @@ typedef struct /* per scheduler state */ struct ksock_sched_info *kss_info; /* owner of it */ struct page *kss_rx_scratch_pgs[LNET_MAX_IOV]; struct kvec kss_scratch_iov[LNET_MAX_IOV]; -} ksock_sched_t; +}; struct ksock_sched_info { int ksi_nthreads_max; /* max allowed threads */ int ksi_nthreads; /* number of threads */ int ksi_cpt; /* CPT id */ - ksock_sched_t *ksi_scheds; /* array of schedulers */ + struct ksock_sched *ksi_scheds; /* array of schedulers */ }; #define KSOCK_CPT_SHIFT 16 @@ -103,16 +102,15 @@ struct ksock_sched_info { #define KSOCK_THREAD_CPT(id) ((id) >> KSOCK_CPT_SHIFT) #define KSOCK_THREAD_SID(id) ((id) & ((1UL << KSOCK_CPT_SHIFT) - 1)) -typedef struct /* in-use interface */ -{ +struct ksock_interface { /* in-use interface */ __u32 ksni_ipaddr; /* interface's IP address */ __u32 ksni_netmask; /* interface's network mask */ int ksni_nroutes; /* # routes using (active) */ int ksni_npeers; /* # peers using (passive) */ char ksni_name[IFNAMSIZ]; /* interface name */ -} ksock_interface_t; +}; -typedef struct { +struct ksock_tunables { int *ksnd_timeout; /* "stuck" socket timeout * (seconds) */ int *ksnd_nscheds; /* # scheduler threads in each @@ -155,24 +153,24 @@ typedef struct { * Chelsio TOE) */ int *ksnd_zc_recv_min_nfrags; /* minimum # of fragments to * enable ZC receive */ -} ksock_tunables_t; +}; -typedef struct { +struct ksock_net { __u64 ksnn_incarnation; /* my epoch */ spinlock_t ksnn_lock; /* serialise */ struct list_head ksnn_list; /* chain on global list */ int ksnn_npeers; /* # peers */ int ksnn_shutdown; /* shutting down? */ int ksnn_ninterfaces; /* IP interfaces */ - ksock_interface_t ksnn_interfaces[LNET_MAX_INTERFACES]; -} ksock_net_t; + struct ksock_interface ksnn_interfaces[LNET_MAX_INTERFACES]; +}; /** connd timeout */ #define SOCKNAL_CONND_TIMEOUT 120 /** reserved thread for accepting & creating new connd */ #define SOCKNAL_CONND_RESV 1 -typedef struct { +struct ksock_nal_data { int ksnd_init; /* initialisation state */ int ksnd_nnets; /* # networks set up */ @@ -229,7 +227,7 @@ typedef struct { spinlock_t ksnd_tx_lock; /* serialise, g_lock * unsafe */ -} ksock_nal_data_t; +}; #define SOCKNAL_INIT_NOTHING 0 #define SOCKNAL_INIT_DATA 1 @@ -250,8 +248,7 @@ struct ksock_peer; /* forward ref */ struct ksock_route; /* forward ref */ struct ksock_proto; /* forward ref */ -typedef struct /* transmit packet */ -{ +struct ksock_tx { /* transmit packet */ struct list_head tx_list; /* queue on conn for transmission etc */ struct list_head tx_zc_list; /* queue on peer for ZC request */ @@ -281,20 +278,20 @@ typedef struct /* transmit packet */ struct kvec iov[1]; /* virt hdr + payload */ } virt; } tx_frags; -} ksock_tx_t; +}; -#define KSOCK_NOOP_TX_SIZE (offsetof(ksock_tx_t, tx_frags.paged.kiov[0])) +#define KSOCK_NOOP_TX_SIZE (offsetof(struct ksock_tx, tx_frags.paged.kiov[0])) -/* network zero copy callback descriptor embedded in ksock_tx_t */ +/* network zero copy callback descriptor embedded in struct ksock_tx */ /* * space for the rx frag descriptors; we either read a single contiguous * header, or up to LNET_MAX_IOV frags of payload of either type. */ -typedef union { +union ksock_rxiovspace { struct kvec iov[LNET_MAX_IOV]; lnet_kiov_t kiov[LNET_MAX_IOV]; -} ksock_rxiovspace_t; +}; #define SOCKNAL_RX_KSM_HEADER 1 /* reading ksock message header */ #define SOCKNAL_RX_LNET_HEADER 2 /* reading lnet message header */ @@ -303,7 +300,7 @@ typedef union { #define SOCKNAL_RX_LNET_PAYLOAD 5 /* reading lnet payload (to deliver here) */ #define SOCKNAL_RX_SLOP 6 /* skipping body */ -typedef struct ksock_conn { +struct ksock_conn { struct ksock_peer *ksnc_peer; /* owning peer */ struct ksock_route *ksnc_route; /* owning route */ struct list_head ksnc_list; /* stash on peer's conn list */ @@ -314,8 +311,8 @@ typedef struct ksock_conn { * write_space() callback */ atomic_t ksnc_conn_refcount;/* conn refcount */ atomic_t ksnc_sock_refcount;/* sock refcount */ - ksock_sched_t *ksnc_scheduler; /* who schedules this connection - */ + struct ksock_sched *ksnc_scheduler; /* who schedules this connection + */ __u32 ksnc_myipaddr; /* my IP */ __u32 ksnc_ipaddr; /* peer's IP */ int ksnc_port; /* peer's port */ @@ -341,7 +338,7 @@ typedef struct ksock_conn { struct kvec *ksnc_rx_iov; /* the iovec frags */ int ksnc_rx_nkiov; /* # page frags */ lnet_kiov_t *ksnc_rx_kiov; /* the page frags */ - ksock_rxiovspace_t ksnc_rx_iov_space; /* space for frag descriptors */ + union ksock_rxiovspace ksnc_rx_iov_space; /* space for frag descriptors */ __u32 ksnc_rx_csum; /* partial checksum for incoming * data */ void *ksnc_cookie; /* rx lnet_finalize passthru arg @@ -357,7 +354,7 @@ typedef struct ksock_conn { struct list_head ksnc_tx_list; /* where I enq waiting for output * space */ struct list_head ksnc_tx_queue; /* packets waiting to be sent */ - ksock_tx_t *ksnc_tx_carrier; /* next TX that can carry a LNet + struct ksock_tx *ksnc_tx_carrier; /* next TX that can carry a LNet * message or ZC-ACK */ unsigned long ksnc_tx_deadline; /* when (in jiffies) tx times out */ @@ -367,9 +364,9 @@ typedef struct ksock_conn { int ksnc_tx_scheduled; /* being progressed */ unsigned long ksnc_tx_last_post; /* time stamp of the last posted * TX */ -} ksock_conn_t; +}; -typedef struct ksock_route { +struct ksock_route { struct list_head ksnr_list; /* chain on peer route list */ struct list_head ksnr_connd_list; /* chain on ksnr_connd_routes */ struct ksock_peer *ksnr_peer; /* owning peer */ @@ -389,11 +386,11 @@ typedef struct ksock_route { unsigned int ksnr_share_count; /* created explicitly? */ int ksnr_conn_count; /* # conns established by this * route */ -} ksock_route_t; +}; #define SOCKNAL_KEEPALIVE_PING 1 /* cookie for keepalive ping */ -typedef struct ksock_peer { +struct ksock_peer { struct list_head ksnp_list; /* stash on global peer list */ unsigned long ksnp_last_alive; /* when (in jiffies) I was last * alive */ @@ -420,49 +417,49 @@ typedef struct ksock_peer { /* preferred local interfaces */ __u32 ksnp_passive_ips[LNET_MAX_INTERFACES]; -} ksock_peer_t; +}; -typedef struct ksock_connreq { +struct ksock_connreq { struct list_head ksncr_list; /* stash on ksnd_connd_connreqs */ lnet_ni_t *ksncr_ni; /* chosen NI */ struct socket *ksncr_sock; /* accepted socket */ -} ksock_connreq_t; +}; -extern ksock_nal_data_t ksocknal_data; -extern ksock_tunables_t ksocknal_tunables; +extern struct ksock_nal_data ksocknal_data; +extern struct ksock_tunables ksocknal_tunables; #define SOCKNAL_MATCH_NO 0 /* TX can't match type of connection */ #define SOCKNAL_MATCH_YES 1 /* TX matches type of connection */ #define SOCKNAL_MATCH_MAY 2 /* TX can be sent on the connection, but not * preferred */ -typedef struct ksock_proto { +struct ksock_proto { /* version number of protocol */ int pro_version; /* handshake function */ - int (*pro_send_hello)(ksock_conn_t *, ksock_hello_msg_t *); + int (*pro_send_hello)(struct ksock_conn *, ksock_hello_msg_t *); /* handshake function */ - int (*pro_recv_hello)(ksock_conn_t *, ksock_hello_msg_t *, int); + int (*pro_recv_hello)(struct ksock_conn *, ksock_hello_msg_t *, int); /* message pack */ - void (*pro_pack)(ksock_tx_t *); + void (*pro_pack)(struct ksock_tx *); /* message unpack */ void (*pro_unpack)(ksock_msg_t *); /* queue tx on the connection */ - ksock_tx_t *(*pro_queue_tx_msg)(ksock_conn_t *, ksock_tx_t *); + struct ksock_tx *(*pro_queue_tx_msg)(struct ksock_conn *, struct ksock_tx *); /* queue ZC ack on the connection */ - int (*pro_queue_tx_zcack)(ksock_conn_t *, ksock_tx_t *, __u64); + int (*pro_queue_tx_zcack)(struct ksock_conn *, struct ksock_tx *, __u64); /* handle ZC request */ - int (*pro_handle_zcreq)(ksock_conn_t *, __u64, int); + int (*pro_handle_zcreq)(struct ksock_conn *, __u64, int); /* handle ZC ACK */ - int (*pro_handle_zcack)(ksock_conn_t *, __u64, __u64); + int (*pro_handle_zcack)(struct ksock_conn *, __u64, __u64); /* * msg type matches the connection type: @@ -471,12 +468,12 @@ typedef struct ksock_proto { * return MATCH_YES : matching type * return MATCH_MAY : can be backup */ - int (*pro_match_tx)(ksock_conn_t *, ksock_tx_t *, int); -} ksock_proto_t; + int (*pro_match_tx)(struct ksock_conn *, struct ksock_tx *, int); +}; -extern ksock_proto_t ksocknal_protocol_v1x; -extern ksock_proto_t ksocknal_protocol_v2x; -extern ksock_proto_t ksocknal_protocol_v3x; +extern struct ksock_proto ksocknal_protocol_v1x; +extern struct ksock_proto ksocknal_protocol_v2x; +extern struct ksock_proto ksocknal_protocol_v3x; #define KSOCK_PROTO_V1_MAJOR LNET_PROTO_TCP_VERSION_MAJOR #define KSOCK_PROTO_V1_MINOR LNET_PROTO_TCP_VERSION_MINOR @@ -517,17 +514,17 @@ ksocknal_nid2peerlist(lnet_nid_t nid) } static inline void -ksocknal_conn_addref(ksock_conn_t *conn) +ksocknal_conn_addref(struct ksock_conn *conn) { LASSERT(atomic_read(&conn->ksnc_conn_refcount) > 0); atomic_inc(&conn->ksnc_conn_refcount); } -void ksocknal_queue_zombie_conn(ksock_conn_t *conn); -void ksocknal_finalize_zcreq(ksock_conn_t *conn); +void ksocknal_queue_zombie_conn(struct ksock_conn *conn); +void ksocknal_finalize_zcreq(struct ksock_conn *conn); static inline void -ksocknal_conn_decref(ksock_conn_t *conn) +ksocknal_conn_decref(struct ksock_conn *conn) { LASSERT(atomic_read(&conn->ksnc_conn_refcount) > 0); if (atomic_dec_and_test(&conn->ksnc_conn_refcount)) @@ -535,7 +532,7 @@ ksocknal_conn_decref(ksock_conn_t *conn) } static inline int -ksocknal_connsock_addref(ksock_conn_t *conn) +ksocknal_connsock_addref(struct ksock_conn *conn) { int rc = -ESHUTDOWN; @@ -551,7 +548,7 @@ ksocknal_connsock_addref(ksock_conn_t *conn) } static inline void -ksocknal_connsock_decref(ksock_conn_t *conn) +ksocknal_connsock_decref(struct ksock_conn *conn) { LASSERT(atomic_read(&conn->ksnc_sock_refcount) > 0); if (atomic_dec_and_test(&conn->ksnc_sock_refcount)) { @@ -563,17 +560,17 @@ ksocknal_connsock_decref(ksock_conn_t *conn) } static inline void -ksocknal_tx_addref(ksock_tx_t *tx) +ksocknal_tx_addref(struct ksock_tx *tx) { LASSERT(atomic_read(&tx->tx_refcount) > 0); atomic_inc(&tx->tx_refcount); } -void ksocknal_tx_prep(ksock_conn_t *, ksock_tx_t *tx); -void ksocknal_tx_done(lnet_ni_t *ni, ksock_tx_t *tx); +void ksocknal_tx_prep(struct ksock_conn *, struct ksock_tx *tx); +void ksocknal_tx_done(lnet_ni_t *ni, struct ksock_tx *tx); static inline void -ksocknal_tx_decref(ksock_tx_t *tx) +ksocknal_tx_decref(struct ksock_tx *tx) { LASSERT(atomic_read(&tx->tx_refcount) > 0); if (atomic_dec_and_test(&tx->tx_refcount)) @@ -581,16 +578,16 @@ ksocknal_tx_decref(ksock_tx_t *tx) } static inline void -ksocknal_route_addref(ksock_route_t *route) +ksocknal_route_addref(struct ksock_route *route) { LASSERT(atomic_read(&route->ksnr_refcount) > 0); atomic_inc(&route->ksnr_refcount); } -void ksocknal_destroy_route(ksock_route_t *route); +void ksocknal_destroy_route(struct ksock_route *route); static inline void -ksocknal_route_decref(ksock_route_t *route) +ksocknal_route_decref(struct ksock_route *route) { LASSERT(atomic_read(&route->ksnr_refcount) > 0); if (atomic_dec_and_test(&route->ksnr_refcount)) @@ -598,16 +595,16 @@ ksocknal_route_decref(ksock_route_t *route) } static inline void -ksocknal_peer_addref(ksock_peer_t *peer) +ksocknal_peer_addref(struct ksock_peer *peer) { LASSERT(atomic_read(&peer->ksnp_refcount) > 0); atomic_inc(&peer->ksnp_refcount); } -void ksocknal_destroy_peer(ksock_peer_t *peer); +void ksocknal_destroy_peer(struct ksock_peer *peer); static inline void -ksocknal_peer_decref(ksock_peer_t *peer) +ksocknal_peer_decref(struct ksock_peer *peer) { LASSERT(atomic_read(&peer->ksnp_refcount) > 0); if (atomic_dec_and_test(&peer->ksnp_refcount)) @@ -625,71 +622,71 @@ int ksocknal_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int ksocknal_accept(lnet_ni_t *ni, struct socket *sock); int ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip, int port); -ksock_peer_t *ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id); -ksock_peer_t *ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id); -void ksocknal_peer_failed(ksock_peer_t *peer); -int ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route, +struct ksock_peer *ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id); +struct ksock_peer *ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id); +void ksocknal_peer_failed(struct ksock_peer *peer); +int ksocknal_create_conn(lnet_ni_t *ni, struct ksock_route *route, struct socket *sock, int type); -void ksocknal_close_conn_locked(ksock_conn_t *conn, int why); -void ksocknal_terminate_conn(ksock_conn_t *conn); -void ksocknal_destroy_conn(ksock_conn_t *conn); -int ksocknal_close_peer_conns_locked(ksock_peer_t *peer, +void ksocknal_close_conn_locked(struct ksock_conn *conn, int why); +void ksocknal_terminate_conn(struct ksock_conn *conn); +void ksocknal_destroy_conn(struct ksock_conn *conn); +int ksocknal_close_peer_conns_locked(struct ksock_peer *peer, __u32 ipaddr, int why); -int ksocknal_close_conn_and_siblings(ksock_conn_t *conn, int why); +int ksocknal_close_conn_and_siblings(struct ksock_conn *conn, int why); int ksocknal_close_matching_conns(lnet_process_id_t id, __u32 ipaddr); -ksock_conn_t *ksocknal_find_conn_locked(ksock_peer_t *peer, - ksock_tx_t *tx, int nonblk); +struct ksock_conn *ksocknal_find_conn_locked(struct ksock_peer *peer, + struct ksock_tx *tx, int nonblk); -int ksocknal_launch_packet(lnet_ni_t *ni, ksock_tx_t *tx, +int ksocknal_launch_packet(lnet_ni_t *ni, struct ksock_tx *tx, lnet_process_id_t id); -ksock_tx_t *ksocknal_alloc_tx(int type, int size); -void ksocknal_free_tx(ksock_tx_t *tx); -ksock_tx_t *ksocknal_alloc_tx_noop(__u64 cookie, int nonblk); -void ksocknal_next_tx_carrier(ksock_conn_t *conn); -void ksocknal_queue_tx_locked(ksock_tx_t *tx, ksock_conn_t *conn); +struct ksock_tx *ksocknal_alloc_tx(int type, int size); +void ksocknal_free_tx(struct ksock_tx *tx); +struct ksock_tx *ksocknal_alloc_tx_noop(__u64 cookie, int nonblk); +void ksocknal_next_tx_carrier(struct ksock_conn *conn); +void ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn); void ksocknal_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int error); void ksocknal_notify(lnet_ni_t *ni, lnet_nid_t gw_nid, int alive); void ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when); int ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name); void ksocknal_thread_fini(void); -void ksocknal_launch_all_connections_locked(ksock_peer_t *peer); -ksock_route_t *ksocknal_find_connectable_route_locked(ksock_peer_t *peer); -ksock_route_t *ksocknal_find_connecting_route_locked(ksock_peer_t *peer); -int ksocknal_new_packet(ksock_conn_t *conn, int skip); +void ksocknal_launch_all_connections_locked(struct ksock_peer *peer); +struct ksock_route *ksocknal_find_connectable_route_locked(struct ksock_peer *peer); +struct ksock_route *ksocknal_find_connecting_route_locked(struct ksock_peer *peer); +int ksocknal_new_packet(struct ksock_conn *conn, int skip); int ksocknal_scheduler(void *arg); int ksocknal_connd(void *arg); int ksocknal_reaper(void *arg); -int ksocknal_send_hello(lnet_ni_t *ni, ksock_conn_t *conn, +int ksocknal_send_hello(lnet_ni_t *ni, struct ksock_conn *conn, lnet_nid_t peer_nid, ksock_hello_msg_t *hello); -int ksocknal_recv_hello(lnet_ni_t *ni, ksock_conn_t *conn, +int ksocknal_recv_hello(lnet_ni_t *ni, struct ksock_conn *conn, ksock_hello_msg_t *hello, lnet_process_id_t *id, __u64 *incarnation); -void ksocknal_read_callback(ksock_conn_t *conn); -void ksocknal_write_callback(ksock_conn_t *conn); - -int ksocknal_lib_zc_capable(ksock_conn_t *conn); -void ksocknal_lib_save_callback(struct socket *sock, ksock_conn_t *conn); -void ksocknal_lib_set_callback(struct socket *sock, ksock_conn_t *conn); -void ksocknal_lib_reset_callback(struct socket *sock, ksock_conn_t *conn); -void ksocknal_lib_push_conn(ksock_conn_t *conn); -int ksocknal_lib_get_conn_addrs(ksock_conn_t *conn); +void ksocknal_read_callback(struct ksock_conn *conn); +void ksocknal_write_callback(struct ksock_conn *conn); + +int ksocknal_lib_zc_capable(struct ksock_conn *conn); +void ksocknal_lib_save_callback(struct socket *sock, struct ksock_conn *conn); +void ksocknal_lib_set_callback(struct socket *sock, struct ksock_conn *conn); +void ksocknal_lib_reset_callback(struct socket *sock, struct ksock_conn *conn); +void ksocknal_lib_push_conn(struct ksock_conn *conn); +int ksocknal_lib_get_conn_addrs(struct ksock_conn *conn); int ksocknal_lib_setup_sock(struct socket *so); -int ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx); -int ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx); -void ksocknal_lib_eager_ack(ksock_conn_t *conn); -int ksocknal_lib_recv_iov(ksock_conn_t *conn); -int ksocknal_lib_recv_kiov(ksock_conn_t *conn); -int ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, +int ksocknal_lib_send_iov(struct ksock_conn *conn, struct ksock_tx *tx); +int ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx); +void ksocknal_lib_eager_ack(struct ksock_conn *conn); +int ksocknal_lib_recv_iov(struct ksock_conn *conn); +int ksocknal_lib_recv_kiov(struct ksock_conn *conn); +int ksocknal_lib_get_conn_tunables(struct ksock_conn *conn, int *txmem, int *rxmem, int *nagle); -void ksocknal_read_callback(ksock_conn_t *conn); -void ksocknal_write_callback(ksock_conn_t *conn); +void ksocknal_read_callback(struct ksock_conn *conn); +void ksocknal_write_callback(struct ksock_conn *conn); int ksocknal_tunables_init(void); -void ksocknal_lib_csum_tx(ksock_tx_t *tx); +void ksocknal_lib_csum_tx(struct ksock_tx *tx); -int ksocknal_lib_memory_pressure(ksock_conn_t *conn); +int ksocknal_lib_memory_pressure(struct ksock_conn *conn); int ksocknal_lib_bind_thread_to_cpu(int id); #endif /* _SOCKLND_SOCKLND_H_ */ diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 976fd78..e63d29b 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -23,10 +23,10 @@ #include "socklnd.h" -ksock_tx_t * +struct ksock_tx * ksocknal_alloc_tx(int type, int size) { - ksock_tx_t *tx = NULL; + struct ksock_tx *tx = NULL; if (type == KSOCK_MSG_NOOP) { LASSERT(size == KSOCK_NOOP_TX_SIZE); @@ -36,7 +36,7 @@ ksocknal_alloc_tx(int type, int size) if (!list_empty(&ksocknal_data.ksnd_idle_noop_txs)) { tx = list_entry(ksocknal_data.ksnd_idle_noop_txs. \ - next, ksock_tx_t, tx_list); + next, struct ksock_tx, tx_list); LASSERT(tx->tx_desc_size == size); list_del(&tx->tx_list); } @@ -61,10 +61,10 @@ ksocknal_alloc_tx(int type, int size) return tx; } -ksock_tx_t * +struct ksock_tx * ksocknal_alloc_tx_noop(__u64 cookie, int nonblk) { - ksock_tx_t *tx; + struct ksock_tx *tx; tx = ksocknal_alloc_tx(KSOCK_MSG_NOOP, KSOCK_NOOP_TX_SIZE); if (!tx) { @@ -87,7 +87,7 @@ ksocknal_alloc_tx_noop(__u64 cookie, int nonblk) } void -ksocknal_free_tx(ksock_tx_t *tx) +ksocknal_free_tx(struct ksock_tx *tx) { atomic_dec(&ksocknal_data.ksnd_nactive_txs); @@ -104,7 +104,7 @@ ksocknal_free_tx(ksock_tx_t *tx) } static int -ksocknal_send_iov(ksock_conn_t *conn, ksock_tx_t *tx) +ksocknal_send_iov(struct ksock_conn *conn, struct ksock_tx *tx) { struct kvec *iov = tx->tx_iov; int nob; @@ -141,7 +141,7 @@ ksocknal_send_iov(ksock_conn_t *conn, ksock_tx_t *tx) } static int -ksocknal_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx) +ksocknal_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx) { lnet_kiov_t *kiov = tx->tx_kiov; int nob; @@ -179,7 +179,7 @@ ksocknal_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx) } static int -ksocknal_transmit(ksock_conn_t *conn, ksock_tx_t *tx) +ksocknal_transmit(struct ksock_conn *conn, struct ksock_tx *tx) { int rc; int bufnob; @@ -247,7 +247,7 @@ ksocknal_transmit(ksock_conn_t *conn, ksock_tx_t *tx) } static int -ksocknal_recv_iov(ksock_conn_t *conn) +ksocknal_recv_iov(struct ksock_conn *conn) { struct kvec *iov = conn->ksnc_rx_iov; int nob; @@ -294,7 +294,7 @@ ksocknal_recv_iov(ksock_conn_t *conn) } static int -ksocknal_recv_kiov(ksock_conn_t *conn) +ksocknal_recv_kiov(struct ksock_conn *conn) { lnet_kiov_t *kiov = conn->ksnc_rx_kiov; int nob; @@ -341,7 +341,7 @@ ksocknal_recv_kiov(ksock_conn_t *conn) } static int -ksocknal_receive(ksock_conn_t *conn) +ksocknal_receive(struct ksock_conn *conn) { /* * Return 1 on success, 0 on EOF, < 0 on error. @@ -391,7 +391,7 @@ ksocknal_receive(ksock_conn_t *conn) } void -ksocknal_tx_done(lnet_ni_t *ni, ksock_tx_t *tx) +ksocknal_tx_done(lnet_ni_t *ni, struct ksock_tx *tx) { lnet_msg_t *lnetmsg = tx->tx_lnetmsg; int rc = (!tx->tx_resid && !tx->tx_zc_aborted) ? 0 : -EIO; @@ -412,10 +412,10 @@ ksocknal_tx_done(lnet_ni_t *ni, ksock_tx_t *tx) void ksocknal_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int error) { - ksock_tx_t *tx; + struct ksock_tx *tx; while (!list_empty(txlist)) { - tx = list_entry(txlist->next, ksock_tx_t, tx_list); + tx = list_entry(txlist->next, struct ksock_tx, tx_list); if (error && tx->tx_lnetmsg) { CNETERR("Deleting packet type %d len %d %s->%s\n", @@ -435,10 +435,10 @@ ksocknal_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int error) } static void -ksocknal_check_zc_req(ksock_tx_t *tx) +ksocknal_check_zc_req(struct ksock_tx *tx) { - ksock_conn_t *conn = tx->tx_conn; - ksock_peer_t *peer = conn->ksnc_peer; + struct ksock_conn *conn = tx->tx_conn; + struct ksock_peer *peer = conn->ksnc_peer; /* * Set tx_msg.ksm_zc_cookies[0] to a unique non-zero cookie and add tx @@ -482,9 +482,9 @@ ksocknal_check_zc_req(ksock_tx_t *tx) } static void -ksocknal_uncheck_zc_req(ksock_tx_t *tx) +ksocknal_uncheck_zc_req(struct ksock_tx *tx) { - ksock_peer_t *peer = tx->tx_conn->ksnc_peer; + struct ksock_peer *peer = tx->tx_conn->ksnc_peer; LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP); LASSERT(tx->tx_zc_capable); @@ -508,7 +508,7 @@ ksocknal_uncheck_zc_req(ksock_tx_t *tx) } static int -ksocknal_process_transmit(ksock_conn_t *conn, ksock_tx_t *tx) +ksocknal_process_transmit(struct ksock_conn *conn, struct ksock_tx *tx) { int rc; @@ -583,7 +583,7 @@ ksocknal_process_transmit(ksock_conn_t *conn, ksock_tx_t *tx) } static void -ksocknal_launch_connection_locked(ksock_route_t *route) +ksocknal_launch_connection_locked(struct ksock_route *route) { /* called holding write lock on ksnd_global_lock */ @@ -604,9 +604,9 @@ ksocknal_launch_connection_locked(ksock_route_t *route) } void -ksocknal_launch_all_connections_locked(ksock_peer_t *peer) +ksocknal_launch_all_connections_locked(struct ksock_peer *peer) { - ksock_route_t *route; + struct ksock_route *route; /* called holding write lock on ksnd_global_lock */ for (;;) { @@ -619,18 +619,18 @@ ksocknal_launch_all_connections_locked(ksock_peer_t *peer) } } -ksock_conn_t * -ksocknal_find_conn_locked(ksock_peer_t *peer, ksock_tx_t *tx, int nonblk) +struct ksock_conn * +ksocknal_find_conn_locked(struct ksock_peer *peer, struct ksock_tx *tx, int nonblk) { struct list_head *tmp; - ksock_conn_t *conn; - ksock_conn_t *typed = NULL; - ksock_conn_t *fallback = NULL; + struct ksock_conn *conn; + struct ksock_conn *typed = NULL; + struct ksock_conn *fallback = NULL; int tnob = 0; int fnob = 0; list_for_each(tmp, &peer->ksnp_conns) { - ksock_conn_t *c = list_entry(tmp, ksock_conn_t, ksnc_list); + struct ksock_conn *c = list_entry(tmp, struct ksock_conn, ksnc_list); int nob = atomic_read(&c->ksnc_tx_nob) + c->ksnc_sock->sk->sk_wmem_queued; int rc; @@ -677,7 +677,7 @@ ksocknal_find_conn_locked(ksock_peer_t *peer, ksock_tx_t *tx, int nonblk) } void -ksocknal_tx_prep(ksock_conn_t *conn, ksock_tx_t *tx) +ksocknal_tx_prep(struct ksock_conn *conn, struct ksock_tx *tx) { conn->ksnc_proto->pro_pack(tx); @@ -687,11 +687,11 @@ ksocknal_tx_prep(ksock_conn_t *conn, ksock_tx_t *tx) } void -ksocknal_queue_tx_locked(ksock_tx_t *tx, ksock_conn_t *conn) +ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn) { - ksock_sched_t *sched = conn->ksnc_scheduler; + struct ksock_sched *sched = conn->ksnc_scheduler; ksock_msg_t *msg = &tx->tx_msg; - ksock_tx_t *ztx = NULL; + struct ksock_tx *ztx = NULL; int bufnob = 0; /* @@ -784,15 +784,15 @@ ksocknal_queue_tx_locked(ksock_tx_t *tx, ksock_conn_t *conn) spin_unlock_bh(&sched->kss_lock); } -ksock_route_t * -ksocknal_find_connectable_route_locked(ksock_peer_t *peer) +struct ksock_route * +ksocknal_find_connectable_route_locked(struct ksock_peer *peer) { unsigned long now = cfs_time_current(); struct list_head *tmp; - ksock_route_t *route; + struct ksock_route *route; list_for_each(tmp, &peer->ksnp_routes) { - route = list_entry(tmp, ksock_route_t, ksnr_list); + route = list_entry(tmp, struct ksock_route, ksnr_list); LASSERT(!route->ksnr_connecting || route->ksnr_scheduled); @@ -820,14 +820,14 @@ ksocknal_find_connectable_route_locked(ksock_peer_t *peer) return NULL; } -ksock_route_t * -ksocknal_find_connecting_route_locked(ksock_peer_t *peer) +struct ksock_route * +ksocknal_find_connecting_route_locked(struct ksock_peer *peer) { struct list_head *tmp; - ksock_route_t *route; + struct ksock_route *route; list_for_each(tmp, &peer->ksnp_routes) { - route = list_entry(tmp, ksock_route_t, ksnr_list); + route = list_entry(tmp, struct ksock_route, ksnr_list); LASSERT(!route->ksnr_connecting || route->ksnr_scheduled); @@ -839,10 +839,10 @@ ksocknal_find_connecting_route_locked(ksock_peer_t *peer) } int -ksocknal_launch_packet(lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id) +ksocknal_launch_packet(lnet_ni_t *ni, struct ksock_tx *tx, lnet_process_id_t id) { - ksock_peer_t *peer; - ksock_conn_t *conn; + struct ksock_peer *peer; + struct ksock_conn *conn; rwlock_t *g_lock; int retry; int rc; @@ -942,7 +942,7 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) lnet_kiov_t *payload_kiov = lntmsg->msg_kiov; unsigned int payload_offset = lntmsg->msg_offset; unsigned int payload_nob = lntmsg->msg_len; - ksock_tx_t *tx; + struct ksock_tx *tx; int desc_size; int rc; @@ -960,10 +960,10 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) LASSERT(!in_interrupt()); if (payload_iov) - desc_size = offsetof(ksock_tx_t, + desc_size = offsetof(struct ksock_tx, tx_frags.virt.iov[1 + payload_niov]); else - desc_size = offsetof(ksock_tx_t, + desc_size = offsetof(struct ksock_tx, tx_frags.paged.kiov[payload_niov]); if (lntmsg->msg_vmflush) @@ -1037,7 +1037,7 @@ ksocknal_thread_fini(void) } int -ksocknal_new_packet(ksock_conn_t *conn, int nob_to_skip) +ksocknal_new_packet(struct ksock_conn *conn, int nob_to_skip) { static char ksocknal_slop_buffer[4096]; @@ -1120,7 +1120,7 @@ ksocknal_new_packet(ksock_conn_t *conn, int nob_to_skip) } static int -ksocknal_process_receive(ksock_conn_t *conn) +ksocknal_process_receive(struct ksock_conn *conn) { lnet_hdr_t *lhdr; lnet_process_id_t *id; @@ -1328,8 +1328,8 @@ ksocknal_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed, unsigned int niov, struct kvec *iov, lnet_kiov_t *kiov, unsigned int offset, unsigned int mlen, unsigned int rlen) { - ksock_conn_t *conn = private; - ksock_sched_t *sched = conn->ksnc_scheduler; + struct ksock_conn *conn = private; + struct ksock_sched *sched = conn->ksnc_scheduler; LASSERT(mlen <= rlen); LASSERT(niov <= LNET_MAX_IOV); @@ -1382,7 +1382,7 @@ ksocknal_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed, } static inline int -ksocknal_sched_cansleep(ksock_sched_t *sched) +ksocknal_sched_cansleep(struct ksock_sched *sched) { int rc; @@ -1399,9 +1399,9 @@ ksocknal_sched_cansleep(ksock_sched_t *sched) int ksocknal_scheduler(void *arg) { struct ksock_sched_info *info; - ksock_sched_t *sched; - ksock_conn_t *conn; - ksock_tx_t *tx; + struct ksock_sched *sched; + struct ksock_conn *conn; + struct ksock_tx *tx; int rc; int nloops = 0; long id = (long)arg; @@ -1426,7 +1426,7 @@ int ksocknal_scheduler(void *arg) if (!list_empty(&sched->kss_rx_conns)) { conn = list_entry(sched->kss_rx_conns.next, - ksock_conn_t, ksnc_rx_list); + struct ksock_conn, ksnc_rx_list); list_del(&conn->ksnc_rx_list); LASSERT(conn->ksnc_rx_scheduled); @@ -1481,7 +1481,7 @@ int ksocknal_scheduler(void *arg) } conn = list_entry(sched->kss_tx_conns.next, - ksock_conn_t, ksnc_tx_list); + struct ksock_conn, ksnc_tx_list); list_del(&conn->ksnc_tx_list); LASSERT(conn->ksnc_tx_scheduled); @@ -1489,7 +1489,7 @@ int ksocknal_scheduler(void *arg) LASSERT(!list_empty(&conn->ksnc_tx_queue)); tx = list_entry(conn->ksnc_tx_queue.next, - ksock_tx_t, tx_list); + struct ksock_tx, tx_list); if (conn->ksnc_tx_carrier == tx) ksocknal_next_tx_carrier(conn); @@ -1575,9 +1575,9 @@ int ksocknal_scheduler(void *arg) * Add connection to kss_rx_conns of scheduler * and wakeup the scheduler. */ -void ksocknal_read_callback(ksock_conn_t *conn) +void ksocknal_read_callback(struct ksock_conn *conn) { - ksock_sched_t *sched; + struct ksock_sched *sched; sched = conn->ksnc_scheduler; @@ -1600,9 +1600,9 @@ void ksocknal_read_callback(ksock_conn_t *conn) * Add connection to kss_tx_conns of scheduler * and wakeup the scheduler. */ -void ksocknal_write_callback(ksock_conn_t *conn) +void ksocknal_write_callback(struct ksock_conn *conn) { - ksock_sched_t *sched; + struct ksock_sched *sched; sched = conn->ksnc_scheduler; @@ -1623,7 +1623,7 @@ void ksocknal_write_callback(ksock_conn_t *conn) spin_unlock_bh(&sched->kss_lock); } -static ksock_proto_t * +static struct ksock_proto * ksocknal_parse_proto_version(ksock_hello_msg_t *hello) { __u32 version = 0; @@ -1666,11 +1666,11 @@ ksocknal_parse_proto_version(ksock_hello_msg_t *hello) } int -ksocknal_send_hello(lnet_ni_t *ni, ksock_conn_t *conn, +ksocknal_send_hello(lnet_ni_t *ni, struct ksock_conn *conn, lnet_nid_t peer_nid, ksock_hello_msg_t *hello) { /* CAVEAT EMPTOR: this byte flips 'ipaddrs' */ - ksock_net_t *net = (ksock_net_t *)ni->ni_data; + struct ksock_net *net = (struct ksock_net *)ni->ni_data; LASSERT(hello->kshm_nips <= LNET_MAX_INTERFACES); @@ -1704,7 +1704,7 @@ ksocknal_invert_type(int type) } int -ksocknal_recv_hello(lnet_ni_t *ni, ksock_conn_t *conn, +ksocknal_recv_hello(lnet_ni_t *ni, struct ksock_conn *conn, ksock_hello_msg_t *hello, lnet_process_id_t *peerid, __u64 *incarnation) { @@ -1718,7 +1718,7 @@ ksocknal_recv_hello(lnet_ni_t *ni, ksock_conn_t *conn, int timeout; int proto_match; int rc; - ksock_proto_t *proto; + struct ksock_proto *proto; lnet_process_id_t recv_id; /* socket type set on active connections - not set on passive */ @@ -1847,10 +1847,10 @@ ksocknal_recv_hello(lnet_ni_t *ni, ksock_conn_t *conn, } static int -ksocknal_connect(ksock_route_t *route) +ksocknal_connect(struct ksock_route *route) { LIST_HEAD(zombies); - ksock_peer_t *peer = route->ksnr_peer; + struct ksock_peer *peer = route->ksnr_peer; int type; int wanted; struct socket *sock; @@ -1989,7 +1989,7 @@ ksocknal_connect(ksock_route_t *route) if (!list_empty(&peer->ksnp_tx_queue) && !peer->ksnp_accepting && !ksocknal_find_connecting_route_locked(peer)) { - ksock_conn_t *conn; + struct ksock_conn *conn; /* * ksnp_tx_queue is queued on a conn on successful @@ -1997,7 +1997,7 @@ ksocknal_connect(ksock_route_t *route) */ if (!list_empty(&peer->ksnp_conns)) { conn = list_entry(peer->ksnp_conns.next, - ksock_conn_t, ksnc_list); + struct ksock_conn, ksnc_list); LASSERT(conn->ksnc_proto == &ksocknal_protocol_v3x); } @@ -2131,10 +2131,10 @@ ksocknal_connd_check_stop(time64_t sec, long *timeout) * Go through connd_routes queue looking for a route that we can process * right now, @timeout_p can be updated if we need to come back later */ -static ksock_route_t * +static struct ksock_route * ksocknal_connd_get_route_locked(signed long *timeout_p) { - ksock_route_t *route; + struct ksock_route *route; unsigned long now; now = cfs_time_current(); @@ -2158,7 +2158,7 @@ int ksocknal_connd(void *arg) { spinlock_t *connd_lock = &ksocknal_data.ksnd_connd_lock; - ksock_connreq_t *cr; + struct ksock_connreq *cr; wait_queue_t wait; int nloops = 0; int cons_retry = 0; @@ -2174,7 +2174,7 @@ ksocknal_connd(void *arg) ksocknal_data.ksnd_connd_running++; while (!ksocknal_data.ksnd_shuttingdown) { - ksock_route_t *route = NULL; + struct ksock_route *route = NULL; time64_t sec = ktime_get_real_seconds(); long timeout = MAX_SCHEDULE_TIMEOUT; int dropped_lock = 0; @@ -2192,8 +2192,8 @@ ksocknal_connd(void *arg) if (!list_empty(&ksocknal_data.ksnd_connd_connreqs)) { /* Connection accepted by the listener */ - cr = list_entry(ksocknal_data.ksnd_connd_connreqs. \ - next, ksock_connreq_t, ksncr_list); + cr = list_entry(ksocknal_data.ksnd_connd_connreqs.next, + struct ksock_connreq, ksncr_list); list_del(&cr->ksncr_list); spin_unlock_bh(connd_lock); @@ -2267,17 +2267,17 @@ ksocknal_connd(void *arg) return 0; } -static ksock_conn_t * -ksocknal_find_timed_out_conn(ksock_peer_t *peer) +static struct ksock_conn * +ksocknal_find_timed_out_conn(struct ksock_peer *peer) { /* We're called with a shared lock on ksnd_global_lock */ - ksock_conn_t *conn; + struct ksock_conn *conn; struct list_head *ctmp; list_for_each(ctmp, &peer->ksnp_conns) { int error; - conn = list_entry(ctmp, ksock_conn_t, ksnc_list); + conn = list_entry(ctmp, struct ksock_conn, ksnc_list); /* Don't need the {get,put}connsock dance to deref ksnc_sock */ LASSERT(!conn->ksnc_closing); @@ -2351,10 +2351,10 @@ ksocknal_find_timed_out_conn(ksock_peer_t *peer) } static inline void -ksocknal_flush_stale_txs(ksock_peer_t *peer) +ksocknal_flush_stale_txs(struct ksock_peer *peer) { - ksock_tx_t *tx; - ksock_tx_t *tmp; + struct ksock_tx *tx; + struct ksock_tx *tmp; LIST_HEAD(stale_txs); write_lock_bh(&ksocknal_data.ksnd_global_lock); @@ -2374,12 +2374,12 @@ ksocknal_flush_stale_txs(ksock_peer_t *peer) } static int -ksocknal_send_keepalive_locked(ksock_peer_t *peer) +ksocknal_send_keepalive_locked(struct ksock_peer *peer) __must_hold(&ksocknal_data.ksnd_global_lock) { - ksock_sched_t *sched; - ksock_conn_t *conn; - ksock_tx_t *tx; + struct ksock_sched *sched; + struct ksock_conn *conn; + struct ksock_tx *tx; if (list_empty(&peer->ksnp_conns)) /* last_alive will be updated by create_conn */ return 0; @@ -2440,9 +2440,9 @@ static void ksocknal_check_peer_timeouts(int idx) { struct list_head *peers = &ksocknal_data.ksnd_peers[idx]; - ksock_peer_t *peer; - ksock_conn_t *conn; - ksock_tx_t *tx; + struct ksock_peer *peer; + struct ksock_conn *conn; + struct ksock_tx *tx; again: /* @@ -2483,8 +2483,8 @@ ksocknal_check_peer_timeouts(int idx) * holding only shared lock */ if (!list_empty(&peer->ksnp_tx_queue)) { - ksock_tx_t *tx = list_entry(peer->ksnp_tx_queue.next, - ksock_tx_t, tx_list); + struct ksock_tx *tx = list_entry(peer->ksnp_tx_queue.next, + struct ksock_tx, tx_list); if (cfs_time_aftereq(cfs_time_current(), tx->tx_deadline)) { @@ -2518,7 +2518,7 @@ ksocknal_check_peer_timeouts(int idx) } tx = list_entry(peer->ksnp_zc_req_list.next, - ksock_tx_t, tx_zc_list); + struct ksock_tx, tx_zc_list); deadline = tx->tx_deadline; resid = tx->tx_resid; conn = tx->tx_conn; @@ -2544,8 +2544,8 @@ int ksocknal_reaper(void *arg) { wait_queue_t wait; - ksock_conn_t *conn; - ksock_sched_t *sched; + struct ksock_conn *conn; + struct ksock_sched *sched; struct list_head enomem_conns; int nenomem_conns; long timeout; @@ -2563,7 +2563,7 @@ ksocknal_reaper(void *arg) while (!ksocknal_data.ksnd_shuttingdown) { if (!list_empty(&ksocknal_data.ksnd_deathrow_conns)) { conn = list_entry(ksocknal_data.ksnd_deathrow_conns.next, - ksock_conn_t, ksnc_list); + struct ksock_conn, ksnc_list); list_del(&conn->ksnc_list); spin_unlock_bh(&ksocknal_data.ksnd_reaper_lock); @@ -2577,7 +2577,7 @@ ksocknal_reaper(void *arg) if (!list_empty(&ksocknal_data.ksnd_zombie_conns)) { conn = list_entry(ksocknal_data.ksnd_zombie_conns.next, - ksock_conn_t, ksnc_list); + struct ksock_conn, ksnc_list); list_del(&conn->ksnc_list); spin_unlock_bh(&ksocknal_data.ksnd_reaper_lock); @@ -2599,7 +2599,7 @@ ksocknal_reaper(void *arg) /* reschedule all the connections that stalled with ENOMEM... */ nenomem_conns = 0; while (!list_empty(&enomem_conns)) { - conn = list_entry(enomem_conns.next, ksock_conn_t, + conn = list_entry(enomem_conns.next, struct ksock_conn, ksnc_tx_list); list_del(&conn->ksnc_tx_list); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c index 964b4e3..44d417b 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c @@ -37,7 +37,7 @@ #include "socklnd.h" int -ksocknal_lib_get_conn_addrs(ksock_conn_t *conn) +ksocknal_lib_get_conn_addrs(struct ksock_conn *conn) { int rc = lnet_sock_getaddr(conn->ksnc_sock, 1, &conn->ksnc_ipaddr, &conn->ksnc_port); @@ -60,7 +60,7 @@ ksocknal_lib_get_conn_addrs(ksock_conn_t *conn) } int -ksocknal_lib_zc_capable(ksock_conn_t *conn) +ksocknal_lib_zc_capable(struct ksock_conn *conn) { int caps = conn->ksnc_sock->sk->sk_route_caps; @@ -75,7 +75,7 @@ ksocknal_lib_zc_capable(ksock_conn_t *conn) } int -ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx) +ksocknal_lib_send_iov(struct ksock_conn *conn, struct ksock_tx *tx) { struct socket *sock = conn->ksnc_sock; int nob; @@ -118,7 +118,7 @@ ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx) } int -ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx) +ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx) { struct socket *sock = conn->ksnc_sock; lnet_kiov_t *kiov = tx->tx_kiov; @@ -187,7 +187,7 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx) } void -ksocknal_lib_eager_ack(ksock_conn_t *conn) +ksocknal_lib_eager_ack(struct ksock_conn *conn) { int opt = 1; struct socket *sock = conn->ksnc_sock; @@ -203,7 +203,7 @@ ksocknal_lib_eager_ack(ksock_conn_t *conn) } int -ksocknal_lib_recv_iov(ksock_conn_t *conn) +ksocknal_lib_recv_iov(struct ksock_conn *conn) { #if SOCKNAL_SINGLE_FRAG_RX struct kvec scratch; @@ -309,7 +309,7 @@ ksocknal_lib_kiov_vmap(lnet_kiov_t *kiov, int niov, } int -ksocknal_lib_recv_kiov(ksock_conn_t *conn) +ksocknal_lib_recv_kiov(struct ksock_conn *conn) { #if SOCKNAL_SINGLE_FRAG_RX || !SOCKNAL_RISK_KMAP_DEADLOCK struct kvec scratch; @@ -393,7 +393,7 @@ ksocknal_lib_recv_kiov(ksock_conn_t *conn) } void -ksocknal_lib_csum_tx(ksock_tx_t *tx) +ksocknal_lib_csum_tx(struct ksock_tx *tx) { int i; __u32 csum; @@ -432,7 +432,7 @@ ksocknal_lib_csum_tx(ksock_tx_t *tx) } int -ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, int *rxmem, int *nagle) +ksocknal_lib_get_conn_tunables(struct ksock_conn *conn, int *txmem, int *rxmem, int *nagle) { struct socket *sock = conn->ksnc_sock; int len; @@ -562,7 +562,7 @@ ksocknal_lib_setup_sock(struct socket *sock) } void -ksocknal_lib_push_conn(ksock_conn_t *conn) +ksocknal_lib_push_conn(struct ksock_conn *conn) { struct sock *sk; struct tcp_sock *tp; @@ -599,7 +599,7 @@ ksocknal_lib_push_conn(ksock_conn_t *conn) static void ksocknal_data_ready(struct sock *sk) { - ksock_conn_t *conn; + struct ksock_conn *conn; /* interleave correctly with closing sockets... */ LASSERT(!in_irq()); @@ -619,7 +619,7 @@ ksocknal_data_ready(struct sock *sk) static void ksocknal_write_space(struct sock *sk) { - ksock_conn_t *conn; + struct ksock_conn *conn; int wspace; int min_wpace; @@ -663,14 +663,14 @@ ksocknal_write_space(struct sock *sk) } void -ksocknal_lib_save_callback(struct socket *sock, ksock_conn_t *conn) +ksocknal_lib_save_callback(struct socket *sock, struct ksock_conn *conn) { conn->ksnc_saved_data_ready = sock->sk->sk_data_ready; conn->ksnc_saved_write_space = sock->sk->sk_write_space; } void -ksocknal_lib_set_callback(struct socket *sock, ksock_conn_t *conn) +ksocknal_lib_set_callback(struct socket *sock, struct ksock_conn *conn) { sock->sk->sk_user_data = conn; sock->sk->sk_data_ready = ksocknal_data_ready; @@ -678,7 +678,7 @@ ksocknal_lib_set_callback(struct socket *sock, ksock_conn_t *conn) } void -ksocknal_lib_reset_callback(struct socket *sock, ksock_conn_t *conn) +ksocknal_lib_reset_callback(struct socket *sock, struct ksock_conn *conn) { /* * Remove conn's network callbacks. @@ -697,10 +697,10 @@ ksocknal_lib_reset_callback(struct socket *sock, ksock_conn_t *conn) } int -ksocknal_lib_memory_pressure(ksock_conn_t *conn) +ksocknal_lib_memory_pressure(struct ksock_conn *conn) { int rc = 0; - ksock_sched_t *sched; + struct ksock_sched *sched; sched = conn->ksnc_scheduler; spin_lock_bh(&sched->kss_lock); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c index 6329cbe..fc7eec8 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c @@ -139,7 +139,7 @@ module_param(protocol, int, 0644); MODULE_PARM_DESC(protocol, "protocol version"); #endif -ksock_tunables_t ksocknal_tunables; +struct ksock_tunables ksocknal_tunables; int ksocknal_tunables_init(void) { diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c index 32cc31e..e1bf910 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c @@ -38,8 +38,8 @@ * pro_match_tx() : Called holding glock */ -static ksock_tx_t * -ksocknal_queue_tx_msg_v1(ksock_conn_t *conn, ksock_tx_t *tx_msg) +static struct ksock_tx * +ksocknal_queue_tx_msg_v1(struct ksock_conn *conn, struct ksock_tx *tx_msg) { /* V1.x, just enqueue it */ list_add_tail(&tx_msg->tx_list, &conn->ksnc_tx_queue); @@ -47,9 +47,9 @@ ksocknal_queue_tx_msg_v1(ksock_conn_t *conn, ksock_tx_t *tx_msg) } void -ksocknal_next_tx_carrier(ksock_conn_t *conn) +ksocknal_next_tx_carrier(struct ksock_conn *conn) { - ksock_tx_t *tx = conn->ksnc_tx_carrier; + struct ksock_tx *tx = conn->ksnc_tx_carrier; /* Called holding BH lock: conn->ksnc_scheduler->kss_lock */ LASSERT(!list_empty(&conn->ksnc_tx_queue)); @@ -66,10 +66,10 @@ ksocknal_next_tx_carrier(ksock_conn_t *conn) } static int -ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn, - ksock_tx_t *tx_ack, __u64 cookie) +ksocknal_queue_tx_zcack_v2(struct ksock_conn *conn, + struct ksock_tx *tx_ack, __u64 cookie) { - ksock_tx_t *tx = conn->ksnc_tx_carrier; + struct ksock_tx *tx = conn->ksnc_tx_carrier; LASSERT(!tx_ack || tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP); @@ -112,10 +112,10 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn, return 1; } -static ksock_tx_t * -ksocknal_queue_tx_msg_v2(ksock_conn_t *conn, ksock_tx_t *tx_msg) +static struct ksock_tx * +ksocknal_queue_tx_msg_v2(struct ksock_conn *conn, struct ksock_tx *tx_msg) { - ksock_tx_t *tx = conn->ksnc_tx_carrier; + struct ksock_tx *tx = conn->ksnc_tx_carrier; /* * Enqueue tx_msg: @@ -149,10 +149,10 @@ ksocknal_queue_tx_msg_v2(ksock_conn_t *conn, ksock_tx_t *tx_msg) } static int -ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn, - ksock_tx_t *tx_ack, __u64 cookie) +ksocknal_queue_tx_zcack_v3(struct ksock_conn *conn, + struct ksock_tx *tx_ack, __u64 cookie) { - ksock_tx_t *tx; + struct ksock_tx *tx; if (conn->ksnc_type != SOCKLND_CONN_ACK) return ksocknal_queue_tx_zcack_v2(conn, tx_ack, cookie); @@ -267,7 +267,7 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn, } static int -ksocknal_match_tx(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk) +ksocknal_match_tx(struct ksock_conn *conn, struct ksock_tx *tx, int nonblk) { int nob; @@ -311,7 +311,7 @@ ksocknal_match_tx(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk) } static int -ksocknal_match_tx_v3(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk) +ksocknal_match_tx_v3(struct ksock_conn *conn, struct ksock_tx *tx, int nonblk) { int nob; @@ -355,18 +355,18 @@ ksocknal_match_tx_v3(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk) /* (Sink) handle incoming ZC request from sender */ static int -ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote) +ksocknal_handle_zcreq(struct ksock_conn *c, __u64 cookie, int remote) { - ksock_peer_t *peer = c->ksnc_peer; - ksock_conn_t *conn; - ksock_tx_t *tx; + struct ksock_peer *peer = c->ksnc_peer; + struct ksock_conn *conn; + struct ksock_tx *tx; int rc; read_lock(&ksocknal_data.ksnd_global_lock); conn = ksocknal_find_conn_locked(peer, NULL, !!remote); if (conn) { - ksock_sched_t *sched = conn->ksnc_scheduler; + struct ksock_sched *sched = conn->ksnc_scheduler; LASSERT(conn->ksnc_proto->pro_queue_tx_zcack); @@ -399,12 +399,12 @@ ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote) /* (Sender) handle ZC_ACK from sink */ static int -ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2) +ksocknal_handle_zcack(struct ksock_conn *conn, __u64 cookie1, __u64 cookie2) { - ksock_peer_t *peer = conn->ksnc_peer; - ksock_tx_t *tx; - ksock_tx_t *temp; - ksock_tx_t *tmp; + struct ksock_peer *peer = conn->ksnc_peer; + struct ksock_tx *tx; + struct ksock_tx *temp; + struct ksock_tx *tmp; LIST_HEAD(zlist); int count; @@ -446,7 +446,7 @@ ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2) } static int -ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello) +ksocknal_send_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello) { struct socket *sock = conn->ksnc_sock; lnet_hdr_t *hdr; @@ -521,7 +521,7 @@ out: } static int -ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello) +ksocknal_send_hello_v2(struct ksock_conn *conn, ksock_hello_msg_t *hello) { struct socket *sock = conn->ksnc_sock; int rc; @@ -563,7 +563,7 @@ ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello) } static int -ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello, +ksocknal_recv_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello, int timeout) { struct socket *sock = conn->ksnc_sock; @@ -639,7 +639,7 @@ out: } static int -ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout) +ksocknal_recv_hello_v2(struct ksock_conn *conn, ksock_hello_msg_t *hello, int timeout) { struct socket *sock = conn->ksnc_sock; int rc; @@ -705,7 +705,7 @@ ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout } static void -ksocknal_pack_msg_v1(ksock_tx_t *tx) +ksocknal_pack_msg_v1(struct ksock_tx *tx) { /* V1.x has no KSOCK_MSG_NOOP */ LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP); @@ -719,7 +719,7 @@ ksocknal_pack_msg_v1(ksock_tx_t *tx) } static void -ksocknal_pack_msg_v2(ksock_tx_t *tx) +ksocknal_pack_msg_v2(struct ksock_tx *tx) { tx->tx_iov[0].iov_base = &tx->tx_msg; @@ -755,7 +755,7 @@ ksocknal_unpack_msg_v2(ksock_msg_t *msg) return; /* Do nothing */ } -ksock_proto_t ksocknal_protocol_v1x = { +struct ksock_proto ksocknal_protocol_v1x = { .pro_version = KSOCK_PROTO_V1, .pro_send_hello = ksocknal_send_hello_v1, .pro_recv_hello = ksocknal_recv_hello_v1, @@ -768,7 +768,7 @@ ksock_proto_t ksocknal_protocol_v1x = { .pro_match_tx = ksocknal_match_tx }; -ksock_proto_t ksocknal_protocol_v2x = { +struct ksock_proto ksocknal_protocol_v2x = { .pro_version = KSOCK_PROTO_V2, .pro_send_hello = ksocknal_send_hello_v2, .pro_recv_hello = ksocknal_recv_hello_v2, @@ -781,7 +781,7 @@ ksock_proto_t ksocknal_protocol_v2x = { .pro_match_tx = ksocknal_match_tx }; -ksock_proto_t ksocknal_protocol_v3x = { +struct ksock_proto ksocknal_protocol_v3x = { .pro_version = KSOCK_PROTO_V3, .pro_send_hello = ksocknal_send_hello_v2, .pro_recv_hello = ksocknal_recv_hello_v2, -- cgit v1.1 From ed4df35478b84c8873b1d3f50f23eecacd22d859 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Tue, 14 Jun 2016 23:33:39 -0400 Subject: staging/lustre: Remove the "Please contact SUN for GPL" from headers Since SUN is no longer around and there's no point in contacting them, just remove that whole thing. Copy of GPL is available online anyway (URLs to be updated in next patch). This patch was generated with: find drivers/staging/lustre -name "*.[ch]" -exec perl -0777 -i -pe 's/ \* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,\n \* CA 95054 USA or visit www.sun.com if you need additional information or\n \* have any questions.\n \*\n//igs' {} \; Signed-off-by: Oleg Drokin Reported-by: Xose Vazquez Perez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/curproc.h | 4 ---- drivers/staging/lustre/include/linux/libcfs/libcfs.h | 4 ---- drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h | 4 ---- drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h | 4 ---- drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h | 4 ---- drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h | 4 ---- drivers/staging/lustre/include/linux/libcfs/libcfs_private.h | 4 ---- drivers/staging/lustre/include/linux/libcfs/libcfs_string.h | 4 ---- drivers/staging/lustre/include/linux/libcfs/libcfs_time.h | 4 ---- drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h | 4 ---- drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h | 4 ---- drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h | 4 ---- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 4 ---- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 4 ---- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 4 ---- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c | 4 ---- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 4 ---- drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c | 4 ---- drivers/staging/lustre/lnet/libcfs/debug.c | 4 ---- drivers/staging/lustre/lnet/libcfs/hash.c | 4 ---- drivers/staging/lustre/lnet/libcfs/libcfs_string.c | 4 ---- drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c | 4 ---- drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c | 4 ---- drivers/staging/lustre/lnet/libcfs/linux/linux-module.c | 4 ---- drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c | 4 ---- drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c | 4 ---- drivers/staging/lustre/lnet/libcfs/module.c | 4 ---- drivers/staging/lustre/lnet/libcfs/prng.c | 4 ---- drivers/staging/lustre/lnet/libcfs/tracefile.c | 4 ---- drivers/staging/lustre/lnet/libcfs/tracefile.h | 4 ---- drivers/staging/lustre/lnet/libcfs/workitem.c | 4 ---- drivers/staging/lustre/lnet/lnet/acceptor.c | 4 ---- drivers/staging/lustre/lnet/lnet/api-ni.c | 4 ---- drivers/staging/lustre/lnet/lnet/config.c | 4 ---- drivers/staging/lustre/lnet/lnet/lib-eq.c | 4 ---- drivers/staging/lustre/lnet/lnet/lib-md.c | 4 ---- drivers/staging/lustre/lnet/lnet/lib-me.c | 4 ---- drivers/staging/lustre/lnet/lnet/lib-move.c | 4 ---- drivers/staging/lustre/lnet/lnet/lib-msg.c | 4 ---- drivers/staging/lustre/lnet/lnet/lo.c | 4 ---- drivers/staging/lustre/lnet/lnet/module.c | 4 ---- drivers/staging/lustre/lnet/lnet/nidstrings.c | 4 ---- drivers/staging/lustre/lnet/lnet/peer.c | 4 ---- drivers/staging/lustre/lnet/selftest/brw_test.c | 4 ---- drivers/staging/lustre/lnet/selftest/conctl.c | 4 ---- drivers/staging/lustre/lnet/selftest/conrpc.c | 4 ---- drivers/staging/lustre/lnet/selftest/conrpc.h | 4 ---- drivers/staging/lustre/lnet/selftest/console.c | 4 ---- drivers/staging/lustre/lnet/selftest/console.h | 4 ---- drivers/staging/lustre/lnet/selftest/framework.c | 4 ---- drivers/staging/lustre/lnet/selftest/module.c | 4 ---- drivers/staging/lustre/lnet/selftest/ping_test.c | 4 ---- drivers/staging/lustre/lnet/selftest/rpc.c | 4 ---- drivers/staging/lustre/lnet/selftest/rpc.h | 4 ---- drivers/staging/lustre/lnet/selftest/selftest.h | 4 ---- drivers/staging/lustre/lnet/selftest/timer.c | 4 ---- drivers/staging/lustre/lnet/selftest/timer.h | 4 ---- drivers/staging/lustre/lustre/fid/fid_internal.h | 4 ---- drivers/staging/lustre/lustre/fid/fid_lib.c | 4 ---- drivers/staging/lustre/lustre/fid/fid_request.c | 4 ---- drivers/staging/lustre/lustre/fid/lproc_fid.c | 4 ---- drivers/staging/lustre/lustre/fld/fld_cache.c | 4 ---- drivers/staging/lustre/lustre/fld/fld_internal.h | 4 ---- drivers/staging/lustre/lustre/fld/fld_request.c | 4 ---- drivers/staging/lustre/lustre/fld/lproc_fld.c | 4 ---- drivers/staging/lustre/lustre/include/cl_object.h | 4 ---- drivers/staging/lustre/lustre/include/interval_tree.h | 4 ---- drivers/staging/lustre/lustre/include/linux/lustre_compat25.h | 4 ---- drivers/staging/lustre/lustre/include/linux/lustre_lite.h | 4 ---- drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h | 4 ---- drivers/staging/lustre/lustre/include/linux/lustre_user.h | 4 ---- drivers/staging/lustre/lustre/include/lprocfs_status.h | 4 ---- drivers/staging/lustre/lustre/include/lu_object.h | 4 ---- drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h | 4 ---- drivers/staging/lustre/lustre/include/lustre/lustre_idl.h | 4 ---- drivers/staging/lustre/lustre/include/lustre/lustre_user.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_acl.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_cfg.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_debug.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_disk.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_dlm.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_eacl.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_export.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_fid.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_fld.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_ha.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_handles.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_import.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_intent.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_lib.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_lite.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_log.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_mdc.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_mds.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_net.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_param.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_req_layout.h | 4 ---- drivers/staging/lustre/lustre/include/lustre_sec.h | 4 ---- drivers/staging/lustre/lustre/include/obd.h | 4 ---- drivers/staging/lustre/lustre/include/obd_cksum.h | 4 ---- drivers/staging/lustre/lustre/include/obd_class.h | 4 ---- drivers/staging/lustre/lustre/include/obd_support.h | 4 ---- drivers/staging/lustre/lustre/ldlm/interval_tree.c | 4 ---- drivers/staging/lustre/lustre/ldlm/l_lock.c | 4 ---- drivers/staging/lustre/lustre/ldlm/ldlm_extent.c | 4 ---- drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 4 ---- drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c | 4 ---- drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 4 ---- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 4 ---- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 4 ---- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 4 ---- drivers/staging/lustre/lustre/ldlm/ldlm_plain.c | 4 ---- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 4 ---- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 4 ---- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 4 ---- drivers/staging/lustre/lustre/llite/dcache.c | 4 ---- drivers/staging/lustre/lustre/llite/dir.c | 4 ---- drivers/staging/lustre/lustre/llite/file.c | 4 ---- drivers/staging/lustre/lustre/llite/glimpse.c | 4 ---- drivers/staging/lustre/lustre/llite/lcommon_cl.c | 4 ---- drivers/staging/lustre/lustre/llite/lcommon_misc.c | 4 ---- drivers/staging/lustre/lustre/llite/llite_close.c | 4 ---- drivers/staging/lustre/lustre/llite/llite_internal.h | 4 ---- drivers/staging/lustre/lustre/llite/llite_lib.c | 4 ---- drivers/staging/lustre/lustre/llite/llite_mmap.c | 4 ---- drivers/staging/lustre/lustre/llite/llite_nfs.c | 4 ---- drivers/staging/lustre/lustre/llite/llite_rmtacl.c | 4 ---- drivers/staging/lustre/lustre/llite/lproc_llite.c | 4 ---- drivers/staging/lustre/lustre/llite/namei.c | 4 ---- drivers/staging/lustre/lustre/llite/remote_perm.c | 4 ---- drivers/staging/lustre/lustre/llite/rw.c | 4 ---- drivers/staging/lustre/lustre/llite/rw26.c | 4 ---- drivers/staging/lustre/lustre/llite/statahead.c | 4 ---- drivers/staging/lustre/lustre/llite/super25.c | 4 ---- drivers/staging/lustre/lustre/llite/symlink.c | 4 ---- drivers/staging/lustre/lustre/llite/vvp_dev.c | 4 ---- drivers/staging/lustre/lustre/llite/vvp_internal.h | 4 ---- drivers/staging/lustre/lustre/llite/vvp_io.c | 4 ---- drivers/staging/lustre/lustre/llite/vvp_lock.c | 4 ---- drivers/staging/lustre/lustre/llite/vvp_object.c | 4 ---- drivers/staging/lustre/lustre/llite/vvp_page.c | 4 ---- drivers/staging/lustre/lustre/llite/xattr.c | 4 ---- drivers/staging/lustre/lustre/lmv/lmv_fld.c | 4 ---- drivers/staging/lustre/lustre/lmv/lmv_intent.c | 4 ---- drivers/staging/lustre/lustre/lmv/lmv_internal.h | 4 ---- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 4 ---- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 4 ---- drivers/staging/lustre/lustre/lov/lov_cl_internal.h | 4 ---- drivers/staging/lustre/lustre/lov/lov_dev.c | 4 ---- drivers/staging/lustre/lustre/lov/lov_ea.c | 4 ---- drivers/staging/lustre/lustre/lov/lov_internal.h | 4 ---- drivers/staging/lustre/lustre/lov/lov_io.c | 4 ---- drivers/staging/lustre/lustre/lov/lov_lock.c | 4 ---- drivers/staging/lustre/lustre/lov/lov_merge.c | 4 ---- drivers/staging/lustre/lustre/lov/lov_obd.c | 4 ---- drivers/staging/lustre/lustre/lov/lov_object.c | 4 ---- drivers/staging/lustre/lustre/lov/lov_offset.c | 4 ---- drivers/staging/lustre/lustre/lov/lov_pack.c | 4 ---- drivers/staging/lustre/lustre/lov/lov_page.c | 4 ---- drivers/staging/lustre/lustre/lov/lov_pool.c | 4 ---- drivers/staging/lustre/lustre/lov/lov_request.c | 4 ---- drivers/staging/lustre/lustre/lov/lovsub_dev.c | 4 ---- drivers/staging/lustre/lustre/lov/lovsub_io.c | 4 ---- drivers/staging/lustre/lustre/lov/lovsub_lock.c | 4 ---- drivers/staging/lustre/lustre/lov/lovsub_object.c | 4 ---- drivers/staging/lustre/lustre/lov/lovsub_page.c | 4 ---- drivers/staging/lustre/lustre/lov/lproc_lov.c | 4 ---- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 4 ---- drivers/staging/lustre/lustre/mdc/mdc_internal.h | 4 ---- drivers/staging/lustre/lustre/mdc/mdc_lib.c | 4 ---- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 4 ---- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 4 ---- drivers/staging/lustre/lustre/mdc/mdc_request.c | 4 ---- drivers/staging/lustre/lustre/mgc/lproc_mgc.c | 4 ---- drivers/staging/lustre/lustre/mgc/mgc_internal.h | 4 ---- drivers/staging/lustre/lustre/mgc/mgc_request.c | 4 ---- drivers/staging/lustre/lustre/obdclass/acl.c | 4 ---- drivers/staging/lustre/lustre/obdclass/cl_internal.h | 4 ---- drivers/staging/lustre/lustre/obdclass/cl_io.c | 4 ---- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 4 ---- drivers/staging/lustre/lustre/obdclass/cl_object.c | 4 ---- drivers/staging/lustre/lustre/obdclass/cl_page.c | 4 ---- drivers/staging/lustre/lustre/obdclass/class_obd.c | 4 ---- drivers/staging/lustre/lustre/obdclass/debug.c | 4 ---- drivers/staging/lustre/lustre/obdclass/genops.c | 4 ---- drivers/staging/lustre/lustre/obdclass/kernelcomm.c | 4 ---- drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 4 ---- drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c | 4 ---- drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c | 4 ---- drivers/staging/lustre/lustre/obdclass/llog.c | 4 ---- drivers/staging/lustre/lustre/obdclass/llog_cat.c | 4 ---- drivers/staging/lustre/lustre/obdclass/llog_internal.h | 4 ---- drivers/staging/lustre/lustre/obdclass/llog_obd.c | 4 ---- drivers/staging/lustre/lustre/obdclass/llog_swab.c | 4 ---- drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 4 ---- drivers/staging/lustre/lustre/obdclass/lu_object.c | 4 ---- drivers/staging/lustre/lustre/obdclass/lu_ref.c | 4 ---- drivers/staging/lustre/lustre/obdclass/lustre_handles.c | 4 ---- drivers/staging/lustre/lustre/obdclass/lustre_peer.c | 4 ---- drivers/staging/lustre/lustre/obdclass/obd_config.c | 4 ---- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 4 ---- drivers/staging/lustre/lustre/obdclass/obdo.c | 4 ---- drivers/staging/lustre/lustre/obdclass/statfs_pack.c | 4 ---- drivers/staging/lustre/lustre/obdclass/uuid.c | 4 ---- drivers/staging/lustre/lustre/obdecho/echo_client.c | 4 ---- drivers/staging/lustre/lustre/osc/lproc_osc.c | 4 ---- drivers/staging/lustre/lustre/osc/osc_cache.c | 4 ---- drivers/staging/lustre/lustre/osc/osc_cl_internal.h | 4 ---- drivers/staging/lustre/lustre/osc/osc_dev.c | 4 ---- drivers/staging/lustre/lustre/osc/osc_internal.h | 4 ---- drivers/staging/lustre/lustre/osc/osc_io.c | 4 ---- drivers/staging/lustre/lustre/osc/osc_lock.c | 4 ---- drivers/staging/lustre/lustre/osc/osc_object.c | 4 ---- drivers/staging/lustre/lustre/osc/osc_page.c | 4 ---- drivers/staging/lustre/lustre/osc/osc_request.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/client.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/connection.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/events.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/import.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/layout.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/llog_client.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/llog_net.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/pack_generic.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/pers.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h | 4 ---- drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/recover.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/sec.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/sec_null.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/service.c | 4 ---- drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 4 ---- 240 files changed, 960 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h index 1edfca5..c673dfc 100644 --- a/drivers/staging/lustre/include/linux/libcfs/curproc.h +++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 4141afb..c93d58e 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index 455c54d..ae8175c 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h index 119986b..6a4387b 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h index 4b9102b..9bdff3f 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h index ac4e8cf..881aae0 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index 2fd2a96..c44e11d 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h index e02cde5..03939ce 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h index 2c7ec2d..3f0ec7a 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h index f9b20c5..5ff23bb 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h index a268ef7..3652119 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h index 7656b09..887811b 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 3f3a9c1..f0c0669 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index 4bac2b7..69711ee 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index b3cf62f..5dde5ff 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c index fdc2f3b..24de544 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 0fdc37c..67d8bf2 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c index 44d417b..defe041 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c b/drivers/staging/lustre/lnet/libcfs/debug.c index 8c260c3..0079a4c 100644 --- a/drivers/staging/lustre/lnet/libcfs/debug.c +++ b/drivers/staging/lustre/lnet/libcfs/debug.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c b/drivers/staging/lustre/lnet/libcfs/hash.c index cc45ed8..db51124 100644 --- a/drivers/staging/lustre/lnet/libcfs/hash.c +++ b/drivers/staging/lustre/lnet/libcfs/hash.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_string.c b/drivers/staging/lustre/lnet/libcfs/libcfs_string.c index 50ac153..750691c 100644 --- a/drivers/staging/lustre/lnet/libcfs/libcfs_string.c +++ b/drivers/staging/lustre/lnet/libcfs/libcfs_string.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c index 13d31e8..4fe58dd 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c index 638e4b3..808d09b 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c index d89f71e..8caee5b 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c index bbe19a6..c1152e6 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c index 91c2ae8..6c9e3976 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c index f2d0411..065f968 100644 --- a/drivers/staging/lustre/lnet/libcfs/module.c +++ b/drivers/staging/lustre/lnet/libcfs/module.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/prng.c b/drivers/staging/lustre/lnet/libcfs/prng.c index c75ae9a..f2e8426 100644 --- a/drivers/staging/lustre/lnet/libcfs/prng.c +++ b/drivers/staging/lustre/lnet/libcfs/prng.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c index 7739b94..ba0e7c3 100644 --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.h b/drivers/staging/lustre/lnet/libcfs/tracefile.h index ac84e7f..ae1c614 100644 --- a/drivers/staging/lustre/lnet/libcfs/tracefile.h +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/workitem.c b/drivers/staging/lustre/lnet/libcfs/workitem.c index 92236ae..c51f389 100644 --- a/drivers/staging/lustre/lnet/libcfs/workitem.c +++ b/drivers/staging/lustre/lnet/libcfs/workitem.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 1452bb3..4456286 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index fe0dbe7..7662c3b 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c index 480cc9c..358e5cf 100644 --- a/drivers/staging/lustre/lnet/lnet/config.c +++ b/drivers/staging/lustre/lnet/lnet/config.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index adbcadb..d04c687 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index 75d3121..51145f1 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c index e671aed..1c370f4 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-me.c +++ b/drivers/staging/lustre/lnet/lnet/lib-me.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index c5d5bed..f5c6eac 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index f879d7f..77ae4e6 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/lnet/lo.c b/drivers/staging/lustre/lnet/lnet/lo.c index 468eda6..6441ef3 100644 --- a/drivers/staging/lustre/lnet/lnet/lo.c +++ b/drivers/staging/lustre/lnet/lnet/lo.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index 246b5c1..40f3c52 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c index ebf468f..74bfda1 100644 --- a/drivers/staging/lustre/lnet/lnet/nidstrings.c +++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c index b026fee..5fde05a 100644 --- a/drivers/staging/lustre/lnet/lnet/peer.c +++ b/drivers/staging/lustre/lnet/lnet/peer.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index a63d86c..6e25e1a 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c index 408c614..9a22f33 100644 --- a/drivers/staging/lustre/lnet/selftest/conctl.c +++ b/drivers/staging/lustre/lnet/selftest/conctl.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index 6f68758..e649d37 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.h b/drivers/staging/lustre/lnet/selftest/conrpc.h index 90c3385..1d8bb63 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.h +++ b/drivers/staging/lustre/lnet/selftest/conrpc.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index a03e52d..31001f4 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/console.h b/drivers/staging/lustre/lnet/selftest/console.h index becd22e..b099946 100644 --- a/drivers/staging/lustre/lnet/selftest/console.h +++ b/drivers/staging/lustre/lnet/selftest/console.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c index 30e4f71..0d53307 100644 --- a/drivers/staging/lustre/lnet/selftest/framework.c +++ b/drivers/staging/lustre/lnet/selftest/framework.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c index cc046b1..b6a3bdf 100644 --- a/drivers/staging/lustre/lnet/selftest/module.c +++ b/drivers/staging/lustre/lnet/selftest/module.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c index ad26fe9..3030c07 100644 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index 3c45a7c..e7aba01 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/rpc.h b/drivers/staging/lustre/lnet/selftest/rpc.h index c9b904c..3254f5d 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.h +++ b/drivers/staging/lustre/lnet/selftest/rpc.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h index 4eac1c9..4a1d2b2 100644 --- a/drivers/staging/lustre/lnet/selftest/selftest.h +++ b/drivers/staging/lustre/lnet/selftest/selftest.h @@ -18,10 +18,6 @@ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * copy of GPLv2]. * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c index b6c4aae..c73ded9 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.c +++ b/drivers/staging/lustre/lnet/selftest/timer.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/selftest/timer.h b/drivers/staging/lustre/lnet/selftest/timer.h index f1fbebd..e86e44e 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.h +++ b/drivers/staging/lustre/lnet/selftest/timer.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/fid/fid_internal.h b/drivers/staging/lustre/lustre/fid/fid_internal.h index b79a813..d6aebb3 100644 --- a/drivers/staging/lustre/lustre/fid/fid_internal.h +++ b/drivers/staging/lustre/lustre/fid/fid_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/fid/fid_lib.c b/drivers/staging/lustre/lustre/fid/fid_lib.c index dd65159..ee7b272 100644 --- a/drivers/staging/lustre/lustre/fid/fid_lib.c +++ b/drivers/staging/lustre/lustre/fid/fid_lib.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index 9db21ba..00b19c7 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index 1f0e786..0103af5 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index 5a04e99..cb33d41 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h index 75d6a48..a85d86a 100644 --- a/drivers/staging/lustre/lustre/fld/fld_internal.h +++ b/drivers/staging/lustre/lustre/fld/fld_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index 304c0ec..5f43af4 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index ca898be..1b96880 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index d4c33dd..a5a28f5 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/interval_tree.h b/drivers/staging/lustre/lustre/include/interval_tree.h index f6df3f3..64cab4b 100644 --- a/drivers/staging/lustre/lustre/include/interval_tree.h +++ b/drivers/staging/lustre/lustre/include/interval_tree.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 79d8f93..7690fa7 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h index 3420cfd..abefa93 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h index c6c7f54..6d138b2 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_user.h b/drivers/staging/lustre/lustre/include/linux/lustre_user.h index 9cc2849..7403139 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_user.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 4146c9c..4f5ab54 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index 28165121..b7bfe39 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h b/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h index 07d45de..664f135 100644 --- a/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h +++ b/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 9c53c17..e5031b1 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index 59ba48a..3b48ba5 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_acl.h b/drivers/staging/lustre/lustre/include/lustre_acl.h index aa4cfa7..9773db7 100644 --- a/drivers/staging/lustre/lustre/include/lustre_acl.h +++ b/drivers/staging/lustre/lustre/include/lustre_acl.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index e229e91..f532af6 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_debug.h b/drivers/staging/lustre/lustre/include/lustre_debug.h index 8a08941..bd531ff 100644 --- a/drivers/staging/lustre/lustre/include/lustre_debug.h +++ b/drivers/staging/lustre/lustre/include/lustre_debug.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h index b36821f..f30c601 100644 --- a/drivers/staging/lustre/lustre/include/lustre_disk.h +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 9cade14..bdc1da7 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_eacl.h b/drivers/staging/lustre/lustre/include/lustre_eacl.h index 0b66593..caab6e3 100644 --- a/drivers/staging/lustre/lustre/include/lustre_eacl.h +++ b/drivers/staging/lustre/lustre/include/lustre_eacl.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index 3014d27..41b6a7c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index 12e8b58..e3794d6 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h index 4cf2b0e..6a91cbc 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fld.h +++ b/drivers/staging/lustre/lustre/include/lustre_fld.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_ha.h b/drivers/staging/lustre/lustre/include/lustre_ha.h index 5488a69..152b0ee 100644 --- a/drivers/staging/lustre/lustre/include/lustre_ha.h +++ b/drivers/staging/lustre/lustre/include/lustre_ha.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h index 27f169d..c1906c2 100644 --- a/drivers/staging/lustre/lustre/include/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/lustre_handles.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index 8325c82..d4f7680 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_intent.h b/drivers/staging/lustre/lustre/include/lustre_intent.h index c491d52..d5b15a4 100644 --- a/drivers/staging/lustre/lustre/include/lustre_intent.h +++ b/drivers/staging/lustre/lustre/include/lustre_intent.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index 00b9767..f7b0ce8 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_lite.h b/drivers/staging/lustre/lustre/include/lustre_lite.h index fcc5ebb..bd328e5 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lite.h +++ b/drivers/staging/lustre/lustre/include/lustre_lite.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index 49618e1..7a3940a 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index f267ff8..cc4158c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_mds.h b/drivers/staging/lustre/lustre/include/lustre_mds.h index 95d27dd..9bcd3cd 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mds.h +++ b/drivers/staging/lustre/lustre/include/lustre_mds.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index a7973d5..ce31181 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_param.h b/drivers/staging/lustre/lustre/include/lustre_param.h index a42cf90..dc6f2b2 100644 --- a/drivers/staging/lustre/lustre/include/lustre_param.h +++ b/drivers/staging/lustre/lustre/include/lustre_param.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_req_layout.h b/drivers/staging/lustre/lustre/include/lustre_req_layout.h index 0aac439..acbc310 100644 --- a/drivers/staging/lustre/lustre/include/lustre_req_layout.h +++ b/drivers/staging/lustre/lustre/include/lustre_req_layout.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h index 01b4e67..7ca6204 100644 --- a/drivers/staging/lustre/lustre/include/lustre_sec.h +++ b/drivers/staging/lustre/lustre/include/lustre_sec.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 2d926e0..6c94fa4 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/obd_cksum.h b/drivers/staging/lustre/lustre/include/obd_cksum.h index f6c18df..02705a5 100644 --- a/drivers/staging/lustre/lustre/include/obd_cksum.h +++ b/drivers/staging/lustre/lustre/include/obd_cksum.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 32863bc..c7a71b2 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index 60034d3..ce5be73 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c index 3230606..59bb066 100644 --- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c +++ b/drivers/staging/lustre/lustre/ldlm/interval_tree.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ldlm/l_lock.c b/drivers/staging/lustre/lustre/ldlm/l_lock.c index 621323f..c6f7dfd 100644 --- a/drivers/staging/lustre/lustre/ldlm/l_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/l_lock.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index cf1f178..16c1621 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index 349bfcc..6c0dd7a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c b/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c index b1bed1e..d98243d 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 32f227f..cc5e654 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index b6a90b0..1a7eee3 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index bff94ea..88e9192 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 3303ffa..1da0eb2 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c b/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c index 0c1965d..621a490 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index b913ba9..1d9ca31 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 107314e..f6b30f6 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index e99c89c..771c1f8 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 1b6f82a..908bdc6 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 85c50e0..8854029a 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 26c6cd6..104129b 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/glimpse.c b/drivers/staging/lustre/lustre/llite/glimpse.c index d8ea754..8788ee0 100644 --- a/drivers/staging/lustre/lustre/llite/glimpse.c +++ b/drivers/staging/lustre/lustre/llite/glimpse.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c b/drivers/staging/lustre/lustre/llite/lcommon_cl.c index 6c00715..28b7482 100644 --- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/lcommon_misc.c b/drivers/staging/lustre/lustre/llite/lcommon_misc.c index 12f3e71..e45bd6d 100644 --- a/drivers/staging/lustre/lustre/llite/lcommon_misc.c +++ b/drivers/staging/lustre/lustre/llite/lcommon_misc.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index 2df551d..2e2abc7 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 7fb949a..f541634 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index b260f60..f513b74 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index 7610799..b569df3 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index c1eef61..086e827 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c index 8509b07..bae3ff0 100644 --- a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c +++ b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 55d62eb..2b3a777 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 95643bc..b7ec512 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/remote_perm.c b/drivers/staging/lustre/lustre/llite/remote_perm.c index e9d2531..0b96175 100644 --- a/drivers/staging/lustre/lustre/llite/remote_perm.c +++ b/drivers/staging/lustre/lustre/llite/remote_perm.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index fa42869..df6cb54 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 947a4f5..d45fdcb 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 6322f88..d533954 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 415750b..f7f8e23 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index 3fc736c..12f945e 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index c63def9..da84d95 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h index 27b9b0a..6708841 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h +++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 763d336..2200d57 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/vvp_lock.c b/drivers/staging/lustre/lustre/llite/vvp_lock.c index f5bd6c2..b5c307f 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_lock.c +++ b/drivers/staging/lustre/lustre/llite/vvp_lock.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c index 18c9df7..11c3004 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_object.c +++ b/drivers/staging/lustre/lustre/llite/vvp_object.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c index 6cd2af7..ae36c75 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_page.c +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 608014b..a286635 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lmv/lmv_fld.c b/drivers/staging/lustre/lustre/lmv/lmv_fld.c index 378691b..fcf1b1c 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_fld.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_fld.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index e0958ea..bdf28cd 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h index 7007e4c..267deef 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 1d9875e..800033d 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index b39e364..aa68623 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h index ac9744e..9a2e5e2 100644 --- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index dae8e89..21e3054 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index 460f0fa..2f8972f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index eef9afa..55fb5bf 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index 86cb3f8..cc70eeb 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index 1b203d1..2d87cfa 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c b/drivers/staging/lustre/lustre/lov/lov_merge.c index 56ef41d..f020656 100644 --- a/drivers/staging/lustre/lustre/lov/lov_merge.c +++ b/drivers/staging/lustre/lustre/lov/lov_merge.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index c179b31..9ca7e63 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index 561d493..08f3d5c 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_offset.c b/drivers/staging/lustre/lustre/lov/lov_offset.c index 7636bfa..2f568b5 100644 --- a/drivers/staging/lustre/lustre/lov/lov_offset.c +++ b/drivers/staging/lustre/lustre/lov/lov_offset.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 0215ea5..69f4a68 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c index 0306f00..6c97e6f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_page.c +++ b/drivers/staging/lustre/lustre/lov/lov_page.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index 690292e..75660c5 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see [sun.com URL with a * copy of GPLv2]. * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 1be4b92..83cd6e4 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index 35f6b1d..cddf3d6 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lovsub_io.c b/drivers/staging/lustre/lustre/lov/lovsub_io.c index 783ec68..c927406 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_io.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_io.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lovsub_lock.c b/drivers/staging/lustre/lustre/lov/lovsub_lock.c index e92edfb..06bfdf9 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_lock.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_lock.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lovsub_object.c b/drivers/staging/lustre/lustre/lov/lovsub_object.c index bcaae1e..a1a0f08 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_object.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_object.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lovsub_page.c b/drivers/staging/lustre/lustre/lov/lovsub_page.c index 9badedc..e8e3475 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_page.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_page.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 0dcb6b6..c5f7aac 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 5c7a15d..95a8fcd 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index c5519ae..cd57233 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index 856c54e..8411729 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 3b1bc91..c14c9df 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index 4ef3db1..8380c56 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 86b7445..e152429 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index 8d5bc5a..c77e120 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h index 82fb8f4..0eb31cc 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h +++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 2311a43..2a80d85 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c index 0e02ae9..9f4eaba 100644 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ b/drivers/staging/lustre/lustre/obdclass/acl.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/cl_internal.h b/drivers/staging/lustre/lustre/obdclass/cl_internal.h index 7eb0ad7..09a1884 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_internal.h +++ b/drivers/staging/lustre/lustre/obdclass/cl_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 583fb5f..dcc1b4e 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index 26a576b..737612a 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index 5940f30..14da4b1 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index b754f51..c014b69 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index f48816a..b8dd638 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/debug.c b/drivers/staging/lustre/lustre/obdclass/debug.c index e4edfb2..0786683 100644 --- a/drivers/staging/lustre/lustre/obdclass/debug.c +++ b/drivers/staging/lustre/lustre/obdclass/debug.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index d95f11d..2ec9eae 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c index 8405ecc..407c41e 100644 --- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c +++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 2cd4522..e7beee4 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c index b41b65e2..1d4a8d6 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c index e6bf414..58d1a44 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 55a9755..e100ada 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index c27d4ec..e64a5e5 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/llog_internal.h b/drivers/staging/lustre/lustre/obdclass/llog_internal.h index 7fb48dd..bce65fe 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_internal.h +++ b/drivers/staging/lustre/lustre/obdclass/llog_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index 826623f..b06dfe3 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index 967ba2e..b5281d8 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 5a1eae1..849deb1 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index e043857..1deaa2b 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ref.c b/drivers/staging/lustre/lustre/obdclass/lu_ref.c index 993697b..6363292 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_ref.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_ref.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 403ceea..6df2940 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c index b1abe02..e0e3a46 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index cb1d65c..39cfbc51 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index bc4e1e4..7dbf40e 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c index 748e33f..a62bf2b 100644 --- a/drivers/staging/lustre/lustre/obdclass/obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/obdo.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/statfs_pack.c b/drivers/staging/lustre/lustre/obdclass/statfs_pack.c index fb4e3ae..d633e22 100644 --- a/drivers/staging/lustre/lustre/obdclass/statfs_pack.c +++ b/drivers/staging/lustre/lustre/obdclass/statfs_pack.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdclass/uuid.c b/drivers/staging/lustre/lustre/obdclass/uuid.c index b0b0157..0dfa444 100644 --- a/drivers/staging/lustre/lustre/obdclass/uuid.c +++ b/drivers/staging/lustre/lustre/obdclass/uuid.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 91ef06f..d92d85c 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 33a1132..f7bdd0a 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 2ca5045..4eb1f2af 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index 7359fcb..78cab86 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index d4fe507..1d2938d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 7fad827..439118a 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index d3bce45..79159d9 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index d30ed2f..fef695b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index 738ab10a..2a8b3c2 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 5a3e694..9ed91c4 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 7b1fc7e..740c362 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 8336ed1..325cce1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index a14daff..a1f7d8c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index fdcde9b..af841cc 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index a236e38..2930193 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index c0ecd16..f0dca8e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index a23ac5f..f335b1f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c index fbccb62..ed3e88f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index ff40be2..8d67108 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index 10b8fe8..17dd6ea 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 811acf6..e7187a4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/pers.c b/drivers/staging/lustre/lustre/ptlrpc/pers.c index ec3af10..14608ef 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pers.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pers.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index d9d4ca2..8ae6fd1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index 6ca26c9..52eda29 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c index a8ec0e9..e7443f3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 76a355a..fd343819 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c index 30d9a16..5c69309 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 657b41f..9ec6417 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 02e6cda..34e2972 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index a51b18b..f7210c8 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c index 9082da0..15d0586 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c index e610a8d..bba4adf 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c index af92e9e..04381af 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index ec8edbf..a2dd435 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 17c7b97..f369a5e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index aacc810..4b9a23e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c @@ -17,10 +17,6 @@ * version 2 along with this program; If not, see * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* -- cgit v1.1 From 6a5b99a46bedc2cfbba96dec6d255c4b90af9ff8 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Tue, 14 Jun 2016 23:33:40 -0400 Subject: staging/lustre: Replace sun.com GPLv2 URL with gnu.org one. http://www.sun.com/software/products/lustre/docs/GPLv2.pdf is no longer around, so replae it with (hopefully more permanent) http://http://www.gnu.org/licenses/gpl-2.0.html Signed-off-by: Oleg Drokin Reported-by: Xose Vazquez Perez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/curproc.h | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs.h | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs_private.h | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs_string.h | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs_time.h | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h | 2 +- drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h | 2 +- drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h | 2 +- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 2 +- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 2 +- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 2 +- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c | 2 +- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 2 +- drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c | 2 +- drivers/staging/lustre/lnet/libcfs/debug.c | 2 +- drivers/staging/lustre/lnet/libcfs/hash.c | 2 +- drivers/staging/lustre/lnet/libcfs/libcfs_string.c | 2 +- drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c | 2 +- drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c | 2 +- drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c | 2 +- drivers/staging/lustre/lnet/libcfs/linux/linux-module.c | 2 +- drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c | 2 +- drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c | 2 +- drivers/staging/lustre/lnet/libcfs/module.c | 2 +- drivers/staging/lustre/lnet/libcfs/prng.c | 2 +- drivers/staging/lustre/lnet/libcfs/tracefile.c | 2 +- drivers/staging/lustre/lnet/libcfs/tracefile.h | 2 +- drivers/staging/lustre/lnet/libcfs/workitem.c | 2 +- drivers/staging/lustre/lnet/lnet/acceptor.c | 2 +- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- drivers/staging/lustre/lnet/lnet/config.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-eq.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-md.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-me.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-msg.c | 2 +- drivers/staging/lustre/lnet/lnet/lo.c | 2 +- drivers/staging/lustre/lnet/lnet/module.c | 2 +- drivers/staging/lustre/lnet/lnet/nidstrings.c | 2 +- drivers/staging/lustre/lnet/lnet/peer.c | 2 +- drivers/staging/lustre/lnet/selftest/brw_test.c | 2 +- drivers/staging/lustre/lnet/selftest/conctl.c | 2 +- drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +- drivers/staging/lustre/lnet/selftest/conrpc.h | 2 +- drivers/staging/lustre/lnet/selftest/console.c | 2 +- drivers/staging/lustre/lnet/selftest/console.h | 2 +- drivers/staging/lustre/lnet/selftest/framework.c | 2 +- drivers/staging/lustre/lnet/selftest/module.c | 2 +- drivers/staging/lustre/lnet/selftest/ping_test.c | 2 +- drivers/staging/lustre/lnet/selftest/rpc.c | 2 +- drivers/staging/lustre/lnet/selftest/rpc.h | 2 +- drivers/staging/lustre/lnet/selftest/selftest.h | 2 +- drivers/staging/lustre/lnet/selftest/timer.c | 2 +- drivers/staging/lustre/lnet/selftest/timer.h | 2 +- drivers/staging/lustre/lustre/fid/fid_internal.h | 2 +- drivers/staging/lustre/lustre/fid/fid_lib.c | 2 +- drivers/staging/lustre/lustre/fid/fid_request.c | 2 +- drivers/staging/lustre/lustre/fid/lproc_fid.c | 2 +- drivers/staging/lustre/lustre/fld/fld_cache.c | 2 +- drivers/staging/lustre/lustre/fld/fld_internal.h | 2 +- drivers/staging/lustre/lustre/fld/fld_request.c | 2 +- drivers/staging/lustre/lustre/fld/lproc_fld.c | 2 +- drivers/staging/lustre/lustre/include/cl_object.h | 2 +- drivers/staging/lustre/lustre/include/interval_tree.h | 2 +- drivers/staging/lustre/lustre/include/linux/lustre_compat25.h | 2 +- drivers/staging/lustre/lustre/include/linux/lustre_lite.h | 2 +- drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h | 2 +- drivers/staging/lustre/lustre/include/linux/lustre_user.h | 2 +- drivers/staging/lustre/lustre/include/lprocfs_status.h | 2 +- drivers/staging/lustre/lustre/include/lu_object.h | 2 +- drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h | 2 +- drivers/staging/lustre/lustre/include/lustre/lustre_idl.h | 2 +- drivers/staging/lustre/lustre/include/lustre/lustre_user.h | 2 +- drivers/staging/lustre/lustre/include/lustre_acl.h | 2 +- drivers/staging/lustre/lustre/include/lustre_cfg.h | 2 +- drivers/staging/lustre/lustre/include/lustre_debug.h | 2 +- drivers/staging/lustre/lustre/include/lustre_disk.h | 2 +- drivers/staging/lustre/lustre/include/lustre_dlm.h | 2 +- drivers/staging/lustre/lustre/include/lustre_eacl.h | 2 +- drivers/staging/lustre/lustre/include/lustre_export.h | 2 +- drivers/staging/lustre/lustre/include/lustre_fid.h | 2 +- drivers/staging/lustre/lustre/include/lustre_fld.h | 2 +- drivers/staging/lustre/lustre/include/lustre_ha.h | 2 +- drivers/staging/lustre/lustre/include/lustre_handles.h | 2 +- drivers/staging/lustre/lustre/include/lustre_import.h | 2 +- drivers/staging/lustre/lustre/include/lustre_intent.h | 2 +- drivers/staging/lustre/lustre/include/lustre_lib.h | 2 +- drivers/staging/lustre/lustre/include/lustre_lite.h | 2 +- drivers/staging/lustre/lustre/include/lustre_log.h | 2 +- drivers/staging/lustre/lustre/include/lustre_mdc.h | 2 +- drivers/staging/lustre/lustre/include/lustre_mds.h | 2 +- drivers/staging/lustre/lustre/include/lustre_net.h | 2 +- drivers/staging/lustre/lustre/include/lustre_param.h | 2 +- drivers/staging/lustre/lustre/include/lustre_req_layout.h | 2 +- drivers/staging/lustre/lustre/include/lustre_sec.h | 2 +- drivers/staging/lustre/lustre/include/obd.h | 2 +- drivers/staging/lustre/lustre/include/obd_cksum.h | 2 +- drivers/staging/lustre/lustre/include/obd_class.h | 2 +- drivers/staging/lustre/lustre/include/obd_support.h | 2 +- drivers/staging/lustre/lustre/ldlm/interval_tree.c | 2 +- drivers/staging/lustre/lustre/ldlm/l_lock.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_extent.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_plain.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 2 +- drivers/staging/lustre/lustre/llite/dcache.c | 2 +- drivers/staging/lustre/lustre/llite/dir.c | 2 +- drivers/staging/lustre/lustre/llite/file.c | 2 +- drivers/staging/lustre/lustre/llite/glimpse.c | 2 +- drivers/staging/lustre/lustre/llite/lcommon_cl.c | 2 +- drivers/staging/lustre/lustre/llite/lcommon_misc.c | 2 +- drivers/staging/lustre/lustre/llite/llite_close.c | 2 +- drivers/staging/lustre/lustre/llite/llite_internal.h | 2 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 2 +- drivers/staging/lustre/lustre/llite/llite_mmap.c | 2 +- drivers/staging/lustre/lustre/llite/llite_nfs.c | 2 +- drivers/staging/lustre/lustre/llite/llite_rmtacl.c | 2 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- drivers/staging/lustre/lustre/llite/namei.c | 2 +- drivers/staging/lustre/lustre/llite/remote_perm.c | 2 +- drivers/staging/lustre/lustre/llite/rw.c | 2 +- drivers/staging/lustre/lustre/llite/rw26.c | 2 +- drivers/staging/lustre/lustre/llite/statahead.c | 2 +- drivers/staging/lustre/lustre/llite/super25.c | 2 +- drivers/staging/lustre/lustre/llite/symlink.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_dev.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_internal.h | 2 +- drivers/staging/lustre/lustre/llite/vvp_io.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_lock.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_object.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_page.c | 2 +- drivers/staging/lustre/lustre/llite/xattr.c | 2 +- drivers/staging/lustre/lustre/lmv/lmv_fld.c | 2 +- drivers/staging/lustre/lustre/lmv/lmv_intent.c | 2 +- drivers/staging/lustre/lustre/lmv/lmv_internal.h | 2 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 2 +- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 2 +- drivers/staging/lustre/lustre/lov/lov_cl_internal.h | 2 +- drivers/staging/lustre/lustre/lov/lov_dev.c | 2 +- drivers/staging/lustre/lustre/lov/lov_ea.c | 2 +- drivers/staging/lustre/lustre/lov/lov_internal.h | 2 +- drivers/staging/lustre/lustre/lov/lov_io.c | 2 +- drivers/staging/lustre/lustre/lov/lov_lock.c | 2 +- drivers/staging/lustre/lustre/lov/lov_merge.c | 2 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 2 +- drivers/staging/lustre/lustre/lov/lov_object.c | 2 +- drivers/staging/lustre/lustre/lov/lov_offset.c | 2 +- drivers/staging/lustre/lustre/lov/lov_pack.c | 2 +- drivers/staging/lustre/lustre/lov/lov_page.c | 2 +- drivers/staging/lustre/lustre/lov/lov_request.c | 2 +- drivers/staging/lustre/lustre/lov/lovsub_dev.c | 2 +- drivers/staging/lustre/lustre/lov/lovsub_io.c | 2 +- drivers/staging/lustre/lustre/lov/lovsub_lock.c | 2 +- drivers/staging/lustre/lustre/lov/lovsub_object.c | 2 +- drivers/staging/lustre/lustre/lov/lovsub_page.c | 2 +- drivers/staging/lustre/lustre/lov/lproc_lov.c | 2 +- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_internal.h | 2 +- drivers/staging/lustre/lustre/mdc/mdc_lib.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +- drivers/staging/lustre/lustre/mgc/lproc_mgc.c | 2 +- drivers/staging/lustre/lustre/mgc/mgc_internal.h | 2 +- drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +- drivers/staging/lustre/lustre/obdclass/acl.c | 2 +- drivers/staging/lustre/lustre/obdclass/cl_internal.h | 2 +- drivers/staging/lustre/lustre/obdclass/cl_io.c | 2 +- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 2 +- drivers/staging/lustre/lustre/obdclass/cl_object.c | 2 +- drivers/staging/lustre/lustre/obdclass/cl_page.c | 2 +- drivers/staging/lustre/lustre/obdclass/class_obd.c | 2 +- drivers/staging/lustre/lustre/obdclass/debug.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 2 +- drivers/staging/lustre/lustre/obdclass/kernelcomm.c | 2 +- drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 2 +- drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c | 2 +- drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c | 2 +- drivers/staging/lustre/lustre/obdclass/llog.c | 2 +- drivers/staging/lustre/lustre/obdclass/llog_cat.c | 2 +- drivers/staging/lustre/lustre/obdclass/llog_internal.h | 2 +- drivers/staging/lustre/lustre/obdclass/llog_obd.c | 2 +- drivers/staging/lustre/lustre/obdclass/llog_swab.c | 2 +- drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 2 +- drivers/staging/lustre/lustre/obdclass/lu_object.c | 2 +- drivers/staging/lustre/lustre/obdclass/lu_ref.c | 2 +- drivers/staging/lustre/lustre/obdclass/lustre_handles.c | 2 +- drivers/staging/lustre/lustre/obdclass/lustre_peer.c | 2 +- drivers/staging/lustre/lustre/obdclass/obd_config.c | 2 +- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 2 +- drivers/staging/lustre/lustre/obdclass/obdo.c | 2 +- drivers/staging/lustre/lustre/obdclass/statfs_pack.c | 2 +- drivers/staging/lustre/lustre/obdclass/uuid.c | 2 +- drivers/staging/lustre/lustre/obdecho/echo_client.c | 2 +- drivers/staging/lustre/lustre/osc/lproc_osc.c | 2 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 2 +- drivers/staging/lustre/lustre/osc/osc_cl_internal.h | 2 +- drivers/staging/lustre/lustre/osc/osc_dev.c | 2 +- drivers/staging/lustre/lustre/osc/osc_internal.h | 2 +- drivers/staging/lustre/lustre/osc/osc_io.c | 2 +- drivers/staging/lustre/lustre/osc/osc_lock.c | 2 +- drivers/staging/lustre/lustre/osc/osc_object.c | 2 +- drivers/staging/lustre/lustre/osc/osc_page.c | 2 +- drivers/staging/lustre/lustre/osc/osc_request.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/client.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/connection.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/events.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/layout.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/llog_client.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/llog_net.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/pack_generic.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/pers.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h | 2 +- drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/recover.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec_null.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 2 +- 240 files changed, 240 insertions(+), 240 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h index c673dfc..be0675d 100644 --- a/drivers/staging/lustre/include/linux/libcfs/curproc.h +++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index c93d58e..3f6447c 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index ae8175c..25adab1 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h index 6a4387b..6949a18 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h index 9bdff3f..cce6b58 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h index 881aae0..8c75d50 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index c44e11d..4daa382 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h index 03939ce..0ee60ff 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_string.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h index 3f0ec7a..008da44 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h index 5ff23bb..a7e1340 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_workitem.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h index 3652119..e8695e4 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h index 887811b..b646acd 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index f0c0669..4f5978b 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index 69711ee..b66ab79 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index 5dde5ff..adc346a 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c index 24de544..44e960f 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 67d8bf2..d4e7dae 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c index defe041..6a17757 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c b/drivers/staging/lustre/lnet/libcfs/debug.c index 0079a4c..75a2a42 100644 --- a/drivers/staging/lustre/lnet/libcfs/debug.c +++ b/drivers/staging/lustre/lnet/libcfs/debug.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/libcfs/hash.c b/drivers/staging/lustre/lnet/libcfs/hash.c index db51124..23283b6 100644 --- a/drivers/staging/lustre/lnet/libcfs/hash.c +++ b/drivers/staging/lustre/lnet/libcfs/hash.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_string.c b/drivers/staging/lustre/lnet/libcfs/libcfs_string.c index 750691c..fc697cd 100644 --- a/drivers/staging/lustre/lnet/libcfs/libcfs_string.c +++ b/drivers/staging/lustre/lnet/libcfs/libcfs_string.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c index 4fe58dd..3e22cad 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-curproc.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c index 808d09b..435b784 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-debug.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c index 86f32ff..a6a76a6 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-mem.c @@ -11,7 +11,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c index 8caee5b..38308f8b 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c index c1152e6..291d286 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-prim.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c index 6c9e3976..8b551d27 100644 --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-tracefile.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c index 065f968..86b4d25 100644 --- a/drivers/staging/lustre/lnet/libcfs/module.c +++ b/drivers/staging/lustre/lnet/libcfs/module.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/libcfs/prng.c b/drivers/staging/lustre/lnet/libcfs/prng.c index f2e8426..a9bdb28 100644 --- a/drivers/staging/lustre/lnet/libcfs/prng.c +++ b/drivers/staging/lustre/lnet/libcfs/prng.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c index ba0e7c3..1c7efdf 100644 --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.h b/drivers/staging/lustre/lnet/libcfs/tracefile.h index ae1c614..d878676 100644 --- a/drivers/staging/lustre/lnet/libcfs/tracefile.h +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/libcfs/workitem.c b/drivers/staging/lustre/lnet/libcfs/workitem.c index c51f389..e98c818 100644 --- a/drivers/staging/lustre/lnet/libcfs/workitem.c +++ b/drivers/staging/lustre/lnet/libcfs/workitem.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 4456286..8c50c99 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 7662c3b..48327ca 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c index 358e5cf..a72afdf 100644 --- a/drivers/staging/lustre/lnet/lnet/config.c +++ b/drivers/staging/lustre/lnet/lnet/config.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index d04c687..d05c6cc 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c index 51145f1..1834bf7 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-md.c +++ b/drivers/staging/lustre/lnet/lnet/lib-md.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c index 1c370f4..b430046 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-me.c +++ b/drivers/staging/lustre/lnet/lnet/lib-me.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index f5c6eac..e6d3b80 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index 77ae4e6..910e106 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/lnet/lo.c b/drivers/staging/lustre/lnet/lnet/lo.c index 6441ef3..08402712 100644 --- a/drivers/staging/lustre/lnet/lnet/lo.c +++ b/drivers/staging/lustre/lnet/lnet/lo.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index 40f3c52..58cf246 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/lnet/nidstrings.c b/drivers/staging/lustre/lnet/lnet/nidstrings.c index 74bfda1..a6d7a61 100644 --- a/drivers/staging/lustre/lnet/lnet/nidstrings.c +++ b/drivers/staging/lustre/lnet/lnet/nidstrings.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c index 5fde05a..e806191 100644 --- a/drivers/staging/lustre/lnet/lnet/peer.c +++ b/drivers/staging/lustre/lnet/lnet/peer.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index 6e25e1a..13d0454 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c index 9a22f33..b786f8b 100644 --- a/drivers/staging/lustre/lnet/selftest/conctl.c +++ b/drivers/staging/lustre/lnet/selftest/conctl.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index e649d37..1be3cad 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.h b/drivers/staging/lustre/lnet/selftest/conrpc.h index 1d8bb63..7ec6fc9 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.h +++ b/drivers/staging/lustre/lnet/selftest/conrpc.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index 31001f4..4c33621 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/selftest/console.h b/drivers/staging/lustre/lnet/selftest/console.h index b099946..78b1477 100644 --- a/drivers/staging/lustre/lnet/selftest/console.h +++ b/drivers/staging/lustre/lnet/selftest/console.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c index 0d53307..c2f121f 100644 --- a/drivers/staging/lustre/lnet/selftest/framework.c +++ b/drivers/staging/lustre/lnet/selftest/framework.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c index b6a3bdf..71485f9 100644 --- a/drivers/staging/lustre/lnet/selftest/module.c +++ b/drivers/staging/lustre/lnet/selftest/module.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c index 3030c07..9331ca4 100644 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index e7aba01..3b26d6e 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/selftest/rpc.h b/drivers/staging/lustre/lnet/selftest/rpc.h index 3254f5d..4ab2ee2 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.h +++ b/drivers/staging/lustre/lnet/selftest/rpc.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h index 4a1d2b2..1b21a1a 100644 --- a/drivers/staging/lustre/lnet/selftest/selftest.h +++ b/drivers/staging/lustre/lnet/selftest/selftest.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * copy of GPLv2]. * * GPL HEADER END diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c index c73ded9..dcd2258 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.c +++ b/drivers/staging/lustre/lnet/selftest/timer.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lnet/selftest/timer.h b/drivers/staging/lustre/lnet/selftest/timer.h index e86e44e..441d6d6 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.h +++ b/drivers/staging/lustre/lnet/selftest/timer.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/fid/fid_internal.h b/drivers/staging/lustre/lustre/fid/fid_internal.h index d6aebb3..5c53773e 100644 --- a/drivers/staging/lustre/lustre/fid/fid_internal.h +++ b/drivers/staging/lustre/lustre/fid/fid_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/fid/fid_lib.c b/drivers/staging/lustre/lustre/fid/fid_lib.c index ee7b272..99ae7eb 100644 --- a/drivers/staging/lustre/lustre/fid/fid_lib.c +++ b/drivers/staging/lustre/lustre/fid/fid_lib.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index 00b19c7..454744d 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index 0103af5..81b7ca9 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index cb33d41..0100a93 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h index a85d86a..f0efe5b 100644 --- a/drivers/staging/lustre/lustre/fld/fld_internal.h +++ b/drivers/staging/lustre/lustre/fld/fld_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index 5f43af4..e59d626 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index 1b96880..61ac420 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index a5a28f5..36ca935 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/interval_tree.h b/drivers/staging/lustre/lustre/include/interval_tree.h index 64cab4b..4a15228 100644 --- a/drivers/staging/lustre/lustre/include/interval_tree.h +++ b/drivers/staging/lustre/lustre/include/interval_tree.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 7690fa7..1eb64ec 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h index abefa93..d18e8a7 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h index 6d138b2..5842cb1 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_user.h b/drivers/staging/lustre/lustre/include/linux/lustre_user.h index 7403139..e967950 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_user.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 4f5ab54..d68e60e 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index b7bfe39..c6281e6 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h b/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h index 664f135..c2340d6 100644 --- a/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h +++ b/drivers/staging/lustre/lustre/include/lustre/ll_fiemap.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index e5031b1..bf8a0cd 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index 3b48ba5..a6e351a 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_acl.h b/drivers/staging/lustre/lustre/include/lustre_acl.h index 9773db7..fecabe1 100644 --- a/drivers/staging/lustre/lustre/include/lustre_acl.h +++ b/drivers/staging/lustre/lustre/include/lustre_acl.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index f532af6..95a0be1 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_debug.h b/drivers/staging/lustre/lustre/include/lustre_debug.h index bd531ff..93c1bda 100644 --- a/drivers/staging/lustre/lustre/include/lustre_debug.h +++ b/drivers/staging/lustre/lustre/include/lustre_debug.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h index f30c601..8886458 100644 --- a/drivers/staging/lustre/lustre/include/lustre_disk.h +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index bdc1da7..63085a0 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_eacl.h b/drivers/staging/lustre/lustre/include/lustre_eacl.h index caab6e3..e5eadc4 100644 --- a/drivers/staging/lustre/lustre/include/lustre_eacl.h +++ b/drivers/staging/lustre/lustre/include/lustre_eacl.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index 41b6a7c..7c3ed55 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index e3794d6..cbdd91a 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h index 6a91cbc..932410d 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fld.h +++ b/drivers/staging/lustre/lustre/include/lustre_fld.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_ha.h b/drivers/staging/lustre/lustre/include/lustre_ha.h index 152b0ee..cde7ed7 100644 --- a/drivers/staging/lustre/lustre/include/lustre_ha.h +++ b/drivers/staging/lustre/lustre/include/lustre_ha.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h index c1906c2..1a63a6b 100644 --- a/drivers/staging/lustre/lustre/include/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/lustre_handles.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index d4f7680..4445be7 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_intent.h b/drivers/staging/lustre/lustre/include/lustre_intent.h index d5b15a4..fdc6236 100644 --- a/drivers/staging/lustre/lustre/include/lustre_intent.h +++ b/drivers/staging/lustre/lustre/include/lustre_intent.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index f7b0ce8..06958f2 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_lite.h b/drivers/staging/lustre/lustre/include/lustre_lite.h index bd328e5..b168977 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lite.h +++ b/drivers/staging/lustre/lustre/include/lustre_lite.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index 7a3940a..b96e023 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index cc4158c..0ef4226 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_mds.h b/drivers/staging/lustre/lustre/include/lustre_mds.h index 9bcd3cd..4104bd9 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mds.h +++ b/drivers/staging/lustre/lustre/include/lustre_mds.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index ce31181..dba4d1d 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_param.h b/drivers/staging/lustre/lustre/include/lustre_param.h index dc6f2b2..82aadd3 100644 --- a/drivers/staging/lustre/lustre/include/lustre_param.h +++ b/drivers/staging/lustre/lustre/include/lustre_param.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_req_layout.h b/drivers/staging/lustre/lustre/include/lustre_req_layout.h index acbc310..d00aae5 100644 --- a/drivers/staging/lustre/lustre/include/lustre_req_layout.h +++ b/drivers/staging/lustre/lustre/include/lustre_req_layout.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h index 7ca6204..ed4b4c7 100644 --- a/drivers/staging/lustre/lustre/include/lustre_sec.h +++ b/drivers/staging/lustre/lustre/include/lustre_sec.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 6c94fa4..e654d42 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/obd_cksum.h b/drivers/staging/lustre/lustre/include/obd_cksum.h index 02705a5..a8a81e6 100644 --- a/drivers/staging/lustre/lustre/include/obd_cksum.h +++ b/drivers/staging/lustre/lustre/include/obd_cksum.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index c7a71b2..2196744 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index ce5be73..cdf20d6 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c index 59bb066..f4a70eb 100644 --- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c +++ b/drivers/staging/lustre/lustre/ldlm/interval_tree.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ldlm/l_lock.c b/drivers/staging/lustre/lustre/ldlm/l_lock.c index c6f7dfd..ea8840c 100644 --- a/drivers/staging/lustre/lustre/ldlm/l_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/l_lock.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index 16c1621..f5023d9 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index 6c0dd7a..38c507f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c b/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c index d98243d..79f4e6f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_inodebits.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index cc5e654..e4cf65d 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 1a7eee3..7c832aa 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 88e9192..1ecdfa2 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 1da0eb2..3eab059 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c b/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c index 621a490..0aed39c 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_plain.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 1d9ca31..657ed40 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index f6b30f6..471ab08 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 771c1f8..f7c95b7 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 908bdc6..9d13d5e 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 8854029a..99735f6 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 104129b..4602596 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/glimpse.c b/drivers/staging/lustre/lustre/llite/glimpse.c index 8788ee0..92004a05 100644 --- a/drivers/staging/lustre/lustre/llite/glimpse.c +++ b/drivers/staging/lustre/lustre/llite/glimpse.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/lcommon_cl.c b/drivers/staging/lustre/lustre/llite/lcommon_cl.c index 28b7482..396e4e4f 100644 --- a/drivers/staging/lustre/lustre/llite/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/llite/lcommon_cl.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/lcommon_misc.c b/drivers/staging/lustre/lustre/llite/lcommon_misc.c index e45bd6d..8a508ed 100644 --- a/drivers/staging/lustre/lustre/llite/lcommon_misc.c +++ b/drivers/staging/lustre/lustre/llite/lcommon_misc.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index 2e2abc7..2326b40 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index f541634..7c1a3254 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index f513b74..ac833db 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index b569df3..fb1c3b6 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index 086e827..d7878e5 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c index bae3ff0..edb92f9 100644 --- a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c +++ b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 2b3a777..6e9a8a5 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index b7ec512..d7459bd 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/remote_perm.c b/drivers/staging/lustre/lustre/llite/remote_perm.c index 0b96175..9df9e784 100644 --- a/drivers/staging/lustre/lustre/llite/remote_perm.c +++ b/drivers/staging/lustre/lustre/llite/remote_perm.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index df6cb54..87393c4 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index d45fdcb..d98c7ac 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index d533954..03ad858 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index f7f8e23..b40ea79 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index 12f945e..8c8bdfe 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index da84d95..6c09fb2 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/vvp_internal.h b/drivers/staging/lustre/lustre/llite/vvp_internal.h index 6708841..79fc428 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_internal.h +++ b/drivers/staging/lustre/lustre/llite/vvp_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 2200d57..94916dc 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/vvp_lock.c b/drivers/staging/lustre/lustre/llite/vvp_lock.c index b5c307f..64be0c9 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_lock.c +++ b/drivers/staging/lustre/lustre/llite/vvp_lock.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c index 11c3004..2c520b0 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_object.c +++ b/drivers/staging/lustre/lustre/llite/vvp_object.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c index ae36c75..2e566d9 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_page.c +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index a286635..6ce790e 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lmv/lmv_fld.c b/drivers/staging/lustre/lustre/lmv/lmv_fld.c index fcf1b1c..a3d170a 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_fld.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_fld.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index bdf28cd..980c9d4 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h index 267deef..0beafc4 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h +++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 800033d..ab4f4fb 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index aa68623..c29c361 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h index 9a2e5e2..9740568 100644 --- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index 21e3054..b1f260d 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index 2f8972f..5053dea 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index 55fb5bf..12bd511 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index cc70eeb..84032a51 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index 2d87cfa..f3a0583 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c b/drivers/staging/lustre/lustre/lov/lov_merge.c index f020656..b9c9086 100644 --- a/drivers/staging/lustre/lustre/lov/lov_merge.c +++ b/drivers/staging/lustre/lustre/lov/lov_merge.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 9ca7e63..c87096e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index 08f3d5c..ec55b88 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lov_offset.c b/drivers/staging/lustre/lustre/lov/lov_offset.c index 2f568b5..ecca74f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_offset.c +++ b/drivers/staging/lustre/lustre/lov/lov_offset.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 69f4a68..869ef41 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c index 6c97e6f..c17026f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_page.c +++ b/drivers/staging/lustre/lustre/lov/lov_page.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 83cd6e4..4099b51 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index cddf3d6..b519a19 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lovsub_io.c b/drivers/staging/lustre/lustre/lov/lovsub_io.c index c927406..6a98202 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_io.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_io.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lovsub_lock.c b/drivers/staging/lustre/lustre/lov/lovsub_lock.c index 06bfdf9..38f9b73 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_lock.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_lock.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lovsub_object.c b/drivers/staging/lustre/lustre/lov/lovsub_object.c index a1a0f08..fb2f266 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_object.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_object.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lovsub_page.c b/drivers/staging/lustre/lustre/lov/lovsub_page.c index e8e3475..b2e68c3 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_page.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_page.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index c5f7aac..eb6d30d 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 95a8fcd..98d15fb 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h index cd57233..58f2841 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h +++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index 8411729..2703113 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index c14c9df..b395420 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index 8380c56..661488e 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index e152429..12cb238 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index c77e120..0735220 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h index 0eb31cc..f146f75 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h +++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 2a80d85..69f5337 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c index 9f4eaba..30d8b42 100644 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ b/drivers/staging/lustre/lustre/obdclass/acl.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/cl_internal.h b/drivers/staging/lustre/lustre/obdclass/cl_internal.h index 09a1884..e866754 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_internal.h +++ b/drivers/staging/lustre/lustre/obdclass/cl_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index dcc1b4e..e72f1fc 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index 737612a..9d7b593 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index 14da4b1..615158a 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index c014b69..71bff49 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index b8dd638..d9d2a19 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/debug.c b/drivers/staging/lustre/lustre/obdclass/debug.c index 0786683..8acf672 100644 --- a/drivers/staging/lustre/lustre/obdclass/debug.c +++ b/drivers/staging/lustre/lustre/obdclass/debug.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 2ec9eae..99c2da6 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c index 407c41e..a0f65c4 100644 --- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c +++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index e7beee4..33342bf 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c index 1d4a8d6..c6cc6a7 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c index 58d1a44..8f70dd2 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index e100ada..1784ca0 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index e64a5e5..a82a295 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/llog_internal.h b/drivers/staging/lustre/lustre/obdclass/llog_internal.h index bce65fe..f794952 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_internal.h +++ b/drivers/staging/lustre/lustre/obdclass/llog_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index b06dfe3..6ace7e0 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index b5281d8..f7b9b19 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 849deb1..279b625 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 1deaa2b..9b03059 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ref.c b/drivers/staging/lustre/lustre/obdclass/lu_ref.c index 6363292..e9f6040 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_ref.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_ref.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 6df2940..082f530 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c index e0e3a46..5974a9b 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 39cfbc51..694c58e 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 7dbf40e..aa84a50e 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c index a62bf2b..8583a4a 100644 --- a/drivers/staging/lustre/lustre/obdclass/obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/obdo.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/statfs_pack.c b/drivers/staging/lustre/lustre/obdclass/statfs_pack.c index d633e22..4bad1fa 100644 --- a/drivers/staging/lustre/lustre/obdclass/statfs_pack.c +++ b/drivers/staging/lustre/lustre/obdclass/statfs_pack.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdclass/uuid.c b/drivers/staging/lustre/lustre/obdclass/uuid.c index 0dfa444..abd9b1a 100644 --- a/drivers/staging/lustre/lustre/obdclass/uuid.c +++ b/drivers/staging/lustre/lustre/obdclass/uuid.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index d92d85c..5b29c4a 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index f7bdd0a..7e83d39 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 4eb1f2af..1a6df43 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index 78cab86..437c659 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index 1d2938d..83d30c1 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h index 439118a..7a27f09 100644 --- a/drivers/staging/lustre/lustre/osc/osc_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 79159d9..6e3dcd3 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index fef695b..42def38 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index 2a8b3c2..d211d19 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 9ed91c4..57d8a5a 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 740c362..7260027 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 325cce1..22bf893 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index a1f7d8c..177a379 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index af841cc..b8ca7d6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 2930193..914bbd2 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index f0dca8e..e6ff97d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index f335b1f..0f55c01 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c index ed3e88f..bccdace 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 8d67108..fe6f7a6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index 17dd6ea..ff9a95c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index e7187a4..9ff58a1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/pers.c b/drivers/staging/lustre/lustre/ptlrpc/pers.c index 14608ef..6c820e9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pers.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pers.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 8ae6fd1..c0529d8 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index 52eda29..97e97e2 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c index e7443f3..a70d584 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index fd343819..b0cf585 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c index 5c69309..718b3a8 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 9ec6417..7ab3ae9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 34e2972..b3e3ed9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index f7210c8..303bf96 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c index 15d0586..9b9801e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c index bba4adf..07273f5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c index 04381af..3306233 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index a2dd435..ea79b15 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index f369a5e..4788c49 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index 4b9a23e..9fd9de9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ -- cgit v1.1 From 06894eed50785979228f0068e135131aebd03ff1 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Tue, 14 Jun 2016 23:33:41 -0400 Subject: staging/lustre/lov: Fix gpl URL in lov_pool.c There's no longer a matching sun.com URL, so refer to gnu.org copy. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_pool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index 75660c5..4c2d217 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -14,8 +14,8 @@ * in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see [sun.com URL with a - * copy of GPLv2]. + * version 2 along with this program; If not, see + * http://http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ -- cgit v1.1 From 837e4e6e51622e8714b670058b400bcbfcfe934c Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Tue, 14 Jun 2016 23:33:42 -0400 Subject: staging/lustre: Remove stray line from selftest/selftest.h The 'copy of GPLv2]' is an ending from template that's no longer needed, so remove it to avoid any extra confusion. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/selftest/selftest.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h index 1b21a1a..d033ac0 100644 --- a/drivers/staging/lustre/lnet/selftest/selftest.h +++ b/drivers/staging/lustre/lnet/selftest/selftest.h @@ -16,7 +16,6 @@ * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see * http://www.gnu.org/licenses/gpl-2.0.html - * copy of GPLv2]. * * GPL HEADER END */ -- cgit v1.1 From 82ce9365ced9a4c454bfd64ba403ab7e1f33a110 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Tue, 14 Jun 2016 23:33:43 -0400 Subject: staging/lustre/libcfs: Remove "Please contact Oracle" from header The "Please contact Oracle Corporation" lines are removed since not only Oracle has nothing to do with Lustre anymore, there's a pointer to GPL already that's independent of any particular company. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h | 4 ---- drivers/staging/lustre/lnet/libcfs/fail.c | 4 ---- 2 files changed, 8 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h index 2e008bf..d3f9a60 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_fail.h @@ -16,10 +16,6 @@ * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see http://www.gnu.org/licenses * - * Please contact Oracle Corporation, Inc., 500 Oracle Parkway, Redwood Shores, - * CA 94065 USA or visit www.oracle.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* diff --git a/drivers/staging/lustre/lnet/libcfs/fail.c b/drivers/staging/lustre/lnet/libcfs/fail.c index 086e690..9288ee0 100644 --- a/drivers/staging/lustre/lnet/libcfs/fail.c +++ b/drivers/staging/lustre/lnet/libcfs/fail.c @@ -16,10 +16,6 @@ * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see http://www.gnu.org/licenses * - * Please contact Oracle Corporation, Inc., 500 Oracle Parkway, Redwood Shores, - * CA 94065 USA or visit www.oracle.com if you need additional information or - * have any questions. - * * GPL HEADER END */ /* -- cgit v1.1 From 7e573494b8940dd9089de734f47e6933fb46474d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:39 -0700 Subject: staging: comedi: das16m1: tidy up copyright and comedi comments Fix the checkpatch.pl issue: WARNING: Block comments use * on subsequent lines Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 98 +++++++++++++++----------------- 1 file changed, 47 insertions(+), 51 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 3a37373..90d3869 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -1,56 +1,52 @@ /* - comedi/drivers/das16m1.c - CIO-DAS16/M1 driver - Author: Frank Mori Hess, based on code from the das16 - driver. - Copyright (C) 2001 Frank Mori Hess - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 2000 David A. Schleef - - 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. -*/ + * Comedi driver for CIO-DAS16/M1 + * Author: Frank Mori Hess, based on code from the das16 driver. + * Copyright (C) 2001 Frank Mori Hess + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef + * + * 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. + */ + /* -Driver: das16m1 -Description: CIO-DAS16/M1 -Author: Frank Mori Hess -Devices: [Measurement Computing] CIO-DAS16/M1 (das16m1) -Status: works - -This driver supports a single board - the CIO-DAS16/M1. -As far as I know, there are no other boards that have -the same register layout. Even the CIO-DAS16/M1/16 is -significantly different. - -I was _barely_ able to reach the full 1 MHz capability -of this board, using a hard real-time interrupt -(set the TRIG_RT flag in your struct comedi_cmd and use -rtlinux or RTAI). The board can't do dma, so the bottleneck is -pulling the data across the ISA bus. I timed the interrupt -handler, and it took my computer ~470 microseconds to pull 512 -samples from the board. So at 1 Mhz sampling rate, -expect your CPU to be spending almost all of its -time in the interrupt handler. - -This board has some unusual restrictions for its channel/gain list. If the -list has 2 or more channels in it, then two conditions must be satisfied: -(1) - even/odd channels must appear at even/odd indices in the list -(2) - the list must have an even number of entries. - -Options: - [0] - base io address - [1] - irq (optional, but you probably want it) - -irq can be omitted, although the cmd interface will not work without it. -*/ + * Driver: das16m1 + * Description: CIO-DAS16/M1 + * Author: Frank Mori Hess + * Devices: [Measurement Computing] CIO-DAS16/M1 (das16m1) + * Status: works + * + * This driver supports a single board - the CIO-DAS16/M1. As far as I know, + * there are no other boards that have the same register layout. Even the + * CIO-DAS16/M1/16 is significantly different. + * + * I was _barely_ able to reach the full 1 MHz capability of this board, using + * a hard real-time interrupt (set the TRIG_RT flag in your struct comedi_cmd + * and use rtlinux or RTAI). The board can't do dma, so the bottleneck is + * pulling the data across the ISA bus. I timed the interrupt handler, and it + * took my computer ~470 microseconds to pull 512 samples from the board. So + * at 1 Mhz sampling rate, expect your CPU to be spending almost all of its + * time in the interrupt handler. + * + * This board has some unusual restrictions for its channel/gain list. If the + * list has 2 or more channels in it, then two conditions must be satisfied: + * (1) - even/odd channels must appear at even/odd indices in the list + * (2) - the list must have an even number of entries. + * + * Configuration options: + * [0] - base io address + * [1] - irq (optional, but you probably want it) + * + * irq can be omitted, although the cmd interface will not work without it. + */ #include #include -- cgit v1.1 From 27eeef415d2b0a3f07bfc5c5c2446a35ab87e5f7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:40 -0700 Subject: staging: comedi: das16m1: tidy up comments in das16m1_handler() Fix the checkpatch.pl issue: WARNING: Block comments use a trailing */ on a separate line Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 90d3869..75e096a 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -405,20 +405,24 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status) /* figure out how many samples are in fifo */ hw_counter = comedi_8254_read(devpriv->counter, 1); - /* make sure hardware counter reading is not bogus due to initial value - * not having been loaded yet */ + /* + * Make sure hardware counter reading is not bogus due to initial + * value not having been loaded yet. + */ if (devpriv->adc_count == 0 && hw_counter == devpriv->initial_hw_count) { num_samples = 0; } else { - /* The calculation of num_samples looks odd, but it uses the + /* + * The calculation of num_samples looks odd, but it uses the * following facts. 16 bit hardware counter is initialized with * value of zero (which really means 0x1000). The counter * decrements by one on each conversion (when the counter * decrements from zero it goes to 0xffff). num_samples is a * 16 bit variable, so it will roll over in a similar fashion * to the hardware counter. Work it out, and this is what you - * get. */ + * get. + */ num_samples = -hw_counter - devpriv->adc_count; } /* check if we only need some of the points */ @@ -441,8 +445,10 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status) } } - /* this probably won't catch overruns since the card doesn't generate - * overrun interrupts, but we might as well try */ + /* + * This probably won't catch overruns since the card doesn't generate + * overrun interrupts, but we might as well try. + */ if (status & OVRUN) { async->events |= COMEDI_CB_ERROR; dev_err(dev->class_dev, "fifo overflow\n"); -- cgit v1.1 From 50ac3ae33bff7ffa20b47bba4c372f6976ea2be3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:41 -0700 Subject: staging: comedi: das16m1: tidy up comment in das16m1_cmd_exec() Fix the checkpatch.pl issue: WARNING: Block comments use a trailing */ on a separate line Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 75e096a..05ceb13 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -291,8 +291,10 @@ static int das16m1_cmd_exec(struct comedi_device *dev, /* set control & status register */ byte = 0; - /* if we are using external start trigger (also board dislikes having - * both start and conversion triggers external simultaneously) */ + /* + * If we are using external start trigger (also board dislikes having + * both start and conversion triggers external simultaneously). + */ if (cmd->start_src == TRIG_EXT && cmd->convert_src != TRIG_EXT) byte |= EXT_TRIG_BIT; -- cgit v1.1 From 3cea946df7ba1ad96512ba0fb7609683eafb66c9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:42 -0700 Subject: staging: comedi: das16m1: remove unnecessary private data comments These comments are just extra cruft. Removing them also fixes a checkpatch.pl issue: WARNING: Block comments use a trailing */ on a separate line Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 05ceb13..078b26e 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -120,10 +120,7 @@ static const struct comedi_lrange range_das16m1 = { struct das16m1_private_struct { struct comedi_8254 *counter; unsigned int control_state; - unsigned int adc_count; /* number of samples completed */ - /* initial value in lower half of hardware conversion counter, - * needed to keep track of whether new count has been loaded into - * counter yet (loaded by first sample conversion) */ + unsigned int adc_count; u16 initial_hw_count; unsigned short ai_buffer[FIFO_SIZE]; unsigned long extra_iobase; -- cgit v1.1 From 07cbd594f02abe3b414a9318578fd44be1be51b7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:43 -0700 Subject: staging: comedi: das16m1: tidy up register map comment The comment about all the registers is not neccessary. The defines give the same information. This also fixes a checkpatch.pl issue: WARNING: Block comments use * on subsequent lines Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 078b26e..6638a9a 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -61,25 +61,8 @@ #define FIFO_SIZE 1024 /* 1024 sample fifo */ /* - CIO-DAS16_M1.pdf - - "cio-das16/m1" - - 0 a/d bits 0-3, mux start 12 bit - 1 a/d bits 4-11 unused - 2 status control - 3 di 4 bit do 4 bit - 4 unused clear interrupt - 5 interrupt, pacer - 6 channel/gain queue address - 7 channel/gain queue data - 89ab 8254 - cdef 8254 - 400 8255 - 404-407 8254 - -*/ - + * Register map (dev->iobase) + */ #define DAS16M1_AI 0 /* 16-bit wide register */ #define AI_CHAN(x) ((x) & 0xf) #define DAS16M1_CS 2 -- cgit v1.1 From a782a851e3ba67e4bd8360b1429cde3ece7d6957 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:44 -0700 Subject: staging: comedi: das16m1: tidy up analog input data register defines Convert the inline helper munge_sample() into a macro and rename the defines for the analog input data register/bits. Use the register define when accessing this register instead of just dev->iobase. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 6638a9a..2c7c86c 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -63,8 +63,9 @@ /* * Register map (dev->iobase) */ -#define DAS16M1_AI 0 /* 16-bit wide register */ -#define AI_CHAN(x) ((x) & 0xf) +#define DAS16M1_AI_REG 0x00 /* 16-bit register */ +#define DAS16M1_AI_TO_CHAN(x) (((x) >> 0) & 0xf) +#define DAS16M1_AI_TO_SAMPLE(x) (((x) >> 4) & 0xfff) #define DAS16M1_CS 2 #define EXT_TRIG_BIT 0x1 #define OVRUN 0x20 @@ -109,17 +110,12 @@ struct das16m1_private_struct { unsigned long extra_iobase; }; -static inline unsigned short munge_sample(unsigned short data) -{ - return (data >> 4) & 0xfff; -} - static void munge_sample_array(unsigned short *array, unsigned int num_elements) { unsigned int i; for (i = 0; i < num_elements; i++) - array[i] = munge_sample(array[i]); + array[i] = DAS16M1_AI_TO_SAMPLE(array[i]); } static int das16m1_ai_check_chanlist(struct comedi_device *dev, @@ -331,16 +327,19 @@ static int das16m1_ai_rinsn(struct comedi_device *dev, outb(byte, dev->iobase + DAS16M1_QUEUE_DATA); for (n = 0; n < insn->n; n++) { + unsigned short val; + /* clear IRQDATA bit */ outb(0, dev->iobase + DAS16M1_CLEAR_INTR); /* trigger conversion */ - outb(0, dev->iobase); + outb(0, dev->iobase + DAS16M1_AI_REG); ret = comedi_timeout(dev, s, insn, das16m1_ai_eoc, 0); if (ret) return ret; - data[n] = munge_sample(inw(dev->iobase)); + val = inw(dev->iobase + DAS16M1_AI_REG); + data[n] = DAS16M1_AI_TO_SAMPLE(val); } return n; -- cgit v1.1 From cec60bf6ce8a33ce50afd6a5d26ec61d0d36136f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:45 -0700 Subject: staging: comedi: das16m1: tidy up control/status register defines Rename the defines for the control/status register/bits. Use the BIT macro to define the bits. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 2c7c86c..49eb829 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -66,10 +66,10 @@ #define DAS16M1_AI_REG 0x00 /* 16-bit register */ #define DAS16M1_AI_TO_CHAN(x) (((x) >> 0) & 0xf) #define DAS16M1_AI_TO_SAMPLE(x) (((x) >> 4) & 0xfff) -#define DAS16M1_CS 2 -#define EXT_TRIG_BIT 0x1 -#define OVRUN 0x20 -#define IRQDATA 0x80 +#define DAS16M1_CS_REG 0x02 +#define DAS16M1_CS_EXT_TRIG BIT(0) +#define DAS16M1_CS_OVRUN BIT(5) +#define DAS16M1_CS_IRQDATA BIT(7) #define DAS16M1_DIO 3 #define DAS16M1_CLEAR_INTR 4 #define DAS16M1_INTR_CONTROL 5 @@ -272,9 +272,9 @@ static int das16m1_cmd_exec(struct comedi_device *dev, * both start and conversion triggers external simultaneously). */ if (cmd->start_src == TRIG_EXT && cmd->convert_src != TRIG_EXT) - byte |= EXT_TRIG_BIT; + byte |= DAS16M1_CS_EXT_TRIG; - outb(byte, dev->iobase + DAS16M1_CS); + outb(byte, dev->iobase + DAS16M1_CS_REG); /* clear interrupt bit */ outb(0, dev->iobase + DAS16M1_CLEAR_INTR); @@ -301,8 +301,8 @@ static int das16m1_ai_eoc(struct comedi_device *dev, { unsigned int status; - status = inb(dev->iobase + DAS16M1_CS); - if (status & IRQDATA) + status = inb(dev->iobase + DAS16M1_CS_REG); + if (status & DAS16M1_CS_IRQDATA) return 0; return -EBUSY; } @@ -329,7 +329,7 @@ static int das16m1_ai_rinsn(struct comedi_device *dev, for (n = 0; n < insn->n; n++) { unsigned short val; - /* clear IRQDATA bit */ + /* clear DAS16M1_CS_IRQDATA bit */ outb(0, dev->iobase + DAS16M1_CLEAR_INTR); /* trigger conversion */ outb(0, dev->iobase + DAS16M1_AI_REG); @@ -430,7 +430,7 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status) * This probably won't catch overruns since the card doesn't generate * overrun interrupts, but we might as well try. */ - if (status & OVRUN) { + if (status & DAS16M1_CS_OVRUN) { async->events |= COMEDI_CB_ERROR; dev_err(dev->class_dev, "fifo overflow\n"); } @@ -445,7 +445,7 @@ static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s) /* prevent race with interrupt handler */ spin_lock_irqsave(&dev->spinlock, flags); - status = inb(dev->iobase + DAS16M1_CS); + status = inb(dev->iobase + DAS16M1_CS_REG); das16m1_handler(dev, status); spin_unlock_irqrestore(&dev->spinlock, flags); @@ -464,9 +464,9 @@ static irqreturn_t das16m1_interrupt(int irq, void *d) /* prevent race with comedi_poll() */ spin_lock(&dev->spinlock); - status = inb(dev->iobase + DAS16M1_CS); + status = inb(dev->iobase + DAS16M1_CS_REG); - if ((status & (IRQDATA | OVRUN)) == 0) { + if ((status & (DAS16M1_CS_IRQDATA | DAS16M1_CS_OVRUN)) == 0) { dev_err(dev->class_dev, "spurious interrupt\n"); spin_unlock(&dev->spinlock); return IRQ_NONE; -- cgit v1.1 From 4246a637e781dc8a7f90db1efd7058bd5e452ea3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:46 -0700 Subject: staging: comedi: das16m1: tidy up digital input/output register defines The digtial inputs and outputs are read/written using the same register offset but they are different logical registers. Physically they are the same register with the hi 4 bits returning the inputs and the lo 4 bits driving the outputs. For aesthetics, use two different defines for the registers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 49eb829..e85d989 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -70,7 +70,8 @@ #define DAS16M1_CS_EXT_TRIG BIT(0) #define DAS16M1_CS_OVRUN BIT(5) #define DAS16M1_CS_IRQDATA BIT(7) -#define DAS16M1_DIO 3 +#define DAS16M1_DI_REG 0x03 +#define DAS16M1_DO_REG 0x03 #define DAS16M1_CLEAR_INTR 4 #define DAS16M1_INTR_CONTROL 5 #define EXT_PACER 0x2 @@ -351,7 +352,7 @@ static int das16m1_di_rbits(struct comedi_device *dev, { unsigned int bits; - bits = inb(dev->iobase + DAS16M1_DIO) & 0xf; + bits = inb(dev->iobase + DAS16M1_DI_REG) & 0xf; data[1] = bits; data[0] = 0; @@ -364,7 +365,7 @@ static int das16m1_do_wbits(struct comedi_device *dev, unsigned int *data) { if (comedi_dio_update_state(s, data)) - outb(s->state, dev->iobase + DAS16M1_DIO); + outb(s->state, dev->iobase + DAS16M1_DO_REG); data[1] = s->state; @@ -596,7 +597,7 @@ static int das16m1_attach(struct comedi_device *dev, return ret; /* initialize digital output lines */ - outb(0, dev->iobase + DAS16M1_DIO); + outb(0, dev->iobase + DAS16M1_DO_REG); /* set the interrupt level */ devpriv->control_state = das16m1_irq_bits(dev->irq) << 4; -- cgit v1.1 From 6b62e7578b82c797897f960680cebe3c858780d6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:47 -0700 Subject: staging: comedi: das16m1: tidy up clear interrupt register define Rename this define and use a consistent comment throughout the code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index e85d989..dcec4e2 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -72,7 +72,7 @@ #define DAS16M1_CS_IRQDATA BIT(7) #define DAS16M1_DI_REG 0x03 #define DAS16M1_DO_REG 0x03 -#define DAS16M1_CLEAR_INTR 4 +#define DAS16M1_CLR_INTR_REG 0x04 #define DAS16M1_INTR_CONTROL 5 #define EXT_PACER 0x2 #define INT_PACER 0x3 @@ -276,8 +276,9 @@ static int das16m1_cmd_exec(struct comedi_device *dev, byte |= DAS16M1_CS_EXT_TRIG; outb(byte, dev->iobase + DAS16M1_CS_REG); - /* clear interrupt bit */ - outb(0, dev->iobase + DAS16M1_CLEAR_INTR); + + /* clear interrupt */ + outb(0, dev->iobase + DAS16M1_CLR_INTR_REG); devpriv->control_state |= INTE; outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL); @@ -330,8 +331,8 @@ static int das16m1_ai_rinsn(struct comedi_device *dev, for (n = 0; n < insn->n; n++) { unsigned short val; - /* clear DAS16M1_CS_IRQDATA bit */ - outb(0, dev->iobase + DAS16M1_CLEAR_INTR); + /* clear interrupt */ + outb(0, dev->iobase + DAS16M1_CLR_INTR_REG); /* trigger conversion */ outb(0, dev->iobase + DAS16M1_AI_REG); @@ -476,7 +477,7 @@ static irqreturn_t das16m1_interrupt(int irq, void *d) das16m1_handler(dev, status); /* clear interrupt */ - outb(0, dev->iobase + DAS16M1_CLEAR_INTR); + outb(0, dev->iobase + DAS16M1_CLR_INTR_REG); spin_unlock(&dev->spinlock); return IRQ_HANDLED; -- cgit v1.1 From ceb6a45de22f51174e5f508eb403679a7aa127e4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:48 -0700 Subject: staging: comedi: das16m1: remove unnecessary ai 'cancel' operations The comedi core will only call the (*insn_read) and (*do_cmd) functions if the subdevice is not "busy". All async commands are terminated by a (*cancel) operation which clears the INTE and PACER_MASK bits in the interrupt control register. These bits are also cleared when the driver first attaches. There is no need for the (*insn_read) or (*do_cmd) to duplicate the cancel. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index dcec4e2..ce788ae 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -226,10 +226,6 @@ static int das16m1_cmd_exec(struct comedi_device *dev, struct comedi_cmd *cmd = &async->cmd; unsigned int byte, i; - /* disable interrupts and internal pacer */ - devpriv->control_state &= ~INTE & ~PACER_MASK; - outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL); - /* set software count */ devpriv->adc_count = 0; @@ -313,15 +309,10 @@ static int das16m1_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct das16m1_private_struct *devpriv = dev->private; int ret; int n; int byte; - /* disable interrupts and internal pacer */ - devpriv->control_state &= ~INTE & ~PACER_MASK; - outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL); - /* setup channel/gain queue */ outb(0, dev->iobase + DAS16M1_QUEUE_ADDR); byte = -- cgit v1.1 From 7ca99ee40ea738a607d04c888468882d1bd16e95 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:49 -0700 Subject: staging: comedi: das16m1: tidy up interrupt control register defines Rename these defines and use the BIT macro to define the bits. Define some macros for the multi-bit fields in the register. Rename the private data 'control_state' member to better match the register name. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 34 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index ce788ae..5b1d1fc 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -73,11 +73,13 @@ #define DAS16M1_DI_REG 0x03 #define DAS16M1_DO_REG 0x03 #define DAS16M1_CLR_INTR_REG 0x04 -#define DAS16M1_INTR_CONTROL 5 -#define EXT_PACER 0x2 -#define INT_PACER 0x3 -#define PACER_MASK 0x3 -#define INTE 0x80 +#define DAS16M1_INTR_CTRL_REG 0x05 +#define DAS16M1_INTR_CTRL_PACER(x) (((x) & 0x3) << 0) +#define DAS16M1_INTR_CTRL_PACER_EXT DAS16M1_INTR_CTRL_PACER(2) +#define DAS16M1_INTR_CTRL_PACER_INT DAS16M1_INTR_CTRL_PACER(3) +#define DAS16M1_INTR_CTRL_PACER_MASK DAS16M1_INTR_CTRL_PACER(3) +#define DAS16M1_INTR_CTRL_IRQ(x) (((x) & 0x7) << 4) +#define DAS16M1_INTR_CTRL_INTE BIT(7) #define DAS16M1_QUEUE_ADDR 6 #define DAS16M1_QUEUE_DATA 7 #define Q_CHAN(x) ((x) & 0x7) @@ -104,7 +106,7 @@ static const struct comedi_lrange range_das16m1 = { struct das16m1_private_struct { struct comedi_8254 *counter; - unsigned int control_state; + unsigned int intr_ctrl; unsigned int adc_count; u16 initial_hw_count; unsigned short ai_buffer[FIFO_SIZE]; @@ -253,13 +255,13 @@ static int das16m1_cmd_exec(struct comedi_device *dev, } /* enable interrupts and set internal pacer counter mode and counts */ - devpriv->control_state &= ~PACER_MASK; + devpriv->intr_ctrl &= ~DAS16M1_INTR_CTRL_PACER_MASK; if (cmd->convert_src == TRIG_TIMER) { comedi_8254_update_divisors(dev->pacer); comedi_8254_pacer_enable(dev->pacer, 1, 2, true); - devpriv->control_state |= INT_PACER; + devpriv->intr_ctrl |= DAS16M1_INTR_CTRL_PACER_INT; } else { /* TRIG_EXT */ - devpriv->control_state |= EXT_PACER; + devpriv->intr_ctrl |= DAS16M1_INTR_CTRL_PACER_EXT; } /* set control & status register */ @@ -276,8 +278,8 @@ static int das16m1_cmd_exec(struct comedi_device *dev, /* clear interrupt */ outb(0, dev->iobase + DAS16M1_CLR_INTR_REG); - devpriv->control_state |= INTE; - outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL); + devpriv->intr_ctrl |= DAS16M1_INTR_CTRL_INTE; + outb(devpriv->intr_ctrl, dev->iobase + DAS16M1_INTR_CTRL_REG); return 0; } @@ -286,8 +288,10 @@ static int das16m1_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { struct das16m1_private_struct *devpriv = dev->private; - devpriv->control_state &= ~INTE & ~PACER_MASK; - outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL); + /* disable interrupts and pacer */ + devpriv->intr_ctrl &= ~(DAS16M1_INTR_CTRL_INTE | + DAS16M1_INTR_CTRL_PACER_MASK); + outb(devpriv->intr_ctrl, dev->iobase + DAS16M1_INTR_CTRL_REG); return 0; } @@ -592,8 +596,8 @@ static int das16m1_attach(struct comedi_device *dev, outb(0, dev->iobase + DAS16M1_DO_REG); /* set the interrupt level */ - devpriv->control_state = das16m1_irq_bits(dev->irq) << 4; - outb(devpriv->control_state, dev->iobase + DAS16M1_INTR_CONTROL); + devpriv->intr_ctrl = DAS16M1_INTR_CTRL_IRQ(das16m1_irq_bits(dev->irq)); + outb(devpriv->intr_ctrl, dev->iobase + DAS16M1_INTR_CTRL_REG); return 0; } -- cgit v1.1 From c9a050cfbe2c05399c6a27b9ed6a73529e8b6666 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:50 -0700 Subject: staging: comedi: das16m1: tidy up queue register defines Rename these defines. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 5b1d1fc..1a8cf92 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -80,11 +80,10 @@ #define DAS16M1_INTR_CTRL_PACER_MASK DAS16M1_INTR_CTRL_PACER(3) #define DAS16M1_INTR_CTRL_IRQ(x) (((x) & 0x7) << 4) #define DAS16M1_INTR_CTRL_INTE BIT(7) -#define DAS16M1_QUEUE_ADDR 6 -#define DAS16M1_QUEUE_DATA 7 -#define Q_CHAN(x) ((x) & 0x7) -#define Q_RANGE(x) (((x) & 0xf) << 4) -#define UNIPOLAR 0x40 +#define DAS16M1_Q_ADDR_REG 0x06 +#define DAS16M1_Q_REG 0x07 +#define DAS16M1_Q_CHAN(x) (((x) & 0x7) << 0) +#define DAS16M1_Q_RANGE(x) (((x) & 0xf) << 4) #define DAS16M1_8254_FIRST 0x8 #define DAS16M1_8254_SECOND 0xc #define DAS16M1_82C55 0x400 @@ -247,11 +246,11 @@ static int das16m1_cmd_exec(struct comedi_device *dev, /* setup channel/gain queue */ for (i = 0; i < cmd->chanlist_len; i++) { - outb(i, dev->iobase + DAS16M1_QUEUE_ADDR); + outb(i, dev->iobase + DAS16M1_Q_ADDR_REG); byte = - Q_CHAN(CR_CHAN(cmd->chanlist[i])) | - Q_RANGE(CR_RANGE(cmd->chanlist[i])); - outb(byte, dev->iobase + DAS16M1_QUEUE_DATA); + DAS16M1_Q_CHAN(CR_CHAN(cmd->chanlist[i])) | + DAS16M1_Q_RANGE(CR_RANGE(cmd->chanlist[i])); + outb(byte, dev->iobase + DAS16M1_Q_REG); } /* enable interrupts and set internal pacer counter mode and counts */ @@ -318,10 +317,10 @@ static int das16m1_ai_rinsn(struct comedi_device *dev, int byte; /* setup channel/gain queue */ - outb(0, dev->iobase + DAS16M1_QUEUE_ADDR); - byte = - Q_CHAN(CR_CHAN(insn->chanspec)) | Q_RANGE(CR_RANGE(insn->chanspec)); - outb(byte, dev->iobase + DAS16M1_QUEUE_DATA); + outb(0, dev->iobase + DAS16M1_Q_ADDR_REG); + byte = DAS16M1_Q_CHAN(CR_CHAN(insn->chanspec)) | + DAS16M1_Q_RANGE(CR_RANGE(insn->chanspec)); + outb(byte, dev->iobase + DAS16M1_Q_REG); for (n = 0; n < insn->n; n++) { unsigned short val; -- cgit v1.1 From a70615894a091687d9b219d471362fc37e98f07b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:51 -0700 Subject: staging: comedi: das16m1: introduce das16m1_ai_set_queue() Introduce a helper function to handle writing the channel/gain data to the queue for single channel reads, (*insn_read), and multi-channel scans, (*do_cmd). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 33 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 1a8cf92..b941dcf 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -112,6 +112,21 @@ struct das16m1_private_struct { unsigned long extra_iobase; }; +static void das16m1_ai_set_queue(struct comedi_device *dev, + unsigned int *chanspec, unsigned int len) +{ + unsigned int i; + + for (i = 0; i < len; i++) { + unsigned int chan = CR_CHAN(chanspec[i]); + unsigned int range = CR_RANGE(chanspec[i]); + + outb(i, dev->iobase + DAS16M1_Q_ADDR_REG); + outb(DAS16M1_Q_CHAN(chan) | DAS16M1_Q_RANGE(range), + dev->iobase + DAS16M1_Q_REG); + } +} + static void munge_sample_array(unsigned short *array, unsigned int num_elements) { unsigned int i; @@ -225,7 +240,7 @@ static int das16m1_cmd_exec(struct comedi_device *dev, struct das16m1_private_struct *devpriv = dev->private; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; - unsigned int byte, i; + unsigned int byte; /* set software count */ devpriv->adc_count = 0; @@ -244,14 +259,7 @@ static int das16m1_cmd_exec(struct comedi_device *dev, */ devpriv->initial_hw_count = comedi_8254_read(devpriv->counter, 1); - /* setup channel/gain queue */ - for (i = 0; i < cmd->chanlist_len; i++) { - outb(i, dev->iobase + DAS16M1_Q_ADDR_REG); - byte = - DAS16M1_Q_CHAN(CR_CHAN(cmd->chanlist[i])) | - DAS16M1_Q_RANGE(CR_RANGE(cmd->chanlist[i])); - outb(byte, dev->iobase + DAS16M1_Q_REG); - } + das16m1_ai_set_queue(dev, cmd->chanlist, cmd->chanlist_len); /* enable interrupts and set internal pacer counter mode and counts */ devpriv->intr_ctrl &= ~DAS16M1_INTR_CTRL_PACER_MASK; @@ -314,13 +322,8 @@ static int das16m1_ai_rinsn(struct comedi_device *dev, { int ret; int n; - int byte; - /* setup channel/gain queue */ - outb(0, dev->iobase + DAS16M1_Q_ADDR_REG); - byte = DAS16M1_Q_CHAN(CR_CHAN(insn->chanspec)) | - DAS16M1_Q_RANGE(CR_RANGE(insn->chanspec)); - outb(byte, dev->iobase + DAS16M1_Q_REG); + das16m1_ai_set_queue(dev, &insn->chanspec, 1); for (n = 0; n < insn->n; n++) { unsigned short val; -- cgit v1.1 From 5c8694d699d44dfe4fa0631f74280c359935d8c5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:52 -0700 Subject: staging: comedi: das16m1: tidy up analog input subdevice init Add some whitespace to the subdevice init and rename the support functions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 48 +++++++++++++++++--------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index b941dcf..b19715c 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -163,8 +163,9 @@ static int das16m1_ai_check_chanlist(struct comedi_device *dev, return 0; } -static int das16m1_cmd_test(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_cmd *cmd) +static int das16m1_ai_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) { int err = 0; @@ -234,8 +235,8 @@ static int das16m1_cmd_test(struct comedi_device *dev, return 0; } -static int das16m1_cmd_exec(struct comedi_device *dev, - struct comedi_subdevice *s) +static int das16m1_ai_cmd(struct comedi_device *dev, + struct comedi_subdevice *s) { struct das16m1_private_struct *devpriv = dev->private; struct comedi_async *async = s->async; @@ -291,7 +292,8 @@ static int das16m1_cmd_exec(struct comedi_device *dev, return 0; } -static int das16m1_cancel(struct comedi_device *dev, struct comedi_subdevice *s) +static int das16m1_ai_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) { struct das16m1_private_struct *devpriv = dev->private; @@ -316,9 +318,10 @@ static int das16m1_ai_eoc(struct comedi_device *dev, return -EBUSY; } -static int das16m1_ai_rinsn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das16m1_ai_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { int ret; int n; @@ -437,7 +440,8 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status) comedi_handle_events(dev, s); } -static int das16m1_poll(struct comedi_device *dev, struct comedi_subdevice *s) +static int das16m1_ai_poll(struct comedi_device *dev, + struct comedi_subdevice *s) { unsigned long flags; unsigned int status; @@ -552,22 +556,22 @@ static int das16m1_attach(struct comedi_device *dev, if (ret) return ret; + /* Analog Input subdevice */ s = &dev->subdevices[0]; - /* ai */ - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE | SDF_DIFF; - s->n_chan = 8; - s->maxdata = (1 << 12) - 1; - s->range_table = &range_das16m1; - s->insn_read = das16m1_ai_rinsn; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE | SDF_DIFF; + s->n_chan = 8; + s->maxdata = 0x0fff; + s->range_table = &range_das16m1; + s->insn_read = das16m1_ai_insn_read; if (dev->irq) { dev->read_subdev = s; - s->subdev_flags |= SDF_CMD_READ; - s->len_chanlist = 256; - s->do_cmdtest = das16m1_cmd_test; - s->do_cmd = das16m1_cmd_exec; - s->cancel = das16m1_cancel; - s->poll = das16m1_poll; + s->subdev_flags |= SDF_CMD_READ; + s->len_chanlist = 256; + s->do_cmdtest = das16m1_ai_cmdtest; + s->do_cmd = das16m1_ai_cmd; + s->cancel = das16m1_ai_cancel; + s->poll = das16m1_ai_poll; } s = &dev->subdevices[1]; -- cgit v1.1 From fdb68f9abd17c8008f36801cf940fd59e7683556 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:53 -0700 Subject: staging: comedi: das16m1: tidy up digital input subdevice init Add some whitespace to the subdevice init and rename the support function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index b19715c..f51da80 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -347,9 +347,10 @@ static int das16m1_ai_insn_read(struct comedi_device *dev, return n; } -static int das16m1_di_rbits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das16m1_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { unsigned int bits; @@ -574,14 +575,14 @@ static int das16m1_attach(struct comedi_device *dev, s->poll = das16m1_ai_poll; } + /* Digital Input subdevice */ s = &dev->subdevices[1]; - /* di */ - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE; - s->n_chan = 4; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = das16m1_di_rbits; + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 4; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = das16m1_di_insn_bits; s = &dev->subdevices[2]; /* do */ -- cgit v1.1 From 8500b75c1dbe126df6f1a4b396853769986b155e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:54 -0700 Subject: staging: comedi: das16m1: tidy up das16m1_di_insn_bits() The (*insn_bits) for a digital input subdevice only needs to return the state of the inputs in data[1]. Remove the cruft. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index f51da80..538544b 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -352,11 +352,7 @@ static int das16m1_di_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int bits; - - bits = inb(dev->iobase + DAS16M1_DI_REG) & 0xf; - data[1] = bits; - data[0] = 0; + data[1] = inb(dev->iobase + DAS16M1_DI_REG) & 0xf; return insn->n; } -- cgit v1.1 From 702907d7ab040eb9cf9d311878aad4bd64362ef0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:55 -0700 Subject: staging: comedi: das16m1: tidy up digital output subdevice init Add some whitespace to the subdevice init and rename the support function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 538544b..cb5cd5e 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -357,10 +357,10 @@ static int das16m1_di_insn_bits(struct comedi_device *dev, return insn->n; } -static int das16m1_do_wbits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static int das16m1_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { if (comedi_dio_update_state(s, data)) outb(s->state, dev->iobase + DAS16M1_DO_REG); @@ -580,14 +580,14 @@ static int das16m1_attach(struct comedi_device *dev, s->range_table = &range_digital; s->insn_bits = das16m1_di_insn_bits; + /* Digital Output subdevice */ s = &dev->subdevices[2]; - /* do */ - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = 4; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = das16m1_do_wbits; + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = 4; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = das16m1_do_insn_bits; s = &dev->subdevices[3]; /* 8255 */ -- cgit v1.1 From 255d302dc88f4f00603c5681a01d8c2e7ceaca95 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:56 -0700 Subject: staging: comedi: das16m1: tidy up 8254/8255 register defines For aesthetics, rename these defines. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index cb5cd5e..824cc94 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -84,10 +84,10 @@ #define DAS16M1_Q_REG 0x07 #define DAS16M1_Q_CHAN(x) (((x) & 0x7) << 0) #define DAS16M1_Q_RANGE(x) (((x) & 0xf) << 4) -#define DAS16M1_8254_FIRST 0x8 -#define DAS16M1_8254_SECOND 0xc -#define DAS16M1_82C55 0x400 -#define DAS16M1_8254_THIRD 0x404 +#define DAS16M1_8254_IOBASE1 0x08 +#define DAS16M1_8254_IOBASE2 0x0c +#define DAS16M1_8255_IOBASE 0x400 +#define DAS16M1_8254_IOBASE3 0x404 static const struct comedi_lrange range_das16m1 = { 9, { @@ -524,12 +524,12 @@ static int das16m1_attach(struct comedi_device *dev, ret = comedi_request_region(dev, it->options[0], 0x10); if (ret) return ret; - /* Request an additional region for the 8255 */ - ret = __comedi_request_region(dev, dev->iobase + DAS16M1_82C55, + /* Request an additional region for the 8255 and 3rd 8254 */ + ret = __comedi_request_region(dev, dev->iobase + DAS16M1_8255_IOBASE, DAS16M1_SIZE2); if (ret) return ret; - devpriv->extra_iobase = dev->iobase + DAS16M1_82C55; + devpriv->extra_iobase = dev->iobase + DAS16M1_8255_IOBASE; /* only irqs 2, 3, 4, 5, 6, 7, 10, 11, 12, 14, and 15 are valid */ if ((1 << it->options[1]) & 0xdcfc) { @@ -539,12 +539,12 @@ static int das16m1_attach(struct comedi_device *dev, dev->irq = it->options[1]; } - dev->pacer = comedi_8254_init(dev->iobase + DAS16M1_8254_SECOND, + dev->pacer = comedi_8254_init(dev->iobase + DAS16M1_8254_IOBASE2, I8254_OSC_BASE_10MHZ, I8254_IO8, 0); if (!dev->pacer) return -ENOMEM; - devpriv->counter = comedi_8254_init(dev->iobase + DAS16M1_8254_FIRST, + devpriv->counter = comedi_8254_init(dev->iobase + DAS16M1_8254_IOBASE1, 0, I8254_IO8, 0); if (!devpriv->counter) return -ENOMEM; @@ -589,9 +589,9 @@ static int das16m1_attach(struct comedi_device *dev, s->range_table = &range_digital; s->insn_bits = das16m1_do_insn_bits; + /* Digital I/O subdevice (8255) */ s = &dev->subdevices[3]; - /* 8255 */ - ret = subdev_8255_init(dev, s, NULL, DAS16M1_82C55); + ret = subdev_8255_init(dev, s, NULL, DAS16M1_8255_IOBASE); if (ret) return ret; -- cgit v1.1 From 4a026c2ebb8c8dd190c2dd60435a60bb8dfc6ebf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:57 -0700 Subject: staging: comedi: das16m1: tidy up misc. defines For aesthetics, move these after the register map defines and rename the FIFO_SIZE define. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 824cc94..6797da1 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -56,10 +56,6 @@ #include "8255.h" #include "comedi_8254.h" -#define DAS16M1_SIZE2 8 - -#define FIFO_SIZE 1024 /* 1024 sample fifo */ - /* * Register map (dev->iobase) */ @@ -89,6 +85,10 @@ #define DAS16M1_8255_IOBASE 0x400 #define DAS16M1_8254_IOBASE3 0x404 +#define DAS16M1_SIZE2 0x08 + +#define DAS16M1_AI_FIFO_SZ 1024 /* # samples */ + static const struct comedi_lrange range_das16m1 = { 9, { BIP_RANGE(5), @@ -108,7 +108,7 @@ struct das16m1_private_struct { unsigned int intr_ctrl; unsigned int adc_count; u16 initial_hw_count; - unsigned short ai_buffer[FIFO_SIZE]; + unsigned short ai_buffer[DAS16M1_AI_FIFO_SZ]; unsigned long extra_iobase; }; @@ -411,8 +411,8 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status) num_samples = cmd->stop_arg * cmd->chanlist_len; } /* make sure we dont try to get too many points if fifo has overrun */ - if (num_samples > FIFO_SIZE) - num_samples = FIFO_SIZE; + if (num_samples > DAS16M1_AI_FIFO_SZ) + num_samples = DAS16M1_AI_FIFO_SZ; insw(dev->iobase, devpriv->ai_buffer, num_samples); munge_sample_array(devpriv->ai_buffer, num_samples); comedi_buf_write_samples(s, devpriv->ai_buffer, num_samples); -- cgit v1.1 From 300b31c22503393c6c41c8dbe80281a446f54ca2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:58 -0700 Subject: staging: comedi: das16m1: remove an unnecessery comment The configuration options are listed in the comedi comment block. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 6797da1..3a62f5a 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -505,11 +505,6 @@ static int das16m1_irq_bits(unsigned int irq) } } -/* - * Options list: - * 0 I/O base - * 1 IRQ - */ static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it) { -- cgit v1.1 From b31cf3126474e71192282c97ae88a6f60b17bea0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:29:59 -0700 Subject: staging: comedi: das16m1: init local variables when declared For aesthetics, init the comedi_subdevice, comedi_async, and comedi_cmd pointers when the local variables are declared. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 3a62f5a..d4b1b92 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -373,16 +373,12 @@ static int das16m1_do_insn_bits(struct comedi_device *dev, static void das16m1_handler(struct comedi_device *dev, unsigned int status) { struct das16m1_private_struct *devpriv = dev->private; - struct comedi_subdevice *s; - struct comedi_async *async; - struct comedi_cmd *cmd; + struct comedi_subdevice *s = dev->read_subdev; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; u16 num_samples; u16 hw_counter; - s = dev->read_subdev; - async = s->async; - cmd = &async->cmd; - /* figure out how many samples are in fifo */ hw_counter = comedi_8254_read(devpriv->counter, 1); /* -- cgit v1.1 From d0e50e6588e236c17f494b3055be986344692af9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:30:00 -0700 Subject: staging: comedi: das16m1: minor cleanup to das16m1_ai_insn_read() The (*insn_read) functions return the number of data values read. The 'n' value is correct but for clarity change the return to 'insn->n'. For aesthetics, change the 'n' loop variable name to 'i'. That's more common in comedi drivers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index d4b1b92..c0f2796 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -324,11 +324,11 @@ static int das16m1_ai_insn_read(struct comedi_device *dev, unsigned int *data) { int ret; - int n; + int i; das16m1_ai_set_queue(dev, &insn->chanspec, 1); - for (n = 0; n < insn->n; n++) { + for (i = 0; i < insn->n; i++) { unsigned short val; /* clear interrupt */ @@ -341,10 +341,10 @@ static int das16m1_ai_insn_read(struct comedi_device *dev, return ret; val = inw(dev->iobase + DAS16M1_AI_REG); - data[n] = DAS16M1_AI_TO_SAMPLE(val); + data[i] = DAS16M1_AI_TO_SAMPLE(val); } - return n; + return insn->n; } static int das16m1_di_insn_bits(struct comedi_device *dev, -- cgit v1.1 From 243c701308e9798d3bdd55cc2446cbbdbc44ea28 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:30:01 -0700 Subject: staging: comedi: das16m1: convert munge_sample_array() into a subdevice (*munge) For aesthetics, convert this function into a subdevice (*munge) function and let the comedi core handle the munging. Add a comment about why the data needs to be munged. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index c0f2796..a803032 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -127,11 +127,21 @@ static void das16m1_ai_set_queue(struct comedi_device *dev, } } -static void munge_sample_array(unsigned short *array, unsigned int num_elements) +static void das16m1_ai_munge(struct comedi_device *dev, + struct comedi_subdevice *s, + void *data, unsigned int num_bytes, + unsigned int start_chan_index) { + unsigned short *array = data; + unsigned int nsamples = comedi_bytes_to_samples(s, num_bytes); unsigned int i; - for (i = 0; i < num_elements; i++) + /* + * The fifo values have the channel number in the lower 4-bits and + * the sample in the upper 12-bits. This just shifts the values + * to remove the channel numbers. + */ + for (i = 0; i < nsamples; i++) array[i] = DAS16M1_AI_TO_SAMPLE(array[i]); } @@ -410,7 +420,6 @@ static void das16m1_handler(struct comedi_device *dev, unsigned int status) if (num_samples > DAS16M1_AI_FIFO_SZ) num_samples = DAS16M1_AI_FIFO_SZ; insw(dev->iobase, devpriv->ai_buffer, num_samples); - munge_sample_array(devpriv->ai_buffer, num_samples); comedi_buf_write_samples(s, devpriv->ai_buffer, num_samples); devpriv->adc_count += num_samples; @@ -560,6 +569,7 @@ static int das16m1_attach(struct comedi_device *dev, s->do_cmd = das16m1_ai_cmd; s->cancel = das16m1_ai_cancel; s->poll = das16m1_ai_poll; + s->munge = das16m1_ai_munge; } /* Digital Input subdevice */ -- cgit v1.1 From cd99cfbe84b2a070b4c2e792b89bec533c668d17 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:30:02 -0700 Subject: staging: comedi: das16m1: rename struct das16m1_private_struct For aesthetics, remove the redundant '_struct' suffix. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index a803032..7185b85 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -103,7 +103,7 @@ static const struct comedi_lrange range_das16m1 = { } }; -struct das16m1_private_struct { +struct das16m1_private { struct comedi_8254 *counter; unsigned int intr_ctrl; unsigned int adc_count; @@ -248,7 +248,7 @@ static int das16m1_ai_cmdtest(struct comedi_device *dev, static int das16m1_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - struct das16m1_private_struct *devpriv = dev->private; + struct das16m1_private *devpriv = dev->private; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; unsigned int byte; @@ -305,7 +305,7 @@ static int das16m1_ai_cmd(struct comedi_device *dev, static int das16m1_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct das16m1_private_struct *devpriv = dev->private; + struct das16m1_private *devpriv = dev->private; /* disable interrupts and pacer */ devpriv->intr_ctrl &= ~(DAS16M1_INTR_CTRL_INTE | @@ -382,7 +382,7 @@ static int das16m1_do_insn_bits(struct comedi_device *dev, static void das16m1_handler(struct comedi_device *dev, unsigned int status) { - struct das16m1_private_struct *devpriv = dev->private; + struct das16m1_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; @@ -513,7 +513,7 @@ static int das16m1_irq_bits(unsigned int irq) static int das16m1_attach(struct comedi_device *dev, struct comedi_devconfig *it) { - struct das16m1_private_struct *devpriv; + struct das16m1_private *devpriv; struct comedi_subdevice *s; int ret; @@ -608,7 +608,7 @@ static int das16m1_attach(struct comedi_device *dev, static void das16m1_detach(struct comedi_device *dev) { - struct das16m1_private_struct *devpriv = dev->private; + struct das16m1_private *devpriv = dev->private; if (devpriv) { if (devpriv->extra_iobase) -- cgit v1.1 From d1aee5dd118f6d0f76db6527ae9734347ca185c0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 3 May 2016 12:30:03 -0700 Subject: staging: comedi: das16m1: update the MODULE_DESCRIPTION Change the MODULE_DESCRIPTION to something more usefull than the generic "Comedi low-level driver". Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16m1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 7185b85..bb8d6ec 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -627,5 +627,5 @@ static struct comedi_driver das16m1_driver = { module_comedi_driver(das16m1_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("Comedi driver for CIO-DAS16/M1 ISA cards"); MODULE_LICENSE("GPL"); -- cgit v1.1 From f7ede00d609d24dae6ef47d294630e81b8ce3091 Mon Sep 17 00:00:00 2001 From: Nikita Eshkeev Date: Tue, 3 May 2016 18:22:23 +0300 Subject: staging:comedi:Use unsigned int instead of unsigned This patch fixed the checkpatch.pl warning: WARNING: Prefer 'unsigned int' to bare use of 'unsigned' Signed-off-by: Nikita Eshkeev Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi.h | 2 +- drivers/staging/comedi/drivers/comedi_bond.c | 10 +++++----- drivers/staging/comedi/drivers/das800.c | 4 ++-- drivers/staging/comedi/drivers/ni_65xx.c | 18 +++++++++--------- drivers/staging/comedi/drivers/ni_pcidio.c | 4 ++-- drivers/staging/comedi/drivers/ni_pcimio.c | 8 ++++---- drivers/staging/comedi/drivers/pcmuio.c | 2 +- drivers/staging/comedi/drivers/quatech_daqp_cs.c | 2 +- drivers/staging/comedi/drivers/rtd520.c | 10 +++++----- drivers/staging/comedi/drivers/s626.c | 8 ++++---- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h index ad5297f..08fb26b 100644 --- a/drivers/staging/comedi/comedi.h +++ b/drivers/staging/comedi/comedi.h @@ -779,7 +779,7 @@ struct comedi_subdinfo { unsigned int flags; unsigned int range_type; unsigned int settling_time_0; - unsigned insn_bits_support; + unsigned int insn_bits_support; unsigned int unused[8]; }; diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 50b76ec..64a5ea3 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -55,16 +55,16 @@ struct bonded_device { struct comedi_device *dev; - unsigned minor; - unsigned subdev; - unsigned nchans; + unsigned int minor; + unsigned int subdev; + unsigned int nchans; }; struct comedi_bond_private { char name[256]; struct bonded_device **devs; - unsigned ndevs; - unsigned nchans; + unsigned int ndevs; + unsigned int nchans; }; static int bonding_dio_insn_bits(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index b02f122..9059872 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -218,7 +218,7 @@ struct das800_private { }; static void das800_ind_write(struct comedi_device *dev, - unsigned val, unsigned reg) + unsigned int val, unsigned int reg) { /* * Select dev->iobase + 2 to be desired register @@ -228,7 +228,7 @@ static void das800_ind_write(struct comedi_device *dev, outb(val, dev->iobase + 2); } -static unsigned das800_ind_read(struct comedi_device *dev, unsigned reg) +static unsigned int das800_ind_read(struct comedi_device *dev, unsigned int reg) { /* * Select dev->iobase + 7 to be desired register diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 251117b..07f38e3 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -151,10 +151,10 @@ enum ni_65xx_boardid { struct ni_65xx_board { const char *name; - unsigned num_dio_ports; - unsigned num_di_ports; - unsigned num_do_ports; - unsigned legacy_invert:1; + unsigned int num_dio_ports; + unsigned int num_di_ports; + unsigned int num_do_ports; + unsigned int legacy_invert:1; }; static const struct ni_65xx_board ni_65xx_boards[] = { @@ -360,7 +360,7 @@ static int ni_65xx_dio_insn_config(struct comedi_device *dev, unsigned long base_port = (unsigned long)s->private; unsigned int chan = CR_CHAN(insn->chanspec); unsigned int chan_mask = NI_65XX_CHAN_TO_MASK(chan); - unsigned port = base_port + NI_65XX_CHAN_TO_PORT(chan); + unsigned int port = base_port + NI_65XX_CHAN_TO_PORT(chan); unsigned int interval; unsigned int val; @@ -428,14 +428,14 @@ static int ni_65xx_dio_insn_bits(struct comedi_device *dev, unsigned long base_port = (unsigned long)s->private; unsigned int base_chan = CR_CHAN(insn->chanspec); int last_port_offset = NI_65XX_CHAN_TO_PORT(s->n_chan - 1); - unsigned read_bits = 0; + unsigned int read_bits = 0; int port_offset; for (port_offset = NI_65XX_CHAN_TO_PORT(base_chan); port_offset <= last_port_offset; port_offset++) { - unsigned port = base_port + port_offset; + unsigned int port = base_port + port_offset; int base_port_channel = NI_65XX_PORT_TO_CHAN(port_offset); - unsigned port_mask, port_data, bits; + unsigned int port_mask, port_data, bits; int bitshift = base_port_channel - base_chan; if (bitshift >= 32) @@ -640,7 +640,7 @@ static int ni_65xx_auto_attach(struct comedi_device *dev, struct pci_dev *pcidev = comedi_to_pci_dev(dev); const struct ni_65xx_board *board = NULL; struct comedi_subdevice *s; - unsigned i; + unsigned int i; int ret; if (context < ARRAY_SIZE(ni_65xx_boards)) diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 02a5329..35ef192 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -170,12 +170,12 @@ comedi_nonfree_firmware tarball available from http://www.comedi.org #define DMA_Line_Control_Group1 76 #define DMA_Line_Control_Group2 108 /* channel zero is none */ -static inline unsigned primary_DMAChannel_bits(unsigned channel) +static inline unsigned int primary_DMAChannel_bits(unsigned int channel) { return channel & 0x3; } -static inline unsigned secondary_DMAChannel_bits(unsigned channel) +static inline unsigned int secondary_DMAChannel_bits(unsigned int channel) { return (channel << 2) & 0xc; } diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index 344aa34..d891739 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -1064,12 +1064,12 @@ static void m_series_init_eeprom_buffer(struct comedi_device *dev) struct mite *mite = devpriv->mite; resource_size_t daq_phys_addr; static const int Start_Cal_EEPROM = 0x400; - static const unsigned window_size = 10; + static const unsigned int window_size = 10; static const int serial_number_eeprom_offset = 0x4; static const int serial_number_eeprom_length = 0x4; - unsigned old_iodwbsr_bits; - unsigned old_iodwbsr1_bits; - unsigned old_iodwcr1_bits; + unsigned int old_iodwbsr_bits; + unsigned int old_iodwbsr1_bits; + unsigned int old_iodwcr1_bits; int i; /* IO Window 1 needs to be temporarily mapped to read the eeprom */ diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index 7ea8130..8ad64f2 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -307,7 +307,7 @@ static void pcmuio_stop_intr(struct comedi_device *dev, static void pcmuio_handle_intr_subdev(struct comedi_device *dev, struct comedi_subdevice *s, - unsigned triggered) + unsigned int triggered) { struct pcmuio_private *devpriv = dev->private; int asic = pcmuio_subdevice_to_asic(s); diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index e9e4313..802f51e 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -643,7 +643,7 @@ static int daqp_ao_insn_write(struct comedi_device *dev, outb(0, dev->iobase + DAQP_AUX_REG); for (i = 0; i > insn->n; i++) { - unsigned val = data[i]; + unsigned int val = data[i]; int ret; /* D/A transfer rate is about 8ms */ diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 9b6c567..0990f62 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -362,7 +362,7 @@ struct rtd_private { long ai_count; /* total transfer size (samples) */ int xfer_count; /* # to transfer data. 0->1/2FIFO */ int flags; /* flag event modes */ - unsigned fifosz; + unsigned int fifosz; /* 8254 Timer/Counter gate and clock sources */ unsigned char timer_gate_src[3]; @@ -491,9 +491,9 @@ static void rtd_load_channelgain_list(struct comedi_device *dev, static int rtd520_probe_fifo_depth(struct comedi_device *dev) { unsigned int chanspec = CR_PACK(0, 0, AREF_GROUND); - unsigned i; - static const unsigned limit = 0x2000; - unsigned fifo_size = 0; + unsigned int i; + static const unsigned int limit = 0x2000; + unsigned int fifo_size = 0; writel(0, dev->mmio + LAS0_ADC_FIFO_CLEAR); rtd_load_channelgain_list(dev, 1, &chanspec); @@ -501,7 +501,7 @@ static int rtd520_probe_fifo_depth(struct comedi_device *dev) writel(0, dev->mmio + LAS0_ADC_CONVERSION); /* convert samples */ for (i = 0; i < limit; ++i) { - unsigned fifo_status; + unsigned int fifo_status; /* trigger conversion */ writew(0, dev->mmio + LAS0_ADC); usleep_range(1, 1000); diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index c5e0863..4a87b4b 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -708,7 +708,7 @@ static uint16_t s626_get_mode_a(struct comedi_device *dev, uint16_t cra; uint16_t crb; uint16_t setup; - unsigned cntsrc, clkmult, clkpol, encmode; + unsigned int cntsrc, clkmult, clkpol, encmode; /* Fetch CRA and CRB register images. */ cra = s626_debi_read(dev, S626_LP_CRA(chan)); @@ -763,7 +763,7 @@ static uint16_t s626_get_mode_b(struct comedi_device *dev, uint16_t cra; uint16_t crb; uint16_t setup; - unsigned cntsrc, clkmult, clkpol, encmode; + unsigned int cntsrc, clkmult, clkpol, encmode; /* Fetch CRA and CRB register images. */ cra = s626_debi_read(dev, S626_LP_CRA(chan)); @@ -838,7 +838,7 @@ static void s626_set_mode_a(struct comedi_device *dev, struct s626_private *devpriv = dev->private; uint16_t cra; uint16_t crb; - unsigned cntsrc, clkmult, clkpol; + unsigned int cntsrc, clkmult, clkpol; /* Initialize CRA and CRB images. */ /* Preload trigger is passed through. */ @@ -916,7 +916,7 @@ static void s626_set_mode_b(struct comedi_device *dev, struct s626_private *devpriv = dev->private; uint16_t cra; uint16_t crb; - unsigned cntsrc, clkmult, clkpol; + unsigned int cntsrc, clkmult, clkpol; /* Initialize CRA and CRB images. */ /* IndexSrc is passed through. */ -- cgit v1.1 From 8a8f5489db6d54f31cd73177c31de20e40357271 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:06 -0700 Subject: staging: comedi: dt2811: tidy up copyright and comedi comments Fix the checkpatch.pl issue: WARNING: Block comments use * on subsequent lines Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 78 ++++++++++++++++----------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index a807732..499637b 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -1,45 +1,45 @@ /* - comedi/drivers/dt2811.c - Hardware driver for Data Translation DT2811 - - COMEDI - Linux Control and Measurement Device Interface - History: - Base Version - David A. Schleef - December 1998 - Updated to work. David does not have a DT2811 - board any longer so this was suffering from bitrot. - Updated performed by ... - - 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. + * Comedi driver for Data Translation DT2811 + * + * COMEDI - Linux Control and Measurement Device Interface + * History: + * Base Version - David A. Schleef + * December 1998 - Updated to work. David does not have a DT2811 + * board any longer so this was suffering from bitrot. + * Updated performed by ... + * + * 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. */ + /* -Driver: dt2811 -Description: Data Translation DT2811 -Author: ds -Devices: [Data Translation] DT2811-PGL (dt2811-pgl), DT2811-PGH (dt2811-pgh) -Status: works - -Configuration options: - [0] - I/O port base address - [1] - IRQ, although this is currently unused - [2] - A/D reference - 0 = signle-ended - 1 = differential - 2 = pseudo-differential (common reference) - [3] - A/D range - 0 = [-5, 5] - 1 = [-2.5, 2.5] - 2 = [0, 5] - [4] - D/A 0 range (same choices) - [4] - D/A 1 range (same choices) -*/ + * Driver: dt2811 + * Description: Data Translation DT2811 + * Author: ds + * Devices: [Data Translation] DT2811-PGL (dt2811-pgl), DT2811-PGH (dt2811-pgh) + * Status: works + * + * Configuration options: + * [0] - I/O port base address + * [1] - IRQ, although this is currently unused + * [2] - A/D reference + * 0 = single-ended + * 1 = differential + * 2 = pseudo-differential (common reference) + * [3] - A/D range + * 0 = [-5, 5] + * 1 = [-2.5, 2.5] + * 2 = [0, 5] + * [4] - D/A 0 range (same as A/D range) + * [5] - D/A 1 range (same as A/D range) + */ #include #include "../comedidev.h" -- cgit v1.1 From a40ff88e58d60336aec32e0acf40e3e0fca4ca03 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:07 -0700 Subject: staging: comedi: dt2811: remove redundant block comment The configuration options are listed in the comedi comment block. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 499637b..5d550d1 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -297,26 +297,6 @@ static int dt2811_do_insn_bits(struct comedi_device *dev, return insn->n; } -/* - options[0] Board base address - options[1] IRQ - options[2] Input configuration - 0 == single-ended - 1 == differential - 2 == pseudo-differential - options[3] Analog input range configuration - 0 == bipolar 5 (-5V -- +5V) - 1 == bipolar 2.5V (-2.5V -- +2.5V) - 2 == unipolar 5V (0V -- +5V) - options[4] Analog output 0 range configuration - 0 == bipolar 5 (-5V -- +5V) - 1 == bipolar 2.5V (-2.5V -- +2.5V) - 2 == unipolar 5V (0V -- +5V) - options[5] Analog output 1 range configuration - 0 == bipolar 5 (-5V -- +5V) - 1 == bipolar 2.5V (-2.5V -- +2.5V) - 2 == unipolar 5V (0V -- +5V) -*/ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) { /* int i; */ -- cgit v1.1 From 6e4e38b5e6a1a28fda8cf54f124b386d1df73fcd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:08 -0700 Subject: staging: comedi: dt2811: remove disabled code There is no reason the (*attach) should be trying to read an analog input sample. Remove this disabled code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 5d550d1..3cd9fe5 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -299,23 +299,15 @@ static int dt2811_do_insn_bits(struct comedi_device *dev, static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) { - /* int i; */ const struct dt2811_board *board = dev->board_ptr; struct dt2811_private *devpriv; - int ret; struct comedi_subdevice *s; + int ret; ret = comedi_request_region(dev, it->options[0], 0x8); if (ret) return ret; -#if 0 - outb(0, dev->iobase + DT2811_ADCSR); - udelay(100); - i = inb(dev->iobase + DT2811_ADDATLO); - i = inb(dev->iobase + DT2811_ADDATHI); -#endif - ret = comedi_alloc_subdevices(dev, 4); if (ret) return ret; -- cgit v1.1 From 022ac9529986e494b39386ab59eb97c99d2e4983 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:09 -0700 Subject: staging: comedi: dt2811: tidy up A/D Control/Status register defines Cleanup the defines for this register and its bits and remove the redundant information in the comment. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 59 ++++++++++++--------------------- 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 3cd9fe5..433cfd1 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -44,6 +44,25 @@ #include #include "../comedidev.h" +/* + * Register I/O map + */ +#define DT2811_ADCSR_REG 0x00 /* r/w A/D Control/Status */ +#define DT2811_ADCSR_ADDONE BIT(7) /* r 1=A/D conv done */ +#define DT2811_ADCSR_ADERROR BIT(6) /* r 1=A/D error */ +#define DT2811_ADCSR_ADBUSY BIT(5) /* r 1=A/D busy */ +#define DT2811_ADCSR_CLRERROR BIT(4) +#define DT2811_ADCSR_INTENB BIT(2) /* r/w 1=interupts ena */ +#define DT2811_ADCSR_ADMODE(x) (((x) & 0x3) << 0) +/* single conversion on ADGCR load */ +#define DT2811_ADCSR_ADMODE_SINGLE DT2811_ADCSR_ADMODE(0) +/* continuous conversion, internal clock, (clock enabled on ADGCR load) */ +#define DT2811_ADCSR_ADMODE_CONT DT2811_ADCSR_ADMODE(1) +/* continuous conversion, internal clock, external trigger */ +#define DT2811_ADCSR_ADMODE_EXT_TRIG DT2811_ADCSR_ADMODE(2) +/* continuous conversion, external clock, external trigger */ +#define DT2811_ADCSR_ADMODE_EXT DT2811_ADCSR_ADMODE(3) + static const struct comedi_lrange range_dt2811_pgh_ai_5_unipolar = { 4, { UNI_RANGE(5), @@ -100,28 +119,6 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { /* - 0x00 ADCSR R/W A/D Control/Status Register - bit 7 - (R) 1 indicates A/D conversion done - reading ADDAT clears bit - (W) ignored - bit 6 - (R) 1 indicates A/D error - (W) ignored - bit 5 - (R) 1 indicates A/D busy, cleared at end - of conversion - (W) ignored - bit 4 - (R) 0 - (W) - bit 3 - (R) 0 - bit 2 - (R/W) 1 indicates interrupts enabled - bits 1,0 - (R/W) mode bits - 00 single conversion on ADGCR load - 01 continuous conversion, internal clock, - (clock enabled on ADGCR load) - 10 continuous conversion, internal clock, - external trigger - 11 continuous conversion, external clock, - external trigger - 0x01 ADGCR R/W A/D Gain/Channel Register bit 6,7 - (R/W) gain select 00 gain=1, both PGH, PGL models @@ -169,7 +166,6 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { #define TIMEOUT 10000 -#define DT2811_ADCSR 0 #define DT2811_ADGCR 1 #define DT2811_ADDATLO 2 #define DT2811_ADDATHI 3 @@ -180,19 +176,6 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { #define DT2811_DIO 6 #define DT2811_TMRCTR 7 -/* - * flags - */ - -/* ADCSR */ - -#define DT2811_ADDONE 0x80 -#define DT2811_ADERROR 0x40 -#define DT2811_ADBUSY 0x20 -#define DT2811_CLRERROR 0x10 -#define DT2811_INTENB 0x04 -#define DT2811_ADMODE 0x03 - struct dt2811_board { const char *name; const struct comedi_lrange *bip_5; @@ -227,8 +210,8 @@ static int dt2811_ai_eoc(struct comedi_device *dev, { unsigned int status; - status = inb(dev->iobase + DT2811_ADCSR); - if ((status & DT2811_ADBUSY) == 0) + status = inb(dev->iobase + DT2811_ADCSR_REG); + if ((status & DT2811_ADCSR_ADBUSY) == 0) return 0; return -EBUSY; } -- cgit v1.1 From b99c859b8fc3db534c7ef7700c1627d0e3df4dbe Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:10 -0700 Subject: staging: comedi: dt2811: tidy up A/D Gain/Channel register defines Cleanup the defines for this register and its bits and remove the redundant information in the comment. Make the (*insn_read) use the range to set the gain bits correctly. Currently the gain is always set to 1. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 433cfd1..f72d6c8 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -63,6 +63,10 @@ /* continuous conversion, external clock, external trigger */ #define DT2811_ADCSR_ADMODE_EXT DT2811_ADCSR_ADMODE(3) +#define DT2811_ADGCR_REG 0x01 /* r/w A/D Gain/Channel */ +#define DT2811_ADGCR_GAIN(x) (((x) & 0x3) << 6) +#define DT2811_ADGCR_CHAN(x) (((x) & 0xf) << 0) + static const struct comedi_lrange range_dt2811_pgh_ai_5_unipolar = { 4, { UNI_RANGE(5), @@ -119,16 +123,6 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { /* - 0x01 ADGCR R/W A/D Gain/Channel Register - bit 6,7 - (R/W) gain select - 00 gain=1, both PGH, PGL models - 01 gain=2 PGH, 10 PGL - 10 gain=4 PGH, 100 PGL - 11 gain=8 PGH, 500 PGL - bit 4,5 - reserved - bit 3-0 - (R/W) channel select - channel number from 0-15 - 0x02,0x03 (R) ADDAT A/D Data Register (W) DADAT0 D/A Data Register 0 0x02 low byte @@ -166,7 +160,6 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { #define TIMEOUT 10000 -#define DT2811_ADGCR 1 #define DT2811_ADDATLO 2 #define DT2811_ADDATHI 3 #define DT2811_DADAT0LO 2 @@ -219,12 +212,15 @@ static int dt2811_ai_eoc(struct comedi_device *dev, static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - int chan = CR_CHAN(insn->chanspec); + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int range = CR_RANGE(insn->chanspec); int ret; int i; for (i = 0; i < insn->n; i++) { - outb(chan, dev->iobase + DT2811_ADGCR); + /* select channel/gain and trigger conversion */ + outb(DT2811_ADGCR_CHAN(chan) | DT2811_ADGCR_GAIN(range), + dev->iobase + DT2811_ADGCR_REG); ret = comedi_timeout(dev, s, insn, dt2811_ai_eoc, 0); if (ret) -- cgit v1.1 From d82985fa4c2e2cc6f10f45a4e62a92ab2bce4cd0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:11 -0700 Subject: staging: comedi: dt2811: tidy up A/D Data register defines Cleanup the defines for these registers and and remove the redundant information in the comment. Tidy up the reading of the data registers in the (*insn_read). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index f72d6c8..0c0b7b7 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -67,6 +67,9 @@ #define DT2811_ADGCR_GAIN(x) (((x) & 0x3) << 6) #define DT2811_ADGCR_CHAN(x) (((x) & 0xf) << 0) +#define DT2811_ADDATA_LO_REG 0x02 /* r A/D Data low byte */ +#define DT2811_ADDATA_HI_REG 0x03 /* r A/D Data high byte */ + static const struct comedi_lrange range_dt2811_pgh_ai_5_unipolar = { 4, { UNI_RANGE(5), @@ -123,7 +126,7 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { /* - 0x02,0x03 (R) ADDAT A/D Data Register + 0x02,0x03 (W) DADAT0 D/A Data Register 0 0x02 low byte 0x03 high byte @@ -160,8 +163,6 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { #define TIMEOUT 10000 -#define DT2811_ADDATLO 2 -#define DT2811_ADDATHI 3 #define DT2811_DADAT0LO 2 #define DT2811_DADAT0HI 3 #define DT2811_DADAT1LO 4 @@ -218,6 +219,8 @@ static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, int i; for (i = 0; i < insn->n; i++) { + unsigned int val; + /* select channel/gain and trigger conversion */ outb(DT2811_ADGCR_CHAN(chan) | DT2811_ADGCR_GAIN(range), dev->iobase + DT2811_ADGCR_REG); @@ -226,9 +229,11 @@ static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, if (ret) return ret; - data[i] = inb(dev->iobase + DT2811_ADDATLO); - data[i] |= inb(dev->iobase + DT2811_ADDATHI) << 8; - data[i] &= 0xfff; + val = inb(dev->iobase + DT2811_ADDATA_LO_REG) | + (inb(dev->iobase + DT2811_ADDATA_HI_REG) << 8); + val &= s->maxdata; + + data[i] = val; } return i; -- cgit v1.1 From addb85bd6e8ae5a343b991afbed72350435bba00 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:12 -0700 Subject: staging: comedi: dt2811: tidy up D/A Data register defines Cleanup the defines for these registers and and remove the redundant information in the comment. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 0c0b7b7..1717281 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -70,6 +70,9 @@ #define DT2811_ADDATA_LO_REG 0x02 /* r A/D Data low byte */ #define DT2811_ADDATA_HI_REG 0x03 /* r A/D Data high byte */ +#define DT2811_DADATA_LO_REG(x) (0x02 + ((x) * 2)) /* w D/A Data low */ +#define DT2811_DADATA_HI_REG(x) (0x03 + ((x) * 2)) /* w D/A Data high */ + static const struct comedi_lrange range_dt2811_pgh_ai_5_unipolar = { 4, { UNI_RANGE(5), @@ -125,14 +128,6 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { }; /* - - 0x02,0x03 - (W) DADAT0 D/A Data Register 0 - 0x02 low byte - 0x03 high byte - - 0x04,0x05 (W) DADAT0 D/A Data Register 1 - 0x06 (R) DIO0 Digital Input Port 0 (W) DIO1 Digital Output Port 1 @@ -163,10 +158,6 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { #define TIMEOUT 10000 -#define DT2811_DADAT0LO 2 -#define DT2811_DADAT0HI 3 -#define DT2811_DADAT1LO 4 -#define DT2811_DADAT1HI 5 #define DT2811_DIO 6 #define DT2811_TMRCTR 7 @@ -250,9 +241,9 @@ static int dt2811_ao_insn_write(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { val = data[i]; - outb(val & 0xff, dev->iobase + DT2811_DADAT0LO + 2 * chan); + outb(val & 0xff, dev->iobase + DT2811_DADATA_LO_REG(chan)); outb((val >> 8) & 0xff, - dev->iobase + DT2811_DADAT0HI + 2 * chan); + dev->iobase + DT2811_DADATA_HI_REG(chan)); } s->readback[chan] = val; -- cgit v1.1 From 3d6dc7838ca1a553628f53a4fb59aa456b3b4195 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:13 -0700 Subject: staging: comedi: dt2811: tidy up Digital Input/Output register defines The digital input and outputs are separate ports even though they share the same register offset. For aesthetics, define then separately and remove the redundant information in the comment. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 1717281..61aa323 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -73,6 +73,9 @@ #define DT2811_DADATA_LO_REG(x) (0x02 + ((x) * 2)) /* w D/A Data low */ #define DT2811_DADATA_HI_REG(x) (0x03 + ((x) * 2)) /* w D/A Data high */ +#define DT2811_DI_REG 0x06 /* r Digital Input Port 0 */ +#define DT2811_DO_REG 0x06 /* w Digital Output Port 1 */ + static const struct comedi_lrange range_dt2811_pgh_ai_5_unipolar = { 4, { UNI_RANGE(5), @@ -128,9 +131,6 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { }; /* - 0x06 (R) DIO0 Digital Input Port 0 - (W) DIO1 Digital Output Port 1 - 0x07 TMRCTR (R/W) Timer/Counter Register bits 6,7 - reserved bits 5-3 - Timer frequency control (mantissa) @@ -158,7 +158,6 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { #define TIMEOUT 10000 -#define DT2811_DIO 6 #define DT2811_TMRCTR 7 struct dt2811_board { @@ -254,7 +253,7 @@ static int dt2811_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - data[1] = inb(dev->iobase + DT2811_DIO); + data[1] = inb(dev->iobase + DT2811_DI_REG); return insn->n; } @@ -265,7 +264,7 @@ static int dt2811_do_insn_bits(struct comedi_device *dev, unsigned int *data) { if (comedi_dio_update_state(s, data)) - outb(s->state, dev->iobase + DT2811_DIO); + outb(s->state, dev->iobase + DT2811_DO_REG); data[1] = s->state; -- cgit v1.1 From ef0af0ca910b937f277dea75be4a3e1ea1ed3df5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:14 -0700 Subject: staging: comedi: dt2811: tidy up Timer/Counter register defines This register currently is not being used. For aesthetics, cleanup the define and the comment about the frequency control. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 45 +++++++++++++-------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 61aa323..6ea1ad4 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -76,6 +76,23 @@ #define DT2811_DI_REG 0x06 /* r Digital Input Port 0 */ #define DT2811_DO_REG 0x06 /* w Digital Output Port 1 */ +/* + * Timer frequency control: + * DT2811_TMRCTR_MANTISSA DT2811_TMRCTR_EXPONENT + * val divisor frequency val multiply divisor/divide frequency by + * 0 1 600 kHz 0 1 + * 1 10 60 kHz 1 10 + * 2 2 300 kHz 2 100 + * 3 3 200 kHz 3 1000 + * 4 4 150 kHz 4 10000 + * 5 5 120 kHz 5 100000 + * 6 6 100 kHz 6 1000000 + * 7 12 50 kHz 7 10000000 + */ +#define DT2811_TMRCTR_REG 0x07 /* r/w Timer/Counter */ +#define DT2811_TMRCTR_MANTISSA(x) (((x) & 0x7) << 3) +#define DT2811_TMRCTR_EXPONENT(x) (((x) & 0x7) << 0) + static const struct comedi_lrange range_dt2811_pgh_ai_5_unipolar = { 4, { UNI_RANGE(5), @@ -130,36 +147,8 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { } }; -/* - 0x07 TMRCTR (R/W) Timer/Counter Register - bits 6,7 - reserved - bits 5-3 - Timer frequency control (mantissa) - 543 divisor freqency (kHz) - 000 1 600 - 001 10 60 - 010 2 300 - 011 3 200 - 100 4 150 - 101 5 120 - 110 6 100 - 111 12 50 - bits 2-0 - Timer frequency control (exponent) - 210 multiply divisor/divide frequency by - 000 1 - 001 10 - 010 100 - 011 1000 - 100 10000 - 101 100000 - 110 1000000 - 111 10000000 - - */ - #define TIMEOUT 10000 -#define DT2811_TMRCTR 7 - struct dt2811_board { const char *name; const struct comedi_lrange *bip_5; -- cgit v1.1 From 1d1209fea1f47ae48f15c23d2df55e2e57ac1088 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:15 -0700 Subject: staging: comedi: dt2811: tidy up the digital subdevices Add some whitespace to the digital input and output subdevice initialization. Reorder the initialization a bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 6ea1ad4..0512d70 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -240,7 +240,8 @@ static int dt2811_ao_insn_write(struct comedi_device *dev, static int dt2811_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { data[1] = inb(dev->iobase + DT2811_DI_REG); @@ -357,24 +358,23 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; + /* Digital Input subdevice */ s = &dev->subdevices[2]; - /* di subdevice */ - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE; - s->n_chan = 8; - s->insn_bits = dt2811_di_insn_bits; - s->maxdata = 1; - s->range_table = &range_digital; - + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 8; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = dt2811_di_insn_bits; + + /* Digital Output subdevice */ s = &dev->subdevices[3]; - /* do subdevice */ - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = 8; - s->insn_bits = dt2811_do_insn_bits; - s->maxdata = 1; - s->state = 0; - s->range_table = &range_digital; + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = 8; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = dt2811_do_insn_bits; return 0; } -- cgit v1.1 From 5fba273959d2143bd3b22b34c698ecbffa90d3f1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:16 -0700 Subject: staging: comedi: dt2811: simplify analog output range options The D/A ranges are not programmable. Currently this driver uses some configuration options to select the comedi_lrange for each channel. This is a bit messy and it requires the user to make sure the correct option value is used. The range information isn't used by the driver. The user space library uses it to convert between raw data values and physical units. If the user passed an incorrect option when attaching the driver the conversion will be incorrect. Simplify the analog output ranges by providing a range_table that contains all the possible output ranges. The user can then select the correct range when converting values. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 69 +++++++++++++-------------------- 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 0512d70..6850eb8 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -37,8 +37,14 @@ * 0 = [-5, 5] * 1 = [-2.5, 2.5] * 2 = [0, 5] - * [4] - D/A 0 range (same as A/D range) - * [5] - D/A 1 range (same as A/D range) + * [4] - D/A 0 range (deprecated, see below) + * [5] - D/A 1 range (deprecated, see below) + * + * Notes: + * - D/A ranges are not programmable. The AO subdevice has a range_table + * containing all the possible analog output ranges. Use the range + * that matches your board configuration to convert between data + * values and physical units. */ #include @@ -147,6 +153,23 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { } }; +/* + * The Analog Output range is set per-channel using jumpers on the board. + * + * DAC0 Jumpers DAC1 Jumpers + * Output Range W5 W6 W7 W8 W1 W2 W3 W4 + * -5V to +5V In Out In Out In Out In Out + * -2.5V to +2.5V In Out Out In In Out Out In + * 0 to +5V Out In Out In Out In Out In + */ +static const struct comedi_lrange dt2811_ao_ranges = { + 3, { + BIP_RANGE(5), /* default setting from factory */ + BIP_RANGE(2.5), + UNI_RANGE(5) + } +}; + #define TIMEOUT 10000 struct dt2811_board { @@ -164,16 +187,6 @@ struct dt2811_private { enum { adc_singleended, adc_diff, adc_pseudo_diff } adc_mux; - enum { - dac_bipolar_5, dac_bipolar_2_5, dac_unipolar_5 - } dac_range[2]; - const struct comedi_lrange *range_type_list[2]; -}; - -static const struct comedi_lrange *dac_range_types[] = { - &range_bipolar5, - &range_bipolar2_5, - &range_unipolar5 }; static int dt2811_ai_eoc(struct comedi_device *dev, @@ -294,34 +307,6 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->adc_mux = adc_singleended; break; } - switch (it->options[4]) { - case 0: - devpriv->dac_range[0] = dac_bipolar_5; - break; - case 1: - devpriv->dac_range[0] = dac_bipolar_2_5; - break; - case 2: - devpriv->dac_range[0] = dac_unipolar_5; - break; - default: - devpriv->dac_range[0] = dac_bipolar_5; - break; - } - switch (it->options[5]) { - case 0: - devpriv->dac_range[1] = dac_bipolar_5; - break; - case 1: - devpriv->dac_range[1] = dac_bipolar_2_5; - break; - case 2: - devpriv->dac_range[1] = dac_unipolar_5; - break; - default: - devpriv->dac_range[1] = dac_bipolar_5; - break; - } s = &dev->subdevices[0]; /* initialize the ADC subdevice */ @@ -349,9 +334,7 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; s->maxdata = 0xfff; - s->range_table_list = devpriv->range_type_list; - devpriv->range_type_list[0] = dac_range_types[devpriv->dac_range[0]]; - devpriv->range_type_list[1] = dac_range_types[devpriv->dac_range[1]]; + s->range_table = &dt2811_ao_ranges; s->insn_write = dt2811_ao_insn_write; ret = comedi_alloc_subdev_readback(s); -- cgit v1.1 From dedfdf9009fde19dbb1e1da9cc42c6dab6795135 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:17 -0700 Subject: staging: comedi: dt2811: tidy up analog output subdevice init Add some whitespace to the analog output subdevice initialization. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 6850eb8..b60ee74 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -328,14 +328,14 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) break; } + /* Analog Output subdevice */ s = &dev->subdevices[1]; - /* ao subdevice */ - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = 2; - s->maxdata = 0xfff; - s->range_table = &dt2811_ao_ranges; - s->insn_write = dt2811_ao_insn_write; + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = 2; + s->maxdata = 0x0fff; + s->range_table = &dt2811_ao_ranges; + s->insn_write = dt2811_ao_insn_write; ret = comedi_alloc_subdev_readback(s); if (ret) -- cgit v1.1 From 7c9574090d30609df66d5c39139c82e6b6e98f9c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:18 -0700 Subject: staging: comedi: dt2811: simplify A/D reference configuration The analog inputs are confgured with jumpers on the board to be: * 16 single-ended inputs * 8 differential inputs * 16 pseudo-differential inputs (common ground) Simplify the handling of this configuration option and properly set the subdev_flags based on the selected input mode. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index b60ee74..1fe657c 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -29,10 +29,10 @@ * Configuration options: * [0] - I/O port base address * [1] - IRQ, although this is currently unused - * [2] - A/D reference - * 0 = single-ended - * 1 = differential - * 2 = pseudo-differential (common reference) + * [2] - A/D reference (# of analog inputs) + * 0 = single-ended (16 channels) + * 1 = differential (8 channels) + * 2 = pseudo-differential (16 channels) * [3] - A/D range * 0 = [-5, 5] * 1 = [-2.5, 2.5] @@ -184,9 +184,6 @@ enum { card_2811_pgh, card_2811_pgl }; struct dt2811_private { int ntrig; int curadchan; - enum { - adc_singleended, adc_diff, adc_pseudo_diff - } adc_mux; }; static int dt2811_ai_eoc(struct comedi_device *dev, @@ -293,26 +290,13 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (!devpriv) return -ENOMEM; - switch (it->options[2]) { - case 0: - devpriv->adc_mux = adc_singleended; - break; - case 1: - devpriv->adc_mux = adc_diff; - break; - case 2: - devpriv->adc_mux = adc_pseudo_diff; - break; - default: - devpriv->adc_mux = adc_singleended; - break; - } - s = &dev->subdevices[0]; /* initialize the ADC subdevice */ s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE | SDF_GROUND; - s->n_chan = devpriv->adc_mux == adc_diff ? 8 : 16; + s->subdev_flags = SDF_READABLE | + (it->options[2] == 1) ? SDF_DIFF : + (it->options[2] == 2) ? SDF_COMMON : SDF_GROUND; + s->n_chan = (it->options[2] == 1) ? 8 : 16; s->insn_read = dt2811_ai_insn; s->maxdata = 0xfff; switch (it->options[3]) { -- cgit v1.1 From acd356f9fc4eda5d4523bcede2f461480fc49fe8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:19 -0700 Subject: staging: comedi: dt2811: remove private data The remaining members of the private data are not used by the driver. Remove it and the allocation. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 1fe657c..379b7d5 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -181,11 +181,6 @@ struct dt2811_board { enum { card_2811_pgh, card_2811_pgl }; -struct dt2811_private { - int ntrig; - int curadchan; -}; - static int dt2811_ai_eoc(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -274,7 +269,6 @@ static int dt2811_do_insn_bits(struct comedi_device *dev, static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct dt2811_board *board = dev->board_ptr; - struct dt2811_private *devpriv; struct comedi_subdevice *s; int ret; @@ -286,10 +280,6 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - s = &dev->subdevices[0]; /* initialize the ADC subdevice */ s->type = COMEDI_SUBD_AI; -- cgit v1.1 From 048e27aac962b1079920ab856c7b36c109be8386 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:20 -0700 Subject: staging: comedi: dt2811: simplify analog input range options The A/D ranges are not programmable but the gain is. Currently this driver uses a configuration option to select the comedi_lrange that will be used for the analog input subdevice. This requires that the user makes sure the correct option value is used. The user space library uses the range information to convert between raw values and physical units. If the user passed an incorrect option when attaching the driver the conversion will be incorrect. A previous patch allowed the gain to be set based on the chanspec range. Prior to that the gain was always set to 1 so any conversion with a gain that is not 1 would be incorrect anyway. Simplify the analog input ranges by providing a range_table for the pgh and pgl boards that contain all the possible range/gain options. The user can then select the correct range (and gain) when converting values or reading the analog inputs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 143 ++++++++++++++------------------ 1 file changed, 61 insertions(+), 82 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 379b7d5..f0b3c5e 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -33,14 +33,17 @@ * 0 = single-ended (16 channels) * 1 = differential (8 channels) * 2 = pseudo-differential (16 channels) - * [3] - A/D range - * 0 = [-5, 5] - * 1 = [-2.5, 2.5] - * 2 = [0, 5] + * [3] - A/D range (deprecated, see below) * [4] - D/A 0 range (deprecated, see below) * [5] - D/A 1 range (deprecated, see below) * * Notes: + * - A/D ranges are not programmable but the gain is. The AI subdevice has + * a range_table containing all the possible analog input range/gain + * options for the dt2811-pgh or dt2811-pgl. Use the range that matches + * your board configuration and the desired gain to correctly convert + * between data values and physical units and to set the correct output + * gain. * - D/A ranges are not programmable. The AO subdevice has a range_table * containing all the possible analog output ranges. Use the range * that matches your board configuration to convert between data @@ -99,57 +102,52 @@ #define DT2811_TMRCTR_MANTISSA(x) (((x) & 0x7) << 3) #define DT2811_TMRCTR_EXPONENT(x) (((x) & 0x7) << 0) -static const struct comedi_lrange range_dt2811_pgh_ai_5_unipolar = { - 4, { - UNI_RANGE(5), - UNI_RANGE(2.5), - UNI_RANGE(1.25), - UNI_RANGE(0.625) - } -}; - -static const struct comedi_lrange range_dt2811_pgh_ai_2_5_bipolar = { - 4, { - BIP_RANGE(2.5), - BIP_RANGE(1.25), - BIP_RANGE(0.625), - BIP_RANGE(0.3125) - } -}; - -static const struct comedi_lrange range_dt2811_pgh_ai_5_bipolar = { - 4, { - BIP_RANGE(5), - BIP_RANGE(2.5), - BIP_RANGE(1.25), - BIP_RANGE(0.625) - } -}; - -static const struct comedi_lrange range_dt2811_pgl_ai_5_unipolar = { - 4, { - UNI_RANGE(5), - UNI_RANGE(0.5), - UNI_RANGE(0.05), - UNI_RANGE(0.01) - } -}; - -static const struct comedi_lrange range_dt2811_pgl_ai_2_5_bipolar = { - 4, { - BIP_RANGE(2.5), - BIP_RANGE(0.25), - BIP_RANGE(0.025), - BIP_RANGE(0.005) +/* + * The Analog Input range is set using jumpers on the board. + * + * Input Range W9 W10 + * -5V to +5V In Out + * -2.5V to +2.5V In In + * 0V to +5V Out In + * + * The gain may be set to 1, 2, 4, or 8 (on the dt2811-pgh) or to + * 1, 10, 100, 500 (on the dt2811-pgl). + */ +static const struct comedi_lrange dt2811_pgh_ai_ranges = { + 12, { + BIP_RANGE(5), /* range 0: gain=1 */ + BIP_RANGE(2.5), /* range 1: gain=2 */ + BIP_RANGE(1.25), /* range 2: gain=4 */ + BIP_RANGE(0.625), /* range 3: gain=8 */ + + BIP_RANGE(2.5), /* range 0+4: gain=1 */ + BIP_RANGE(1.25), /* range 1+4: gain=2 */ + BIP_RANGE(0.625), /* range 2+4: gain=4 */ + BIP_RANGE(0.3125), /* range 3+4: gain=8 */ + + UNI_RANGE(5), /* range 0+8: gain=1 */ + UNI_RANGE(2.5), /* range 1+8: gain=2 */ + UNI_RANGE(1.25), /* range 2+8: gain=4 */ + UNI_RANGE(0.625) /* range 3+8: gain=8 */ } }; -static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = { - 4, { - BIP_RANGE(5), - BIP_RANGE(0.5), - BIP_RANGE(0.05), - BIP_RANGE(0.01) +static const struct comedi_lrange dt2811_pgl_ai_ranges = { + 12, { + BIP_RANGE(5), /* range 0: gain=1 */ + BIP_RANGE(0.5), /* range 1: gain=10 */ + BIP_RANGE(0.05), /* range 2: gain=100 */ + BIP_RANGE(0.01), /* range 3: gain=500 */ + + BIP_RANGE(2.5), /* range 0+4: gain=1 */ + BIP_RANGE(0.25), /* range 1+4: gain=10 */ + BIP_RANGE(0.025), /* range 2+4: gain=100 */ + BIP_RANGE(0.005), /* range 3+4: gain=500 */ + + UNI_RANGE(5), /* range 0+8: gain=1 */ + UNI_RANGE(0.5), /* range 1+8: gain=10 */ + UNI_RANGE(0.05), /* range 2+8: gain=100 */ + UNI_RANGE(0.01) /* range 3+8: gain=500 */ } }; @@ -174,12 +172,17 @@ static const struct comedi_lrange dt2811_ao_ranges = { struct dt2811_board { const char *name; - const struct comedi_lrange *bip_5; - const struct comedi_lrange *bip_2_5; - const struct comedi_lrange *unip_5; + unsigned int is_pgh:1; }; -enum { card_2811_pgh, card_2811_pgl }; +static const struct dt2811_board boardtypes[] = { + { + .name = "dt2811-pgh", + .is_pgh = 1, + }, { + .name = "dt2811-pgl", + }, +}; static int dt2811_ai_eoc(struct comedi_device *dev, struct comedi_subdevice *s, @@ -289,18 +292,8 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->n_chan = (it->options[2] == 1) ? 8 : 16; s->insn_read = dt2811_ai_insn; s->maxdata = 0xfff; - switch (it->options[3]) { - case 0: - default: - s->range_table = board->bip_5; - break; - case 1: - s->range_table = board->bip_2_5; - break; - case 2: - s->range_table = board->unip_5; - break; - } + s->range_table = board->is_pgh ? &dt2811_pgh_ai_ranges + : &dt2811_pgl_ai_ranges; /* Analog Output subdevice */ s = &dev->subdevices[1]; @@ -336,20 +329,6 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) return 0; } -static const struct dt2811_board boardtypes[] = { - { - .name = "dt2811-pgh", - .bip_5 = &range_dt2811_pgh_ai_5_bipolar, - .bip_2_5 = &range_dt2811_pgh_ai_2_5_bipolar, - .unip_5 = &range_dt2811_pgh_ai_5_unipolar, - }, { - .name = "dt2811-pgl", - .bip_5 = &range_dt2811_pgl_ai_5_bipolar, - .bip_2_5 = &range_dt2811_pgl_ai_2_5_bipolar, - .unip_5 = &range_dt2811_pgl_ai_5_unipolar, - }, -}; - static struct comedi_driver dt2811_driver = { .driver_name = "dt2811", .module = THIS_MODULE, -- cgit v1.1 From f52e8d0cae9a1b18da9304487395b730f08422b8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:21 -0700 Subject: staging: comedi: dt2811: tidy up analog input subdevice init Add some whitespace to the analog output subdevice initialization and rename the (*insn_read) function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index f0b3c5e..44afa78 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -197,8 +197,10 @@ static int dt2811_ai_eoc(struct comedi_device *dev, return -EBUSY; } -static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int dt2811_ai_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); unsigned int range = CR_RANGE(insn->chanspec); @@ -283,17 +285,17 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; + /* Analog Input subdevice */ s = &dev->subdevices[0]; - /* initialize the ADC subdevice */ - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE | + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE | (it->options[2] == 1) ? SDF_DIFF : (it->options[2] == 2) ? SDF_COMMON : SDF_GROUND; - s->n_chan = (it->options[2] == 1) ? 8 : 16; - s->insn_read = dt2811_ai_insn; - s->maxdata = 0xfff; + s->n_chan = (it->options[2] == 1) ? 8 : 16; + s->maxdata = 0x0fff; s->range_table = board->is_pgh ? &dt2811_pgh_ai_ranges : &dt2811_pgl_ai_ranges; + s->insn_read = dt2811_ai_insn_read; /* Analog Output subdevice */ s = &dev->subdevices[1]; -- cgit v1.1 From a426744c74314054fbf8c3036eaba8d779eb3086 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:22 -0700 Subject: staging: comedi: dt2811: remove unused define This define is not used by the driver. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 44afa78..b1926e7 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -168,8 +168,6 @@ static const struct comedi_lrange dt2811_ao_ranges = { } }; -#define TIMEOUT 10000 - struct dt2811_board { const char *name; unsigned int is_pgh:1; -- cgit v1.1 From 9910131ceb8b798a044244fe7dd0e4838e2923b4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:23 -0700 Subject: staging: comedi: dt2811: rename 'boardtypes' Rename this array so it has namespace associated with the driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index b1926e7..312403f 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -173,7 +173,7 @@ struct dt2811_board { unsigned int is_pgh:1; }; -static const struct dt2811_board boardtypes[] = { +static const struct dt2811_board dt2811_boards[] = { { .name = "dt2811-pgh", .is_pgh = 1, @@ -334,8 +334,8 @@ static struct comedi_driver dt2811_driver = { .module = THIS_MODULE, .attach = dt2811_attach, .detach = comedi_legacy_detach, - .board_name = &boardtypes[0].name, - .num_names = ARRAY_SIZE(boardtypes), + .board_name = &dt2811_boards[0].name, + .num_names = ARRAY_SIZE(dt2811_boards), .offset = sizeof(struct dt2811_board), }; module_comedi_driver(dt2811_driver); -- cgit v1.1 From 277b861349d1fda79e124a3d0fd81f5d6e594b3f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 12:47:24 -0700 Subject: staging: comedi: dt2811: update the MODULE_DESCRIPTION Change the MODULE_DESCRIPTION to something more useful than the generic "Comedi low-level driver". Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 312403f..415512b 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -341,5 +341,5 @@ static struct comedi_driver dt2811_driver = { module_comedi_driver(dt2811_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("Comedi driver for Data Translation DT2811 series boards"); MODULE_LICENSE("GPL"); -- cgit v1.1 From 34d3473263250c4c0883d7d6d95e8f122d8d348d Mon Sep 17 00:00:00 2001 From: Shyam Saini Date: Tue, 10 May 2016 21:21:07 +0530 Subject: Staging: comedi: comedi_fops.c: Fixed coding style issue Fixed following checkpatch.pl warnings WARNING: Prefer WRITE_ONCE(, ) over ACCESS_ONCE() = WARNING: Prefer READ_ONCE() over ACCESS_ONCE() Signed-off-by: Shyam Saini Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 629080f..4d87596 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -312,8 +312,8 @@ static void comedi_file_reset(struct file *file) } cfp->last_attached = dev->attached; cfp->last_detach_count = dev->detach_count; - ACCESS_ONCE(cfp->read_subdev) = read_s; - ACCESS_ONCE(cfp->write_subdev) = write_s; + WRITE_ONCE(cfp->read_subdev, read_s); + WRITE_ONCE(cfp->write_subdev, write_s); } static void comedi_file_check(struct file *file) @@ -331,7 +331,7 @@ static struct comedi_subdevice *comedi_file_read_subdevice(struct file *file) struct comedi_file *cfp = file->private_data; comedi_file_check(file); - return ACCESS_ONCE(cfp->read_subdev); + return READ_ONCE(cfp->read_subdev); } static struct comedi_subdevice *comedi_file_write_subdevice(struct file *file) @@ -339,7 +339,7 @@ static struct comedi_subdevice *comedi_file_write_subdevice(struct file *file) struct comedi_file *cfp = file->private_data; comedi_file_check(file); - return ACCESS_ONCE(cfp->write_subdev); + return READ_ONCE(cfp->write_subdev); } static int resize_async_buffer(struct comedi_device *dev, @@ -1992,7 +1992,7 @@ static int do_setrsubd_ioctl(struct comedi_device *dev, unsigned long arg, !(s_old->async->cmd.flags & CMDF_WRITE)) return -EBUSY; - ACCESS_ONCE(cfp->read_subdev) = s_new; + WRITE_ONCE(cfp->read_subdev, s_new); return 0; } @@ -2034,7 +2034,7 @@ static int do_setwsubd_ioctl(struct comedi_device *dev, unsigned long arg, (s_old->async->cmd.flags & CMDF_WRITE)) return -EBUSY; - ACCESS_ONCE(cfp->write_subdev) = s_new; + WRITE_ONCE(cfp->write_subdev, s_new); return 0; } -- cgit v1.1 From f2975a9b2ab9a9243f2ca2e99d8209e01138cdfc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 4 May 2016 15:25:38 -0700 Subject: staging: comedi: dt2811: add async command support for AI subdevice The interrupt support available on this board is pretty limited but its simple enough to give basic async command support. This allows reading a single channel continuously using either the internal or an external clock to trigger each conversion. The command can also use the external trigger input to start the command if the external clock is being used for conversions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2811.c | 371 +++++++++++++++++++++++++++++--- 1 file changed, 340 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 415512b..904f6377 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -2,11 +2,7 @@ * Comedi driver for Data Translation DT2811 * * COMEDI - Linux Control and Measurement Device Interface - * History: - * Base Version - David A. Schleef - * December 1998 - Updated to work. David does not have a DT2811 - * board any longer so this was suffering from bitrot. - * Updated performed by ... + * Copyright (C) David A. Schleef * * 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 @@ -28,7 +24,7 @@ * * Configuration options: * [0] - I/O port base address - * [1] - IRQ, although this is currently unused + * [1] - IRQ (optional, needed for async command support) * [2] - A/D reference (# of analog inputs) * 0 = single-ended (16 channels) * 1 = differential (8 channels) @@ -51,6 +47,9 @@ */ #include +#include +#include + #include "../comedidev.h" /* @@ -61,16 +60,9 @@ #define DT2811_ADCSR_ADERROR BIT(6) /* r 1=A/D error */ #define DT2811_ADCSR_ADBUSY BIT(5) /* r 1=A/D busy */ #define DT2811_ADCSR_CLRERROR BIT(4) -#define DT2811_ADCSR_INTENB BIT(2) /* r/w 1=interupts ena */ +#define DT2811_ADCSR_DMAENB BIT(3) /* r/w 1=dma ena */ +#define DT2811_ADCSR_INTENB BIT(2) /* r/w 1=interupts ena */ #define DT2811_ADCSR_ADMODE(x) (((x) & 0x3) << 0) -/* single conversion on ADGCR load */ -#define DT2811_ADCSR_ADMODE_SINGLE DT2811_ADCSR_ADMODE(0) -/* continuous conversion, internal clock, (clock enabled on ADGCR load) */ -#define DT2811_ADCSR_ADMODE_CONT DT2811_ADCSR_ADMODE(1) -/* continuous conversion, internal clock, external trigger */ -#define DT2811_ADCSR_ADMODE_EXT_TRIG DT2811_ADCSR_ADMODE(2) -/* continuous conversion, external clock, external trigger */ -#define DT2811_ADCSR_ADMODE_EXT DT2811_ADCSR_ADMODE(3) #define DT2811_ADGCR_REG 0x01 /* r/w A/D Gain/Channel */ #define DT2811_ADGCR_GAIN(x) (((x) & 0x3) << 6) @@ -85,6 +77,12 @@ #define DT2811_DI_REG 0x06 /* r Digital Input Port 0 */ #define DT2811_DO_REG 0x06 /* w Digital Output Port 1 */ +#define DT2811_TMRCTR_REG 0x07 /* r/w Timer/Counter */ +#define DT2811_TMRCTR_MANTISSA(x) (((x) & 0x7) << 3) +#define DT2811_TMRCTR_EXPONENT(x) (((x) & 0x7) << 0) + +#define DT2811_OSC_BASE 1666 /* 600 kHz = 1666.6667ns */ + /* * Timer frequency control: * DT2811_TMRCTR_MANTISSA DT2811_TMRCTR_EXPONENT @@ -98,9 +96,13 @@ * 6 6 100 kHz 6 1000000 * 7 12 50 kHz 7 10000000 */ -#define DT2811_TMRCTR_REG 0x07 /* r/w Timer/Counter */ -#define DT2811_TMRCTR_MANTISSA(x) (((x) & 0x7) << 3) -#define DT2811_TMRCTR_EXPONENT(x) (((x) & 0x7) << 0) +const unsigned int dt2811_clk_dividers[] = { + 1, 10, 2, 3, 4, 5, 6, 12 +}; + +const unsigned int dt2811_clk_multipliers[] = { + 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000 +}; /* * The Analog Input range is set using jumpers on the board. @@ -182,6 +184,287 @@ static const struct dt2811_board dt2811_boards[] = { }, }; +struct dt2811_private { + unsigned int ai_divisor; +}; + +static unsigned int dt2811_ai_read_sample(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + unsigned int val; + + val = inb(dev->iobase + DT2811_ADDATA_LO_REG) | + (inb(dev->iobase + DT2811_ADDATA_HI_REG) << 8); + + return val & s->maxdata; +} + +static irqreturn_t dt2811_interrupt(int irq, void *d) +{ + struct comedi_device *dev = d; + struct comedi_subdevice *s = dev->read_subdev; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; + unsigned int status; + + if (!dev->attached) + return IRQ_NONE; + + status = inb(dev->iobase + DT2811_ADCSR_REG); + + if (status & DT2811_ADCSR_ADERROR) { + async->events |= COMEDI_CB_OVERFLOW; + + outb(status | DT2811_ADCSR_CLRERROR, + dev->iobase + DT2811_ADCSR_REG); + } + + if (status & DT2811_ADCSR_ADDONE) { + unsigned short val; + + val = dt2811_ai_read_sample(dev, s); + comedi_buf_write_samples(s, &val, 1); + } + + if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg) + async->events |= COMEDI_CB_EOA; + + comedi_handle_events(dev, s); + + return IRQ_HANDLED; +} + +static int dt2811_ai_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + /* + * Mode 0 + * Single conversion + * + * Loading a chanspec will trigger a conversion. + */ + outb(DT2811_ADCSR_ADMODE(0), dev->iobase + DT2811_ADCSR_REG); + + return 0; +} + +static void dt2811_ai_set_chanspec(struct comedi_device *dev, + unsigned int chanspec) +{ + unsigned int chan = CR_CHAN(chanspec); + unsigned int range = CR_RANGE(chanspec); + + outb(DT2811_ADGCR_CHAN(chan) | DT2811_ADGCR_GAIN(range), + dev->iobase + DT2811_ADGCR_REG); +} + +static int dt2811_ai_cmd(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + struct dt2811_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; + unsigned int mode; + + if (cmd->start_src == TRIG_NOW) { + /* + * Mode 1 + * Continuous conversion, internal trigger and clock + * + * This resets the trigger flip-flop, disabling A/D strobes. + * The timer/counter register is loaded with the division + * ratio which will give the required sample rate. + * + * Loading the first chanspec sets the trigger flip-flop, + * enabling the timer/counter. A/D strobes are then generated + * at the rate set by the internal clock/divider. + */ + mode = DT2811_ADCSR_ADMODE(1); + } else { /* TRIG_EXT */ + if (cmd->convert_src == TRIG_TIMER) { + /* + * Mode 2 + * Continuous conversion, external trigger + * + * Similar to Mode 1, with the exception that the + * trigger flip-flop must be set by a negative edge + * on the external trigger input. + */ + mode = DT2811_ADCSR_ADMODE(2); + } else { /* TRIG_EXT */ + /* + * Mode 3 + * Continuous conversion, external trigger, clock + * + * Similar to Mode 2, with the exception that the + * conversion rate is set by the frequency on the + * external clock/divider. + */ + mode = DT2811_ADCSR_ADMODE(3); + } + } + outb(mode | DT2811_ADCSR_INTENB, dev->iobase + DT2811_ADCSR_REG); + + /* load timer */ + outb(devpriv->ai_divisor, dev->iobase + DT2811_TMRCTR_REG); + + /* load chanspec - enables timer */ + dt2811_ai_set_chanspec(dev, cmd->chanlist[0]); + + return 0; +} + +static unsigned int dt2811_ns_to_timer(unsigned int *nanosec, + unsigned int flags) +{ + unsigned long long ns = *nanosec; + unsigned int ns_lo = COMEDI_MIN_SPEED; + unsigned int ns_hi = 0; + unsigned int divisor_hi = 0; + unsigned int divisor_lo = 0; + unsigned int _div; + unsigned int _mult; + + /* + * Work through all the divider/multiplier values to find the two + * closest divisors to generate the requested nanosecond timing. + */ + for (_div = 0; _div <= 7; _div++) { + for (_mult = 0; _mult <= 7; _mult++) { + unsigned int div = dt2811_clk_dividers[_div]; + unsigned int mult = dt2811_clk_multipliers[_mult]; + unsigned long long divider = div * mult; + unsigned int divisor = DT2811_TMRCTR_MANTISSA(_div) | + DT2811_TMRCTR_EXPONENT(_mult); + + /* + * The timer can be configured to run at a slowest + * speed of 0.005hz (600 Khz/120000000), which requires + * 37-bits to represent the nanosecond value. Limit the + * slowest timing to what comedi handles (32-bits). + */ + ns = divider * DT2811_OSC_BASE; + if (ns > COMEDI_MIN_SPEED) + continue; + + /* Check for fastest found timing */ + if (ns <= *nanosec && ns > ns_hi) { + ns_hi = ns; + divisor_hi = divisor; + } + /* Check for slowest found timing */ + if (ns >= *nanosec && ns < ns_lo) { + ns_lo = ns; + divisor_lo = divisor; + } + } + } + + /* + * The slowest found timing will be invalid if the requested timing + * is faster than what can be generated by the timer. Fix it so that + * CMDF_ROUND_UP returns valid timing. + */ + if (ns_lo == COMEDI_MIN_SPEED) { + ns_lo = ns_hi; + divisor_lo = divisor_hi; + } + /* + * The fastest found timing will be invalid if the requested timing + * is less than what can be generated by the timer. Fix it so that + * CMDF_ROUND_NEAREST and CMDF_ROUND_DOWN return valid timing. + */ + if (ns_hi == 0) { + ns_hi = ns_lo; + divisor_hi = divisor_lo; + } + + switch (flags & CMDF_ROUND_MASK) { + case CMDF_ROUND_NEAREST: + default: + if (ns_hi - *nanosec < *nanosec - ns_lo) { + *nanosec = ns_lo; + return divisor_lo; + } + *nanosec = ns_hi; + return divisor_hi; + case CMDF_ROUND_UP: + *nanosec = ns_lo; + return divisor_lo; + case CMDF_ROUND_DOWN: + *nanosec = ns_hi; + return divisor_hi; + } +} + +static int dt2811_ai_cmdtest(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_cmd *cmd) +{ + struct dt2811_private *devpriv = dev->private; + unsigned int arg; + int err = 0; + + /* Step 1 : check if triggers are trivially valid */ + + err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT); + err |= comedi_check_trigger_src(&cmd->scan_begin_src, TRIG_FOLLOW); + err |= comedi_check_trigger_src(&cmd->convert_src, + TRIG_TIMER | TRIG_EXT); + err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); + err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE); + + if (err) + return 1; + + /* Step 2a : make sure trigger sources are unique */ + + err |= comedi_check_trigger_is_unique(cmd->start_src); + err |= comedi_check_trigger_is_unique(cmd->convert_src); + err |= comedi_check_trigger_is_unique(cmd->stop_src); + + /* Step 2b : and mutually compatible */ + + if (cmd->convert_src == TRIG_EXT && cmd->start_src != TRIG_EXT) + err |= -EINVAL; + + if (err) + return 2; + + /* Step 3: check if arguments are trivially valid */ + + err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0); + err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0); + if (cmd->convert_src == TRIG_TIMER) + err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 12500); + err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg, + cmd->chanlist_len); + if (cmd->stop_src == TRIG_COUNT) + err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1); + else /* TRIG_NONE */ + err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0); + + if (err) + return 3; + + /* Step 4: fix up any arguments */ + + if (cmd->convert_src == TRIG_TIMER) { + arg = cmd->convert_arg; + devpriv->ai_divisor = dt2811_ns_to_timer(&arg, cmd->flags); + err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg); + } else { /* TRIG_EXT */ + /* The convert_arg is used to set the divisor. */ + devpriv->ai_divisor = cmd->convert_arg; + } + + if (err) + return 4; + + /* Step 5: check channel list if it exists */ + + return 0; +} + static int dt2811_ai_eoc(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -200,30 +483,22 @@ static int dt2811_ai_insn_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int range = CR_RANGE(insn->chanspec); int ret; int i; + /* We will already be in Mode 0 */ for (i = 0; i < insn->n; i++) { - unsigned int val; - - /* select channel/gain and trigger conversion */ - outb(DT2811_ADGCR_CHAN(chan) | DT2811_ADGCR_GAIN(range), - dev->iobase + DT2811_ADGCR_REG); + /* load chanspec and trigger conversion */ + dt2811_ai_set_chanspec(dev, insn->chanspec); ret = comedi_timeout(dev, s, insn, dt2811_ai_eoc, 0); if (ret) return ret; - val = inb(dev->iobase + DT2811_ADDATA_LO_REG) | - (inb(dev->iobase + DT2811_ADDATA_HI_REG) << 8); - val &= s->maxdata; - - data[i] = val; + data[i] = dt2811_ai_read_sample(dev, s); } - return i; + return insn->n; } static int dt2811_ao_insn_write(struct comedi_device *dev, @@ -269,16 +544,42 @@ static int dt2811_do_insn_bits(struct comedi_device *dev, return insn->n; } +static void dt2811_reset(struct comedi_device *dev) +{ + /* This is the initialization sequence from the users manual */ + outb(DT2811_ADCSR_ADMODE(0), dev->iobase + DT2811_ADCSR_REG); + usleep_range(100, 1000); + inb(dev->iobase + DT2811_ADDATA_LO_REG); + inb(dev->iobase + DT2811_ADDATA_HI_REG); + outb(DT2811_ADCSR_ADMODE(0) | DT2811_ADCSR_CLRERROR, + dev->iobase + DT2811_ADCSR_REG); +} + static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct dt2811_board *board = dev->board_ptr; + struct dt2811_private *devpriv; struct comedi_subdevice *s; int ret; + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); + if (!devpriv) + return -ENOMEM; + ret = comedi_request_region(dev, it->options[0], 0x8); if (ret) return ret; + dt2811_reset(dev); + + /* IRQ's 2,3,5,7 are valid for async command support */ + if (it->options[1] <= 7 && (BIT(it->options[1]) & 0xac)) { + ret = request_irq(it->options[1], dt2811_interrupt, 0, + dev->board_name, dev); + if (ret == 0) + dev->irq = it->options[1]; + } + ret = comedi_alloc_subdevices(dev, 4); if (ret) return ret; @@ -294,6 +595,14 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->range_table = board->is_pgh ? &dt2811_pgh_ai_ranges : &dt2811_pgl_ai_ranges; s->insn_read = dt2811_ai_insn_read; + if (dev->irq) { + dev->read_subdev = s; + s->subdev_flags |= SDF_CMD_READ; + s->len_chanlist = 1; + s->do_cmdtest = dt2811_ai_cmdtest; + s->do_cmd = dt2811_ai_cmd; + s->cancel = dt2811_ai_cancel; + } /* Analog Output subdevice */ s = &dev->subdevices[1]; -- cgit v1.1 From 805c5f93286f2e5b5ab53fb23501768b47314aea Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Wed, 8 Jun 2016 15:18:54 +0530 Subject: Staging: comedi: s626: fix comment issue This fixes up a WARNING: 'Block comments use a trailing */ on a separate line'found by the checkpatch.pl tool. Signed-off-by: Ravishankar Karkala Mallikarjunayya Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s626.h | 356 ++++++++++++++++++++++------------ 1 file changed, 237 insertions(+), 119 deletions(-) diff --git a/drivers/staging/comedi/drivers/s626.h b/drivers/staging/comedi/drivers/s626.h index b83424e..6a00a64 100644 --- a/drivers/staging/comedi/drivers/s626.h +++ b/drivers/staging/comedi/drivers/s626.h @@ -29,8 +29,10 @@ #define S626_ENCODER_CHANNELS 6 #define S626_DIO_CHANNELS 48 #define S626_DIO_BANKS 3 /* Number of DIO groups. */ -#define S626_DIO_EXTCHANS 40 /* Number of extended-capability - * DIO channels. */ +#define S626_DIO_EXTCHANS 40 /* + * Number of extended-capability + * DIO channels. + */ #define S626_NUM_TRIMDACS 12 /* Number of valid TrimDAC channels. */ @@ -48,21 +50,29 @@ #define S626_GSEL_BIPOLAR10V 0x00A0 /* S626_LP_GSEL setting 10V bipolar. */ /* Error codes that must be visible to this base class. */ -#define S626_ERR_ILLEGAL_PARM 0x00010000 /* Illegal function parameter - * value was specified. */ +#define S626_ERR_ILLEGAL_PARM 0x00010000 /* + * Illegal function parameter + * value was specified. + */ #define S626_ERR_I2C 0x00020000 /* I2C error. */ -#define S626_ERR_COUNTERSETUP 0x00200000 /* Illegal setup specified for - * counter channel. */ +#define S626_ERR_COUNTERSETUP 0x00200000 /* + * Illegal setup specified for + * counter channel. + */ #define S626_ERR_DEBI_TIMEOUT 0x00400000 /* DEBI transfer timed out. */ /* * Organization (physical order) and size (in DWORDs) of logical DMA buffers * contained by ANA_DMABUF. */ -#define S626_ADC_DMABUF_DWORDS 40 /* ADC DMA buffer must hold 16 samples, - * plus pre/post garbage samples. */ -#define S626_DAC_WDMABUF_DWORDS 1 /* DAC output DMA buffer holds a single - * sample. */ +#define S626_ADC_DMABUF_DWORDS 40 /* + * ADC DMA buffer must hold 16 samples, + * plus pre/post garbage samples. + */ +#define S626_DAC_WDMABUF_DWORDS 1 /* + * DAC output DMA buffer holds a single + * sample. + */ /* All remaining space in 4KB DMA buffer is available for the RPS1 program. */ @@ -95,60 +105,90 @@ #define S626_RPS_IRQ 0x60000000 /* IRQ */ #define S626_RPS_LOGICAL_OR 0x08000000 /* Logical OR conditionals. */ -#define S626_RPS_INVERT 0x04000000 /* Test for negated - * semaphores. */ +#define S626_RPS_INVERT 0x04000000 /* + * Test for negated + * semaphores. + */ #define S626_RPS_DEBI 0x00000002 /* DEBI done */ -#define S626_RPS_SIG0 0x00200000 /* RPS semaphore 0 - * (used by ADC). */ -#define S626_RPS_SIG1 0x00400000 /* RPS semaphore 1 - * (used by DAC). */ -#define S626_RPS_SIG2 0x00800000 /* RPS semaphore 2 - * (not used). */ +#define S626_RPS_SIG0 0x00200000 /* + * RPS semaphore 0 + * (used by ADC). + */ +#define S626_RPS_SIG1 0x00400000 /* + * RPS semaphore 1 + * (used by DAC). + */ +#define S626_RPS_SIG2 0x00800000 /* + * RPS semaphore 2 + * (not used). + */ #define S626_RPS_GPIO2 0x00080000 /* RPS GPIO2 */ #define S626_RPS_GPIO3 0x00100000 /* RPS GPIO3 */ -#define S626_RPS_SIGADC S626_RPS_SIG0 /* Trigger/status for - * ADC's RPS program. */ -#define S626_RPS_SIGDAC S626_RPS_SIG1 /* Trigger/status for - * DAC's RPS program. */ +#define S626_RPS_SIGADC S626_RPS_SIG0 /* + * Trigger/status for + * ADC's RPS program. + */ +#define S626_RPS_SIGDAC S626_RPS_SIG1 /* + * Trigger/status for + * DAC's RPS program. + */ /* RPS clock parameters. */ -#define S626_RPSCLK_SCALAR 8 /* This is apparent ratio of - * PCI/RPS clks (undocumented!!). */ +#define S626_RPSCLK_SCALAR 8 /* + * This is apparent ratio of + * PCI/RPS clks (undocumented!!). + */ #define S626_RPSCLK_PER_US (33 / S626_RPSCLK_SCALAR) - /* Number of RPS clocks in one - * microsecond. */ + /* + * Number of RPS clocks in one + * microsecond. + */ /* Event counter source addresses. */ #define S626_SBA_RPS_A0 0x27 /* Time of RPS0 busy, in PCI clocks. */ /* GPIO constants. */ -#define S626_GPIO_BASE 0x10004000 /* GPIO 0,2,3 = inputs, - * GPIO3 = IRQ; GPIO1 = out. */ +#define S626_GPIO_BASE 0x10004000 /* + * GPIO 0,2,3 = inputs, + * GPIO3 = IRQ; GPIO1 = out. + */ #define S626_GPIO1_LO 0x00000000 /* GPIO1 set to LOW. */ #define S626_GPIO1_HI 0x00001000 /* GPIO1 set to HIGH. */ /* Primary Status Register (PSR) constants. */ #define S626_PSR_DEBI_E 0x00040000 /* DEBI event flag. */ #define S626_PSR_DEBI_S 0x00080000 /* DEBI status flag. */ -#define S626_PSR_A2_IN 0x00008000 /* Audio output DMA2 protection - * address reached. */ -#define S626_PSR_AFOU 0x00000800 /* Audio FIFO under/overflow - * detected. */ -#define S626_PSR_GPIO2 0x00000020 /* GPIO2 input pin: 0=AdcBusy, - * 1=AdcIdle. */ -#define S626_PSR_EC0S 0x00000001 /* Event counter 0 threshold - * reached. */ +#define S626_PSR_A2_IN 0x00008000 /* + * Audio output DMA2 protection + * address reached. + */ +#define S626_PSR_AFOU 0x00000800 /* + * Audio FIFO under/overflow + * detected. + */ +#define S626_PSR_GPIO2 0x00000020 /* + * GPIO2 input pin: 0=AdcBusy, + * 1=AdcIdle. + */ +#define S626_PSR_EC0S 0x00000001 /* + * Event counter 0 threshold + * reached. + */ /* Secondary Status Register (SSR) constants. */ -#define S626_SSR_AF2_OUT 0x00000200 /* Audio 2 output FIFO - * under/overflow detected. */ +#define S626_SSR_AF2_OUT 0x00000200 /* + * Audio 2 output FIFO + * under/overflow detected. + */ /* Master Control Register 1 (MC1) constants. */ #define S626_MC1_SOFT_RESET 0x80000000 /* Invoke 7146 soft reset. */ -#define S626_MC1_SHUTDOWN 0x3FFF0000 /* Shut down all MC1-controlled - * enables. */ +#define S626_MC1_SHUTDOWN 0x3FFF0000 /* + * Shut down all MC1-controlled + * enables. + */ #define S626_MC1_ERPS1 0x2000 /* Enab/disable RPS task 1. */ #define S626_MC1_ERPS0 0x1000 /* Enab/disable RPS task 0. */ @@ -177,15 +217,23 @@ #define S626_P_DEBIAD 0x0088 /* DEBI target address. */ #define S626_P_I2CCTRL 0x008C /* I2C control. */ #define S626_P_I2CSTAT 0x0090 /* I2C status. */ -#define S626_P_BASEA2_IN 0x00AC /* Audio input 2 base physical DMAbuf - * address. */ -#define S626_P_PROTA2_IN 0x00B0 /* Audio input 2 physical DMAbuf - * protection address. */ +#define S626_P_BASEA2_IN 0x00AC /* + * Audio input 2 base physical DMAbuf + * address. + */ +#define S626_P_PROTA2_IN 0x00B0 /* + * Audio input 2 physical DMAbuf + * protection address. + */ #define S626_P_PAGEA2_IN 0x00B4 /* Audio input 2 paging attributes. */ -#define S626_P_BASEA2_OUT 0x00B8 /* Audio output 2 base physical DMAbuf - * address. */ -#define S626_P_PROTA2_OUT 0x00BC /* Audio output 2 physical DMAbuf - * protection address. */ +#define S626_P_BASEA2_OUT 0x00B8 /* + * Audio output 2 base physical DMAbuf + * address. + */ +#define S626_P_PROTA2_OUT 0x00BC /* + * Audio output 2 physical DMAbuf + * protection address. + */ #define S626_P_PAGEA2_OUT 0x00C0 /* Audio output 2 paging attributes. */ #define S626_P_RPSPAGE0 0x00C4 /* RPS0 page. */ #define S626_P_RPSPAGE1 0x00C8 /* RPS1 page. */ @@ -205,8 +253,10 @@ #define S626_P_PSR 0x0110 /* Primary status. */ #define S626_P_SSR 0x0114 /* Secondary status. */ #define S626_P_EC1R 0x0118 /* Event counter set 1. */ -#define S626_P_ADP4 0x0138 /* Logical audio DMA pointer of audio - * input FIFO A2_IN. */ +#define S626_P_ADP4 0x0138 /* + * Logical audio DMA pointer of audio + * input FIFO A2_IN. + */ #define S626_P_FB_BUFFER1 0x0144 /* Audio feedback buffer 1. */ #define S626_P_FB_BUFFER2 0x0148 /* Audio feedback buffer 2. */ #define S626_P_TSL1 0x0180 /* Audio time slot list 1. */ @@ -243,13 +293,19 @@ #define S626_LP_RDMISC2 0x0082 /* Read Misc2. */ /* Bit masks for MISC1 register that are the same for reads and writes. */ -#define S626_MISC1_WENABLE 0x8000 /* enab writes to MISC2 (except Clear - * Watchdog bit). */ +#define S626_MISC1_WENABLE 0x8000 /* + * enab writes to MISC2 (except Clear + * Watchdog bit). + */ #define S626_MISC1_WDISABLE 0x0000 /* Disable writes to MISC2. */ -#define S626_MISC1_EDCAP 0x1000 /* Enable edge capture on DIO chans - * specified by S626_LP_WRCAPSELx. */ -#define S626_MISC1_NOEDCAP 0x0000 /* Disable edge capture on specified - * DIO chans. */ +#define S626_MISC1_EDCAP 0x1000 /* + * Enable edge capture on DIO chans + * specified by S626_LP_WRCAPSELx. + */ +#define S626_MISC1_NOEDCAP 0x0000 /* + * Disable edge capture on specified + * DIO chans. + */ /* Bit masks for MISC1 register reads. */ #define S626_RDMISC1_WDTIMEOUT 0x4000 /* Watchdog timer timed out. */ @@ -268,35 +324,49 @@ #define S626_A1_RUN 0x20000000 /* Run A1 based on TSL1. */ #define S626_A1_SWAP 0x00200000 /* Use big-endian for A1. */ #define S626_A2_SWAP 0x00100000 /* Use big-endian for A2. */ -#define S626_WS_MODES 0x00019999 /* WS0 = TSL1 trigger input, - * WS1-WS4 = CS* outputs. */ - -#if S626_PLATFORM == S626_INTEL /* Base ACON1 config: always run - * A1 based on TSL1. */ +#define S626_WS_MODES 0x00019999 /* + * WS0 = TSL1 trigger input, + * WS1-WS4 = CS* outputs. + */ + +#if S626_PLATFORM == S626_INTEL /* + * Base ACON1 config: always run + * A1 based on TSL1. + */ #define S626_ACON1_BASE (S626_WS_MODES | S626_A1_RUN) #elif S626_PLATFORM == S626_MOTOROLA #define S626_ACON1_BASE \ (S626_WS_MODES | S626_A1_RUN | S626_A1_SWAP | S626_A2_SWAP) #endif -#define S626_ACON1_ADCSTART S626_ACON1_BASE /* Start ADC: run A1 - * based on TSL1. */ +#define S626_ACON1_ADCSTART S626_ACON1_BASE /* + * Start ADC: run A1 + * based on TSL1. + */ #define S626_ACON1_DACSTART (S626_ACON1_BASE | S626_A2_RUN) /* Start transmit to DAC: run A2 based on TSL2. */ #define S626_ACON1_DACSTOP S626_ACON1_BASE /* Halt A2. */ /* Bit masks for ACON2 register. */ #define S626_A1_CLKSRC_BCLK1 0x00000000 /* A1 bit rate = BCLK1 (ADC). */ -#define S626_A2_CLKSRC_X1 0x00800000 /* A2 bit rate = ACLK/1 - * (DACs). */ -#define S626_A2_CLKSRC_X2 0x00C00000 /* A2 bit rate = ACLK/2 - * (DACs). */ -#define S626_A2_CLKSRC_X4 0x01400000 /* A2 bit rate = ACLK/4 - * (DACs). */ +#define S626_A2_CLKSRC_X1 0x00800000 /* + * A2 bit rate = ACLK/1 + * (DACs). + */ +#define S626_A2_CLKSRC_X2 0x00C00000 /* + * A2 bit rate = ACLK/2 + * (DACs). + */ +#define S626_A2_CLKSRC_X4 0x01400000 /* + * A2 bit rate = ACLK/4 + * (DACs). + */ #define S626_INVERT_BCLK2 0x00100000 /* Invert BCLK2 (DACs). */ #define S626_BCLK2_OE 0x00040000 /* Enable BCLK2 (DACs). */ -#define S626_ACON2_XORMASK 0x000C0000 /* XOR mask for ACON2 - * active-low bits. */ +#define S626_ACON2_XORMASK 0x000C0000 /* + * XOR mask for ACON2 + * active-low bits. + */ #define S626_ACON2_INIT (S626_ACON2_XORMASK ^ \ (S626_A1_CLKSRC_BCLK1 | S626_A2_CLKSRC_X2 | \ @@ -308,12 +378,18 @@ #define S626_WS3 0x10000000 #define S626_WS4 0x08000000 #define S626_RSD1 0x01000000 /* Shift A1 data in on SD1. */ -#define S626_SDW_A1 0x00800000 /* Store rcv'd char at next char - * slot of DWORD1 buffer. */ -#define S626_SIB_A1 0x00400000 /* Store rcv'd char at next - * char slot of FB1 buffer. */ -#define S626_SF_A1 0x00200000 /* Write unsigned long - * buffer to input FIFO. */ +#define S626_SDW_A1 0x00800000 /* + * Store rcv'd char at next char + * slot of DWORD1 buffer. + */ +#define S626_SIB_A1 0x00400000 /* + * Store rcv'd char at next + * char slot of FB1 buffer. + */ +#define S626_SF_A1 0x00200000 /* + * Write unsigned long + * buffer to input FIFO. + */ /* Select parallel-to-serial converter's data source: */ #define S626_XFIFO_0 0x00000000 /* Data fifo byte 0. */ @@ -324,31 +400,45 @@ #define S626_XFB1 0x00000050 /* FB_BUFFER byte 1. */ #define S626_XFB2 0x00000060 /* FB_BUFFER byte 2. */ #define S626_XFB3 0x00000070 /* FB_BUFFER byte 3. */ -#define S626_SIB_A2 0x00000200 /* Store next dword from A2's +#define S626_SIB_A2 0x00000200 /* + * Store next dword from A2's * input shifter to FB2 - * buffer. */ -#define S626_SF_A2 0x00000100 /* Store next dword from A2's + * buffer. + */ +#define S626_SF_A2 0x00000100 /* + * Store next dword from A2's * input shifter to its input - * fifo. */ -#define S626_LF_A2 0x00000080 /* Load next dword from A2's + * fifo. + */ +#define S626_LF_A2 0x00000080 /* + * Load next dword from A2's * output fifo into its - * output dword buffer. */ + * output dword buffer. + */ #define S626_XSD2 0x00000008 /* Shift data out on SD2. */ #define S626_RSD3 0x00001800 /* Shift data in on SD3. */ #define S626_RSD2 0x00001000 /* Shift data in on SD2. */ -#define S626_LOW_A2 0x00000002 /* Drive last SD low for 7 clks, - * then tri-state. */ +#define S626_LOW_A2 0x00000002 /* + * Drive last SD low for 7 clks, + * then tri-state. + */ #define S626_EOS 0x00000001 /* End of superframe. */ /* I2C configuration constants. */ -#define S626_I2C_CLKSEL 0x0400 /* I2C bit rate = - * PCIclk/480 = 68.75 KHz. */ -#define S626_I2C_BITRATE 68.75 /* I2C bus data bit rate +#define S626_I2C_CLKSEL 0x0400 /* + * I2C bit rate = + * PCIclk/480 = 68.75 KHz. + */ +#define S626_I2C_BITRATE 68.75 /* + * I2C bus data bit rate * (determined by - * S626_I2C_CLKSEL) in KHz. */ -#define S626_I2C_WRTIME 15.0 /* Worst case time, in msec, + * S626_I2C_CLKSEL) in KHz. + */ +#define S626_I2C_WRTIME 15.0 /* + * Worst case time, in msec, * for EEPROM internal write - * op. */ + * op. + */ /* I2C manifest constants. */ @@ -368,8 +458,10 @@ #define S626_I2C_B0(ATTR, VAL) (((ATTR) << 2) | ((VAL) << 8)) /* DEBI command constants. */ -#define S626_DEBI_CMD_SIZE16 (2 << 17) /* Transfer size is always - * 2 bytes. */ +#define S626_DEBI_CMD_SIZE16 (2 << 17) /* + * Transfer size is always + * 2 bytes. + */ #define S626_DEBI_CMD_READ 0x00010000 /* Read operation. */ #define S626_DEBI_CMD_WRITE 0x00000000 /* Write operation. */ @@ -380,42 +472,58 @@ #define S626_DEBI_CMD_WRWORD (S626_DEBI_CMD_WRITE | S626_DEBI_CMD_SIZE16) /* DEBI configuration constants. */ -#define S626_DEBI_CFG_XIRQ_EN 0x80000000 /* Enable external interrupt - * on GPIO3. */ +#define S626_DEBI_CFG_XIRQ_EN 0x80000000 /* + * Enable external interrupt + * on GPIO3. + */ #define S626_DEBI_CFG_XRESUME 0x40000000 /* Resume block */ - /* Transfer when XIRQ - * deasserted. */ + /* + * Transfer when XIRQ + * deasserted. + */ #define S626_DEBI_CFG_TOQ 0x03C00000 /* Timeout (15 PCI cycles). */ #define S626_DEBI_CFG_FAST 0x10000000 /* Fast mode enable. */ /* 4-bit field that specifies DEBI timeout value in PCI clock cycles: */ -#define S626_DEBI_CFG_TOUT_BIT 22 /* Finish DEBI cycle after this many - * clocks. */ +#define S626_DEBI_CFG_TOUT_BIT 22 /* + * Finish DEBI cycle after this many + * clocks. + */ /* 2-bit field that specifies Endian byte lane steering: */ -#define S626_DEBI_CFG_SWAP_NONE 0x00000000 /* Straight - don't swap any - * bytes (Intel). */ +#define S626_DEBI_CFG_SWAP_NONE 0x00000000 /* + * Straight - don't swap any + * bytes (Intel). + */ #define S626_DEBI_CFG_SWAP_2 0x00100000 /* 2-byte swap (Motorola). */ #define S626_DEBI_CFG_SWAP_4 0x00200000 /* 4-byte swap. */ -#define S626_DEBI_CFG_SLAVE16 0x00080000 /* Slave is able to serve - * 16-bit cycles. */ -#define S626_DEBI_CFG_INC 0x00040000 /* Enable address increment - * for block transfers. */ +#define S626_DEBI_CFG_SLAVE16 0x00080000 /* + * Slave is able to serve + * 16-bit cycles. + */ +#define S626_DEBI_CFG_INC 0x00040000 /* + * Enable address increment + * for block transfers. + */ #define S626_DEBI_CFG_INTEL 0x00020000 /* Intel style local bus. */ #define S626_DEBI_CFG_TIMEROFF 0x00010000 /* Disable timer. */ #if S626_PLATFORM == S626_INTEL -#define S626_DEBI_TOUT 7 /* Wait 7 PCI clocks (212 ns) before - * polling RDY. */ +#define S626_DEBI_TOUT 7 /* + * Wait 7 PCI clocks (212 ns) before + * polling RDY. + */ /* Intel byte lane steering (pass through all byte lanes). */ #define S626_DEBI_SWAP S626_DEBI_CFG_SWAP_NONE #elif S626_PLATFORM == S626_MOTOROLA -#define S626_DEBI_TOUT 15 /* Wait 15 PCI clocks (454 ns) maximum - * before timing out. */ +#define S626_DEBI_TOUT 15 /* + * Wait 15 PCI clocks (454 ns) maximum + * before timing out. + */ /* Motorola byte lane steering. */ #define S626_DEBI_SWAP S626_DEBI_CFG_SWAP_2 @@ -429,10 +537,14 @@ /* LoadSrc values: */ #define S626_LOADSRC_INDX 0 /* Preload core in response to Index. */ -#define S626_LOADSRC_OVER 1 /* Preload core in response to - * Overflow. */ -#define S626_LOADSRCB_OVERA 2 /* Preload B core in response to - * A Overflow. */ +#define S626_LOADSRC_OVER 1 /* + * Preload core in response to + * Overflow. + */ +#define S626_LOADSRCB_OVERA 2 /* + * Preload B core in response to + * A Overflow. + */ #define S626_LOADSRC_NONE 3 /* Never preload core. */ /* IntSrc values: */ @@ -469,10 +581,14 @@ #define S626_CNTSRC_SYSCLK_DOWN 3 /* System clock down */ /* ClkPol values: */ -#define S626_CLKPOL_POS 0 /* Counter/Extender clock is - * active high. */ -#define S626_CLKPOL_NEG 1 /* Counter/Extender clock is - * active low. */ +#define S626_CLKPOL_POS 0 /* + * Counter/Extender clock is + * active high. + */ +#define S626_CLKPOL_NEG 1 /* + * Counter/Extender clock is + * active low. + */ #define S626_CNTDIR_UP 0 /* Timer counts up. */ #define S626_CNTDIR_DOWN 1 /* Timer counts down. */ @@ -488,8 +604,10 @@ /* Sanity-check limits for parameters. */ -#define S626_NUM_COUNTERS 6 /* Maximum valid counter - * logical channel number. */ +#define S626_NUM_COUNTERS 6 /* + * Maximum valid counter + * logical channel number. + */ #define S626_NUM_INTSOURCES 4 #define S626_NUM_LATCHSOURCES 4 #define S626_NUM_CLKMULTS 4 -- cgit v1.1 From 9c84ae6b69d29f5f2b2aeb12d701034a20584a7c Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Tue, 17 May 2016 15:43:57 +0530 Subject: Staging: comedi: Fix WARNING issue in dt2801.c This is a patch to the dt2801.c file that fixes up a Block comments issues found by the checkpatch.pl tool. i.e. Block comments use a trailing */ on a separate line Signed-off-by: Ravishankar Karkala Mallikarjunayya Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2801.c | 95 +++++++++++++++++---------------- 1 file changed, 50 insertions(+), 45 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index 6c7b4d2..c2ce1eb 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -4,30 +4,30 @@ * */ /* -Driver: dt2801 -Description: Data Translation DT2801 series and DT01-EZ -Author: ds -Status: works -Devices: [Data Translation] DT2801 (dt2801), DT2801-A, DT2801/5716A, - DT2805, DT2805/5716A, DT2808, DT2818, DT2809, DT01-EZ - -This driver can autoprobe the type of board. - -Configuration options: - [0] - I/O port base address - [1] - unused - [2] - A/D reference 0=differential, 1=single-ended - [3] - A/D range - 0 = [-10, 10] - 1 = [0,10] - [4] - D/A 0 range - 0 = [-10, 10] - 1 = [-5,5] - 2 = [-2.5,2.5] - 3 = [0,10] - 4 = [0,5] - [5] - D/A 1 range (same choices) -*/ + * Driver: dt2801 + * Description: Data Translation DT2801 series and DT01-EZ + * Author: ds + * Status: works + * Devices: [Data Translation] DT2801 (dt2801), DT2801-A, DT2801/5716A, + * DT2805, DT2805/5716A, DT2808, DT2818, DT2809, DT01-EZ + * + * This driver can autoprobe the type of board. + * + * Configuration options: + * [0] - I/O port base address + * [1] - unused + * [2] - A/D reference 0=differential, 1=single-ended + * [3] - A/D range + * 0 = [-10, 10] + * 1 = [0,10] + * [4] - D/A 0 range + * 0 = [-10, 10] + * 1 = [-5,5] + * 2 = [-2.5,2.5] + * 3 = [0,10] + * 4 = [0,5] + * [5] - D/A 1 range (same choices) + */ #include #include "../comedidev.h" @@ -65,9 +65,10 @@ Configuration options: #define DT_C_SET_AD 0xd #define DT_C_READ_AD 0xe -/* Command modifiers (only used with read/write), EXTTRIG can be - used with some other commands. -*/ +/* + * Command modifiers (only used with read/write), EXTTRIG can be + * used with some other commands. + */ #define DT_MOD_DMA BIT(4) #define DT_MOD_CONT BIT(5) #define DT_MOD_EXTCLK BIT(6) @@ -135,9 +136,10 @@ struct dt2801_board { int dabits; }; -/* Typeid's for the different boards of the DT2801-series - (taken from the test-software, that comes with the board) - */ +/* + * Typeid's for the different boards of the DT2801-series + * (taken from the test-software, that comes with the board) + */ static const struct dt2801_board boardtypes[] = { { .name = "dt2801", @@ -209,15 +211,18 @@ struct dt2801_private { const struct comedi_lrange *dac_range_types[2]; }; -/* These are the low-level routines: - writecommand: write a command to the board - writedata: write data byte - readdata: read data byte +/* + * These are the low-level routines: + * writecommand: write a command to the board + * writedata: write data byte + * readdata: read data byte */ -/* Only checks DataOutReady-flag, not the Ready-flag as it is done - in the examples of the manual. I don't see why this should be - necessary. */ +/* + * Only checks DataOutReady-flag, not the Ready-flag as it is done + * in the examples of the manual. I don't see why this should be + * necessary. + */ static int dt2801_readdata(struct comedi_device *dev, int *data) { int stat = 0; @@ -517,14 +522,14 @@ static int dt2801_dio_insn_config(struct comedi_device *dev, } /* - options: - [0] - i/o base - [1] - unused - [2] - a/d 0=differential, 1=single-ended - [3] - a/d range 0=[-10,10], 1=[0,10] - [4] - dac0 range 0=[-10,10], 1=[-5,5], 2=[-2.5,2.5] 3=[0,10], 4=[0,5] - [5] - dac1 range 0=[-10,10], 1=[-5,5], 2=[-2.5,2.5] 3=[0,10], 4=[0,5] -*/ + * options: + * [0] - i/o base + * [1] - unused + * [2] - a/d 0=differential, 1=single-ended + * [3] - a/d range 0=[-10,10], 1=[0,10] + * [4] - dac0 range 0=[-10,10], 1=[-5,5], 2=[-2.5,2.5] 3=[0,10], 4=[0,5] + * [5] - dac1 range 0=[-10,10], 1=[-5,5], 2=[-2.5,2.5] 3=[0,10], 4=[0,5] + */ static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct dt2801_board *board; -- cgit v1.1 From 1694830640d4573e8535dd6798b6f4cf00f680fd Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Wed, 18 May 2016 10:27:29 +0530 Subject: Staging: comedi: fix CHECK: Prefer using the BIT macro issues in pcmmio.c This patch Replace all occurences of (1< Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmmio.c | 40 ++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 10472e6..70ad497 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -84,25 +84,25 @@ #define PCMMIO_AI_LSB_REG 0x00 #define PCMMIO_AI_MSB_REG 0x01 #define PCMMIO_AI_CMD_REG 0x02 -#define PCMMIO_AI_CMD_SE (1 << 7) -#define PCMMIO_AI_CMD_ODD_CHAN (1 << 6) +#define PCMMIO_AI_CMD_SE BIT(7) +#define PCMMIO_AI_CMD_ODD_CHAN BIT(6) #define PCMMIO_AI_CMD_CHAN_SEL(x) (((x) & 0x3) << 4) #define PCMMIO_AI_CMD_RANGE(x) (((x) & 0x3) << 2) #define PCMMIO_RESOURCE_REG 0x02 #define PCMMIO_RESOURCE_IRQ(x) (((x) & 0xf) << 0) #define PCMMIO_AI_STATUS_REG 0x03 -#define PCMMIO_AI_STATUS_DATA_READY (1 << 7) -#define PCMMIO_AI_STATUS_DATA_DMA_PEND (1 << 6) -#define PCMMIO_AI_STATUS_CMD_DMA_PEND (1 << 5) -#define PCMMIO_AI_STATUS_IRQ_PEND (1 << 4) -#define PCMMIO_AI_STATUS_DATA_DRQ_ENA (1 << 2) -#define PCMMIO_AI_STATUS_REG_SEL (1 << 3) -#define PCMMIO_AI_STATUS_CMD_DRQ_ENA (1 << 1) -#define PCMMIO_AI_STATUS_IRQ_ENA (1 << 0) +#define PCMMIO_AI_STATUS_DATA_READY BIT(7) +#define PCMMIO_AI_STATUS_DATA_DMA_PEND BIT(6) +#define PCMMIO_AI_STATUS_CMD_DMA_PEND BIT(5) +#define PCMMIO_AI_STATUS_IRQ_PEND BIT(4) +#define PCMMIO_AI_STATUS_DATA_DRQ_ENA BIT(2) +#define PCMMIO_AI_STATUS_REG_SEL BIT(3) +#define PCMMIO_AI_STATUS_CMD_DRQ_ENA BIT(1) +#define PCMMIO_AI_STATUS_IRQ_ENA BIT(0) #define PCMMIO_AI_RES_ENA_REG 0x03 #define PCMMIO_AI_RES_ENA_CMD_REG_ACCESS (0 << 3) -#define PCMMIO_AI_RES_ENA_AI_RES_ACCESS (1 << 3) -#define PCMMIO_AI_RES_ENA_DIO_RES_ACCESS (1 << 4) +#define PCMMIO_AI_RES_ENA_AI_RES_ACCESS BIT(3) +#define PCMMIO_AI_RES_ENA_DIO_RES_ACCESS BIT(4) #define PCMMIO_AI_2ND_ADC_OFFSET 0x04 #define PCMMIO_AO_LSB_REG 0x08 @@ -125,14 +125,14 @@ #define PCMMIO_AO_CMD_CHAN_SEL(x) (((x) & 0x03) << 1) #define PCMMIO_AO_CMD_CHAN_SEL_ALL (0x0f << 0) #define PCMMIO_AO_STATUS_REG 0x0b -#define PCMMIO_AO_STATUS_DATA_READY (1 << 7) -#define PCMMIO_AO_STATUS_DATA_DMA_PEND (1 << 6) -#define PCMMIO_AO_STATUS_CMD_DMA_PEND (1 << 5) -#define PCMMIO_AO_STATUS_IRQ_PEND (1 << 4) -#define PCMMIO_AO_STATUS_DATA_DRQ_ENA (1 << 2) -#define PCMMIO_AO_STATUS_REG_SEL (1 << 3) -#define PCMMIO_AO_STATUS_CMD_DRQ_ENA (1 << 1) -#define PCMMIO_AO_STATUS_IRQ_ENA (1 << 0) +#define PCMMIO_AO_STATUS_DATA_READY BIT(7) +#define PCMMIO_AO_STATUS_DATA_DMA_PEND BIT(6) +#define PCMMIO_AO_STATUS_CMD_DMA_PEND BIT(5) +#define PCMMIO_AO_STATUS_IRQ_PEND BIT(4) +#define PCMMIO_AO_STATUS_DATA_DRQ_ENA BIT(2) +#define PCMMIO_AO_STATUS_REG_SEL BIT(3) +#define PCMMIO_AO_STATUS_CMD_DRQ_ENA BIT(1) +#define PCMMIO_AO_STATUS_IRQ_ENA BIT(0) #define PCMMIO_AO_RESOURCE_ENA_REG 0x0b #define PCMMIO_AO_2ND_DAC_OFFSET 0x04 -- cgit v1.1 From 269452dc6c5a415f0b24e62f894cb45d0c08a6fe Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:14 +0100 Subject: staging: comedi: daqboard2000: remove commented out code Remove some commented out code. Some of it uses constructs that don't exist in the driver, and probably come from the source code for the MS Windows driver. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index a536a15..a68506f 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -278,9 +278,7 @@ struct daqboard2000_private { static void writeAcqScanListEntry(struct comedi_device *dev, u16 entry) { - /* udelay(4); */ writew(entry & 0x00ff, dev->mmio + acqScanListFIFO); - /* udelay(4); */ writew((entry >> 8) & 0x00ff, dev->mmio + acqScanListFIFO); } @@ -315,13 +313,9 @@ static void setup_sampling(struct comedi_device *dev, int chan, int gain) word3 = 0; break; } -/* - dev->eeprom.correctionDACSE[i][j][k].offset = 0x800; - dev->eeprom.correctionDACSE[i][j][k].gain = 0xc00; -*/ /* These should be read from EEPROM */ - word2 |= 0x0800; - word3 |= 0xc000; + word2 |= 0x0800; /* offset */ + word3 |= 0xc000; /* gain */ writeAcqScanListEntry(dev, word0); writeAcqScanListEntry(dev, word1); writeAcqScanListEntry(dev, word2); -- cgit v1.1 From 77a574ec7b10afc1b3a9145f5aa6143bb9b9ca3a Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:15 +0100 Subject: staging: comedi: daqboard2000: use usual block comment style Reformat one of the block comments to conform to the usual style (it's the only one that doesn't). Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index a68506f..7b550ce 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -359,10 +359,12 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, gain = CR_RANGE(insn->chanspec); chan = CR_CHAN(insn->chanspec); - /* This doesn't look efficient. I decided to take the conservative + /* + * This doesn't look efficient. I decided to take the conservative * approach when I did the insn conversion. Perhaps it would be * better to have broken it completely, then someone would have been - * forced to fix it. --ds */ + * forced to fix it. --ds + */ for (i = 0; i < insn->n; i++) { setup_sampling(dev, chan, gain); /* Enable reading from the scanlist FIFO */ -- cgit v1.1 From 0f2ee9bea701d1712aa505eee8ddf5e98870c3f6 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:16 +0100 Subject: staging: comedi: daqboard2000: CHECK: spaces preferred around that '*' Fix checkpatch issues of the form "CHECK: spaces preferred around that '*' (ctx:VxV)". Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 7b550ce..a45f318 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -169,17 +169,17 @@ static const struct comedi_lrange range_daqboard2000_ai = { #define dioP3hsioData 0x32 /* s16 */ #define dioP3Control 0x34 /* u16 */ #define calEepromControl 0x36 /* u16 */ -#define dacSetting(x) (0x38 + (x)*2) /* s16 */ +#define dacSetting(x) (0x38 + (x) * 2) /* s16 */ #define dioP2ExpansionIO8Bit 0x40 /* s16 */ #define ctrTmrControl 0x80 /* u16 */ -#define ctrInput(x) (0x88 + (x)*2) /* s16 */ -#define timerDivisor(x) (0xa0 + (x)*2) /* u16 */ +#define ctrInput(x) (0x88 + (x) * 2) /* s16 */ +#define timerDivisor(x) (0xa0 + (x) * 2) /* u16 */ #define dmaControl 0xb0 /* u16 */ #define trigControl 0xb2 /* u16 */ #define calEeprom 0xb8 /* u16 */ #define acqDigitalMark 0xba /* u16 */ #define trigDacs 0xbc /* u16 */ -#define dioP2ExpansionIO16Bit(x) (0xc0 + (x)*2) /* s16 */ +#define dioP2ExpansionIO16Bit(x) (0xc0 + (x) * 2) /* s16 */ /* Scan Sequencer programming */ #define DAQBOARD2000_SeqStartScanList 0x0011 -- cgit v1.1 From 4044ceb454c88b1a3d2c2baad5bcf0e425bdd651 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:17 +0100 Subject: staging: comedi: daqboard2000: add blank line after struct declaration Fix checkpatch issue: "CHECK: Please use a blank line after function/struct/union/enum declarations". Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index a45f318..677d586 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -264,6 +264,7 @@ struct daq200_boardtype { const char *name; int id; }; + static const struct daq200_boardtype boardtypes[] = { {"ids2", DAQBOARD2000_SUBSYSTEM_IDS2}, {"ids4", DAQBOARD2000_SUBSYSTEM_IDS4}, -- cgit v1.1 From ff2ca4f0e89245680ef5f835b685fde3720ee83e Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:18 +0100 Subject: staging: comedi: daqboard2000: rename serial EEPROM register macros Rename the macros defining values for the Serial EEPROM Control Register to avoid CamelCase. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 677d586..c99773d 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -116,12 +116,12 @@ #define DAQBOARD2000_SUBSYSTEM_IDS4 0x0004 /* Daqboard/2000 - 4 Dacs */ /* Initialization bits for the Serial EEPROM Control Register */ -#define DAQBOARD2000_SECRProgPinHi 0x8001767e -#define DAQBOARD2000_SECRProgPinLo 0x8000767e -#define DAQBOARD2000_SECRLocalBusHi 0xc000767e -#define DAQBOARD2000_SECRLocalBusLo 0x8000767e -#define DAQBOARD2000_SECRReloadHi 0xa000767e -#define DAQBOARD2000_SECRReloadLo 0x8000767e +#define DB2K_SECR_PROG_PIN_HI 0x8001767e +#define DB2K_SECR_PROG_PIN_LO 0x8000767e +#define DB2K_SECR_LOCAL_BUS_HI 0xc000767e +#define DB2K_SECR_LOCAL_BUS_LO 0x8000767e +#define DB2K_SECR_RELOAD_HI 0xa000767e +#define DB2K_SECR_RELOAD_LO 0x8000767e /* SECR status bits */ #define DAQBOARD2000_EEPROM_PRESENT 0x10000000 @@ -438,9 +438,9 @@ static void daqboard2000_resetLocalBus(struct comedi_device *dev) { struct daqboard2000_private *devpriv = dev->private; - writel(DAQBOARD2000_SECRLocalBusHi, devpriv->plx + 0x6c); + writel(DB2K_SECR_LOCAL_BUS_HI, devpriv->plx + 0x6c); mdelay(10); - writel(DAQBOARD2000_SECRLocalBusLo, devpriv->plx + 0x6c); + writel(DB2K_SECR_LOCAL_BUS_LO, devpriv->plx + 0x6c); mdelay(10); } @@ -448,11 +448,11 @@ static void daqboard2000_reloadPLX(struct comedi_device *dev) { struct daqboard2000_private *devpriv = dev->private; - writel(DAQBOARD2000_SECRReloadLo, devpriv->plx + 0x6c); + writel(DB2K_SECR_RELOAD_LO, devpriv->plx + 0x6c); mdelay(10); - writel(DAQBOARD2000_SECRReloadHi, devpriv->plx + 0x6c); + writel(DB2K_SECR_RELOAD_HI, devpriv->plx + 0x6c); mdelay(10); - writel(DAQBOARD2000_SECRReloadLo, devpriv->plx + 0x6c); + writel(DB2K_SECR_RELOAD_LO, devpriv->plx + 0x6c); mdelay(10); } @@ -460,9 +460,9 @@ static void daqboard2000_pulseProgPin(struct comedi_device *dev) { struct daqboard2000_private *devpriv = dev->private; - writel(DAQBOARD2000_SECRProgPinHi, devpriv->plx + 0x6c); + writel(DB2K_SECR_PROG_PIN_HI, devpriv->plx + 0x6c); mdelay(10); - writel(DAQBOARD2000_SECRProgPinLo, devpriv->plx + 0x6c); + writel(DB2K_SECR_PROG_PIN_LO, devpriv->plx + 0x6c); mdelay(10); /* Not in the original code, but I like symmetry... */ } -- cgit v1.1 From 1e33538596ed153d0be3e0f9fffd224a0ac765a6 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:19 +0100 Subject: staging: comedi: daqboard2000: rename register offset macros Rename the macros defining register offsets to avoid CamelCase, and to use namespace associated with the driver. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 112 ++++++++++++++------------ 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index c99773d..32053ee 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -151,35 +151,35 @@ static const struct comedi_lrange range_daqboard2000_ai = { /* * Register Memory Map */ -#define acqControl 0x00 /* u16 */ -#define acqScanListFIFO 0x02 /* u16 */ -#define acqPacerClockDivLow 0x04 /* u32 */ -#define acqScanCounter 0x08 /* u16 */ -#define acqPacerClockDivHigh 0x0a /* u16 */ -#define acqTriggerCount 0x0c /* u16 */ -#define acqResultsFIFO 0x10 /* u16 */ -#define acqResultsShadow 0x14 /* u16 */ -#define acqAdcResult 0x18 /* u16 */ -#define dacScanCounter 0x1c /* u16 */ -#define dacControl 0x20 /* u16 */ -#define dacFIFO 0x24 /* s16 */ -#define dacPacerClockDiv 0x2a /* u16 */ -#define refDacs 0x2c /* u16 */ -#define dioControl 0x30 /* u16 */ -#define dioP3hsioData 0x32 /* s16 */ -#define dioP3Control 0x34 /* u16 */ -#define calEepromControl 0x36 /* u16 */ -#define dacSetting(x) (0x38 + (x) * 2) /* s16 */ -#define dioP2ExpansionIO8Bit 0x40 /* s16 */ -#define ctrTmrControl 0x80 /* u16 */ -#define ctrInput(x) (0x88 + (x) * 2) /* s16 */ -#define timerDivisor(x) (0xa0 + (x) * 2) /* u16 */ -#define dmaControl 0xb0 /* u16 */ -#define trigControl 0xb2 /* u16 */ -#define calEeprom 0xb8 /* u16 */ -#define acqDigitalMark 0xba /* u16 */ -#define trigDacs 0xbc /* u16 */ -#define dioP2ExpansionIO16Bit(x) (0xc0 + (x) * 2) /* s16 */ +#define DB2K_REG_ACQ_CONTROL 0x00 /* u16 */ +#define DB2K_REG_ACQ_SCAN_LIST_FIFO 0x02 /* u16 */ +#define DB2K_REG_ACQ_PACER_CLOCK_DIV_LOW 0x04 /* u32 */ +#define DB2K_REG_ACQ_SCAN_COUNTER 0x08 /* u16 */ +#define DB2K_REG_ACQ_PACER_CLOCK_DIV_HIGH 0x0a /* u16 */ +#define DB2K_REG_ACQ_TRIGGER_COUNT 0x0c /* u16 */ +#define DB2K_REG_ACQ_RESULTS_FIFO 0x10 /* u16 */ +#define DB2K_REG_ACQ_RESULTS_SHADOW 0x14 /* u16 */ +#define DB2K_REG_ACQ_ADC_RESULT 0x18 /* u16 */ +#define DB2K_REG_DAC_SCAN_COUNTER 0x1c /* u16 */ +#define DB2K_REG_DAC_CONTROL 0x20 /* u16 */ +#define DB2K_REG_DAC_FIFO 0x24 /* s16 */ +#define DB2K_REG_DAC_PACER_CLOCK_DIV 0x2a /* u16 */ +#define DB2K_REG_REF_DACS 0x2c /* u16 */ +#define DB2K_REG_DIO_CONTROL 0x30 /* u16 */ +#define DB2K_REG_P3_HSIO_DATA 0x32 /* s16 */ +#define DB2K_REG_P3_CONTROL 0x34 /* u16 */ +#define DB2K_REG_CAL_EEPROM_CONTROL 0x36 /* u16 */ +#define DB2K_REG_DAC_SETTING(x) (0x38 + (x) * 2) /* s16 */ +#define DB2K_REG_DIO_P2_EXP_IO_8_BIT 0x40 /* s16 */ +#define DB2K_REG_COUNTER_TIMER_CONTROL 0x80 /* u16 */ +#define DB2K_REG_COUNTER_INPUT(x) (0x88 + (x) * 2) /* s16 */ +#define DB2K_REG_TIMER_DIV(x) (0xa0 + (x) * 2) /* u16 */ +#define DB2K_REG_DMA_CONTROL 0xb0 /* u16 */ +#define DB2K_REG_TRIG_CONTROL 0xb2 /* u16 */ +#define DB2K_REG_CAL_EEPROM 0xb8 /* u16 */ +#define DB2K_REG_ACQ_DIGITAL_MARK 0xba /* u16 */ +#define DB2K_REG_TRIG_DACS 0xbc /* u16 */ +#define DB2K_REG_DIO_P2_EXP_IO_16_BIT(x) (0xc0 + (x) * 2) /* s16 */ /* Scan Sequencer programming */ #define DAQBOARD2000_SeqStartScanList 0x0011 @@ -279,8 +279,9 @@ struct daqboard2000_private { static void writeAcqScanListEntry(struct comedi_device *dev, u16 entry) { - writew(entry & 0x00ff, dev->mmio + acqScanListFIFO); - writew((entry >> 8) & 0x00ff, dev->mmio + acqScanListFIFO); + writew(entry & 0x00ff, dev->mmio + DB2K_REG_ACQ_SCAN_LIST_FIFO); + writew((entry >> 8) & 0x00ff, + dev->mmio + DB2K_REG_ACQ_SCAN_LIST_FIFO); } static void setup_sampling(struct comedi_device *dev, int chan, int gain) @@ -330,7 +331,7 @@ static int daqboard2000_ai_status(struct comedi_device *dev, { unsigned int status; - status = readw(dev->mmio + acqControl); + status = readw(dev->mmio + DB2K_REG_ACQ_CONTROL); if (status & context) return 0; return -EBUSY; @@ -347,15 +348,16 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, writew(DAQBOARD2000_AcqResetScanListFifo | DAQBOARD2000_AcqResetResultsFifo | - DAQBOARD2000_AcqResetConfigPipe, dev->mmio + acqControl); + DAQBOARD2000_AcqResetConfigPipe, + dev->mmio + DB2K_REG_ACQ_CONTROL); /* * If pacer clock is not set to some high value (> 10 us), we * risk multiple samples to be put into the result FIFO. */ /* 1 second, should be long enough */ - writel(1000000, dev->mmio + acqPacerClockDivLow); - writew(0, dev->mmio + acqPacerClockDivHigh); + writel(1000000, dev->mmio + DB2K_REG_ACQ_PACER_CLOCK_DIV_LOW); + writew(0, dev->mmio + DB2K_REG_ACQ_PACER_CLOCK_DIV_HIGH); gain = CR_RANGE(insn->chanspec); chan = CR_CHAN(insn->chanspec); @@ -369,14 +371,16 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { setup_sampling(dev, chan, gain); /* Enable reading from the scanlist FIFO */ - writew(DAQBOARD2000_SeqStartScanList, dev->mmio + acqControl); + writew(DAQBOARD2000_SeqStartScanList, + dev->mmio + DB2K_REG_ACQ_CONTROL); ret = comedi_timeout(dev, s, insn, daqboard2000_ai_status, DAQBOARD2000_AcqConfigPipeFull); if (ret) return ret; - writew(DAQBOARD2000_AdcPacerEnable, dev->mmio + acqControl); + writew(DAQBOARD2000_AdcPacerEnable, + dev->mmio + DB2K_REG_ACQ_CONTROL); ret = comedi_timeout(dev, s, insn, daqboard2000_ai_status, DAQBOARD2000_AcqLogicScanning); @@ -388,9 +392,11 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, if (ret) return ret; - data[i] = readw(dev->mmio + acqResultsFIFO); - writew(DAQBOARD2000_AdcPacerDisable, dev->mmio + acqControl); - writew(DAQBOARD2000_SeqStopScanList, dev->mmio + acqControl); + data[i] = readw(dev->mmio + DB2K_REG_ACQ_RESULTS_FIFO); + writew(DAQBOARD2000_AdcPacerDisable, + dev->mmio + DB2K_REG_ACQ_CONTROL); + writew(DAQBOARD2000_SeqStopScanList, + dev->mmio + DB2K_REG_ACQ_CONTROL); } return i; @@ -404,7 +410,7 @@ static int daqboard2000_ao_eoc(struct comedi_device *dev, unsigned int chan = CR_CHAN(insn->chanspec); unsigned int status; - status = readw(dev->mmio + dacControl); + status = readw(dev->mmio + DB2K_REG_DAC_CONTROL); if ((status & ((chan + 1) * 0x0010)) == 0) return 0; return -EBUSY; @@ -422,7 +428,7 @@ static int daqboard2000_ao_insn_write(struct comedi_device *dev, unsigned int val = data[i]; int ret; - writew(val, dev->mmio + dacSetting(chan)); + writew(val, dev->mmio + DB2K_REG_DAC_SETTING(chan)); ret = comedi_timeout(dev, s, insn, daqboard2000_ao_eoc, 0); if (ret) @@ -550,18 +556,20 @@ static void daqboard2000_adcDisarm(struct comedi_device *dev) /* Disable hardware triggers */ udelay(2); writew(DAQBOARD2000_TrigAnalog | DAQBOARD2000_TrigDisable, - dev->mmio + trigControl); + dev->mmio + DB2K_REG_TRIG_CONTROL); udelay(2); writew(DAQBOARD2000_TrigTTL | DAQBOARD2000_TrigDisable, - dev->mmio + trigControl); + dev->mmio + DB2K_REG_TRIG_CONTROL); /* Stop the scan list FIFO from loading the configuration pipe */ udelay(2); - writew(DAQBOARD2000_SeqStopScanList, dev->mmio + acqControl); + writew(DAQBOARD2000_SeqStopScanList, + dev->mmio + DB2K_REG_ACQ_CONTROL); /* Stop the pacer clock */ udelay(2); - writew(DAQBOARD2000_AdcPacerDisable, dev->mmio + acqControl); + writew(DAQBOARD2000_AdcPacerDisable, + dev->mmio + DB2K_REG_ACQ_CONTROL); /* Stop the input dma (abort channel 1) */ daqboard2000_adcStopDmaTransfer(dev); @@ -573,18 +581,20 @@ static void daqboard2000_activateReferenceDacs(struct comedi_device *dev) int timeout; /* Set the + reference dac value in the FPGA */ - writew(0x80 | DAQBOARD2000_PosRefDacSelect, dev->mmio + refDacs); + writew(0x80 | DAQBOARD2000_PosRefDacSelect, + dev->mmio + DB2K_REG_REF_DACS); for (timeout = 0; timeout < 20; timeout++) { - val = readw(dev->mmio + dacControl); + val = readw(dev->mmio + DB2K_REG_DAC_CONTROL); if ((val & DAQBOARD2000_RefBusy) == 0) break; udelay(2); } /* Set the - reference dac value in the FPGA */ - writew(0x80 | DAQBOARD2000_NegRefDacSelect, dev->mmio + refDacs); + writew(0x80 | DAQBOARD2000_NegRefDacSelect, + dev->mmio + DB2K_REG_REF_DACS); for (timeout = 0; timeout < 20; timeout++) { - val = readw(dev->mmio + dacControl); + val = readw(dev->mmio + DB2K_REG_DAC_CONTROL); if ((val & DAQBOARD2000_RefBusy) == 0) break; udelay(2); @@ -711,7 +721,7 @@ static int daqboard2000_auto_attach(struct comedi_device *dev, s = &dev->subdevices[2]; return subdev_8255_init(dev, s, daqboard2000_8255_cb, - dioP2ExpansionIO8Bit); + DB2K_REG_DIO_P2_EXP_IO_8_BIT); } static void daqboard2000_detach(struct comedi_device *dev) -- cgit v1.1 From f1ee5d86d66a91dfd8d8280e6adc5589034fd19e Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:20 +0100 Subject: staging: comedi: daqboard2000: rename acquisition control register macros Rename the macros defining values for the acquisition control register to avoid CamelCase, and to make it clearer which register they are associated with. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 50 ++++++++++++--------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 32053ee..483b131 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -182,13 +182,13 @@ static const struct comedi_lrange range_daqboard2000_ai = { #define DB2K_REG_DIO_P2_EXP_IO_16_BIT(x) (0xc0 + (x) * 2) /* s16 */ /* Scan Sequencer programming */ -#define DAQBOARD2000_SeqStartScanList 0x0011 -#define DAQBOARD2000_SeqStopScanList 0x0010 +#define DB2K_ACQ_CONTROL_SEQ_START_SCAN_LIST 0x0011 +#define DB2K_ACQ_CONTROL_SEQ_STOP_SCAN_LIST 0x0010 /* Prepare for acquisition */ -#define DAQBOARD2000_AcqResetScanListFifo 0x0004 -#define DAQBOARD2000_AcqResetResultsFifo 0x0002 -#define DAQBOARD2000_AcqResetConfigPipe 0x0001 +#define DB2K_ACQ_CONTROL_RESET_SCAN_LIST_FIFO 0x0004 +#define DB2K_ACQ_CONTROL_RESET_RESULTS_FIFO 0x0002 +#define DB2K_ACQ_CONTROL_RESET_CONFIG_PIPE 0x0001 /* Acqusition status bits */ #define DAQBOARD2000_AcqResultsFIFOMore1Sample 0x0001 @@ -203,20 +203,16 @@ static const struct comedi_lrange range_daqboard2000_ai = { #define DAQBOARD2000_DacPacerOverrun 0x0200 #define DAQBOARD2000_AcqHardwareError 0x01c0 -/* Scan Sequencer programming */ -#define DAQBOARD2000_SeqStartScanList 0x0011 -#define DAQBOARD2000_SeqStopScanList 0x0010 - /* Pacer Clock Control */ -#define DAQBOARD2000_AdcPacerInternal 0x0030 -#define DAQBOARD2000_AdcPacerExternal 0x0032 -#define DAQBOARD2000_AdcPacerEnable 0x0031 -#define DAQBOARD2000_AdcPacerEnableDacPacer 0x0034 -#define DAQBOARD2000_AdcPacerDisable 0x0030 -#define DAQBOARD2000_AdcPacerNormalMode 0x0060 -#define DAQBOARD2000_AdcPacerCompatibilityMode 0x0061 -#define DAQBOARD2000_AdcPacerInternalOutEnable 0x0008 -#define DAQBOARD2000_AdcPacerExternalRising 0x0100 +#define DB2K_ACQ_CONTROL_ADC_PACER_INTERNAL 0x0030 +#define DB2K_ACQ_CONTROL_ADC_PACER_EXTERNAL 0x0032 +#define DB2K_ACQ_CONTROL_ADC_PACER_ENABLE 0x0031 +#define DB2K_ACQ_CONTROL_ADC_PACER_ENABLE_DAC_PACER 0x0034 +#define DB2K_ACQ_CONTROL_ADC_PACER_DISABLE 0x0030 +#define DB2K_ACQ_CONTROL_ADC_PACER_NORMAL_MODE 0x0060 +#define DB2K_ACQ_CONTROL_ADC_PACER_COMPATIBILITY_MODE 0x0061 +#define DB2K_ACQ_CONTROL_ADC_PACER_INTERNAL_OUT_ENABLE 0x0008 +#define DB2K_ACQ_CONTROL_ADC_PACER_EXTERNAL_RISING 0x0100 /* DAC status */ #define DAQBOARD2000_DacFull 0x0001 @@ -346,9 +342,9 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, int ret; int i; - writew(DAQBOARD2000_AcqResetScanListFifo | - DAQBOARD2000_AcqResetResultsFifo | - DAQBOARD2000_AcqResetConfigPipe, + writew(DB2K_ACQ_CONTROL_RESET_SCAN_LIST_FIFO | + DB2K_ACQ_CONTROL_RESET_RESULTS_FIFO | + DB2K_ACQ_CONTROL_RESET_CONFIG_PIPE, dev->mmio + DB2K_REG_ACQ_CONTROL); /* @@ -371,7 +367,7 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { setup_sampling(dev, chan, gain); /* Enable reading from the scanlist FIFO */ - writew(DAQBOARD2000_SeqStartScanList, + writew(DB2K_ACQ_CONTROL_SEQ_START_SCAN_LIST, dev->mmio + DB2K_REG_ACQ_CONTROL); ret = comedi_timeout(dev, s, insn, daqboard2000_ai_status, @@ -379,7 +375,7 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, if (ret) return ret; - writew(DAQBOARD2000_AdcPacerEnable, + writew(DB2K_ACQ_CONTROL_ADC_PACER_ENABLE, dev->mmio + DB2K_REG_ACQ_CONTROL); ret = comedi_timeout(dev, s, insn, daqboard2000_ai_status, @@ -393,9 +389,9 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, return ret; data[i] = readw(dev->mmio + DB2K_REG_ACQ_RESULTS_FIFO); - writew(DAQBOARD2000_AdcPacerDisable, + writew(DB2K_ACQ_CONTROL_ADC_PACER_DISABLE, dev->mmio + DB2K_REG_ACQ_CONTROL); - writew(DAQBOARD2000_SeqStopScanList, + writew(DB2K_ACQ_CONTROL_SEQ_STOP_SCAN_LIST, dev->mmio + DB2K_REG_ACQ_CONTROL); } @@ -563,12 +559,12 @@ static void daqboard2000_adcDisarm(struct comedi_device *dev) /* Stop the scan list FIFO from loading the configuration pipe */ udelay(2); - writew(DAQBOARD2000_SeqStopScanList, + writew(DB2K_ACQ_CONTROL_SEQ_STOP_SCAN_LIST, dev->mmio + DB2K_REG_ACQ_CONTROL); /* Stop the pacer clock */ udelay(2); - writew(DAQBOARD2000_AdcPacerDisable, + writew(DB2K_ACQ_CONTROL_ADC_PACER_DISABLE, dev->mmio + DB2K_REG_ACQ_CONTROL); /* Stop the input dma (abort channel 1) */ -- cgit v1.1 From 34d49fc07c19e2172d57ac69d516db783aeed902 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:21 +0100 Subject: staging: comedi: daqboard2000: rename acq status register macros Rename the macros associated with the acquisition status register to avoid CamelCase and to make it clear which register they are associated with. Add a macro to define the offset of the read-only acquisition status register. It's the same offset as the acquisition control register, which is write-only. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 39 ++++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 483b131..fd35ddf 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -151,7 +151,8 @@ static const struct comedi_lrange range_daqboard2000_ai = { /* * Register Memory Map */ -#define DB2K_REG_ACQ_CONTROL 0x00 /* u16 */ +#define DB2K_REG_ACQ_CONTROL 0x00 /* u16 (w) */ +#define DB2K_REG_ACQ_STATUS 0x00 /* u16 (r) */ #define DB2K_REG_ACQ_SCAN_LIST_FIFO 0x02 /* u16 */ #define DB2K_REG_ACQ_PACER_CLOCK_DIV_LOW 0x04 /* u32 */ #define DB2K_REG_ACQ_SCAN_COUNTER 0x08 /* u16 */ @@ -190,19 +191,6 @@ static const struct comedi_lrange range_daqboard2000_ai = { #define DB2K_ACQ_CONTROL_RESET_RESULTS_FIFO 0x0002 #define DB2K_ACQ_CONTROL_RESET_CONFIG_PIPE 0x0001 -/* Acqusition status bits */ -#define DAQBOARD2000_AcqResultsFIFOMore1Sample 0x0001 -#define DAQBOARD2000_AcqResultsFIFOHasValidData 0x0002 -#define DAQBOARD2000_AcqResultsFIFOOverrun 0x0004 -#define DAQBOARD2000_AcqLogicScanning 0x0008 -#define DAQBOARD2000_AcqConfigPipeFull 0x0010 -#define DAQBOARD2000_AcqScanListFIFOEmpty 0x0020 -#define DAQBOARD2000_AcqAdcNotReady 0x0040 -#define DAQBOARD2000_ArbitrationFailure 0x0080 -#define DAQBOARD2000_AcqPacerOverrun 0x0100 -#define DAQBOARD2000_DacPacerOverrun 0x0200 -#define DAQBOARD2000_AcqHardwareError 0x01c0 - /* Pacer Clock Control */ #define DB2K_ACQ_CONTROL_ADC_PACER_INTERNAL 0x0030 #define DB2K_ACQ_CONTROL_ADC_PACER_EXTERNAL 0x0032 @@ -214,6 +202,18 @@ static const struct comedi_lrange range_daqboard2000_ai = { #define DB2K_ACQ_CONTROL_ADC_PACER_INTERNAL_OUT_ENABLE 0x0008 #define DB2K_ACQ_CONTROL_ADC_PACER_EXTERNAL_RISING 0x0100 +/* Acquisition status bits */ +#define DB2K_ACQ_STATUS_RESULTS_FIFO_MORE_1_SAMPLE 0x0001 +#define DB2K_ACQ_STATUS_RESULTS_FIFO_HAS_DATA 0x0002 +#define DB2K_ACQ_STATUS_RESULTS_FIFO_OVERRUN 0x0004 +#define DB2K_ACQ_STATUS_LOGIC_SCANNING 0x0008 +#define DB2K_ACQ_STATUS_CONFIG_PIPE_FULL 0x0010 +#define DB2K_ACQ_STATUS_SCAN_LIST_FIFO_EMPTY 0x0020 +#define DB2K_ACQ_STATUS_ADC_NOT_READY 0x0040 +#define DB2K_ACQ_STATUS_ARBITRATION_FAILURE 0x0080 +#define DB2K_ACQ_STATUS_ADC_PACER_OVERRUN 0x0100 +#define DB2K_ACQ_STATUS_DAC_PACER_OVERRUN 0x0200 + /* DAC status */ #define DAQBOARD2000_DacFull 0x0001 #define DAQBOARD2000_RefBusy 0x0002 @@ -327,7 +327,7 @@ static int daqboard2000_ai_status(struct comedi_device *dev, { unsigned int status; - status = readw(dev->mmio + DB2K_REG_ACQ_CONTROL); + status = readw(dev->mmio + DB2K_REG_ACQ_STATUS); if (status & context) return 0; return -EBUSY; @@ -371,7 +371,7 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, dev->mmio + DB2K_REG_ACQ_CONTROL); ret = comedi_timeout(dev, s, insn, daqboard2000_ai_status, - DAQBOARD2000_AcqConfigPipeFull); + DB2K_ACQ_STATUS_CONFIG_PIPE_FULL); if (ret) return ret; @@ -379,12 +379,13 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, dev->mmio + DB2K_REG_ACQ_CONTROL); ret = comedi_timeout(dev, s, insn, daqboard2000_ai_status, - DAQBOARD2000_AcqLogicScanning); + DB2K_ACQ_STATUS_LOGIC_SCANNING); if (ret) return ret; - ret = comedi_timeout(dev, s, insn, daqboard2000_ai_status, - DAQBOARD2000_AcqResultsFIFOHasValidData); + ret = + comedi_timeout(dev, s, insn, daqboard2000_ai_status, + DB2K_ACQ_STATUS_RESULTS_FIFO_HAS_DATA); if (ret) return ret; -- cgit v1.1 From ab8a4dc8595c8d4559420fe10e56a6a58b2982ac Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:22 +0100 Subject: staging: comedi: daqboard2000: redo DAC control register macros Rename the macros used to define values for the DAC control register to avoid CamelCase and to make it clearer which register they are associated with. Refactor the macros used to define values to enable or disable DAC channels to use the channel number as a parameter. None of these macros are currently used by the driver. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index fd35ddf..7d5f647 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -225,20 +225,13 @@ static const struct comedi_lrange range_daqboard2000_ai = { #define DAQBOARD2000_Dac3Busy 0x0080 /* DAC control */ -#define DAQBOARD2000_Dac0Enable 0x0021 -#define DAQBOARD2000_Dac1Enable 0x0031 -#define DAQBOARD2000_Dac2Enable 0x0041 -#define DAQBOARD2000_Dac3Enable 0x0051 -#define DAQBOARD2000_DacEnableBit 0x0001 -#define DAQBOARD2000_Dac0Disable 0x0020 -#define DAQBOARD2000_Dac1Disable 0x0030 -#define DAQBOARD2000_Dac2Disable 0x0040 -#define DAQBOARD2000_Dac3Disable 0x0050 -#define DAQBOARD2000_DacResetFifo 0x0004 -#define DAQBOARD2000_DacPatternDisable 0x0060 -#define DAQBOARD2000_DacPatternEnable 0x0061 -#define DAQBOARD2000_DacSelectSignedData 0x0002 -#define DAQBOARD2000_DacSelectUnsignedData 0x0000 +#define DB2K_DAC_CONTROL_ENABLE_BIT 0x0001 +#define DB2K_DAC_CONTROL_DATA_IS_SIGNED 0x0002 +#define DB2K_DAC_CONTROL_RESET_FIFO 0x0004 +#define DB2K_DAC_CONTROL_DAC_DISABLE(x) (0x0020 + ((x) << 4)) +#define DB2K_DAC_CONTROL_DAC_ENABLE(x) (0x0021 + ((x) << 4)) +#define DB2K_DAC_CONTROL_PATTERN_DISABLE 0x0060 +#define DB2K_DAC_CONTROL_PATTERN_ENABLE 0x0061 /* Trigger Control */ #define DAQBOARD2000_TrigAnalog 0x0000 -- cgit v1.1 From 944f0d7f4b79433c07ab4f575330b9c747b90493 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:23 +0100 Subject: staging: comedi: daqboard2000: redo DAC status macros and fix busy Rename the macros defining values for the DAC status register to avoid CamelCase, and to make it clear which register they are associated with. Refactor the macros defining the regular DAC channel "busy" bits into a single macro that takes the DAC channel number as a parameter. Add a macro to define the offset of the read-only DAC status register. It is the same offset as the DAC control register, which is write-only. The code in `daqboard2000_ao_eoc()` that checks the status for completion of the DAC conversion looks wrong. The register has a "busy" bit for each channel, but the existing code only works for channels 0 and 1. The driver only supports two DAC channels at the moment, so the bug is currently harmless, but fix it so we can support four DAC channels on some board models. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 28 +++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 7d5f647..2fd664d 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -162,7 +162,8 @@ static const struct comedi_lrange range_daqboard2000_ai = { #define DB2K_REG_ACQ_RESULTS_SHADOW 0x14 /* u16 */ #define DB2K_REG_ACQ_ADC_RESULT 0x18 /* u16 */ #define DB2K_REG_DAC_SCAN_COUNTER 0x1c /* u16 */ -#define DB2K_REG_DAC_CONTROL 0x20 /* u16 */ +#define DB2K_REG_DAC_CONTROL 0x20 /* u16 (w) */ +#define DB2K_REG_DAC_STATUS 0x20 /* u16 (r) */ #define DB2K_REG_DAC_FIFO 0x24 /* s16 */ #define DB2K_REG_DAC_PACER_CLOCK_DIV 0x2a /* u16 */ #define DB2K_REG_REF_DACS 0x2c /* u16 */ @@ -215,14 +216,11 @@ static const struct comedi_lrange range_daqboard2000_ai = { #define DB2K_ACQ_STATUS_DAC_PACER_OVERRUN 0x0200 /* DAC status */ -#define DAQBOARD2000_DacFull 0x0001 -#define DAQBOARD2000_RefBusy 0x0002 -#define DAQBOARD2000_TrgBusy 0x0004 -#define DAQBOARD2000_CalBusy 0x0008 -#define DAQBOARD2000_Dac0Busy 0x0010 -#define DAQBOARD2000_Dac1Busy 0x0020 -#define DAQBOARD2000_Dac2Busy 0x0040 -#define DAQBOARD2000_Dac3Busy 0x0080 +#define DB2K_DAC_STATUS_DAC_FULL 0x0001 +#define DB2K_DAC_STATUS_REF_BUSY 0x0002 +#define DB2K_DAC_STATUS_TRIG_BUSY 0x0004 +#define DB2K_DAC_STATUS_CAL_BUSY 0x0008 +#define DB2K_DAC_STATUS_DAC_BUSY(x) (0x0010 << (x)) /* DAC control */ #define DB2K_DAC_CONTROL_ENABLE_BIT 0x0001 @@ -400,8 +398,8 @@ static int daqboard2000_ao_eoc(struct comedi_device *dev, unsigned int chan = CR_CHAN(insn->chanspec); unsigned int status; - status = readw(dev->mmio + DB2K_REG_DAC_CONTROL); - if ((status & ((chan + 1) * 0x0010)) == 0) + status = readw(dev->mmio + DB2K_REG_DAC_STATUS); + if ((status & DB2K_DAC_STATUS_DAC_BUSY(chan)) == 0) return 0; return -EBUSY; } @@ -574,8 +572,8 @@ static void daqboard2000_activateReferenceDacs(struct comedi_device *dev) writew(0x80 | DAQBOARD2000_PosRefDacSelect, dev->mmio + DB2K_REG_REF_DACS); for (timeout = 0; timeout < 20; timeout++) { - val = readw(dev->mmio + DB2K_REG_DAC_CONTROL); - if ((val & DAQBOARD2000_RefBusy) == 0) + val = readw(dev->mmio + DB2K_REG_DAC_STATUS); + if ((val & DB2K_DAC_STATUS_REF_BUSY) == 0) break; udelay(2); } @@ -584,8 +582,8 @@ static void daqboard2000_activateReferenceDacs(struct comedi_device *dev) writew(0x80 | DAQBOARD2000_NegRefDacSelect, dev->mmio + DB2K_REG_REF_DACS); for (timeout = 0; timeout < 20; timeout++) { - val = readw(dev->mmio + DB2K_REG_DAC_CONTROL); - if ((val & DAQBOARD2000_RefBusy) == 0) + val = readw(dev->mmio + DB2K_REG_DAC_STATUS); + if ((val & DB2K_DAC_STATUS_REF_BUSY) == 0) break; udelay(2); } -- cgit v1.1 From 77b9634cbdbf62c0aa12f783df7b2c48cf1e5ba3 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:24 +0100 Subject: staging: comedi: daqboard2000: rename trigger control register macros Rename the macros that define values for the trigger control register to avoid CamelCase, and to make it clearer which register they are associated with. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 2fd664d..6f991e7 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -232,16 +232,16 @@ static const struct comedi_lrange range_daqboard2000_ai = { #define DB2K_DAC_CONTROL_PATTERN_ENABLE 0x0061 /* Trigger Control */ -#define DAQBOARD2000_TrigAnalog 0x0000 -#define DAQBOARD2000_TrigTTL 0x0010 -#define DAQBOARD2000_TrigTransHiLo 0x0004 -#define DAQBOARD2000_TrigTransLoHi 0x0000 -#define DAQBOARD2000_TrigAbove 0x0000 -#define DAQBOARD2000_TrigBelow 0x0004 -#define DAQBOARD2000_TrigLevelSense 0x0002 -#define DAQBOARD2000_TrigEdgeSense 0x0000 -#define DAQBOARD2000_TrigEnable 0x0001 -#define DAQBOARD2000_TrigDisable 0x0000 +#define DB2K_TRIG_CONTROL_TYPE_ANALOG 0x0000 +#define DB2K_TRIG_CONTROL_TYPE_TTL 0x0010 +#define DB2K_TRIG_CONTROL_EDGE_HI_LO 0x0004 +#define DB2K_TRIG_CONTROL_EDGE_LO_HI 0x0000 +#define DB2K_TRIG_CONTROL_LEVEL_ABOVE 0x0000 +#define DB2K_TRIG_CONTROL_LEVEL_BELOW 0x0004 +#define DB2K_TRIG_CONTROL_SENSE_LEVEL 0x0002 +#define DB2K_TRIG_CONTROL_SENSE_EDGE 0x0000 +#define DB2K_TRIG_CONTROL_ENABLE 0x0001 +#define DB2K_TRIG_CONTROL_DISABLE 0x0000 /* Reference Dac Selection */ #define DAQBOARD2000_PosRefDacSelect 0x0100 @@ -543,10 +543,10 @@ static void daqboard2000_adcDisarm(struct comedi_device *dev) { /* Disable hardware triggers */ udelay(2); - writew(DAQBOARD2000_TrigAnalog | DAQBOARD2000_TrigDisable, + writew(DB2K_TRIG_CONTROL_TYPE_ANALOG | DB2K_TRIG_CONTROL_DISABLE, dev->mmio + DB2K_REG_TRIG_CONTROL); udelay(2); - writew(DAQBOARD2000_TrigTTL | DAQBOARD2000_TrigDisable, + writew(DB2K_TRIG_CONTROL_TYPE_TTL | DB2K_TRIG_CONTROL_DISABLE, dev->mmio + DB2K_REG_TRIG_CONTROL); /* Stop the scan list FIFO from loading the configuration pipe */ -- cgit v1.1 From 2c7aab274d648dffa99122af79b2edf09943f960 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:25 +0100 Subject: staging: comedi: daqboard2000: rename reference DACs register macros Rename the macros that define values for the reference DACs register to avoid CamelCase, and to make it clearer which register they are associated with. Add a macro `DB2K_REG_DACS_SET` for the value `0x0080` that triggers setting one of the references. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 6f991e7..2876710 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -244,8 +244,9 @@ static const struct comedi_lrange range_daqboard2000_ai = { #define DB2K_TRIG_CONTROL_DISABLE 0x0000 /* Reference Dac Selection */ -#define DAQBOARD2000_PosRefDacSelect 0x0100 -#define DAQBOARD2000_NegRefDacSelect 0x0000 +#define DB2K_REF_DACS_SET 0x0080 +#define DB2K_REF_DACS_SELECT_POS_REF 0x0100 +#define DB2K_REF_DACS_SELECT_NEG_REF 0x0000 struct daq200_boardtype { const char *name; @@ -569,7 +570,7 @@ static void daqboard2000_activateReferenceDacs(struct comedi_device *dev) int timeout; /* Set the + reference dac value in the FPGA */ - writew(0x80 | DAQBOARD2000_PosRefDacSelect, + writew(DB2K_REF_DACS_SET | DB2K_REF_DACS_SELECT_POS_REF, dev->mmio + DB2K_REG_REF_DACS); for (timeout = 0; timeout < 20; timeout++) { val = readw(dev->mmio + DB2K_REG_DAC_STATUS); @@ -579,7 +580,7 @@ static void daqboard2000_activateReferenceDacs(struct comedi_device *dev) } /* Set the - reference dac value in the FPGA */ - writew(0x80 | DAQBOARD2000_NegRefDacSelect, + writew(DB2K_REF_DACS_SET | DB2K_REF_DACS_SELECT_NEG_REF, dev->mmio + DB2K_REG_REF_DACS); for (timeout = 0; timeout < 20; timeout++) { val = readw(dev->mmio + DB2K_REG_DAC_STATUS); -- cgit v1.1 From 0ef613473f8902708f7ea75d63e5dadb7c4a988c Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:26 +0100 Subject: staging: comedi: daqboard2000: rename CamelCase functions Rename functions to avoid CamelCase warnings from checkpatch, and to use namespace associated with the driver. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 80 ++++++++++++++------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 2876710..6bc5bfe 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -265,14 +265,16 @@ struct daqboard2000_private { void __iomem *plx; }; -static void writeAcqScanListEntry(struct comedi_device *dev, u16 entry) +static void daqboard2000_write_acq_scan_list_entry(struct comedi_device *dev, + u16 entry) { writew(entry & 0x00ff, dev->mmio + DB2K_REG_ACQ_SCAN_LIST_FIFO); writew((entry >> 8) & 0x00ff, dev->mmio + DB2K_REG_ACQ_SCAN_LIST_FIFO); } -static void setup_sampling(struct comedi_device *dev, int chan, int gain) +static void daqboard2000_setup_sampling(struct comedi_device *dev, int chan, + int gain) { u16 word0, word1, word2, word3; @@ -306,10 +308,10 @@ static void setup_sampling(struct comedi_device *dev, int chan, int gain) /* These should be read from EEPROM */ word2 |= 0x0800; /* offset */ word3 |= 0xc000; /* gain */ - writeAcqScanListEntry(dev, word0); - writeAcqScanListEntry(dev, word1); - writeAcqScanListEntry(dev, word2); - writeAcqScanListEntry(dev, word3); + daqboard2000_write_acq_scan_list_entry(dev, word0); + daqboard2000_write_acq_scan_list_entry(dev, word1); + daqboard2000_write_acq_scan_list_entry(dev, word2); + daqboard2000_write_acq_scan_list_entry(dev, word3); } static int daqboard2000_ai_status(struct comedi_device *dev, @@ -357,7 +359,7 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, * forced to fix it. --ds */ for (i = 0; i < insn->n; i++) { - setup_sampling(dev, chan, gain); + daqboard2000_setup_sampling(dev, chan, gain); /* Enable reading from the scanlist FIFO */ writew(DB2K_ACQ_CONTROL_SEQ_START_SCAN_LIST, dev->mmio + DB2K_REG_ACQ_CONTROL); @@ -429,7 +431,7 @@ static int daqboard2000_ao_insn_write(struct comedi_device *dev, return insn->n; } -static void daqboard2000_resetLocalBus(struct comedi_device *dev) +static void daqboard2000_reset_local_bus(struct comedi_device *dev) { struct daqboard2000_private *devpriv = dev->private; @@ -439,7 +441,7 @@ static void daqboard2000_resetLocalBus(struct comedi_device *dev) mdelay(10); } -static void daqboard2000_reloadPLX(struct comedi_device *dev) +static void daqboard2000_reload_plx(struct comedi_device *dev) { struct daqboard2000_private *devpriv = dev->private; @@ -451,7 +453,7 @@ static void daqboard2000_reloadPLX(struct comedi_device *dev) mdelay(10); } -static void daqboard2000_pulseProgPin(struct comedi_device *dev) +static void daqboard2000_pulse_prog_pin(struct comedi_device *dev) { struct daqboard2000_private *devpriv = dev->private; @@ -461,7 +463,7 @@ static void daqboard2000_pulseProgPin(struct comedi_device *dev) mdelay(10); /* Not in the original code, but I like symmetry... */ } -static int daqboard2000_pollCPLD(struct comedi_device *dev, int mask) +static int daqboard2000_poll_cpld(struct comedi_device *dev, int mask) { int result = 0; int i; @@ -480,7 +482,7 @@ static int daqboard2000_pollCPLD(struct comedi_device *dev, int mask) return result; } -static int daqboard2000_writeCPLD(struct comedi_device *dev, int data) +static int daqboard2000_write_cpld(struct comedi_device *dev, int data) { int result = 0; @@ -493,9 +495,9 @@ static int daqboard2000_writeCPLD(struct comedi_device *dev, int data) return result; } -static int initialize_daqboard2000(struct comedi_device *dev, - const u8 *cpld_array, size_t len, - unsigned long context) +static int daqboard2000_load_firmware(struct comedi_device *dev, + const u8 *cpld_array, size_t len, + unsigned long context) { struct daqboard2000_private *devpriv = dev->private; int result = -EIO; @@ -510,10 +512,10 @@ static int initialize_daqboard2000(struct comedi_device *dev, return -EIO; for (retry = 0; retry < 3; retry++) { - daqboard2000_resetLocalBus(dev); - daqboard2000_reloadPLX(dev); - daqboard2000_pulseProgPin(dev); - if (daqboard2000_pollCPLD(dev, DAQBOARD2000_CPLD_INIT)) { + daqboard2000_reset_local_bus(dev); + daqboard2000_reload_plx(dev); + daqboard2000_pulse_prog_pin(dev); + if (daqboard2000_poll_cpld(dev, DAQBOARD2000_CPLD_INIT)) { for (i = 0; i < len; i++) { if (cpld_array[i] == 0xff && cpld_array[i + 1] == 0x20) @@ -522,12 +524,12 @@ static int initialize_daqboard2000(struct comedi_device *dev, for (; i < len; i += 2) { int data = (cpld_array[i] << 8) + cpld_array[i + 1]; - if (!daqboard2000_writeCPLD(dev, data)) + if (!daqboard2000_write_cpld(dev, data)) break; } if (i >= len) { - daqboard2000_resetLocalBus(dev); - daqboard2000_reloadPLX(dev); + daqboard2000_reset_local_bus(dev); + daqboard2000_reload_plx(dev); result = 0; break; } @@ -536,11 +538,11 @@ static int initialize_daqboard2000(struct comedi_device *dev, return result; } -static void daqboard2000_adcStopDmaTransfer(struct comedi_device *dev) +static void daqboard2000_adc_stop_dma_transfer(struct comedi_device *dev) { } -static void daqboard2000_adcDisarm(struct comedi_device *dev) +static void daqboard2000_adc_disarm(struct comedi_device *dev) { /* Disable hardware triggers */ udelay(2); @@ -561,10 +563,10 @@ static void daqboard2000_adcDisarm(struct comedi_device *dev) dev->mmio + DB2K_REG_ACQ_CONTROL); /* Stop the input dma (abort channel 1) */ - daqboard2000_adcStopDmaTransfer(dev); + daqboard2000_adc_stop_dma_transfer(dev); } -static void daqboard2000_activateReferenceDacs(struct comedi_device *dev) +static void daqboard2000_activate_reference_dacs(struct comedi_device *dev) { unsigned int val; int timeout; @@ -590,29 +592,29 @@ static void daqboard2000_activateReferenceDacs(struct comedi_device *dev) } } -static void daqboard2000_initializeCtrs(struct comedi_device *dev) +static void daqboard2000_initialize_ctrs(struct comedi_device *dev) { } -static void daqboard2000_initializeTmrs(struct comedi_device *dev) +static void daqboard2000_initialize_tmrs(struct comedi_device *dev) { } -static void daqboard2000_dacDisarm(struct comedi_device *dev) +static void daqboard2000_dac_disarm(struct comedi_device *dev) { } -static void daqboard2000_initializeAdc(struct comedi_device *dev) +static void daqboard2000_initialize_adc(struct comedi_device *dev) { - daqboard2000_adcDisarm(dev); - daqboard2000_activateReferenceDacs(dev); - daqboard2000_initializeCtrs(dev); - daqboard2000_initializeTmrs(dev); + daqboard2000_adc_disarm(dev); + daqboard2000_activate_reference_dacs(dev); + daqboard2000_initialize_ctrs(dev); + daqboard2000_initialize_tmrs(dev); } -static void daqboard2000_initializeDac(struct comedi_device *dev) +static void daqboard2000_initialize_dac(struct comedi_device *dev) { - daqboard2000_dacDisarm(dev); + daqboard2000_dac_disarm(dev); } static int daqboard2000_8255_cb(struct comedi_device *dev, @@ -679,12 +681,12 @@ static int daqboard2000_auto_attach(struct comedi_device *dev, result = comedi_load_firmware(dev, &comedi_to_pci_dev(dev)->dev, DAQBOARD2000_FIRMWARE, - initialize_daqboard2000, 0); + daqboard2000_load_firmware, 0); if (result < 0) return result; - daqboard2000_initializeAdc(dev); - daqboard2000_initializeDac(dev); + daqboard2000_initialize_adc(dev); + daqboard2000_initialize_dac(dev); s = &dev->subdevices[0]; /* ai subdevice */ -- cgit v1.1 From cda2315000d257fb169e8e15675b667264634a74 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 19 May 2016 19:15:27 +0100 Subject: staging: comedi: daqboard2000: prefer usleep_range() The checkpatch.pl warns about two `udelay(x)` calls, one of 100 microseconds, and one of 10 microseconds. The 100 microseconds one is used when waiting for FPGA to become ready to accept firmware, and is not that critical, so replace it with a call to `usleep_range(100, 1000)`. The 10 microseconds one is called as each 16-bit word of firmware data is written. Replace it with a fairly tight `usleep_range(10, 20)` to avoid slowing down firmware loading too much. The firmware is fairly short, so this would only slow it down firmware loading by about 20 milliseconds or so. Signed-off-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/daqboard2000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 6bc5bfe..65daef0 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -476,7 +476,7 @@ static int daqboard2000_poll_cpld(struct comedi_device *dev, int mask) result = 1; break; } - udelay(100); + usleep_range(100, 1000); } udelay(5); return result; @@ -486,7 +486,7 @@ static int daqboard2000_write_cpld(struct comedi_device *dev, int data) { int result = 0; - udelay(10); + usleep_range(10, 20); writew(data, dev->mmio + 0x1000); if ((readw(dev->mmio + 0x1000) & DAQBOARD2000_CPLD_INIT) == DAQBOARD2000_CPLD_INIT) { -- cgit v1.1 From 66906590caef4de2932577a6f8d46071613bbd21 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:03 +0100 Subject: staging: comedi: plx9080.h: correct LRNG_IO_MASK and LMAP_IO_MASK For the PLX local address space range registers, LAS0RR and LAS1RR, bit 0 indicates whether the local address space will be mapped to memory space or I/O space. If mapped to I/O space, bit 1 must be set to 0, and bits 31 to 2 form the address decoding mask, which should be -2^N mod 2^32 for a range of length 2^N. The `LRNG_IO_MASK` macro is supposed to specify the address decoding bits for I/O space. It currently has the value `0xfffffffa`, but should be `0xfffffffc`, or possibly `0xfffffffe` (it doesn't really matter, since bit 1 is required to be set to 0). Change it to `0xfffffffc`. Similarly, for the PLX local address space local base address (remap) registers, LAS0BA and LAS1BA, bits 31 to 2, masked with the corresponding "range" register form the local base address for the local address space. The `LMAP_IO_MASK` macro is supposed to mask the valid bits for I/O space. Change its value from `0xfffffffa` to `0xfffffffc` to match `LRNG_IO_MASK`. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/plx9080.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 8d1aee00b1..7d6311c 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -60,7 +60,7 @@ struct plx_dma_desc { /* bits that specify range for memory io */ #define LRNG_MEM_MASK 0xfffffff0 /* bits that specify range for normal io */ -#define LRNG_IO_MASK 0xfffffffa +#define LRNG_IO_MASK 0xfffffffc /* L, Local Addr Space 0 Remap Register */ #define PLX_LAS0MAP_REG 0x0004 /* L, Local Addr Space 1 Remap Register */ @@ -69,7 +69,7 @@ struct plx_dma_desc { /* bits that specify decode for memory io */ #define LMAP_MEM_MASK 0xfffffff0 /* bits that specify decode bits for normal io */ -#define LMAP_IO_MASK 0xfffffffa +#define LMAP_IO_MASK 0xfffffffc /* * Mode/Arbitration Register. -- cgit v1.1 From dc895b42871065dd2ddf162a99b083cf6892d507 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:04 +0100 Subject: staging: comedi: plx9080.h: remove Power-Up Test Suite stuff The defines related to the Power-Up Test Suite (PUTS) are just cruft that has nothing to do with the PLX PCI-9080 chip. They seem to have been inherited from "drivers/net/plx9060.h" in the kernel 2.2.16 sources for use by the "wanxl" driver. Remove them. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/plx9080.h | 120 ------------------------------- 1 file changed, 120 deletions(-) diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 7d6311c..3759a19 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -294,126 +294,6 @@ enum bigend_bits { #define PLX_PREFETCH 32 -/* - * The PCI Interface, via the PCI-9060 Chip, has up to eight (8) Mailbox - * Registers. The PUTS (Power-Up Test Suite) handles the board-side - * interface/interaction using the first 4 registers. Specifications for - * the use of the full PUTS' command and status interface is contained - * within a separate SBE PUTS Manual. The Host-Side Device Driver only - * uses a subset of the full PUTS interface. - */ - -/*****************************************/ -/*** MAILBOX #(-1) - MEM ACCESS STS ***/ -/*****************************************/ - -#define MBX_STS_VALID 0x57584744 /* 'WXGD' */ -#define MBX_STS_DILAV 0x44475857 /* swapped = 'DGXW' */ - -/*****************************************/ -/*** MAILBOX #0 - PUTS STATUS ***/ -/*****************************************/ - -#define MBX_STS_MASK 0x000000ff /* PUTS Status Register bits */ -#define MBX_STS_TMASK 0x0000000f /* register bits for TEST number */ - -#define MBX_STS_PCIRESET 0x00000100 /* Host issued PCI reset request */ -#define MBX_STS_BUSY 0x00000080 /* PUTS is in progress */ -#define MBX_STS_ERROR 0x00000040 /* PUTS has failed */ -/* - * Undefined -> status in transition. We are in process of changing bits; - * we SET Error bit before RESET of Busy bit - */ -#define MBX_STS_RESERVED 0x000000c0 - -#define MBX_RESERVED_5 0x00000020 /* FYI: reserved/unused bit */ -#define MBX_RESERVED_4 0x00000010 /* FYI: reserved/unused bit */ - -/******************************************/ -/*** MAILBOX #1 - PUTS COMMANDS ***/ -/******************************************/ - -/* - * Any attempt to execute an unimplement command results in the PUTS - * interface executing a NOOP and continuing as if the offending command - * completed normally. Note: this supplies a simple method to interrogate - * mailbox command processing functionality. - */ - -#define MBX_CMD_MASK 0xffff0000 /* PUTS Command Register bits */ - -#define MBX_CMD_ABORTJ 0x85000000 /* abort and jump */ -#define MBX_CMD_RESETP 0x86000000 /* reset and pause at start */ -#define MBX_CMD_PAUSE 0x87000000 /* pause immediately */ -#define MBX_CMD_PAUSEC 0x88000000 /* pause on completion */ -#define MBX_CMD_RESUME 0x89000000 /* resume operation */ -#define MBX_CMD_STEP 0x8a000000 /* single step tests */ - -#define MBX_CMD_BSWAP 0x8c000000 /* identify byte swap scheme */ -#define MBX_CMD_BSWAP_0 0x8c000000 /* use scheme 0 */ -#define MBX_CMD_BSWAP_1 0x8c000001 /* use scheme 1 */ - -/* setup host memory access window size */ -#define MBX_CMD_SETHMS 0x8d000000 -/* setup host memory access base address */ -#define MBX_CMD_SETHBA 0x8e000000 -/* perform memory setup and continue (IE. Done) */ -#define MBX_CMD_MGO 0x8f000000 -#define MBX_CMD_NOOP 0xFF000000 /* dummy, illegal command */ - -/*****************************************/ -/*** MAILBOX #2 - MEMORY SIZE ***/ -/*****************************************/ - -#define MBX_MEMSZ_MASK 0xffff0000 /* PUTS Memory Size Register bits */ - -#define MBX_MEMSZ_128KB 0x00020000 /* 128 kilobyte board */ -#define MBX_MEMSZ_256KB 0x00040000 /* 256 kilobyte board */ -#define MBX_MEMSZ_512KB 0x00080000 /* 512 kilobyte board */ -#define MBX_MEMSZ_1MB 0x00100000 /* 1 megabyte board */ -#define MBX_MEMSZ_2MB 0x00200000 /* 2 megabyte board */ -#define MBX_MEMSZ_4MB 0x00400000 /* 4 megabyte board */ -#define MBX_MEMSZ_8MB 0x00800000 /* 8 megabyte board */ -#define MBX_MEMSZ_16MB 0x01000000 /* 16 megabyte board */ - -/***************************************/ -/*** MAILBOX #2 - BOARD TYPE ***/ -/***************************************/ - -#define MBX_BTYPE_MASK 0x0000ffff /* PUTS Board Type Register */ -/* PUTS Board Family Register */ -#define MBX_BTYPE_FAMILY_MASK 0x0000ff00 -#define MBX_BTYPE_SUBTYPE_MASK 0x000000ff /* PUTS Board Subtype */ - -#define MBX_BTYPE_PLX9060 0x00000100 /* PLX family type */ -#define MBX_BTYPE_PLX9080 0x00000300 /* PLX wanXL100s family type */ - -#define MBX_BTYPE_WANXL_4 0x00000104 /* wanXL400, 4-port */ -#define MBX_BTYPE_WANXL_2 0x00000102 /* wanXL200, 2-port */ -#define MBX_BTYPE_WANXL_1s 0x00000301 /* wanXL100s, 1-port */ -#define MBX_BTYPE_WANXL_1t 0x00000401 /* wanXL100T1, 1-port */ - -/*****************************************/ -/*** MAILBOX #3 - SHMQ MAILBOX ***/ -/*****************************************/ - -#define MBX_SMBX_MASK 0x000000ff /* PUTS SHMQ Mailbox bits */ - -/***************************************/ -/*** GENERIC HOST-SIDE DRIVER ***/ -/***************************************/ - -#define MBX_ERR 0 -#define MBX_OK 1 - -/* mailbox check routine - type of testing */ -#define MBXCHK_STS 0x00 /* check for PUTS status */ -#define MBXCHK_NOWAIT 0x01 /* dont care about PUTS status */ - -/* system allocates this many bytes for address mapping mailbox space */ -#define MBX_ADDR_SPACE_360 0x80 /* wanXL100s/200/400 */ -#define MBX_ADDR_MASK_360 (MBX_ADDR_SPACE_360 - 1) - static inline int plx9080_abort_dma(void __iomem *iobase, unsigned int channel) { void __iomem *dma_cs_addr; -- cgit v1.1 From c644a11aae6e36b6dbae425cdfa9630d2abaaa16 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:05 +0100 Subject: staging: comedi: drivers: rename PLX PCI 9080 register offsets Rename the macros in "plx9080.h" that define the offsets of registers, following the pattern `PLX_REG_`, where `` is the register name from the PLX PCI 9080 Data Book. Add defines for the "Mailbox" registers, and add parameterized macros for the mailbox registers and the DMA control registers. Make use of the parameterized versions of the macros where it seems appropriate. The registers for supporting the I2O (Intelligent Input/Output) feature are largely left undefined, just defining enough to allow the I2O feature to be disabled. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 96 ++++++--------- drivers/staging/comedi/drivers/gsc_hpdi.c | 39 +++--- drivers/staging/comedi/drivers/plx9080.h | 177 +++++++++++++++++++-------- drivers/staging/comedi/drivers/rtd520.c | 4 +- 4 files changed, 185 insertions(+), 131 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index c773b8c..d9468db 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1238,7 +1238,7 @@ static void disable_plx_interrupts(struct comedi_device *dev) devpriv->plx_intcsr_bits = 0; writel(devpriv->plx_intcsr_bits, - devpriv->plx9080_iobase + PLX_INTRCS_REG); + devpriv->plx9080_iobase + PLX_REG_INTCSR); } static void disable_ai_interrupts(struct comedi_device *dev) @@ -1291,14 +1291,14 @@ static void init_plx9080(struct comedi_device *dev) void __iomem *plx_iobase = devpriv->plx9080_iobase; devpriv->plx_control_bits = - readl(devpriv->plx9080_iobase + PLX_CONTROL_REG); + readl(devpriv->plx9080_iobase + PLX_REG_CNTRL); #ifdef __BIG_ENDIAN bits = BIGEND_DMA0 | BIGEND_DMA1; #else bits = 0; #endif - writel(bits, devpriv->plx9080_iobase + PLX_BIGEND_REG); + writel(bits, devpriv->plx9080_iobase + PLX_REG_BIGEND); disable_plx_interrupts(dev); @@ -1330,16 +1330,16 @@ static void init_plx9080(struct comedi_device *dev) bits |= PLX_LOCAL_BUS_32_WIDE_BITS; else /* localspace0 bus is 16 bits wide */ bits |= PLX_LOCAL_BUS_16_WIDE_BITS; - writel(bits, plx_iobase + PLX_DMA1_MODE_REG); + writel(bits, plx_iobase + PLX_REG_DMAMODE1); if (ao_cmd_is_supported(board)) - writel(bits, plx_iobase + PLX_DMA0_MODE_REG); + writel(bits, plx_iobase + PLX_REG_DMAMODE0); /* enable interrupts on plx 9080 */ devpriv->plx_intcsr_bits |= ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE | ICS_DMA0_E | ICS_DMA1_E; writel(devpriv->plx_intcsr_bits, - devpriv->plx9080_iobase + PLX_INTRCS_REG); + devpriv->plx9080_iobase + PLX_REG_INTCSR); } static void disable_ai_pacing(struct comedi_device *dev) @@ -1615,7 +1615,7 @@ static void i2c_set_sda(struct comedi_device *dev, int state) struct pcidas64_private *devpriv = dev->private; static const int data_bit = CTL_EE_W; void __iomem *plx_control_addr = devpriv->plx9080_iobase + - PLX_CONTROL_REG; + PLX_REG_CNTRL; if (state) { /* set data line high */ @@ -1636,7 +1636,7 @@ static void i2c_set_scl(struct comedi_device *dev, int state) struct pcidas64_private *devpriv = dev->private; static const int clock_bit = CTL_USERO; void __iomem *plx_control_addr = devpriv->plx9080_iobase + - PLX_CONTROL_REG; + PLX_REG_CNTRL; if (state) { /* set clock line high */ @@ -2367,14 +2367,8 @@ static inline void dma_start_sync(struct comedi_device *dev, /* spinlock for plx dma control/status reg */ spin_lock_irqsave(&dev->spinlock, flags); - if (channel) - writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | - PLX_CLEAR_DMA_INTR_BIT, - devpriv->plx9080_iobase + PLX_DMA1_CS_REG); - else - writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | - PLX_CLEAR_DMA_INTR_BIT, - devpriv->plx9080_iobase + PLX_DMA0_CS_REG); + writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | PLX_CLEAR_DMA_INTR_BIT, + devpriv->plx9080_iobase + PLX_REG_DMACSR(channel)); spin_unlock_irqrestore(&dev->spinlock, flags); } @@ -2552,21 +2546,17 @@ static inline void load_first_dma_descriptor(struct comedi_device *dev, * block. Initializing them to zero seems to fix the problem. */ if (dma_channel) { - writel(0, - devpriv->plx9080_iobase + PLX_DMA1_TRANSFER_SIZE_REG); - writel(0, devpriv->plx9080_iobase + PLX_DMA1_PCI_ADDRESS_REG); - writel(0, - devpriv->plx9080_iobase + PLX_DMA1_LOCAL_ADDRESS_REG); + writel(0, devpriv->plx9080_iobase + PLX_REG_DMASIZ1); + writel(0, devpriv->plx9080_iobase + PLX_REG_DMAPADR1); + writel(0, devpriv->plx9080_iobase + PLX_REG_DMALADR1); writel(descriptor_bits, - devpriv->plx9080_iobase + PLX_DMA1_DESCRIPTOR_REG); + devpriv->plx9080_iobase + PLX_REG_DMADPR1); } else { - writel(0, - devpriv->plx9080_iobase + PLX_DMA0_TRANSFER_SIZE_REG); - writel(0, devpriv->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG); - writel(0, - devpriv->plx9080_iobase + PLX_DMA0_LOCAL_ADDRESS_REG); + writel(0, devpriv->plx9080_iobase + PLX_REG_DMASIZ0); + writel(0, devpriv->plx9080_iobase + PLX_REG_DMAPADR0); + writel(0, devpriv->plx9080_iobase + PLX_REG_DMALADR0); writel(descriptor_bits, - devpriv->plx9080_iobase + PLX_DMA0_DESCRIPTOR_REG); + devpriv->plx9080_iobase + PLX_REG_DMADPR0); } } @@ -2803,12 +2793,7 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel) int num_samples = 0; void __iomem *pci_addr_reg; - if (channel) - pci_addr_reg = - devpriv->plx9080_iobase + PLX_DMA1_PCI_ADDRESS_REG; - else - pci_addr_reg = - devpriv->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG; + pci_addr_reg = devpriv->plx9080_iobase + PLX_REG_DMAPADR(channel); /* loop until we have read all the full buffers */ for (j = 0, next_transfer_addr = readl(pci_addr_reg); @@ -2850,10 +2835,10 @@ static void handle_ai_interrupt(struct comedi_device *dev, } /* spin lock makes sure no one else changes plx dma control reg */ spin_lock_irqsave(&dev->spinlock, flags); - dma1_status = readb(devpriv->plx9080_iobase + PLX_DMA1_CS_REG); + dma1_status = readb(devpriv->plx9080_iobase + PLX_REG_DMACSR1); if (plx_status & ICS_DMA1_A) { /* dma chan 1 interrupt */ writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, - devpriv->plx9080_iobase + PLX_DMA1_CS_REG); + devpriv->plx9080_iobase + PLX_REG_DMACSR1); if (dma1_status & PLX_DMA_EN_BIT) drain_dma_buffers(dev, 1); @@ -2902,12 +2887,12 @@ static int last_ao_dma_load_completed(struct comedi_device *dev) unsigned short dma_status; buffer_index = prev_ao_dma_index(dev); - dma_status = readb(devpriv->plx9080_iobase + PLX_DMA0_CS_REG); + dma_status = readb(devpriv->plx9080_iobase + PLX_REG_DMACSR0); if ((dma_status & PLX_DMA_DONE_BIT) == 0) return 0; transfer_address = - readl(devpriv->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG); + readl(devpriv->plx9080_iobase + PLX_REG_DMAPADR0); if (transfer_address != devpriv->ao_buffer_bus_addr[buffer_index]) return 0; @@ -2931,8 +2916,7 @@ static void restart_ao_dma(struct comedi_device *dev) struct pcidas64_private *devpriv = dev->private; unsigned int dma_desc_bits; - dma_desc_bits = - readl(devpriv->plx9080_iobase + PLX_DMA0_DESCRIPTOR_REG); + dma_desc_bits = readl(devpriv->plx9080_iobase + PLX_REG_DMADPR0); dma_desc_bits &= ~PLX_END_OF_CHAIN_BIT; load_first_dma_descriptor(dev, 0, dma_desc_bits); @@ -2994,8 +2978,7 @@ static void load_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) struct pcidas64_private *devpriv = dev->private; unsigned int num_bytes; unsigned int next_transfer_addr; - void __iomem *pci_addr_reg = - devpriv->plx9080_iobase + PLX_DMA0_PCI_ADDRESS_REG; + void __iomem *pci_addr_reg = devpriv->plx9080_iobase + PLX_REG_DMAPADR0; unsigned int buffer_index; do { @@ -3030,15 +3013,16 @@ static void handle_ao_interrupt(struct comedi_device *dev, /* spin lock makes sure no one else changes plx dma control reg */ spin_lock_irqsave(&dev->spinlock, flags); - dma0_status = readb(devpriv->plx9080_iobase + PLX_DMA0_CS_REG); + dma0_status = readb(devpriv->plx9080_iobase + PLX_REG_DMACSR0); if (plx_status & ICS_DMA0_A) { /* dma chan 0 interrupt */ if ((dma0_status & PLX_DMA_EN_BIT) && - !(dma0_status & PLX_DMA_DONE_BIT)) + !(dma0_status & PLX_DMA_DONE_BIT)) { writeb(PLX_DMA_EN_BIT | PLX_CLEAR_DMA_INTR_BIT, - devpriv->plx9080_iobase + PLX_DMA0_CS_REG); - else + devpriv->plx9080_iobase + PLX_REG_DMACSR0); + } else { writeb(PLX_CLEAR_DMA_INTR_BIT, - devpriv->plx9080_iobase + PLX_DMA0_CS_REG); + devpriv->plx9080_iobase + PLX_REG_DMACSR0); + } spin_unlock_irqrestore(&dev->spinlock, flags); if (dma0_status & PLX_DMA_EN_BIT) { load_ao_dma(dev, cmd); @@ -3069,7 +3053,7 @@ static irqreturn_t handle_interrupt(int irq, void *d) uint32_t plx_status; uint32_t plx_bits; - plx_status = readl(devpriv->plx9080_iobase + PLX_INTRCS_REG); + plx_status = readl(devpriv->plx9080_iobase + PLX_REG_INTCSR); status = readw(devpriv->main_iobase + HW_STATUS_REG); /* @@ -3085,8 +3069,8 @@ static irqreturn_t handle_interrupt(int irq, void *d) /* clear possible plx9080 interrupt sources */ if (plx_status & ICS_LDIA) { /* clear local doorbell interrupt */ - plx_bits = readl(devpriv->plx9080_iobase + PLX_DBR_OUT_REG); - writel(plx_bits, devpriv->plx9080_iobase + PLX_DBR_OUT_REG); + plx_bits = readl(devpriv->plx9080_iobase + PLX_REG_L2PDBELL); + writel(plx_bits, devpriv->plx9080_iobase + PLX_REG_L2PDBELL); } return IRQ_HANDLED; @@ -3725,7 +3709,7 @@ static uint16_t read_eeprom(struct comedi_device *dev, uint8_t address) unsigned int bitstream = (read_command << 8) | address; unsigned int bit; void __iomem * const plx_control_addr = - devpriv->plx9080_iobase + PLX_CONTROL_REG; + devpriv->plx9080_iobase + PLX_REG_CNTRL; uint16_t value; static const int value_length = 16; static const int eeprom_udelay = 1; @@ -3962,7 +3946,7 @@ static int setup_subdevices(struct comedi_device *dev) /* serial EEPROM, if present */ s = &dev->subdevices[8]; - if (readl(devpriv->plx9080_iobase + PLX_CONTROL_REG) & CTL_EECHK) { + if (readl(devpriv->plx9080_iobase + PLX_REG_CNTRL) & CTL_EECHK) { s->type = COMEDI_SUBD_MEMORY; s->subdev_flags = SDF_READABLE | SDF_INTERNAL; s->n_chan = 128; @@ -4019,15 +4003,15 @@ static int auto_attach(struct comedi_device *dev, } /* figure out what local addresses are */ - local_range = readl(devpriv->plx9080_iobase + PLX_LAS0RNG_REG) & + local_range = readl(devpriv->plx9080_iobase + PLX_REG_LAS0RR) & LRNG_MEM_MASK; - local_decode = readl(devpriv->plx9080_iobase + PLX_LAS0MAP_REG) & + local_decode = readl(devpriv->plx9080_iobase + PLX_REG_LAS0BA) & local_range & LMAP_MEM_MASK; devpriv->local0_iobase = ((uint32_t)devpriv->main_phys_iobase & ~local_range) | local_decode; - local_range = readl(devpriv->plx9080_iobase + PLX_LAS1RNG_REG) & + local_range = readl(devpriv->plx9080_iobase + PLX_REG_LAS1RR) & LRNG_MEM_MASK; - local_decode = readl(devpriv->plx9080_iobase + PLX_LAS1MAP_REG) & + local_decode = readl(devpriv->plx9080_iobase + PLX_REG_LAS1BA) & local_range & LMAP_MEM_MASK; devpriv->local1_iobase = ((uint32_t)devpriv->dio_counter_phys_iobase & ~local_range) | local_decode; diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 63b5cbc..e2831e1 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -158,10 +158,7 @@ static void gsc_hpdi_drain_dma(struct comedi_device *dev, unsigned int channel) unsigned int size; unsigned int next; - if (channel) - next = readl(devpriv->plx9080_mmio + PLX_DMA1_PCI_ADDRESS_REG); - else - next = readl(devpriv->plx9080_mmio + PLX_DMA0_PCI_ADDRESS_REG); + next = readl(devpriv->plx9080_mmio + PLX_REG_DMAPADR(channel)); idx = devpriv->dma_desc_index; start = le32_to_cpu(devpriv->dma_desc[idx].pci_start_addr); @@ -201,7 +198,7 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) if (!dev->attached) return IRQ_NONE; - plx_status = readl(devpriv->plx9080_mmio + PLX_INTRCS_REG); + plx_status = readl(devpriv->plx9080_mmio + PLX_REG_INTCSR); if ((plx_status & (ICS_DMA0_A | ICS_DMA1_A | ICS_LIA)) == 0) return IRQ_NONE; @@ -213,11 +210,11 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) /* spin lock makes sure no one else changes plx dma control reg */ spin_lock_irqsave(&dev->spinlock, flags); - dma0_status = readb(devpriv->plx9080_mmio + PLX_DMA0_CS_REG); + dma0_status = readb(devpriv->plx9080_mmio + PLX_REG_DMACSR0); if (plx_status & ICS_DMA0_A) { /* dma chan 0 interrupt */ writeb((dma0_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, - devpriv->plx9080_mmio + PLX_DMA0_CS_REG); + devpriv->plx9080_mmio + PLX_REG_DMACSR0); if (dma0_status & PLX_DMA_EN_BIT) gsc_hpdi_drain_dma(dev, 0); @@ -226,19 +223,19 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) /* spin lock makes sure no one else changes plx dma control reg */ spin_lock_irqsave(&dev->spinlock, flags); - dma1_status = readb(devpriv->plx9080_mmio + PLX_DMA1_CS_REG); + dma1_status = readb(devpriv->plx9080_mmio + PLX_REG_DMACSR1); if (plx_status & ICS_DMA1_A) { /* XXX */ /* dma chan 1 interrupt */ writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, - devpriv->plx9080_mmio + PLX_DMA1_CS_REG); + devpriv->plx9080_mmio + PLX_REG_DMACSR1); } spin_unlock_irqrestore(&dev->spinlock, flags); /* clear possible plx9080 interrupt sources */ if (plx_status & ICS_LDIA) { /* clear local doorbell interrupt */ - plx_bits = readl(devpriv->plx9080_mmio + PLX_DBR_OUT_REG); - writel(plx_bits, devpriv->plx9080_mmio + PLX_DBR_OUT_REG); + plx_bits = readl(devpriv->plx9080_mmio + PLX_REG_L2PDBELL); + writel(plx_bits, devpriv->plx9080_mmio + PLX_REG_L2PDBELL); } if (hpdi_board_status & RX_OVERRUN_BIT) { @@ -307,19 +304,19 @@ static int gsc_hpdi_cmd(struct comedi_device *dev, * occasionally cause problems with transfer of first dma * block. Initializing them to zero seems to fix the problem. */ - writel(0, devpriv->plx9080_mmio + PLX_DMA0_TRANSFER_SIZE_REG); - writel(0, devpriv->plx9080_mmio + PLX_DMA0_PCI_ADDRESS_REG); - writel(0, devpriv->plx9080_mmio + PLX_DMA0_LOCAL_ADDRESS_REG); + writel(0, devpriv->plx9080_mmio + PLX_REG_DMASIZ0); + writel(0, devpriv->plx9080_mmio + PLX_REG_DMAPADR0); + writel(0, devpriv->plx9080_mmio + PLX_REG_DMALADR0); /* give location of first dma descriptor */ bits = devpriv->dma_desc_phys_addr | PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT | PLX_XFER_LOCAL_TO_PCI; - writel(bits, devpriv->plx9080_mmio + PLX_DMA0_DESCRIPTOR_REG); + writel(bits, devpriv->plx9080_mmio + PLX_REG_DMADPR0); /* enable dma transfer */ spin_lock_irqsave(&dev->spinlock, flags); writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | PLX_CLEAR_DMA_INTR_BIT, - devpriv->plx9080_mmio + PLX_DMA0_CS_REG); + devpriv->plx9080_mmio + PLX_REG_DMACSR0); spin_unlock_irqrestore(&dev->spinlock, flags); if (cmd->stop_src == TRIG_COUNT) @@ -538,7 +535,7 @@ static int gsc_hpdi_init(struct comedi_device *dev) plx_intcsr_bits = ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE | ICS_DMA0_E; - writel(plx_intcsr_bits, devpriv->plx9080_mmio + PLX_INTRCS_REG); + writel(plx_intcsr_bits, devpriv->plx9080_mmio + PLX_REG_INTCSR); return 0; } @@ -554,9 +551,9 @@ static void gsc_hpdi_init_plx9080(struct comedi_device *dev) #else bits = 0; #endif - writel(bits, devpriv->plx9080_mmio + PLX_BIGEND_REG); + writel(bits, devpriv->plx9080_mmio + PLX_REG_BIGEND); - writel(0, devpriv->plx9080_mmio + PLX_INTRCS_REG); + writel(0, devpriv->plx9080_mmio + PLX_REG_INTCSR); gsc_hpdi_abort_dma(dev, 0); gsc_hpdi_abort_dma(dev, 1); @@ -584,7 +581,7 @@ static void gsc_hpdi_init_plx9080(struct comedi_device *dev) /* enable local burst mode */ bits |= PLX_DMA_LOCAL_BURST_EN_BIT; bits |= PLX_LOCAL_BUS_32_WIDE_BITS; - writel(bits, plx_iobase + PLX_DMA0_MODE_REG); + writel(bits, plx_iobase + PLX_REG_DMAMODE0); } static int gsc_hpdi_auto_attach(struct comedi_device *dev, @@ -680,7 +677,7 @@ static void gsc_hpdi_detach(struct comedi_device *dev) free_irq(dev->irq, dev); if (devpriv) { if (devpriv->plx9080_mmio) { - writel(0, devpriv->plx9080_mmio + PLX_INTRCS_REG); + writel(0, devpriv->plx9080_mmio + PLX_REG_INTCSR); iounmap(devpriv->plx9080_mmio); } if (dev->mmio) diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 3759a19..92d2480 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -36,7 +36,7 @@ struct plx_dma_desc { __le32 transfer_size; /* * address of next descriptor (quad word aligned), plus some - * additional bits (see PLX_DMA0_DESCRIPTOR_REG) + * additional bits (see PLX_REG_DMADPR) */ __le32 next; }; @@ -49,10 +49,11 @@ struct plx_dma_desc { ** **********************************************************************/ -/* L, Local Addr Space 0 Range Register */ -#define PLX_LAS0RNG_REG 0x0000 -/* L, Local Addr Space 1 Range Register */ -#define PLX_LAS1RNG_REG 0x00f0 +/* Local Address Space 0 Range Register */ +#define PLX_REG_LAS0RR 0x0000 +/* Local Address Space 1 Range Register */ +#define PLX_REG_LAS1RR 0x00f0 + #define LRNG_IO 0x00000001 /* Map to: 1=I/O, 0=Mem */ #define LRNG_ANY32 0x00000000 /* Locate anywhere in 32 bit */ #define LRNG_LT1MB 0x00000002 /* Locate in 1st meg */ @@ -61,21 +62,23 @@ struct plx_dma_desc { #define LRNG_MEM_MASK 0xfffffff0 /* bits that specify range for normal io */ #define LRNG_IO_MASK 0xfffffffc -/* L, Local Addr Space 0 Remap Register */ -#define PLX_LAS0MAP_REG 0x0004 -/* L, Local Addr Space 1 Remap Register */ -#define PLX_LAS1MAP_REG 0x00f4 + +/* Local Address Space 0 Local Base Address (Remap) Register */ +#define PLX_REG_LAS0BA 0x0004 +/* Local Address Space 1 Local Base Address (Remap) Register */ +#define PLX_REG_LAS1BA 0x00f4 + #define LMAP_EN 0x00000001 /* Enable slave decode */ /* bits that specify decode for memory io */ #define LMAP_MEM_MASK 0xfffffff0 /* bits that specify decode bits for normal io */ #define LMAP_IO_MASK 0xfffffffc -/* - * Mode/Arbitration Register. - */ -#define PLX_MARB_REG 0x8 /* L, Local Arbitration Register */ -#define PLX_DMAARB_REG 0xac +/* Mode/Arbitration Register */ +#define PLX_REG_MARBR 0x0008 +/* DMA Arbitration Register (alias of MARBR). */ +#define PLX_REG_DMAARB 0x00ac + enum marb_bits { MARB_LLT_MASK = 0x000000ff, /* Local Bus Latency Timer */ MARB_LPT_MASK = 0x0000ff00, /* Local Bus Pause Timer */ @@ -97,7 +100,9 @@ enum marb_bits { MARB_USE_SUBSYSTEM_IDS = 0x20000000, }; -#define PLX_BIGEND_REG 0xc +/* Big/Little Endian Descriptor Register */ +#define PLX_REG_BIGEND 0x000c + enum bigend_bits { /* use big endian ordering for configuration register accesses */ BIGEND_CONFIG = 0x1, @@ -119,11 +124,16 @@ enum bigend_bits { ** This expansion ROM code is executed by the host CPU at boot time. ** For this reason no bit definitions are provided here. */ -#define PLX_ROMRNG_REG 0x0010 /* L, Expn ROM Space Range Register */ -/* L, Local Addr Space Range Register */ -#define PLX_ROMMAP_REG 0x0014 +/* Expansion ROM Range Register */ +#define PLX_REG_EROMRR 0x0010 +/* Expansion ROM Local Base Address (Remap) Register */ +#define PLX_REG_EROMBA 0x0014 + +/* Local Address Space 0/Expansion ROM Bus Region Descriptor Register */ +#define PLX_REG_LBRD0 0x0018 +/* Local Address Space 1 Bus Region Descriptor Register */ +#define PLX_REG_LBRD1 0x00f8 -#define PLX_REGION0_REG 0x0018 /* L, Local Bus Region 0 Descriptor */ #define RGN_WIDTH 0x00000002 /* Local bus width bits */ #define RGN_8BITS 0x00000000 /* 08 bit Local Bus */ #define RGN_16BITS 0x00000001 /* 16 bit Local Bus */ @@ -149,15 +159,18 @@ enum bigend_bits { #define RGN_THROT 0x08000000 /* De-assert TRDY when FIFO full */ #define RGN_TRD 0xF0000000 /* Target Ready Delay /8 */ -#define PLX_REGION1_REG 0x00f8 /* L, Local Bus Region 1 Descriptor */ +/* Local Range Register for Direct Master to PCI */ +#define PLX_REG_DMRR 0x001c -#define PLX_DMRNG_REG 0x001C /* L, Direct Master Range Register */ +/* Local Bus Base Address Register for Direct Master to PCI Memory */ +#define PLX_REG_DMLBAM 0x0020 -#define PLX_LBAPMEM_REG 0x0020 /* L, Lcl Base Addr for PCI mem space */ +/* Local Base Address Register for Direct Master to PCI IO/CFG */ +#define PLX_REG_DMLBAI 0x0024 -#define PLX_LBAPIO_REG 0x0024 /* L, Lcl Base Addr for PCI I/O space */ +/* PCI Base Address (Remap) Register for Direct Master to PCI Memory */ +#define PLX_REG_DMPBAM 0x0028 -#define PLX_DMMAP_REG 0x0028 /* L, Direct Master Remap Register */ #define DMM_MAE 0x00000001 /* Direct Mstr Memory Acc Enable */ #define DMM_IAE 0x00000002 /* Direct Mstr I/O Acc Enable */ #define DMM_LCK 0x00000004 /* LOCK Input Enable */ @@ -173,7 +186,9 @@ enum bigend_bits { #define DMM_PAF7 0x000000D0 /* Programmable Almost fill level */ #define DMM_MAP 0xFFFF0000 /* Remap Address Bits */ -#define PLX_CAR_REG 0x002C /* L, Configuration Address Register */ +/* PCI Configuration Address Register for Direct Master to PCI IO/CFG */ +#define PLX_REG_DMCFGA 0x002c + #define CAR_CT0 0x00000000 /* Config Type 0 */ #define CAR_CT1 0x00000001 /* Config Type 1 */ #define CAR_REG 0x000000FC /* Register Number Bits */ @@ -182,11 +197,38 @@ enum bigend_bits { #define CAR_BUS 0x00FF0000 /* Bus Number Bits */ #define CAR_CFG 0x80000000 /* Config Spc Access Enable */ -#define PLX_DBR_IN_REG 0x0060 /* L, PCI to Local Doorbell Register */ - -#define PLX_DBR_OUT_REG 0x0064 /* L, Local to PCI Doorbell Register */ +/* + * Mailbox Register N (N <= 7) + * + * Note that if the I2O feature is enabled (QSR[0] is set), Mailbox Register 0 + * is replaced by the Inbound Queue Port, and Mailbox Register 1 is replaced + * by the Outbound Queue Port. However, Mailbox Register 0 and 1 are always + * accessible at alternative offsets if the I2O feature is enabled. + */ +#define PLX_REG_MBOX(n) (0x0040 + (n) * 4) +#define PLX_REG_MBOX0 PLX_REG_MBOX(0) +#define PLX_REG_MBOX1 PLX_REG_MBOX(1) +#define PLX_REG_MBOX2 PLX_REG_MBOX(2) +#define PLX_REG_MBOX3 PLX_REG_MBOX(3) +#define PLX_REG_MBOX4 PLX_REG_MBOX(4) +#define PLX_REG_MBOX5 PLX_REG_MBOX(5) +#define PLX_REG_MBOX6 PLX_REG_MBOX(6) +#define PLX_REG_MBOX7 PLX_REG_MBOX(7) + +/* Alternative offsets for Mailbox Registers 0 and 1 (in case I2O is enabled) */ +#define PLX_REG_ALT_MBOX(n) ((n) < 2 ? 0x0078 + (n) * 4 : PLX_REG_MBOX(n)) +#define PLX_REG_ALT_MBOX0 PLX_REG_ALT_MBOX(0) +#define PLX_REG_ALT_MBOX1 PLX_REG_ALT_MBOX(1) + +/* PCI-to-Local Doorbell Register */ +#define PLX_REG_P2LDBELL 0x0060 + +/* Local-to-PCI Doorbell Register */ +#define PLX_REG_L2PDBELL 0x0064 + +/* Interrupt Control/Status Register */ +#define PLX_REG_INTCSR 0x0068 -#define PLX_INTRCS_REG 0x0068 /* L, Interrupt Control/Status Reg */ #define ICS_AERR 0x00000001 /* Assert LSERR on ABORT */ #define ICS_PERR 0x00000002 /* Assert LSERR on Parity Error */ #define ICS_SERR 0x00000004 /* Generate PCI SERR# */ @@ -214,7 +256,12 @@ enum bigend_bits { /* mailbox x is active */ #define ICS_MBIA(x) (0x10000000 << ((x) & 0x3)) -#define PLX_CONTROL_REG 0x006C /* L, EEPROM Cntl & PCI Cmd Codes */ +/* + * Serial EEPROM Control, PCI Command Codes, User I/O Control, + * Init Control Register + */ +#define PLX_REG_CNTRL 0x006c + #define CTL_RDMA 0x0000000E /* DMA Read Command */ #define CTL_WDMA 0x00000070 /* DMA Write Command */ #define CTL_RMEM 0x00000600 /* Memory Read Command */ @@ -230,12 +277,17 @@ enum bigend_bits { #define CTL_RESET 0x40000000 /* !! Adapter Reset !! */ #define CTL_READY 0x80000000 /* Local Init Done */ -#define PLX_ID_REG 0x70 /* hard-coded plx vendor and device ids */ +/* PCI Permanent Configuration ID Register (hard-coded PLX vendor and device) */ +#define PLX_REG_PCIHIDR 0x0070 + +/* PCI Permanent Revision ID Register (hard-coded silicon revision) (8-bit). */ +#define PLX_REG_PCIHREV 0x0074 -#define PLX_REVISION_REG 0x74 /* silicon revision */ +/* DMA Channel N Mode Register (N <= 1) */ +#define PLX_REG_DMAMODE(n) ((n) ? PLX_REG_DMAMODE1 : PLX_REG_DMAMODE0) +#define PLX_REG_DMAMODE0 0x0080 +#define PLX_REG_DMAMODE1 0x0094 -#define PLX_DMA0_MODE_REG 0x80 /* dma channel 0 mode register */ -#define PLX_DMA1_MODE_REG 0x94 /* dma channel 0 mode register */ #define PLX_LOCAL_BUS_16_WIDE_BITS 0x1 #define PLX_LOCAL_BUS_32_WIDE_BITS 0x3 #define PLX_LOCAL_BUS_WIDTH_MASK 0x3 @@ -254,20 +306,26 @@ enum bigend_bits { /* routes dma interrupt to pci bus (instead of local bus) */ #define PLX_DMA_INTR_PCI_BIT 0x20000 -/* pci address that dma transfers start at */ -#define PLX_DMA0_PCI_ADDRESS_REG 0x84 -#define PLX_DMA1_PCI_ADDRESS_REG 0x98 +/* DMA Channel N PCI Address Register (N <= 1) */ +#define PLX_REG_DMAPADR(n) ((n) ? PLX_REG_DMAPADR1 : PLX_REG_DMAPADR0) +#define PLX_REG_DMAPADR0 0x0084 +#define PLX_REG_DMAPADR1 0x0098 + +/* DMA Channel N Local Address Register (N <= 1) */ +#define PLX_REG_DMALADR(n) ((n) ? PLX_REG_DMALADR1 : PLX_REG_DMALADR0) +#define PLX_REG_DMALADR0 0x0088 +#define PLX_REG_DMALADR1 0x009c -/* local address that dma transfers start at */ -#define PLX_DMA0_LOCAL_ADDRESS_REG 0x88 -#define PLX_DMA1_LOCAL_ADDRESS_REG 0x9c +/* DMA Channel N Transfer Size (Bytes) Register (N <= 1) (first 23 bits) */ +#define PLX_REG_DMASIZ(n) ((n) ? PLX_REG_DMASIZ1 : PLX_REG_DMASIZ0) +#define PLX_REG_DMASIZ0 0x008c +#define PLX_REG_DMASIZ1 0x00a0 -/* number of bytes to transfer (first 23 bits) */ -#define PLX_DMA0_TRANSFER_SIZE_REG 0x8c -#define PLX_DMA1_TRANSFER_SIZE_REG 0xa0 +/* DMA Channel N Descriptor Pointer Register (N <= 1) */ +#define PLX_REG_DMADPR(n) ((n) ? PLX_REG_DMADPR1 : PLX_REG_DMADPR0) +#define PLX_REG_DMADPR0 0x0090 +#define PLX_REG_DMADPR1 0x00a4 -#define PLX_DMA0_DESCRIPTOR_REG 0x90 /* descriptor pointer register */ -#define PLX_DMA1_DESCRIPTOR_REG 0xa4 /* descriptor is located in pci space (not local space) */ #define PLX_DESC_IN_PCI_BIT 0x1 #define PLX_END_OF_CHAIN_BIT 0x2 /* end of chain bit */ @@ -276,15 +334,33 @@ enum bigend_bits { /* transfer from local to pci bus (not pci to local) */ #define PLX_XFER_LOCAL_TO_PCI 0x8 -#define PLX_DMA0_CS_REG 0xa8 /* command status register */ -#define PLX_DMA1_CS_REG 0xa9 +/* DMA Channel N Command/Status Register (N <= 1) (8-bit) */ +#define PLX_REG_DMACSR(n) ((n) ? PLX_REG_DMACSR1 : PLX_REG_DMACSR0) +#define PLX_REG_DMACSR0 0x00a8 +#define PLX_REG_DMACSR1 0x00a9 + #define PLX_DMA_EN_BIT 0x1 /* enable dma channel */ #define PLX_DMA_START_BIT 0x2 /* start dma transfer */ #define PLX_DMA_ABORT_BIT 0x4 /* abort dma transfer */ #define PLX_CLEAR_DMA_INTR_BIT 0x8 /* clear dma interrupt */ #define PLX_DMA_DONE_BIT 0x10 /* transfer done status bit */ -#define PLX_DMA0_THRESHOLD_REG 0xb0 /* command status register */ +/* DMA Threshold Register */ +#define PLX_REG_DMATHR 0x00b0 + +/* + * Messaging Queue Registers OPLFIS, OPLFIM, IQP, OQP, MQCR, QBAR, IFHPR, + * IFTPR, IPHPR, IPTPR, OFHPR, OFTPR, OPHPR, OPTPR, and QSR have been omitted. + * They are used by the I2O feature. (IQP and OQP occupy the usual offsets of + * the MBOX0 and MBOX1 registers if the I2O feature is enabled, but MBOX0 and + * MBOX1 are accessible via alternative offsets. + */ + +/* Queue Status/Control Register */ +#define PLX_REG_QSR 0x00e8 + +/* Value of QSR after reset - disables I2O feature completely. */ +#define PLX_QSR_VALUE_AFTER_RESET 0x00000050 /* * Accesses near the end of memory can cause the PLX chip @@ -301,10 +377,7 @@ static inline int plx9080_abort_dma(void __iomem *iobase, unsigned int channel) const int timeout = 10000; unsigned int i; - if (channel) - dma_cs_addr = iobase + PLX_DMA1_CS_REG; - else - dma_cs_addr = iobase + PLX_DMA0_CS_REG; + dma_cs_addr = iobase + PLX_REG_DMACSR(channel); /* abort dma transfer if necessary */ dma_status = readb(dma_cs_addr); diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 0990f62..236f6ad 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -1175,7 +1175,7 @@ static void rtd_reset(struct comedi_device *dev) writel(0, dev->mmio + LAS0_BOARD_RESET); usleep_range(100, 1000); /* needed? */ - writel(0, devpriv->lcfg + PLX_INTRCS_REG); + writel(0, devpriv->lcfg + PLX_REG_INTCSR); writew(0, dev->mmio + LAS0_IT); writew(~0, dev->mmio + LAS0_CLEAR); readw(dev->mmio + LAS0_CLEAR); @@ -1316,7 +1316,7 @@ static int rtd_auto_attach(struct comedi_device *dev, devpriv->fifosz = ret; if (dev->irq) - writel(ICS_PIE | ICS_PLIE, devpriv->lcfg + PLX_INTRCS_REG); + writel(ICS_PIE | ICS_PLIE, devpriv->lcfg + PLX_REG_INTCSR); return 0; } -- cgit v1.1 From be13e14e31c6ce247fa4d6635f53d9755a545d4b Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:06 +0100 Subject: staging: comedi: drivers: re-do macros for PLX PCI 9080 LASxRR values Rename the macros for the PLX PCI 9080 LAS0RR and LAS1RR registers in "plx9080.h", using the prefix `PLX_LASRR_`. Make use of the `BIT(x)` and `GENMASK(h,l)` macros to define the values. Define a macro `PLX_LASRR_PREFETCH` for the "prefetchable memory" bit in this register, and define a macro `PLX_LASRR_MLOC_MASK` to mask the PCI memory location control bits. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 4 ++-- drivers/staging/comedi/drivers/plx9080.h | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index d9468db..59d81e8 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -4004,13 +4004,13 @@ static int auto_attach(struct comedi_device *dev, /* figure out what local addresses are */ local_range = readl(devpriv->plx9080_iobase + PLX_REG_LAS0RR) & - LRNG_MEM_MASK; + PLX_LASRR_MEM_MASK; local_decode = readl(devpriv->plx9080_iobase + PLX_REG_LAS0BA) & local_range & LMAP_MEM_MASK; devpriv->local0_iobase = ((uint32_t)devpriv->main_phys_iobase & ~local_range) | local_decode; local_range = readl(devpriv->plx9080_iobase + PLX_REG_LAS1RR) & - LRNG_MEM_MASK; + PLX_LASRR_MEM_MASK; local_decode = readl(devpriv->plx9080_iobase + PLX_REG_LAS1BA) & local_range & LMAP_MEM_MASK; devpriv->local1_iobase = ((uint32_t)devpriv->dio_counter_phys_iobase & diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 92d2480..8788117 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -54,14 +54,16 @@ struct plx_dma_desc { /* Local Address Space 1 Range Register */ #define PLX_REG_LAS1RR 0x00f0 -#define LRNG_IO 0x00000001 /* Map to: 1=I/O, 0=Mem */ -#define LRNG_ANY32 0x00000000 /* Locate anywhere in 32 bit */ -#define LRNG_LT1MB 0x00000002 /* Locate in 1st meg */ -#define LRNG_ANY64 0x00000004 /* Locate anywhere in 64 bit */ -/* bits that specify range for memory io */ -#define LRNG_MEM_MASK 0xfffffff0 -/* bits that specify range for normal io */ -#define LRNG_IO_MASK 0xfffffffc +#define PLX_LASRR_IO BIT(0) /* Map to: 1=I/O, 0=Mem */ +#define PLX_LASRR_ANY32 (BIT(1) * 0) /* Locate anywhere in 32 bit */ +#define PLX_LASRR_LT1MB (BIT(1) * 1) /* Locate in 1st meg */ +#define PLX_LASRR_ANY64 (BIT(1) * 2) /* Locate anywhere in 64 bit */ +#define PLX_LASRR_MLOC_MASK GENMASK(2, 1) /* Memory location bits */ +#define PLX_LASRR_PREFETCH BIT(3) /* Memory is prefetchable */ +/* bits that specify range for memory space decode bits */ +#define PLX_LASRR_MEM_MASK GENMASK(31, 4) +/* bits that specify range for i/o space decode bits */ +#define PLX_LASRR_IO_MASK GENMASK(31, 2) /* Local Address Space 0 Local Base Address (Remap) Register */ #define PLX_REG_LAS0BA 0x0004 -- cgit v1.1 From 5eaa593dbf4830cb7e2513dbbcf5bbb274da0ccd Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:07 +0100 Subject: staging: comedi: drivers: re-do macros for PLX PCI 9080 LASxBA values Replace the existing macros in "plx9080.h" that define values for the LAS0BA and LAS1BA registers. Use the prefix `PLX_LASBA_` for the macros. Make use of the `BIT(x)` and `GENMASK(h,l)` macros to define the macros. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 4 ++-- drivers/staging/comedi/drivers/plx9080.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 59d81e8..f997c1f 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -4006,13 +4006,13 @@ static int auto_attach(struct comedi_device *dev, local_range = readl(devpriv->plx9080_iobase + PLX_REG_LAS0RR) & PLX_LASRR_MEM_MASK; local_decode = readl(devpriv->plx9080_iobase + PLX_REG_LAS0BA) & - local_range & LMAP_MEM_MASK; + local_range & PLX_LASBA_MEM_MASK; devpriv->local0_iobase = ((uint32_t)devpriv->main_phys_iobase & ~local_range) | local_decode; local_range = readl(devpriv->plx9080_iobase + PLX_REG_LAS1RR) & PLX_LASRR_MEM_MASK; local_decode = readl(devpriv->plx9080_iobase + PLX_REG_LAS1BA) & - local_range & LMAP_MEM_MASK; + local_range & PLX_LASBA_MEM_MASK; devpriv->local1_iobase = ((uint32_t)devpriv->dio_counter_phys_iobase & ~local_range) | local_decode; diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 8788117..140135c 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -70,11 +70,11 @@ struct plx_dma_desc { /* Local Address Space 1 Local Base Address (Remap) Register */ #define PLX_REG_LAS1BA 0x00f4 -#define LMAP_EN 0x00000001 /* Enable slave decode */ -/* bits that specify decode for memory io */ -#define LMAP_MEM_MASK 0xfffffff0 -/* bits that specify decode bits for normal io */ -#define LMAP_IO_MASK 0xfffffffc +#define PLX_LASBA_EN BIT(0) /* Enable slave decode */ +/* bits that specify local base address for memory space */ +#define PLX_LASBA_MEM_MASK GENMASK(31, 4) +/* bits that specify local base address for i/o space */ +#define PLX_LASBA_IO_MASK GENMASK(31, 2) /* Mode/Arbitration Register */ #define PLX_REG_MARBR 0x0008 -- cgit v1.1 From b5dcdceafa750e933abdf4a7a1be097ccab8fcc7 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:08 +0100 Subject: staging: comedi: drivers: re-do PLX PCI 9080 MARBR register values Replace `enum marb_bits` in "plx9080.h" with a bunch of macros defining values for the MARBR and DMAARB registers (which are the same Mode/Arbitation register at two different offsets). Use the prefix `PLX_MARBR_` for the macros. Make use of the `BIT(x)` and `GENMASK(h,l)` macros to define the values. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/plx9080.h | 60 +++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 140135c..0bcdbad 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -81,26 +81,46 @@ struct plx_dma_desc { /* DMA Arbitration Register (alias of MARBR). */ #define PLX_REG_DMAARB 0x00ac -enum marb_bits { - MARB_LLT_MASK = 0x000000ff, /* Local Bus Latency Timer */ - MARB_LPT_MASK = 0x0000ff00, /* Local Bus Pause Timer */ - MARB_LTEN = 0x00010000, /* Latency Timer Enable */ - MARB_LPEN = 0x00020000, /* Pause Timer Enable */ - MARB_BREQ = 0x00040000, /* Local Bus BREQ Enable */ - MARB_DMA_PRIORITY_MASK = 0x00180000, - /* local bus direct slave give up bus mode */ - MARB_LBDS_GIVE_UP_BUS_MODE = 0x00200000, - /* direct slave LLOCKo# enable */ - MARB_DS_LLOCK_ENABLE = 0x00400000, - MARB_PCI_REQUEST_MODE = 0x00800000, - MARB_PCIV21_MODE = 0x01000000, /* pci specification v2.1 mode */ - MARB_PCI_READ_NO_WRITE_MODE = 0x02000000, - MARB_PCI_READ_WITH_WRITE_FLUSH_MODE = 0x04000000, - /* gate local bus latency timer with BREQ */ - MARB_GATE_TIMER_WITH_BREQ = 0x08000000, - MARB_PCI_READ_NO_FLUSH_MODE = 0x10000000, - MARB_USE_SUBSYSTEM_IDS = 0x20000000, -}; +/* Local Bus Latency Timer */ +#define PLX_MARBR_LT(x) (BIT(0) * ((x) & 0xff)) +#define PLX_MARBR_LT_MASK GENMASK(7, 0) +#define PLX_MARBR_LT_SHIFT 0 +/* Local Bus Pause Timer */ +#define PLX_MARBR_PT(x) (BIT(8) * ((x) & 0xff)) +#define PLX_MARBR_PT_MASK GENMASK(15, 8) +#define PLX_MARBR_PT_SHIFT 8 +/* Local Bus Latency Timer Enable */ +#define PLX_MARBR_LTEN BIT(16) +/* Local Bus Pause Timer Enable */ +#define PLX_MARBR_PTEN BIT(17) +/* Local Bus BREQ Enable */ +#define PLX_MARBR_BREQEN BIT(18) +/* DMA Channel Priority */ +#define PLX_MARBR_PRIO_ROT (BIT(19) * 0) /* Rotational priority */ +#define PLX_MARBR_PRIO_DMA0 (BIT(19) * 1) /* DMA channel 0 has priority */ +#define PLX_MARBR_PRIO_DMA1 (BIT(19) * 2) /* DMA channel 1 has priority */ +#define PLX_MARBR_PRIO_MASK GENMASK(20, 19) +/* Local Bus Direct Slave Give Up Bus Mode */ +#define PLX_MARBR_DSGUBM BIT(21) +/* Direct Slace LLOCKo# Enable */ +#define PLX_MARBR_DSLLOCKOEN BIT(22) +/* PCI Request Mode */ +#define PLX_MARBR_PCIREQM BIT(23) +/* PCI Specification v2.1 Mode */ +#define PLX_MARBR_PCIV21M BIT(24) +/* PCI Read No Write Mode */ +#define PLX_MARBR_PCIRNWM BIT(25) +/* PCI Read with Write Flush Mode */ +#define PLX_MARBR_PCIRWFM BIT(26) +/* Gate Local Bus Latency Timer with BREQ */ +#define PLX_MARBR_GLTBREQ BIT(27) +/* PCI Read No Flush Mode */ +#define PLX_MARBR_PCIRNFM BIT(28) +/* + * Make reads from PCI Configuration register 0 return Subsystem ID and + * Subsystem Vendor ID instead of Device ID and Vendor ID + */ +#define PLX_MARBR_SUBSYSIDS BIT(29) /* Big/Little Endian Descriptor Register */ #define PLX_REG_BIGEND 0x000c -- cgit v1.1 From a9c254a763e4641d41c4e4b7665d979180c8af27 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:09 +0100 Subject: staging: comedi: drivers: re-do PLX PCI 9080 BIGEND register values Replace `enum bigend_bits` in "plx9080.h" with a bunch of macros defining values for the BIGEND register. Use the prefix `PLX_BIGEND_` for the macro names. Make use of the `BIT(x)` and `GENMASK(h,l)` macros to define the values. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 2 +- drivers/staging/comedi/drivers/gsc_hpdi.c | 2 +- drivers/staging/comedi/drivers/plx9080.h | 33 +++++++++++++++------------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index f997c1f..4a8e88a 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1294,7 +1294,7 @@ static void init_plx9080(struct comedi_device *dev) readl(devpriv->plx9080_iobase + PLX_REG_CNTRL); #ifdef __BIG_ENDIAN - bits = BIGEND_DMA0 | BIGEND_DMA1; + bits = PLX_BIGEND_DMA0 | PLX_BIGEND_DMA1; #else bits = 0; #endif diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index e2831e1..536bebe 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -547,7 +547,7 @@ static void gsc_hpdi_init_plx9080(struct comedi_device *dev) void __iomem *plx_iobase = devpriv->plx9080_mmio; #ifdef __BIG_ENDIAN - bits = BIGEND_DMA0 | BIGEND_DMA1; + bits = PLX_BIGEND_DMA0 | PLX_BIGEND_DMA1; #else bits = 0; #endif diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 0bcdbad..84dd366 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -125,21 +125,24 @@ struct plx_dma_desc { /* Big/Little Endian Descriptor Register */ #define PLX_REG_BIGEND 0x000c -enum bigend_bits { - /* use big endian ordering for configuration register accesses */ - BIGEND_CONFIG = 0x1, - BIGEND_DIRECT_MASTER = 0x2, - BIGEND_DIRECT_SLAVE_LOCAL0 = 0x4, - BIGEND_ROM = 0x8, - /* - * use byte lane consisting of most significant bits instead of - * least significant - */ - BIGEND_BYTE_LANE = 0x10, - BIGEND_DIRECT_SLAVE_LOCAL1 = 0x20, - BIGEND_DMA1 = 0x40, - BIGEND_DMA0 = 0x80, -}; +/* Configuration Register Big Endian Mode */ +#define PLX_BIGEND_CONFIG BIT(0) +/* Direct Master Big Endian Mode */ +#define PLX_BIGEND_DM BIT(1) +/* Direct Slave Address Space 0 Big Endian Mode */ +#define PLX_BIGEND_DSAS0 BIT(2) +/* Direct Slave Expansion ROM Big Endian Mode */ +#define PLX_BIGEND_EROM BIT(3) +/* Big Endian Byte Lane Mode - use most significant byte lanes */ +#define PLX_BIGEND_BEBLM BIT(4) +/* Direct Slave Address Space 1 Big Endian Mode */ +#define PLX_BIGEND_DSAS1 BIT(5) +/* DMA Channel 1 Big Endian Mode */ +#define PLX_BIGEND_DMA1 BIT(6) +/* DMA Channel 0 Big Endian Mode */ +#define PLX_BIGEND_DMA0 BIT(7) +/* DMA Channel N Big Endian Mode (N <= 1) */ +#define PLX_BIGEND_DMA(n) ((n) ? PLX_BIGEND_DMA1 : PLX_BIGEND_DMA0) /* ** Note: The Expansion ROM stuff is only relevant to the PC environment. -- cgit v1.1 From 1ddb95d3c4820644df28ba1e5251e87dd46e4830 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:10 +0100 Subject: staging: comedi: drivers: re-do PLX PCI 9080 LBRDx register values Replace the existing macros in "plx9080.h" that define values for the LBRD0 and LBRD1 registers. Use the prefix `PLX_LBRD_` for macros that apply to both registers, `PLX_LBRD0_` for macros that apply only to the LBRD0 register, and `PLX_LBRD1_` for macros that apply only to the LBRD1 register. Make use of the `BIT(x)` and `GENMASK(h,l)` macros to define the values. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/plx9080.h | 80 ++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 84dd366..93b2e89 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -159,30 +159,62 @@ struct plx_dma_desc { /* Local Address Space 1 Bus Region Descriptor Register */ #define PLX_REG_LBRD1 0x00f8 -#define RGN_WIDTH 0x00000002 /* Local bus width bits */ -#define RGN_8BITS 0x00000000 /* 08 bit Local Bus */ -#define RGN_16BITS 0x00000001 /* 16 bit Local Bus */ -#define RGN_32BITS 0x00000002 /* 32 bit Local Bus */ -#define RGN_MWS 0x0000003C /* Memory Access Wait States */ -#define RGN_0MWS 0x00000000 -#define RGN_1MWS 0x00000004 -#define RGN_2MWS 0x00000008 -#define RGN_3MWS 0x0000000C -#define RGN_4MWS 0x00000010 -#define RGN_6MWS 0x00000018 -#define RGN_8MWS 0x00000020 -#define RGN_MRE 0x00000040 /* Memory Space Ready Input Enable */ -#define RGN_MBE 0x00000080 /* Memory Space Bterm Input Enable */ -#define RGN_READ_PREFETCH_DISABLE 0x00000100 -#define RGN_ROM_PREFETCH_DISABLE 0x00000200 -#define RGN_READ_PREFETCH_COUNT_ENABLE 0x00000400 -#define RGN_RWS 0x003C0000 /* Expn ROM Wait States */ -#define RGN_RRE 0x00400000 /* ROM Space Ready Input Enable */ -#define RGN_RBE 0x00800000 /* ROM Space Bterm Input Enable */ -#define RGN_MBEN 0x01000000 /* Memory Space Burst Enable */ -#define RGN_RBEN 0x04000000 /* ROM Space Burst Enable */ -#define RGN_THROT 0x08000000 /* De-assert TRDY when FIFO full */ -#define RGN_TRD 0xF0000000 /* Target Ready Delay /8 */ +/* Memory Space Local Bus Width */ +#define PLX_LBRD_MSWIDTH8 (BIT(0) * 0) /* 8 bits wide */ +#define PLX_LBRD_MSWIDTH16 (BIT(0) * 1) /* 16 bits wide */ +#define PLX_LBRD_MSWIDTH32 (BIT(0) * 2) /* 32 bits wide */ +#define PLX_LBRD_MSWIDTH32A (BIT(0) * 3) /* 32 bits wide */ +#define PLX_LBRD_MSWIDTH_MASK GENMASK(1, 0) +#define PLX_LBRD_MSWIDTH_SHIFT 0 +/* Memory Space Internal Wait States */ +#define PLX_LBRD_MSIWS(x) (BIT(2) * ((x) & 0xf)) +#define PLX_LBRD_MSIWS_MASK GENMASK(5, 2) +#define PLX_LBRD_MSIWS_SHIFT 2 +/* Memory Space Ready Input Enable */ +#define PLX_LBRD_MSREADYIEN BIT(6) +/* Memory Space BTERM# Input Enable */ +#define PLX_LBRD_MSBTERMIEN BIT(7) +/* Memory Space 0 Prefetch Disable (LBRD0 only) */ +#define PLX_LBRD0_MSPREDIS BIT(8) +/* Memory Space 1 Burst Enable (LBRD1 only) */ +#define PLX_LBRD1_MSBURSTEN BIT(8) +/* Expansion ROM Space Prefetch Disable (LBRD0 only) */ +#define PLX_LBRD0_EROMPREDIS BIT(9) +/* Memory Space 1 Prefetch Disable (LBRD1 only) */ +#define PLX_LBRD1_MSPREDIS BIT(9) +/* Read Prefetch Count Enable */ +#define PLX_LBRD_RPFCOUNTEN BIT(10) +/* Prefetch Counter */ +#define PLX_LBRD_PFCOUNT(x) (BIT(11) * ((x) & 0xf)) +#define PLX_LBRD_PFCOUNT_MASK GENMASK(14, 11) +#define PLX_LBRD_PFCOUNT_SHIFT 11 +/* Expansion ROM Space Local Bus Width (LBRD0 only) */ +#define PLX_LBRD0_EROMWIDTH8 (BIT(16) * 0) /* 8 bits wide */ +#define PLX_LBRD0_EROMWIDTH16 (BIT(16) * 1) /* 16 bits wide */ +#define PLX_LBRD0_EROMWIDTH32 (BIT(16) * 2) /* 32 bits wide */ +#define PLX_LBRD0_EROMWIDTH32A (BIT(16) * 3) /* 32 bits wide */ +#define PLX_LBRD0_EROMWIDTH_MASK GENMASK(17, 16) +#define PLX_LBRD0_EROMWIDTH_SHIFT 16 +/* Expansion ROM Space Internal Wait States (LBRD0 only) */ +#define PLX_LBRD0_EROMIWS(x) (BIT(18) * ((x) & 0xf)) +#define PLX_LBRD0_EROMIWS_MASK GENMASK(21, 18) +#define PLX_LBRD0_EROMIWS_SHIFT 18 +/* Expansion ROM Space Ready Input Enable (LBDR0 only) */ +#define PLX_LBRD0_EROMREADYIEN BIT(22) +/* Expansion ROM Space BTERM# Input Enable (LBRD0 only) */ +#define PLX_LBRD0_EROMBTERMIEN BIT(23) +/* Memory Space 0 Burst Enable (LBRD0 only) */ +#define PLX_LBRD0_MSBURSTEN BIT(24) +/* Extra Long Load From Serial EEPROM (LBRD0 only) */ +#define PLX_LBRD0_EELONGLOAD BIT(25) +/* Expansion ROM Space Burst Enable (LBRD0 only) */ +#define PLX_LBRD0_EROMBURSTEN BIT(26) +/* Direct Slave PCI Write Mode - assert TRDY# when FIFO full (LBRD0 only) */ +#define PLX_LBRD0_DSWMTRDY BIT(27) +/* PCI Target Retry Delay Clocks / 8 (LBRD0 only) */ +#define PLX_LBRD0_TRDELAY(x) (BIT(28) * ((x) & 0xF)) +#define PLX_LBRD0_TRDELAY_MASK GENMASK(31, 28) +#define PLX_LBRD0_TRDELAY_SHIFT 28 /* Local Range Register for Direct Master to PCI */ #define PLX_REG_DMRR 0x001c -- cgit v1.1 From e0045472e0d9a398d68b8570b748a49a091b12fa Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:11 +0100 Subject: staging: comedi: drivers: re-do PLX PCI 9080 DMPBAM register values Replace the existing macros in "plx9080.h" that define values for the DMPBAM register. Use the prefix `PLX_DMPBAM_` for the macros. Make use of the `BIT(x)` and `GENMASK(h,l)` macros to define the values. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/plx9080.h | 48 ++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 93b2e89..ab90837 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -228,20 +228,40 @@ struct plx_dma_desc { /* PCI Base Address (Remap) Register for Direct Master to PCI Memory */ #define PLX_REG_DMPBAM 0x0028 -#define DMM_MAE 0x00000001 /* Direct Mstr Memory Acc Enable */ -#define DMM_IAE 0x00000002 /* Direct Mstr I/O Acc Enable */ -#define DMM_LCK 0x00000004 /* LOCK Input Enable */ -#define DMM_PF4 0x00000008 /* Prefetch 4 Mode Enable */ -#define DMM_THROT 0x00000010 /* Assert IRDY when read FIFO full */ -#define DMM_PAF0 0x00000000 /* Programmable Almost fill level */ -#define DMM_PAF1 0x00000020 /* Programmable Almost fill level */ -#define DMM_PAF2 0x00000040 /* Programmable Almost fill level */ -#define DMM_PAF3 0x00000060 /* Programmable Almost fill level */ -#define DMM_PAF4 0x00000080 /* Programmable Almost fill level */ -#define DMM_PAF5 0x000000A0 /* Programmable Almost fill level */ -#define DMM_PAF6 0x000000C0 /* Programmable Almost fill level */ -#define DMM_PAF7 0x000000D0 /* Programmable Almost fill level */ -#define DMM_MAP 0xFFFF0000 /* Remap Address Bits */ +/* Direct Master Memory Access Enable */ +#define PLX_DMPBAM_MEMACCEN BIT(0) +/* Direct Master I/O Access Enable */ +#define PLX_DMPBAM_IOACCEN BIT(1) +/* LLOCK# Input Enable */ +#define PLX_DMPBAM_LLOCKIEN BIT(2) +/* Direct Master Read Prefetch Size Control (bits 12, 3) */ +#define PLX_DMPBAM_RPSIZECONT ((BIT(12) * 0) | (BIT(3) * 0)) +#define PLX_DMPBAM_RPSIZE4 ((BIT(12) * 0) | (BIT(3) * 1)) +#define PLX_DMPBAM_RPSIZE8 ((BIT(12) * 1) | (BIT(3) * 0)) +#define PLX_DMPBAM_RPSIZE16 ((BIT(12) * 1) | (BIT(3) * 1)) +#define PLX_DMPBAM_RPSIZE_MASK (BIT(12) | BIT(3)) +/* Direct Master PCI Read Mode - deassert IRDY when FIFO full */ +#define PLX_DMPBAM_RMIRDY BIT(4) +/* Programmable Almost Full Level (bits 10, 8:5) */ +#define PLX_DMPBAM_PAFL(x) ((BIT(10) * !!((x) & 0x10)) | \ + (BIT(5) * ((x) & 0xf))) +#define PLX_DMPBAM_TO_PAFL(v) ((((BIT(10) & (v)) >> 1) | \ + (GENMASK(8, 5) & (v))) >> 5) +#define PLX_DMPBAM_PAFL_MASK (BIT(10) | GENMASK(8, 5)) +/* Write And Invalidate Mode */ +#define PLX_DMPBAM_WIM BIT(9) +/* Direct Master Prefetch Limit */ +#define PLX_DBPBAM_PFLIMIT BIT(11) +/* I/O Remap Select */ +#define PLX_DMPBAM_IOREMAPSEL BIT(13) +/* Direct Master Write Delay */ +#define PLX_DMPBAM_WDELAYNONE (BIT(14) * 0) +#define PLX_DMPBAM_WDELAY4 (BIT(14) * 1) +#define PLX_DMPBAM_WDELAY8 (BIT(14) * 2) +#define PLX_DMPBAM_WDELAY16 (BIT(14) * 3) +#define PLX_DMPBAM_WDELAY_MASK GENMASK(15, 14) +/* Remap of Local-to-PCI Space Into PCI Address Space */ +#define PLX_DMPBAM_REMAP_MASK GENMASK(31, 16) /* PCI Configuration Address Register for Direct Master to PCI IO/CFG */ #define PLX_REG_DMCFGA 0x002c -- cgit v1.1 From ed5df5db92b3148a94bfa9b025a8e21c6a9518e6 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:12 +0100 Subject: staging: comedi: drivers: re-do PLX PCI 9080 DMCFGA register values Replace the existing macros in "plx9080.h" that define values for the DMCFGA register. Use the prefix `PLX_DMCFGA_` for the macros. Make use of the `BIT(x)` and `GENMASK(h,l)` macros to define the values. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/plx9080.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index ab90837..e544327 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -266,13 +266,28 @@ struct plx_dma_desc { /* PCI Configuration Address Register for Direct Master to PCI IO/CFG */ #define PLX_REG_DMCFGA 0x002c -#define CAR_CT0 0x00000000 /* Config Type 0 */ -#define CAR_CT1 0x00000001 /* Config Type 1 */ -#define CAR_REG 0x000000FC /* Register Number Bits */ -#define CAR_FUN 0x00000700 /* Function Number Bits */ -#define CAR_DEV 0x0000F800 /* Device Number Bits */ -#define CAR_BUS 0x00FF0000 /* Bus Number Bits */ -#define CAR_CFG 0x80000000 /* Config Spc Access Enable */ +/* Congiguration Type */ +#define PLX_DMCFGA_TYPE0 (BIT(0) * 0) +#define PLX_DMCFGA_TYPE1 (BIT(0) * 1) +#define PLX_DMCFGA_TYPE_MASK GENMASK(1, 0) +/* Register Number */ +#define PLX_DMCFGA_REGNUM(x) (BIT(2) * ((x) & 0x3f)) +#define PLX_DMCFGA_REGNUM_MASK GENMASK(7, 2) +#define PLX_DMCFGA_REGNUM_SHIFT 2 +/* Function Number */ +#define PLX_DMCFGA_FUNCNUM(x) (BIT(8) * ((x) & 0x7)) +#define PLX_DMCFGA_FUNCNUM_MASK GENMASK(10, 8) +#define PLX_DMCFGA_FUNCNUM_SHIFT 8 +/* Device Number */ +#define PLX_DMCFGA_DEVNUM(x) (BIT(11) * ((x) & 0x1f)) +#define PLX_DMCFGA_DEVNUM_MASK GENMASK(15, 11) +#define PLX_DMCFGA_DEVNUM_SHIFT 11 +/* Bus Number */ +#define PLX_DMCFGA_BUSNUM(x) (BIT(16) * ((x) & 0xff)) +#define PLX_DMCFGA_BUSNUM_MASK GENMASK(23, 16) +#define PLX_DMCFGA_BUSNUM_SHIFT 16 +/* Configuration Enable */ +#define PLX_DMCFGA_CONFIGEN BIT(31) /* * Mailbox Register N (N <= 7) -- cgit v1.1 From 9dc53852b10888f9032baf78d672b45ab4d791fe Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:13 +0100 Subject: staging: comedi: drivers: re-do PLX PCI 9080 INTCSR register values Replace the existing macros in "plx9080.h" that define values for the INTCSR register. Use the prefix `PLX_INTCSR_` for the macros. Make use of the `BIT(x)` and `GENMASK(h,l)` macros to define the values. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 14 +++-- drivers/staging/comedi/drivers/gsc_hpdi.c | 14 +++-- drivers/staging/comedi/drivers/plx9080.h | 91 ++++++++++++++++++++-------- drivers/staging/comedi/drivers/rtd520.c | 3 +- 4 files changed, 83 insertions(+), 39 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 4a8e88a..6b3f4dc 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1336,8 +1336,9 @@ static void init_plx9080(struct comedi_device *dev) /* enable interrupts on plx 9080 */ devpriv->plx_intcsr_bits |= - ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE | - ICS_DMA0_E | ICS_DMA1_E; + PLX_INTCSR_LSEABORTEN | PLX_INTCSR_LSEPARITYEN | PLX_INTCSR_PIEN | + PLX_INTCSR_PLIEN | PLX_INTCSR_PABORTIEN | PLX_INTCSR_LIOEN | + PLX_INTCSR_DMA0IEN | PLX_INTCSR_DMA1IEN; writel(devpriv->plx_intcsr_bits, devpriv->plx9080_iobase + PLX_REG_INTCSR); } @@ -2836,7 +2837,7 @@ static void handle_ai_interrupt(struct comedi_device *dev, /* spin lock makes sure no one else changes plx dma control reg */ spin_lock_irqsave(&dev->spinlock, flags); dma1_status = readb(devpriv->plx9080_iobase + PLX_REG_DMACSR1); - if (plx_status & ICS_DMA1_A) { /* dma chan 1 interrupt */ + if (plx_status & PLX_INTCSR_DMA1IA) { /* dma chan 1 interrupt */ writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, devpriv->plx9080_iobase + PLX_REG_DMACSR1); @@ -3014,7 +3015,7 @@ static void handle_ao_interrupt(struct comedi_device *dev, /* spin lock makes sure no one else changes plx dma control reg */ spin_lock_irqsave(&dev->spinlock, flags); dma0_status = readb(devpriv->plx9080_iobase + PLX_REG_DMACSR0); - if (plx_status & ICS_DMA0_A) { /* dma chan 0 interrupt */ + if (plx_status & PLX_INTCSR_DMA0IA) { /* dma chan 0 interrupt */ if ((dma0_status & PLX_DMA_EN_BIT) && !(dma0_status & PLX_DMA_DONE_BIT)) { writeb(PLX_DMA_EN_BIT | PLX_CLEAR_DMA_INTR_BIT, @@ -3067,8 +3068,9 @@ static irqreturn_t handle_interrupt(int irq, void *d) handle_ai_interrupt(dev, status, plx_status); handle_ao_interrupt(dev, status, plx_status); - /* clear possible plx9080 interrupt sources */ - if (plx_status & ICS_LDIA) { /* clear local doorbell interrupt */ + /* clear possible plx9080 interrupt sources */ + if (plx_status & PLX_INTCSR_LDBIA) { + /* clear local doorbell interrupt */ plx_bits = readl(devpriv->plx9080_iobase + PLX_REG_L2PDBELL); writel(plx_bits, devpriv->plx9080_iobase + PLX_REG_L2PDBELL); } diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 536bebe..e288798 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -199,7 +199,8 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) return IRQ_NONE; plx_status = readl(devpriv->plx9080_mmio + PLX_REG_INTCSR); - if ((plx_status & (ICS_DMA0_A | ICS_DMA1_A | ICS_LIA)) == 0) + if ((plx_status & + (PLX_INTCSR_DMA0IA | PLX_INTCSR_DMA1IA | PLX_INTCSR_PLIA)) == 0) return IRQ_NONE; hpdi_intr_status = readl(dev->mmio + INTERRUPT_STATUS_REG); @@ -211,7 +212,7 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) /* spin lock makes sure no one else changes plx dma control reg */ spin_lock_irqsave(&dev->spinlock, flags); dma0_status = readb(devpriv->plx9080_mmio + PLX_REG_DMACSR0); - if (plx_status & ICS_DMA0_A) { + if (plx_status & PLX_INTCSR_DMA0IA) { /* dma chan 0 interrupt */ writeb((dma0_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, devpriv->plx9080_mmio + PLX_REG_DMACSR0); @@ -224,7 +225,7 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) /* spin lock makes sure no one else changes plx dma control reg */ spin_lock_irqsave(&dev->spinlock, flags); dma1_status = readb(devpriv->plx9080_mmio + PLX_REG_DMACSR1); - if (plx_status & ICS_DMA1_A) { + if (plx_status & PLX_INTCSR_DMA1IA) { /* XXX */ /* dma chan 1 interrupt */ writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, devpriv->plx9080_mmio + PLX_REG_DMACSR1); @@ -232,7 +233,7 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) spin_unlock_irqrestore(&dev->spinlock, flags); /* clear possible plx9080 interrupt sources */ - if (plx_status & ICS_LDIA) { + if (plx_status & PLX_INTCSR_LDBIA) { /* clear local doorbell interrupt */ plx_bits = readl(devpriv->plx9080_mmio + PLX_REG_L2PDBELL); writel(plx_bits, devpriv->plx9080_mmio + PLX_REG_L2PDBELL); @@ -533,8 +534,9 @@ static int gsc_hpdi_init(struct comedi_device *dev) /* enable interrupts */ plx_intcsr_bits = - ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE | - ICS_DMA0_E; + PLX_INTCSR_LSEABORTEN | PLX_INTCSR_LSEPARITYEN | PLX_INTCSR_PIEN | + PLX_INTCSR_PLIEN | PLX_INTCSR_PABORTIEN | PLX_INTCSR_LIOEN | + PLX_INTCSR_DMA0IEN; writel(plx_intcsr_bits, devpriv->plx9080_mmio + PLX_REG_INTCSR); return 0; diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index e544327..e9f1b9c 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -321,32 +321,71 @@ struct plx_dma_desc { /* Interrupt Control/Status Register */ #define PLX_REG_INTCSR 0x0068 -#define ICS_AERR 0x00000001 /* Assert LSERR on ABORT */ -#define ICS_PERR 0x00000002 /* Assert LSERR on Parity Error */ -#define ICS_SERR 0x00000004 /* Generate PCI SERR# */ -#define ICS_MBIE 0x00000008 /* mailbox interrupt enable */ -#define ICS_PIE 0x00000100 /* PCI Interrupt Enable */ -#define ICS_PDIE 0x00000200 /* PCI Doorbell Interrupt Enable */ -#define ICS_PAIE 0x00000400 /* PCI Abort Interrupt Enable */ -#define ICS_PLIE 0x00000800 /* PCI Local Int Enable */ -#define ICS_RAE 0x00001000 /* Retry Abort Enable */ -#define ICS_PDIA 0x00002000 /* PCI Doorbell Interrupt Active */ -#define ICS_PAIA 0x00004000 /* PCI Abort Interrupt Active */ -#define ICS_LIA 0x00008000 /* Local Interrupt Active */ -#define ICS_LIE 0x00010000 /* Local Interrupt Enable */ -#define ICS_LDIE 0x00020000 /* Local Doorbell Int Enable */ -#define ICS_DMA0_E 0x00040000 /* DMA #0 Interrupt Enable */ -#define ICS_DMA1_E 0x00080000 /* DMA #1 Interrupt Enable */ -#define ICS_LDIA 0x00100000 /* Local Doorbell Int Active */ -#define ICS_DMA0_A 0x00200000 /* DMA #0 Interrupt Active */ -#define ICS_DMA1_A 0x00400000 /* DMA #1 Interrupt Active */ -#define ICS_BIA 0x00800000 /* BIST Interrupt Active */ -#define ICS_TA_DM 0x01000000 /* Target Abort - Direct Master */ -#define ICS_TA_DMA0 0x02000000 /* Target Abort - DMA #0 */ -#define ICS_TA_DMA1 0x04000000 /* Target Abort - DMA #1 */ -#define ICS_TA_RA 0x08000000 /* Target Abort - Retry Timeout */ -/* mailbox x is active */ -#define ICS_MBIA(x) (0x10000000 << ((x) & 0x3)) +/* Enable Local Bus LSERR# when PCI Bus Target Abort or Master Abort occurs */ +#define PLX_INTCSR_LSEABORTEN BIT(0) +/* Enable Local Bus LSERR# when PCI parity error occurs */ +#define PLX_INTCSR_LSEPARITYEN BIT(1) +/* Generate PCI Bus SERR# when set to 1 */ +#define PLX_INTCSR_GENSERR BIT(2) +/* Mailbox Interrupt Enable (local bus interrupts on PCI write to MBOX0-3) */ +#define PLX_INTCSR_MBIEN BIT(3) +/* PCI Interrupt Enable */ +#define PLX_INTCSR_PIEN BIT(8) +/* PCI Doorbell Interrupt Enable */ +#define PLX_INTCSR_PDBIEN BIT(9) +/* PCI Abort Interrupt Enable */ +#define PLX_INTCSR_PABORTIEN BIT(10) +/* PCI Local Interrupt Enable */ +#define PLX_INTCSR_PLIEN BIT(11) +/* Retry Abort Enable (for diagnostic purposes only) */ +#define PLX_INTCSR_RAEN BIT(12) +/* PCI Doorbell Interrupt Active (read-only) */ +#define PLX_INTCSR_PDBIA BIT(13) +/* PCI Abort Interrupt Active (read-only) */ +#define PLX_INTCSR_PABORTIA BIT(14) +/* Local Interrupt (LINTi#) Active (read-only) */ +#define PLX_INTCSR_PLIA BIT(15) +/* Local Interrupt Output (LINTo#) Enable */ +#define PLX_INTCSR_LIOEN BIT(16) +/* Local Doorbell Interrupt Enable */ +#define PLX_INTCSR_LDBIEN BIT(17) +/* DMA Channel 0 Interrupt Enable */ +#define PLX_INTCSR_DMA0IEN BIT(18) +/* DMA Channel 1 Interrupt Enable */ +#define PLX_INTCSR_DMA1IEN BIT(19) +/* DMA Channel N Interrupt Enable (N <= 1) */ +#define PLX_INTCSR_DMAIEN(n) ((n) ? PLX_INTCSR_DMA1IEN : PLX_INTCSR_DMA0IEN) +/* Local Doorbell Interrupt Active (read-only) */ +#define PLX_INTCSR_LDBIA BIT(20) +/* DMA Channel 0 Interrupt Active (read-only) */ +#define PLX_INTCSR_DMA0IA BIT(21) +/* DMA Channel 1 Interrupt Active (read-only) */ +#define PLX_INTCSR_DMA1IA BIT(22) +/* DMA Channel N Interrupt Active (N <= 1) (read-only) */ +#define PLX_INTCSR_DMAIA(n) ((n) ? PLX_INTCSR_DMA1IA : PLX_INTCSR_DMA0IA) +/* BIST Interrupt Active (read-only) */ +#define PLX_INTCSR_BISTIA BIT(23) +/* Direct Master Not Bus Master During Master Or Target Abort (read-only) */ +#define PLX_INTCSR_ABNOTDM BIT(24) +/* DMA Channel 0 Not Bus Master During Master Or Target Abort (read-only) */ +#define PLX_INTCSR_ABNOTDMA0 BIT(25) +/* DMA Channel 1 Not Bus Master During Master Or Target Abort (read-only) */ +#define PLX_INTCSR_ABNOTDMA1 BIT(26) +/* DMA Channel N Not Bus Master During Master Or Target Abort (read-only) */ +#define PLX_INTCSR_ABNOTDMA(n) ((n) ? PLX_INTCSR_ABNOTDMA1 \ + : PLX_INTCSR_ABNOTDMA0) +/* Target Abort Not Generated After 256 Master Retries (read-only) */ +#define PLX_INTCSR_ABNOTRETRY BIT(27) +/* PCI Wrote Mailbox 0 (enabled if bit 3 set) (read-only) */ +#define PLX_INTCSR_MB0IA BIT(28) +/* PCI Wrote Mailbox 1 (enabled if bit 3 set) (read-only) */ +#define PLX_INTCSR_MB1IA BIT(29) +/* PCI Wrote Mailbox 2 (enabled if bit 3 set) (read-only) */ +#define PLX_INTCSR_MB2IA BIT(30) +/* PCI Wrote Mailbox 3 (enabled if bit 3 set) (read-only) */ +#define PLX_INTCSR_MB3IA BIT(31) +/* PCI Wrote Mailbox N (N <= 3) (enabled if bit 3 set) (read-only) */ +#define PLX_INTCSR_MBIA(n) BIT(28 + (n)) /* * Serial EEPROM Control, PCI Command Codes, User I/O Control, diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 236f6ad..e00e9c6 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -1316,7 +1316,8 @@ static int rtd_auto_attach(struct comedi_device *dev, devpriv->fifosz = ret; if (dev->irq) - writel(ICS_PIE | ICS_PLIE, devpriv->lcfg + PLX_REG_INTCSR); + writel(PLX_INTCSR_PIEN | PLX_INTCSR_PLIEN, + devpriv->lcfg + PLX_REG_INTCSR); return 0; } -- cgit v1.1 From a3228bc8b7a07e7abf74b8833f3778586e30cb2f Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:14 +0100 Subject: staging: comedi: drivers: re-do PLX PCI 9080 CNTRL register values Replace the existing macros in "plx9080.h" that define values for the CNTRL register. Use the prefix `PLX_CNTRL_` for the macros. Make use of the `BIT(x)` and `GENMASK(h,l)` macros to define the values. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 31 +++++++------- drivers/staging/comedi/drivers/plx9080.h | 63 +++++++++++++++++++++------- 2 files changed, 65 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 6b3f4dc..dfb2ae8 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1614,7 +1614,7 @@ static const int i2c_low_udelay = 10; static void i2c_set_sda(struct comedi_device *dev, int state) { struct pcidas64_private *devpriv = dev->private; - static const int data_bit = CTL_EE_W; + static const int data_bit = PLX_CNTRL_EEWB; void __iomem *plx_control_addr = devpriv->plx9080_iobase + PLX_REG_CNTRL; @@ -1635,7 +1635,7 @@ static void i2c_set_sda(struct comedi_device *dev, int state) static void i2c_set_scl(struct comedi_device *dev, int state) { struct pcidas64_private *devpriv = dev->private; - static const int clock_bit = CTL_USERO; + static const int clock_bit = PLX_CNTRL_USERO; void __iomem *plx_control_addr = devpriv->plx9080_iobase + PLX_REG_CNTRL; @@ -1708,7 +1708,7 @@ static void i2c_write(struct comedi_device *dev, unsigned int address, */ /* make sure we dont send anything to eeprom */ - devpriv->plx_control_bits &= ~CTL_EE_CS; + devpriv->plx_control_bits &= ~PLX_CNTRL_EECS; i2c_stop(dev); i2c_start(dev); @@ -3717,13 +3717,13 @@ static uint16_t read_eeprom(struct comedi_device *dev, uint8_t address) static const int eeprom_udelay = 1; udelay(eeprom_udelay); - devpriv->plx_control_bits &= ~CTL_EE_CLK & ~CTL_EE_CS; + devpriv->plx_control_bits &= ~PLX_CNTRL_EESK & ~PLX_CNTRL_EECS; /* make sure we don't send anything to the i2c bus on 4020 */ - devpriv->plx_control_bits |= CTL_USERO; + devpriv->plx_control_bits |= PLX_CNTRL_USERO; writel(devpriv->plx_control_bits, plx_control_addr); /* activate serial eeprom */ udelay(eeprom_udelay); - devpriv->plx_control_bits |= CTL_EE_CS; + devpriv->plx_control_bits |= PLX_CNTRL_EECS; writel(devpriv->plx_control_bits, plx_control_addr); /* write read command and desired memory address */ @@ -3731,16 +3731,16 @@ static uint16_t read_eeprom(struct comedi_device *dev, uint8_t address) /* set bit to be written */ udelay(eeprom_udelay); if (bitstream & bit) - devpriv->plx_control_bits |= CTL_EE_W; + devpriv->plx_control_bits |= PLX_CNTRL_EEWB; else - devpriv->plx_control_bits &= ~CTL_EE_W; + devpriv->plx_control_bits &= ~PLX_CNTRL_EEWB; writel(devpriv->plx_control_bits, plx_control_addr); /* clock in bit */ udelay(eeprom_udelay); - devpriv->plx_control_bits |= CTL_EE_CLK; + devpriv->plx_control_bits |= PLX_CNTRL_EESK; writel(devpriv->plx_control_bits, plx_control_addr); udelay(eeprom_udelay); - devpriv->plx_control_bits &= ~CTL_EE_CLK; + devpriv->plx_control_bits &= ~PLX_CNTRL_EESK; writel(devpriv->plx_control_bits, plx_control_addr); } /* read back value from eeprom memory location */ @@ -3748,19 +3748,19 @@ static uint16_t read_eeprom(struct comedi_device *dev, uint8_t address) for (bit = 1 << (value_length - 1); bit; bit >>= 1) { /* clock out bit */ udelay(eeprom_udelay); - devpriv->plx_control_bits |= CTL_EE_CLK; + devpriv->plx_control_bits |= PLX_CNTRL_EESK; writel(devpriv->plx_control_bits, plx_control_addr); udelay(eeprom_udelay); - devpriv->plx_control_bits &= ~CTL_EE_CLK; + devpriv->plx_control_bits &= ~PLX_CNTRL_EESK; writel(devpriv->plx_control_bits, plx_control_addr); udelay(eeprom_udelay); - if (readl(plx_control_addr) & CTL_EE_R) + if (readl(plx_control_addr) & PLX_CNTRL_EERB) value |= bit; } /* deactivate eeprom serial input */ udelay(eeprom_udelay); - devpriv->plx_control_bits &= ~CTL_EE_CS; + devpriv->plx_control_bits &= ~PLX_CNTRL_EECS; writel(devpriv->plx_control_bits, plx_control_addr); return value; @@ -3948,7 +3948,8 @@ static int setup_subdevices(struct comedi_device *dev) /* serial EEPROM, if present */ s = &dev->subdevices[8]; - if (readl(devpriv->plx9080_iobase + PLX_REG_CNTRL) & CTL_EECHK) { + if (readl(devpriv->plx9080_iobase + PLX_REG_CNTRL) & + PLX_CNTRL_EEPRESENT) { s->type = COMEDI_SUBD_MEMORY; s->subdev_flags = SDF_READABLE | SDF_INTERNAL; s->n_chan = 128; diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index e9f1b9c..4ad9464 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -393,20 +393,55 @@ struct plx_dma_desc { */ #define PLX_REG_CNTRL 0x006c -#define CTL_RDMA 0x0000000E /* DMA Read Command */ -#define CTL_WDMA 0x00000070 /* DMA Write Command */ -#define CTL_RMEM 0x00000600 /* Memory Read Command */ -#define CTL_WMEM 0x00007000 /* Memory Write Command */ -#define CTL_USERO 0x00010000 /* USERO output pin control bit */ -#define CTL_USERI 0x00020000 /* USERI input pin bit */ -#define CTL_EE_CLK 0x01000000 /* EEPROM Clock line */ -#define CTL_EE_CS 0x02000000 /* EEPROM Chip Select */ -#define CTL_EE_W 0x04000000 /* EEPROM Write bit */ -#define CTL_EE_R 0x08000000 /* EEPROM Read bit */ -#define CTL_EECHK 0x10000000 /* EEPROM Present bit */ -#define CTL_EERLD 0x20000000 /* EEPROM Reload Register */ -#define CTL_RESET 0x40000000 /* !! Adapter Reset !! */ -#define CTL_READY 0x80000000 /* Local Init Done */ +/* PCI Read Command Code For DMA */ +#define PLX_CNTRL_CCRDMA(x) (BIT(0) * ((x) & 0xf)) +#define PLX_CNTRL_CCRDMA_MASK GENMASK(3, 0) +#define PLX_CNTRL_CCRDMA_SHIFT 0 +#define PLX_CNTRL_CCRDMA_NORMAL PLX_CNTRL_CCRDMA(14) /* value after reset */ +/* PCI Write Command Code For DMA 0 */ +#define PLX_CNTRL_CCWDMA(x) (BIT(4) * ((x) & 0xf)) +#define PLX_CNTRL_CCWDMA_MASK GENMASK(7, 4) +#define PLX_CNTRL_CCWDMA_SHIFT 4 +#define PLX_CNTRL_CCWDMA_NORMAL PLX_CNTRL_CCWDMA(7) /* value after reset */ +/* PCI Memory Read Command Code For Direct Master */ +#define PLX_CNTRL_CCRDM(x) (BIT(8) * ((x) & 0xf)) +#define PLX_CNTRL_CCRDM_MASK GENMASK(11, 8) +#define PLX_CNTRL_CCRDM_SHIFT 8 +#define PLX_CNTRL_CCRDM_NORMAL PLX_CNTRL_CCRDM(6) /* value after reset */ +/* PCI Memory Write Command Code For Direct Master */ +#define PLX_CNTRL_CCWDM(x) (BIT(12) * ((x) & 0xf)) +#define PLX_CNTRL_CCWDM_MASK GENMASK(15, 12) +#define PLX_CNTRL_CCWDM_SHIFT 12 +#define PLX_CNTRL_CCWDM_NORMAL PLX_CNTRL_CCWDM(7) /* value after reset */ +/* General Purpose Output (USERO) */ +#define PLX_CNTRL_USERO BIT(16) +/* General Purpose Input (USERI) (read-only) */ +#define PLX_CNTRL_USERI BIT(17) +/* Serial EEPROM Clock Output (EESK) */ +#define PLX_CNTRL_EESK BIT(24) +/* Serial EEPROM Chip Select Output (EECS) */ +#define PLX_CNTRL_EECS BIT(25) +/* Serial EEPROM Data Write Bit (EEDI (sic)) */ +#define PLX_CNTRL_EEWB BIT(26) +/* Serial EEPROM Data Read Bit (EEDO (sic)) (read-only) */ +#define PLX_CNTRL_EERB BIT(27) +/* Serial EEPROM Present (read-only) */ +#define PLX_CNTRL_EEPRESENT BIT(28) +/* Reload Configuration Registers from EEPROM */ +#define PLX_CNTRL_EERELOAD BIT(29) +/* PCI Adapter Software Reset (asserts LRESETo#) */ +#define PLX_CNTRL_RESET BIT(30) +/* Local Init Status (read-only) */ +#define PLX_CNTRL_INITDONE BIT(31) +/* + * Combined command code stuff for convenience. + */ +#define PLX_CNTRL_CC_MASK \ + (PLX_CNTRL_CCRDMA_MASK | PLX_CNTRL_CCWDMA_MASK | \ + PLX_CNTRL_CCRDM_MASK | PLX_CNTRL_CCWDM_MASK) +#define PLX_CNTRL_CC_NORMAL \ + (PLX_CNTRL_CCRDMA_NORMAL | PLX_CNTRL_CCWDMA_NORMAL | \ + PLX_CNTRL_CCRDM_NORMAL | PLX_CNTRL_CCWDM_NORMAL) /* val after reset */ /* PCI Permanent Configuration ID Register (hard-coded PLX vendor and device) */ #define PLX_REG_PCIHIDR 0x0070 -- cgit v1.1 From df04d3aa028a5feb905b1b0871c000ed51535eef Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:15 +0100 Subject: staging: comedi: plx9080.h: add hard-coded PCIHIDR register value For the PLX PCI 9080, the read-only PCIHIDR register is hard-coded with the value `0x908010b5`. Add a macro `PLX_PCIHIDR_9080` that expands to this value. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/plx9080.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 4ad9464..c70af5e 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -446,6 +446,9 @@ struct plx_dma_desc { /* PCI Permanent Configuration ID Register (hard-coded PLX vendor and device) */ #define PLX_REG_PCIHIDR 0x0070 +/* Hard-coded ID for PLX PCI 9080 */ +#define PLX_PCIHIDR_9080 0x908010b5 + /* PCI Permanent Revision ID Register (hard-coded silicon revision) (8-bit). */ #define PLX_REG_PCIHREV 0x0074 -- cgit v1.1 From 65bf53de830063520cfbdedd56d80f1125d62271 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:16 +0100 Subject: staging: comedi: drivers: re-do PLX PCI 9080 DMAMODEx register values Replace the existing macros in "plx9080.h" that define values for the DMAMODE0 and DMAMODE1 registers. Use the prefix `PLX_DMAMODE_` for the macros. Make use of the `BIT(x)` and `GENMASK(h,l)` macros to define the values. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 20 +++++------ drivers/staging/comedi/drivers/gsc_hpdi.c | 16 ++++----- drivers/staging/comedi/drivers/plx9080.h | 52 +++++++++++++++++++--------- 3 files changed, 53 insertions(+), 35 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index dfb2ae8..48aca06 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1308,28 +1308,28 @@ static void init_plx9080(struct comedi_device *dev) /* configure dma0 mode */ bits = 0; /* enable ready input, not sure if this is necessary */ - bits |= PLX_DMA_EN_READYIN_BIT; + bits |= PLX_DMAMODE_READYIEN; /* enable bterm, not sure if this is necessary */ - bits |= PLX_EN_BTERM_BIT; + bits |= PLX_DMAMODE_BTERMIEN; /* enable dma chaining */ - bits |= PLX_EN_CHAIN_BIT; + bits |= PLX_DMAMODE_CHAINEN; /* enable interrupt on dma done * (probably don't need this, since chain never finishes) */ - bits |= PLX_EN_DMA_DONE_INTR_BIT; + bits |= PLX_DMAMODE_DONEIEN; /* don't increment local address during transfers * (we are transferring from a fixed fifo register) */ - bits |= PLX_LOCAL_ADDR_CONST_BIT; + bits |= PLX_DMAMODE_LACONST; /* route dma interrupt to pci bus */ - bits |= PLX_DMA_INTR_PCI_BIT; + bits |= PLX_DMAMODE_INTRPCI; /* enable demand mode */ - bits |= PLX_DEMAND_MODE_BIT; + bits |= PLX_DMAMODE_DEMAND; /* enable local burst mode */ - bits |= PLX_DMA_LOCAL_BURST_EN_BIT; + bits |= PLX_DMAMODE_BURSTEN; /* 4020 uses 32 bit dma */ if (board->layout == LAYOUT_4020) - bits |= PLX_LOCAL_BUS_32_WIDE_BITS; + bits |= PLX_DMAMODE_WIDTH32; else /* localspace0 bus is 16 bits wide */ - bits |= PLX_LOCAL_BUS_16_WIDE_BITS; + bits |= PLX_DMAMODE_WIDTH16; writel(bits, plx_iobase + PLX_REG_DMAMODE1); if (ao_cmd_is_supported(board)) writel(bits, plx_iobase + PLX_REG_DMAMODE0); diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index e288798..d63dc46 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -563,26 +563,26 @@ static void gsc_hpdi_init_plx9080(struct comedi_device *dev) /* configure dma0 mode */ bits = 0; /* enable ready input */ - bits |= PLX_DMA_EN_READYIN_BIT; + bits |= PLX_DMAMODE_READYIEN; /* enable dma chaining */ - bits |= PLX_EN_CHAIN_BIT; + bits |= PLX_DMAMODE_CHAINEN; /* * enable interrupt on dma done * (probably don't need this, since chain never finishes) */ - bits |= PLX_EN_DMA_DONE_INTR_BIT; + bits |= PLX_DMAMODE_DONEIEN; /* * don't increment local address during transfers * (we are transferring from a fixed fifo register) */ - bits |= PLX_LOCAL_ADDR_CONST_BIT; + bits |= PLX_DMAMODE_LACONST; /* route dma interrupt to pci bus */ - bits |= PLX_DMA_INTR_PCI_BIT; + bits |= PLX_DMAMODE_INTRPCI; /* enable demand mode */ - bits |= PLX_DEMAND_MODE_BIT; + bits |= PLX_DMAMODE_DEMAND; /* enable local burst mode */ - bits |= PLX_DMA_LOCAL_BURST_EN_BIT; - bits |= PLX_LOCAL_BUS_32_WIDE_BITS; + bits |= PLX_DMAMODE_BURSTEN; + bits |= PLX_DMAMODE_WIDTH32; writel(bits, plx_iobase + PLX_REG_DMAMODE0); } diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index c70af5e..99c075c 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -457,23 +457,41 @@ struct plx_dma_desc { #define PLX_REG_DMAMODE0 0x0080 #define PLX_REG_DMAMODE1 0x0094 -#define PLX_LOCAL_BUS_16_WIDE_BITS 0x1 -#define PLX_LOCAL_BUS_32_WIDE_BITS 0x3 -#define PLX_LOCAL_BUS_WIDTH_MASK 0x3 -#define PLX_DMA_EN_READYIN_BIT 0x40 /* enable ready in input */ -#define PLX_EN_BTERM_BIT 0x80 /* enable BTERM# input */ -#define PLX_DMA_LOCAL_BURST_EN_BIT 0x100 /* enable local burst mode */ -#define PLX_EN_CHAIN_BIT 0x200 /* enables chaining */ -/* enables interrupt on dma done */ -#define PLX_EN_DMA_DONE_INTR_BIT 0x400 -/* hold local address constant (don't increment) */ -#define PLX_LOCAL_ADDR_CONST_BIT 0x800 -/* enables demand-mode for dma transfer */ -#define PLX_DEMAND_MODE_BIT 0x1000 -#define PLX_EOT_ENABLE_BIT 0x4000 -#define PLX_STOP_MODE_BIT 0x8000 -/* routes dma interrupt to pci bus (instead of local bus) */ -#define PLX_DMA_INTR_PCI_BIT 0x20000 +/* Local Bus Width */ +#define PLX_DMAMODE_WIDTH8 (BIT(0) * 0) /* 8 bits wide */ +#define PLX_DMAMODE_WIDTH16 (BIT(0) * 1) /* 16 bits wide */ +#define PLX_DMAMODE_WIDTH32 (BIT(0) * 2) /* 32 bits wide */ +#define PLX_DMAMODE_WIDTH32A (BIT(0) * 3) /* 32 bits wide */ +#define PLX_DMAMODE_WIDTH_MASK GENMASK(1, 0) +#define PLX_DMAMODE_WIDTH_SHIFT 0 +/* Internal Wait States */ +#define PLX_DMAMODE_IWS(x) (BIT(2) * ((x) & 0xf)) +#define PLX_DMAMODE_IWS_MASK GENMASK(5, 2) +#define PLX_DMAMODE_SHIFT 2 +/* Ready Input Enable */ +#define PLX_DMAMODE_READYIEN BIT(6) +/* BTERM# Input Enable */ +#define PLX_DMAMODE_BTERMIEN BIT(7) +/* Local Burst Enable */ +#define PLX_DMAMODE_BURSTEN BIT(8) +/* Chaining Enable */ +#define PLX_DMAMODE_CHAINEN BIT(9) +/* Done Interrupt Enable */ +#define PLX_DMAMODE_DONEIEN BIT(10) +/* Hold Local Address Constant */ +#define PLX_DMAMODE_LACONST BIT(11) +/* Demand Mode */ +#define PLX_DMAMODE_DEMAND BIT(12) +/* Write And Invalidate Mode */ +#define PLX_DMAMODE_WINVALIDATE BIT(13) +/* DMA EOT Enable - enables EOT0# or EOT1# input pin */ +#define PLX_DMAMODE_EOTEN BIT(14) +/* DMA Stop Data Transfer Mode - 0:BLAST; 1:EOT asserted or DREQ deasserted */ +#define PLX_DMAMODE_STOP BIT(15) +/* DMA Clear Count Mode - count in descriptor cleared on completion */ +#define PLX_DMAMODE_CLRCOUNT BIT(16) +/* DMA Channel Interrupt Select - 0:local bus interrupt; 1:PCI interrupt */ +#define PLX_DMAMODE_INTRPCI BIT(17) /* DMA Channel N PCI Address Register (N <= 1) */ #define PLX_REG_DMAPADR(n) ((n) ? PLX_REG_DMAPADR1 : PLX_REG_DMAPADR0) -- cgit v1.1 From dde90d89ae5a98a3f1420b6c20c7f58dd95ccfa3 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:17 +0100 Subject: staging: comedi: drivers: re-do PLX PCI 9080 DMADPRx register values Replace the existing macros in "plx9080.h" that define values for the DMADPR0 and DMADPR1 registers. (A little-endian version of the register value is also placed in the `next` member of `struct plx_dma_desc`.) Use the prefix `PLX_DMADPR_` for the macros. Make use of the `BIT(x)` and `GENMASK(h,l)` macros to define the values. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 22 +++++++++++----------- drivers/staging/comedi/drivers/gsc_hpdi.c | 8 ++++---- drivers/staging/comedi/drivers/plx9080.h | 17 ++++++++++------- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 48aca06..a4d10a3 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1534,8 +1534,8 @@ static int alloc_and_init_dma_members(struct comedi_device *dev) cpu_to_le32((devpriv->ai_dma_desc_bus_addr + ((i + 1) % ai_dma_ring_count(board)) * sizeof(devpriv->ai_dma_desc[0])) | - PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT | - PLX_XFER_LOCAL_TO_PCI); + PLX_DMADPR_DESCPCI | PLX_DMADPR_TCINTR | + PLX_DMADPR_XFERL2P); } if (ao_cmd_is_supported(board)) { for (i = 0; i < AO_DMA_RING_COUNT; i++) { @@ -1549,8 +1549,8 @@ static int alloc_and_init_dma_members(struct comedi_device *dev) cpu_to_le32((devpriv->ao_dma_desc_bus_addr + ((i + 1) % (AO_DMA_RING_COUNT)) * sizeof(devpriv->ao_dma_desc[0])) | - PLX_DESC_IN_PCI_BIT | - PLX_INTR_TERM_COUNT); + PLX_DMADPR_DESCPCI | + PLX_DMADPR_TCINTR); } } return 0; @@ -2634,9 +2634,9 @@ static int ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* give location of first dma descriptor */ load_first_dma_descriptor(dev, 1, devpriv->ai_dma_desc_bus_addr | - PLX_DESC_IN_PCI_BIT | - PLX_INTR_TERM_COUNT | - PLX_XFER_LOCAL_TO_PCI); + PLX_DMADPR_DESCPCI | + PLX_DMADPR_TCINTR | + PLX_DMADPR_XFERL2P); dma_start_sync(dev, 1); } @@ -2918,7 +2918,7 @@ static void restart_ao_dma(struct comedi_device *dev) unsigned int dma_desc_bits; dma_desc_bits = readl(devpriv->plx9080_iobase + PLX_REG_DMADPR0); - dma_desc_bits &= ~PLX_END_OF_CHAIN_BIT; + dma_desc_bits &= ~PLX_DMADPR_CHAINEND; load_first_dma_descriptor(dev, 0, dma_desc_bits); dma_start_sync(dev, 0); @@ -2959,14 +2959,14 @@ static unsigned int load_ao_dma_buffer(struct comedi_device *dev, devpriv->ao_dma_desc[buffer_index].transfer_size = cpu_to_le32(nbytes); /* set end of chain bit so we catch underruns */ next_bits = le32_to_cpu(devpriv->ao_dma_desc[buffer_index].next); - next_bits |= PLX_END_OF_CHAIN_BIT; + next_bits |= PLX_DMADPR_CHAINEND; devpriv->ao_dma_desc[buffer_index].next = cpu_to_le32(next_bits); /* * clear end of chain bit on previous buffer now that we have set it * for the last buffer */ next_bits = le32_to_cpu(devpriv->ao_dma_desc[prev_buffer_index].next); - next_bits &= ~PLX_END_OF_CHAIN_BIT; + next_bits &= ~PLX_DMADPR_CHAINEND; devpriv->ao_dma_desc[prev_buffer_index].next = cpu_to_le32(next_bits); devpriv->ao_dma_index = (buffer_index + 1) % AO_DMA_RING_COUNT; @@ -3310,7 +3310,7 @@ static int ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) set_dac_select_reg(dev, cmd); set_dac_interval_regs(dev, cmd); load_first_dma_descriptor(dev, 0, devpriv->ao_dma_desc_bus_addr | - PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT); + PLX_DMADPR_DESCPCI | PLX_DMADPR_TCINTR); set_dac_control1_reg(dev, cmd); s->async->inttrig = ao_inttrig; diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index d63dc46..f2f1874 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -310,8 +310,8 @@ static int gsc_hpdi_cmd(struct comedi_device *dev, writel(0, devpriv->plx9080_mmio + PLX_REG_DMALADR0); /* give location of first dma descriptor */ - bits = devpriv->dma_desc_phys_addr | PLX_DESC_IN_PCI_BIT | - PLX_INTR_TERM_COUNT | PLX_XFER_LOCAL_TO_PCI; + bits = devpriv->dma_desc_phys_addr | PLX_DMADPR_DESCPCI | + PLX_DMADPR_TCINTR | PLX_DMADPR_XFERL2P; writel(bits, devpriv->plx9080_mmio + PLX_REG_DMADPR0); /* enable dma transfer */ @@ -422,8 +422,8 @@ static int gsc_hpdi_setup_dma_descriptors(struct comedi_device *dev, { struct hpdi_private *devpriv = dev->private; dma_addr_t phys_addr = devpriv->dma_desc_phys_addr; - u32 next_bits = PLX_DESC_IN_PCI_BIT | PLX_INTR_TERM_COUNT | - PLX_XFER_LOCAL_TO_PCI; + u32 next_bits = PLX_DMADPR_DESCPCI | PLX_DMADPR_TCINTR | + PLX_DMADPR_XFERL2P; unsigned int offset = 0; unsigned int idx = 0; unsigned int i; diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 99c075c..2fe1a4d 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -513,13 +513,16 @@ struct plx_dma_desc { #define PLX_REG_DMADPR0 0x0090 #define PLX_REG_DMADPR1 0x00a4 -/* descriptor is located in pci space (not local space) */ -#define PLX_DESC_IN_PCI_BIT 0x1 -#define PLX_END_OF_CHAIN_BIT 0x2 /* end of chain bit */ -/* interrupt when this descriptor's transfer is finished */ -#define PLX_INTR_TERM_COUNT 0x4 -/* transfer from local to pci bus (not pci to local) */ -#define PLX_XFER_LOCAL_TO_PCI 0x8 +/* Descriptor Located In PCI Address Space (not local address space) */ +#define PLX_DMADPR_DESCPCI BIT(0) +/* End Of Chain */ +#define PLX_DMADPR_CHAINEND BIT(1) +/* Interrupt After Terminal Count */ +#define PLX_DMADPR_TCINTR BIT(2) +/* Direction Of Transfer Local Bus To PCI (not PCI to local) */ +#define PLX_DMADPR_XFERL2P BIT(3) +/* Next Descriptor Address Bits 31:4 (16 byte boundary) */ +#define PLX_DMADPR_NEXT_MASK GENMASK(31, 4) /* DMA Channel N Command/Status Register (N <= 1) (8-bit) */ #define PLX_REG_DMACSR(n) ((n) ? PLX_REG_DMACSR1 : PLX_REG_DMACSR0) -- cgit v1.1 From 3dcf1b5596603076cf127a3efdf3a33a276d8b9e Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:18 +0100 Subject: staging: comedi: drivers: re-do PLX PCI 9080 DMACSRx register values Replace the existing macros in "plx9080.h" that define values for the DMACSR0 and DMACSR0 registers. Use the prefix `PLX_DMACSR_` for the macros. Make use of the `BIT(x)` macro to define the values. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 22 +++++++++++----------- drivers/staging/comedi/drivers/gsc_hpdi.c | 8 ++++---- drivers/staging/comedi/drivers/plx9080.h | 23 ++++++++++++++--------- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index a4d10a3..1f9c08a 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -2368,7 +2368,7 @@ static inline void dma_start_sync(struct comedi_device *dev, /* spinlock for plx dma control/status reg */ spin_lock_irqsave(&dev->spinlock, flags); - writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | PLX_CLEAR_DMA_INTR_BIT, + writeb(PLX_DMACSR_ENABLE | PLX_DMACSR_START | PLX_DMACSR_CLEARINTR, devpriv->plx9080_iobase + PLX_REG_DMACSR(channel)); spin_unlock_irqrestore(&dev->spinlock, flags); } @@ -2838,10 +2838,10 @@ static void handle_ai_interrupt(struct comedi_device *dev, spin_lock_irqsave(&dev->spinlock, flags); dma1_status = readb(devpriv->plx9080_iobase + PLX_REG_DMACSR1); if (plx_status & PLX_INTCSR_DMA1IA) { /* dma chan 1 interrupt */ - writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, + writeb((dma1_status & PLX_DMACSR_ENABLE) | PLX_DMACSR_CLEARINTR, devpriv->plx9080_iobase + PLX_REG_DMACSR1); - if (dma1_status & PLX_DMA_EN_BIT) + if (dma1_status & PLX_DMACSR_ENABLE) drain_dma_buffers(dev, 1); } spin_unlock_irqrestore(&dev->spinlock, flags); @@ -2889,7 +2889,7 @@ static int last_ao_dma_load_completed(struct comedi_device *dev) buffer_index = prev_ao_dma_index(dev); dma_status = readb(devpriv->plx9080_iobase + PLX_REG_DMACSR0); - if ((dma_status & PLX_DMA_DONE_BIT) == 0) + if ((dma_status & PLX_DMACSR_DONE) == 0) return 0; transfer_address = @@ -2903,8 +2903,8 @@ static int last_ao_dma_load_completed(struct comedi_device *dev) static inline int ao_dma_needs_restart(struct comedi_device *dev, unsigned short dma_status) { - if ((dma_status & PLX_DMA_DONE_BIT) == 0 || - (dma_status & PLX_DMA_EN_BIT) == 0) + if ((dma_status & PLX_DMACSR_DONE) == 0 || + (dma_status & PLX_DMACSR_ENABLE) == 0) return 0; if (last_ao_dma_load_completed(dev)) return 0; @@ -3016,16 +3016,16 @@ static void handle_ao_interrupt(struct comedi_device *dev, spin_lock_irqsave(&dev->spinlock, flags); dma0_status = readb(devpriv->plx9080_iobase + PLX_REG_DMACSR0); if (plx_status & PLX_INTCSR_DMA0IA) { /* dma chan 0 interrupt */ - if ((dma0_status & PLX_DMA_EN_BIT) && - !(dma0_status & PLX_DMA_DONE_BIT)) { - writeb(PLX_DMA_EN_BIT | PLX_CLEAR_DMA_INTR_BIT, + if ((dma0_status & PLX_DMACSR_ENABLE) && + !(dma0_status & PLX_DMACSR_DONE)) { + writeb(PLX_DMACSR_ENABLE | PLX_DMACSR_CLEARINTR, devpriv->plx9080_iobase + PLX_REG_DMACSR0); } else { - writeb(PLX_CLEAR_DMA_INTR_BIT, + writeb(PLX_DMACSR_CLEARINTR, devpriv->plx9080_iobase + PLX_REG_DMACSR0); } spin_unlock_irqrestore(&dev->spinlock, flags); - if (dma0_status & PLX_DMA_EN_BIT) { + if (dma0_status & PLX_DMACSR_ENABLE) { load_ao_dma(dev, cmd); /* try to recover from dma end-of-chain event */ if (ao_dma_needs_restart(dev, dma0_status)) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index f2f1874..af4b417 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -214,10 +214,10 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) dma0_status = readb(devpriv->plx9080_mmio + PLX_REG_DMACSR0); if (plx_status & PLX_INTCSR_DMA0IA) { /* dma chan 0 interrupt */ - writeb((dma0_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, + writeb((dma0_status & PLX_DMACSR_ENABLE) | PLX_DMACSR_CLEARINTR, devpriv->plx9080_mmio + PLX_REG_DMACSR0); - if (dma0_status & PLX_DMA_EN_BIT) + if (dma0_status & PLX_DMACSR_ENABLE) gsc_hpdi_drain_dma(dev, 0); } spin_unlock_irqrestore(&dev->spinlock, flags); @@ -227,7 +227,7 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d) dma1_status = readb(devpriv->plx9080_mmio + PLX_REG_DMACSR1); if (plx_status & PLX_INTCSR_DMA1IA) { /* XXX */ /* dma chan 1 interrupt */ - writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT, + writeb((dma1_status & PLX_DMACSR_ENABLE) | PLX_DMACSR_CLEARINTR, devpriv->plx9080_mmio + PLX_REG_DMACSR1); } spin_unlock_irqrestore(&dev->spinlock, flags); @@ -316,7 +316,7 @@ static int gsc_hpdi_cmd(struct comedi_device *dev, /* enable dma transfer */ spin_lock_irqsave(&dev->spinlock, flags); - writeb(PLX_DMA_EN_BIT | PLX_DMA_START_BIT | PLX_CLEAR_DMA_INTR_BIT, + writeb(PLX_DMACSR_ENABLE | PLX_DMACSR_START | PLX_DMACSR_CLEARINTR, devpriv->plx9080_mmio + PLX_REG_DMACSR0); spin_unlock_irqrestore(&dev->spinlock, flags); diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 2fe1a4d..9e76342 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -529,11 +529,16 @@ struct plx_dma_desc { #define PLX_REG_DMACSR0 0x00a8 #define PLX_REG_DMACSR1 0x00a9 -#define PLX_DMA_EN_BIT 0x1 /* enable dma channel */ -#define PLX_DMA_START_BIT 0x2 /* start dma transfer */ -#define PLX_DMA_ABORT_BIT 0x4 /* abort dma transfer */ -#define PLX_CLEAR_DMA_INTR_BIT 0x8 /* clear dma interrupt */ -#define PLX_DMA_DONE_BIT 0x10 /* transfer done status bit */ +/* Channel Enable */ +#define PLX_DMACSR_ENABLE BIT(0) +/* Channel Start - write 1 to start transfer (write-only) */ +#define PLX_DMACSR_START BIT(1) +/* Channel Abort - write 1 to abort transfer (write-only) */ +#define PLX_DMACSR_ABORT BIT(2) +/* Clear Interrupt - write 1 to clear DMA Channel Interrupt (write-only) */ +#define PLX_DMACSR_CLEARINTR BIT(3) +/* Channel Done - transfer complete/inactive (read-only) */ +#define PLX_DMACSR_DONE BIT(4) /* DMA Threshold Register */ #define PLX_REG_DMATHR 0x00b0 @@ -571,11 +576,11 @@ static inline int plx9080_abort_dma(void __iomem *iobase, unsigned int channel) /* abort dma transfer if necessary */ dma_status = readb(dma_cs_addr); - if ((dma_status & PLX_DMA_EN_BIT) == 0) + if ((dma_status & PLX_DMACSR_ENABLE) == 0) return 0; /* wait to make sure done bit is zero */ - for (i = 0; (dma_status & PLX_DMA_DONE_BIT) && i < timeout; i++) { + for (i = 0; (dma_status & PLX_DMACSR_DONE) && i < timeout; i++) { udelay(1); dma_status = readb(dma_cs_addr); } @@ -583,10 +588,10 @@ static inline int plx9080_abort_dma(void __iomem *iobase, unsigned int channel) return -ETIMEDOUT; /* disable and abort channel */ - writeb(PLX_DMA_ABORT_BIT, dma_cs_addr); + writeb(PLX_DMACSR_ABORT, dma_cs_addr); /* wait for dma done bit */ dma_status = readb(dma_cs_addr); - for (i = 0; (dma_status & PLX_DMA_DONE_BIT) == 0 && i < timeout; i++) { + for (i = 0; (dma_status & PLX_DMACSR_DONE) == 0 && i < timeout; i++) { udelay(1); dma_status = readb(dma_cs_addr); } -- cgit v1.1 From eb89333146c3f86aed85944c65c08ad8250668d5 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:19 +0100 Subject: staging: comedi: drivers: add PLX PCI 9080 DMATHR register values Add macros in "plx9080.h" that define values for the DMATHR register values. Use the prefix `PLX_DMATHR_` for the macros. Make use of the `BIT(x)` and `GENMASK(h,l)` macros to define the values. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/plx9080.h | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 9e76342..50d0b1b 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -544,6 +544,47 @@ struct plx_dma_desc { #define PLX_REG_DMATHR 0x00b0 /* + * DMA Threshold constraints: + * (C0PLAF + 1) + (C0PLAE + 1) <= 32 + * (C0LPAF + 1) + (C0LPAE + 1) <= 32 + * (C1PLAF + 1) + (C1PLAE + 1) <= 16 + * (C1LPAF + 1) + (C1LPAE + 1) <= 16 + */ + +/* DMA Channel 0 PCI-to-Local Almost Full (divided by 2, minus 1) */ +#define PLX_DMATHR_C0PLAF(x) (BIT(0) * ((x) & 0xf)) +#define PLX_DMATHR_C0PLAF_MASK GENMASK(3, 0) +#define PLX_DMATHR_C0PLAF_SHIFT 0 +/* DMA Channel 0 Local-to-PCI Almost Empty (divided by 2, minus 1) */ +#define PLX_DMATHR_C0LPAE(x) (BIT(4) * ((x) & 0xf)) +#define PLX_DMATHR_C0LPAE_MASK GENMASK(7, 4) +#define PLX_DMATHR_C0LPAE_SHIFT 4 +/* DMA Channel 0 Local-to-PCI Almost Full (divided by 2, minus 1) */ +#define PLX_DMATHR_C0LPAF(x) (BIT(8) * ((x) & 0xf)) +#define PLX_DMATHR_C0LPAF_MASK GENMASK(11, 8) +#define PLX_DMATHR_C0LPAF_SHIFT 8 +/* DMA Channel 0 PCI-to-Local Almost Empty (divided by 2, minus 1) */ +#define PLX_DMATHR_C0PLAE(x) (BIT(12) * ((x) & 0xf)) +#define PLX_DMATHR_C0PLAE_MASK GENMASK(15, 12) +#define PLX_DMATHR_C0PLAE_SHIFT 12 +/* DMA Channel 1 PCI-to-Local Almost Full (divided by 2, minus 1) */ +#define PLX_DMATHR_C1PLAF(x) (BIT(16) * ((x) & 0xf)) +#define PLX_DMATHR_C1PLAF_MASK GENMASK(19, 16) +#define PLX_DMATHR_C1PLAF_SHIFT 16 +/* DMA Channel 1 Local-to-PCI Almost Empty (divided by 2, minus 1) */ +#define PLX_DMATHR_C1LPAE(x) (BIT(20) * ((x) & 0xf)) +#define PLX_DMATHR_C1LPAE_MASK GENMASK(23, 20) +#define PLX_DMATHR_C1LPAE_SHIFT 20 +/* DMA Channel 1 Local-to-PCI Almost Full (divided by 2, minus 1) */ +#define PLX_DMATHR_C1LPAF(x) (BIT(24) * ((x) & 0xf)) +#define PLX_DMATHR_C1LPAF_MASK GENMASK(27, 24) +#define PLX_DMATHR_C1LPAF_SHIFT 24 +/* DMA Channel 1 PCI-to-Local Almost Empty (divided by 2, minus 1) */ +#define PLX_DMATHR_C1PLAE(x) (BIT(28) * ((x) & 0xf)) +#define PLX_DMATHR_C1PLAE_MASK GENMASK(31, 28) +#define PLX_DMATHR_C1PLAE_SHIFT 28 + +/* * Messaging Queue Registers OPLFIS, OPLFIM, IQP, OQP, MQCR, QBAR, IFHPR, * IFTPR, IPHPR, IPTPR, OFHPR, OFTPR, OPHPR, OPTPR, and QSR have been omitted. * They are used by the I2O feature. (IQP and OQP occupy the usual offsets of -- cgit v1.1 From 457bec0f73d87dcbab6657c6ba2fce78f1325022 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:20 +0100 Subject: staging: comedi: plx9080.h: tidy up some comments Use the usual block comment style and remove some excess spaces from single-line comments. Remove some obvious stuff about register offsets being zero relative. Remove some text about the original history of the file, as it bears hardly any resemblance to it now. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/plx9080.h | 36 +++++++++++--------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 50d0b1b..d701b15 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -3,15 +3,6 @@ * * Copyright (C) 2002,2003 Frank Mori Hess * - * I modified this file from the plx9060.h header for the - * wanXL device driver in the linux kernel, - * for the register offsets and bit definitions. Made minor modifications, - * added plx9080 registers and - * stripped out stuff that was specifically for the wanXL driver. - * Note: I've only made sure the definitions are correct as far - * as I make use of them. There are still various plx9060-isms - * left in this header file. - * ******************************************************************** * * Copyright (C) 1999 RG Studio s.c. @@ -28,7 +19,7 @@ #ifndef __COMEDI_PLX9080_H #define __COMEDI_PLX9080_H -/* descriptor block used for chained dma transfers */ +/* descriptor block used for chained dma transfers */ struct plx_dma_desc { __le32 pci_start_addr; __le32 local_start_addr; @@ -41,13 +32,9 @@ struct plx_dma_desc { __le32 next; }; -/********************************************************************** -** Register Offsets and Bit Definitions -** -** Note: All offsets zero relative. IE. Some standard base address -** must be added to the Register Number to properly access the register. -** -**********************************************************************/ +/* + * Register Offsets and Bit Definitions + */ /* Local Address Space 0 Range Register */ #define PLX_REG_LAS0RR 0x0000 @@ -145,10 +132,11 @@ struct plx_dma_desc { #define PLX_BIGEND_DMA(n) ((n) ? PLX_BIGEND_DMA1 : PLX_BIGEND_DMA0) /* -** Note: The Expansion ROM stuff is only relevant to the PC environment. -** This expansion ROM code is executed by the host CPU at boot time. -** For this reason no bit definitions are provided here. + * Note: The Expansion ROM stuff is only relevant to the PC environment. + * This expansion ROM code is executed by the host CPU at boot time. + * For this reason no bit definitions are provided here. */ + /* Expansion ROM Range Register */ #define PLX_REG_EROMRR 0x0010 /* Expansion ROM Local Base Address (Remap) Register */ @@ -615,12 +603,12 @@ static inline int plx9080_abort_dma(void __iomem *iobase, unsigned int channel) dma_cs_addr = iobase + PLX_REG_DMACSR(channel); - /* abort dma transfer if necessary */ + /* abort dma transfer if necessary */ dma_status = readb(dma_cs_addr); if ((dma_status & PLX_DMACSR_ENABLE) == 0) return 0; - /* wait to make sure done bit is zero */ + /* wait to make sure done bit is zero */ for (i = 0; (dma_status & PLX_DMACSR_DONE) && i < timeout; i++) { udelay(1); dma_status = readb(dma_cs_addr); @@ -628,9 +616,9 @@ static inline int plx9080_abort_dma(void __iomem *iobase, unsigned int channel) if (i == timeout) return -ETIMEDOUT; - /* disable and abort channel */ + /* disable and abort channel */ writeb(PLX_DMACSR_ABORT, dma_cs_addr); - /* wait for dma done bit */ + /* wait for dma done bit */ dma_status = readb(dma_cs_addr); for (i = 0; (dma_status & PLX_DMACSR_DONE) == 0 && i < timeout; i++) { udelay(1); -- cgit v1.1 From 6a64877f6318c6db63beb5ae1397c8afc09e8628 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:21 +0100 Subject: staging: comedi: plx9080.h: Add kerneldoc comments Document the DMA descriptor `struct plx_dma_desc`, and the DMA abort function `plx9080_abort_dma()`. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/plx9080.h | 35 ++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index d701b15..f67f9d7 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -19,16 +19,27 @@ #ifndef __COMEDI_PLX9080_H #define __COMEDI_PLX9080_H -/* descriptor block used for chained dma transfers */ +/** + * struct plx_dma_desc - DMA descriptor format for PLX PCI 9080 + * @pci_start_addr: PCI Bus address for transfer (DMAPADR). + * @local_start_addr: Local Bus address for transfer (DMALADR). + * @transfer_size: Transfer size in bytes (max 8 MiB) (DMASIZ). + * @next: Address of next descriptor + flags (DMADPR). + * + * Describes the format of a scatter-gather DMA descriptor for the PLX + * PCI 9080. All members are raw, little-endian register values that + * will be transferred by the DMA engine from local or PCI memory into + * corresponding registers for the DMA channel. + * + * The DMA descriptors must be aligned on a 16-byte boundary. Bits 3:0 + * of @next contain flags describing the address space of the next + * descriptor (local or PCI), an "end of chain" marker, an "interrupt on + * terminal count" bit, and a data transfer direction. + */ struct plx_dma_desc { __le32 pci_start_addr; __le32 local_start_addr; - /* transfer_size is in bytes, only first 23 bits of register are used */ __le32 transfer_size; - /* - * address of next descriptor (quad word aligned), plus some - * additional bits (see PLX_REG_DMADPR) - */ __le32 next; }; @@ -594,6 +605,18 @@ struct plx_dma_desc { #define PLX_PREFETCH 32 +/** + * plx9080_abort_dma - Abort a PLX PCI 9080 DMA transfer + * @iobase: Remapped base address of configuration registers. + * @channel: DMA channel number (0 or 1). + * + * Aborts the DMA transfer on the channel, which must have been enabled + * and started beforehand. + * + * Return: + * %0 on success. + * -%ETIMEDOUT if timed out waiting for abort to complete. + */ static inline int plx9080_abort_dma(void __iomem *iobase, unsigned int channel) { void __iomem *dma_cs_addr; -- cgit v1.1 From 52caeb4ad1f38d6984c9ce456169669fae363cfc Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 20 May 2016 14:49:22 +0100 Subject: staging: comedi: plx9080.h: include headers for declarations Add `#include` lines to declare stuff used by "plx9080.h" itself. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/plx9080.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index f67f9d7..0e20cc5 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -19,6 +19,13 @@ #ifndef __COMEDI_PLX9080_H #define __COMEDI_PLX9080_H +#include +#include +#include +#include +#include +#include + /** * struct plx_dma_desc - DMA descriptor format for PLX PCI 9080 * @pci_start_addr: PCI Bus address for transfer (DMAPADR). -- cgit v1.1 From 931987a0c6da7404f64e650fa3fd2d5659c61280 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 8 Jun 2016 11:26:38 -0700 Subject: staging: comedi: addi_apci_1564: clarify change-of-state interrupt support This board supports change-of-state interrupts on digital inputs 4 to 19 not 0 to 15. The current code "works" but it could set inappropriate bits in the mode1 and mode2 registers that setup which channels are enabled. It also doesn't return the status of the upper 4 channels (19 to 16). Fix the comment and mask the mode1/mode2 values so that only the interrupt capable channels can be enabled. Add the SDF_LSAMPL flag to the subdevice so that 32-bit samples are used instead of 16-bit ones. This allows returning the upper 4 channels. Use the remaining bits in the sample to return "event" flags to the user. The timer and counter subdevices can also generate interrupts and are a bit hacked. They don't currently follow the comedi API and they use send_sig() to let the task that know that the interrupt occured. The "event" flags will be used instead when these subdevices are fixed. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 41 +++++++++++++++++-------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index f1ccfbd..9350f59 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -77,6 +77,7 @@ #define APCI1564_DI_REG 0x00 #define APCI1564_DI_INT_MODE1_REG 0x04 #define APCI1564_DI_INT_MODE2_REG 0x08 +#define APCI1564_DI_INT_MODE_MASK 0x000ffff0 /* chans [19:4] */ #define APCI1564_DI_INT_STATUS_REG 0x0c #define APCI1564_DI_IRQ_REG 0x10 #define APCI1564_DI_IRQ_ENA BIT(2) @@ -111,11 +112,18 @@ */ #define APCI1564_COUNTER(x) ((x) * 0x20) +/* + * The dev->read_subdev is used to return the interrupt events along with + * the state of the interrupt capable inputs. + */ +#define APCI1564_EVENT_COS BIT(31) +#define APCI1564_EVENT_MASK 0xfff0000f /* all but [19:4] */ + struct apci1564_private { unsigned long eeprom; /* base address of EEPROM register */ unsigned long timer; /* base address of 12-bit timer */ unsigned long counters; /* base address of 32-bit counters */ - unsigned int mode1; /* riding-edge/high level channels */ + unsigned int mode1; /* rising-edge/high level channels */ unsigned int mode2; /* falling-edge/low level channels */ unsigned int ctrl; /* interrupt mode OR (edge) . AND (level) */ struct task_struct *tsk_current; @@ -165,18 +173,18 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) unsigned int ctrl; unsigned int chan; + s->state &= ~APCI1564_EVENT_MASK; + status = inl(dev->iobase + APCI1564_DI_IRQ_REG); if (status & APCI1564_DI_IRQ_ENA) { - /* disable the interrupt */ + /* get the COS interrupt state and set the event flag */ + s->state = inl(dev->iobase + APCI1564_DI_INT_STATUS_REG); + s->state &= APCI1564_DI_INT_MODE_MASK; + s->state |= APCI1564_EVENT_COS; + + /* clear the interrupt */ outl(status & ~APCI1564_DI_IRQ_ENA, dev->iobase + APCI1564_DI_IRQ_REG); - - s->state = inl(dev->iobase + APCI1564_DI_INT_STATUS_REG) & - 0xffff; - comedi_buf_write_samples(s, &s->state, 1); - comedi_handle_events(dev, s); - - /* enable the interrupt */ outl(status, dev->iobase + APCI1564_DI_IRQ_REG); } @@ -214,6 +222,11 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) } } + if (s->state & APCI1564_EVENT_MASK) { + comedi_buf_write_samples(s, &s->state, 1); + comedi_handle_events(dev, s); + } + return IRQ_HANDLED; } @@ -255,7 +268,7 @@ static int apci1564_diag_insn_bits(struct comedi_device *dev, /* * Change-Of-State (COS) interrupt configuration * - * Channels 0 to 15 are interruptible. These channels can be configured + * Channels 4 to 19 are interruptible. These channels can be configured * to generate interrupts based on AND/OR logic for the desired channels. * * OR logic @@ -343,6 +356,10 @@ static int apci1564_cos_insn_config(struct comedi_device *dev, default: return -EINVAL; } + + /* ensure the mode bits are in-range for channels [19:4] */ + devpriv->mode1 &= APCI1564_DI_INT_MODE_MASK; + devpriv->mode2 &= APCI1564_DI_INT_MODE_MASK; break; default: return -EINVAL; @@ -409,7 +426,7 @@ static int apci1564_cos_cmd(struct comedi_device *dev, { struct apci1564_private *devpriv = dev->private; - if (!devpriv->ctrl) { + if (!devpriv->ctrl && !(devpriv->mode1 || devpriv->mode2)) { dev_warn(dev->class_dev, "Interrupts disabled due to mode configuration!\n"); return -EINVAL; @@ -501,7 +518,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, if (dev->irq) { dev->read_subdev = s; s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_CMD_READ; + s->subdev_flags = SDF_READABLE | SDF_CMD_READ | SDF_LSAMPL; s->n_chan = 1; s->maxdata = 1; s->range_table = &range_digital; -- cgit v1.1 From ff9842b651c501a2f13295035c5eb48d4b8e49b3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 8 Jun 2016 11:26:39 -0700 Subject: staging: comedi: addi_apci_1564: use comedi_handle_event() for timer The timer subdevice can generate an interrupt. Currently send_sig() is used to let the task know when the interrupt occurs. Use the dev->read_subdev and comedi_handle_events() instead. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 9350f59..45c1558 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -117,6 +117,7 @@ * the state of the interrupt capable inputs. */ #define APCI1564_EVENT_COS BIT(31) +#define APCI1564_EVENT_TIMER BIT(30) #define APCI1564_EVENT_MASK 0xfff0000f /* all but [19:4] */ struct apci1564_private { @@ -189,15 +190,12 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) } status = inl(devpriv->timer + ADDI_TCW_IRQ_REG); - if (status & 0x01) { - /* Disable Timer Interrupt */ + if (status & ADDI_TCW_IRQ) { + s->state |= APCI1564_EVENT_TIMER; + + /* clear the interrupt */ ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); outl(0x0, devpriv->timer + ADDI_TCW_CTRL_REG); - - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_current, 0); - - /* Enable Timer Interrupt */ outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG); } -- cgit v1.1 From a23b85a5ab9f19936ac673104f0e5b57a7ab13a1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 8 Jun 2016 11:26:40 -0700 Subject: staging: comedi: addi_apci_1564: use comedi_handle_event() for counters The counter subdevice can generate an interrupt. Currently send_sig() is used to let the task know when the interrupt occurs. Use the dev->read_subdev and comedi_handle_events() instead. Remove the, now unused, 'tsk_current' member from the private data and the unnecessary include of . Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi-data/hwdrv_apci1564.c | 4 ---- drivers/staging/comedi/drivers/addi_apci_1564.c | 16 ++++++---------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index f0c0d58..d6b2880 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -6,8 +6,6 @@ static int apci1564_timer_insn_config(struct comedi_device *dev, struct apci1564_private *devpriv = dev->private; unsigned int ctrl; - devpriv->tsk_current = current; - /* Stop the timer */ ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG | @@ -101,8 +99,6 @@ static int apci1564_counter_insn_config(struct comedi_device *dev, unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); unsigned int ctrl; - devpriv->tsk_current = current; - /* Stop The Timer */ ctrl = inl(iobase + ADDI_TCW_CTRL_REG); ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG | diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 45c1558..4af45d8 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -23,7 +23,6 @@ #include #include -#include #include "../comedi_pci.h" #include "addi_tcw.h" @@ -118,6 +117,7 @@ */ #define APCI1564_EVENT_COS BIT(31) #define APCI1564_EVENT_TIMER BIT(30) +#define APCI1564_EVENT_COUNTER(x) BIT(27 + (x)) /* counter 0-2 */ #define APCI1564_EVENT_MASK 0xfff0000f /* all but [19:4] */ struct apci1564_private { @@ -127,7 +127,6 @@ struct apci1564_private { unsigned int mode1; /* rising-edge/high level channels */ unsigned int mode2; /* falling-edge/low level channels */ unsigned int ctrl; /* interrupt mode OR (edge) . AND (level) */ - struct task_struct *tsk_current; }; #include "addi-data/hwdrv_apci1564.c" @@ -200,21 +199,18 @@ static irqreturn_t apci1564_interrupt(int irq, void *d) } if (devpriv->counters) { - for (chan = 0; chan < 4; chan++) { + for (chan = 0; chan < 3; chan++) { unsigned long iobase; iobase = devpriv->counters + APCI1564_COUNTER(chan); status = inl(iobase + ADDI_TCW_IRQ_REG); - if (status & 0x01) { - /* Disable Counter Interrupt */ + if (status & ADDI_TCW_IRQ) { + s->state |= APCI1564_EVENT_COUNTER(chan); + + /* clear the interrupt */ ctrl = inl(iobase + ADDI_TCW_CTRL_REG); outl(0x0, iobase + ADDI_TCW_CTRL_REG); - - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_current, 0); - - /* Enable Counter Interrupt */ outl(ctrl, iobase + ADDI_TCW_CTRL_REG); } } -- cgit v1.1 From 05704ffafaea7b5176b4469d48487c86cba4861b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 8 Jun 2016 11:26:41 -0700 Subject: staging: comedi: addi_apci_1564: rewrite the timer subdevice support The support functions for the timer subdevice are broken. 1) The (*insn_write) assumes that insn->n is always 2 (data[1] is used) 2) The (*insn_read) assumes that insn->n is always 2 (data can be returned in data[0] and data[1]). 3) The (*insn_config) does not follow the API. It assumes insn->n is always 4 (data[1], data[2] and data[3] are used). It also doesn't use data[0] to determine what the config "instruction" is. Rewrite the code to follow the comedi API and add the missing comedi driver comment block. The new implementation is based on the (minimal) datasheet I have from ADDI-DATA. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 91 --------------- drivers/staging/comedi/drivers/addi_apci_1564.c | 129 +++++++++++++++++++++ 2 files changed, 129 insertions(+), 91 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c index d6b2880..a1df66d 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c @@ -1,94 +1,3 @@ -static int apci1564_timer_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1564_private *devpriv = dev->private; - unsigned int ctrl; - - /* Stop the timer */ - ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); - ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG | - ADDI_TCW_CTRL_ENA); - outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG); - - if (data[1] == 1) { - /* Enable timer int & disable all the other int sources */ - outl(ADDI_TCW_CTRL_IRQ_ENA, - devpriv->timer + ADDI_TCW_CTRL_REG); - outl(0x0, dev->iobase + APCI1564_DI_IRQ_REG); - outl(0x0, dev->iobase + APCI1564_DO_IRQ_REG); - outl(0x0, dev->iobase + APCI1564_WDOG_IRQ_REG); - if (devpriv->counters) { - unsigned long iobase; - - iobase = devpriv->counters + ADDI_TCW_IRQ_REG; - outl(0x0, iobase + APCI1564_COUNTER(0)); - outl(0x0, iobase + APCI1564_COUNTER(1)); - outl(0x0, iobase + APCI1564_COUNTER(2)); - } - } else { - /* disable Timer interrupt */ - outl(0x0, devpriv->timer + ADDI_TCW_CTRL_REG); - } - - /* Loading Timebase */ - outl(data[2], devpriv->timer + ADDI_TCW_TIMEBASE_REG); - - /* Loading the Reload value */ - outl(data[3], devpriv->timer + ADDI_TCW_RELOAD_REG); - - ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); - ctrl &= ~(ADDI_TCW_CTRL_CNTR_ENA | ADDI_TCW_CTRL_MODE_MASK | - ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG | - ADDI_TCW_CTRL_TIMER_ENA | ADDI_TCW_CTRL_RESET_ENA | - ADDI_TCW_CTRL_WARN_ENA | ADDI_TCW_CTRL_ENA); - ctrl |= ADDI_TCW_CTRL_MODE(2) | ADDI_TCW_CTRL_TIMER_ENA; - outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG); - - return insn->n; -} - -static int apci1564_timer_insn_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1564_private *devpriv = dev->private; - unsigned int ctrl; - - ctrl = inl(devpriv->timer + ADDI_TCW_CTRL_REG); - ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG); - switch (data[1]) { - case 0: /* Stop The Timer */ - ctrl &= ~ADDI_TCW_CTRL_ENA; - break; - case 1: /* Enable the Timer */ - ctrl |= ADDI_TCW_CTRL_ENA; - break; - } - outl(ctrl, devpriv->timer + ADDI_TCW_CTRL_REG); - - return insn->n; -} - -static int apci1564_timer_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1564_private *devpriv = dev->private; - - /* Stores the status of the Timer */ - data[0] = inl(devpriv->timer + ADDI_TCW_STATUS_REG) & - ADDI_TCW_STATUS_OVERFLOW; - - /* Stores the Actual value of the Timer */ - data[1] = inl(devpriv->timer + ADDI_TCW_VAL_REG); - - return insn->n; -} - static int apci1564_counter_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 4af45d8..3e8ac67 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -21,6 +21,54 @@ * details. */ +/* + * Driver: addi_apci_1564 + * Description: ADDI-DATA APCI-1564 Digital I/O board + * Devices: [ADDI-DATA] APCI-1564 (addi_apci_1564) + * Author: H Hartley Sweeten + * Updated: Thu, 02 Jun 2016 13:12:46 -0700 + * Status: untested + * + * Configuration Options: not applicable, uses comedi PCI auto config + * + * This board has the following features: + * - 32 optically isolated digital inputs (24V), 16 of which can + * generate change-of-state (COS) interrupts (channels 4 to 19) + * - 32 optically isolated digital outputs (10V to 36V) + * - 1 8-bit watchdog for resetting the outputs + * - 1 12-bit timer + * - 3 32-bit counters + * - 2 diagnostic inputs + * + * The COS, timer, and counter subdevices all use the dev->read_subdev to + * return the interrupt status. The sample data is updated and returned when + * any of these subdevices generate an interrupt. The sample data format is: + * + * Bit Description + * ----- ------------------------------------------ + * 31 COS interrupt + * 30 timer interrupt + * 29 counter 2 interrupt + * 28 counter 1 interrupt + * 27 counter 0 interrupt + * 26:20 not used + * 19:4 COS digital input state (channels 19 to 4) + * 3:0 not used + * + * The COS interrupts must be configured using an INSN_CONFIG_DIGITAL_TRIG + * instruction before they can be enabled by an async command. The COS + * interrupts will stay active until canceled. + * + * The timer subdevice does not use an async command. All control is handled + * by the (*insn_config). + * + * FIXME: The format of the ADDI_TCW_TIMEBASE_REG is not descibed in the + * datasheet I have. The INSN_CONFIG_SET_CLOCK_SRC currently just writes + * the raw data[1] to this register along with the raw data[2] value to the + * ADDI_TCW_RELOAD_REG. If anyone tests this and can determine the actual + * timebase/reload operation please let me know. + */ + #include #include @@ -444,6 +492,87 @@ static int apci1564_cos_cancel(struct comedi_device *dev, return 0; } +static int apci1564_timer_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci1564_private *devpriv = dev->private; + unsigned int val; + + switch (data[0]) { + case INSN_CONFIG_ARM: + if (data[1] > s->maxdata) + return -EINVAL; + outl(data[1], devpriv->timer + ADDI_TCW_RELOAD_REG); + outl(ADDI_TCW_CTRL_IRQ_ENA | ADDI_TCW_CTRL_TIMER_ENA, + devpriv->timer + ADDI_TCW_CTRL_REG); + break; + case INSN_CONFIG_DISARM: + outl(0x0, devpriv->timer + ADDI_TCW_CTRL_REG); + break; + case INSN_CONFIG_GET_COUNTER_STATUS: + data[1] = 0; + val = inl(devpriv->timer + ADDI_TCW_CTRL_REG); + if (val & ADDI_TCW_CTRL_IRQ_ENA) + data[1] |= COMEDI_COUNTER_ARMED; + if (val & ADDI_TCW_CTRL_TIMER_ENA) + data[1] |= COMEDI_COUNTER_COUNTING; + val = inl(devpriv->timer + ADDI_TCW_STATUS_REG); + if (val & ADDI_TCW_STATUS_OVERFLOW) + data[1] |= COMEDI_COUNTER_TERMINAL_COUNT; + data[2] = COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING | + COMEDI_COUNTER_TERMINAL_COUNT; + break; + case INSN_CONFIG_SET_CLOCK_SRC: + if (data[2] > s->maxdata) + return -EINVAL; + outl(data[1], devpriv->timer + ADDI_TCW_TIMEBASE_REG); + outl(data[2], devpriv->timer + ADDI_TCW_RELOAD_REG); + break; + case INSN_CONFIG_GET_CLOCK_SRC: + data[1] = inl(devpriv->timer + ADDI_TCW_TIMEBASE_REG); + data[2] = inl(devpriv->timer + ADDI_TCW_RELOAD_REG); + break; + default: + return -EINVAL; + } + + return insn->n; +} + +static int apci1564_timer_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci1564_private *devpriv = dev->private; + + /* just write the last last to the reload register */ + if (insn->n) { + unsigned int val = data[insn->n - 1]; + + outl(val, devpriv->timer + ADDI_TCW_RELOAD_REG); + } + + return insn->n; +} + +static int apci1564_timer_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci1564_private *devpriv = dev->private; + int i; + + /* return the actual value of the timer */ + for (i = 0; i < insn->n; i++) + data[i] = inl(devpriv->timer + ADDI_TCW_VAL_REG); + + return insn->n; +} + static int apci1564_auto_attach(struct comedi_device *dev, unsigned long context_unused) { -- cgit v1.1 From 2ec19efbc8d4c5646b8205564678568fa26e4b32 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 8 Jun 2016 11:26:42 -0700 Subject: staging: comedi: addi_apci_1564: rewrite the counter subdevice support Like the timer, the support functions for the counter subdevice are broken. Rewrite the code to follow the comedi API. The new implementation is based on the (minimal) datasheet I have from ADDI-DATA. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/hwdrv_apci1564.c | 92 --------------------- drivers/staging/comedi/drivers/addi_apci_1564.c | 94 +++++++++++++++++++++- 2 files changed, 92 insertions(+), 94 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c deleted file mode 100644 index a1df66d..0000000 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci1564.c +++ /dev/null @@ -1,92 +0,0 @@ -static int apci1564_counter_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1564_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); - unsigned int ctrl; - - /* Stop The Timer */ - ctrl = inl(iobase + ADDI_TCW_CTRL_REG); - ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG | - ADDI_TCW_CTRL_ENA); - outl(ctrl, iobase + ADDI_TCW_CTRL_REG); - - /* Set the reload value */ - outl(data[3], iobase + ADDI_TCW_RELOAD_REG); - - /* Set the mode */ - ctrl &= ~(ADDI_TCW_CTRL_EXT_CLK_MASK | ADDI_TCW_CTRL_MODE_MASK | - ADDI_TCW_CTRL_TIMER_ENA | ADDI_TCW_CTRL_RESET_ENA | - ADDI_TCW_CTRL_WARN_ENA); - ctrl |= ADDI_TCW_CTRL_CNTR_ENA | ADDI_TCW_CTRL_MODE(data[4]); - outl(ctrl, iobase + ADDI_TCW_CTRL_REG); - - /* Enable or Disable Interrupt */ - if (data[1]) - ctrl |= ADDI_TCW_CTRL_IRQ_ENA; - else - ctrl &= ~ADDI_TCW_CTRL_IRQ_ENA; - outl(ctrl, iobase + ADDI_TCW_CTRL_REG); - - /* Set the Up/Down selection */ - if (data[6]) - ctrl |= ADDI_TCW_CTRL_CNT_UP; - else - ctrl &= ~ADDI_TCW_CTRL_CNT_UP; - outl(ctrl, iobase + ADDI_TCW_CTRL_REG); - - return insn->n; -} - -static int apci1564_counter_insn_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1564_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); - unsigned int ctrl; - - ctrl = inl(iobase + ADDI_TCW_CTRL_REG); - ctrl &= ~(ADDI_TCW_CTRL_GATE | ADDI_TCW_CTRL_TRIG); - switch (data[1]) { - case 0: /* Stops the Counter subdevice */ - ctrl = 0; - break; - case 1: /* Start the Counter subdevice */ - ctrl |= ADDI_TCW_CTRL_ENA; - break; - case 2: /* Clears the Counter subdevice */ - ctrl |= ADDI_TCW_CTRL_GATE; - break; - } - outl(ctrl, iobase + ADDI_TCW_CTRL_REG); - - return insn->n; -} - -static int apci1564_counter_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct apci1564_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); - unsigned int status; - - /* Read the Counter Actual Value. */ - data[0] = inl(iobase + ADDI_TCW_VAL_REG); - - status = inl(iobase + ADDI_TCW_STATUS_REG); - data[1] = (status & ADDI_TCW_STATUS_SOFT_TRIG) ? 1 : 0; - data[2] = (status & ADDI_TCW_STATUS_HARDWARE_TRIG) ? 1 : 0; - data[3] = (status & ADDI_TCW_STATUS_SOFT_CLR) ? 1 : 0; - data[4] = (status & ADDI_TCW_STATUS_OVERFLOW) ? 1 : 0; - - return insn->n; -} diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 3e8ac67..5813de5 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -67,6 +67,12 @@ * the raw data[1] to this register along with the raw data[2] value to the * ADDI_TCW_RELOAD_REG. If anyone tests this and can determine the actual * timebase/reload operation please let me know. + * + * The counter subdevice also does not use an async command. All control is + * handled by the (*insn_config). + * + * FIXME: The operation of the counters is not really described in the + * datasheet I have. The (*insn_config) needs more work. */ #include @@ -177,8 +183,6 @@ struct apci1564_private { unsigned int ctrl; /* interrupt mode OR (edge) . AND (level) */ }; -#include "addi-data/hwdrv_apci1564.c" - static int apci1564_reset(struct comedi_device *dev) { struct apci1564_private *devpriv = dev->private; @@ -573,6 +577,92 @@ static int apci1564_timer_insn_read(struct comedi_device *dev, return insn->n; } +static int apci1564_counter_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci1564_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); + unsigned int val; + + switch (data[0]) { + case INSN_CONFIG_ARM: + val = inl(iobase + ADDI_TCW_CTRL_REG); + val |= ADDI_TCW_CTRL_IRQ_ENA | ADDI_TCW_CTRL_CNTR_ENA; + outl(data[1], iobase + ADDI_TCW_RELOAD_REG); + outl(val, iobase + ADDI_TCW_CTRL_REG); + break; + case INSN_CONFIG_DISARM: + val = inl(iobase + ADDI_TCW_CTRL_REG); + val &= ~(ADDI_TCW_CTRL_IRQ_ENA | ADDI_TCW_CTRL_CNTR_ENA); + outl(val, iobase + ADDI_TCW_CTRL_REG); + break; + case INSN_CONFIG_SET_COUNTER_MODE: + /* + * FIXME: The counter operation is not described in the + * datasheet. For now just write the raw data[1] value to + * the control register. + */ + outl(data[1], iobase + ADDI_TCW_CTRL_REG); + break; + case INSN_CONFIG_GET_COUNTER_STATUS: + data[1] = 0; + val = inl(iobase + ADDI_TCW_CTRL_REG); + if (val & ADDI_TCW_CTRL_IRQ_ENA) + data[1] |= COMEDI_COUNTER_ARMED; + if (val & ADDI_TCW_CTRL_CNTR_ENA) + data[1] |= COMEDI_COUNTER_COUNTING; + val = inl(iobase + ADDI_TCW_STATUS_REG); + if (val & ADDI_TCW_STATUS_OVERFLOW) + data[1] |= COMEDI_COUNTER_TERMINAL_COUNT; + data[2] = COMEDI_COUNTER_ARMED | COMEDI_COUNTER_COUNTING | + COMEDI_COUNTER_TERMINAL_COUNT; + break; + default: + return -EINVAL; + } + + return insn->n; +} + +static int apci1564_counter_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci1564_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); + + /* just write the last last to the reload register */ + if (insn->n) { + unsigned int val = data[insn->n - 1]; + + outl(val, iobase + ADDI_TCW_RELOAD_REG); + } + + return insn->n; +} + +static int apci1564_counter_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + struct apci1564_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned long iobase = devpriv->counters + APCI1564_COUNTER(chan); + int i; + + /* return the actual value of the counter */ + for (i = 0; i < insn->n; i++) + data[i] = inl(iobase + ADDI_TCW_VAL_REG); + + return insn->n; +} + static int apci1564_auto_attach(struct comedi_device *dev, unsigned long context_unused) { -- cgit v1.1 From 20cefae2d278a056417c24315d0b0cd8d3e97c9a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 8 Jun 2016 11:26:43 -0700 Subject: staging: comedi: addi_apci_1564: remove unnecessary wdog register defines The watchdog subdevice is supported using the addi_watchdog module and it uses the register defines from addi_tcw.h. The only register define needed it the iobase offset to the register block. Remove the unnecessary defines and rename the iobase define. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1564.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 5813de5..9bfb79c 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -144,14 +144,7 @@ #define APCI1564_DO_INT_STATUS_VCC BIT(0) #define APCI1564_DO_IRQ_REG 0x20 #define APCI1564_DO_IRQ_INTR BIT(0) -#define APCI1564_WDOG_REG 0x24 -#define APCI1564_WDOG_RELOAD_REG 0x28 -#define APCI1564_WDOG_TIMEBASE_REG 0x2c -#define APCI1564_WDOG_CTRL_REG 0x30 -#define APCI1564_WDOG_STATUS_REG 0x34 -#define APCI1564_WDOG_IRQ_REG 0x38 -#define APCI1564_WDOG_WARN_TIMEVAL_REG 0x3c -#define APCI1564_WDOG_WARN_TIMEBASE_REG 0x40 +#define APCI1564_WDOG_IOBASE 0x24 /* * devpriv->timer Register Map (see addi_tcw.h for register/bit defines) @@ -198,7 +191,7 @@ static int apci1564_reset(struct comedi_device *dev) outl(0x0, dev->iobase + APCI1564_DO_INT_CTRL_REG); /* Reset the watchdog registers */ - addi_watchdog_reset(dev->iobase + APCI1564_WDOG_REG); + addi_watchdog_reset(dev->iobase + APCI1564_WDOG_IOBASE); /* Reset the timer registers */ outl(0x0, devpriv->timer + ADDI_TCW_CTRL_REG); @@ -773,7 +766,7 @@ static int apci1564_auto_attach(struct comedi_device *dev, /* Initialize the watchdog subdevice */ s = &dev->subdevices[5]; - ret = addi_watchdog_init(s, dev->iobase + APCI1564_WDOG_REG); + ret = addi_watchdog_init(s, dev->iobase + APCI1564_WDOG_IOBASE); if (ret) return ret; -- cgit v1.1 From 6f594b82038d0f9d72f8a6dce1a72e3c88d9961a Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sat, 4 Jun 2016 06:35:20 +0100 Subject: staging: comedi: adl_pci9118: fix spelling mistake "acqusition" -> "acquisition" trivial fix to spelling mistake Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 4437ea3..be70bd3 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -570,7 +570,7 @@ static int pci9118_ai_cancel(struct comedi_device *dev, /* set default config (disable burst and triggers) */ devpriv->ai_cfg = PCI9118_AI_CFG_PDTRG | PCI9118_AI_CFG_PETRG; outl(devpriv->ai_cfg, dev->iobase + PCI9118_AI_CFG_REG); - /* reset acqusition control */ + /* reset acquisition control */ devpriv->ai_ctrl = 0; outl(devpriv->ai_ctrl, dev->iobase + PCI9118_AI_CTRL_REG); outl(0, dev->iobase + PCI9118_AI_BURST_NUM_REG); @@ -1022,12 +1022,12 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* * Configure analog input and load the chanlist. - * The acqusition control bits are enabled later. + * The acquisition control bits are enabled later. */ pci9118_set_chanlist(dev, s, cmd->chanlist_len, cmd->chanlist, devpriv->ai_add_front, devpriv->ai_add_back); - /* Determine acqusition mode and calculate timing */ + /* Determine acquisition mode and calculate timing */ devpriv->ai_do = 0; if (cmd->scan_begin_src != TRIG_TIMER && cmd->convert_src == TRIG_TIMER) { @@ -1097,7 +1097,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (devpriv->ai_do == 0) { dev_err(dev->class_dev, - "Unable to determine acqusition mode! BUG in (*do_cmdtest)?\n"); + "Unable to determine acquisition mode! BUG in (*do_cmdtest)?\n"); return -EINVAL; } -- cgit v1.1 From 45de2688191fb276fee4cd6bc35805e20e484e41 Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Mon, 6 Jun 2016 16:31:15 +0530 Subject: Staging: comedi: Indentation issue in mpc624.c This is a patch to the mpc624.c file that fixes up a WARNING: 'Statements should start on a tabstop' found by the checkpatch.pl tool. Signed-off-by: Ravishankar Karkala Mallikarjunayya Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mpc624.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c index 826e439..9bda761 100644 --- a/drivers/staging/comedi/drivers/mpc624.c +++ b/drivers/staging/comedi/drivers/mpc624.c @@ -103,7 +103,7 @@ static const struct comedi_lrange range_mpc624_bipolar1 = { /* BIP_RANGE(1.01) this is correct, */ /* but my MPC-624 actually seems to have a range of 2.02 */ BIP_RANGE(2.02) - } + } }; static const struct comedi_lrange range_mpc624_bipolar10 = { @@ -112,7 +112,7 @@ static const struct comedi_lrange range_mpc624_bipolar10 = { /* BIP_RANGE(10.1) this is correct, */ /* but my MPC-624 actually seems to have a range of 20.2 */ BIP_RANGE(20.2) - } + } }; static unsigned int mpc624_ai_get_sample(struct comedi_device *dev, -- cgit v1.1 From e31eae76185cb4f86e5edf4f1f26b728863ded6b Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Mon, 6 Jun 2016 16:31:16 +0530 Subject: Staging: comedi:Fix a warning issues in me_daq.c This is a patch to the me_daq.c file that fixes up a WARNING: Prefer 'unsigned int' to bare use of 'unsigned' found by the checkpatch.pl tool. Signed-off-by: Ravishankar Karkala Mallikarjunayya Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/me_daq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 3bf0caa..c0b7a30 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -150,7 +150,7 @@ struct me_private_data { unsigned short dac_ctrl; /* Mirror of the DAC_CONTROL register */ }; -static inline void sleep(unsigned sec) +static inline void sleep(unsigned int sec) { schedule_timeout_interruptible(sec * HZ); } -- cgit v1.1 From fb999e7fab6cdf6dee6df087159a0acc2f3b236b Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Mon, 6 Jun 2016 16:31:17 +0530 Subject: Staging: comedi: Fix comment issues in jr3_pci.c This is a patch to the jr3_pci.c file that fixes up a WARNING: 'Block comments use a trailing */ on a separate line' found by the checkpatch.pl tool. Signed-off-by: Ravishankar Karkala Mallikarjunayya Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/jr3_pci.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index b87192e..fa0d4b1 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -1,20 +1,20 @@ /* - comedi/drivers/jr3_pci.c - hardware driver for JR3/PCI force sensor board - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 2007 Anders Blomdell - - 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. -*/ + * comedi/drivers/jr3_pci.c + * hardware driver for JR3/PCI force sensor board + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2007 Anders Blomdell + * + * 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. + */ /* * Driver: jr3_pci * Description: JR3/PCI force sensor board -- cgit v1.1 From 86c7815e9773bab44d244428d083a43e5a6f7aca Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Mon, 6 Jun 2016 16:31:18 +0530 Subject: Staging: comedi: Prefer using the BIT macro issue in das16.c This patch Replace all occurences of (1< Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index fd8e0b7..69133e3 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -92,37 +92,37 @@ #define DAS16_AO_LSB_REG(x) ((x) ? 0x06 : 0x04) #define DAS16_AO_MSB_REG(x) ((x) ? 0x07 : 0x05) #define DAS16_STATUS_REG 0x08 -#define DAS16_STATUS_BUSY (1 << 7) -#define DAS16_STATUS_UNIPOLAR (1 << 6) -#define DAS16_STATUS_MUXBIT (1 << 5) -#define DAS16_STATUS_INT (1 << 4) +#define DAS16_STATUS_BUSY BIT(7) +#define DAS16_STATUS_UNIPOLAR BIT(6) +#define DAS16_STATUS_MUXBIT BIT(5) +#define DAS16_STATUS_INT BIT(4) #define DAS16_CTRL_REG 0x09 -#define DAS16_CTRL_INTE (1 << 7) +#define DAS16_CTRL_INTE BIT(7) #define DAS16_CTRL_IRQ(x) (((x) & 0x7) << 4) -#define DAS16_CTRL_DMAE (1 << 2) +#define DAS16_CTRL_DMAE BIT(2) #define DAS16_CTRL_PACING_MASK (3 << 0) #define DAS16_CTRL_INT_PACER (3 << 0) #define DAS16_CTRL_EXT_PACER (2 << 0) #define DAS16_CTRL_SOFT_PACER (0 << 0) #define DAS16_PACER_REG 0x0a #define DAS16_PACER_BURST_LEN(x) (((x) & 0xf) << 4) -#define DAS16_PACER_CTR0 (1 << 1) -#define DAS16_PACER_TRIG0 (1 << 0) +#define DAS16_PACER_CTR0 BIT(1) +#define DAS16_PACER_TRIG0 BIT(0) #define DAS16_GAIN_REG 0x0b #define DAS16_TIMER_BASE_REG 0x0c /* to 0x0f */ #define DAS1600_CONV_REG 0x404 -#define DAS1600_CONV_DISABLE (1 << 6) +#define DAS1600_CONV_DISABLE BIT(6) #define DAS1600_BURST_REG 0x405 -#define DAS1600_BURST_VAL (1 << 6) +#define DAS1600_BURST_VAL BIT(6) #define DAS1600_ENABLE_REG 0x406 -#define DAS1600_ENABLE_VAL (1 << 6) +#define DAS1600_ENABLE_VAL BIT(6) #define DAS1600_STATUS_REG 0x407 -#define DAS1600_STATUS_BME (1 << 6) -#define DAS1600_STATUS_ME (1 << 5) -#define DAS1600_STATUS_CD (1 << 4) -#define DAS1600_STATUS_WS (1 << 1) -#define DAS1600_STATUS_CLK_10MHZ (1 << 0) +#define DAS1600_STATUS_BME BIT(6) +#define DAS1600_STATUS_ME BIT(5) +#define DAS1600_STATUS_CD BIT(4) +#define DAS1600_STATUS_WS BIT(1) +#define DAS1600_STATUS_CLK_10MHZ BIT(0) static const struct comedi_lrange range_das1x01_bip = { 4, { -- cgit v1.1 From 2c81ab4304d2b09bd4e1cde34b045a16d907974b Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Mon, 6 Jun 2016 16:31:20 +0530 Subject: Staging: comedi: fix BIT macro issue in das6402.c This patch Replace all occurences of (1< Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das6402.c | 74 ++++++++++++++++---------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index 1701294..0fdf5e0 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -50,48 +50,50 @@ #define DAS6402_AO_LSB_REG(x) (0x04 + ((x) * 2)) #define DAS6402_AO_MSB_REG(x) (0x05 + ((x) * 2)) #define DAS6402_STATUS_REG 0x08 -#define DAS6402_STATUS_FFNE (1 << 0) -#define DAS6402_STATUS_FHALF (1 << 1) -#define DAS6402_STATUS_FFULL (1 << 2) -#define DAS6402_STATUS_XINT (1 << 3) -#define DAS6402_STATUS_INT (1 << 4) -#define DAS6402_STATUS_XTRIG (1 << 5) -#define DAS6402_STATUS_INDGT (1 << 6) -#define DAS6402_STATUS_10MHZ (1 << 7) -#define DAS6402_STATUS_W_CLRINT (1 << 0) -#define DAS6402_STATUS_W_CLRXTR (1 << 1) -#define DAS6402_STATUS_W_CLRXIN (1 << 2) -#define DAS6402_STATUS_W_EXTEND (1 << 4) -#define DAS6402_STATUS_W_ARMED (1 << 5) -#define DAS6402_STATUS_W_POSTMODE (1 << 6) -#define DAS6402_STATUS_W_10MHZ (1 << 7) +#define DAS6402_STATUS_FFNE BIT(0) +#define DAS6402_STATUS_FHALF BIT(1) +#define DAS6402_STATUS_FFULL BIT(2) +#define DAS6402_STATUS_XINT BIT(3) +#define DAS6402_STATUS_INT BIT(4) +#define DAS6402_STATUS_XTRIG BIT(5) +#define DAS6402_STATUS_INDGT BIT(6) +#define DAS6402_STATUS_10MHZ BIT(7) +#define DAS6402_STATUS_W_CLRINT BIT(0) +#define DAS6402_STATUS_W_CLRXTR BIT(1) +#define DAS6402_STATUS_W_CLRXIN BIT(2) +#define DAS6402_STATUS_W_EXTEND BIT(4) +#define DAS6402_STATUS_W_ARMED BIT(5) +#define DAS6402_STATUS_W_POSTMODE BIT(6) +#define DAS6402_STATUS_W_10MHZ BIT(7) #define DAS6402_CTRL_REG 0x09 -#define DAS6402_CTRL_SOFT_TRIG (0 << 0) -#define DAS6402_CTRL_EXT_FALL_TRIG (1 << 0) -#define DAS6402_CTRL_EXT_RISE_TRIG (2 << 0) -#define DAS6402_CTRL_PACER_TRIG (3 << 0) -#define DAS6402_CTRL_BURSTEN (1 << 2) -#define DAS6402_CTRL_XINTE (1 << 3) +#define DAS6402_CTRL_TRIG(x) ((x) << 0) +#define DAS6402_CTRL_SOFT_TRIG DAS6402_CTRL_TRIG(0) +#define DAS6402_CTRL_EXT_FALL_TRIG DAS6402_CTRL_TRIG(1) +#define DAS6402_CTRL_EXT_RISE_TRIG DAS6402_CTRL_TRIG(2) +#define DAS6402_CTRL_PACER_TRIG DAS6402_CTRL_TRIG(3) +#define DAS6402_CTRL_BURSTEN BIT(2) +#define DAS6402_CTRL_XINTE BIT(3) #define DAS6402_CTRL_IRQ(x) ((x) << 4) -#define DAS6402_CTRL_INTE (1 << 7) +#define DAS6402_CTRL_INTE BIT(7) #define DAS6402_TRIG_REG 0x0a -#define DAS6402_TRIG_TGEN (1 << 0) -#define DAS6402_TRIG_TGSEL (1 << 1) -#define DAS6402_TRIG_TGPOL (1 << 2) -#define DAS6402_TRIG_PRETRIG (1 << 3) +#define DAS6402_TRIG_TGEN BIT(0) +#define DAS6402_TRIG_TGSEL BIT(1) +#define DAS6402_TRIG_TGPOL BIT(2) +#define DAS6402_TRIG_PRETRIG BIT(3) #define DAS6402_AO_RANGE(_chan, _range) ((_range) << ((_chan) ? 6 : 4)) #define DAS6402_AO_RANGE_MASK(_chan) (3 << ((_chan) ? 6 : 4)) #define DAS6402_MODE_REG 0x0b -#define DAS6402_MODE_RANGE(x) ((x) << 0) -#define DAS6402_MODE_POLLED (0 << 2) -#define DAS6402_MODE_FIFONEPTY (1 << 2) -#define DAS6402_MODE_FIFOHFULL (2 << 2) -#define DAS6402_MODE_EOB (3 << 2) -#define DAS6402_MODE_ENHANCED (1 << 4) -#define DAS6402_MODE_SE (1 << 5) -#define DAS6402_MODE_UNI (1 << 6) -#define DAS6402_MODE_DMA1 (0 << 7) -#define DAS6402_MODE_DMA3 (1 << 7) +#define DAS6402_MODE_RANGE(x) ((x) << 2) +#define DAS6402_MODE_POLLED DAS6402_MODE_RANGE(0) +#define DAS6402_MODE_FIFONEPTY DAS6402_MODE_RANGE(1) +#define DAS6402_MODE_FIFOHFULL DAS6402_MODE_RANGE(2) +#define DAS6402_MODE_EOB DAS6402_MODE_RANGE(3) +#define DAS6402_MODE_ENHANCED BIT(4) +#define DAS6402_MODE_SE BIT(5) +#define DAS6402_MODE_UNI BIT(6) +#define DAS6402_MODE_DMA(x) ((x) << 7) +#define DAS6402_MODE_DMA1 DAS6402_MODE_DMA(0) +#define DAS6402_MODE_DMA3 DAS6402_MODE_DMA(1) #define DAS6402_TIMER_BASE 0x0c static const struct comedi_lrange das6402_ai_ranges = { -- cgit v1.1 From 5efe11599e78600d4af230c9d1574bc2728428bd Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Mon, 6 Jun 2016 16:31:23 +0530 Subject: Staging: comedi: Used unsigned int instead of unsigned issue in jr3_pci.c This is a patch to the jr3_pci.c file that fixes up a WARNING: Prefer 'unsigned int' to bare use of 'unsigned' found by the checkpatch.pl tool. Signed-off-by: Ravishankar Karkala Mallikarjunayya Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/jr3_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index fa0d4b1..6c4ff02 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -231,7 +231,7 @@ static unsigned int jr3_pci_ai_read_chan(struct comedi_device *dev, if (chan < 56) { unsigned int axis = chan % 8; - unsigned filter = chan / 8; + unsigned int filter = chan / 8; switch (axis) { case 0: @@ -690,7 +690,7 @@ static int jr3_pci_auto_attach(struct comedi_device *dev, if (sizeof(struct jr3_channel) != 0xc00) { dev_err(dev->class_dev, "sizeof(struct jr3_channel) = %x [expected %x]\n", - (unsigned)sizeof(struct jr3_channel), 0xc00); + (unsigned int)sizeof(struct jr3_channel), 0xc00); return -EINVAL; } -- cgit v1.1 From d9b9c9a0339fb3f5b6c6365b144f1fa717f5b147 Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Tue, 14 Jun 2016 11:23:22 +0530 Subject: Staging: comedi: dmm32at: fix BIT macro issue. This Replace all occurences of (1< Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 98 ++++++++++++++++---------------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 958c0d4..b8606de 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -46,73 +46,75 @@ #define DMM32AT_AI_START_CONV_REG 0x00 #define DMM32AT_AI_LSB_REG 0x00 #define DMM32AT_AUX_DOUT_REG 0x01 -#define DMM32AT_AUX_DOUT2 (1 << 2) /* J3.42 - OUT2 (OUT2EN) */ -#define DMM32AT_AUX_DOUT1 (1 << 1) /* J3.43 */ -#define DMM32AT_AUX_DOUT0 (1 << 0) /* J3.44 - OUT0 (OUT0EN) */ +#define DMM32AT_AUX_DOUT2 BIT(2) /* J3.42 - OUT2 (OUT2EN) */ +#define DMM32AT_AUX_DOUT1 BIT(1) /* J3.43 */ +#define DMM32AT_AUX_DOUT0 BIT(0) /* J3.44 - OUT0 (OUT0EN) */ #define DMM32AT_AI_MSB_REG 0x01 #define DMM32AT_AI_LO_CHAN_REG 0x02 #define DMM32AT_AI_HI_CHAN_REG 0x03 #define DMM32AT_AUX_DI_REG 0x04 -#define DMM32AT_AUX_DI_DACBUSY (1 << 7) -#define DMM32AT_AUX_DI_CALBUSY (1 << 6) -#define DMM32AT_AUX_DI3 (1 << 3) /* J3.45 - ADCLK (CLKSEL) */ -#define DMM32AT_AUX_DI2 (1 << 2) /* J3.46 - GATE12 (GT12EN) */ -#define DMM32AT_AUX_DI1 (1 << 1) /* J3.47 - GATE0 (GT0EN) */ -#define DMM32AT_AUX_DI0 (1 << 0) /* J3.48 - CLK0 (SRC0) */ +#define DMM32AT_AUX_DI_DACBUSY BIT(7) +#define DMM32AT_AUX_DI_CALBUSY BIT(6) +#define DMM32AT_AUX_DI3 BIT(3) /* J3.45 - ADCLK (CLKSEL) */ +#define DMM32AT_AUX_DI2 BIT(2) /* J3.46 - GATE12 (GT12EN) */ +#define DMM32AT_AUX_DI1 BIT(1) /* J3.47 - GATE0 (GT0EN) */ +#define DMM32AT_AUX_DI0 BIT(0) /* J3.48 - CLK0 (SRC0) */ #define DMM32AT_AO_LSB_REG 0x04 #define DMM32AT_AO_MSB_REG 0x05 #define DMM32AT_AO_MSB_DACH(x) ((x) << 6) #define DMM32AT_FIFO_DEPTH_REG 0x06 #define DMM32AT_FIFO_CTRL_REG 0x07 -#define DMM32AT_FIFO_CTRL_FIFOEN (1 << 3) -#define DMM32AT_FIFO_CTRL_SCANEN (1 << 2) -#define DMM32AT_FIFO_CTRL_FIFORST (1 << 1) +#define DMM32AT_FIFO_CTRL_FIFOEN BIT(3) +#define DMM32AT_FIFO_CTRL_SCANEN BIT(2) +#define DMM32AT_FIFO_CTRL_FIFORST BIT(1) #define DMM32AT_FIFO_STATUS_REG 0x07 -#define DMM32AT_FIFO_STATUS_EF (1 << 7) -#define DMM32AT_FIFO_STATUS_HF (1 << 6) -#define DMM32AT_FIFO_STATUS_FF (1 << 5) -#define DMM32AT_FIFO_STATUS_OVF (1 << 4) -#define DMM32AT_FIFO_STATUS_FIFOEN (1 << 3) -#define DMM32AT_FIFO_STATUS_SCANEN (1 << 2) +#define DMM32AT_FIFO_STATUS_EF BIT(7) +#define DMM32AT_FIFO_STATUS_HF BIT(6) +#define DMM32AT_FIFO_STATUS_FF BIT(5) +#define DMM32AT_FIFO_STATUS_OVF BIT(4) +#define DMM32AT_FIFO_STATUS_FIFOEN BIT(3) +#define DMM32AT_FIFO_STATUS_SCANEN BIT(2) #define DMM32AT_FIFO_STATUS_PAGE_MASK (3 << 0) #define DMM32AT_CTRL_REG 0x08 -#define DMM32AT_CTRL_RESETA (1 << 5) -#define DMM32AT_CTRL_RESETD (1 << 4) -#define DMM32AT_CTRL_INTRST (1 << 3) -#define DMM32AT_CTRL_PAGE_8254 (0 << 0) -#define DMM32AT_CTRL_PAGE_8255 (1 << 0) -#define DMM32AT_CTRL_PAGE_CALIB (3 << 0) +#define DMM32AT_CTRL_RESETA BIT(5) +#define DMM32AT_CTRL_RESETD BIT(4) +#define DMM32AT_CTRL_INTRST BIT(3) +#define DMM32AT_CTRL_PAGE(x) ((x) << 0) +#define DMM32AT_CTRL_PAGE_8254 DMM32AT_CTRL_PAGE(0) +#define DMM32AT_CTRL_PAGE_8255 DMM32AT_CTRL_PAGE(1) +#define DMM32AT_CTRL_PAGE_CALIB DMM32AT_CTRL_PAGE(3) #define DMM32AT_AI_STATUS_REG 0x08 -#define DMM32AT_AI_STATUS_STS (1 << 7) -#define DMM32AT_AI_STATUS_SD1 (1 << 6) -#define DMM32AT_AI_STATUS_SD0 (1 << 5) +#define DMM32AT_AI_STATUS_STS BIT(7) +#define DMM32AT_AI_STATUS_SD1 BIT(6) +#define DMM32AT_AI_STATUS_SD0 BIT(5) #define DMM32AT_AI_STATUS_ADCH_MASK (0x1f << 0) #define DMM32AT_INTCLK_REG 0x09 -#define DMM32AT_INTCLK_ADINT (1 << 7) -#define DMM32AT_INTCLK_DINT (1 << 6) -#define DMM32AT_INTCLK_TINT (1 << 5) -#define DMM32AT_INTCLK_CLKEN (1 << 1) /* 1=see below 0=software */ -#define DMM32AT_INTCLK_CLKSEL (1 << 0) /* 1=OUT2 0=EXTCLK */ +#define DMM32AT_INTCLK_ADINT BIT(7) +#define DMM32AT_INTCLK_DINT BIT(6) +#define DMM32AT_INTCLK_TINT BIT(5) +#define DMM32AT_INTCLK_CLKEN BIT(1) /* 1=see below 0=software */ +#define DMM32AT_INTCLK_CLKSEL BIT(0) /* 1=OUT2 0=EXTCLK */ #define DMM32AT_CTRDIO_CFG_REG 0x0a -#define DMM32AT_CTRDIO_CFG_FREQ12 (1 << 7) /* CLK12 1=100KHz 0=10MHz */ -#define DMM32AT_CTRDIO_CFG_FREQ0 (1 << 6) /* CLK0 1=10KHz 0=10MHz */ -#define DMM32AT_CTRDIO_CFG_OUT2EN (1 << 5) /* J3.42 1=OUT2 is DOUT2 */ -#define DMM32AT_CTRDIO_CFG_OUT0EN (1 << 4) /* J3,44 1=OUT0 is DOUT0 */ -#define DMM32AT_CTRDIO_CFG_GT0EN (1 << 2) /* J3.47 1=DIN1 is GATE0 */ -#define DMM32AT_CTRDIO_CFG_SRC0 (1 << 1) /* CLK0 is 0=FREQ0 1=J3.48 */ -#define DMM32AT_CTRDIO_CFG_GT12EN (1 << 0) /* J3.46 1=DIN2 is GATE12 */ +#define DMM32AT_CTRDIO_CFG_FREQ12 BIT(7) /* CLK12 1=100KHz 0=10MHz */ +#define DMM32AT_CTRDIO_CFG_FREQ0 BIT(6) /* CLK0 1=10KHz 0=10MHz */ +#define DMM32AT_CTRDIO_CFG_OUT2EN BIT(5) /* J3.42 1=OUT2 is DOUT2 */ +#define DMM32AT_CTRDIO_CFG_OUT0EN BIT(4) /* J3,44 1=OUT0 is DOUT0 */ +#define DMM32AT_CTRDIO_CFG_GT0EN BIT(2) /* J3.47 1=DIN1 is GATE0 */ +#define DMM32AT_CTRDIO_CFG_SRC0 BIT(1) /* CLK0 is 0=FREQ0 1=J3.48 */ +#define DMM32AT_CTRDIO_CFG_GT12EN BIT(0) /* J3.46 1=DIN2 is GATE12 */ #define DMM32AT_AI_CFG_REG 0x0b -#define DMM32AT_AI_CFG_SCINT_20US (0 << 4) -#define DMM32AT_AI_CFG_SCINT_15US (1 << 4) -#define DMM32AT_AI_CFG_SCINT_10US (2 << 4) -#define DMM32AT_AI_CFG_SCINT_5US (3 << 4) -#define DMM32AT_AI_CFG_RANGE (1 << 3) /* 0=5V 1=10V */ -#define DMM32AT_AI_CFG_ADBU (1 << 2) /* 0=bipolar 1=unipolar */ +#define DMM32AT_AI_CFG_SCINT(x) ((x) << 4) +#define DMM32AT_AI_CFG_SCINT_20US DMM32AT_AI_CFG_SCINT(0) +#define DMM32AT_AI_CFG_SCINT_15US DMM32AT_AI_CFG_SCINT(1) +#define DMM32AT_AI_CFG_SCINT_10US DMM32AT_AI_CFG_SCINT(2) +#define DMM32AT_AI_CFG_SCINT_5US DMM32AT_AI_CFG_SCINT(3) +#define DMM32AT_AI_CFG_RANGE BIT(3) /* 0=5V 1=10V */ +#define DMM32AT_AI_CFG_ADBU BIT(2) /* 0=bipolar 1=unipolar */ #define DMM32AT_AI_CFG_GAIN(x) ((x) << 0) #define DMM32AT_AI_READBACK_REG 0x0b -#define DMM32AT_AI_READBACK_WAIT (1 << 7) /* DMM32AT_AI_STATUS_STS */ -#define DMM32AT_AI_READBACK_RANGE (1 << 3) -#define DMM32AT_AI_READBACK_ADBU (1 << 2) +#define DMM32AT_AI_READBACK_WAIT BIT(7) /* DMM32AT_AI_STATUS_STS */ +#define DMM32AT_AI_READBACK_RANGE BIT(3) +#define DMM32AT_AI_READBACK_ADBU BIT(2) #define DMM32AT_AI_READBACK_GAIN_MASK (3 << 0) #define DMM32AT_CLK1 0x0d -- cgit v1.1 From d855c3a41ff6d4b907cf24bea136a96d70e02893 Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Tue, 7 Jun 2016 14:06:16 +0530 Subject: Staging: comedi: fix blank line issue in das16.c This is a patch to the das16.c file that fixes up a blank line after function/struct/union/enum check found by the checkpatch.pl tool Signed-off-by: Ravishankar Karkala Mallikarjunayya Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 69133e3..8b037bd 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -198,6 +198,7 @@ enum { das16_pg_1601, das16_pg_1602, }; + static const int *const das16_gainlists[] = { NULL, das16jr_gainlist, -- cgit v1.1 From 55cc6164eecfa72777d34b789e066f618eb1fd93 Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Tue, 7 Jun 2016 14:06:17 +0530 Subject: Staging: comedi: Block comment issue fixed for das16.c This is a patch to the das16.c file that fixes up a WARNING: 'Block comments use a trailing */ on a separate line' found by the checkpatch.pl tool. Signed-off-by: Ravishankar Karkala Mallikarjunayya Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 8b037bd..5d15795 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -429,8 +429,10 @@ static const struct das16_board das16_boards[] = { }, }; -/* Period for timer interrupt in jiffies. It's a function - * to deal with possibility of dynamic HZ patches */ +/* + * Period for timer interrupt in jiffies. It's a function + * to deal with possibility of dynamic HZ patches + */ static inline int timer_period(void) { return HZ / 20; -- cgit v1.1 From deecca61b3d33221bd3d30241dd083d53de67aa1 Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Tue, 7 Jun 2016 14:06:18 +0530 Subject: Staging: comedi: fix comment issue fixed for das800.c This is a patch to the das800.c file that fixes up a WARNING: 'Block comments use a trailing */ on a separate line' found by the checkpatch.pl tool Signed-off-by: Ravishankar Karkala Mallikarjunayya Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das800.c | 102 ++++++++++++++++---------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 9059872..fd4cb49 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -1,56 +1,56 @@ /* - comedi/drivers/das800.c - Driver for Keitley das800 series boards and compatibles - Copyright (C) 2000 Frank Mori Hess - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 2000 David A. Schleef - - 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. -*/ + * comedi/drivers/das800.c + * Driver for Keitley das800 series boards and compatibles + * Copyright (C) 2000 Frank Mori Hess + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef + * + * 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. + */ /* -Driver: das800 -Description: Keithley Metrabyte DAS800 (& compatibles) -Author: Frank Mori Hess -Devices: [Keithley Metrabyte] DAS-800 (das-800), DAS-801 (das-801), - DAS-802 (das-802), - [Measurement Computing] CIO-DAS800 (cio-das800), - CIO-DAS801 (cio-das801), CIO-DAS802 (cio-das802), - CIO-DAS802/16 (cio-das802/16) -Status: works, cio-das802/16 untested - email me if you have tested it - -Configuration options: - [0] - I/O port base address - [1] - IRQ (optional, required for timed or externally triggered conversions) - -Notes: - IRQ can be omitted, although the cmd interface will not work without it. - - All entries in the channel/gain list must use the same gain and be - consecutive channels counting upwards in channel number (these are - hardware limitations.) - - I've never tested the gain setting stuff since I only have a - DAS-800 board with fixed gain. - - The cio-das802/16 does not have a fifo-empty status bit! Therefore - only fifo-half-full transfers are possible with this card. - -cmd triggers supported: - start_src: TRIG_NOW | TRIG_EXT - scan_begin_src: TRIG_FOLLOW - scan_end_src: TRIG_COUNT - convert_src: TRIG_TIMER | TRIG_EXT - stop_src: TRIG_NONE | TRIG_COUNT -*/ + * Driver: das800 + * Description: Keithley Metrabyte DAS800 (& compatibles) + * Author: Frank Mori Hess + * Devices: [Keithley Metrabyte] DAS-800 (das-800), DAS-801 (das-801), + * DAS-802 (das-802), + * [Measurement Computing] CIO-DAS800 (cio-das800), + * CIO-DAS801 (cio-das801), CIO-DAS802 (cio-das802), + * CIO-DAS802/16 (cio-das802/16) + * Status: works, cio-das802/16 untested - email me if you have tested it + * + * Configuration options: + * [0] - I/O port base address + * [1] - IRQ (optional, required for timed or externally triggered conversions) + * + * Notes: + * IRQ can be omitted, although the cmd interface will not work without it. + * + * All entries in the channel/gain list must use the same gain and be + * consecutive channels counting upwards in channel number (these are + * hardware limitations.) + * + * I've never tested the gain setting stuff since I only have a + * DAS-800 board with fixed gain. + * + * The cio-das802/16 does not have a fifo-empty status bit! Therefore + * only fifo-half-full transfers are possible with this card. + * + * cmd triggers supported: + * start_src: TRIG_NOW | TRIG_EXT + * scan_begin_src: TRIG_FOLLOW + * scan_end_src: TRIG_COUNT + * convert_src: TRIG_TIMER | TRIG_EXT + * stop_src: TRIG_NONE | TRIG_COUNT + */ #include #include -- cgit v1.1 From 2e3d417c02ceadd7feea0b34b37a36a1ffda96f1 Mon Sep 17 00:00:00 2001 From: Chris Cesare Date: Thu, 9 Jun 2016 15:39:02 -0400 Subject: staging: comedi: serial2002: Fix bare unsigned styling issue checkpatch.pl warns about a bare unsigned. Add type int to make explicit and suit the coding style. Signed-off-by Chris Cesare Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/serial2002.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index 7a1defc..b777946 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -95,7 +95,7 @@ struct serial_data { #define S2002_CFG_SIGN(x) (((x) >> 13) & 0x1) #define S2002_CFG_BASE(x) (((x) >> 14) & 0xfffff) -static long serial2002_tty_ioctl(struct file *f, unsigned op, +static long serial2002_tty_ioctl(struct file *f, unsigned int op, unsigned long param) { if (f->f_op->unlocked_ioctl) -- cgit v1.1 From c9b0f2b63f47ec35ca5e6588df488bb7e51efb43 Mon Sep 17 00:00:00 2001 From: Chris Cesare Date: Thu, 9 Jun 2016 15:39:03 -0400 Subject: staging: comedi: serial2002: Fix unnecessary cast styling issue checkpatch.pl warns that a cast of 1 to (long long) is unnecessary. Remove the cast and also add code to check and make sure that maxdata_list[chan] is not shifted too far, as suggested by Ian Abbott. Signed-off-by Chris Cesare Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/serial2002.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index b777946..0d33e52 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -379,7 +379,10 @@ static int serial2002_setup_subdevice(struct comedi_subdevice *s, range_table_list[chan] = (const struct comedi_lrange *)&range[j]; } - maxdata_list[chan] = ((long long)1 << cfg[j].bits) - 1; + if (cfg[j].bits < 32) + maxdata_list[chan] = (1u << cfg[j].bits) - 1; + else + maxdata_list[chan] = 0xffffffff; chan++; } } -- cgit v1.1 From 6adb21c2759ad8316f9e47244ac96d3d5d866ecf Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Fri, 17 Jun 2016 16:56:17 +0530 Subject: Staging: comedi: dt2814: Block comment issue fixed This fixes up a WARNING: 'Block comments use a trailing */ on a separate line' found by the checkpatch.pl tool. Signed-off-by: Ravishankar Karkala Mallikarjunayya Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2814.c | 72 +++++++++++++++++---------------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index 66705f9..2f903be 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c @@ -1,38 +1,38 @@ /* - comedi/drivers/dt2814.c - Hardware driver for Data Translation DT2814 - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1998 David A. Schleef - - 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. -*/ + * comedi/drivers/dt2814.c + * Hardware driver for Data Translation DT2814 + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1998 David A. Schleef + * + * 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. + */ /* -Driver: dt2814 -Description: Data Translation DT2814 -Author: ds -Status: complete -Devices: [Data Translation] DT2814 (dt2814) - -Configuration options: - [0] - I/O port base address - [1] - IRQ - -This card has 16 analog inputs multiplexed onto a 12 bit ADC. There -is a minimally useful onboard clock. The base frequency for the -clock is selected by jumpers, and the clock divider can be selected -via programmed I/O. Unfortunately, the clock divider can only be -a power of 10, from 1 to 10^7, of which only 3 or 4 are useful. In -addition, the clock does not seem to be very accurate. -*/ + * Driver: dt2814 + * Description: Data Translation DT2814 + * Author: ds + * Status: complete + * Devices: [Data Translation] DT2814 (dt2814) + * + * Configuration options: + * [0] - I/O port base address + * [1] - IRQ + * + * This card has 16 analog inputs multiplexed onto a 12 bit ADC. There + * is a minimally useful onboard clock. The base frequency for the + * clock is selected by jumpers, and the clock divider can be selected + * via programmed I/O. Unfortunately, the clock divider can only be + * a power of 10, from 1 to 10^7, of which only 3 or 4 are useful. In + * addition, the clock does not seem to be very accurate. + */ #include #include @@ -215,8 +215,10 @@ static irqreturn_t dt2814_interrupt(int irq, void *d) int i; outb(0, dev->iobase + DT2814_CSR); - /* note: turning off timed mode triggers another - sample. */ + /* + * note: turning off timed mode triggers another + * sample. + */ for (i = 0; i < DT2814_TIMEOUT; i++) { if (inb(dev->iobase + DT2814_CSR) & DT2814_FINISH) -- cgit v1.1 From 62c701d794d2fdad48140f9c82ca228917131342 Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Fri, 17 Jun 2016 16:56:18 +0530 Subject: Staging: comedi: dt2815: Comment issue fixed This fixes up a WARNING: 'Block comments use a trailing */ on a separate line' found by the checkpatch.pl tool. Signed-off-by: Ravishankar Karkala Mallikarjunayya Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2815.c | 140 ++++++++++++++++---------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c index fb08569..0be77cc 100644 --- a/drivers/staging/comedi/drivers/dt2815.c +++ b/drivers/staging/comedi/drivers/dt2815.c @@ -1,55 +1,55 @@ /* - comedi/drivers/dt2815.c - Hardware driver for Data Translation DT2815 - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1999 Anders Blomdell - - 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. + * comedi/drivers/dt2815.c + * Hardware driver for Data Translation DT2815 + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1999 Anders Blomdell + * + * 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. */ /* -Driver: dt2815 -Description: Data Translation DT2815 -Author: ds -Status: mostly complete, untested -Devices: [Data Translation] DT2815 (dt2815) - -I'm not sure anyone has ever tested this board. If you have information -contrary, please update. - -Configuration options: - [0] - I/O port base base address - [1] - IRQ (unused) - [2] - Voltage unipolar/bipolar configuration - 0 == unipolar 5V (0V -- +5V) - 1 == bipolar 5V (-5V -- +5V) - [3] - Current offset configuration - 0 == disabled (0mA -- +32mAV) - 1 == enabled (+4mA -- +20mAV) - [4] - Firmware program configuration - 0 == program 1 (see manual table 5-4) - 1 == program 2 (see manual table 5-4) - 2 == program 3 (see manual table 5-4) - 3 == program 4 (see manual table 5-4) - [5] - Analog output 0 range configuration - 0 == voltage - 1 == current - [6] - Analog output 1 range configuration (same options) - [7] - Analog output 2 range configuration (same options) - [8] - Analog output 3 range configuration (same options) - [9] - Analog output 4 range configuration (same options) - [10] - Analog output 5 range configuration (same options) - [11] - Analog output 6 range configuration (same options) - [12] - Analog output 7 range configuration (same options) -*/ + * Driver: dt2815 + * Description: Data Translation DT2815 + * Author: ds + * Status: mostly complete, untested + * Devices: [Data Translation] DT2815 (dt2815) + * + * I'm not sure anyone has ever tested this board. If you have information + * contrary, please update. + * + * Configuration options: + * [0] - I/O port base base address + * [1] - IRQ (unused) + * [2] - Voltage unipolar/bipolar configuration + * 0 == unipolar 5V (0V -- +5V) + * 1 == bipolar 5V (-5V -- +5V) + * [3] - Current offset configuration + * 0 == disabled (0mA -- +32mAV) + * 1 == enabled (+4mA -- +20mAV) + * [4] - Firmware program configuration + * 0 == program 1 (see manual table 5-4) + * 1 == program 2 (see manual table 5-4) + * 2 == program 3 (see manual table 5-4) + * 3 == program 4 (see manual table 5-4) + * [5] - Analog output 0 range configuration + * 0 == voltage + * 1 == current + * [6] - Analog output 1 range configuration (same options) + * [7] - Analog output 2 range configuration (same options) + * [8] - Analog output 3 range configuration (same options) + * [9] - Analog output 4 range configuration (same options) + * [10] - Analog output 5 range configuration (same options) + * [11] - Analog output 6 range configuration (same options) + * [12] - Analog output 7 range configuration (same options) + */ #include #include "../comedidev.h" @@ -120,27 +120,27 @@ static int dt2815_ao_insn(struct comedi_device *dev, struct comedi_subdevice *s, } /* - options[0] Board base address - options[1] IRQ (not applicable) - options[2] Voltage unipolar/bipolar configuration - 0 == unipolar 5V (0V -- +5V) - 1 == bipolar 5V (-5V -- +5V) - options[3] Current offset configuration - 0 == disabled (0mA -- +32mAV) - 1 == enabled (+4mA -- +20mAV) - options[4] Firmware program configuration - 0 == program 1 (see manual table 5-4) - 1 == program 2 (see manual table 5-4) - 2 == program 3 (see manual table 5-4) - 3 == program 4 (see manual table 5-4) - options[5] Analog output 0 range configuration - 0 == voltage - 1 == current - options[6] Analog output 1 range configuration - ... - options[12] Analog output 7 range configuration - 0 == voltage - 1 == current + * options[0] Board base address + * options[1] IRQ (not applicable) + * options[2] Voltage unipolar/bipolar configuration + * 0 == unipolar 5V (0V -- +5V) + * 1 == bipolar 5V (-5V -- +5V) + * options[3] Current offset configuration + * 0 == disabled (0mA -- +32mAV) + * 1 == enabled (+4mA -- +20mAV) + * options[4] Firmware program configuration + * 0 == program 1 (see manual table 5-4) + * 1 == program 2 (see manual table 5-4) + * 2 == program 3 (see manual table 5-4) + * 3 == program 4 (see manual table 5-4) + * options[5] Analog output 0 range configuration + * 0 == voltage + * 1 == current + * options[6] Analog output 1 range configuration + * ... + * options[12] Analog output 7 range configuration + * 0 == voltage + * 1 == current */ static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it) -- cgit v1.1 From 533364c7c6af7c995d8e2868b93883e6015812b4 Mon Sep 17 00:00:00 2001 From: Ravishankar Karkala Mallikarjunayya Date: Fri, 17 Jun 2016 16:56:20 +0530 Subject: Staging: comedi: dt2817: Coding style issue fixed. This fixes up a WARNING: 'Block comments use a trailing */ on a separate line' found by the checkpatch.pl tool. Signed-off-by: Ravishankar Karkala Mallikarjunayya Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2817.c | 64 ++++++++++++++++----------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c index 5131dee..39d2566 100644 --- a/drivers/staging/comedi/drivers/dt2817.c +++ b/drivers/staging/comedi/drivers/dt2817.c @@ -1,37 +1,37 @@ /* - comedi/drivers/dt2817.c - Hardware driver for Data Translation DT2817 - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1998 David A. Schleef - - 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. -*/ + * comedi/drivers/dt2817.c + * Hardware driver for Data Translation DT2817 + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 1998 David A. Schleef + * + * 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. + */ /* -Driver: dt2817 -Description: Data Translation DT2817 -Author: ds -Status: complete -Devices: [Data Translation] DT2817 (dt2817) - -A very simple digital I/O card. Four banks of 8 lines, each bank -is configurable for input or output. One wonders why it takes a -50 page manual to describe this thing. - -The driver (which, btw, is much less than 50 pages) has 1 subdevice -with 32 channels, configurable in groups of 8. - -Configuration options: - [0] - I/O port base base address -*/ + * Driver: dt2817 + * Description: Data Translation DT2817 + * Author: ds + * Status: complete + * Devices: [Data Translation] DT2817 (dt2817) + * + * A very simple digital I/O card. Four banks of 8 lines, each bank + * is configurable for input or output. One wonders why it takes a + * 50 page manual to describe this thing. + * + * The driver (which, btw, is much less than 50 pages) has 1 subdevice + * with 32 channels, configurable in groups of 8. + * + * Configuration options: + * [0] - I/O port base base address + */ #include #include "../comedidev.h" -- cgit v1.1 From 70db384cd6dd780a32197c194ad41735630d265e Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 17 Jun 2016 21:56:15 +0200 Subject: staging: comedi: avoid using timeval Comedi uses 32-bit seconds for its timestamps, on both 32-bit and 64-bit machines. For all I can tell, this was originally meant as a 'timespec', which would overflow in 2038 because of the use of a signed 'long' on 32-bit machines, but it is now used as an array of two unsigned 'lsampl_t' values in comedilib, which will only overflow in 2106, on both 32-bit and 64-bit machines. In an effort to get rid of all uses of 'struct timeval' in the kernel, this replaces the internal code with a call to ktime_get_real_ts64() and a comment at the location of the conversion. Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 4d87596..1999eed 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1256,16 +1256,17 @@ static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, switch (insn->insn) { case INSN_GTOD: { - struct timeval tv; + struct timespec64 tv; if (insn->n != 2) { ret = -EINVAL; break; } - do_gettimeofday(&tv); - data[0] = tv.tv_sec; - data[1] = tv.tv_usec; + ktime_get_real_ts64(&tv); + /* unsigned data safe until 2106 */ + data[0] = (unsigned int)tv.tv_sec; + data[1] = tv.tv_nsec / NSEC_PER_USEC; ret = 2; break; -- cgit v1.1 From 63bb0bc1b19d125c052e3b199421a0ca4d67e021 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:58:56 -0300 Subject: staging/android: store last signaled value on sync timeline Now fence timeline is aware of the last signaled fence, as it receives the increment to the current value in sync_timeline_signal(). That allow us to remove .has_signaled() from timeline_ops as we can directly compare using timeline->value and fence->seqno in sync.c Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sw_sync.c | 16 ++-------------- drivers/staging/android/sync.c | 15 +++++++-------- drivers/staging/android/sync.h | 14 +++++--------- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index af39ff5..428e22c 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -30,7 +30,7 @@ struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) struct sw_sync_pt *pt; pt = (struct sw_sync_pt *) - sync_pt_create(&obj->obj, sizeof(struct sw_sync_pt)); + sync_pt_create(&obj->obj, sizeof(struct sw_sync_pt), value); pt->value = value; @@ -38,15 +38,6 @@ struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) } EXPORT_SYMBOL(sw_sync_pt_create); -static int sw_sync_fence_has_signaled(struct fence *fence) -{ - struct sw_sync_pt *pt = (struct sw_sync_pt *)fence; - struct sw_sync_timeline *obj = - (struct sw_sync_timeline *)fence_parent(fence); - - return (pt->value > obj->value) ? 0 : 1; -} - static void sw_sync_timeline_value_str(struct sync_timeline *sync_timeline, char *str, int size) { @@ -64,7 +55,6 @@ static void sw_sync_fence_value_str(struct fence *fence, char *str, int size) static struct sync_timeline_ops sw_sync_timeline_ops = { .driver_name = "sw_sync", - .has_signaled = sw_sync_fence_has_signaled, .timeline_value_str = sw_sync_timeline_value_str, .fence_value_str = sw_sync_fence_value_str, }; @@ -82,8 +72,6 @@ EXPORT_SYMBOL(sw_sync_timeline_create); void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc) { - obj->value += inc; - - sync_timeline_signal(&obj->obj); + sync_timeline_signal(&obj->obj, inc); } EXPORT_SYMBOL(sw_sync_timeline_inc); diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 1d14c83..8dd2181 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -90,7 +90,7 @@ void sync_timeline_destroy(struct sync_timeline *obj) } EXPORT_SYMBOL(sync_timeline_destroy); -void sync_timeline_signal(struct sync_timeline *obj) +void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc) { unsigned long flags; struct fence *fence, *next; @@ -99,6 +99,8 @@ void sync_timeline_signal(struct sync_timeline *obj) spin_lock_irqsave(&obj->child_list_lock, flags); + obj->value += inc; + list_for_each_entry_safe(fence, next, &obj->active_list_head, active_list) { if (fence_is_signaled_locked(fence)) @@ -109,7 +111,8 @@ void sync_timeline_signal(struct sync_timeline *obj) } EXPORT_SYMBOL(sync_timeline_signal); -struct fence *sync_pt_create(struct sync_timeline *obj, int size) +struct fence *sync_pt_create(struct sync_timeline *obj, int size, + unsigned int value) { unsigned long flags; struct fence *fence; @@ -124,7 +127,7 @@ struct fence *sync_pt_create(struct sync_timeline *obj, int size) spin_lock_irqsave(&obj->child_list_lock, flags); sync_timeline_get(obj); fence_init(fence, &android_fence_ops, &obj->child_list_lock, - obj->context, ++obj->value); + obj->context, value); list_add_tail(&fence->child_list, &obj->child_list_head); INIT_LIST_HEAD(&fence->active_list); spin_unlock_irqrestore(&obj->child_list_lock, flags); @@ -164,12 +167,8 @@ static void android_fence_release(struct fence *fence) static bool android_fence_signaled(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); - int ret; - ret = parent->ops->has_signaled(fence); - if (ret < 0) - fence->status = ret; - return ret; + return (fence->seqno > parent->value) ? false : true; } static bool android_fence_enable_signaling(struct fence *fence) diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index b56885c..627525c 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -28,19 +28,12 @@ struct sync_timeline; /** * struct sync_timeline_ops - sync object implementation ops * @driver_name: name of the implementation - * @has_signaled: returns: - * 1 if pt has signaled - * 0 if pt has not signaled - * <0 on error * @timeline_value_str: fill str with the value of the sync_timeline's counter * @fence_value_str: fill str with the value of the fence */ struct sync_timeline_ops { const char *driver_name; - /* required */ - int (*has_signaled)(struct fence *fence); - /* optional */ void (*timeline_value_str)(struct sync_timeline *timeline, char *str, int size); @@ -117,23 +110,26 @@ void sync_timeline_destroy(struct sync_timeline *obj); /** * sync_timeline_signal() - signal a status change on a sync_timeline * @obj: sync_timeline to signal + * @inc: num to increment on timeline->value * * A sync implementation should call this any time one of it's fences * has signaled or has an error condition. */ -void sync_timeline_signal(struct sync_timeline *obj); +void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc); /** * sync_pt_create() - creates a sync pt * @parent: fence's parent sync_timeline * @size: size to allocate for this pt + * @inc: value of the fence * * Creates a new fence as a child of @parent. @size bytes will be * allocated allowing for implementation specific data to be kept after * the generic sync_timeline struct. Returns the fence object or * NULL in case of error. */ -struct fence *sync_pt_create(struct sync_timeline *parent, int size); +struct fence *sync_pt_create(struct sync_timeline *parent, int size, + unsigned int inc); #ifdef CONFIG_DEBUG_FS -- cgit v1.1 From 5c1401f83a16b7ee3762c9044ab56ed3f3cdcdcd Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:58:57 -0300 Subject: staging/android: remove .{fence, timeline}_value_str() from timeline_ops Now that the value of fence and the timeline are not stored by sw_sync anymore we can remove this extra abstraction to retrieve this data. This patch changes both fence_ops (.fence_value_str and .timeline_value_str) to return the str directly. It also clean up struct sync_timeline_ops by removing both ops from there. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sw_sync.c | 17 ----------------- drivers/staging/android/sync.c | 16 ++-------------- drivers/staging/android/sync.h | 9 --------- drivers/staging/android/sync_debug.c | 12 ++---------- drivers/staging/android/trace/sync.h | 12 +++--------- 5 files changed, 7 insertions(+), 59 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 428e22c..4200b12 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -38,25 +38,8 @@ struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) } EXPORT_SYMBOL(sw_sync_pt_create); -static void sw_sync_timeline_value_str(struct sync_timeline *sync_timeline, - char *str, int size) -{ - struct sw_sync_timeline *timeline = - (struct sw_sync_timeline *)sync_timeline; - snprintf(str, size, "%d", timeline->value); -} - -static void sw_sync_fence_value_str(struct fence *fence, char *str, int size) -{ - struct sw_sync_pt *pt = (struct sw_sync_pt *)fence; - - snprintf(str, size, "%d", pt->value); -} - static struct sync_timeline_ops sw_sync_timeline_ops = { .driver_name = "sw_sync", - .timeline_value_str = sw_sync_timeline_value_str, - .fence_value_str = sw_sync_fence_value_str, }; struct sw_sync_timeline *sw_sync_timeline_create(const char *name) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 8dd2181..c75d1e6 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -185,14 +185,7 @@ static bool android_fence_enable_signaling(struct fence *fence) static void android_fence_value_str(struct fence *fence, char *str, int size) { - struct sync_timeline *parent = fence_parent(fence); - - if (!parent->ops->fence_value_str) { - if (size) - *str = 0; - return; - } - parent->ops->fence_value_str(fence, str, size); + snprintf(str, size, "%d", fence->seqno); } static void android_fence_timeline_value_str(struct fence *fence, @@ -200,12 +193,7 @@ static void android_fence_timeline_value_str(struct fence *fence, { struct sync_timeline *parent = fence_parent(fence); - if (!parent->ops->timeline_value_str) { - if (size) - *str = 0; - return; - } - parent->ops->timeline_value_str(parent, str, size); + snprintf(str, size, "%d", parent->value); } static const struct fence_ops android_fence_ops = { diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 627525c..29f8c19 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -28,18 +28,9 @@ struct sync_timeline; /** * struct sync_timeline_ops - sync object implementation ops * @driver_name: name of the implementation - * @timeline_value_str: fill str with the value of the sync_timeline's counter - * @fence_value_str: fill str with the value of the fence */ struct sync_timeline_ops { const char *driver_name; - - /* optional */ - void (*timeline_value_str)(struct sync_timeline *timeline, char *str, - int size); - - /* optional */ - void (*fence_value_str)(struct fence *fence, char *str, int size); }; /** diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 5f57499..c532457 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -133,16 +133,8 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj) struct list_head *pos; unsigned long flags; - seq_printf(s, "%s %s", obj->name, obj->ops->driver_name); - - if (obj->ops->timeline_value_str) { - char value[64]; - - obj->ops->timeline_value_str(obj, value, sizeof(value)); - seq_printf(s, ": %s", value); - } - - seq_puts(s, "\n"); + seq_printf(s, "%s %s: %d\n", obj->name, obj->ops->driver_name, + obj->value); spin_lock_irqsave(&obj->child_list_lock, flags); list_for_each(pos, &obj->child_list_head) { diff --git a/drivers/staging/android/trace/sync.h b/drivers/staging/android/trace/sync.h index a0f80f4..d7f6457f 100644 --- a/drivers/staging/android/trace/sync.h +++ b/drivers/staging/android/trace/sync.h @@ -15,21 +15,15 @@ TRACE_EVENT(sync_timeline, TP_STRUCT__entry( __string(name, timeline->name) - __array(char, value, 32) + __field(u32, value) ), TP_fast_assign( __assign_str(name, timeline->name); - if (timeline->ops->timeline_value_str) { - timeline->ops->timeline_value_str(timeline, - __entry->value, - sizeof(__entry->value)); - } else { - __entry->value[0] = '\0'; - } + __entry->value = timeline->value; ), - TP_printk("name=%s value=%s", __get_str(name), __entry->value) + TP_printk("name=%s value=%d", __get_str(name), __entry->value) ); #endif /* if !defined(_TRACE_SYNC_H) || defined(TRACE_HEADER_MULTI_READ) */ -- cgit v1.1 From ef30afefeaf624c483e56c63e60e0dda8c42a0ef Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:58:58 -0300 Subject: staging/android: remove struct sync_timeline_ops Move drv_name, the last field of sync_timeline_ops, to sync_timeline and remove sync_timeline_ops. struct sync_timeline_ops was just an extra abstraction on top of fence_ops, and in the last few commits we removed all it ops in favor of cleaner fence_ops. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sw_sync.c | 9 ++------- drivers/staging/android/sync.c | 8 ++++---- drivers/staging/android/sync.h | 28 +++++++++------------------- drivers/staging/android/sync_debug.c | 3 +-- 4 files changed, 16 insertions(+), 32 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 4200b12..c5e92c6 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -38,16 +38,11 @@ struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) } EXPORT_SYMBOL(sw_sync_pt_create); -static struct sync_timeline_ops sw_sync_timeline_ops = { - .driver_name = "sw_sync", -}; - struct sw_sync_timeline *sw_sync_timeline_create(const char *name) { struct sw_sync_timeline *obj = (struct sw_sync_timeline *) - sync_timeline_create(&sw_sync_timeline_ops, - sizeof(struct sw_sync_timeline), - name); + sync_timeline_create(sizeof(struct sw_sync_timeline), + "sw_sync", name); return obj; } diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index c75d1e6..b3efcaa 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -30,8 +30,8 @@ static const struct fence_ops android_fence_ops; -struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops, - int size, const char *name) +struct sync_timeline *sync_timeline_create(int size, const char *drv_name, + const char *name) { struct sync_timeline *obj; @@ -43,9 +43,9 @@ struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops, return NULL; kref_init(&obj->kref); - obj->ops = ops; obj->context = fence_context_alloc(1); strlcpy(obj->name, name, sizeof(obj->name)); + strlcpy(obj->drv_name, drv_name, sizeof(obj->drv_name)); INIT_LIST_HEAD(&obj->child_list_head); INIT_LIST_HEAD(&obj->active_list_head); @@ -139,7 +139,7 @@ static const char *android_fence_get_driver_name(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); - return parent->ops->driver_name; + return parent->drv_name; } static const char *android_fence_get_timeline_name(struct fence *fence) diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 29f8c19..f003e97 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -23,20 +23,10 @@ #include #include -struct sync_timeline; - -/** - * struct sync_timeline_ops - sync object implementation ops - * @driver_name: name of the implementation - */ -struct sync_timeline_ops { - const char *driver_name; -}; - /** * struct sync_timeline - sync object * @kref: reference count on fence. - * @ops: ops that define the implementation of the sync_timeline + * @drv_name: drv_name of the driver using the sync_timeline * @name: name of the sync_timeline. Useful for debugging * @destroyed: set when sync_timeline is destroyed * @child_list_head: list of children sync_pts for this sync_timeline @@ -47,7 +37,7 @@ struct sync_timeline_ops { */ struct sync_timeline { struct kref kref; - const struct sync_timeline_ops *ops; + char drv_name[32]; char name[32]; /* protected by child_list_lock */ @@ -76,17 +66,17 @@ static inline struct sync_timeline *fence_parent(struct fence *fence) /** * sync_timeline_create() - creates a sync object - * @ops: specifies the implementation ops for the object * @size: size to allocate for this obj + * @drv_name: sync_timeline driver name * @name: sync_timeline name * - * Creates a new sync_timeline which will use the implementation specified by - * @ops. @size bytes will be allocated allowing for implementation specific - * data to be kept after the generic sync_timeline struct. Returns the - * sync_timeline object or NULL in case of error. + * Creates a new sync_timeline. @size bytes will be allocated allowing + * for implementation specific data to be kept after the generic + * sync_timeline struct. Returns the sync_timeline object or NULL in + * case of error. */ -struct sync_timeline *sync_timeline_create(const struct sync_timeline_ops *ops, - int size, const char *name); +struct sync_timeline *sync_timeline_create(int size, const char *drv_name, + const char *name); /** * sync_timeline_destroy() - destroys a sync object diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index c532457..e5634f2 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -133,8 +133,7 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj) struct list_head *pos; unsigned long flags; - seq_printf(s, "%s %s: %d\n", obj->name, obj->ops->driver_name, - obj->value); + seq_printf(s, "%s %s: %d\n", obj->name, obj->drv_name, obj->value); spin_lock_irqsave(&obj->child_list_lock, flags); list_for_each(pos, &obj->child_list_head) { -- cgit v1.1 From dcc280803e8a803643b6d12b2f35df608623c7fd Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:58:59 -0300 Subject: staging/android: remove sw_sync_timeline and sw_sync_pt As we moved value storage to sync_timeline and fence those two structs became useless and can be removed now. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sw_sync.c | 24 +++++++----------------- drivers/staging/android/sw_sync.h | 24 ++++++------------------ drivers/staging/android/sync_debug.c | 12 ++++++------ 3 files changed, 19 insertions(+), 41 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index c5e92c6..461dbd9 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -25,31 +25,21 @@ #include "sw_sync.h" -struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value) +struct fence *sw_sync_pt_create(struct sync_timeline *obj, u32 value) { - struct sw_sync_pt *pt; - - pt = (struct sw_sync_pt *) - sync_pt_create(&obj->obj, sizeof(struct sw_sync_pt), value); - - pt->value = value; - - return (struct fence *)pt; + return sync_pt_create(obj, sizeof(struct fence), value); } EXPORT_SYMBOL(sw_sync_pt_create); -struct sw_sync_timeline *sw_sync_timeline_create(const char *name) +struct sync_timeline *sw_sync_timeline_create(const char *name) { - struct sw_sync_timeline *obj = (struct sw_sync_timeline *) - sync_timeline_create(sizeof(struct sw_sync_timeline), - "sw_sync", name); - - return obj; + return sync_timeline_create(sizeof(struct sync_timeline), + "sw_sync", name); } EXPORT_SYMBOL(sw_sync_timeline_create); -void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc) +void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc) { - sync_timeline_signal(&obj->obj, inc); + sync_timeline_signal(obj, inc); } EXPORT_SYMBOL(sw_sync_timeline_inc); diff --git a/drivers/staging/android/sw_sync.h b/drivers/staging/android/sw_sync.h index e18667b..9f26c62 100644 --- a/drivers/staging/android/sw_sync.h +++ b/drivers/staging/android/sw_sync.h @@ -22,34 +22,22 @@ #include "sync.h" #include "uapi/sw_sync.h" -struct sw_sync_timeline { - struct sync_timeline obj; - - u32 value; -}; - -struct sw_sync_pt { - struct fence pt; - - u32 value; -}; - #if IS_ENABLED(CONFIG_SW_SYNC) -struct sw_sync_timeline *sw_sync_timeline_create(const char *name); -void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc); +struct sync_timeline *sw_sync_timeline_create(const char *name); +void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc); -struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, u32 value); +struct fence *sw_sync_pt_create(struct sync_timeline *obj, u32 value); #else -static inline struct sw_sync_timeline *sw_sync_timeline_create(const char *name) +static inline struct sync_timeline *sw_sync_timeline_create(const char *name) { return NULL; } -static inline void sw_sync_timeline_inc(struct sw_sync_timeline *obj, u32 inc) +static inline void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc) { } -static inline struct fence *sw_sync_pt_create(struct sw_sync_timeline *obj, +static inline struct fence *sw_sync_pt_create(struct sync_timeline *obj, u32 value) { return NULL; diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index e5634f2..e207a4d 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -209,7 +209,7 @@ static const struct file_operations sync_info_debugfs_fops = { /* opening sw_sync create a new sync obj */ static int sw_sync_debugfs_open(struct inode *inode, struct file *file) { - struct sw_sync_timeline *obj; + struct sync_timeline *obj; char task_comm[TASK_COMM_LEN]; get_task_comm(task_comm, current); @@ -225,13 +225,13 @@ static int sw_sync_debugfs_open(struct inode *inode, struct file *file) static int sw_sync_debugfs_release(struct inode *inode, struct file *file) { - struct sw_sync_timeline *obj = file->private_data; + struct sync_timeline *obj = file->private_data; - sync_timeline_destroy(&obj->obj); + sync_timeline_destroy(obj); return 0; } -static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, +static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, unsigned long arg) { int fd = get_unused_fd_flags(O_CLOEXEC); @@ -277,7 +277,7 @@ err: return err; } -static long sw_sync_ioctl_inc(struct sw_sync_timeline *obj, unsigned long arg) +static long sw_sync_ioctl_inc(struct sync_timeline *obj, unsigned long arg) { u32 value; @@ -292,7 +292,7 @@ static long sw_sync_ioctl_inc(struct sw_sync_timeline *obj, unsigned long arg) static long sw_sync_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - struct sw_sync_timeline *obj = file->private_data; + struct sync_timeline *obj = file->private_data; switch (cmd) { case SW_SYNC_IOC_CREATE_FENCE: -- cgit v1.1 From d21858fdb3269e98aa62d522efec7ce2865368e6 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:00 -0300 Subject: staging/android: remove sw_sync.[ch] files We can glue the sw_sync file operations directly on the sync framework without the need to pass through sw_sync wrappers. It only builds sw_sync debugfs file support if CONFIG_SW_SYNC is enabled. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/Makefile | 1 - drivers/staging/android/sw_sync.c | 45 ---------------------------------- drivers/staging/android/sw_sync.h | 47 ------------------------------------ drivers/staging/android/sync_debug.c | 17 ++++++++++--- 4 files changed, 13 insertions(+), 97 deletions(-) delete mode 100644 drivers/staging/android/sw_sync.c delete mode 100644 drivers/staging/android/sw_sync.h diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile index 980d6dc..bf45967 100644 --- a/drivers/staging/android/Makefile +++ b/drivers/staging/android/Makefile @@ -5,4 +5,3 @@ obj-y += ion/ obj-$(CONFIG_ASHMEM) += ashmem.o obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o obj-$(CONFIG_SYNC) += sync.o sync_debug.o -obj-$(CONFIG_SW_SYNC) += sw_sync.o diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c deleted file mode 100644 index 461dbd9..0000000 --- a/drivers/staging/android/sw_sync.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * drivers/base/sw_sync.c - * - * Copyright (C) 2012 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sw_sync.h" - -struct fence *sw_sync_pt_create(struct sync_timeline *obj, u32 value) -{ - return sync_pt_create(obj, sizeof(struct fence), value); -} -EXPORT_SYMBOL(sw_sync_pt_create); - -struct sync_timeline *sw_sync_timeline_create(const char *name) -{ - return sync_timeline_create(sizeof(struct sync_timeline), - "sw_sync", name); -} -EXPORT_SYMBOL(sw_sync_timeline_create); - -void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc) -{ - sync_timeline_signal(obj, inc); -} -EXPORT_SYMBOL(sw_sync_timeline_inc); diff --git a/drivers/staging/android/sw_sync.h b/drivers/staging/android/sw_sync.h deleted file mode 100644 index 9f26c62..0000000 --- a/drivers/staging/android/sw_sync.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * include/linux/sw_sync.h - * - * Copyright (C) 2012 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -#ifndef _LINUX_SW_SYNC_H -#define _LINUX_SW_SYNC_H - -#include -#include -#include "sync.h" -#include "uapi/sw_sync.h" - -#if IS_ENABLED(CONFIG_SW_SYNC) -struct sync_timeline *sw_sync_timeline_create(const char *name); -void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc); - -struct fence *sw_sync_pt_create(struct sync_timeline *obj, u32 value); -#else -static inline struct sync_timeline *sw_sync_timeline_create(const char *name) -{ - return NULL; -} - -static inline void sw_sync_timeline_inc(struct sync_timeline *obj, u32 inc) -{ -} - -static inline struct fence *sw_sync_pt_create(struct sync_timeline *obj, - u32 value) -{ - return NULL; -} -#endif /* IS_ENABLED(CONFIG_SW_SYNC) */ - -#endif /* _LINUX_SW_SYNC_H */ diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index e207a4d..dc85d5f 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -27,7 +27,11 @@ #include #include #include -#include "sw_sync.h" +#include +#include + +#include "uapi/sw_sync.h" +#include "sync.h" #ifdef CONFIG_DEBUG_FS @@ -200,6 +204,7 @@ static const struct file_operations sync_info_debugfs_fops = { .release = single_release, }; +#if IS_ENABLED(CONFIG_SW_SYNC) /* * *WARNING* * @@ -214,7 +219,7 @@ static int sw_sync_debugfs_open(struct inode *inode, struct file *file) get_task_comm(task_comm, current); - obj = sw_sync_timeline_create(task_comm); + obj = sync_timeline_create(sizeof(*obj), "sw_sync", task_comm); if (!obj) return -ENOMEM; @@ -248,7 +253,7 @@ static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, goto err; } - fence = sw_sync_pt_create(obj, data.value); + fence = sync_pt_create(obj, sizeof(*fence), data.value); if (!fence) { err = -ENOMEM; goto err; @@ -284,7 +289,7 @@ static long sw_sync_ioctl_inc(struct sync_timeline *obj, unsigned long arg) if (copy_from_user(&value, (void __user *)arg, sizeof(value))) return -EFAULT; - sw_sync_timeline_inc(obj, value); + sync_timeline_signal(obj, value); return 0; } @@ -312,14 +317,18 @@ static const struct file_operations sw_sync_debugfs_fops = { .unlocked_ioctl = sw_sync_ioctl, .compat_ioctl = sw_sync_ioctl, }; +#endif static __init int sync_debugfs_init(void) { dbgfs = debugfs_create_dir("sync", NULL); debugfs_create_file("info", 0444, dbgfs, NULL, &sync_info_debugfs_fops); + +#if IS_ENABLED(CONFIG_SW_SYNC) debugfs_create_file("sw_sync", 0644, dbgfs, NULL, &sw_sync_debugfs_fops); +#endif return 0; } -- cgit v1.1 From 4be6e00cd34210d5b3d37ddb7bf46137cf5a99b1 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:01 -0300 Subject: staging/android: rename android_fence to timeline_fence We are moving out of staging/android so rename it to a name that is not related to android anymore. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sync.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index b3efcaa..442d808 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -28,7 +28,7 @@ #define CREATE_TRACE_POINTS #include "trace/sync.h" -static const struct fence_ops android_fence_ops; +static const struct fence_ops timeline_fence_ops; struct sync_timeline *sync_timeline_create(int size, const char *drv_name, const char *name) @@ -126,7 +126,7 @@ struct fence *sync_pt_create(struct sync_timeline *obj, int size, spin_lock_irqsave(&obj->child_list_lock, flags); sync_timeline_get(obj); - fence_init(fence, &android_fence_ops, &obj->child_list_lock, + fence_init(fence, &timeline_fence_ops, &obj->child_list_lock, obj->context, value); list_add_tail(&fence->child_list, &obj->child_list_head); INIT_LIST_HEAD(&fence->active_list); @@ -135,21 +135,21 @@ struct fence *sync_pt_create(struct sync_timeline *obj, int size, } EXPORT_SYMBOL(sync_pt_create); -static const char *android_fence_get_driver_name(struct fence *fence) +static const char *timeline_fence_get_driver_name(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); return parent->drv_name; } -static const char *android_fence_get_timeline_name(struct fence *fence) +static const char *timeline_fence_get_timeline_name(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); return parent->name; } -static void android_fence_release(struct fence *fence) +static void timeline_fence_release(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); unsigned long flags; @@ -164,31 +164,31 @@ static void android_fence_release(struct fence *fence) fence_free(fence); } -static bool android_fence_signaled(struct fence *fence) +static bool timeline_fence_signaled(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); return (fence->seqno > parent->value) ? false : true; } -static bool android_fence_enable_signaling(struct fence *fence) +static bool timeline_fence_enable_signaling(struct fence *fence) { struct sync_timeline *parent = fence_parent(fence); - if (android_fence_signaled(fence)) + if (timeline_fence_signaled(fence)) return false; list_add_tail(&fence->active_list, &parent->active_list_head); return true; } -static void android_fence_value_str(struct fence *fence, +static void timeline_fence_value_str(struct fence *fence, char *str, int size) { snprintf(str, size, "%d", fence->seqno); } -static void android_fence_timeline_value_str(struct fence *fence, +static void timeline_fence_timeline_value_str(struct fence *fence, char *str, int size) { struct sync_timeline *parent = fence_parent(fence); @@ -196,13 +196,13 @@ static void android_fence_timeline_value_str(struct fence *fence, snprintf(str, size, "%d", parent->value); } -static const struct fence_ops android_fence_ops = { - .get_driver_name = android_fence_get_driver_name, - .get_timeline_name = android_fence_get_timeline_name, - .enable_signaling = android_fence_enable_signaling, - .signaled = android_fence_signaled, +static const struct fence_ops timeline_fence_ops = { + .get_driver_name = timeline_fence_get_driver_name, + .get_timeline_name = timeline_fence_get_timeline_name, + .enable_signaling = timeline_fence_enable_signaling, + .signaled = timeline_fence_signaled, .wait = fence_default_wait, - .release = android_fence_release, - .fence_value_str = android_fence_value_str, - .timeline_value_str = android_fence_timeline_value_str, + .release = timeline_fence_release, + .fence_value_str = timeline_fence_value_str, + .timeline_value_str = timeline_fence_timeline_value_str, }; -- cgit v1.1 From 724812d6a66e3a1524f7eb78b900bc0624b6d7dc Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:02 -0300 Subject: staging/android: remove unnecessary check for fence When we call sync_print_fence() fence is always valid. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sync_debug.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index dc85d5f..6282046 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -109,7 +109,7 @@ static void sync_print_fence(struct seq_file *s, struct fence *fence, bool show) seq_printf(s, "@%lld.%09ld", (s64)ts64.tv_sec, ts64.tv_nsec); } - if ((!fence || fence->ops->timeline_value_str) && + if (fence->ops->timeline_value_str && fence->ops->fence_value_str) { char value[64]; bool success; @@ -117,10 +117,9 @@ static void sync_print_fence(struct seq_file *s, struct fence *fence, bool show) fence->ops->fence_value_str(fence, value, sizeof(value)); success = strlen(value); - if (success) + if (success) { seq_printf(s, ": %s", value); - if (success && fence) { fence->ops->timeline_value_str(fence, value, sizeof(value)); -- cgit v1.1 From 62627c8f61e09a6204cd77de30df9a83ff158812 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:03 -0300 Subject: staging/android: remove size arg of sync_timeline_create() After we removed sw_sync_timeline this arg has not been really used by anyone, all its users pass the size of struct sync_timeline there. So simplify this function but not requiring the size anymore. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sync.c | 7 ++----- drivers/staging/android/sync.h | 7 ++----- drivers/staging/android/sync_debug.c | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 442d808..c83a599 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -30,15 +30,12 @@ static const struct fence_ops timeline_fence_ops; -struct sync_timeline *sync_timeline_create(int size, const char *drv_name, +struct sync_timeline *sync_timeline_create(const char *drv_name, const char *name) { struct sync_timeline *obj; - if (size < sizeof(struct sync_timeline)) - return NULL; - - obj = kzalloc(size, GFP_KERNEL); + obj = kzalloc(sizeof(*obj), GFP_KERNEL); if (!obj) return NULL; diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index f003e97..f2fbf98 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -66,16 +66,13 @@ static inline struct sync_timeline *fence_parent(struct fence *fence) /** * sync_timeline_create() - creates a sync object - * @size: size to allocate for this obj * @drv_name: sync_timeline driver name * @name: sync_timeline name * - * Creates a new sync_timeline. @size bytes will be allocated allowing - * for implementation specific data to be kept after the generic - * sync_timeline struct. Returns the sync_timeline object or NULL in + * Creates a new sync_timeline. Returns the sync_timeline object or NULL in * case of error. */ -struct sync_timeline *sync_timeline_create(int size, const char *drv_name, +struct sync_timeline *sync_timeline_create(const char *drv_name, const char *name); /** diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 6282046..cb0f888 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -218,7 +218,7 @@ static int sw_sync_debugfs_open(struct inode *inode, struct file *file) get_task_comm(task_comm, current); - obj = sync_timeline_create(sizeof(*obj), "sw_sync", task_comm); + obj = sync_timeline_create("sw_sync", task_comm); if (!obj) return -ENOMEM; -- cgit v1.1 From 0431b9065f28ecf6c320fefebe0241620049984f Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:04 -0300 Subject: staging/android: bring struct sync_pt back Move the list_head members from sync_pt to struct fence was a mistake, they will not be used by struct fence as planned before, so here we create sync_pt again to bring the list heads back. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sync.c | 40 ++++++++++++++++++------------------ drivers/staging/android/sync.h | 29 ++++++++++++++++++++++---- drivers/staging/android/sync_debug.c | 16 +++++++-------- include/linux/fence.h | 2 -- 4 files changed, 53 insertions(+), 34 deletions(-) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index c83a599..aab80ec 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -28,8 +28,6 @@ #define CREATE_TRACE_POINTS #include "trace/sync.h" -static const struct fence_ops timeline_fence_ops; - struct sync_timeline *sync_timeline_create(const char *drv_name, const char *name) { @@ -90,7 +88,7 @@ EXPORT_SYMBOL(sync_timeline_destroy); void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc) { unsigned long flags; - struct fence *fence, *next; + struct sync_pt *pt, *next; trace_sync_timeline(obj); @@ -98,37 +96,37 @@ void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc) obj->value += inc; - list_for_each_entry_safe(fence, next, &obj->active_list_head, + list_for_each_entry_safe(pt, next, &obj->active_list_head, active_list) { - if (fence_is_signaled_locked(fence)) - list_del_init(&fence->active_list); + if (fence_is_signaled_locked(&pt->base)) + list_del_init(&pt->active_list); } spin_unlock_irqrestore(&obj->child_list_lock, flags); } EXPORT_SYMBOL(sync_timeline_signal); -struct fence *sync_pt_create(struct sync_timeline *obj, int size, +struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size, unsigned int value) { unsigned long flags; - struct fence *fence; + struct sync_pt *pt; - if (size < sizeof(*fence)) + if (size < sizeof(*pt)) return NULL; - fence = kzalloc(size, GFP_KERNEL); - if (!fence) + pt = kzalloc(size, GFP_KERNEL); + if (!pt) return NULL; spin_lock_irqsave(&obj->child_list_lock, flags); sync_timeline_get(obj); - fence_init(fence, &timeline_fence_ops, &obj->child_list_lock, + fence_init(&pt->base, &timeline_fence_ops, &obj->child_list_lock, obj->context, value); - list_add_tail(&fence->child_list, &obj->child_list_head); - INIT_LIST_HEAD(&fence->active_list); + list_add_tail(&pt->child_list, &obj->child_list_head); + INIT_LIST_HEAD(&pt->active_list); spin_unlock_irqrestore(&obj->child_list_lock, flags); - return fence; + return pt; } EXPORT_SYMBOL(sync_pt_create); @@ -148,13 +146,14 @@ static const char *timeline_fence_get_timeline_name(struct fence *fence) static void timeline_fence_release(struct fence *fence) { + struct sync_pt *pt = fence_to_sync_pt(fence); struct sync_timeline *parent = fence_parent(fence); unsigned long flags; spin_lock_irqsave(fence->lock, flags); - list_del(&fence->child_list); - if (WARN_ON_ONCE(!list_empty(&fence->active_list))) - list_del(&fence->active_list); + list_del(&pt->child_list); + if (WARN_ON_ONCE(!list_empty(&pt->active_list))) + list_del(&pt->active_list); spin_unlock_irqrestore(fence->lock, flags); sync_timeline_put(parent); @@ -170,12 +169,13 @@ static bool timeline_fence_signaled(struct fence *fence) static bool timeline_fence_enable_signaling(struct fence *fence) { + struct sync_pt *pt = fence_to_sync_pt(fence); struct sync_timeline *parent = fence_parent(fence); if (timeline_fence_signaled(fence)) return false; - list_add_tail(&fence->active_list, &parent->active_list_head); + list_add_tail(&pt->active_list, &parent->active_list_head); return true; } @@ -193,7 +193,7 @@ static void timeline_fence_timeline_value_str(struct fence *fence, snprintf(str, size, "%d", parent->value); } -static const struct fence_ops timeline_fence_ops = { +const struct fence_ops timeline_fence_ops = { .get_driver_name = timeline_fence_get_driver_name, .get_timeline_name = timeline_fence_get_timeline_name, .enable_signaling = timeline_fence_enable_signaling, diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index f2fbf98..14b61cb 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -60,6 +60,27 @@ static inline struct sync_timeline *fence_parent(struct fence *fence) child_list_lock); } +/** + * struct sync_pt - sync_pt object + * @base: base fence object + * @child_list: sync timeline child's list + * @active_list: sync timeline active child's list + */ +struct sync_pt { + struct fence base; + struct list_head child_list; + struct list_head active_list; +}; + +extern const struct fence_ops timeline_fence_ops; + +static inline struct sync_pt *fence_to_sync_pt(struct fence *fence) +{ + if (fence->ops != &timeline_fence_ops) + return NULL; + return container_of(fence, struct sync_pt, base); +} + /* * API for sync_timeline implementers */ @@ -101,13 +122,13 @@ void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc); * @size: size to allocate for this pt * @inc: value of the fence * - * Creates a new fence as a child of @parent. @size bytes will be + * Creates a new sync_pt as a child of @parent. @size bytes will be * allocated allowing for implementation specific data to be kept after - * the generic sync_timeline struct. Returns the fence object or + * the generic sync_timeline struct. Returns the sync_pt object or * NULL in case of error. */ -struct fence *sync_pt_create(struct sync_timeline *parent, int size, - unsigned int inc); +struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size, + unsigned int inc); #ifdef CONFIG_DEBUG_FS diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index cb0f888..703f198 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -140,9 +140,9 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj) spin_lock_irqsave(&obj->child_list_lock, flags); list_for_each(pos, &obj->child_list_head) { - struct fence *fence = - container_of(pos, struct fence, child_list); - sync_print_fence(s, fence, false); + struct sync_pt *pt = + container_of(pos, struct sync_pt, child_list); + sync_print_fence(s, &pt->base, false); } spin_unlock_irqrestore(&obj->child_list_lock, flags); } @@ -240,7 +240,7 @@ static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, { int fd = get_unused_fd_flags(O_CLOEXEC); int err; - struct fence *fence; + struct sync_pt *pt; struct sync_file *sync_file; struct sw_sync_create_fence_data data; @@ -252,15 +252,15 @@ static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, goto err; } - fence = sync_pt_create(obj, sizeof(*fence), data.value); - if (!fence) { + pt = sync_pt_create(obj, sizeof(*pt), data.value); + if (!pt) { err = -ENOMEM; goto err; } - sync_file = sync_file_create(fence); + sync_file = sync_file_create(&pt->base); if (!sync_file) { - fence_put(fence); + fence_put(&pt->base); err = -ENOMEM; goto err; } diff --git a/include/linux/fence.h b/include/linux/fence.h index 2056e9f..1de1b3f 100644 --- a/include/linux/fence.h +++ b/include/linux/fence.h @@ -81,8 +81,6 @@ struct fence { unsigned long flags; ktime_t timestamp; int status; - struct list_head child_list; - struct list_head active_list; }; enum fence_flag_bits { -- cgit v1.1 From 1867a23b13b25d0a228b0509ade20fb977dcb601 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:05 -0300 Subject: staging/android: move sw_sync related code to sw_sync.c Split sync_debug and sw_sync in two different files. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/Makefile | 1 + drivers/staging/android/sw_sync.c | 136 +++++++++++++++++++++++++++++++++++ drivers/staging/android/sync.h | 2 + drivers/staging/android/sync_debug.c | 115 ----------------------------- 4 files changed, 139 insertions(+), 115 deletions(-) create mode 100644 drivers/staging/android/sw_sync.c diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile index bf45967..980d6dc 100644 --- a/drivers/staging/android/Makefile +++ b/drivers/staging/android/Makefile @@ -5,3 +5,4 @@ obj-y += ion/ obj-$(CONFIG_ASHMEM) += ashmem.o obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o obj-$(CONFIG_SYNC) += sync.o sync_debug.o +obj-$(CONFIG_SW_SYNC) += sw_sync.o diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c new file mode 100644 index 0000000..90e3ee5 --- /dev/null +++ b/drivers/staging/android/sw_sync.c @@ -0,0 +1,136 @@ +/* + * drivers/dma-buf/sw_sync.c + * + * Copyright (C) 2012 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + * + */ + +#include +#include +#include +#include + +#include "uapi/sw_sync.h" +#include "sync.h" + +/* + * *WARNING* + * + * improper use of this can result in deadlocking kernel drivers from userspace. + */ + +/* opening sw_sync create a new sync obj */ +static int sw_sync_debugfs_open(struct inode *inode, struct file *file) +{ + struct sync_timeline *obj; + char task_comm[TASK_COMM_LEN]; + + get_task_comm(task_comm, current); + + obj = sync_timeline_create("sw_sync", task_comm); + if (!obj) + return -ENOMEM; + + file->private_data = obj; + + return 0; +} + +static int sw_sync_debugfs_release(struct inode *inode, struct file *file) +{ + struct sync_timeline *obj = file->private_data; + + sync_timeline_destroy(obj); + return 0; +} + +static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, + unsigned long arg) +{ + int fd = get_unused_fd_flags(O_CLOEXEC); + int err; + struct sync_pt *pt; + struct sync_file *sync_file; + struct sw_sync_create_fence_data data; + + if (fd < 0) + return fd; + + if (copy_from_user(&data, (void __user *)arg, sizeof(data))) { + err = -EFAULT; + goto err; + } + + pt = sync_pt_create(obj, sizeof(*pt), data.value); + if (!pt) { + err = -ENOMEM; + goto err; + } + + sync_file = sync_file_create(&pt->base); + if (!sync_file) { + fence_put(&pt->base); + err = -ENOMEM; + goto err; + } + + data.fence = fd; + if (copy_to_user((void __user *)arg, &data, sizeof(data))) { + fput(sync_file->file); + err = -EFAULT; + goto err; + } + + fd_install(fd, sync_file->file); + + return 0; + +err: + put_unused_fd(fd); + return err; +} + +static long sw_sync_ioctl_inc(struct sync_timeline *obj, unsigned long arg) +{ + u32 value; + + if (copy_from_user(&value, (void __user *)arg, sizeof(value))) + return -EFAULT; + + sync_timeline_signal(obj, value); + + return 0; +} + +static long sw_sync_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) +{ + struct sync_timeline *obj = file->private_data; + + switch (cmd) { + case SW_SYNC_IOC_CREATE_FENCE: + return sw_sync_ioctl_create_fence(obj, arg); + + case SW_SYNC_IOC_INC: + return sw_sync_ioctl_inc(obj, arg); + + default: + return -ENOTTY; + } +} + +const struct file_operations sw_sync_debugfs_fops = { + .open = sw_sync_debugfs_open, + .release = sw_sync_debugfs_release, + .unlocked_ioctl = sw_sync_ioctl, + .compat_ioctl = sw_sync_ioctl, +}; diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 14b61cb..02ecf44 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -132,6 +132,8 @@ struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size, #ifdef CONFIG_DEBUG_FS +extern const struct file_operations sw_sync_debugfs_fops; + void sync_timeline_debug_add(struct sync_timeline *obj); void sync_timeline_debug_remove(struct sync_timeline *obj); void sync_file_debug_add(struct sync_file *fence); diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 703f198..2733cc3 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -203,121 +203,6 @@ static const struct file_operations sync_info_debugfs_fops = { .release = single_release, }; -#if IS_ENABLED(CONFIG_SW_SYNC) -/* - * *WARNING* - * - * improper use of this can result in deadlocking kernel drivers from userspace. - */ - -/* opening sw_sync create a new sync obj */ -static int sw_sync_debugfs_open(struct inode *inode, struct file *file) -{ - struct sync_timeline *obj; - char task_comm[TASK_COMM_LEN]; - - get_task_comm(task_comm, current); - - obj = sync_timeline_create("sw_sync", task_comm); - if (!obj) - return -ENOMEM; - - file->private_data = obj; - - return 0; -} - -static int sw_sync_debugfs_release(struct inode *inode, struct file *file) -{ - struct sync_timeline *obj = file->private_data; - - sync_timeline_destroy(obj); - return 0; -} - -static long sw_sync_ioctl_create_fence(struct sync_timeline *obj, - unsigned long arg) -{ - int fd = get_unused_fd_flags(O_CLOEXEC); - int err; - struct sync_pt *pt; - struct sync_file *sync_file; - struct sw_sync_create_fence_data data; - - if (fd < 0) - return fd; - - if (copy_from_user(&data, (void __user *)arg, sizeof(data))) { - err = -EFAULT; - goto err; - } - - pt = sync_pt_create(obj, sizeof(*pt), data.value); - if (!pt) { - err = -ENOMEM; - goto err; - } - - sync_file = sync_file_create(&pt->base); - if (!sync_file) { - fence_put(&pt->base); - err = -ENOMEM; - goto err; - } - - data.fence = fd; - if (copy_to_user((void __user *)arg, &data, sizeof(data))) { - fput(sync_file->file); - err = -EFAULT; - goto err; - } - - fd_install(fd, sync_file->file); - - return 0; - -err: - put_unused_fd(fd); - return err; -} - -static long sw_sync_ioctl_inc(struct sync_timeline *obj, unsigned long arg) -{ - u32 value; - - if (copy_from_user(&value, (void __user *)arg, sizeof(value))) - return -EFAULT; - - sync_timeline_signal(obj, value); - - return 0; -} - -static long sw_sync_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - struct sync_timeline *obj = file->private_data; - - switch (cmd) { - case SW_SYNC_IOC_CREATE_FENCE: - return sw_sync_ioctl_create_fence(obj, arg); - - case SW_SYNC_IOC_INC: - return sw_sync_ioctl_inc(obj, arg); - - default: - return -ENOTTY; - } -} - -static const struct file_operations sw_sync_debugfs_fops = { - .open = sw_sync_debugfs_open, - .release = sw_sync_debugfs_release, - .unlocked_ioctl = sw_sync_ioctl, - .compat_ioctl = sw_sync_ioctl, -}; -#endif - static __init int sync_debugfs_init(void) { dbgfs = debugfs_create_dir("sync", NULL); -- cgit v1.1 From d79892ad0b97ec23645cffa5406edb4eb18cb553 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:06 -0300 Subject: staging/android: clean up #includes in the sync framework Most of the includes there are not necessary anymore. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sync.c | 6 ------ drivers/staging/android/sync.h | 3 --- drivers/staging/android/sync_debug.c | 16 ---------------- 3 files changed, 25 deletions(-) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index aab80ec..bb12d86 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -14,14 +14,8 @@ * */ -#include #include -#include -#include -#include #include -#include -#include #include "sync.h" diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 02ecf44..54c515b 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -13,9 +13,6 @@ #ifndef _LINUX_SYNC_H #define _LINUX_SYNC_H -#include -#include -#include #include #include #include diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 2733cc3..864ad01 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -15,22 +15,6 @@ */ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "uapi/sw_sync.h" #include "sync.h" #ifdef CONFIG_DEBUG_FS -- cgit v1.1 From aff9da10e218c54f5ffc8bcb66c9837135074190 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:07 -0300 Subject: staging/android: make sync_timeline internal to sw_sync The only use sync_timeline will have in upstream kernel is for debugging through the SW_SYNC interface. So make it internal to SW_SYNC to avoid people use it in the future. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/Kconfig | 16 +-- drivers/staging/android/Makefile | 3 +- drivers/staging/android/sw_sync.c | 220 +++++++++++++++++++++++++++++++++++ drivers/staging/android/sync.c | 199 ------------------------------- drivers/staging/android/sync.h | 58 --------- drivers/staging/android/sync_debug.c | 2 - 6 files changed, 225 insertions(+), 273 deletions(-) delete mode 100644 drivers/staging/android/sync.c diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig index 6480f60..f52c682 100644 --- a/drivers/staging/android/Kconfig +++ b/drivers/staging/android/Kconfig @@ -24,26 +24,18 @@ config ANDROID_LOW_MEMORY_KILLER scripts (/init.rc), and it defines priority values with minimum free memory size for each priority. -config SYNC - bool "Synchronization framework" - default n - select ANON_INODES - select DMA_SHARED_BUFFER - ---help--- - This option enables the framework for synchronization between multiple - drivers. Sync implementations can take advantage of hardware - synchronization built into devices like GPUs. - config SW_SYNC - bool "Software synchronization objects" + bool "Software synchronization framework" default n - depends on SYNC depends on SYNC_FILE ---help--- A sync object driver that uses a 32bit counter to coordinate synchronization. Useful when there is no hardware primitive backing the synchronization. + WARNING: improper use of this can result in deadlocking kernel + drivers from userspace. Intended for test and debug only. + source "drivers/staging/android/ion/Kconfig" endif # if ANDROID diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile index 980d6dc..7ca61b7 100644 --- a/drivers/staging/android/Makefile +++ b/drivers/staging/android/Makefile @@ -4,5 +4,4 @@ obj-y += ion/ obj-$(CONFIG_ASHMEM) += ashmem.o obj-$(CONFIG_ANDROID_LOW_MEMORY_KILLER) += lowmemorykiller.o -obj-$(CONFIG_SYNC) += sync.o sync_debug.o -obj-$(CONFIG_SW_SYNC) += sw_sync.o +obj-$(CONFIG_SW_SYNC) += sw_sync.o sync_debug.o diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 90e3ee5..c149ac90 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -17,11 +17,231 @@ #include #include #include +#include #include #include "uapi/sw_sync.h" #include "sync.h" +#define CREATE_TRACE_POINTS +#include "trace/sync.h" + +static const struct fence_ops timeline_fence_ops; + +static inline struct sync_pt *fence_to_sync_pt(struct fence *fence) +{ + if (fence->ops != &timeline_fence_ops) + return NULL; + return container_of(fence, struct sync_pt, base); +} + +/** + * sync_timeline_create() - creates a sync object + * @drv_name: sync_timeline driver name + * @name: sync_timeline name + * + * Creates a new sync_timeline. Returns the sync_timeline object or NULL in + * case of error. + */ +struct sync_timeline *sync_timeline_create(const char *drv_name, + const char *name) +{ + struct sync_timeline *obj; + + obj = kzalloc(sizeof(*obj), GFP_KERNEL); + if (!obj) + return NULL; + + kref_init(&obj->kref); + obj->context = fence_context_alloc(1); + strlcpy(obj->name, name, sizeof(obj->name)); + strlcpy(obj->drv_name, drv_name, sizeof(obj->drv_name)); + + INIT_LIST_HEAD(&obj->child_list_head); + INIT_LIST_HEAD(&obj->active_list_head); + spin_lock_init(&obj->child_list_lock); + + sync_timeline_debug_add(obj); + + return obj; +} + +static void sync_timeline_free(struct kref *kref) +{ + struct sync_timeline *obj = + container_of(kref, struct sync_timeline, kref); + + sync_timeline_debug_remove(obj); + + kfree(obj); +} + +static void sync_timeline_get(struct sync_timeline *obj) +{ + kref_get(&obj->kref); +} + +static void sync_timeline_put(struct sync_timeline *obj) +{ + kref_put(&obj->kref, sync_timeline_free); +} + +/** + * sync_timeline_destroy() - destroys a sync object + * @obj: sync_timeline to destroy + * + * A sync implementation should call this when the @obj is going away + * (i.e. module unload.) @obj won't actually be freed until all its children + * fences are freed. + */ +static void sync_timeline_destroy(struct sync_timeline *obj) +{ + obj->destroyed = true; + /* + * Ensure timeline is marked as destroyed before + * changing timeline's fences status. + */ + smp_wmb(); + + sync_timeline_put(obj); +} + +/** + * sync_timeline_signal() - signal a status change on a sync_timeline + * @obj: sync_timeline to signal + * @inc: num to increment on timeline->value + * + * A sync implementation should call this any time one of it's fences + * has signaled or has an error condition. + */ +static void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc) +{ + unsigned long flags; + struct sync_pt *pt, *next; + + trace_sync_timeline(obj); + + spin_lock_irqsave(&obj->child_list_lock, flags); + + obj->value += inc; + + list_for_each_entry_safe(pt, next, &obj->active_list_head, + active_list) { + if (fence_is_signaled_locked(&pt->base)) + list_del_init(&pt->active_list); + } + + spin_unlock_irqrestore(&obj->child_list_lock, flags); +} + +/** + * sync_pt_create() - creates a sync pt + * @parent: fence's parent sync_timeline + * @size: size to allocate for this pt + * @inc: value of the fence + * + * Creates a new sync_pt as a child of @parent. @size bytes will be + * allocated allowing for implementation specific data to be kept after + * the generic sync_timeline struct. Returns the sync_pt object or + * NULL in case of error. + */ +static struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size, + unsigned int value) +{ + unsigned long flags; + struct sync_pt *pt; + + if (size < sizeof(*pt)) + return NULL; + + pt = kzalloc(size, GFP_KERNEL); + if (!pt) + return NULL; + + spin_lock_irqsave(&obj->child_list_lock, flags); + sync_timeline_get(obj); + fence_init(&pt->base, &timeline_fence_ops, &obj->child_list_lock, + obj->context, value); + list_add_tail(&pt->child_list, &obj->child_list_head); + INIT_LIST_HEAD(&pt->active_list); + spin_unlock_irqrestore(&obj->child_list_lock, flags); + return pt; +} + +static const char *timeline_fence_get_driver_name(struct fence *fence) +{ + struct sync_timeline *parent = fence_parent(fence); + + return parent->drv_name; +} + +static const char *timeline_fence_get_timeline_name(struct fence *fence) +{ + struct sync_timeline *parent = fence_parent(fence); + + return parent->name; +} + +static void timeline_fence_release(struct fence *fence) +{ + struct sync_pt *pt = fence_to_sync_pt(fence); + struct sync_timeline *parent = fence_parent(fence); + unsigned long flags; + + spin_lock_irqsave(fence->lock, flags); + list_del(&pt->child_list); + if (WARN_ON_ONCE(!list_empty(&pt->active_list))) + list_del(&pt->active_list); + spin_unlock_irqrestore(fence->lock, flags); + + sync_timeline_put(parent); + fence_free(fence); +} + +static bool timeline_fence_signaled(struct fence *fence) +{ + struct sync_timeline *parent = fence_parent(fence); + + return (fence->seqno > parent->value) ? false : true; +} + +static bool timeline_fence_enable_signaling(struct fence *fence) +{ + struct sync_pt *pt = fence_to_sync_pt(fence); + struct sync_timeline *parent = fence_parent(fence); + + if (timeline_fence_signaled(fence)) + return false; + + list_add_tail(&pt->active_list, &parent->active_list_head); + return true; +} + +static void timeline_fence_value_str(struct fence *fence, + char *str, int size) +{ + snprintf(str, size, "%d", fence->seqno); +} + +static void timeline_fence_timeline_value_str(struct fence *fence, + char *str, int size) +{ + struct sync_timeline *parent = fence_parent(fence); + + snprintf(str, size, "%d", parent->value); +} + +static const struct fence_ops timeline_fence_ops = { + .get_driver_name = timeline_fence_get_driver_name, + .get_timeline_name = timeline_fence_get_timeline_name, + .enable_signaling = timeline_fence_enable_signaling, + .signaled = timeline_fence_signaled, + .wait = fence_default_wait, + .release = timeline_fence_release, + .fence_value_str = timeline_fence_value_str, + .timeline_value_str = timeline_fence_timeline_value_str, +}; + /* * *WARNING* * diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c deleted file mode 100644 index bb12d86..0000000 --- a/drivers/staging/android/sync.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * drivers/base/sync.c - * - * Copyright (C) 2012 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -#include -#include - -#include "sync.h" - -#define CREATE_TRACE_POINTS -#include "trace/sync.h" - -struct sync_timeline *sync_timeline_create(const char *drv_name, - const char *name) -{ - struct sync_timeline *obj; - - obj = kzalloc(sizeof(*obj), GFP_KERNEL); - if (!obj) - return NULL; - - kref_init(&obj->kref); - obj->context = fence_context_alloc(1); - strlcpy(obj->name, name, sizeof(obj->name)); - strlcpy(obj->drv_name, drv_name, sizeof(obj->drv_name)); - - INIT_LIST_HEAD(&obj->child_list_head); - INIT_LIST_HEAD(&obj->active_list_head); - spin_lock_init(&obj->child_list_lock); - - sync_timeline_debug_add(obj); - - return obj; -} -EXPORT_SYMBOL(sync_timeline_create); - -static void sync_timeline_free(struct kref *kref) -{ - struct sync_timeline *obj = - container_of(kref, struct sync_timeline, kref); - - sync_timeline_debug_remove(obj); - - kfree(obj); -} - -static void sync_timeline_get(struct sync_timeline *obj) -{ - kref_get(&obj->kref); -} - -static void sync_timeline_put(struct sync_timeline *obj) -{ - kref_put(&obj->kref, sync_timeline_free); -} - -void sync_timeline_destroy(struct sync_timeline *obj) -{ - obj->destroyed = true; - /* - * Ensure timeline is marked as destroyed before - * changing timeline's fences status. - */ - smp_wmb(); - - sync_timeline_put(obj); -} -EXPORT_SYMBOL(sync_timeline_destroy); - -void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc) -{ - unsigned long flags; - struct sync_pt *pt, *next; - - trace_sync_timeline(obj); - - spin_lock_irqsave(&obj->child_list_lock, flags); - - obj->value += inc; - - list_for_each_entry_safe(pt, next, &obj->active_list_head, - active_list) { - if (fence_is_signaled_locked(&pt->base)) - list_del_init(&pt->active_list); - } - - spin_unlock_irqrestore(&obj->child_list_lock, flags); -} -EXPORT_SYMBOL(sync_timeline_signal); - -struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size, - unsigned int value) -{ - unsigned long flags; - struct sync_pt *pt; - - if (size < sizeof(*pt)) - return NULL; - - pt = kzalloc(size, GFP_KERNEL); - if (!pt) - return NULL; - - spin_lock_irqsave(&obj->child_list_lock, flags); - sync_timeline_get(obj); - fence_init(&pt->base, &timeline_fence_ops, &obj->child_list_lock, - obj->context, value); - list_add_tail(&pt->child_list, &obj->child_list_head); - INIT_LIST_HEAD(&pt->active_list); - spin_unlock_irqrestore(&obj->child_list_lock, flags); - return pt; -} -EXPORT_SYMBOL(sync_pt_create); - -static const char *timeline_fence_get_driver_name(struct fence *fence) -{ - struct sync_timeline *parent = fence_parent(fence); - - return parent->drv_name; -} - -static const char *timeline_fence_get_timeline_name(struct fence *fence) -{ - struct sync_timeline *parent = fence_parent(fence); - - return parent->name; -} - -static void timeline_fence_release(struct fence *fence) -{ - struct sync_pt *pt = fence_to_sync_pt(fence); - struct sync_timeline *parent = fence_parent(fence); - unsigned long flags; - - spin_lock_irqsave(fence->lock, flags); - list_del(&pt->child_list); - if (WARN_ON_ONCE(!list_empty(&pt->active_list))) - list_del(&pt->active_list); - spin_unlock_irqrestore(fence->lock, flags); - - sync_timeline_put(parent); - fence_free(fence); -} - -static bool timeline_fence_signaled(struct fence *fence) -{ - struct sync_timeline *parent = fence_parent(fence); - - return (fence->seqno > parent->value) ? false : true; -} - -static bool timeline_fence_enable_signaling(struct fence *fence) -{ - struct sync_pt *pt = fence_to_sync_pt(fence); - struct sync_timeline *parent = fence_parent(fence); - - if (timeline_fence_signaled(fence)) - return false; - - list_add_tail(&pt->active_list, &parent->active_list_head); - return true; -} - -static void timeline_fence_value_str(struct fence *fence, - char *str, int size) -{ - snprintf(str, size, "%d", fence->seqno); -} - -static void timeline_fence_timeline_value_str(struct fence *fence, - char *str, int size) -{ - struct sync_timeline *parent = fence_parent(fence); - - snprintf(str, size, "%d", parent->value); -} - -const struct fence_ops timeline_fence_ops = { - .get_driver_name = timeline_fence_get_driver_name, - .get_timeline_name = timeline_fence_get_timeline_name, - .enable_signaling = timeline_fence_enable_signaling, - .signaled = timeline_fence_signaled, - .wait = fence_default_wait, - .release = timeline_fence_release, - .fence_value_str = timeline_fence_value_str, - .timeline_value_str = timeline_fence_timeline_value_str, -}; diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 54c515b..3a50851 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -69,64 +69,6 @@ struct sync_pt { struct list_head active_list; }; -extern const struct fence_ops timeline_fence_ops; - -static inline struct sync_pt *fence_to_sync_pt(struct fence *fence) -{ - if (fence->ops != &timeline_fence_ops) - return NULL; - return container_of(fence, struct sync_pt, base); -} - -/* - * API for sync_timeline implementers - */ - -/** - * sync_timeline_create() - creates a sync object - * @drv_name: sync_timeline driver name - * @name: sync_timeline name - * - * Creates a new sync_timeline. Returns the sync_timeline object or NULL in - * case of error. - */ -struct sync_timeline *sync_timeline_create(const char *drv_name, - const char *name); - -/** - * sync_timeline_destroy() - destroys a sync object - * @obj: sync_timeline to destroy - * - * A sync implementation should call this when the @obj is going away - * (i.e. module unload.) @obj won't actually be freed until all its children - * fences are freed. - */ -void sync_timeline_destroy(struct sync_timeline *obj); - -/** - * sync_timeline_signal() - signal a status change on a sync_timeline - * @obj: sync_timeline to signal - * @inc: num to increment on timeline->value - * - * A sync implementation should call this any time one of it's fences - * has signaled or has an error condition. - */ -void sync_timeline_signal(struct sync_timeline *obj, unsigned int inc); - -/** - * sync_pt_create() - creates a sync pt - * @parent: fence's parent sync_timeline - * @size: size to allocate for this pt - * @inc: value of the fence - * - * Creates a new sync_pt as a child of @parent. @size bytes will be - * allocated allowing for implementation specific data to be kept after - * the generic sync_timeline struct. Returns the sync_pt object or - * NULL in case of error. - */ -struct sync_pt *sync_pt_create(struct sync_timeline *parent, int size, - unsigned int inc); - #ifdef CONFIG_DEBUG_FS extern const struct file_operations sw_sync_debugfs_fops; diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 864ad01..77386d2 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -193,10 +193,8 @@ static __init int sync_debugfs_init(void) debugfs_create_file("info", 0444, dbgfs, NULL, &sync_info_debugfs_fops); -#if IS_ENABLED(CONFIG_SW_SYNC) debugfs_create_file("sw_sync", 0644, dbgfs, NULL, &sw_sync_debugfs_fops); -#endif return 0; } -- cgit v1.1 From 6f65aa8925f7a908eb4d08339c03c40a300ac461 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:08 -0300 Subject: staging/android: make sw_ioctl info internal to sw_sync.c We don't want to export this from the kernel. This is interface is only for testing and debug. So testers shall copy the ioctl info in their own projects. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sw_sync.c | 13 ++++++++++++- drivers/staging/android/uapi/sw_sync.h | 32 -------------------------------- 2 files changed, 12 insertions(+), 33 deletions(-) delete mode 100644 drivers/staging/android/uapi/sw_sync.h diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index c149ac90..72262ba 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -20,12 +20,23 @@ #include #include -#include "uapi/sw_sync.h" #include "sync.h" #define CREATE_TRACE_POINTS #include "trace/sync.h" +struct sw_sync_create_fence_data { + __u32 value; + char name[32]; + __s32 fence; /* fd of new fence */ +}; + +#define SW_SYNC_IOC_MAGIC 'W' + +#define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ + struct sw_sync_create_fence_data) +#define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, __u32) + static const struct fence_ops timeline_fence_ops; static inline struct sync_pt *fence_to_sync_pt(struct fence *fence) diff --git a/drivers/staging/android/uapi/sw_sync.h b/drivers/staging/android/uapi/sw_sync.h deleted file mode 100644 index 9b5d486..0000000 --- a/drivers/staging/android/uapi/sw_sync.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2012 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - * - */ - -#ifndef _UAPI_LINUX_SW_SYNC_H -#define _UAPI_LINUX_SW_SYNC_H - -#include - -struct sw_sync_create_fence_data { - __u32 value; - char name[32]; - __s32 fence; /* fd of new fence */ -}; - -#define SW_SYNC_IOC_MAGIC 'W' - -#define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0,\ - struct sw_sync_create_fence_data) -#define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, __u32) - -#endif /* _UAPI_LINUX_SW_SYNC_H */ -- cgit v1.1 From 342952d3a5c4d128649c7fd8e34d7d5eb6d036aa Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:09 -0300 Subject: staging/android: remove 'destroyed' member from struct sync_timeline 'destroyed' was set but not used ny anyone. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sw_sync.c | 5 ----- drivers/staging/android/sync.h | 5 +---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 72262ba..1f956b9 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -107,11 +107,6 @@ static void sync_timeline_put(struct sync_timeline *obj) */ static void sync_timeline_destroy(struct sync_timeline *obj) { - obj->destroyed = true; - /* - * Ensure timeline is marked as destroyed before - * changing timeline's fences status. - */ smp_wmb(); sync_timeline_put(obj); diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 3a50851..3c551f5 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -25,10 +25,8 @@ * @kref: reference count on fence. * @drv_name: drv_name of the driver using the sync_timeline * @name: name of the sync_timeline. Useful for debugging - * @destroyed: set when sync_timeline is destroyed * @child_list_head: list of children sync_pts for this sync_timeline - * @child_list_lock: lock protecting @child_list_head, destroyed, and - * fence.status + * @child_list_lock: lock protecting @child_list_head and fence.status * @active_list_head: list of active (unsignaled/errored) sync_pts * @sync_timeline_list: membership in global sync_timeline_list */ @@ -38,7 +36,6 @@ struct sync_timeline { char name[32]; /* protected by child_list_lock */ - bool destroyed; int context, value; struct list_head child_list_head; -- cgit v1.1 From 711102325302d793aa0eee493be79ce9c32ae426 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:10 -0300 Subject: staging/android: remove sync_timeline_destroy() This function was just used by the file release function, so we just fold its content there and remove sync_timeline_destroy(). Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sw_sync.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 1f956b9..cf4de27 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -98,21 +98,6 @@ static void sync_timeline_put(struct sync_timeline *obj) } /** - * sync_timeline_destroy() - destroys a sync object - * @obj: sync_timeline to destroy - * - * A sync implementation should call this when the @obj is going away - * (i.e. module unload.) @obj won't actually be freed until all its children - * fences are freed. - */ -static void sync_timeline_destroy(struct sync_timeline *obj) -{ - smp_wmb(); - - sync_timeline_put(obj); -} - -/** * sync_timeline_signal() - signal a status change on a sync_timeline * @obj: sync_timeline to signal * @inc: num to increment on timeline->value @@ -275,7 +260,9 @@ static int sw_sync_debugfs_release(struct inode *inode, struct file *file) { struct sync_timeline *obj = file->private_data; - sync_timeline_destroy(obj); + smp_wmb(); + + sync_timeline_put(obj); return 0; } -- cgit v1.1 From b9bc2b7b658a4bee8884e2c339a0a27f4bfa7f22 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:11 -0300 Subject: staging/android: remove drv_name from sync_timeline As it is internal to sw_sync now this value will always be "sw_sync". Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sw_sync.c | 11 +++-------- drivers/staging/android/sync.h | 2 -- drivers/staging/android/sync_debug.c | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index cf4de27..ae56ece 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -48,14 +48,12 @@ static inline struct sync_pt *fence_to_sync_pt(struct fence *fence) /** * sync_timeline_create() - creates a sync object - * @drv_name: sync_timeline driver name * @name: sync_timeline name * * Creates a new sync_timeline. Returns the sync_timeline object or NULL in * case of error. */ -struct sync_timeline *sync_timeline_create(const char *drv_name, - const char *name) +struct sync_timeline *sync_timeline_create(const char *name) { struct sync_timeline *obj; @@ -66,7 +64,6 @@ struct sync_timeline *sync_timeline_create(const char *drv_name, kref_init(&obj->kref); obj->context = fence_context_alloc(1); strlcpy(obj->name, name, sizeof(obj->name)); - strlcpy(obj->drv_name, drv_name, sizeof(obj->drv_name)); INIT_LIST_HEAD(&obj->child_list_head); INIT_LIST_HEAD(&obj->active_list_head); @@ -161,9 +158,7 @@ static struct sync_pt *sync_pt_create(struct sync_timeline *obj, int size, static const char *timeline_fence_get_driver_name(struct fence *fence) { - struct sync_timeline *parent = fence_parent(fence); - - return parent->drv_name; + return "sw_sync"; } static const char *timeline_fence_get_timeline_name(struct fence *fence) @@ -247,7 +242,7 @@ static int sw_sync_debugfs_open(struct inode *inode, struct file *file) get_task_comm(task_comm, current); - obj = sync_timeline_create("sw_sync", task_comm); + obj = sync_timeline_create(task_comm); if (!obj) return -ENOMEM; diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h index 3c551f5..48e2d1c 100644 --- a/drivers/staging/android/sync.h +++ b/drivers/staging/android/sync.h @@ -23,7 +23,6 @@ /** * struct sync_timeline - sync object * @kref: reference count on fence. - * @drv_name: drv_name of the driver using the sync_timeline * @name: name of the sync_timeline. Useful for debugging * @child_list_head: list of children sync_pts for this sync_timeline * @child_list_lock: lock protecting @child_list_head and fence.status @@ -32,7 +31,6 @@ */ struct sync_timeline { struct kref kref; - char drv_name[32]; char name[32]; /* protected by child_list_lock */ diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 77386d2..b2697a1 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -120,7 +120,7 @@ static void sync_print_obj(struct seq_file *s, struct sync_timeline *obj) struct list_head *pos; unsigned long flags; - seq_printf(s, "%s %s: %d\n", obj->name, obj->drv_name, obj->value); + seq_printf(s, "%s: %d\n", obj->name, obj->value); spin_lock_irqsave(&obj->child_list_lock, flags); list_for_each(pos, &obj->child_list_head) { -- cgit v1.1 From 1fe82e2e148697fd1fbbb2944e143b182c51e227 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:12 -0300 Subject: staging/android: rename sync.h to sync_debug.h This header file only contains information for debugging and SW_SYNC, so rename it to sync_debug.h instead of having a more generic name. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sw_sync.c | 2 +- drivers/staging/android/sync.h | 85 ------------------------------------ drivers/staging/android/sync_debug.c | 2 +- drivers/staging/android/sync_debug.h | 85 ++++++++++++++++++++++++++++++++++++ drivers/staging/android/trace/sync.h | 2 +- 5 files changed, 88 insertions(+), 88 deletions(-) delete mode 100644 drivers/staging/android/sync.h create mode 100644 drivers/staging/android/sync_debug.h diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index ae56ece..115c917 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -20,7 +20,7 @@ #include #include -#include "sync.h" +#include "sync_debug.h" #define CREATE_TRACE_POINTS #include "trace/sync.h" diff --git a/drivers/staging/android/sync.h b/drivers/staging/android/sync.h deleted file mode 100644 index 48e2d1c..0000000 --- a/drivers/staging/android/sync.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * include/linux/sync.h - * - * Copyright (C) 2012 Google, Inc. - * - * 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. - * - */ - -#ifndef _LINUX_SYNC_H -#define _LINUX_SYNC_H - -#include -#include -#include - -#include -#include - -/** - * struct sync_timeline - sync object - * @kref: reference count on fence. - * @name: name of the sync_timeline. Useful for debugging - * @child_list_head: list of children sync_pts for this sync_timeline - * @child_list_lock: lock protecting @child_list_head and fence.status - * @active_list_head: list of active (unsignaled/errored) sync_pts - * @sync_timeline_list: membership in global sync_timeline_list - */ -struct sync_timeline { - struct kref kref; - char name[32]; - - /* protected by child_list_lock */ - int context, value; - - struct list_head child_list_head; - spinlock_t child_list_lock; - - struct list_head active_list_head; - -#ifdef CONFIG_DEBUG_FS - struct list_head sync_timeline_list; -#endif -}; - -static inline struct sync_timeline *fence_parent(struct fence *fence) -{ - return container_of(fence->lock, struct sync_timeline, - child_list_lock); -} - -/** - * struct sync_pt - sync_pt object - * @base: base fence object - * @child_list: sync timeline child's list - * @active_list: sync timeline active child's list - */ -struct sync_pt { - struct fence base; - struct list_head child_list; - struct list_head active_list; -}; - -#ifdef CONFIG_DEBUG_FS - -extern const struct file_operations sw_sync_debugfs_fops; - -void sync_timeline_debug_add(struct sync_timeline *obj); -void sync_timeline_debug_remove(struct sync_timeline *obj); -void sync_file_debug_add(struct sync_file *fence); -void sync_file_debug_remove(struct sync_file *fence); -void sync_dump(void); - -#else -# define sync_timeline_debug_add(obj) -# define sync_timeline_debug_remove(obj) -# define sync_file_debug_add(fence) -# define sync_file_debug_remove(fence) -# define sync_dump() -#endif - -#endif /* _LINUX_SYNC_H */ diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index b2697a1..b760226 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -15,7 +15,7 @@ */ #include -#include "sync.h" +#include "sync_debug.h" #ifdef CONFIG_DEBUG_FS diff --git a/drivers/staging/android/sync_debug.h b/drivers/staging/android/sync_debug.h new file mode 100644 index 0000000..48e2d1c --- /dev/null +++ b/drivers/staging/android/sync_debug.h @@ -0,0 +1,85 @@ +/* + * include/linux/sync.h + * + * Copyright (C) 2012 Google, Inc. + * + * 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. + * + */ + +#ifndef _LINUX_SYNC_H +#define _LINUX_SYNC_H + +#include +#include +#include + +#include +#include + +/** + * struct sync_timeline - sync object + * @kref: reference count on fence. + * @name: name of the sync_timeline. Useful for debugging + * @child_list_head: list of children sync_pts for this sync_timeline + * @child_list_lock: lock protecting @child_list_head and fence.status + * @active_list_head: list of active (unsignaled/errored) sync_pts + * @sync_timeline_list: membership in global sync_timeline_list + */ +struct sync_timeline { + struct kref kref; + char name[32]; + + /* protected by child_list_lock */ + int context, value; + + struct list_head child_list_head; + spinlock_t child_list_lock; + + struct list_head active_list_head; + +#ifdef CONFIG_DEBUG_FS + struct list_head sync_timeline_list; +#endif +}; + +static inline struct sync_timeline *fence_parent(struct fence *fence) +{ + return container_of(fence->lock, struct sync_timeline, + child_list_lock); +} + +/** + * struct sync_pt - sync_pt object + * @base: base fence object + * @child_list: sync timeline child's list + * @active_list: sync timeline active child's list + */ +struct sync_pt { + struct fence base; + struct list_head child_list; + struct list_head active_list; +}; + +#ifdef CONFIG_DEBUG_FS + +extern const struct file_operations sw_sync_debugfs_fops; + +void sync_timeline_debug_add(struct sync_timeline *obj); +void sync_timeline_debug_remove(struct sync_timeline *obj); +void sync_file_debug_add(struct sync_file *fence); +void sync_file_debug_remove(struct sync_file *fence); +void sync_dump(void); + +#else +# define sync_timeline_debug_add(obj) +# define sync_timeline_debug_remove(obj) +# define sync_file_debug_add(fence) +# define sync_file_debug_remove(fence) +# define sync_dump() +#endif + +#endif /* _LINUX_SYNC_H */ diff --git a/drivers/staging/android/trace/sync.h b/drivers/staging/android/trace/sync.h index d7f6457f..6b5ce96 100644 --- a/drivers/staging/android/trace/sync.h +++ b/drivers/staging/android/trace/sync.h @@ -5,7 +5,7 @@ #if !defined(_TRACE_SYNC_H) || defined(TRACE_HEADER_MULTI_READ) #define _TRACE_SYNC_H -#include "../sync.h" +#include "../sync_debug.h" #include TRACE_EVENT(sync_timeline, -- cgit v1.1 From b1f656044a9936880d5a7460cd8784b2e124ab87 Mon Sep 17 00:00:00 2001 From: Gustavo Padovan Date: Tue, 31 May 2016 16:59:13 -0300 Subject: staging/android: add DEBUG_FS dependence on Kconfig SW_SYNC only works with DEBUG_FS so state it in the Kconfig file. Signed-off-by: Gustavo Padovan Reviewed-by: Daniel Vetter Reviewed-by: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/Kconfig | 1 + drivers/staging/android/sync_debug.c | 4 ---- drivers/staging/android/sync_debug.h | 4 +--- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig index f52c682..06e41d2 100644 --- a/drivers/staging/android/Kconfig +++ b/drivers/staging/android/Kconfig @@ -28,6 +28,7 @@ config SW_SYNC bool "Software synchronization framework" default n depends on SYNC_FILE + depends on DEBUG_FS ---help--- A sync object driver that uses a 32bit counter to coordinate synchronization. Useful when there is no hardware primitive backing diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index b760226..9032969 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -17,8 +17,6 @@ #include #include "sync_debug.h" -#ifdef CONFIG_DEBUG_FS - static struct dentry *dbgfs; static LIST_HEAD(sync_timeline_list_head); @@ -225,5 +223,3 @@ void sync_dump(void) } } } - -#endif diff --git a/drivers/staging/android/sync_debug.h b/drivers/staging/android/sync_debug.h index 48e2d1c..425ebc5 100644 --- a/drivers/staging/android/sync_debug.h +++ b/drivers/staging/android/sync_debug.h @@ -41,9 +41,7 @@ struct sync_timeline { struct list_head active_list_head; -#ifdef CONFIG_DEBUG_FS struct list_head sync_timeline_list; -#endif }; static inline struct sync_timeline *fence_parent(struct fence *fence) @@ -64,7 +62,7 @@ struct sync_pt { struct list_head active_list; }; -#ifdef CONFIG_DEBUG_FS +#ifdef CONFIG_SW_SYNC extern const struct file_operations sw_sync_debugfs_fops; -- cgit v1.1 From 0fd9da9a979aecfb9df40dfb3304db2b16fa7e05 Mon Sep 17 00:00:00 2001 From: Nicolai Stange Date: Fri, 27 May 2016 20:03:54 +0200 Subject: staging/android: sync_debug: unproxify debugfs files' fops Since commit 49d200deaa68 ("debugfs: prevent access to removed files' private data"), a debugfs file's file_operations methods get proxied through lifetime aware wrappers. However, only a certain subset of the file_operations members is supported by debugfs and ->compat_ioctl isn't among them -- it appears to be NULL from the VFS layer's perspective. This behaviour breaks the /sys/kernel/debug/sync/sw_sync file introduced concurrently with commit a44eb74cd413 ("staging/android: move SW_SYNC_USER to a debugfs file"). Since that file never gets removed, there is no file removal race and thus, a lifetime checking proxy isn't needed. Avoid the proxying for /sys/kernel/debug/sync/sw_sync by creating it via debugfs_create_file_unsafe() rather than debugfs_create_file(). For consistency, do the same for /sys/kernel/debug/sync/info. Fixes: 49d200deaa68 ("debugfs: prevent access to removed files' private data") Fixes: a44eb74cd413 ("staging/android: move SW_SYNC_USER to a debugfs file") Signed-off-by: Nicolai Stange Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sync_debug.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/android/sync_debug.c b/drivers/staging/android/sync_debug.c index 9032969..4c5a855 100644 --- a/drivers/staging/android/sync_debug.c +++ b/drivers/staging/android/sync_debug.c @@ -189,10 +189,15 @@ static __init int sync_debugfs_init(void) { dbgfs = debugfs_create_dir("sync", NULL); - debugfs_create_file("info", 0444, dbgfs, NULL, &sync_info_debugfs_fops); - - debugfs_create_file("sw_sync", 0644, dbgfs, NULL, - &sw_sync_debugfs_fops); + /* + * The debugfs files won't ever get removed and thus, there is + * no need to protect it against removal races. The use of + * debugfs_create_file_unsafe() is actually safe here. + */ + debugfs_create_file_unsafe("info", 0444, dbgfs, NULL, + &sync_info_debugfs_fops); + debugfs_create_file_unsafe("sw_sync", 0644, dbgfs, NULL, + &sw_sync_debugfs_fops); return 0; } -- cgit v1.1 From 6ee9169b407f70334f59cdf5a40a72a5d27f0ec2 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 17 Jun 2016 10:46:52 +0200 Subject: staging: ks7010: remove cfg file handling I verified that all but two settings from the config file can be set up also via 'iwconfig' or 'iwpriv'. The two missing are ROM_FILE and PhyInformationTimer. ROM_FILE can be easily dropped. There is only one known firmware floating on the net, so, the name is fix and we can make this constant. Frankly, I don't know when PhyInformationTimer needs to be set to non-zero. But if we need it somewhen, there is already (currently commented out) code to add this as another private method, so we could use that. Summa summarum: We can remove the config file handling and the example config file. The only useful action, initialization of the configuration struct, is now moved to the sdio main file. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/Makefile | 3 +- drivers/staging/ks7010/TODO | 1 - drivers/staging/ks7010/ks7010_config.c | 500 --------------------------------- drivers/staging/ks7010/ks7010_sdio.c | 49 ++-- drivers/staging/ks7010/ks7010_sdio.h | 1 - drivers/staging/ks7010/ks79xx.cfg | 116 -------- drivers/staging/ks7010/ks_wlan.h | 1 - 7 files changed, 33 insertions(+), 638 deletions(-) delete mode 100644 drivers/staging/ks7010/ks7010_config.c delete mode 100644 drivers/staging/ks7010/ks79xx.cfg diff --git a/drivers/staging/ks7010/Makefile b/drivers/staging/ks7010/Makefile index f6a2cc8..69fcf8d 100644 --- a/drivers/staging/ks7010/Makefile +++ b/drivers/staging/ks7010/Makefile @@ -1,5 +1,4 @@ obj-$(CONFIG_KS7010) += ks7010.o ccflags-y += -DKS_WLAN_DEBUG=0 -ks7010-y := michael_mic.o ks_hostif.o ks_wlan_net.o \ - ks7010_sdio.o ks7010_config.o +ks7010-y := michael_mic.o ks_hostif.o ks_wlan_net.o ks7010_sdio.o diff --git a/drivers/staging/ks7010/TODO b/drivers/staging/ks7010/TODO index 5cbb4ca..2938d35 100644 --- a/drivers/staging/ks7010/TODO +++ b/drivers/staging/ks7010/TODO @@ -26,7 +26,6 @@ Now the TODOs: - fix codechecker warnings (checkpatch, sparse, smatch). But PLEASE make sure that you are not only silencing the warning but really fixing code. You should understand the change you submit. -- drop using a config file and use an upstream technique for configuration - fix the 'card removal' event when card is inserted when booting - check what other upstream wireless mechanisms can be used instead of the custom ones here diff --git a/drivers/staging/ks7010/ks7010_config.c b/drivers/staging/ks7010/ks7010_config.c deleted file mode 100644 index 4b495cb..0000000 --- a/drivers/staging/ks7010/ks7010_config.c +++ /dev/null @@ -1,500 +0,0 @@ -#include -#include - -#include "ks_wlan.h" -#include "ks_hostif.h" -#include "ks_wlan_ioctl.h" - -static int wep_on_off; -#define WEP_OFF 0 -#define WEP_ON_64BIT 1 -#define WEP_ON_128BIT 2 - -static int wep_type; -#define WEP_KEY_CHARACTER 0 -#define WEP_KEY_HEX 1 - -static -void analyze_character_wep_key(struct ks_wlan_parameter *param, - int wep_key_index, char *value) -{ - int i; - unsigned char wep_key[26], key_length; - - key_length = (wep_on_off == WEP_ON_64BIT) ? 5 : 13; - /* 64bit key_length = 5; 128bit key_length = 13; */ - - for (i = 0; i < key_length; i++) { - wep_key[i] = value[i]; - } - - if (wep_key_index < 0 || wep_key_index > 3) - return; - - param->wep_key[wep_key_index].size = key_length; - for (i = 0; i < (param->wep_key[wep_key_index].size); i++) { - param->wep_key[wep_key_index].val[i] = wep_key[i]; - } -} - -static -void analyze_hex_wep_key(struct ks_wlan_parameter *param, int wep_key_index, - char *value) -{ - unsigned char wep_end[26], i, j, key_length; - - key_length = (wep_on_off == WEP_ON_64BIT) ? 10 : 26; - /* 64bit key_length = 10; 128bit key_length = 26; */ - - for (i = 0; i < key_length; i++) { - wep_end[i] = value[i]; - if (i % 2) { - /* Odd */ - for (j = 0x00; j < 0x10; j++) { - if (j < 0x0a) { - if (wep_end[i] == j + 0x30) - wep_end[i] = j; - } else { - if ((wep_end[i] == - j + 0x37) | (wep_end[i] == - j + 0x57)) - wep_end[i] = j; - } - } - } else { - /* Even */ - for (j = 0x00; j < 0x10; j++) { - if (j < 0x0a) { - if (wep_end[i] == j + 0x30) { - wep_end[i] = j * 16; - } - } else { - if ((wep_end[i] == - j + 0x37) | (wep_end[i] == - j + 0x57)) - wep_end[i] = j * 16; - } - } - } - } - - for (i = 0; i < key_length / 2; i++) { - wep_end[i] = wep_end[i * 2] + wep_end[(i * 2) + 1]; - } - - if (wep_key_index < 0 || wep_key_index > 3) - return; - - param->wep_key[wep_key_index].size = key_length / 2; - for (i = 0; i < (param->wep_key[wep_key_index].size); i++) { - param->wep_key[wep_key_index].val[i] = wep_end[i]; - } - -} - -static -int rate_set_configuration(struct ks_wlan_private *priv, char *value) -{ - int rc = 0; - - priv->reg.tx_rate = TX_RATE_FIXED; - priv->reg.rate_set.size = 1; - - switch (*value) { - case '1': /* 1M 11M 12M 18M */ - if (*(value + 1) == '8') { - priv->reg.rate_set.body[0] = TX_RATE_18M; - } else if (*(value + 1) == '2') { - priv->reg.rate_set.body[0] = TX_RATE_12M | BASIC_RATE; - } else if (*(value + 1) == '1') { - priv->reg.rate_set.body[0] = TX_RATE_11M | BASIC_RATE; - } else { - priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE; - } - break; - case '2': /* 2M 24M */ - if (*(value + 1) == '4') { - priv->reg.rate_set.body[0] = TX_RATE_24M | BASIC_RATE; - } else { - priv->reg.rate_set.body[0] = TX_RATE_2M | BASIC_RATE; - } - break; - case '3': /* 36M */ - priv->reg.rate_set.body[0] = TX_RATE_36M; - break; - case '4': /* 48M */ - priv->reg.rate_set.body[0] = TX_RATE_48M; - break; - case '5': /* 5.5M 54M */ - if (*(value + 1) == '4') { - priv->reg.rate_set.body[0] = TX_RATE_54M; - } else { - priv->reg.rate_set.body[0] = TX_RATE_5M | BASIC_RATE; - } - break; - case '6': /* 6M */ - priv->reg.rate_set.body[0] = TX_RATE_6M | BASIC_RATE; - break; - case '9': /* 9M */ - priv->reg.rate_set.body[0] = TX_RATE_9M; - break; - case 'K': - priv->reg.rate_set.body[6] = TX_RATE_36M; - priv->reg.rate_set.body[5] = TX_RATE_18M; - priv->reg.rate_set.body[4] = TX_RATE_24M | BASIC_RATE; - priv->reg.rate_set.body[3] = TX_RATE_12M | BASIC_RATE; - priv->reg.rate_set.body[2] = TX_RATE_6M | BASIC_RATE; - priv->reg.rate_set.body[1] = TX_RATE_11M | BASIC_RATE; - priv->reg.rate_set.body[0] = TX_RATE_2M | BASIC_RATE; - priv->reg.tx_rate = TX_RATE_FULL_AUTO; - priv->reg.rate_set.size = 7; - break; - default: - priv->reg.rate_set.body[11] = TX_RATE_54M; - priv->reg.rate_set.body[10] = TX_RATE_48M; - priv->reg.rate_set.body[9] = TX_RATE_36M; - priv->reg.rate_set.body[8] = TX_RATE_18M; - priv->reg.rate_set.body[7] = TX_RATE_9M; - priv->reg.rate_set.body[6] = TX_RATE_24M | BASIC_RATE; - priv->reg.rate_set.body[5] = TX_RATE_12M | BASIC_RATE; - priv->reg.rate_set.body[4] = TX_RATE_6M | BASIC_RATE; - priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE; - priv->reg.rate_set.body[2] = TX_RATE_5M | BASIC_RATE; - priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE; - priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE; - priv->reg.tx_rate = TX_RATE_FULL_AUTO; - priv->reg.rate_set.size = 12; - break; - } - return rc; -} - -#include -int ks_wlan_read_config_file(struct ks_wlan_private *priv) -{ - struct { - const int key_len; - const char *key; - const char *val; - } cfg_tbl[] = { - {15, "BeaconLostCount", "20"}, /* 0 */ - {7, "Channel", "1"}, /* 1 */ - {17, "FragmentThreshold", "2346"}, /* 2 */ - {13, "OperationMode", "Infrastructure"}, /* 3 */ - {19, "PowerManagementMode", "ACTIVE"}, /* 4 */ - {12, "RTSThreshold", "2347"}, /* 5 */ - {4, "SSID", "default"}, /* 6 */ - {6, "TxRate", "Auto"}, /* 7 */ - {23, "AuthenticationAlgorithm", ""}, /* 8 */ - {12, "WepKeyValue1", ""}, /* 9 */ - {12, "WepKeyValue2", ""}, /* 10 */ - {12, "WepKeyValue3", ""}, /* 11 */ - {12, "WepKeyValue4", ""}, /* 12 */ - {8, "WepIndex", "1"}, /* 13 */ - {7, "WepType", "STRING"}, /* 14 */ - {3, "Wep", "OFF"}, /* 15 */ - {13, "PREAMBLE_TYPE", "LONG"}, /* 16 */ - {8, "ScanType", "ACTIVE_SCAN"}, /* 17 */ - {8, "ROM_FILE", ROM_FILE}, /* 18 */ - {7, "PhyType", "BG_MODE"}, /* 19 */ - {7, "CtsMode", "FALSE"}, /* 20 */ - {19, "PhyInformationTimer", "0"}, /* 21 */ - {0, "", ""}, - }; - - const struct firmware *fw_entry; - struct device *dev = NULL; - char cfg_file[] = CFG_FILE; - char *cur_p, *end_p; - char wk_buff[256], *wk_p; - - /* Initialize Variable */ - priv->reg.operation_mode = MODE_INFRASTRUCTURE; /* Infrastructure */ - priv->reg.channel = 10; /* 10 */ - memset(priv->reg.bssid, 0x0, ETH_ALEN); /* BSSID */ - priv->reg.ssid.body[0] = '\0'; /* SSID */ - priv->reg.ssid.size = 0; /* SSID size */ - priv->reg.tx_rate = TX_RATE_AUTO; /* TxRate Fully Auto */ - priv->reg.preamble = LONG_PREAMBLE; /* Preamble = LONG */ - priv->reg.powermgt = POWMGT_ACTIVE_MODE; /* POWMGT_ACTIVE_MODE */ - priv->reg.scan_type = ACTIVE_SCAN; /* Active */ - priv->reg.beacon_lost_count = 20; /* Beacon Lost Count */ - priv->reg.rts = 2347UL; /* RTS Threashold */ - priv->reg.fragment = 2346UL; /* Fragmentation Threashold */ - - strcpy(&priv->reg.rom_file[0], ROM_FILE); - - priv->skb = NULL; - - priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; /* AuthenticationAlgorithm */ - - priv->reg.privacy_invoked = 0x00; /* WEP */ - priv->reg.wep_index = 0; - memset(&priv->reg.wep_key[0], 0, sizeof(priv->reg.wep_key[0])); - memset(&priv->reg.wep_key[1], 0, sizeof(priv->reg.wep_key[0])); - memset(&priv->reg.wep_key[2], 0, sizeof(priv->reg.wep_key[0])); - memset(&priv->reg.wep_key[3], 0, sizeof(priv->reg.wep_key[0])); - - priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; - priv->reg.cts_mode = CTS_MODE_FALSE; - priv->reg.phy_info_timer = 0; - priv->reg.rate_set.body[11] = TX_RATE_54M; - priv->reg.rate_set.body[10] = TX_RATE_48M; - priv->reg.rate_set.body[9] = TX_RATE_36M; - priv->reg.rate_set.body[8] = TX_RATE_18M; - priv->reg.rate_set.body[7] = TX_RATE_9M; - priv->reg.rate_set.body[6] = TX_RATE_24M | BASIC_RATE; - priv->reg.rate_set.body[5] = TX_RATE_12M | BASIC_RATE; - priv->reg.rate_set.body[4] = TX_RATE_6M | BASIC_RATE; - priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE; - priv->reg.rate_set.body[2] = TX_RATE_5M | BASIC_RATE; - priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE; - priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE; - priv->reg.tx_rate = TX_RATE_FULL_AUTO; - priv->reg.rate_set.size = 12; - - dev = &priv->ks_wlan_hw.sdio_card->func->dev; - /* If no cfg file, stay with the defaults */ - if (request_firmware_direct(&fw_entry, cfg_file, dev)) - return 0; - - DPRINTK(4, "success request_firmware() file=%s size=%zu\n", cfg_file, - fw_entry->size); - cur_p = fw_entry->data; - end_p = cur_p + fw_entry->size; - *end_p = '\0'; - - while (cur_p < end_p) { - int i, j, len; - - len = end_p - cur_p; - for (i = 0; cfg_tbl[i].key_len != 0; i++) { - if (*cur_p == '#') { - break; - } - if (len < cfg_tbl[i].key_len) { - continue; - } - if (!strncmp(cfg_tbl[i].key, cur_p, cfg_tbl[i].key_len)) { - break; - } - } - if ((*cur_p == '#') || (cfg_tbl[i].key_len == 0)) { - while (*cur_p != '\n') { - if (cur_p >= end_p) { - break; - } - cur_p++; - } - cur_p++; - } else { - cur_p += cfg_tbl[i].key_len; - if (*cur_p != '=') { - while (*cur_p != '\n') { - if (cur_p >= end_p) { - break; - } - cur_p++; - } - continue; - } - cur_p++; - - for (j = 0, wk_p = cur_p; *wk_p != '\n' && wk_p < end_p; - j++, wk_p++) { - wk_buff[j] = *wk_p; - } - wk_buff[j] = '\0'; - cur_p = wk_p; - DPRINTK(4, "%s=%s\n", cfg_tbl[i].key, wk_buff); - wk_p = wk_buff; - - switch (i) { - case 0: /* "BeaconLostCount", "10" */ - priv->reg.beacon_lost_count = - simple_strtol(wk_buff, NULL, 10); - break; - case 1: /* "Channel", "1" */ - priv->reg.channel = - simple_strtol(wk_buff, NULL, 10); - break; - case 2: /* "FragmentThreshold","2346" */ - j = simple_strtol(wk_buff, NULL, 10); - priv->reg.fragment = (unsigned long)j; - break; - case 3: /* "OperationMode","Infrastructure" */ - switch (*wk_buff) { - case 'P': - priv->reg.operation_mode = - MODE_PSEUDO_ADHOC; - break; - case 'I': - priv->reg.operation_mode = - MODE_INFRASTRUCTURE; - break; - case '8': - priv->reg.operation_mode = MODE_ADHOC; - break; - default: - priv->reg.operation_mode = - MODE_INFRASTRUCTURE; - } - break; - case 4: /* "PowerManagementMode","POWER_ACTIVE" */ - if (!strncmp(wk_buff, "SAVE1", 5)) { - priv->reg.powermgt = POWMGT_SAVE1_MODE; - } else if (!strncmp(wk_buff, "SAVE2", 5)) { - priv->reg.powermgt = POWMGT_SAVE2_MODE; - } else { - priv->reg.powermgt = POWMGT_ACTIVE_MODE; - } - break; - case 5: /* "RTSThreshold","2347" */ - j = simple_strtol(wk_buff, NULL, 10); - priv->reg.rts = (unsigned long)j; - break; - case 6: /* "SSID","" */ - if (*wk_p != '"') - break; - wk_p++; - for (j = 0; *wk_p != '"'; j++) { - if (wk_p == '\0') { - break; - } - priv->reg.ssid.body[j] = *wk_p++; - } - priv->reg.ssid.body[j] = '\0'; - priv->reg.ssid.size = j; - wk_p++; - break; - case 7: /* "TxRate","Auto" */ - rate_set_configuration(priv, wk_p); - break; - case 8: /* "AuthenticationAlgorithm","OPEN_SYSTEM" */ - switch (*wk_p) { - case 'O': /* Authenticate System : Open System */ - priv->reg.authenticate_type = - AUTH_TYPE_OPEN_SYSTEM; - break; - case 'S': /* Authenticate System : Shared Key */ - priv->reg.authenticate_type = - AUTH_TYPE_SHARED_KEY; - break; - } - break; - case 9: /* "WepKeyValue1","" */ - case 10: /* "WepKeyValue2","" */ - case 11: /* "WepKeyValue3","" */ - case 12: /* "WepKeyValue4","" */ - if (wep_on_off != WEP_OFF) { - switch (wep_type) { - case WEP_KEY_CHARACTER: - analyze_character_wep_key - (&priv->reg, (i - 9), wk_p); - break; - case WEP_KEY_HEX: - analyze_hex_wep_key(&priv->reg, - (i - 9), - wk_p); - break; - } - } - break; - case 13: /* "WepIndex","1"->0 (So, Zero Origin) */ - priv->reg.wep_index = - simple_strtol(wk_buff, NULL, 10) - 1; - break; - case 14: /* "WepType","STRING" */ - if (!strncmp(wk_buff, "STRING", 6)) { - wep_type = WEP_KEY_CHARACTER; - } else { - wep_type = WEP_KEY_HEX; - } - break; - case 15: /* "Wep","OFF" */ - if (!strncmp(wk_buff, "OFF", 3)) { - priv->reg.privacy_invoked = 0x00; - wep_on_off = WEP_OFF; - } else { /* 64bit or 128bit */ - priv->reg.privacy_invoked = 0x01; - if (*wk_buff == '6') { /* 64bit */ - wep_on_off = WEP_ON_64BIT; - } else { /* 128bit */ - wep_on_off = WEP_ON_128BIT; - } - } - break; - case 16: /* "PREAMBLE_TYPE","LONG" */ - if (!strncmp(wk_buff, "SHORT", 5)) { - priv->reg.preamble = SHORT_PREAMBLE; - } else { /* "LONG" */ - priv->reg.preamble = LONG_PREAMBLE; - } - break; - case 17: /* "ScanType","ACTIVE_SCAN" */ - if (!strncmp(wk_buff, "PASSIVE_SCAN", 12)) { - priv->reg.scan_type = PASSIVE_SCAN; - } else { /* "ACTIVE_SCAN" */ - priv->reg.scan_type = ACTIVE_SCAN; - } - break; - case 18: // "ROM_FILE",ROMFILE - if (*wk_p != '"') - break; - wk_p++; - for (j = 0; *wk_p != '"'; j++) { - if (wk_p == '\0') { - break; - } - priv->reg.rom_file[j] = *wk_p++; - } - priv->reg.rom_file[j] = '\0'; - wk_p++; - break; - case 19: /*"PhyType", "BG_MODE" */ - if (!strncmp(wk_buff, "B_MODE", 6)) { - priv->reg.phy_type = D_11B_ONLY_MODE; - } else if (!strncmp(wk_buff, "G_MODE", 6)) { - priv->reg.phy_type = D_11G_ONLY_MODE; - } else { - priv->reg.phy_type = - D_11BG_COMPATIBLE_MODE; - } - break; - case 20: /* "CtsMode", "FALSE" */ - if (!strncmp(wk_buff, "TRUE", 4)) { - priv->reg.cts_mode = CTS_MODE_TRUE; - } else { - priv->reg.cts_mode = CTS_MODE_FALSE; - } - break; - case 21: /* "PhyInformationTimer", "0" */ - j = simple_strtol(wk_buff, NULL, 10); - priv->reg.phy_info_timer = (uint16_t) j; - break; - default: - break; - } - if (cur_p >= end_p) { - break; - } - cur_p++; - } - - } - release_firmware(fw_entry); - - DPRINTK(3, - "\n operation_mode = %d\n channel = %d\n ssid = %s\n tx_rate = %d\n \ - preamble = %d\n powermgt = %d\n scan_type = %d\n beacon_lost_count = %d\n rts = %d\n \ - fragment = %d\n privacy_invoked = %d\n wep_type = %d\n wep_on_off = %d\n wep_index = %d\n romfile = %s\n", - priv->reg.operation_mode, priv->reg.channel, &priv->reg.ssid.body[0], priv->reg.tx_rate, priv->reg.preamble, priv->reg.powermgt, priv->reg.scan_type, priv->reg.beacon_lost_count, priv->reg.rts, priv->reg.fragment, priv->reg.privacy_invoked, wep_type, wep_on_off, - priv->reg.wep_index, &priv->reg.rom_file[0] - ); - DPRINTK(3, - "\n phy_type = %d\n cts_mode = %d\n tx_rate = %d\n phy_info_timer = %d\n", - priv->reg.phy_type, priv->reg.cts_mode, priv->reg.tx_rate, - priv->reg.phy_info_timer); - - return (0); -} diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index c340254..d4cce78 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -807,15 +807,10 @@ static int ks79xx_upload_firmware(struct ks_wlan_private *priv, goto error_out0; } - if (request_firmware - (&fw_entry, priv->reg.rom_file, - &priv->ks_wlan_hw.sdio_card->func->dev) != 0) { - DPRINTK(1, "error request_firmware() file=%s\n", - priv->reg.rom_file); - return 1; - } - DPRINTK(4, "success request_firmware() file=%s size=%zu\n", - priv->reg.rom_file, fw_entry->size); + retval = request_firmware(&fw_entry, ROM_FILE, &priv->ks_wlan_hw.sdio_card->func->dev); + if (retval) + return retval; + length = fw_entry->size; /* Load Program */ @@ -966,6 +961,33 @@ static struct sdio_driver ks7010_sdio_driver = { extern int ks_wlan_net_start(struct net_device *dev); extern int ks_wlan_net_stop(struct net_device *dev); +static void ks7010_init_defaults(struct ks_wlan_private *priv) +{ + priv->reg.tx_rate = TX_RATE_AUTO; + priv->reg.preamble = LONG_PREAMBLE; + priv->reg.powermgt = POWMGT_ACTIVE_MODE; + priv->reg.scan_type = ACTIVE_SCAN; + priv->reg.beacon_lost_count = 20; + priv->reg.rts = 2347UL; + priv->reg.fragment = 2346UL; + priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; + priv->reg.cts_mode = CTS_MODE_FALSE; + priv->reg.rate_set.body[11] = TX_RATE_54M; + priv->reg.rate_set.body[10] = TX_RATE_48M; + priv->reg.rate_set.body[9] = TX_RATE_36M; + priv->reg.rate_set.body[8] = TX_RATE_18M; + priv->reg.rate_set.body[7] = TX_RATE_9M; + priv->reg.rate_set.body[6] = TX_RATE_24M | BASIC_RATE; + priv->reg.rate_set.body[5] = TX_RATE_12M | BASIC_RATE; + priv->reg.rate_set.body[4] = TX_RATE_6M | BASIC_RATE; + priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE; + priv->reg.rate_set.body[2] = TX_RATE_5M | BASIC_RATE; + priv->reg.rate_set.body[1] = TX_RATE_2M | BASIC_RATE; + priv->reg.rate_set.body[0] = TX_RATE_1M | BASIC_RATE; + priv->reg.tx_rate = TX_RATE_FULL_AUTO; + priv->reg.rate_set.size = 12; +} + static int ks7910_sdio_probe(struct sdio_func *func, const struct sdio_device_id *device) { @@ -1069,14 +1091,7 @@ static int ks7910_sdio_probe(struct sdio_func *func, hostif_init(priv); ks_wlan_net_start(netdev); - /* Read config file */ - ret = ks_wlan_read_config_file(priv); - if (ret) { - printk(KERN_ERR - "ks79xx: read configuration file failed !! retern code = %d\n", - ret); - goto error_free_read_buf; - } + ks7010_init_defaults(priv); /* Upload firmware */ ret = ks79xx_upload_firmware(priv, card); /* firmware load */ diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h index 987cfa7..815ecf80 100644 --- a/drivers/staging/ks7010/ks7010_sdio.h +++ b/drivers/staging/ks7010/ks7010_sdio.h @@ -142,7 +142,6 @@ struct rx_device { spinlock_t rx_dev_lock; }; #define ROM_FILE "ks7010sd.rom" -#define CFG_FILE "ks79xx.cfg" #define KS_WLAN_DRIVER_VERSION_INFO "ks7010 sdio linux 007" #endif /* _KS7010_SDIO_H */ diff --git a/drivers/staging/ks7010/ks79xx.cfg b/drivers/staging/ks7010/ks79xx.cfg deleted file mode 100644 index 0f2d24d..0000000 --- a/drivers/staging/ks7010/ks79xx.cfg +++ /dev/null @@ -1,116 +0,0 @@ -#ks79xx.cfg -#KS79xx configuration file -# - -# -#BeaconLostCount default 20 -BeaconLostCount=20 -# - -# -#Ap List Scan Type default ACTIVE_SCAN ACTIVE_SCAN or PASSIVE_SCAN -ScanType=ACTIVE_SCAN -# - -# -#Channel default 10 min 1 max 14 -Channel=10 -# - -# -#FragmentThreshold default 2346 min 256 max 2346 -FragmentThreshold=2346 -# - -# -#OperationMode default Infrastructure Pseudo-Ad-Hoc or 802.11-Ad-Hoc or Infrastructure -OperationMode=Infrastructure -# - -# -#PowerManagementMode default ACTIVE ACTIVE or SAVE1 or SAVE2 -PowerManagementMode=ACTIVE -# - -# -#RTSThreshold default 2347 min 0 max 2347 -RTSThreshold=2347 -# - -# -#SSID default "" max 32 character -SSID="default" -# - -# -#TxRate default Auto 1, 2, 5.5, 11 ex. TxRate=1,2 TxRate=11 TxRate=Auto ... -TxRate=Auto -# - -# -#Wep default OFF OFF or 64bit or 128bit -Wep=OFF -# - -# -#WepType default STRING STRING or HEX -WepType=STRING -# - -# -#WepIndex=1 -# - -# -#WepKeyValue1 -# character_wep_key:64bit key_length = 5; 128bit key_length = 13 -# hex_wep_key:64bit key_length = 10; 128bit key_length = 26 -# - -# -#WepKeyValue2 -# character_wep_key:64bit key_length = 5; 128bit key_length = 13 -# hex_wep_key:64bit key_length = 10; 128bit key_length = 26 -# - -# -#WepKeyValue3 -# character_wep_key:64bit key_length = 5; 128bit key_length = 13 -# hex_wep_key:64bit key_length = 10; 128bit key_length = 26 -# - -# -#WepKeyValue4 -# character_wep_key:64bit key_length = 5; 128bit key_length = 13 -# hex_wep_key:64bit key_length = 10; 128bit key_length = 26 -# - -# -#AuthenticationAlgorithm default OPEN_SYSTEM OPEN_SYSTEM or SHARED_KEY -AuthenticationAlgorithm=OPEN_SYSTEM -# - -# -#PREAMBLE_TYPE default LONG LONG or SHORT -PREAMBLE_TYPE=SHORT -# - -# -# PhyType default BG_MODE B_MODE, G_MODE or BG_MODE -PhyType=BG_MODE -# - -# -# CtsMode defalut FALSE TURE or FALSE -CtsMode=FALSE -# - -# -# PhyInformationTimer defalut 0 uint 100msec -PhyInformationTimer=0 -# - -# -#ROM_FILE default "ks7010sd.rom" -ROM_FILE="ks7010sd.rom" -# diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index c42d99c..019c430 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -73,7 +73,6 @@ struct ks_wlan_parameter { uint16_t phy_type; /* 11b/11g/11bg mode type */ uint16_t cts_mode; /* for 11g/11bg mode cts mode */ uint16_t phy_info_timer; /* phy information timer */ - char rom_file[256]; }; enum { -- cgit v1.1 From 30776cf921cd9033d88da56d33707515ce892a8a Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 17 Jun 2016 10:46:53 +0200 Subject: staging: ks7010: function declaration should be in a header file Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 3 --- drivers/staging/ks7010/ks_wlan.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index d4cce78..714f933 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -958,9 +958,6 @@ static struct sdio_driver ks7010_sdio_driver = { .remove = ks7910_sdio_remove, }; -extern int ks_wlan_net_start(struct net_device *dev); -extern int ks_wlan_net_stop(struct net_device *dev); - static void ks7010_init_defaults(struct ks_wlan_private *priv) { priv->reg.tx_rate = TX_RATE_AUTO; diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index 019c430..f05dc01 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -499,4 +499,7 @@ struct ks_wlan_private { uint wakeup_count; /* for detect wakeup loop */ }; +extern int ks_wlan_net_start(struct net_device *dev); +extern int ks_wlan_net_stop(struct net_device *dev); + #endif /* _KS_WLAN_H */ -- cgit v1.1 From 1c013a5ca630eba9ee532eaa77aa67ad4164c298 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 17 Jun 2016 10:46:54 +0200 Subject: staging: ks7010: collect all includes and sort them Includes probably need a driver-wide clean up, but for now let's at least group all includes from the sdio file together. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 714f933..b3c98eb 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -10,15 +10,15 @@ * published by the Free Software Foundation. */ -#include -#include +#include #include #include +#include +#include #include "ks_wlan.h" #include "ks_wlan_ioctl.h" #include "ks_hostif.h" - #include "ks7010_sdio.h" #define KS7010_FUNC_NUM 1 @@ -777,7 +777,6 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address, return rc; } -#include static int ks79xx_upload_firmware(struct ks_wlan_private *priv, struct ks_sdio_card *card) { -- cgit v1.1 From f9b5bd05a1b43de072da29649b192130411a982c Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 17 Jun 2016 10:46:55 +0200 Subject: staging: ks7010: export sdio ids So the module will be loaded automatically on card insertion. Rename the array while here. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index b3c98eb..280cbfb 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -27,11 +27,12 @@ static int reg_net = 0; -static const struct sdio_device_id if_sdio_ids[] = { +static const struct sdio_device_id ks7010_sdio_ids[] = { {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_A, SDIO_DEVICE_ID_KS_7010)}, {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_B, SDIO_DEVICE_ID_KS_7010)}, { /* all zero */ } }; +MODULE_DEVICE_TABLE(sdio, ks7010_sdio_ids); static int ks7910_sdio_probe(struct sdio_func *function, const struct sdio_device_id *device); @@ -952,7 +953,7 @@ static void ks7010_card_init(struct ks_wlan_private *priv) static struct sdio_driver ks7010_sdio_driver = { .name = "ks7910_sdio", - .id_table = if_sdio_ids, + .id_table = ks7010_sdio_ids, .probe = ks7910_sdio_probe, .remove = ks7910_sdio_remove, }; -- cgit v1.1 From c4730a92766dacc336f6740c5c1e6181334ef316 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 17 Jun 2016 10:46:56 +0200 Subject: staging: ks7010: unify naming to ks7010 No 79xx anymore, this is confusing. Add a comment saying that old versions were probably named 7910/79xx. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 28 ++++++++++++++-------------- drivers/staging/ks7010/ks7010_sdio.h | 1 + 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 280cbfb..8c2b62b 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -34,9 +34,9 @@ static const struct sdio_device_id ks7010_sdio_ids[] = { }; MODULE_DEVICE_TABLE(sdio, ks7010_sdio_ids); -static int ks7910_sdio_probe(struct sdio_func *function, +static int ks7010_sdio_probe(struct sdio_func *function, const struct sdio_device_id *device); -static void ks7910_sdio_remove(struct sdio_func *function); +static void ks7010_sdio_remove(struct sdio_func *function); static void ks7010_rw_function(struct work_struct *work); static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address, unsigned char *buffer, int length); @@ -778,7 +778,7 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address, return rc; } -static int ks79xx_upload_firmware(struct ks_wlan_private *priv, +static int ks7010_upload_firmware(struct ks_wlan_private *priv, struct ks_sdio_card *card) { unsigned int size, offset, n = 0; @@ -952,10 +952,10 @@ static void ks7010_card_init(struct ks_wlan_private *priv) } static struct sdio_driver ks7010_sdio_driver = { - .name = "ks7910_sdio", + .name = "ks7010_sdio", .id_table = ks7010_sdio_ids, - .probe = ks7910_sdio_probe, - .remove = ks7910_sdio_remove, + .probe = ks7010_sdio_probe, + .remove = ks7010_sdio_remove, }; static void ks7010_init_defaults(struct ks_wlan_private *priv) @@ -985,7 +985,7 @@ static void ks7010_init_defaults(struct ks_wlan_private *priv) priv->reg.rate_set.size = 12; } -static int ks7910_sdio_probe(struct sdio_func *func, +static int ks7010_sdio_probe(struct sdio_func *func, const struct sdio_device_id *device) { struct ks_wlan_private *priv; @@ -994,7 +994,7 @@ static int ks7910_sdio_probe(struct sdio_func *func, unsigned char rw_data; int ret; - DPRINTK(5, "ks7910_sdio_probe()\n"); + DPRINTK(5, "ks7010_sdio_probe()\n"); priv = NULL; netdev = NULL; @@ -1049,11 +1049,11 @@ static int ks7910_sdio_probe(struct sdio_func *func, /* private memory allocate */ netdev = alloc_etherdev(sizeof(*priv)); if (netdev == NULL) { - printk(KERN_ERR "ks79xx : Unable to alloc new net device\n"); + printk(KERN_ERR "ks7010 : Unable to alloc new net device\n"); goto error_release_irq; } if (dev_alloc_name(netdev, netdev->name) < 0) { - printk(KERN_ERR "ks79xx : Couldn't get name!\n"); + printk(KERN_ERR "ks7010 : Couldn't get name!\n"); goto error_free_netdev; } @@ -1091,10 +1091,10 @@ static int ks7910_sdio_probe(struct sdio_func *func, ks7010_init_defaults(priv); /* Upload firmware */ - ret = ks79xx_upload_firmware(priv, card); /* firmware load */ + ret = ks7010_upload_firmware(priv, card); /* firmware load */ if (ret) { printk(KERN_ERR - "ks79xx: firmware load failed !! retern code = %d\n", + "ks7010: firmware load failed !! retern code = %d\n", ret); goto error_free_read_buf; } @@ -1151,13 +1151,13 @@ static int ks7910_sdio_probe(struct sdio_func *func, return -ENODEV; } -static void ks7910_sdio_remove(struct sdio_func *func) +static void ks7010_sdio_remove(struct sdio_func *func) { int ret; struct ks_sdio_card *card; struct ks_wlan_private *priv; struct net_device *netdev; - DPRINTK(1, "ks7910_sdio_remove()\n"); + DPRINTK(1, "ks7010_sdio_remove()\n"); card = sdio_get_drvdata(func); diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h index 815ecf80..e71c097 100644 --- a/drivers/staging/ks7010/ks7010_sdio.h +++ b/drivers/staging/ks7010/ks7010_sdio.h @@ -19,6 +19,7 @@ /* SDIO KeyStream vendor and device */ #define SDIO_VENDOR_ID_KS_CODE_A 0x005b #define SDIO_VENDOR_ID_KS_CODE_B 0x0023 +/* Older sources suggest earlier versions were named 7910 or 79xx */ #define SDIO_DEVICE_ID_KS_7010 0x7910 /* Read Status Register */ -- cgit v1.1 From 4c0d46d2cf62c9cd199cc3323d0b670e7b755650 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 17 Jun 2016 10:46:57 +0200 Subject: staging: ks7010: sdio: remove forward declarations Move read/write functions to the top and driver struct to the end, so we can remove all forward declarations. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 100 ++++++++++++++++------------------- 1 file changed, 46 insertions(+), 54 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 8c2b62b..16b9d76 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -34,14 +34,6 @@ static const struct sdio_device_id ks7010_sdio_ids[] = { }; MODULE_DEVICE_TABLE(sdio, ks7010_sdio_ids); -static int ks7010_sdio_probe(struct sdio_func *function, - const struct sdio_device_id *device); -static void ks7010_sdio_remove(struct sdio_func *function); -static void ks7010_rw_function(struct work_struct *work); -static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address, - unsigned char *buffer, int length); -static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address, - unsigned char *buffer, int length); /* macro */ #define inc_txqhead(priv) \ @@ -58,6 +50,45 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address, #define cnt_rxqbody(priv) \ (((priv->rx_dev.qtail + RX_DEVICE_BUFF_SIZE) - (priv->rx_dev.qhead)) % RX_DEVICE_BUFF_SIZE ) +static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address, + unsigned char *buffer, int length) +{ + struct ks_sdio_card *card; + int rc; + + card = priv->ks_wlan_hw.sdio_card; + + if (length == 1) /* CMD52 */ + *buffer = sdio_readb(card->func, address, &rc); + else /* CMD53 multi-block transfer */ + rc = sdio_memcpy_fromio(card->func, buffer, address, length); + + if (rc != 0) + DPRINTK(1, "sdio error=%d size=%d\n", rc, length); + + return rc; +} + +static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address, + unsigned char *buffer, int length) +{ + struct ks_sdio_card *card; + int rc; + + card = priv->ks_wlan_hw.sdio_card; + + if (length == 1) /* CMD52 */ + sdio_writeb(card->func, *buffer, (unsigned int)address, &rc); + else /* CMD53 */ + rc = sdio_memcpy_toio(card->func, (unsigned int)address, buffer, + length); + + if (rc != 0) + DPRINTK(1, "sdio error=%d size=%d\n", rc, length); + + return rc; +} + void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) { unsigned char rw_data; @@ -230,45 +261,6 @@ int ks_wlan_hw_power_save(struct ks_wlan_private *priv) return 0; } -static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned int address, - unsigned char *buffer, int length) -{ - struct ks_sdio_card *card; - int rc; - - card = priv->ks_wlan_hw.sdio_card; - - if (length == 1) /* CMD52 */ - *buffer = sdio_readb(card->func, address, &rc); - else /* CMD53 multi-block transfer */ - rc = sdio_memcpy_fromio(card->func, buffer, address, length); - - if (rc != 0) - DPRINTK(1, "sdio error=%d size=%d\n", rc, length); - - return rc; -} - -static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address, - unsigned char *buffer, int length) -{ - struct ks_sdio_card *card; - int rc; - - card = priv->ks_wlan_hw.sdio_card; - - if (length == 1) /* CMD52 */ - sdio_writeb(card->func, *buffer, (unsigned int)address, &rc); - else /* CMD53 */ - rc = sdio_memcpy_toio(card->func, (unsigned int)address, buffer, - length); - - if (rc != 0) - DPRINTK(1, "sdio error=%d size=%d\n", rc, length); - - return rc; -} - static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p, unsigned long size, void (*complete_handler) (void *arg1, void *arg2), @@ -951,13 +943,6 @@ static void ks7010_card_init(struct ks_wlan_private *priv) } } -static struct sdio_driver ks7010_sdio_driver = { - .name = "ks7010_sdio", - .id_table = ks7010_sdio_ids, - .probe = ks7010_sdio_probe, - .remove = ks7010_sdio_remove, -}; - static void ks7010_init_defaults(struct ks_wlan_private *priv) { priv->reg.tx_rate = TX_RATE_AUTO; @@ -1239,6 +1224,13 @@ static void ks7010_sdio_remove(struct sdio_func *func) return; } +static struct sdio_driver ks7010_sdio_driver = { + .name = "ks7010_sdio", + .id_table = ks7010_sdio_ids, + .probe = ks7010_sdio_probe, + .remove = ks7010_sdio_remove, +}; + module_driver(ks7010_sdio_driver, sdio_register_driver, sdio_unregister_driver); MODULE_AUTHOR("Sang Engineering, Qi-Hardware, KeyStream"); MODULE_DESCRIPTION("Driver for KeyStream KS7010 based SDIO cards"); -- cgit v1.1 From 3fb54d7590a4a4d4cf99279c5c228bea788b9628 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 17 Jun 2016 10:46:58 +0200 Subject: staging: ks7010: bail out when registering netdevice fails There is no need to continue then. Also, this enables us to remove an ugly static variable. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 16b9d76..c3035b8 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -25,8 +25,6 @@ #define KS7010_IO_BLOCK_SIZE 512 #define KS7010_MAX_CLOCK 25000000 -static int reg_net = 0; - static const struct sdio_device_id ks7010_sdio_ids[] = { {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_A, SDIO_DEVICE_ID_KS_7010)}, {SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_B, SDIO_DEVICE_ID_KS_7010)}, @@ -936,8 +934,6 @@ static void ks7010_card_init(struct ks_wlan_private *priv) if (priv->dev_state >= DEVICE_STATE_PREINIT) { DPRINTK(1, "DEVICE READY!!\n"); priv->dev_state = DEVICE_STATE_READY; - reg_net = register_netdev(priv->net_dev); - DPRINTK(3, "register_netdev=%d\n", reg_net); } else { DPRINTK(1, "dev_state=%d\n", priv->dev_state); } @@ -1115,6 +1111,10 @@ static int ks7010_sdio_probe(struct sdio_func *func, INIT_DELAYED_WORK(&priv->ks_wlan_hw.rw_wq, ks7010_rw_function); ks7010_card_init(priv); + ret = register_netdev(priv->net_dev); + if (ret) + goto error_free_read_buf; + return 0; error_free_read_buf: @@ -1196,9 +1196,7 @@ static void ks7010_sdio_remove(struct sdio_func *func) hostif_exit(priv); DPRINTK(1, "hostif_exit\n"); - if (!reg_net) - unregister_netdev(netdev); - DPRINTK(1, "unregister_netdev\n"); + unregister_netdev(netdev); trx_device_exit(priv); if (priv->ks_wlan_hw.read_buf) { -- cgit v1.1 From 6634cff1b545b8a6353e347c7871302353e5b7ca Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 17 Jun 2016 10:46:59 +0200 Subject: staging: ks7010: report interface as wlan not eth Until we switch to cfg80211 (if ever), we must do this manually. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index c3035b8..b7337fd 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -1033,7 +1033,7 @@ static int ks7010_sdio_probe(struct sdio_func *func, printk(KERN_ERR "ks7010 : Unable to alloc new net device\n"); goto error_release_irq; } - if (dev_alloc_name(netdev, netdev->name) < 0) { + if (dev_alloc_name(netdev, "wlan%d") < 0) { printk(KERN_ERR "ks7010 : Couldn't get name!\n"); goto error_free_netdev; } -- cgit v1.1 From 516a4f04a39712cdb0d3cee263158853603376aa Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Fri, 17 Jun 2016 10:47:00 +0200 Subject: staging: ks7010: drop private handler for driver version We are upstream now, we don't need seperate driver versioning. Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.h | 1 - drivers/staging/ks7010/ks_wlan_ioctl.h | 2 +- drivers/staging/ks7010/ks_wlan_net.c | 15 +-------------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h index e71c097..c72064b 100644 --- a/drivers/staging/ks7010/ks7010_sdio.h +++ b/drivers/staging/ks7010/ks7010_sdio.h @@ -143,6 +143,5 @@ struct rx_device { spinlock_t rx_dev_lock; }; #define ROM_FILE "ks7010sd.rom" -#define KS_WLAN_DRIVER_VERSION_INFO "ks7010 sdio linux 007" #endif /* _KS7010_SDIO_H */ diff --git a/drivers/staging/ks7010/ks_wlan_ioctl.h b/drivers/staging/ks7010/ks_wlan_ioctl.h index f1fb2dd..49369e4 100644 --- a/drivers/staging/ks7010/ks_wlan_ioctl.h +++ b/drivers/staging/ks7010/ks_wlan_ioctl.h @@ -16,7 +16,7 @@ /* The low order bit identify a SET (0) or a GET (1) ioctl. */ /* SIOCIWFIRSTPRIV+0 */ -#define KS_WLAN_GET_DRIVER_VERSION SIOCIWFIRSTPRIV+1 +/* former KS_WLAN_GET_DRIVER_VERSION SIOCIWFIRSTPRIV+1 */ /* SIOCIWFIRSTPRIV+2 */ #define KS_WLAN_GET_FIRM_VERSION SIOCIWFIRSTPRIV+3 #ifdef WPS diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 8ef0f11..26dbb75 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2199,17 +2199,6 @@ static int ks_wlan_set_mlme(struct net_device *dev, } /*------------------------------------------------------------------*/ -/* Private handler : get driver version */ -static int ks_wlan_get_driver_version(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *dwrq, char *extra) -{ - strcpy(extra, KS_WLAN_DRIVER_VERSION_INFO); - dwrq->length = strlen(KS_WLAN_DRIVER_VERSION_INFO) + 1; - return 0; -} - -/*------------------------------------------------------------------*/ /* Private handler : get firemware version */ static int ks_wlan_get_firmware_version(struct net_device *dev, struct iw_request_info *info, @@ -3128,8 +3117,6 @@ static int ks_wlan_hostt(struct net_device *dev, struct iw_request_info *info, static const struct iw_priv_args ks_wlan_private_args[] = { /*{ cmd, set_args, get_args, name[16] } */ - {KS_WLAN_GET_DRIVER_VERSION, IW_PRIV_TYPE_NONE, - IW_PRIV_TYPE_CHAR | (128 + 1), "GetDriverVer"}, {KS_WLAN_GET_FIRM_VERSION, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128 + 1), "GetFirmwareVer"}, #ifdef WPS @@ -3258,7 +3245,7 @@ static const iw_handler ks_wlan_handler[] = { /* private_handler */ static const iw_handler ks_wlan_private_handler[] = { (iw_handler) NULL, /* 0 */ - (iw_handler) ks_wlan_get_driver_version, /* 1 KS_WLAN_GET_DRIVER_VERSION */ + (iw_handler) NULL, /* 1, used to be: KS_WLAN_GET_DRIVER_VERSION */ (iw_handler) NULL, /* 2 */ (iw_handler) ks_wlan_get_firmware_version, /* 3 KS_WLAN_GET_FIRM_VERSION */ #ifdef WPS -- cgit v1.1 From 453e102db531ac1ffa55f3e03c4907c063125859 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 14 Jun 2016 14:17:02 +0300 Subject: staging: ks7010: remove bogus NULL checks enc->rx_seq[] and enc->key[] are arrays, not pointers and they can't be NULL. Let's remove these NULL checks. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 26dbb75..1e21eb1 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1910,11 +1910,8 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, priv->wpa.txkey = index; commit |= SME_WEP_INDEX; } else if (enc->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) { - if (enc->rx_seq) - memcpy(&priv->wpa.key[index].rx_seq[0], - enc->rx_seq, IW_ENCODE_SEQ_MAX_SIZE); - else - return -EINVAL; + memcpy(&priv->wpa.key[index].rx_seq[0], + enc->rx_seq, IW_ENCODE_SEQ_MAX_SIZE); } memcpy(&priv->wpa.key[index].addr.sa_data[0], @@ -1935,7 +1932,7 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, priv->reg.privacy_invoked = 0x01; commit |= SME_WEP_FLAG; } - if (enc->key && enc->key_len) { + if (enc->key_len) { memcpy(&priv->wpa.key[index].key_val[0], &enc->key[0], enc->key_len); priv->wpa.key[index].key_len = enc->key_len; @@ -1947,7 +1944,7 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, priv->reg.privacy_invoked = 0x01; commit |= SME_WEP_FLAG; } - if (enc->key && enc->key_len == 32) { + if (enc->key_len == 32) { memcpy(&priv->wpa.key[index].key_val[0], &enc->key[0], enc->key_len - 16); priv->wpa.key[index].key_len = -- cgit v1.1 From 2fe9262e7e024b089d6f1962fe1fa06b383d2991 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Wed, 4 May 2016 04:42:40 +0100 Subject: staging: rtl8192u: check return value of read_nic_word_E The call of read_nic_word_E may fail, therefore its return value must be checked and propagated in the case of error. Signed-off-by: Salah Triki Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8180_93cx6.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8180_93cx6.c b/drivers/staging/rtl8192u/r8180_93cx6.c index 97d9b3f..2c53132 100644 --- a/drivers/staging/rtl8192u/r8180_93cx6.c +++ b/drivers/staging/rtl8192u/r8180_93cx6.c @@ -23,8 +23,11 @@ static void eprom_cs(struct net_device *dev, short bit) { u8 cmdreg; + int err; - read_nic_byte_E(dev, EPROM_CMD, &cmdreg); + err = read_nic_byte_E(dev, EPROM_CMD, &cmdreg); + if (err) + return; if (bit) /* enable EPROM */ write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_CS_BIT); @@ -40,8 +43,11 @@ static void eprom_cs(struct net_device *dev, short bit) static void eprom_ck_cycle(struct net_device *dev) { u8 cmdreg; + int err; - read_nic_byte_E(dev, EPROM_CMD, &cmdreg); + err = read_nic_byte_E(dev, EPROM_CMD, &cmdreg); + if (err) + return; write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_CK_BIT); force_pci_posting(dev); udelay(EPROM_DELAY); @@ -56,8 +62,11 @@ static void eprom_ck_cycle(struct net_device *dev) static void eprom_w(struct net_device *dev, short bit) { u8 cmdreg; + int err; - read_nic_byte_E(dev, EPROM_CMD, &cmdreg); + err = read_nic_byte_E(dev, EPROM_CMD, &cmdreg); + if (err) + return; if (bit) write_nic_byte_E(dev, EPROM_CMD, cmdreg | EPROM_W_BIT); else @@ -71,8 +80,12 @@ static void eprom_w(struct net_device *dev, short bit) static short eprom_r(struct net_device *dev) { u8 bit; + int err; + + err = read_nic_byte_E(dev, EPROM_CMD, &bit); + if (err) + return err; - read_nic_byte_E(dev, EPROM_CMD, &bit); udelay(EPROM_DELAY); if (bit & EPROM_R_BIT) -- cgit v1.1 From 6ceb65b83771ec860478061479ba54b7093c2ee2 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Wed, 4 May 2016 04:42:41 +0100 Subject: staging: rtl8192u: propagate errors in eprom_read Propagate error from eprom_r and change the return type of eprom_read from u32 to int. Signed-off-by: Salah Triki Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8180_93cx6.c | 9 +++++++-- drivers/staging/rtl8192u/r8180_93cx6.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/r8180_93cx6.c b/drivers/staging/rtl8192u/r8180_93cx6.c index 2c53132..f35defc 100644 --- a/drivers/staging/rtl8192u/r8180_93cx6.c +++ b/drivers/staging/rtl8192u/r8180_93cx6.c @@ -106,7 +106,7 @@ static void eprom_send_bits_string(struct net_device *dev, short b[], int len) } -u32 eprom_read(struct net_device *dev, u32 addr) +int eprom_read(struct net_device *dev, u32 addr) { struct r8192_priv *priv = ieee80211_priv(dev); short read_cmd[] = {1, 1, 0}; @@ -114,6 +114,7 @@ u32 eprom_read(struct net_device *dev, u32 addr) int i; int addr_len; u32 ret; + int err; ret = 0; /* enable EPROM programming */ @@ -157,7 +158,11 @@ u32 eprom_read(struct net_device *dev, u32 addr) * and reading data. (eeprom outs a dummy 0) */ eprom_ck_cycle(dev); - ret |= (eprom_r(dev)<<(15-i)); + err = eprom_r(dev); + if (err < 0) + return err; + + ret |= err<<(15-i); } eprom_cs(dev, 0); diff --git a/drivers/staging/rtl8192u/r8180_93cx6.h b/drivers/staging/rtl8192u/r8180_93cx6.h index b840348..9cf7f58 100644 --- a/drivers/staging/rtl8192u/r8180_93cx6.h +++ b/drivers/staging/rtl8192u/r8180_93cx6.h @@ -40,4 +40,4 @@ #define EPROM_TXPW1 0x3d -u32 eprom_read(struct net_device *dev, u32 addr); /* reads a 16 bits word */ +int eprom_read(struct net_device *dev, u32 addr); /* reads a 16 bits word */ -- cgit v1.1 From 16feab644fd18726e4a1629334d5630d583865c4 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Wed, 4 May 2016 04:42:42 +0100 Subject: staging: rtl8192u: check return value eprom_read The call of eprom_read may fail, therefore its return value must be checked Signed-off-by: Salah Triki Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 112 ++++++++++++++++++++++----------- 1 file changed, 76 insertions(+), 36 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 8c1d737..950107c 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -2429,9 +2429,13 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); u16 tmpValue = 0; int i; + int ret; RT_TRACE(COMP_EPROM, "===========>%s()\n", __func__); - wEPROM_ID = eprom_read(dev, 0); /* first read EEPROM ID out; */ + ret = eprom_read(dev, 0); /* first read EEPROM ID out; */ + if (ret < 0) + return; + wEPROM_ID = (u16)ret; RT_TRACE(COMP_EPROM, "EEPROM ID is 0x%x\n", wEPROM_ID); if (wEPROM_ID != RTL8190_EEPROM_ID) @@ -2443,13 +2447,25 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) if (bLoad_From_EEPOM) { tmpValue = eprom_read(dev, EEPROM_VID >> 1); + ret = eprom_read(dev, EEPROM_VID >> 1); + if (ret < 0) + return; + tmpValue = (u16)ret; priv->eeprom_vid = endian_swap(&tmpValue); - priv->eeprom_pid = eprom_read(dev, EEPROM_PID >> 1); - tmpValue = eprom_read(dev, EEPROM_ChannelPlan >> 1); + ret = eprom_read(dev, EEPROM_PID >> 1); + if (ret < 0) + return; + priv->eeprom_pid = (u16)ret; + ret = eprom_read(dev, EEPROM_ChannelPlan >> 1); + if (ret < 0) + return; + tmpValue = (u16)ret; priv->eeprom_ChannelPlan = (tmpValue & 0xff00) >> 8; priv->btxpowerdata_readfromEEPORM = true; - priv->eeprom_CustomerID = - eprom_read(dev, (EEPROM_Customer_ID >> 1)) >> 8; + ret = eprom_read(dev, (EEPROM_Customer_ID >> 1)) >> 8; + if (ret < 0) + return; + priv->eeprom_CustomerID = (u16)ret; } else { priv->eeprom_vid = 0; priv->eeprom_pid = 0; @@ -2467,10 +2483,10 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) int i; for (i = 0; i < 6; i += 2) { - u16 tmp = 0; - - tmp = eprom_read(dev, (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1)); - *(u16 *)(&dev->dev_addr[i]) = tmp; + ret = eprom_read(dev, (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1)); + if (ret < 0) + return; + *(u16 *)(&dev->dev_addr[i]) = (u16)ret; } } else { memcpy(dev->dev_addr, bMac_Tmp_Addr, 6); @@ -2482,52 +2498,72 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) if (priv->card_8192_version == (u8)VERSION_819xU_A) { /* read Tx power gain offset of legacy OFDM to HT rate */ - if (bLoad_From_EEPOM) - priv->EEPROMTxPowerDiff = (eprom_read(dev, (EEPROM_TxPowerDiff >> 1)) & 0xff00) >> 8; - else + if (bLoad_From_EEPOM) { + ret = eprom_read(dev, (EEPROM_TxPowerDiff >> 1)); + if (ret < 0) + return; + priv->EEPROMTxPowerDiff = ((u16)ret & 0xff00) >> 8; + } else priv->EEPROMTxPowerDiff = EEPROM_Default_TxPower; RT_TRACE(COMP_EPROM, "TxPowerDiff:%d\n", priv->EEPROMTxPowerDiff); /* read ThermalMeter from EEPROM */ - if (bLoad_From_EEPOM) - priv->EEPROMThermalMeter = (u8)(eprom_read(dev, (EEPROM_ThermalMeter >> 1)) & 0x00ff); - else + if (bLoad_From_EEPOM) { + ret = eprom_read(dev, (EEPROM_ThermalMeter >> 1)); + if (ret < 0) + return; + priv->EEPROMThermalMeter = (u8)((u16)ret & 0x00ff); + } else priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; RT_TRACE(COMP_EPROM, "ThermalMeter:%d\n", priv->EEPROMThermalMeter); /* for tx power track */ priv->TSSI_13dBm = priv->EEPROMThermalMeter * 100; /* read antenna tx power offset of B/C/D to A from EEPROM */ - if (bLoad_From_EEPOM) - priv->EEPROMPwDiff = (eprom_read(dev, (EEPROM_PwDiff >> 1)) & 0x0f00) >> 8; - else + if (bLoad_From_EEPOM) { + ret = eprom_read(dev, (EEPROM_PwDiff >> 1)); + if (ret < 0) + return; + priv->EEPROMPwDiff = ((u16)ret & 0x0f00) >> 8; + } else priv->EEPROMPwDiff = EEPROM_Default_PwDiff; RT_TRACE(COMP_EPROM, "TxPwDiff:%d\n", priv->EEPROMPwDiff); /* Read CrystalCap from EEPROM */ - if (bLoad_From_EEPOM) - priv->EEPROMCrystalCap = (eprom_read(dev, (EEPROM_CrystalCap >> 1)) & 0x0f); - else + if (bLoad_From_EEPOM) { + ret = eprom_read(dev, (EEPROM_CrystalCap >> 1)); + if (ret < 0) + return; + priv->EEPROMCrystalCap = (u16)ret & 0x0f; + } else priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap; RT_TRACE(COMP_EPROM, "CrystalCap = %d\n", priv->EEPROMCrystalCap); /* get per-channel Tx power level */ - if (bLoad_From_EEPOM) - priv->EEPROM_Def_Ver = (eprom_read(dev, (EEPROM_TxPwIndex_Ver >> 1)) & 0xff00) >> 8; - else + if (bLoad_From_EEPOM) { + ret = eprom_read(dev, (EEPROM_TxPwIndex_Ver >> 1)); + if (ret < 0) + return; + priv->EEPROM_Def_Ver = ((u16)ret & 0xff00) >> 8; + } else priv->EEPROM_Def_Ver = 1; RT_TRACE(COMP_EPROM, "EEPROM_DEF_VER:%d\n", priv->EEPROM_Def_Ver); if (priv->EEPROM_Def_Ver == 0) { /* old eeprom definition */ int i; - if (bLoad_From_EEPOM) - priv->EEPROMTxPowerLevelCCK = (eprom_read(dev, (EEPROM_TxPwIndex_CCK >> 1)) & 0xff) >> 8; - else + if (bLoad_From_EEPOM) { + ret = eprom_read(dev, (EEPROM_TxPwIndex_CCK >> 1)); + if (ret < 0) + return; + priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff) >> 8; + } else priv->EEPROMTxPowerLevelCCK = 0x10; RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n", priv->EEPROMTxPowerLevelCCK); for (i = 0; i < 3; i++) { if (bLoad_From_EEPOM) { - tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G + i) >> 1); + ret = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G + i) >> 1); + if ( ret < 0) + return; if (((EEPROM_TxPwIndex_OFDM_24G + i) % 2) == 0) - tmpValue = tmpValue & 0x00ff; + tmpValue = (u16)ret & 0x00ff; else - tmpValue = (tmpValue & 0xff00) >> 8; + tmpValue = ((u16)ret & 0xff00) >> 8; } else { tmpValue = 0x10; } @@ -2536,17 +2572,21 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) } } else if (priv->EEPROM_Def_Ver == 1) { if (bLoad_From_EEPOM) { - tmpValue = eprom_read(dev, - EEPROM_TxPwIndex_CCK_V1 >> 1); - tmpValue = (tmpValue & 0xff00) >> 8; + ret = eprom_read(dev, EEPROM_TxPwIndex_CCK_V1 >> 1); + if (ret < 0) + return; + tmpValue = ((u16)ret & 0xff00) >> 8; } else { tmpValue = 0x10; } priv->EEPROMTxPowerLevelCCK_V1[0] = (u8)tmpValue; - if (bLoad_From_EEPOM) - tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_CCK_V1 + 2) >> 1); - else + if (bLoad_From_EEPOM) { + ret = eprom_read(dev, (EEPROM_TxPwIndex_CCK_V1 + 2) >> 1); + if (ret < 0) + return; + tmpValue = (u16)ret; + } else tmpValue = 0x1010; *((u16 *)(&priv->EEPROMTxPowerLevelCCK_V1[1])) = tmpValue; if (bLoad_From_EEPOM) -- cgit v1.1 From eafe8261c1f82aa9b7da9fc6f6a4ba624ea708b9 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Wed, 4 May 2016 04:42:43 +0100 Subject: staging: rtl8192u: propagate errors in rtl8192_read_eeprom_info Propagate error from eprom_read and change the return type of rtl8192_read_eeprom_info from void to int. Signed-off-by: Salah Triki Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 950107c..89b6372 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -2421,7 +2421,7 @@ static inline u16 endian_swap(u16 *data) return *data; } -static void rtl8192_read_eeprom_info(struct net_device *dev) +static int rtl8192_read_eeprom_info(struct net_device *dev) { u16 wEPROM_ID = 0; u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x02}; @@ -2434,7 +2434,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) RT_TRACE(COMP_EPROM, "===========>%s()\n", __func__); ret = eprom_read(dev, 0); /* first read EEPROM ID out; */ if (ret < 0) - return; + return ret; wEPROM_ID = (u16)ret; RT_TRACE(COMP_EPROM, "EEPROM ID is 0x%x\n", wEPROM_ID); @@ -2449,22 +2449,22 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) tmpValue = eprom_read(dev, EEPROM_VID >> 1); ret = eprom_read(dev, EEPROM_VID >> 1); if (ret < 0) - return; + return ret; tmpValue = (u16)ret; priv->eeprom_vid = endian_swap(&tmpValue); ret = eprom_read(dev, EEPROM_PID >> 1); if (ret < 0) - return; + return ret; priv->eeprom_pid = (u16)ret; ret = eprom_read(dev, EEPROM_ChannelPlan >> 1); if (ret < 0) - return; + return ret; tmpValue = (u16)ret; priv->eeprom_ChannelPlan = (tmpValue & 0xff00) >> 8; priv->btxpowerdata_readfromEEPORM = true; ret = eprom_read(dev, (EEPROM_Customer_ID >> 1)) >> 8; if (ret < 0) - return; + return ret; priv->eeprom_CustomerID = (u16)ret; } else { priv->eeprom_vid = 0; @@ -2485,7 +2485,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) for (i = 0; i < 6; i += 2) { ret = eprom_read(dev, (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1)); if (ret < 0) - return; + return ret; *(u16 *)(&dev->dev_addr[i]) = (u16)ret; } } else { @@ -2501,7 +2501,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) if (bLoad_From_EEPOM) { ret = eprom_read(dev, (EEPROM_TxPowerDiff >> 1)); if (ret < 0) - return; + return ret; priv->EEPROMTxPowerDiff = ((u16)ret & 0xff00) >> 8; } else priv->EEPROMTxPowerDiff = EEPROM_Default_TxPower; @@ -2510,7 +2510,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) if (bLoad_From_EEPOM) { ret = eprom_read(dev, (EEPROM_ThermalMeter >> 1)); if (ret < 0) - return; + return ret; priv->EEPROMThermalMeter = (u8)((u16)ret & 0x00ff); } else priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; @@ -2521,7 +2521,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) if (bLoad_From_EEPOM) { ret = eprom_read(dev, (EEPROM_PwDiff >> 1)); if (ret < 0) - return; + return ret; priv->EEPROMPwDiff = ((u16)ret & 0x0f00) >> 8; } else priv->EEPROMPwDiff = EEPROM_Default_PwDiff; @@ -2530,7 +2530,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) if (bLoad_From_EEPOM) { ret = eprom_read(dev, (EEPROM_CrystalCap >> 1)); if (ret < 0) - return; + return ret; priv->EEPROMCrystalCap = (u16)ret & 0x0f; } else priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap; @@ -2539,7 +2539,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) if (bLoad_From_EEPOM) { ret = eprom_read(dev, (EEPROM_TxPwIndex_Ver >> 1)); if (ret < 0) - return; + return ret; priv->EEPROM_Def_Ver = ((u16)ret & 0xff00) >> 8; } else priv->EEPROM_Def_Ver = 1; @@ -2550,7 +2550,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) if (bLoad_From_EEPOM) { ret = eprom_read(dev, (EEPROM_TxPwIndex_CCK >> 1)); if (ret < 0) - return; + return ret; priv->EEPROMTxPowerLevelCCK = ((u16)ret & 0xff) >> 8; } else priv->EEPROMTxPowerLevelCCK = 0x10; @@ -2559,7 +2559,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) if (bLoad_From_EEPOM) { ret = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G + i) >> 1); if ( ret < 0) - return; + return ret; if (((EEPROM_TxPwIndex_OFDM_24G + i) % 2) == 0) tmpValue = (u16)ret & 0x00ff; else @@ -2574,7 +2574,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) if (bLoad_From_EEPOM) { ret = eprom_read(dev, EEPROM_TxPwIndex_CCK_V1 >> 1); if (ret < 0) - return; + return ret; tmpValue = ((u16)ret & 0xff00) >> 8; } else { tmpValue = 0x10; @@ -2584,7 +2584,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) if (bLoad_From_EEPOM) { ret = eprom_read(dev, (EEPROM_TxPwIndex_CCK_V1 + 2) >> 1); if (ret < 0) - return; + return ret; tmpValue = (u16)ret; } else tmpValue = 0x1010; @@ -2684,6 +2684,8 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) init_rate_adaptive(dev); RT_TRACE(COMP_EPROM, "<===========%s()\n", __func__); + + return 0; } static short rtl8192_get_channel_map(struct net_device *dev) -- cgit v1.1 From 4dc2abb852ca447ee5f6836ed410676ee0447c33 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Wed, 4 May 2016 04:42:44 +0100 Subject: staging: rtl8192u: check return value of rtl8192_read_eeprom_info The call of rtl8192_read_eeprom_info may fail, therefore its return value must be checked and propagated in the case of error Signed-off-by: Salah Triki Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 89b6372..74cf9e7 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -2706,6 +2706,7 @@ static short rtl8192_get_channel_map(struct net_device *dev) static short rtl8192_init(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); + int err; memset(&(priv->stats), 0, sizeof(struct Stats)); memset(priv->txqueue_to_outpipemap, 0, 9); @@ -2727,7 +2728,14 @@ static short rtl8192_init(struct net_device *dev) rtl8192_init_priv_lock(priv); rtl8192_init_priv_task(dev); rtl8192_get_eeprom_size(dev); - rtl8192_read_eeprom_info(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); init_hal_dm(dev); setup_timer(&priv->watch_dog_timer, watch_dog_timer_callback, -- cgit v1.1 From ba15f657cec028ac375c5ca3f901719b46a55cbd Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Wed, 4 May 2016 04:42:45 +0100 Subject: staging: rtl8192u: propagate errors in write_nic_byte Propagate errors from kzalloc and usb_control_msg and change the return type of write_nic_byte from void to int. Signed-off-by: Salah Triki Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 2 +- drivers/staging/rtl8192u/r8192U_core.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index ee1c722..da9b92b 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -1129,7 +1129,7 @@ int read_nic_byte(struct net_device *dev, int x, u8 *data); int read_nic_byte_E(struct net_device *dev, int x, u8 *data); int read_nic_dword(struct net_device *dev, int x, u32 *data); int read_nic_word(struct net_device *dev, int x, u16 *data); -void write_nic_byte(struct net_device *dev, int x, u8 y); +int write_nic_byte(struct net_device *dev, int x, u8 y); void write_nic_byte_E(struct net_device *dev, int x, u8 y); void write_nic_word(struct net_device *dev, int x, u16 y); void write_nic_dword(struct net_device *dev, int x, u32 y); diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 74cf9e7..30c87c2 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -299,7 +299,7 @@ int read_nic_byte_E(struct net_device *dev, int indx, u8 *data) } /* as 92U has extend page from 4 to 16, so modify functions below. */ -void write_nic_byte(struct net_device *dev, int indx, u8 data) +int write_nic_byte(struct net_device *dev, int indx, u8 data) { int status; @@ -308,7 +308,7 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) u8 *usbdata = kzalloc(sizeof(data), GFP_KERNEL); if (!usbdata) - return; + return -ENOMEM; *usbdata = data; status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -317,8 +317,12 @@ void write_nic_byte(struct net_device *dev, int indx, u8 data) usbdata, 1, HZ / 2); kfree(usbdata); - if (status < 0) + if (status < 0) { netdev_err(dev, "write_nic_byte TimeOut! status: %d\n", status); + return status; + } + + return 0; } -- cgit v1.1 From 6ae4e4b3028b277ab9bcf776bcbe4db8681af317 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Wed, 4 May 2016 04:42:46 +0100 Subject: staging: rtl8192u: propagate errors in write_nic_byte_E Propagate errors from kzalloc and usb_control_msg and change the return type of write_nic_byte_E from void to int. Signed-off-by: Salah Triki Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 2 +- drivers/staging/rtl8192u/r8192U_core.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index da9b92b..e0abcf5 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -1130,7 +1130,7 @@ int read_nic_byte_E(struct net_device *dev, int x, u8 *data); int read_nic_dword(struct net_device *dev, int x, u32 *data); int read_nic_word(struct net_device *dev, int x, u16 *data); int write_nic_byte(struct net_device *dev, int x, u8 y); -void write_nic_byte_E(struct net_device *dev, int x, u8 y); +int write_nic_byte_E(struct net_device *dev, int x, u8 y); void write_nic_word(struct net_device *dev, int x, u16 y); void write_nic_dword(struct net_device *dev, int x, u32 y); void force_pci_posting(struct net_device *dev); diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 30c87c2..675e898 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -253,7 +253,7 @@ u32 read_cam(struct net_device *dev, u8 addr) return data; } -void write_nic_byte_E(struct net_device *dev, int indx, u8 data) +int write_nic_byte_E(struct net_device *dev, int indx, u8 data) { int status; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); @@ -261,7 +261,7 @@ void write_nic_byte_E(struct net_device *dev, int indx, u8 data) u8 *usbdata = kzalloc(sizeof(data), GFP_KERNEL); if (!usbdata) - return; + return -ENOMEM; *usbdata = data; status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -269,9 +269,12 @@ void write_nic_byte_E(struct net_device *dev, int indx, u8 data) indx | 0xfe00, 0, usbdata, 1, HZ / 2); kfree(usbdata); - if (status < 0) + if (status < 0){ netdev_err(dev, "write_nic_byte_E TimeOut! status: %d\n", status); + return status; + } + return 0; } int read_nic_byte_E(struct net_device *dev, int indx, u8 *data) -- cgit v1.1 From 28d653d7d17e774afa375b08fb55c4c0e22795ea Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Wed, 4 May 2016 04:42:47 +0100 Subject: staging: rtl8192u: propagate errors in write_nic_word Propagate errors from kzalloc and usb_control_msg and change the return type of write_nic_word from void to int. Signed-off-by: Salah Triki Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 2 +- drivers/staging/rtl8192u/r8192U_core.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index e0abcf5..27f9aa5 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -1131,7 +1131,7 @@ int read_nic_dword(struct net_device *dev, int x, u32 *data); int read_nic_word(struct net_device *dev, int x, u16 *data); int write_nic_byte(struct net_device *dev, int x, u8 y); int write_nic_byte_E(struct net_device *dev, int x, u8 y); -void write_nic_word(struct net_device *dev, int x, u16 y); +int write_nic_word(struct net_device *dev, int x, u16 y); void write_nic_dword(struct net_device *dev, int x, u32 y); void force_pci_posting(struct net_device *dev); diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 675e898..10eeb1c 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -329,7 +329,7 @@ int write_nic_byte(struct net_device *dev, int indx, u8 data) } -void write_nic_word(struct net_device *dev, int indx, u16 data) +int write_nic_word(struct net_device *dev, int indx, u16 data) { int status; @@ -338,7 +338,7 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) u16 *usbdata = kzalloc(sizeof(data), GFP_KERNEL); if (!usbdata) - return; + return -ENOMEM; *usbdata = data; status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -347,8 +347,12 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) usbdata, 2, HZ / 2); kfree(usbdata); - if (status < 0) + if (status < 0) { netdev_err(dev, "write_nic_word TimeOut! status: %d\n", status); + return status; + } + + return 0; } -- cgit v1.1 From ec06d48f2443a681ff02d353bd188002d0df18f9 Mon Sep 17 00:00:00 2001 From: Salah Triki Date: Wed, 4 May 2016 04:42:48 +0100 Subject: staging: rtl8192u: propagate errors in write_nic_dword Propagate errors from kzalloc and usb_control_msg and change the return type of write_nic_dword from void to int. Signed-off-by: Salah Triki Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 2 +- drivers/staging/rtl8192u/r8192U_core.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 27f9aa5..eb0c351 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -1132,7 +1132,7 @@ int read_nic_word(struct net_device *dev, int x, u16 *data); int write_nic_byte(struct net_device *dev, int x, u8 y); int write_nic_byte_E(struct net_device *dev, int x, u8 y); int write_nic_word(struct net_device *dev, int x, u16 y); -void write_nic_dword(struct net_device *dev, int x, u32 y); +int write_nic_dword(struct net_device *dev, int x, u32 y); void force_pci_posting(struct net_device *dev); void rtl8192_rtx_disable(struct net_device *); diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 10eeb1c..646049d 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -356,7 +356,7 @@ int write_nic_word(struct net_device *dev, int indx, u16 data) } -void write_nic_dword(struct net_device *dev, int indx, u32 data) +int write_nic_dword(struct net_device *dev, int indx, u32 data) { int status; @@ -365,7 +365,7 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) u32 *usbdata = kzalloc(sizeof(data), GFP_KERNEL); if (!usbdata) - return; + return -ENOMEM; *usbdata = data; status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -375,9 +375,13 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) kfree(usbdata); - if (status < 0) + if (status < 0) { netdev_err(dev, "write_nic_dword TimeOut! status: %d\n", status); + return status; + } + + return 0; } -- cgit v1.1 From 75deebb42d8a50ea19617eaaee5e8e7792aecf19 Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Thu, 2 Jun 2016 16:22:59 +0530 Subject: rtl8192u: r8192_priv: Replace semaphore wx_sem with mutex The semaphore 'wx_sem' in r8192_priv is a simple mutex, so it should be written as one. Semaphores are going away in the future. Signed-off-by: Binoy Jayan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 2 +- drivers/staging/rtl8192u/r8192U_core.c | 28 ++++++------ drivers/staging/rtl8192u/r8192U_wx.c | 80 +++++++++++++++++----------------- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index eb0c351..65587ac 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -879,7 +879,7 @@ typedef struct r8192_priv { /* If 1, allow bad crc frame, reception in monitor mode */ short crcmon; - struct semaphore wx_sem; + struct mutex wx_mutex; struct semaphore rf_sem; /* Used to lock rf write operation */ u8 rf_type; /* 0: 1T2R, 1: 2T4R */ diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 646049d..621cabb 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -2376,7 +2376,7 @@ static void rtl8192_init_priv_lock(struct r8192_priv *priv) { spin_lock_init(&priv->tx_lock); spin_lock_init(&priv->irq_lock); - sema_init(&priv->wx_sem, 1); + mutex_init(&priv->wx_mutex); sema_init(&priv->rf_sem, 1); mutex_init(&priv->mutex); } @@ -3368,12 +3368,12 @@ RESET_START: /* Set the variable for reset. */ priv->ResetProgress = RESET_TYPE_SILENT; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); if (priv->up == 0) { RT_TRACE(COMP_ERR, "%s():the driver is not up! return\n", __func__); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return; } priv->up = 0; @@ -3400,7 +3400,7 @@ RESET_START: netdev_dbg(dev, "ieee->state is NOT LINKED\n"); ieee80211_softmac_stop_protocol(priv->ieee80211); } - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); RT_TRACE(COMP_RESET, "%s():<==========down process is finished\n", __func__); @@ -3598,9 +3598,9 @@ static int rtl8192_open(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); int ret; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = rtl8192_up(dev); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -3621,11 +3621,11 @@ static int rtl8192_close(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); int ret; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = rtl8192_down(dev); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -3697,11 +3697,11 @@ static void rtl8192_restart(struct work_struct *work) reset_wq); struct net_device *dev = priv->ieee80211->dev; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); rtl8192_commit(dev); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); } static void r8192_set_multicast(struct net_device *dev) @@ -3724,12 +3724,12 @@ static int r8192_set_mac_adr(struct net_device *dev, void *mac) struct r8192_priv *priv = ieee80211_priv(dev); struct sockaddr *addr = mac; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ether_addr_copy(dev->dev_addr, addr->sa_data); schedule_work(&priv->reset_wq); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return 0; } @@ -3746,7 +3746,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) struct iw_point *p = &wrq->u.data; struct ieee_param *ipw = NULL; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); if (p->length < sizeof(struct ieee_param) || !p->pointer) { @@ -3839,7 +3839,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) kfree(ipw); ipw = NULL; out: - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c index 837704d..d2f2f24 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c @@ -67,11 +67,11 @@ static int r8192_wx_set_rate(struct net_device *dev, int ret; struct r8192_priv *priv = ieee80211_priv(dev); - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_set_rate(priv->ieee80211, info, wrqu, extra); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -83,11 +83,11 @@ static int r8192_wx_set_rts(struct net_device *dev, int ret; struct r8192_priv *priv = ieee80211_priv(dev); - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_set_rts(priv->ieee80211, info, wrqu, extra); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -108,11 +108,11 @@ static int r8192_wx_set_power(struct net_device *dev, int ret; struct r8192_priv *priv = ieee80211_priv(dev); - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_set_power(priv->ieee80211, info, wrqu, extra); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -132,11 +132,11 @@ static int r8192_wx_force_reset(struct net_device *dev, { struct r8192_priv *priv = ieee80211_priv(dev); - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); netdev_dbg(dev, "%s(): force reset ! extra is %d\n", __func__, *extra); priv->force_reset = *extra; - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return 0; } @@ -148,11 +148,11 @@ static int r8192_wx_set_rawtx(struct net_device *dev, struct r8192_priv *priv = ieee80211_priv(dev); int ret; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; @@ -166,7 +166,7 @@ static int r8192_wx_set_crcmon(struct net_device *dev, int *parms = (int *)extra; int enable = (parms[0] > 0); - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); if (enable) priv->crcmon = 1; @@ -176,7 +176,7 @@ static int r8192_wx_set_crcmon(struct net_device *dev, DMESG("bad CRC in monitor mode are %s", priv->crcmon ? "accepted" : "rejected"); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return 0; } @@ -187,13 +187,13 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a, struct r8192_priv *priv = ieee80211_priv(dev); int ret; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_set_mode(priv->ieee80211, a, wrqu, b); rtl8192_set_rxconf(dev); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -338,7 +338,7 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, } } - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); if (priv->ieee80211->state != IEEE80211_LINKED) { priv->ieee80211->scanning = 0; ieee80211_softmac_scan_syncro(priv->ieee80211); @@ -346,7 +346,7 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, } else { ret = ieee80211_wx_set_scan(priv->ieee80211, a, wrqu, b); } - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -361,11 +361,11 @@ static int r8192_wx_get_scan(struct net_device *dev, struct iw_request_info *a, if (!priv->up) return -ENETDOWN; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_get_scan(priv->ieee80211, a, wrqu, b); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -377,11 +377,11 @@ static int r8192_wx_set_essid(struct net_device *dev, struct r8192_priv *priv = ieee80211_priv(dev); int ret; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_set_essid(priv->ieee80211, a, wrqu, b); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -393,11 +393,11 @@ static int r8192_wx_get_essid(struct net_device *dev, int ret; struct r8192_priv *priv = ieee80211_priv(dev); - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -408,11 +408,11 @@ static int r8192_wx_set_freq(struct net_device *dev, struct iw_request_info *a, int ret; struct r8192_priv *priv = ieee80211_priv(dev); - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -468,11 +468,11 @@ static int r8192_wx_set_wap(struct net_device *dev, int ret; struct r8192_priv *priv = ieee80211_priv(dev); /* struct sockaddr *temp = (struct sockaddr *)awrq; */ - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_set_wap(priv->ieee80211, info, awrq, extra); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; @@ -515,12 +515,12 @@ static int r8192_wx_set_enc(struct net_device *dev, if (!priv->up) return -ENETDOWN; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); RT_TRACE(COMP_SEC, "Setting SW wep key"); ret = ieee80211_wx_set_encode(priv->ieee80211, info, wrqu, key); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); @@ -619,7 +619,7 @@ static int r8192_wx_set_retry(struct net_device *dev, struct r8192_priv *priv = ieee80211_priv(dev); int err = 0; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); if (wrqu->retry.flags & IW_RETRY_LIFETIME || wrqu->retry.disabled){ @@ -652,7 +652,7 @@ static int r8192_wx_set_retry(struct net_device *dev, rtl8192_commit(dev); exit: - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return err; } @@ -701,7 +701,7 @@ static int r8192_wx_set_sens(struct net_device *dev, struct r8192_priv *priv = ieee80211_priv(dev); short err = 0; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); if (priv->rf_set_sens == NULL) { err = -1; /* we have not this support for this radio */ goto exit; @@ -712,7 +712,7 @@ static int r8192_wx_set_sens(struct net_device *dev, err = -EINVAL; exit: - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return err; } @@ -727,7 +727,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, struct ieee80211_device *ieee = priv->ieee80211; - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_set_encode_ext(priv->ieee80211, info, wrqu, extra); { @@ -790,7 +790,7 @@ static int r8192_wx_set_enc_ext(struct net_device *dev, end_hw_sec: - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -801,9 +801,9 @@ static int r8192_wx_set_auth(struct net_device *dev, int ret = 0; struct r8192_priv *priv = ieee80211_priv(dev); - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_set_auth(priv->ieee80211, info, &(data->param), extra); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -815,10 +815,10 @@ static int r8192_wx_set_mlme(struct net_device *dev, int ret = 0; struct r8192_priv *priv = ieee80211_priv(dev); - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_set_mlme(priv->ieee80211, info, wrqu, extra); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; } @@ -829,9 +829,9 @@ static int r8192_wx_set_gen_ie(struct net_device *dev, int ret = 0; struct r8192_priv *priv = ieee80211_priv(dev); - down(&priv->wx_sem); + mutex_lock(&priv->wx_mutex); ret = ieee80211_wx_set_gen_ie(priv->ieee80211, extra, data->data.length); - up(&priv->wx_sem); + mutex_unlock(&priv->wx_mutex); return ret; -- cgit v1.1 From e379a9a87952f5b16cbad8f89a8826c4df2fcb31 Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Thu, 2 Jun 2016 16:23:00 +0530 Subject: rtl8192u: ieee80211_device: Replace semaphore wx_sem with mutex The semaphore 'wx_sem' in ieee80211_device is a simple mutex, so it should be written as one. Semaphores are going away in the future. Signed-off-by: Binoy Jayan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 2 +- .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 36 +++++++++++----------- .../rtl8192u/ieee80211/ieee80211_softmac_wx.c | 34 ++++++++++---------- drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 6 ++-- drivers/staging/rtl8192u/r8192U_core.c | 4 +-- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 68931e5..ef9ae22 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -1799,7 +1799,7 @@ struct ieee80211_device { short scanning; short proto_started; - struct semaphore wx_sem; + struct mutex wx_mutex; struct semaphore scan_sem; spinlock_t mgmt_tx_lock; diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index d705595..664664b 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -621,7 +621,7 @@ static void ieee80211_start_scan(struct ieee80211_device *ieee) } -/* called with wx_sem held */ +/* called with wx_mutex held */ void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) { if (IS_DOT11D_ENABLE(ieee) ) @@ -1389,7 +1389,7 @@ static void ieee80211_associate_procedure_wq(struct work_struct *work) { struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq); ieee->sync_scan_hurryup = 1; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); @@ -1402,7 +1402,7 @@ static void ieee80211_associate_procedure_wq(struct work_struct *work) ieee->associate_seq = 1; ieee80211_associate_step1(ieee); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net) @@ -2331,7 +2331,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, start_ibss_wq); /* iwconfig mode ad-hoc will schedule this and return * on the other hand this will block further iwconfig SET - * operations because of the wx_sem hold. + * operations because of the wx_mutex hold. * Anyway some most set operations set a flag to speed-up * (abort) this wq (when syncro scanning) before sleeping * on the semaphore @@ -2340,7 +2340,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) printk("==========oh driver down return\n"); return; } - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (ieee->current_network.ssid_len == 0) { strcpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID); @@ -2431,7 +2431,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) ieee->data_hard_resume(ieee->dev); netif_carrier_on(ieee->dev); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } inline void ieee80211_start_ibss(struct ieee80211_device *ieee) @@ -2439,7 +2439,7 @@ inline void ieee80211_start_ibss(struct ieee80211_device *ieee) schedule_delayed_work(&ieee->start_ibss_wq, 150); } -/* this is called only in user context, with wx_sem held */ +/* this is called only in user context, with wx_mutex held */ void ieee80211_start_bss(struct ieee80211_device *ieee) { unsigned long flags; @@ -2505,7 +2505,7 @@ static void ieee80211_associate_retry_wq(struct work_struct *work) struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); unsigned long flags; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if(!ieee->proto_started) goto exit; @@ -2537,7 +2537,7 @@ static void ieee80211_associate_retry_wq(struct work_struct *work) spin_unlock_irqrestore(&ieee->lock, flags); exit: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) @@ -2583,9 +2583,9 @@ EXPORT_SYMBOL(ieee80211_get_beacon); void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 1; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); ieee80211_stop_protocol(ieee); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } EXPORT_SYMBOL(ieee80211_softmac_stop_protocol); @@ -2609,9 +2609,9 @@ void ieee80211_stop_protocol(struct ieee80211_device *ieee) void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) { ieee->sync_scan_hurryup = 0; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); ieee80211_start_protocol(ieee); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } EXPORT_SYMBOL(ieee80211_softmac_start_protocol); @@ -2728,7 +2728,7 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq); - sema_init(&ieee->wx_sem, 1); + mutex_init(&ieee->wx_mutex); sema_init(&ieee->scan_sem, 1); spin_lock_init(&ieee->mgmt_tx_lock); @@ -2742,14 +2742,14 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) void ieee80211_softmac_free(struct ieee80211_device *ieee) { - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); kfree(ieee->pDot11dInfo); ieee->pDot11dInfo = NULL; del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } /******************************************************** @@ -3138,7 +3138,7 @@ int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_poin struct ieee_param *param; int ret=0; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); //IEEE_DEBUG_INFO("wpa_supplicant: len=%d\n", p->length); if (p->length < sizeof(struct ieee_param) || !p->pointer) { @@ -3183,7 +3183,7 @@ int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_poin kfree(param); out: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return ret; } diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c index aad288a..21bd0dc 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c @@ -34,7 +34,7 @@ int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info int ret; struct iw_freq *fwrq = &wrqu->freq; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (ieee->iw_mode == IW_MODE_INFRA) { ret = -EOPNOTSUPP; @@ -79,7 +79,7 @@ int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info ret = 0; out: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return ret; } EXPORT_SYMBOL(ieee80211_wx_set_freq); @@ -145,7 +145,7 @@ int ieee80211_wx_set_wap(struct ieee80211_device *ieee, ieee->sync_scan_hurryup = 1; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); /* use ifconfig hw ether */ if (ieee->iw_mode == IW_MODE_MASTER) { ret = -1; @@ -173,7 +173,7 @@ int ieee80211_wx_set_wap(struct ieee80211_device *ieee, if (ifup) ieee80211_start_protocol(ieee); out: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return ret; } EXPORT_SYMBOL(ieee80211_wx_set_wap); @@ -274,7 +274,7 @@ int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info ieee->sync_scan_hurryup = 1; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (wrqu->mode == ieee->iw_mode) goto out; @@ -293,7 +293,7 @@ int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info } out: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return 0; } EXPORT_SYMBOL(ieee80211_wx_set_mode); @@ -353,7 +353,7 @@ void ieee80211_wx_sync_scan_wq(struct work_struct *work) ieee80211_start_send_beacons(ieee); netif_carrier_on(ieee->dev); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } @@ -362,7 +362,7 @@ int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info { int ret = 0; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)) { ret = -1; @@ -376,7 +376,7 @@ int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info } out: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return ret; } EXPORT_SYMBOL(ieee80211_wx_set_scan); @@ -391,7 +391,7 @@ int ieee80211_wx_set_essid(struct ieee80211_device *ieee, unsigned long flags; ieee->sync_scan_hurryup = 1; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); proto_started = ieee->proto_started; @@ -430,7 +430,7 @@ int ieee80211_wx_set_essid(struct ieee80211_device *ieee, if (proto_started) ieee80211_start_protocol(ieee); out: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return ret; } EXPORT_SYMBOL(ieee80211_wx_set_essid); @@ -453,7 +453,7 @@ int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, int enable = (parms[0] > 0); short prev = ieee->raw_tx; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (enable) ieee->raw_tx = 1; @@ -475,7 +475,7 @@ int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, netif_carrier_off(ieee->dev); } - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return 0; } @@ -514,7 +514,7 @@ int ieee80211_wx_set_power(struct ieee80211_device *ieee, { int ret = 0; - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (wrqu->power.disabled) { ieee->ps = IEEE80211_PS_DISABLED; @@ -553,7 +553,7 @@ int ieee80211_wx_set_power(struct ieee80211_device *ieee, } exit: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return ret; } @@ -564,7 +564,7 @@ int ieee80211_wx_get_power(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); if (ieee->ps == IEEE80211_PS_DISABLED) { wrqu->power.disabled = 1; @@ -592,7 +592,7 @@ int ieee80211_wx_get_power(struct ieee80211_device *ieee, wrqu->power.flags |= IW_POWER_UNICAST_R; exit: - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); return 0; } diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index 208be5f..563d7fe 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -253,7 +253,7 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee, int i = 0; int err = 0; IEEE80211_DEBUG_WX("Getting scan\n"); - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(network, &ieee->network_list, list) { @@ -262,7 +262,7 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee, { err = -E2BIG; break; - } + } if (ieee->scan_age == 0 || time_after(network->last_scanned + ieee->scan_age, jiffies)) ev = rtl819x_translate_scan(ieee, ev, stop, network, info); @@ -277,7 +277,7 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee, } spin_unlock_irqrestore(&ieee->lock, flags); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); wrqu->data.length = ev - extra; wrqu->data.flags = 0; diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 621cabb..f9c465c 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -3388,14 +3388,14 @@ RESET_START: ieee->sync_scan_hurryup = 1; if (ieee->state == IEEE80211_LINKED) { - down(&ieee->wx_sem); + mutex_lock(&ieee->wx_mutex); netdev_dbg(dev, "ieee->state is IEEE80211_LINKED\n"); ieee80211_stop_send_beacons(priv->ieee80211); del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); ieee80211_stop_scan(ieee); netif_carrier_off(dev); - up(&ieee->wx_sem); + mutex_unlock(&ieee->wx_mutex); } else { netdev_dbg(dev, "ieee->state is NOT LINKED\n"); ieee80211_softmac_stop_protocol(priv->ieee80211); -- cgit v1.1 From 87d63bcc0f98248be03a1eb8cb3431b7c395bcae Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Thu, 2 Jun 2016 16:23:01 +0530 Subject: rtl8192u: Replace semaphore scan_sem with mutex The semaphore 'scan_sem' in rtl8192u is a simple mutex, so it should be written as one. Semaphores are going away in the future. Signed-off-by: Binoy Jayan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index ef9ae22..09e9499 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -1800,7 +1800,7 @@ struct ieee80211_device { short proto_started; struct mutex wx_mutex; - struct semaphore scan_sem; + struct mutex scan_mutex; spinlock_t mgmt_tx_lock; spinlock_t beacon_lock; diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 664664b..49db1b7 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -427,7 +427,7 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) short ch = 0; u8 channel_map[MAX_CHANNEL_NUMBER+1]; memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); - down(&ieee->scan_sem); + mutex_lock(&ieee->scan_mutex); while(1) { @@ -475,13 +475,13 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) out: if(ieee->state < IEEE80211_LINKED){ ieee->actscanning = false; - up(&ieee->scan_sem); + mutex_unlock(&ieee->scan_mutex); } else{ ieee->sync_scan_hurryup = 0; if(IS_DOT11D_ENABLE(ieee)) DOT11D_ScanComplete(ieee); - up(&ieee->scan_sem); + mutex_unlock(&ieee->scan_mutex); } } EXPORT_SYMBOL(ieee80211_softmac_scan_syncro); @@ -495,7 +495,7 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); if(!ieee->ieee_up) return; - down(&ieee->scan_sem); + mutex_lock(&ieee->scan_mutex); do{ ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; @@ -517,7 +517,7 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) schedule_delayed_work(&ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); - up(&ieee->scan_sem); + mutex_unlock(&ieee->scan_mutex); return; out: if(IS_DOT11D_ENABLE(ieee)) @@ -525,7 +525,7 @@ out: ieee->actscanning = false; watchdog = 0; ieee->scanning = 0; - up(&ieee->scan_sem); + mutex_unlock(&ieee->scan_mutex); } @@ -579,7 +579,7 @@ static void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) //ieee->sync_scan_hurryup = 1; - down(&ieee->scan_sem); + mutex_lock(&ieee->scan_mutex); // spin_lock_irqsave(&ieee->lock, flags); if (ieee->scanning == 1) { @@ -589,7 +589,7 @@ static void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) } // spin_unlock_irqrestore(&ieee->lock, flags); - up(&ieee->scan_sem); + mutex_unlock(&ieee->scan_mutex); } void ieee80211_stop_scan(struct ieee80211_device *ieee) @@ -2729,7 +2729,7 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) mutex_init(&ieee->wx_mutex); - sema_init(&ieee->scan_sem, 1); + mutex_init(&ieee->scan_mutex); spin_lock_init(&ieee->mgmt_tx_lock); spin_lock_init(&ieee->beacon_lock); -- cgit v1.1 From b53628cbf9200586a2584cf5ec3bf4e003052178 Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Thu, 2 Jun 2016 16:23:02 +0530 Subject: rtl8192u: Remove unused semaphore rf_sem The semaphore 'rf_sem' in rtl8192u has no users, hence removing it. Signed-off-by: Binoy Jayan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 1 - drivers/staging/rtl8192u/r8192U_core.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 65587ac..821afc0 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -880,7 +880,6 @@ typedef struct r8192_priv { short crcmon; struct mutex wx_mutex; - struct semaphore rf_sem; /* Used to lock rf write operation */ u8 rf_type; /* 0: 1T2R, 1: 2T4R */ RT_RF_TYPE_819xU rf_chip; diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index f9c465c..dd0970f 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -2377,7 +2377,6 @@ static void rtl8192_init_priv_lock(struct r8192_priv *priv) spin_lock_init(&priv->tx_lock); spin_lock_init(&priv->irq_lock); mutex_init(&priv->wx_mutex); - sema_init(&priv->rf_sem, 1); mutex_init(&priv->mutex); } -- cgit v1.1 From f1b91de88a8b39f76caa74100cf44828226e00df Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Sat, 18 Jun 2016 23:53:10 -0400 Subject: staging/lustre: Fix blank line before EXPORT_SYMBOL() This patch fixes one checkpatch warning in lustre: WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable Signed-off-by: Emoly Liu Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index fe6f7a6..bc93b75 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -1158,7 +1158,6 @@ void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes) lprocfs_counter_add(svc_stats, idx, bytes); } - EXPORT_SYMBOL(ptlrpc_lprocfs_brw); void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc) -- cgit v1.1 From d719d2ddd12f0c7e1706d086786647190378f6e0 Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Sat, 18 Jun 2016 23:53:11 -0400 Subject: staging/lustre: Keep logical continuations on the previous line This patch fixes all checkpatch occurences of "CHECK: Logical continuations should be on the previous line" in Lustre code. Signed-off-by: Emoly Liu Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 9 ++++----- drivers/staging/lustre/lustre/obdclass/obd_config.c | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index 38c507f..d6b61bc 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -255,14 +255,13 @@ reprocess: * overflow and underflow. */ if ((new->l_policy_data.l_flock.start > - (lock->l_policy_data.l_flock.end + 1)) - && (lock->l_policy_data.l_flock.end != - OBD_OBJECT_EOF)) + (lock->l_policy_data.l_flock.end + 1)) && + (lock->l_policy_data.l_flock.end != OBD_OBJECT_EOF)) continue; if ((new->l_policy_data.l_flock.end < - (lock->l_policy_data.l_flock.start - 1)) - && (lock->l_policy_data.l_flock.start != 0)) + (lock->l_policy_data.l_flock.start - 1)) && + (lock->l_policy_data.l_flock.start != 0)) break; if (new->l_policy_data.l_flock.start < diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 694c58e..f1c41a1 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -1017,8 +1017,8 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, /* Search proc entries */ while (lvars[j].name) { var = &lvars[j]; - if (!class_match_param(key, var->name, NULL) - && keylen == strlen(var->name)) { + if (!class_match_param(key, var->name, NULL) && + keylen == strlen(var->name)) { matched++; rc = -EROFS; if (var->fops && var->fops->write) { -- cgit v1.1 From 9797fb0e25f5f1f6e714006cf05390b76228e839 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 18 Jun 2016 23:53:12 -0400 Subject: staging/lustre: Remove unnecessary space after a cast This patch fixes all checkpatch occurences of "CHECK: No space is necessary after a cast" in Lustre code. Signed-off-by: Emoly Liu Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/lnet/lib-dlc.h | 2 +- drivers/staging/lustre/include/linux/lnet/types.h | 4 ++-- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 2 +- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 2 +- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 4 ++-- drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 4 ++-- drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c | 6 +++--- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- drivers/staging/lustre/lnet/lnet/module.c | 2 +- drivers/staging/lustre/lustre/include/lustre_sec.h | 6 +++--- drivers/staging/lustre/lustre/llite/file.c | 2 +- drivers/staging/lustre/lustre/llite/vvp_dev.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 4 ++-- drivers/staging/lustre/lustre/mgc/mgc_request.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/cl_object.c | 6 +++--- drivers/staging/lustre/lustre/obdclass/obd_config.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec_null.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/sec_plain.c | 10 +++++----- 22 files changed, 39 insertions(+), 39 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-dlc.h b/drivers/staging/lustre/include/linux/lnet/lib-dlc.h index 6ce9acc..dfff170 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-dlc.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-dlc.h @@ -35,7 +35,7 @@ #define MAX_NUM_SHOW_ENTRIES 32 #define LNET_MAX_STR_LEN 128 #define LNET_MAX_SHOW_NUM_CPT 128 -#define LNET_UNDEFINED_HOPS ((__u32) -1) +#define LNET_UNDEFINED_HOPS ((__u32)(-1)) struct lnet_ioctl_config_lnd_cmn_tunables { __u32 lct_version; diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index 1c679cb..e098b6c 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -68,9 +68,9 @@ typedef __u64 lnet_nid_t; typedef __u32 lnet_pid_t; /** wildcard NID that matches any end-point address */ -#define LNET_NID_ANY ((lnet_nid_t) -1) +#define LNET_NID_ANY ((lnet_nid_t)(-1)) /** wildcard PID that matches any lnet_pid_t */ -#define LNET_PID_ANY ((lnet_pid_t) -1) +#define LNET_PID_ANY ((lnet_pid_t)(-1)) #define LNET_PID_RESERVED 0xf0000000 /* reserved bits in PID */ #define LNET_PID_USERFLAG 0x80000000 /* set in userspace peers */ diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index b66ab79..078a0c3 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -98,7 +98,7 @@ extern struct kib_tunables kiblnd_tunables; #define IBLND_CREDIT_HIGHWATER_V1 7 /* V1 only : when eagerly to return credits */ #define IBLND_CREDITS_DEFAULT 8 /* default # of peer credits */ -#define IBLND_CREDITS_MAX ((typeof(((struct kib_msg *) 0)->ibm_credits)) - 1) /* Max # of peer credits */ +#define IBLND_CREDITS_MAX ((typeof(((struct kib_msg *)0)->ibm_credits)) - 1) /* Max # of peer credits */ /* when eagerly to return credits */ #define IBLND_CREDITS_HIGHWATER(t, v) ((v) == IBLND_MSG_VERSION_1 ? \ diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index adc346a..e32e43b 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -1103,7 +1103,7 @@ kiblnd_init_rdma(struct kib_conn *conn, struct kib_tx *tx, int type, wrknob = min(min(kiblnd_rd_frag_size(srcrd, srcidx), kiblnd_rd_frag_size(dstrd, dstidx)), - (__u32) resid); + (__u32)resid); sge = &tx->tx_sge[tx->tx_nwrq]; sge->addr = kiblnd_rd_frag_addr(srcrd, srcidx); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index d4e7dae..07ec540 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -475,7 +475,7 @@ ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port) write_lock_bh(&ksocknal_data.ksnd_global_lock); /* always called with a ref on ni, so shutdown can't have started */ - LASSERT(!((struct ksock_net *) ni->ni_data)->ksnn_shutdown); + LASSERT(!((struct ksock_net *)ni->ni_data)->ksnn_shutdown); peer2 = ksocknal_find_peer_locked(ni, id); if (peer2) { @@ -1146,7 +1146,7 @@ ksocknal_create_conn(lnet_ni_t *ni, struct ksock_route *route, write_lock_bh(global_lock); /* called with a ref on ni, so shutdown can't have started */ - LASSERT(!((struct ksock_net *) ni->ni_data)->ksnn_shutdown); + LASSERT(!((struct ksock_net *)ni->ni_data)->ksnn_shutdown); peer2 = ksocknal_find_peer_locked(ni, peerid); if (!peer2) { diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index e63d29b..303576d 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -126,7 +126,7 @@ ksocknal_send_iov(struct ksock_conn *conn, struct ksock_tx *tx) do { LASSERT(tx->tx_niov > 0); - if (nob < (int) iov->iov_len) { + if (nob < (int)iov->iov_len) { iov->iov_base = (void *)((char *)iov->iov_base + nob); iov->iov_len -= nob; return rc; @@ -326,7 +326,7 @@ ksocknal_recv_kiov(struct ksock_conn *conn) do { LASSERT(conn->ksnc_rx_nkiov > 0); - if (nob < (int) kiov->kiov_len) { + if (nob < (int)kiov->kiov_len) { kiov->kiov_offset += nob; kiov->kiov_len -= nob; return -EAGAIN; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c index e1bf910..82e174f 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c @@ -503,7 +503,7 @@ ksocknal_send_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello) if (!hello->kshm_nips) goto out; - for (i = 0; i < (int) hello->kshm_nips; i++) + for (i = 0; i < (int)hello->kshm_nips; i++) hello->kshm_ips[i] = __cpu_to_le32(hello->kshm_ips[i]); rc = lnet_sock_write(sock, hello->kshm_ips, @@ -622,7 +622,7 @@ ksocknal_recv_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello, goto out; } - for (i = 0; i < (int) hello->kshm_nips; i++) { + for (i = 0; i < (int)hello->kshm_nips; i++) { hello->kshm_ips[i] = __le32_to_cpu(hello->kshm_ips[i]); if (!hello->kshm_ips[i]) { @@ -690,7 +690,7 @@ ksocknal_recv_hello_v2(struct ksock_conn *conn, ksock_hello_msg_t *hello, int ti return rc; } - for (i = 0; i < (int) hello->kshm_nips; i++) { + for (i = 0; i < (int)hello->kshm_nips; i++) { if (conn->ksnc_flip) __swab32s(&hello->kshm_ips[i]); diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 48327ca..346db89 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1673,7 +1673,7 @@ lnet_fill_ni_info(struct lnet_ni *ni, struct lnet_ioctl_config_data *config) if (!ni || !config) return; - net_config = (struct lnet_ioctl_net_config *) config->cfg_bulk; + net_config = (struct lnet_ioctl_net_config *)config->cfg_bulk; if (!net_config) return; diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index 58cf246..4ffbd3e 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -196,7 +196,7 @@ static int __init lnet_init(void) * Have to schedule a separate thread to avoid deadlocking * in modload */ - (void) kthread_run(lnet_configure, NULL, "lnet_initd"); + (void)kthread_run(lnet_configure, NULL, "lnet_initd"); } return 0; diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h index ed4b4c7..90c1834 100644 --- a/drivers/staging/lustre/lustre/include/lustre_sec.h +++ b/drivers/staging/lustre/lustre/include/lustre_sec.h @@ -217,13 +217,13 @@ enum sptlrpc_bulk_service { #define SPTLRPC_FLVR_DEFAULT SPTLRPC_FLVR_NULL -#define SPTLRPC_FLVR_INVALID ((__u32) 0xFFFFFFFF) -#define SPTLRPC_FLVR_ANY ((__u32) 0xFFF00000) +#define SPTLRPC_FLVR_INVALID ((__u32)0xFFFFFFFF) +#define SPTLRPC_FLVR_ANY ((__u32)0xFFF00000) /** * extract the useful part from wire flavor */ -#define WIRE_FLVR(wflvr) (((__u32) (wflvr)) & 0x000FFFFF) +#define WIRE_FLVR(wflvr) (((__u32)(wflvr)) & 0x000FFFFF) /** @} flavor */ diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 4602596..b0c4548 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1413,7 +1413,7 @@ out_unlock: out: return rc; out_req_free: - ptlrpc_req_finished((struct ptlrpc_request *) oit.d.lustre.it_data); + ptlrpc_req_finished((struct ptlrpc_request *)oit.d.lustre.it_data); goto out; } diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index 6c09fb2..e623216 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -560,7 +560,7 @@ static int vvp_pgcache_show(struct seq_file *f, void *v) env = cl_env_get(&refcheck); if (!IS_ERR(env)) { - pos = *(loff_t *) v; + pos = *(loff_t *)v; vvp_pgcache_id_unpack(pos, &id); sbi = f->private; clob = vvp_pgcache_obj(env, &sbi->ll_cl->cd_lu_dev, &id); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 12cb238..f371e1d 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -1803,7 +1803,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, case IOC_OBD_STATFS: { struct obd_statfs stat_buf = {0}; - if (*((__u32 *) data->ioc_inlbuf2) != 0) { + if (*((__u32 *)data->ioc_inlbuf2) != 0) { rc = -ENODEV; goto out; } @@ -1997,7 +1997,7 @@ static int mdc_hsm_copytool_send(int len, void *val) if (len < sizeof(*lh) + sizeof(*hal)) { CERROR("Short HSM message %d < %d\n", len, - (int) (sizeof(*lh) + sizeof(*hal))); + (int)(sizeof(*lh) + sizeof(*hal))); return -EPROTO; } if (lh->kuc_magic == __swab16(KUC_MAGIC)) { diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 69f5337..fbbf276 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -1030,7 +1030,7 @@ static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, rc = sptlrpc_parse_flavor(val, &flvr); if (rc) { CERROR("invalid sptlrpc flavor %s to MGS\n", - (char *) val); + (char *)val); return rc; } @@ -1046,7 +1046,7 @@ static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, sptlrpc_flavor2name(&cli->cl_flvr_mgc, str, sizeof(str)); LCONSOLE_ERROR("asking sptlrpc flavor %s to MGS but currently %s is in use\n", - (char *) val, str); + (char *)val, str); rc = -EPERM; } return rc; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index 615158a..91a5806 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -573,7 +573,7 @@ static inline struct cl_env *cl_env_fetch(void) { struct cl_env *cle; - cle = cfs_hash_lookup(cl_env_hash, (void *) (long) current->pid); + cle = cfs_hash_lookup(cl_env_hash, (void *)(long)current->pid); LASSERT(ergo(cle, cle->ce_magic == &cl_env_init0)); return cle; } @@ -584,7 +584,7 @@ static inline void cl_env_attach(struct cl_env *cle) int rc; LASSERT(!cle->ce_owner); - cle->ce_owner = (void *) (long) current->pid; + cle->ce_owner = (void *)(long)current->pid; rc = cfs_hash_add_unique(cl_env_hash, cle->ce_owner, &cle->ce_node); LASSERT(rc == 0); @@ -595,7 +595,7 @@ static inline void cl_env_do_detach(struct cl_env *cle) { void *cookie; - LASSERT(cle->ce_owner == (void *) (long) current->pid); + LASSERT(cle->ce_owner == (void *)(long)current->pid); cookie = cfs_hash_del(cl_env_hash, cle->ce_owner, &cle->ce_node); LASSERT(cookie == cle); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index f1c41a1..0eab123 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -1073,7 +1073,7 @@ int class_config_llog_handler(const struct lu_env *env, { struct config_llog_instance *clli = data; int cfg_len = rec->lrh_len; - char *cfg_buf = (char *) (rec + 1); + char *cfg_buf = (char *)(rec + 1); int rc = 0; switch (rec->lrh_type) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index c444f51..d88faf6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -769,7 +769,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, spin_unlock(&nrs->nrs_lock); if (rc != 0) - (void) nrs_policy_unregister(nrs, policy->pol_desc->pd_name); + (void)nrs_policy_unregister(nrs, policy->pol_desc->pd_name); return rc; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 7ab3ae9..f3b4773 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -1100,7 +1100,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, early_req->rq_flvr = req->rq_flvr; early_req->rq_repbuf = early_buf; early_req->rq_repbuf_len = early_bufsz; - early_req->rq_repdata = (struct lustre_msg *) early_buf; + early_req->rq_repdata = (struct lustre_msg *)early_buf; early_req->rq_repdata_len = early_size; early_req->rq_early = 1; early_req->rq_reqmsg = req->rq_reqmsg; @@ -1552,7 +1552,7 @@ void _sptlrpc_enlarge_msg_inplace(struct lustre_msg *msg, /* move from segment + 1 to end segment */ LASSERT(msg->lm_magic == LUSTRE_MSG_MAGIC_V2); oldmsg_size = lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens); - movesize = oldmsg_size - ((unsigned long) src - (unsigned long) msg); + movesize = oldmsg_size - ((unsigned long)src - (unsigned long)msg); LASSERT(movesize >= 0); if (movesize) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index b3e3ed9..5f4d797 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -269,7 +269,7 @@ static unsigned long enc_pools_shrink_scan(struct shrinker *s, static inline int npages_to_npools(unsigned long npages) { - return (int) ((npages + PAGES_PER_POOL - 1) / PAGES_PER_POOL); + return (int)((npages + PAGES_PER_POOL - 1) / PAGES_PER_POOL); } /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index 303bf96..1238c87 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -644,7 +644,7 @@ static int logname2fsname(const char *logname, char *buf, int buflen) return -EINVAL; } - len = min((int) (ptr - logname), buflen - 1); + len = min((int)(ptr - logname), buflen - 1); memcpy(buf, logname, len); buf[len] = '\0'; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c index 3306233..70a61e1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_null.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_null.c @@ -56,7 +56,7 @@ static struct ptlrpc_svc_ctx null_svc_ctx; static inline void null_encode_sec_part(struct lustre_msg *msg, enum lustre_sec_part sp) { - msg->lm_secflvr |= (((__u32) sp) & 0xFF) << 24; + msg->lm_secflvr |= (((__u32)sp) & 0xFF) << 24; } static inline @@ -326,7 +326,7 @@ int null_alloc_rs(struct ptlrpc_request *req, int msgsize) rs->rs_svc_ctx = req->rq_svc_ctx; atomic_inc(&req->rq_svc_ctx->sc_refcount); - rs->rs_repbuf = (struct lustre_msg *) (rs + 1); + rs->rs_repbuf = (struct lustre_msg *)(rs + 1); rs->rs_repbuf_len = rs_size - sizeof(*rs); rs->rs_msg = rs->rs_repbuf; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index ea79b15..5c4590b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -294,7 +294,7 @@ int plain_cli_wrap_bulk(struct ptlrpc_cli_ctx *ctx, LASSERT(req->rq_reqbuf->lm_bufcount == PLAIN_PACK_SEGMENTS); bsd = lustre_msg_buf(req->rq_reqbuf, PLAIN_PACK_BULK_OFF, 0); - token = (struct plain_bulk_token *) bsd->bsd_data; + token = (struct plain_bulk_token *)bsd->bsd_data; bsd->bsd_version = 0; bsd->bsd_flags = 0; @@ -339,7 +339,7 @@ int plain_cli_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, LASSERT(req->rq_repdata->lm_bufcount == PLAIN_PACK_SEGMENTS); bsdv = lustre_msg_buf(req->rq_repdata, PLAIN_PACK_BULK_OFF, 0); - tokenv = (struct plain_bulk_token *) bsdv->bsd_data; + tokenv = (struct plain_bulk_token *)bsdv->bsd_data; if (req->rq_bulk_write) { if (bsdv->bsd_flags & BSD_FL_ERR) @@ -811,7 +811,7 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) rs->rs_svc_ctx = req->rq_svc_ctx; atomic_inc(&req->rq_svc_ctx->sc_refcount); - rs->rs_repbuf = (struct lustre_msg *) (rs + 1); + rs->rs_repbuf = (struct lustre_msg *)(rs + 1); rs->rs_repbuf_len = rs_size - sizeof(*rs); lustre_init_msg_v2(rs->rs_repbuf, PLAIN_PACK_SEGMENTS, buflens, NULL); @@ -891,7 +891,7 @@ int plain_svc_unwrap_bulk(struct ptlrpc_request *req, LASSERT(req->rq_pack_bulk); bsdr = lustre_msg_buf(req->rq_reqbuf, PLAIN_PACK_BULK_OFF, 0); - tokenr = (struct plain_bulk_token *) bsdr->bsd_data; + tokenr = (struct plain_bulk_token *)bsdr->bsd_data; bsdv = lustre_msg_buf(rs->rs_repbuf, PLAIN_PACK_BULK_OFF, 0); bsdv->bsd_version = 0; @@ -926,7 +926,7 @@ int plain_svc_wrap_bulk(struct ptlrpc_request *req, bsdr = lustre_msg_buf(req->rq_reqbuf, PLAIN_PACK_BULK_OFF, 0); bsdv = lustre_msg_buf(rs->rs_repbuf, PLAIN_PACK_BULK_OFF, 0); - tokenv = (struct plain_bulk_token *) bsdv->bsd_data; + tokenv = (struct plain_bulk_token *)bsdv->bsd_data; bsdv->bsd_version = 0; bsdv->bsd_type = SPTLRPC_BULK_DEFAULT; -- cgit v1.1 From 25ed6a5e97809129a1bc852b6b5c7d03baa112c4 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Sat, 18 Jun 2016 23:53:13 -0400 Subject: staging/lustre: Update FID documentation link. When OpenSFS took over lustre.org, there was some reshuffling. FIDs on ZFS document is now at http://wiki.old.lustre.org/index.php/Architecture_-_Interoperability_fids_zfs instead of the old location, so update comments accordingly. Signed-off-by: Oleg Drokin Reported-by: Xose Vazquez Perez Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre/lustre_idl.h | 4 ++-- drivers/staging/lustre/lustre/include/lustre_fid.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index bf8a0cd..fac7215 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -382,7 +382,7 @@ static inline __u64 fid_ver_oid(const struct lu_fid *fid) * used for other purposes and not risk collisions with existing inodes. * * Different FID Format - * http://arch.lustre.org/index.php?title=Interoperability_fids_zfs#NEW.0 + * http://wiki.old.lustre.org/index.php/Architecture_-_Interoperability_fids_zfs */ enum fid_seq { FID_SEQ_OST_MDT0 = 0, @@ -700,7 +700,7 @@ static inline int fid_set_id(struct lu_fid *fid, __u64 oid) * be passed through unchanged. Only legacy OST objects in "group 0" * will be mapped into the IDIF namespace so that they can fit into the * struct lu_fid fields without loss. For reference see: - * http://arch.lustre.org/index.php?title=Interoperability_fids_zfs + * http://wiki.old.lustre.org/index.php/Architecture_-_Interoperability_fids_zfs */ static inline int ostid_to_fid(struct lu_fid *fid, struct ost_id *ostid, __u32 ost_idx) diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index cbdd91a..743671a 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -41,7 +41,7 @@ * * @{ * - * http://wiki.lustre.org/index.php/Architecture_-_Interoperability_fids_zfs + * http://wiki.old.lustre.org/index.php/Architecture_-_Interoperability_fids_zfs * describes the FID namespace and interoperability requirements for FIDs. * The important parts of that document are included here for reference. * -- cgit v1.1 From 341f1f0affed1c24712f37c95bb654b3b33ab2c6 Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Sun, 19 Jun 2016 22:53:53 -0400 Subject: staging: lustre: remove remote client support There are several obsolete sub commands for lfs to work with remote client. We do not support that anymore, and should be deleted along with any kernel code related to remote client. Signed-off-by: Fan Yong Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6971 Reviewed-on: http://review.whamcloud.com/19789 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin Signed-off-by: James Simmons Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre/lustre_idl.h | 40 +- .../lustre/lustre/include/lustre/lustre_user.h | 15 +- .../staging/lustre/lustre/include/lustre_eacl.h | 11 - .../staging/lustre/lustre/include/lustre_export.h | 13 - drivers/staging/lustre/lustre/include/lustre_net.h | 1 - .../lustre/lustre/include/lustre_req_layout.h | 2 +- drivers/staging/lustre/lustre/include/obd.h | 3 - drivers/staging/lustre/lustre/include/obd_class.h | 10 - drivers/staging/lustre/lustre/llite/Makefile | 3 +- drivers/staging/lustre/lustre/llite/dir.c | 29 +- drivers/staging/lustre/lustre/llite/file.c | 15 - .../staging/lustre/lustre/llite/llite_internal.h | 88 +---- drivers/staging/lustre/lustre/llite/llite_lib.c | 69 +--- drivers/staging/lustre/lustre/llite/llite_rmtacl.c | 295 --------------- drivers/staging/lustre/lustre/llite/lproc_llite.c | 6 +- drivers/staging/lustre/lustre/llite/remote_perm.c | 320 ---------------- drivers/staging/lustre/lustre/llite/super25.c | 19 - drivers/staging/lustre/lustre/llite/xattr.c | 97 +---- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 22 -- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 21 +- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 76 +--- drivers/staging/lustre/lustre/obdclass/Makefile | 3 +- drivers/staging/lustre/lustre/obdclass/acl.c | 411 --------------------- drivers/staging/lustre/lustre/osc/osc_cache.c | 5 +- drivers/staging/lustre/lustre/osc/osc_page.c | 4 +- drivers/staging/lustre/lustre/ptlrpc/layout.c | 12 +- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 13 - drivers/staging/lustre/lustre/ptlrpc/wiretest.c | 48 --- 29 files changed, 55 insertions(+), 1598 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/llite/llite_rmtacl.c delete mode 100644 drivers/staging/lustre/lustre/llite/remote_perm.c delete mode 100644 drivers/staging/lustre/lustre/obdclass/acl.c diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index fac7215..051864c 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -1237,8 +1237,16 @@ void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb); */ #define OBD_CONNECT_ATTRFID 0x4000ULL /*Server can GetAttr By Fid*/ #define OBD_CONNECT_NODEVOH 0x8000ULL /*No open hndl on specl nodes*/ -#define OBD_CONNECT_RMT_CLIENT 0x10000ULL /*Remote client */ -#define OBD_CONNECT_RMT_CLIENT_FORCE 0x20000ULL /*Remote client by force */ +#define OBD_CONNECT_RMT_CLIENT 0x10000ULL /* Remote client, never used + * in production. Removed in + * 2.9. Keep this flag to + * avoid reuse. + */ +#define OBD_CONNECT_RMT_CLIENT_FORCE 0x20000ULL /* Remote client by force, + * never used in production. + * Removed in 2.9. Keep this + * flag to avoid reuse + */ #define OBD_CONNECT_BRW_SIZE 0x40000ULL /*Max bytes per rpc */ #define OBD_CONNECT_QUOTA64 0x80000ULL /*Not used since 2.4 */ #define OBD_CONNECT_MDS_CAPA 0x100000ULL /*MDS capability */ @@ -1699,7 +1707,7 @@ lov_mds_md_max_stripe_count(size_t buf_size, __u32 lmm_magic) #define OBD_MD_FLXATTRLS (0x0000002000000000ULL) /* xattr list */ #define OBD_MD_FLXATTRRM (0x0000004000000000ULL) /* xattr remove */ #define OBD_MD_FLACL (0x0000008000000000ULL) /* ACL */ -#define OBD_MD_FLRMTPERM (0x0000010000000000ULL) /* remote permission */ +/* OBD_MD_FLRMTPERM (0x0000010000000000ULL) remote perm, obsolete */ #define OBD_MD_FLMDSCAPA (0x0000020000000000ULL) /* MDS capability */ #define OBD_MD_FLOSSCAPA (0x0000040000000000ULL) /* OSS capability */ #define OBD_MD_FLCKSPLIT (0x0000080000000000ULL) /* Check split on server */ @@ -1711,10 +1719,10 @@ lov_mds_md_max_stripe_count(size_t buf_size, __u32 lmm_magic) */ #define OBD_MD_FLOBJCOUNT (0x0000400000000000ULL) /* for multiple destroy */ -#define OBD_MD_FLRMTLSETFACL (0x0001000000000000ULL) /* lfs lsetfacl case */ -#define OBD_MD_FLRMTLGETFACL (0x0002000000000000ULL) /* lfs lgetfacl case */ -#define OBD_MD_FLRMTRSETFACL (0x0004000000000000ULL) /* lfs rsetfacl case */ -#define OBD_MD_FLRMTRGETFACL (0x0008000000000000ULL) /* lfs rgetfacl case */ +/* OBD_MD_FLRMTLSETFACL (0x0001000000000000ULL) lfs lsetfacl, obsolete */ +/* OBD_MD_FLRMTLGETFACL (0x0002000000000000ULL) lfs lgetfacl, obsolete */ +/* OBD_MD_FLRMTRSETFACL (0x0004000000000000ULL) lfs rsetfacl, obsolete */ +/* OBD_MD_FLRMTRGETFACL (0x0008000000000000ULL) lfs rgetfacl, obsolete */ #define OBD_MD_FLDATAVERSION (0x0010000000000000ULL) /* iversion sum */ #define OBD_MD_FLRELEASED (0x0020000000000000ULL) /* file released */ @@ -2155,26 +2163,8 @@ enum { CFS_SETUID_PERM = 0x01, CFS_SETGID_PERM = 0x02, CFS_SETGRP_PERM = 0x04, - CFS_RMTACL_PERM = 0x08, - CFS_RMTOWN_PERM = 0x10 -}; - -/* inode access permission for remote user, the inode info are omitted, - * for client knows them. - */ -struct mdt_remote_perm { - __u32 rp_uid; - __u32 rp_gid; - __u32 rp_fsuid; - __u32 rp_fsuid_h; - __u32 rp_fsgid; - __u32 rp_fsgid_h; - __u32 rp_access_perm; /* MAY_READ/WRITE/EXEC */ - __u32 rp_padding; }; -void lustre_swab_mdt_remote_perm(struct mdt_remote_perm *p); - struct mdt_rec_setattr { __u32 sa_opcode; __u32 sa_cap; diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index a6e351a..ef6f38f 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -211,7 +211,7 @@ struct ost_id { #define IOC_OBD_STATFS _IOWR('f', 164, struct obd_statfs *) #define IOC_LOV_GETINFO _IOWR('f', 165, struct lov_user_mds_data *) #define LL_IOC_FLUSHCTX _IOW('f', 166, long) -#define LL_IOC_RMTACL _IOW('f', 167, long) +/* LL_IOC_RMTACL 167 obsolete */ #define LL_IOC_GETOBDCOUNT _IOR('f', 168, long) #define LL_IOC_LLOOP_ATTACH _IOWR('f', 169, long) #define LL_IOC_LLOOP_DETACH _IOWR('f', 170, long) @@ -538,19 +538,6 @@ struct identity_downcall_data { __u32 idd_groups[0]; }; -/* for non-mapped uid/gid */ -#define NOBODY_UID 99 -#define NOBODY_GID 99 - -#define INVALID_ID (-1) - -enum { - RMT_LSETFACL = 1, - RMT_LGETFACL = 2, - RMT_RSETFACL = 3, - RMT_RGETFACL = 4 -}; - /* lustre volatile file support * file name header: .^L^S^T^R:volatile" */ diff --git a/drivers/staging/lustre/lustre/include/lustre_eacl.h b/drivers/staging/lustre/lustre/include/lustre_eacl.h index e5eadc4..d1039e1 100644 --- a/drivers/staging/lustre/lustre/include/lustre_eacl.h +++ b/drivers/staging/lustre/lustre/include/lustre_eacl.h @@ -66,17 +66,6 @@ typedef struct { #define CFS_ACL_XATTR_COUNT(size, prefix) \ (((size) - sizeof(prefix ## _header)) / sizeof(prefix ## _entry)) -extern ext_acl_xattr_header * -lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size); -extern int -lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size, - posix_acl_xattr_header **out); -extern void -lustre_ext_acl_xattr_free(ext_acl_xattr_header *header); -extern ext_acl_xattr_header * -lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, - ext_acl_xattr_header *ext_header); - #endif /* CONFIG_FS_POSIX_ACL */ /** @} eacl */ diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index 7c3ed55..6e7cc46 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -176,19 +176,6 @@ static inline int exp_connect_lru_resize(struct obd_export *exp) return !!(exp_connect_flags(exp) & OBD_CONNECT_LRU_RESIZE); } -static inline int exp_connect_rmtclient(struct obd_export *exp) -{ - return !!(exp_connect_flags(exp) & OBD_CONNECT_RMT_CLIENT); -} - -static inline int client_is_remote(struct obd_export *exp) -{ - struct obd_import *imp = class_exp2cliimp(exp); - - return !!(imp->imp_connect_data.ocd_connect_flags & - OBD_CONNECT_RMT_CLIENT); -} - static inline int exp_connect_vbr(struct obd_export *exp) { return !!(exp_connect_flags(exp) & OBD_CONNECT_VBR); diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index dba4d1d..bdd2ed5 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -1384,7 +1384,6 @@ struct ptlrpc_request { rq_bulk_write:1, /* request bulk write */ /* server authentication flags */ rq_auth_gss:1, /* authenticated by gss */ - rq_auth_remote:1, /* authed as remote user */ rq_auth_usr_root:1, /* authed as root */ rq_auth_usr_mdt:1, /* authed as mdt */ rq_auth_usr_ost:1, /* authed as ost */ diff --git a/drivers/staging/lustre/lustre/include/lustre_req_layout.h b/drivers/staging/lustre/lustre/include/lustre_req_layout.h index d00aae5..544a43c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_req_layout.h +++ b/drivers/staging/lustre/lustre/include/lustre_req_layout.h @@ -160,7 +160,7 @@ extern struct req_format RQF_MDS_IS_SUBDIR; extern struct req_format RQF_MDS_DONE_WRITING; extern struct req_format RQF_MDS_REINT; extern struct req_format RQF_MDS_REINT_CREATE; -extern struct req_format RQF_MDS_REINT_CREATE_RMT_ACL; +extern struct req_format RQF_MDS_REINT_CREATE_ACL; extern struct req_format RQF_MDS_REINT_CREATE_SLAVE; extern struct req_format RQF_MDS_REINT_CREATE_SYM; extern struct req_format RQF_MDS_REINT_OPEN; diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index e654d42..9971ee5 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -1115,9 +1115,6 @@ struct md_ops { ldlm_policy_data_t *, enum ldlm_mode, enum ldlm_cancel_flags flags, void *opaque); - int (*get_remote_perm)(struct obd_export *, const struct lu_fid *, - __u32, struct ptlrpc_request **); - int (*intent_getattr_async)(struct obd_export *, struct md_enqueue_info *, struct ldlm_enqueue_info *); diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 2196744..6482a93 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -1650,16 +1650,6 @@ static inline int md_init_ea_size(struct obd_export *exp, int easize, cookiesize, def_cookiesize); } -static inline int md_get_remote_perm(struct obd_export *exp, - const struct lu_fid *fid, __u32 suppgid, - struct ptlrpc_request **request) -{ - EXP_CHECK_MD_OP(exp, get_remote_perm); - EXP_MD_COUNTER_INCREMENT(exp, get_remote_perm); - return MDP(exp->exp_obd, get_remote_perm)(exp, fid, suppgid, - request); -} - static inline int md_intent_getattr_async(struct obd_export *exp, struct md_enqueue_info *minfo, struct ldlm_enqueue_info *einfo) diff --git a/drivers/staging/lustre/lustre/llite/Makefile b/drivers/staging/lustre/lustre/llite/Makefile index 19701e7..2cbb1b8 100644 --- a/drivers/staging/lustre/lustre/llite/Makefile +++ b/drivers/staging/lustre/lustre/llite/Makefile @@ -1,8 +1,7 @@ obj-$(CONFIG_LUSTRE_FS) += lustre.o lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \ rw.o namei.o symlink.o llite_mmap.o \ - xattr.o xattr_cache.o remote_perm.o llite_rmtacl.o \ - rw26.o super25.o statahead.o \ + xattr.o xattr_cache.o rw26.o super25.o statahead.o \ glimpse.o lcommon_cl.o lcommon_misc.o \ vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o vvp_req.o \ lproc_llite.o diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 99735f6..2f2c57e 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1097,8 +1097,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) case Q_QUOTAOFF: case Q_SETQUOTA: case Q_SETINFO: - if (!capable(CFS_CAP_SYS_ADMIN) || - sbi->ll_flags & LL_SBI_RMT_CLIENT) + if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; break; case Q_GETQUOTA: @@ -1106,8 +1105,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) !uid_eq(current_euid(), make_kuid(&init_user_ns, id))) || (type == GRPQUOTA && !in_egroup_p(make_kgid(&init_user_ns, id)))) && - (!capable(CFS_CAP_SYS_ADMIN) || - sbi->ll_flags & LL_SBI_RMT_CLIENT)) + !capable(CFS_CAP_SYS_ADMIN)) return -EPERM; break; case Q_GETINFO: @@ -1118,9 +1116,6 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) } if (valid != QC_GENERAL) { - if (sbi->ll_flags & LL_SBI_RMT_CLIENT) - return -EOPNOTSUPP; - if (cmd == Q_GETINFO) qctl->qc_cmd = Q_GETOINFO; else if (cmd == Q_GETQUOTA) @@ -1621,8 +1616,7 @@ free_lmm: struct obd_quotactl *oqctl; int error = 0; - if (!capable(CFS_CAP_SYS_ADMIN) || - sbi->ll_flags & LL_SBI_RMT_CLIENT) + if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS); @@ -1645,8 +1639,7 @@ free_lmm: case OBD_IOC_POLL_QUOTACHECK: { struct if_quotacheck *check; - if (!capable(CFS_CAP_SYS_ADMIN) || - sbi->ll_flags & LL_SBI_RMT_CLIENT) + if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; check = kzalloc(sizeof(*check), GFP_NOFS); @@ -1703,20 +1696,6 @@ out_quotactl: return ll_get_obd_name(inode, cmd, arg); case LL_IOC_FLUSHCTX: return ll_flush_ctx(inode); -#ifdef CONFIG_FS_POSIX_ACL - case LL_IOC_RMTACL: { - if (sbi->ll_flags & LL_SBI_RMT_CLIENT && is_root_inode(inode)) { - struct ll_file_data *fd = LUSTRE_FPRIVATE(file); - - rc = rct_add(&sbi->ll_rct, current_pid(), arg); - if (!rc) - fd->fd_flags |= LL_FILE_RMTACL; - return rc; - } else { - return 0; - } - } -#endif case LL_IOC_GETOBDCOUNT: { int count, vallen; struct obd_export *exp; diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index b0c4548..2d50d1c 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -344,18 +344,6 @@ int ll_file_release(struct inode *inode, struct file *file) CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n", PFID(ll_inode2fid(inode)), inode); -#ifdef CONFIG_FS_POSIX_ACL - if (sbi->ll_flags & LL_SBI_RMT_CLIENT && is_root_inode(inode)) { - struct ll_file_data *fd = LUSTRE_FPRIVATE(file); - - if (unlikely(fd->fd_flags & LL_FILE_RMTACL)) { - fd->fd_flags &= ~LL_FILE_RMTACL; - rct_del(&sbi->ll_rct, current_pid()); - et_search_free(&sbi->ll_et, current_pid()); - } - } -#endif - if (!is_root_inode(inode)) ll_stats_ops_tally(sbi, LPROC_LL_RELEASE, 1); fd = LUSTRE_FPRIVATE(file); @@ -3156,9 +3144,6 @@ int ll_inode_permission(struct inode *inode, int mask) CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), inode mode %x mask %o\n", PFID(ll_inode2fid(inode)), inode, inode->i_mode, mask); - if (ll_i2sbi(inode)->ll_flags & LL_SBI_RMT_CLIENT) - return lustre_check_remote_perm(inode, mask); - ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_INODE_PERM, 1); rc = generic_permission(inode, mask); diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 7c1a3254..8fe63bd 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -72,9 +72,6 @@ struct ll_dentry_data { #define LLI_INODE_MAGIC 0x111d0de5 #define LLI_INODE_DEAD 0xdeadd00d -/* remote client permission cache */ -#define REMOTE_PERM_HASHSIZE 16 - struct ll_getname_data { struct dir_context ctx; char *lgd_name; /* points to a buffer with NAME_MAX+1 size */ @@ -82,19 +79,6 @@ struct ll_getname_data { int lgd_found; /* inode matched? */ }; -/* llite setxid/access permission for user on remote client */ -struct ll_remote_perm { - struct hlist_node lrp_list; - uid_t lrp_uid; - gid_t lrp_gid; - uid_t lrp_fsuid; - gid_t lrp_fsgid; - int lrp_access_perm; /* MAY_READ/WRITE/EXEC, this - * is access permission with - * lrp_fsuid/lrp_fsgid. - */ -}; - struct ll_grouplock { struct lu_env *lg_env; struct cl_io *lg_io; @@ -129,9 +113,6 @@ struct ll_inode_info { spinlock_t lli_lock; struct posix_acl *lli_posix_acl; - struct hlist_head *lli_remote_perms; - struct mutex lli_rmtperm_mutex; - /* identifying fields for both metadata and data stacks. */ struct lu_fid lli_fid; /* Parent fid for accessing default stripe data on parent directory @@ -141,8 +122,6 @@ struct ll_inode_info { struct list_head lli_close_list; - unsigned long lli_rmtperm_time; - /* handle is to be sent to MDS later on done_writing and setattr. * Open handle data are needed for the recovery to reconstruct * the inode state on the MDS. XXX: recovery is not ready yet. @@ -407,7 +386,7 @@ enum stats_track_type { #define LL_SBI_FLOCK 0x04 #define LL_SBI_USER_XATTR 0x08 /* support user xattr */ #define LL_SBI_ACL 0x10 /* support ACL */ -#define LL_SBI_RMT_CLIENT 0x40 /* remote client */ +/* LL_SBI_RMT_CLIENT 0x40 remote client */ #define LL_SBI_MDS_CAPA 0x80 /* support mds capa, obsolete */ #define LL_SBI_OSS_CAPA 0x100 /* support oss capa, obsolete */ #define LL_SBI_LOCALFLOCK 0x200 /* Local flocks support by kernel */ @@ -429,7 +408,7 @@ enum stats_track_type { "xattr", \ "acl", \ "???", \ - "rmt_client", \ + "???", \ "mds_capa", \ "oss_capa", \ "flock", \ @@ -445,26 +424,6 @@ enum stats_track_type { "xattr", \ } -#define RCE_HASHES 32 - -struct rmtacl_ctl_entry { - struct list_head rce_list; - pid_t rce_key; /* hash key */ - int rce_ops; /* acl operation type */ -}; - -struct rmtacl_ctl_table { - spinlock_t rct_lock; - struct list_head rct_entries[RCE_HASHES]; -}; - -#define EE_HASHES 32 - -struct eacl_table { - spinlock_t et_lock; - struct list_head et_entries[EE_HASHES]; -}; - struct ll_sb_info { /* this protects pglist and ra_info. It isn't safe to * grab from interrupt contexts @@ -529,8 +488,6 @@ struct ll_sb_info { dev_t ll_sdev_orig; /* save s_dev before assign for * clustered nfs */ - struct rmtacl_ctl_table ll_rct; - struct eacl_table ll_et; __kernel_fsid_t ll_fsid; struct kobject ll_kobj; /* sysfs object */ struct super_block *ll_sb; /* struct super_block (for sysfs code)*/ @@ -982,14 +939,6 @@ ssize_t ll_getxattr(struct dentry *dentry, struct inode *inode, ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size); int ll_removexattr(struct dentry *dentry, const char *name); -/* llite/remote_perm.c */ -extern struct kmem_cache *ll_remote_perm_cachep; -extern struct kmem_cache *ll_rmtperm_hash_cachep; - -void free_rmtperm_hash(struct hlist_head *hash); -int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm); -int lustre_check_remote_perm(struct inode *inode, int mask); - /** * Common IO arguments for various VFS I/O interfaces. */ @@ -1003,40 +952,7 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len); void ll_ra_stats_inc(struct inode *inode, enum ra_stat which); -/* llite/llite_rmtacl.c */ -#ifdef CONFIG_FS_POSIX_ACL -struct eacl_entry { - struct list_head ee_list; - pid_t ee_key; /* hash key */ - struct lu_fid ee_fid; - int ee_type; /* ACL type for ACCESS or DEFAULT */ - ext_acl_xattr_header *ee_acl; -}; - -u64 rce_ops2valid(int ops); -struct rmtacl_ctl_entry *rct_search(struct rmtacl_ctl_table *rct, pid_t key); -int rct_add(struct rmtacl_ctl_table *rct, pid_t key, int ops); -int rct_del(struct rmtacl_ctl_table *rct, pid_t key); -void rct_init(struct rmtacl_ctl_table *rct); -void rct_fini(struct rmtacl_ctl_table *rct); - -void ee_free(struct eacl_entry *ee); -int ee_add(struct eacl_table *et, pid_t key, struct lu_fid *fid, int type, - ext_acl_xattr_header *header); -struct eacl_entry *et_search_del(struct eacl_table *et, pid_t key, - struct lu_fid *fid, int type); -void et_search_free(struct eacl_table *et, pid_t key); -void et_init(struct eacl_table *et); -void et_fini(struct eacl_table *et); -#else -static inline u64 rce_ops2valid(int ops) -{ - return 0; -} -#endif - /* statahead.c */ - #define LL_SA_RPC_MIN 2 #define LL_SA_RPC_DEF 32 #define LL_SA_RPC_MAX 8192 diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index ac833db..ae6a571 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -171,8 +171,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, OBD_CONNECT_VERSION | OBD_CONNECT_BRW_SIZE | OBD_CONNECT_CANCELSET | OBD_CONNECT_FID | OBD_CONNECT_AT | OBD_CONNECT_LOV_V3 | - OBD_CONNECT_RMT_CLIENT | OBD_CONNECT_VBR | - OBD_CONNECT_FULL20 | OBD_CONNECT_64BITHASH| + OBD_CONNECT_VBR | OBD_CONNECT_FULL20 | + OBD_CONNECT_64BITHASH | OBD_CONNECT_EINPROGRESS | OBD_CONNECT_JOBSTATS | OBD_CONNECT_LVB_TYPE | OBD_CONNECT_LAYOUTLOCK | @@ -213,8 +213,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, /* real client */ data->ocd_connect_flags |= OBD_CONNECT_REAL; - if (sbi->ll_flags & LL_SBI_RMT_CLIENT) - data->ocd_connect_flags |= OBD_CONNECT_RMT_CLIENT_FORCE; data->ocd_brw_size = MD_MAX_BRW_SIZE; @@ -307,18 +305,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, sbi->ll_flags &= ~LL_SBI_ACL; } - if (data->ocd_connect_flags & OBD_CONNECT_RMT_CLIENT) { - if (!(sbi->ll_flags & LL_SBI_RMT_CLIENT)) { - sbi->ll_flags |= LL_SBI_RMT_CLIENT; - LCONSOLE_INFO("client is set as remote by default.\n"); - } - } else { - if (sbi->ll_flags & LL_SBI_RMT_CLIENT) { - sbi->ll_flags &= ~LL_SBI_RMT_CLIENT; - LCONSOLE_INFO("client claims to be remote, but server rejected, forced to be local.\n"); - } - } - if (data->ocd_connect_flags & OBD_CONNECT_64BITHASH) sbi->ll_flags |= LL_SBI_64BIT_HASH; @@ -352,10 +338,9 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, OBD_CONNECT_REQPORTAL | OBD_CONNECT_BRW_SIZE | OBD_CONNECT_CANCELSET | OBD_CONNECT_FID | OBD_CONNECT_SRVLOCK | OBD_CONNECT_TRUNCLOCK| - OBD_CONNECT_AT | OBD_CONNECT_RMT_CLIENT | - OBD_CONNECT_OSS_CAPA | OBD_CONNECT_VBR| - OBD_CONNECT_FULL20 | OBD_CONNECT_64BITHASH | - OBD_CONNECT_MAXBYTES | + OBD_CONNECT_AT | OBD_CONNECT_OSS_CAPA | + OBD_CONNECT_VBR | OBD_CONNECT_FULL20 | + OBD_CONNECT_64BITHASH | OBD_CONNECT_MAXBYTES | OBD_CONNECT_EINPROGRESS | OBD_CONNECT_JOBSTATS | OBD_CONNECT_LVB_TYPE | OBD_CONNECT_LAYOUTLOCK | OBD_CONNECT_PINGLESS; @@ -378,8 +363,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, } data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE; - if (sbi->ll_flags & LL_SBI_RMT_CLIENT) - data->ocd_connect_flags |= OBD_CONNECT_RMT_CLIENT_FORCE; CDEBUG(D_RPCTRACE, "ocd_connect_flags: %#llx ocd_version: %d ocd_grant: %d\n", data->ocd_connect_flags, @@ -442,9 +425,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, * XXX: move this to after cbd setup? */ valid = OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS | OBD_MD_FLMODEASIZE; - if (sbi->ll_flags & LL_SBI_RMT_CLIENT) - valid |= OBD_MD_FLRMTPERM; - else if (sbi->ll_flags & LL_SBI_ACL) + if (sbi->ll_flags & LL_SBI_ACL) valid |= OBD_MD_FLACL; op_data = kzalloc(sizeof(*op_data), GFP_NOFS); @@ -500,13 +481,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, goto out_root; } -#ifdef CONFIG_FS_POSIX_ACL - if (sbi->ll_flags & LL_SBI_RMT_CLIENT) { - rct_init(&sbi->ll_rct); - et_init(&sbi->ll_et); - } -#endif - checksum = sbi->ll_flags & LL_SBI_CHECKSUM; err = obd_set_info_async(NULL, sbi->ll_dt_exp, sizeof(KEY_CHECKSUM), KEY_CHECKSUM, sizeof(checksum), &checksum, @@ -604,13 +578,6 @@ static void client_common_put_super(struct super_block *sb) { struct ll_sb_info *sbi = ll_s2sbi(sb); -#ifdef CONFIG_FS_POSIX_ACL - if (sbi->ll_flags & LL_SBI_RMT_CLIENT) { - et_fini(&sbi->ll_et); - rct_fini(&sbi->ll_rct); - } -#endif - ll_close_thread_shutdown(sbi->ll_lcq); cl_sb_fini(sb); @@ -700,11 +667,6 @@ static int ll_options(char *options, int *flags) *flags &= ~tmp; goto next; } - tmp = ll_set_opt("remote_client", s1, LL_SBI_RMT_CLIENT); - if (tmp) { - *flags |= tmp; - goto next; - } tmp = ll_set_opt("user_fid2path", s1, LL_SBI_USER_FID2PATH); if (tmp) { *flags |= tmp; @@ -788,12 +750,9 @@ void ll_lli_init(struct ll_inode_info *lli) lli->lli_maxbytes = MAX_LFS_FILESIZE; spin_lock_init(&lli->lli_lock); lli->lli_posix_acl = NULL; - lli->lli_remote_perms = NULL; - mutex_init(&lli->lli_rmtperm_mutex); /* Do not set lli_fid, it has been initialized already. */ fid_zero(&lli->lli_pfid); INIT_LIST_HEAD(&lli->lli_close_list); - lli->lli_rmtperm_time = 0; lli->lli_pending_och = NULL; lli->lli_mds_read_och = NULL; lli->lli_mds_write_och = NULL; @@ -1075,17 +1034,9 @@ void ll_clear_inode(struct inode *inode) ll_xattr_cache_destroy(inode); - if (sbi->ll_flags & LL_SBI_RMT_CLIENT) { - LASSERT(!lli->lli_posix_acl); - if (lli->lli_remote_perms) { - free_rmtperm_hash(lli->lli_remote_perms); - lli->lli_remote_perms = NULL; - } - } #ifdef CONFIG_FS_POSIX_ACL - else if (lli->lli_posix_acl) { + if (lli->lli_posix_acl) { LASSERT(atomic_read(&lli->lli_posix_acl->a_refcount) == 1); - LASSERT(!lli->lli_remote_perms); posix_acl_release(lli->lli_posix_acl); lli->lli_posix_acl = NULL; } @@ -1537,12 +1488,8 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) lli->lli_maxbytes = MAX_LFS_FILESIZE; } - if (sbi->ll_flags & LL_SBI_RMT_CLIENT) { - if (body->valid & OBD_MD_FLRMTPERM) - ll_update_remote_perm(inode, md->remote_perm); - } #ifdef CONFIG_FS_POSIX_ACL - else if (body->valid & OBD_MD_FLACL) { + if (body->valid & OBD_MD_FLACL) { spin_lock(&lli->lli_lock); if (lli->lli_posix_acl) posix_acl_release(lli->lli_posix_acl); diff --git a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c deleted file mode 100644 index edb92f9..0000000 --- a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c +++ /dev/null @@ -1,295 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/llite/llite_rmtacl.c - * - * Lustre Remote User Access Control List. - * - * Author: Fan Yong - */ - -#define DEBUG_SUBSYSTEM S_LLITE - -#ifdef CONFIG_FS_POSIX_ACL - -#include "../include/lustre_lite.h" -#include "../include/lustre_eacl.h" -#include "llite_internal.h" - -static inline __u32 rce_hashfunc(uid_t id) -{ - return id & (RCE_HASHES - 1); -} - -static inline __u32 ee_hashfunc(uid_t id) -{ - return id & (EE_HASHES - 1); -} - -u64 rce_ops2valid(int ops) -{ - switch (ops) { - case RMT_LSETFACL: - return OBD_MD_FLRMTLSETFACL; - case RMT_LGETFACL: - return OBD_MD_FLRMTLGETFACL; - case RMT_RSETFACL: - return OBD_MD_FLRMTRSETFACL; - case RMT_RGETFACL: - return OBD_MD_FLRMTRGETFACL; - default: - return 0; - } -} - -static struct rmtacl_ctl_entry *rce_alloc(pid_t key, int ops) -{ - struct rmtacl_ctl_entry *rce; - - rce = kzalloc(sizeof(*rce), GFP_NOFS); - if (!rce) - return NULL; - - INIT_LIST_HEAD(&rce->rce_list); - rce->rce_key = key; - rce->rce_ops = ops; - - return rce; -} - -static void rce_free(struct rmtacl_ctl_entry *rce) -{ - if (!list_empty(&rce->rce_list)) - list_del(&rce->rce_list); - - kfree(rce); -} - -static struct rmtacl_ctl_entry *__rct_search(struct rmtacl_ctl_table *rct, - pid_t key) -{ - struct rmtacl_ctl_entry *rce; - struct list_head *head = &rct->rct_entries[rce_hashfunc(key)]; - - list_for_each_entry(rce, head, rce_list) - if (rce->rce_key == key) - return rce; - - return NULL; -} - -struct rmtacl_ctl_entry *rct_search(struct rmtacl_ctl_table *rct, pid_t key) -{ - struct rmtacl_ctl_entry *rce; - - spin_lock(&rct->rct_lock); - rce = __rct_search(rct, key); - spin_unlock(&rct->rct_lock); - return rce; -} - -int rct_add(struct rmtacl_ctl_table *rct, pid_t key, int ops) -{ - struct rmtacl_ctl_entry *rce, *e; - - rce = rce_alloc(key, ops); - if (!rce) - return -ENOMEM; - - spin_lock(&rct->rct_lock); - e = __rct_search(rct, key); - if (unlikely(e)) { - CWARN("Unexpected stale rmtacl_entry found: [key: %d] [ops: %d]\n", - (int)key, ops); - rce_free(e); - } - list_add_tail(&rce->rce_list, &rct->rct_entries[rce_hashfunc(key)]); - spin_unlock(&rct->rct_lock); - - return 0; -} - -int rct_del(struct rmtacl_ctl_table *rct, pid_t key) -{ - struct rmtacl_ctl_entry *rce; - - spin_lock(&rct->rct_lock); - rce = __rct_search(rct, key); - if (rce) - rce_free(rce); - spin_unlock(&rct->rct_lock); - - return rce ? 0 : -ENOENT; -} - -void rct_init(struct rmtacl_ctl_table *rct) -{ - int i; - - spin_lock_init(&rct->rct_lock); - for (i = 0; i < RCE_HASHES; i++) - INIT_LIST_HEAD(&rct->rct_entries[i]); -} - -void rct_fini(struct rmtacl_ctl_table *rct) -{ - struct rmtacl_ctl_entry *rce; - int i; - - spin_lock(&rct->rct_lock); - for (i = 0; i < RCE_HASHES; i++) - while (!list_empty(&rct->rct_entries[i])) { - rce = list_entry(rct->rct_entries[i].next, - struct rmtacl_ctl_entry, rce_list); - rce_free(rce); - } - spin_unlock(&rct->rct_lock); -} - -static struct eacl_entry *ee_alloc(pid_t key, struct lu_fid *fid, int type, - ext_acl_xattr_header *header) -{ - struct eacl_entry *ee; - - ee = kzalloc(sizeof(*ee), GFP_NOFS); - if (!ee) - return NULL; - - INIT_LIST_HEAD(&ee->ee_list); - ee->ee_key = key; - ee->ee_fid = *fid; - ee->ee_type = type; - ee->ee_acl = header; - - return ee; -} - -void ee_free(struct eacl_entry *ee) -{ - if (!list_empty(&ee->ee_list)) - list_del(&ee->ee_list); - - if (ee->ee_acl) - lustre_ext_acl_xattr_free(ee->ee_acl); - - kfree(ee); -} - -static struct eacl_entry *__et_search_del(struct eacl_table *et, pid_t key, - struct lu_fid *fid, int type) -{ - struct eacl_entry *ee; - struct list_head *head = &et->et_entries[ee_hashfunc(key)]; - - LASSERT(fid); - list_for_each_entry(ee, head, ee_list) - if (ee->ee_key == key) { - if (lu_fid_eq(&ee->ee_fid, fid) && - ee->ee_type == type) { - list_del_init(&ee->ee_list); - return ee; - } - } - - return NULL; -} - -struct eacl_entry *et_search_del(struct eacl_table *et, pid_t key, - struct lu_fid *fid, int type) -{ - struct eacl_entry *ee; - - spin_lock(&et->et_lock); - ee = __et_search_del(et, key, fid, type); - spin_unlock(&et->et_lock); - return ee; -} - -void et_search_free(struct eacl_table *et, pid_t key) -{ - struct eacl_entry *ee, *next; - struct list_head *head = &et->et_entries[ee_hashfunc(key)]; - - spin_lock(&et->et_lock); - list_for_each_entry_safe(ee, next, head, ee_list) - if (ee->ee_key == key) - ee_free(ee); - - spin_unlock(&et->et_lock); -} - -int ee_add(struct eacl_table *et, pid_t key, struct lu_fid *fid, int type, - ext_acl_xattr_header *header) -{ - struct eacl_entry *ee, *e; - - ee = ee_alloc(key, fid, type, header); - if (!ee) - return -ENOMEM; - - spin_lock(&et->et_lock); - e = __et_search_del(et, key, fid, type); - if (unlikely(e)) { - CWARN("Unexpected stale eacl_entry found: [key: %d] [fid: " DFID "] [type: %d]\n", - (int)key, PFID(fid), type); - ee_free(e); - } - list_add_tail(&ee->ee_list, &et->et_entries[ee_hashfunc(key)]); - spin_unlock(&et->et_lock); - - return 0; -} - -void et_init(struct eacl_table *et) -{ - int i; - - spin_lock_init(&et->et_lock); - for (i = 0; i < EE_HASHES; i++) - INIT_LIST_HEAD(&et->et_entries[i]); -} - -void et_fini(struct eacl_table *et) -{ - struct eacl_entry *ee; - int i; - - spin_lock(&et->et_lock); - for (i = 0; i < EE_HASHES; i++) - while (!list_empty(&et->et_entries[i])) { - ee = list_entry(et->et_entries[i].next, - struct eacl_entry, ee_list); - ee_free(ee); - } - spin_unlock(&et->et_lock); -} - -#endif diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 6e9a8a5..18a7775 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -176,11 +176,7 @@ LUSTRE_RO_ATTR(filesfree); static ssize_t client_type_show(struct kobject *kobj, struct attribute *attr, char *buf) { - struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, - ll_kobj); - - return sprintf(buf, "%s client\n", - sbi->ll_flags & LL_SBI_RMT_CLIENT ? "remote" : "local"); + return sprintf(buf, "local client\n"); } LUSTRE_RO_ATTR(client_type); diff --git a/drivers/staging/lustre/lustre/llite/remote_perm.c b/drivers/staging/lustre/lustre/llite/remote_perm.c deleted file mode 100644 index 9df9e784..0000000 --- a/drivers/staging/lustre/lustre/llite/remote_perm.c +++ /dev/null @@ -1,320 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/llite/remote_perm.c - * - * Lustre Permission Cache for Remote Client - * - * Author: Lai Siyao - * Author: Fan Yong - */ - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include - -#include "../include/lustre_lite.h" -#include "../include/lustre_ha.h" -#include "../include/lustre_dlm.h" -#include "../include/lprocfs_status.h" -#include "../include/lustre_disk.h" -#include "../include/lustre_param.h" -#include "llite_internal.h" - -struct kmem_cache *ll_remote_perm_cachep; -struct kmem_cache *ll_rmtperm_hash_cachep; - -static inline struct ll_remote_perm *alloc_ll_remote_perm(void) -{ - struct ll_remote_perm *lrp; - - lrp = kmem_cache_zalloc(ll_remote_perm_cachep, GFP_KERNEL); - if (lrp) - INIT_HLIST_NODE(&lrp->lrp_list); - return lrp; -} - -static inline void free_ll_remote_perm(struct ll_remote_perm *lrp) -{ - if (!lrp) - return; - - if (!hlist_unhashed(&lrp->lrp_list)) - hlist_del(&lrp->lrp_list); - kmem_cache_free(ll_remote_perm_cachep, lrp); -} - -static struct hlist_head *alloc_rmtperm_hash(void) -{ - struct hlist_head *hash; - int i; - - hash = kmem_cache_zalloc(ll_rmtperm_hash_cachep, GFP_NOFS); - if (!hash) - return NULL; - - for (i = 0; i < REMOTE_PERM_HASHSIZE; i++) - INIT_HLIST_HEAD(hash + i); - - return hash; -} - -void free_rmtperm_hash(struct hlist_head *hash) -{ - int i; - struct ll_remote_perm *lrp; - struct hlist_node *next; - - if (!hash) - return; - - for (i = 0; i < REMOTE_PERM_HASHSIZE; i++) - hlist_for_each_entry_safe(lrp, next, hash + i, lrp_list) - free_ll_remote_perm(lrp); - kmem_cache_free(ll_rmtperm_hash_cachep, hash); -} - -static inline int remote_perm_hashfunc(uid_t uid) -{ - return uid & (REMOTE_PERM_HASHSIZE - 1); -} - -/* NB: setxid permission is not checked here, instead it's done on - * MDT when client get remote permission. - */ -static int do_check_remote_perm(struct ll_inode_info *lli, int mask) -{ - struct hlist_head *head; - struct ll_remote_perm *lrp; - int found = 0, rc; - - if (!lli->lli_remote_perms) - return -ENOENT; - - head = lli->lli_remote_perms + - remote_perm_hashfunc(from_kuid(&init_user_ns, current_uid())); - - spin_lock(&lli->lli_lock); - hlist_for_each_entry(lrp, head, lrp_list) { - if (lrp->lrp_uid != from_kuid(&init_user_ns, current_uid())) - continue; - if (lrp->lrp_gid != from_kgid(&init_user_ns, current_gid())) - continue; - if (lrp->lrp_fsuid != from_kuid(&init_user_ns, current_fsuid())) - continue; - if (lrp->lrp_fsgid != from_kgid(&init_user_ns, current_fsgid())) - continue; - found = 1; - break; - } - - if (!found) { - rc = -ENOENT; - goto out; - } - - CDEBUG(D_SEC, "found remote perm: %u/%u/%u/%u - %#x\n", - lrp->lrp_uid, lrp->lrp_gid, lrp->lrp_fsuid, lrp->lrp_fsgid, - lrp->lrp_access_perm); - rc = ((lrp->lrp_access_perm & mask) == mask) ? 0 : -EACCES; - -out: - spin_unlock(&lli->lli_lock); - return rc; -} - -int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) -{ - struct ll_inode_info *lli = ll_i2info(inode); - struct ll_remote_perm *lrp = NULL, *tmp = NULL; - struct hlist_head *head, *perm_hash = NULL; - - LASSERT(ll_i2sbi(inode)->ll_flags & LL_SBI_RMT_CLIENT); - -#if 0 - if (perm->rp_uid != current->uid || - perm->rp_gid != current->gid || - perm->rp_fsuid != current->fsuid || - perm->rp_fsgid != current->fsgid) { - /* user might setxid in this small period */ - CDEBUG(D_SEC, - "remote perm user %u/%u/%u/%u != current %u/%u/%u/%u\n", - perm->rp_uid, perm->rp_gid, perm->rp_fsuid, - perm->rp_fsgid, current->uid, current->gid, - current->fsuid, current->fsgid); - return -EAGAIN; - } -#endif - - if (!lli->lli_remote_perms) { - perm_hash = alloc_rmtperm_hash(); - if (!perm_hash) { - CERROR("alloc lli_remote_perms failed!\n"); - return -ENOMEM; - } - } - - spin_lock(&lli->lli_lock); - - if (!lli->lli_remote_perms) - lli->lli_remote_perms = perm_hash; - else - free_rmtperm_hash(perm_hash); - - head = lli->lli_remote_perms + remote_perm_hashfunc(perm->rp_uid); - -again: - hlist_for_each_entry(tmp, head, lrp_list) { - if (tmp->lrp_uid != perm->rp_uid) - continue; - if (tmp->lrp_gid != perm->rp_gid) - continue; - if (tmp->lrp_fsuid != perm->rp_fsuid) - continue; - if (tmp->lrp_fsgid != perm->rp_fsgid) - continue; - free_ll_remote_perm(lrp); - lrp = tmp; - break; - } - - if (!lrp) { - spin_unlock(&lli->lli_lock); - lrp = alloc_ll_remote_perm(); - if (!lrp) { - CERROR("alloc memory for ll_remote_perm failed!\n"); - return -ENOMEM; - } - spin_lock(&lli->lli_lock); - goto again; - } - - lrp->lrp_access_perm = perm->rp_access_perm; - if (lrp != tmp) { - lrp->lrp_uid = perm->rp_uid; - lrp->lrp_gid = perm->rp_gid; - lrp->lrp_fsuid = perm->rp_fsuid; - lrp->lrp_fsgid = perm->rp_fsgid; - hlist_add_head(&lrp->lrp_list, head); - } - lli->lli_rmtperm_time = cfs_time_current(); - spin_unlock(&lli->lli_lock); - - CDEBUG(D_SEC, "new remote perm@%p: %u/%u/%u/%u - %#x\n", - lrp, lrp->lrp_uid, lrp->lrp_gid, lrp->lrp_fsuid, lrp->lrp_fsgid, - lrp->lrp_access_perm); - - return 0; -} - -int lustre_check_remote_perm(struct inode *inode, int mask) -{ - struct ll_inode_info *lli = ll_i2info(inode); - struct ll_sb_info *sbi = ll_i2sbi(inode); - struct ptlrpc_request *req = NULL; - struct mdt_remote_perm *perm; - unsigned long save; - int i = 0, rc; - - do { - save = lli->lli_rmtperm_time; - rc = do_check_remote_perm(lli, mask); - if (!rc || (rc != -ENOENT && i)) - break; - - might_sleep(); - - mutex_lock(&lli->lli_rmtperm_mutex); - /* check again */ - if (save != lli->lli_rmtperm_time) { - rc = do_check_remote_perm(lli, mask); - if (!rc || (rc != -ENOENT && i)) { - mutex_unlock(&lli->lli_rmtperm_mutex); - break; - } - } - - if (i++ > 5) { - CERROR("check remote perm falls in dead loop!\n"); - LBUG(); - } - - rc = md_get_remote_perm(sbi->ll_md_exp, ll_inode2fid(inode), - ll_i2suppgid(inode), &req); - if (rc) { - mutex_unlock(&lli->lli_rmtperm_mutex); - break; - } - - perm = req_capsule_server_swab_get(&req->rq_pill, &RMF_ACL, - lustre_swab_mdt_remote_perm); - if (unlikely(!perm)) { - mutex_unlock(&lli->lli_rmtperm_mutex); - rc = -EPROTO; - break; - } - - rc = ll_update_remote_perm(inode, perm); - mutex_unlock(&lli->lli_rmtperm_mutex); - if (rc == -ENOMEM) - break; - - ptlrpc_req_finished(req); - req = NULL; - } while (1); - ptlrpc_req_finished(req); - return rc; -} - -#if 0 /* NB: remote perms can't be freed in ll_mdc_blocking_ast of UPDATE lock, - * because it will fail sanity test 48. - */ -void ll_free_remote_perms(struct inode *inode) -{ - struct ll_inode_info *lli = ll_i2info(inode); - struct hlist_head *hash = lli->lli_remote_perms; - struct ll_remote_perm *lrp; - struct hlist_node *node, *next; - int i; - - LASSERT(hash); - - spin_lock(&lli->lli_lock); - - for (i = 0; i < REMOTE_PERM_HASHSIZE; i++) { - hlist_for_each_entry_safe(lrp, node, next, hash + i, lrp_list) - free_ll_remote_perm(lrp); - } - - spin_unlock(&lli->lli_lock); -} -#endif diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index b40ea79..3dd7e0e 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -114,19 +114,6 @@ static int __init lustre_init(void) if (!ll_file_data_slab) goto out_cache; - ll_remote_perm_cachep = kmem_cache_create("ll_remote_perm_cache", - sizeof(struct ll_remote_perm), - 0, 0, NULL); - if (!ll_remote_perm_cachep) - goto out_cache; - - ll_rmtperm_hash_cachep = kmem_cache_create("ll_rmtperm_hash_cache", - REMOTE_PERM_HASHSIZE * - sizeof(struct list_head), - 0, 0, NULL); - if (!ll_rmtperm_hash_cachep) - goto out_cache; - llite_root = debugfs_create_dir("llite", debugfs_lustre_root); if (IS_ERR_OR_NULL(llite_root)) { rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM; @@ -190,8 +177,6 @@ out_debugfs: out_cache: kmem_cache_destroy(ll_inode_cachep); kmem_cache_destroy(ll_file_data_slab); - kmem_cache_destroy(ll_remote_perm_cachep); - kmem_cache_destroy(ll_rmtperm_hash_cachep); return rc; } @@ -209,10 +194,6 @@ static void __exit lustre_exit(void) vvp_global_fini(); kmem_cache_destroy(ll_inode_cachep); - kmem_cache_destroy(ll_rmtperm_hash_cachep); - - kmem_cache_destroy(ll_remote_perm_cachep); - kmem_cache_destroy(ll_file_data_slab); } diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 6ce790e..98303cf 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -107,11 +107,6 @@ int ll_setxattr_common(struct inode *inode, const char *name, struct ll_sb_info *sbi = ll_i2sbi(inode); struct ptlrpc_request *req = NULL; int xattr_type, rc; -#ifdef CONFIG_FS_POSIX_ACL - struct rmtacl_ctl_entry *rce = NULL; - posix_acl_xattr_header *new_value = NULL; - ext_acl_xattr_header *acl = NULL; -#endif const char *pv = value; xattr_type = get_xattr_type(name); @@ -139,62 +134,9 @@ int ll_setxattr_common(struct inode *inode, const char *name, strcmp(name, "security.selinux") == 0) return -EOPNOTSUPP; -#ifdef CONFIG_FS_POSIX_ACL - if (sbi->ll_flags & LL_SBI_RMT_CLIENT && - (xattr_type == XATTR_ACL_ACCESS_T || - xattr_type == XATTR_ACL_DEFAULT_T)) { - rce = rct_search(&sbi->ll_rct, current_pid()); - if (!rce || - (rce->rce_ops != RMT_LSETFACL && - rce->rce_ops != RMT_RSETFACL)) - return -EOPNOTSUPP; - - if (rce->rce_ops == RMT_LSETFACL) { - struct eacl_entry *ee; - - ee = et_search_del(&sbi->ll_et, current_pid(), - ll_inode2fid(inode), xattr_type); - if (valid & OBD_MD_FLXATTR) { - acl = lustre_acl_xattr_merge2ext( - (posix_acl_xattr_header *)value, - size, ee->ee_acl); - if (IS_ERR(acl)) { - ee_free(ee); - return PTR_ERR(acl); - } - size = CFS_ACL_XATTR_SIZE(\ - le32_to_cpu(acl->a_count), \ - ext_acl_xattr); - pv = (const char *)acl; - } - ee_free(ee); - } else if (rce->rce_ops == RMT_RSETFACL) { - rc = lustre_posix_acl_xattr_filter( - (posix_acl_xattr_header *)value, - size, &new_value); - if (unlikely(rc < 0)) - return rc; - size = rc; - - pv = (const char *)new_value; - } else { - return -EOPNOTSUPP; - } - - valid |= rce_ops2valid(rce->rce_ops); - } -#endif rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, name, pv, size, 0, flags, ll_i2suppgid(inode), &req); -#ifdef CONFIG_FS_POSIX_ACL - /* - * Release the posix ACL space. - */ - kfree(new_value); - if (acl) - lustre_ext_acl_xattr_free(acl); -#endif if (rc) { if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) { LCONSOLE_INFO("Disabling user_xattr feature because it is not supported on the server\n"); @@ -284,7 +226,6 @@ int ll_getxattr_common(struct inode *inode, const char *name, struct mdt_body *body; int xattr_type, rc; void *xdata; - struct rmtacl_ctl_entry *rce = NULL; struct ll_inode_info *lli = ll_i2info(inode); CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n", @@ -315,24 +256,11 @@ int ll_getxattr_common(struct inode *inode, const char *name, return -EOPNOTSUPP; #ifdef CONFIG_FS_POSIX_ACL - if (sbi->ll_flags & LL_SBI_RMT_CLIENT && - (xattr_type == XATTR_ACL_ACCESS_T || - xattr_type == XATTR_ACL_DEFAULT_T)) { - rce = rct_search(&sbi->ll_rct, current_pid()); - if (!rce || - (rce->rce_ops != RMT_LSETFACL && - rce->rce_ops != RMT_LGETFACL && - rce->rce_ops != RMT_RSETFACL && - rce->rce_ops != RMT_RGETFACL)) - return -EOPNOTSUPP; - } - /* posix acl is under protection of LOOKUP lock. when calling to this, * we just have path resolution to the target inode, so we have great * chance that cached ACL is uptodate. */ - if (xattr_type == XATTR_ACL_ACCESS_T && - !(sbi->ll_flags & LL_SBI_RMT_CLIENT)) { + if (xattr_type == XATTR_ACL_ACCESS_T) { struct posix_acl *acl; spin_lock(&lli->lli_lock); @@ -374,9 +302,7 @@ do_getxattr: } else { getxattr_nocache: rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), - valid | (rce ? rce_ops2valid(rce->rce_ops) : 0), - name, NULL, 0, size, 0, &req); - + valid, name, NULL, 0, size, 0, &req); if (rc < 0) goto out_xattr; @@ -413,25 +339,6 @@ getxattr_nocache: rc = body->eadatasize; } -#ifdef CONFIG_FS_POSIX_ACL - if (rce && rce->rce_ops == RMT_LSETFACL) { - ext_acl_xattr_header *acl; - - acl = lustre_posix_acl_xattr_2ext(buffer, rc); - if (IS_ERR(acl)) { - rc = PTR_ERR(acl); - goto out; - } - - rc = ee_add(&sbi->ll_et, current_pid(), ll_inode2fid(inode), - xattr_type, acl); - if (unlikely(rc < 0)) { - lustre_ext_acl_xattr_free(acl); - goto out; - } - } -#endif - out_xattr: if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) { LCONSOLE_INFO( diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index ab4f4fb..6483f2c 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -2607,27 +2607,6 @@ static int lmv_clear_open_replay_data(struct obd_export *exp, return md_clear_open_replay_data(tgt->ltd_exp, och); } -static int lmv_get_remote_perm(struct obd_export *exp, - const struct lu_fid *fid, - __u32 suppgid, struct ptlrpc_request **request) -{ - struct obd_device *obd = exp->exp_obd; - struct lmv_obd *lmv = &obd->u.lmv; - struct lmv_tgt_desc *tgt; - int rc; - - rc = lmv_check_connect(obd); - if (rc) - return rc; - - tgt = lmv_find_target(lmv, fid); - if (IS_ERR(tgt)) - return PTR_ERR(tgt); - - rc = md_get_remote_perm(tgt->ltd_exp, fid, suppgid, request); - return rc; -} - static int lmv_intent_getattr_async(struct obd_export *exp, struct md_enqueue_info *minfo, struct ldlm_enqueue_info *einfo) @@ -2791,7 +2770,6 @@ static struct md_ops lmv_md_ops = { .free_lustre_md = lmv_free_lustre_md, .set_open_replay_data = lmv_set_open_replay_data, .clear_open_replay_data = lmv_clear_open_replay_data, - .get_remote_perm = lmv_get_remote_perm, .intent_getattr_async = lmv_intent_getattr_async, .revalidate_lock = lmv_revalidate_lock }; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index b395420..d55a5d8 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -343,10 +343,6 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp, mdc_open_pack(req, op_data, it->it_create_mode, 0, it->it_flags, lmm, lmmsize); - /* for remote client, fetch remote perm for current user */ - if (client_is_remote(exp)) - req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, - sizeof(struct mdt_remote_perm)); ptlrpc_request_set_replen(req); return req; } @@ -440,9 +436,7 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, struct obd_device *obddev = class_exp2obd(exp); u64 valid = OBD_MD_FLGETATTR | OBD_MD_FLEASIZE | OBD_MD_FLMODEASIZE | OBD_MD_FLDIREA | - OBD_MD_MEA | - (client_is_remote(exp) ? - OBD_MD_FLRMTPERM : OBD_MD_FLACL); + OBD_MD_MEA | OBD_MD_FLACL; struct ldlm_intent *lit; int rc; int easize; @@ -474,9 +468,6 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, mdc_getattr_pack(req, valid, it->it_flags, op_data, easize); req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, easize); - if (client_is_remote(exp)) - req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, - sizeof(struct mdt_remote_perm)); ptlrpc_request_set_replen(req); return req; } @@ -683,16 +674,6 @@ static int mdc_finish_enqueue(struct obd_export *exp, memcpy(lmm, eadata, body->eadatasize); } } - - if (body->valid & OBD_MD_FLRMTPERM) { - struct mdt_remote_perm *perm; - - LASSERT(client_is_remote(exp)); - perm = req_capsule_server_swab_get(pill, &RMF_ACL, - lustre_swab_mdt_remote_perm); - if (!perm) - return -EPROTO; - } } else if (it->it_op & IT_LAYOUT) { /* maybe the lock was granted right away and layout * is packed into RMF_DLM_LVB of req diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index 661488e..5dba2c8 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -230,7 +230,7 @@ rebuild: MDS_INODELOCK_UPDATE); req = ptlrpc_request_alloc(class_exp2cliimp(exp), - &RQF_MDS_REINT_CREATE_RMT_ACL); + &RQF_MDS_REINT_CREATE_ACL); if (!req) { ldlm_lock_list_put(&cancels, l_bl_ast, count); return -ENOMEM; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index f371e1d..f7e30b1 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -146,16 +146,6 @@ static int mdc_getattr_common(struct obd_export *exp, return -EPROTO; } - if (body->valid & OBD_MD_FLRMTPERM) { - struct mdt_remote_perm *perm; - - LASSERT(client_is_remote(exp)); - perm = req_capsule_server_swab_get(pill, &RMF_ACL, - lustre_swab_mdt_remote_perm); - if (!perm) - return -EPROTO; - } - return 0; } @@ -186,11 +176,6 @@ static int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data, req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, op_data->op_mode); - if (op_data->op_valid & OBD_MD_FLRMTPERM) { - LASSERT(client_is_remote(exp)); - req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, - sizeof(struct mdt_remote_perm)); - } ptlrpc_request_set_replen(req); rc = mdc_getattr_common(exp, req); @@ -535,16 +520,7 @@ static int mdc_get_lustre_md(struct obd_export *exp, } rc = 0; - if (md->body->valid & OBD_MD_FLRMTPERM) { - /* remote permission */ - LASSERT(client_is_remote(exp)); - md->remote_perm = req_capsule_server_swab_get(pill, &RMF_ACL, - lustre_swab_mdt_remote_perm); - if (!md->remote_perm) { - rc = -EPROTO; - goto out; - } - } else if (md->body->valid & OBD_MD_FLACL) { + if (md->body->valid & OBD_MD_FLACL) { /* for ACL, it's possible that FLACL is set but aclsize is zero. * only when aclsize != 0 there's an actual segment for ACL * in reply buffer. @@ -1164,7 +1140,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp, goto out; } - mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, -1, 0); + mdc_pack_body(req, NULL, 0, 0, -1, 0); /* Copy hsm_progress struct */ req_hpk = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_PROGRESS); @@ -1198,7 +1174,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives) goto out; } - mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, -1, 0); + mdc_pack_body(req, NULL, 0, 0, -1, 0); /* Copy hsm_progress struct */ archive_mask = req_capsule_client_get(&req->rq_pill, @@ -1237,7 +1213,7 @@ static int mdc_ioc_hsm_current_action(struct obd_export *exp, return rc; } - mdc_pack_body(req, &op_data->op_fid1, OBD_MD_FLRMTPERM, 0, + mdc_pack_body(req, &op_data->op_fid1, 0, 0, op_data->op_suppgids[0], 0); ptlrpc_request_set_replen(req); @@ -1273,7 +1249,7 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp) goto out; } - mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, -1, 0); + mdc_pack_body(req, NULL, 0, 0, -1, 0); ptlrpc_request_set_replen(req); @@ -1302,7 +1278,7 @@ static int mdc_ioc_hsm_state_get(struct obd_export *exp, return rc; } - mdc_pack_body(req, &op_data->op_fid1, OBD_MD_FLRMTPERM, 0, + mdc_pack_body(req, &op_data->op_fid1, 0, 0, op_data->op_suppgids[0], 0); ptlrpc_request_set_replen(req); @@ -1343,7 +1319,7 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp, return rc; } - mdc_pack_body(req, &op_data->op_fid1, OBD_MD_FLRMTPERM, 0, + mdc_pack_body(req, &op_data->op_fid1, 0, 0, op_data->op_suppgids[0], 0); /* Copy states */ @@ -1390,7 +1366,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, return rc; } - mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, -1, 0); + mdc_pack_body(req, NULL, 0, 0, -1, 0); /* Copy hsm_request struct */ req_hr = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_REQUEST); @@ -2428,41 +2404,6 @@ static int mdc_process_config(struct obd_device *obd, u32 len, void *buf) return rc; } -/* get remote permission for current user on fid */ -static int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid, - __u32 suppgid, struct ptlrpc_request **request) -{ - struct ptlrpc_request *req; - int rc; - - LASSERT(client_is_remote(exp)); - - *request = NULL; - req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR); - if (!req) - return -ENOMEM; - - rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR); - if (rc) { - ptlrpc_request_free(req); - return rc; - } - - mdc_pack_body(req, fid, OBD_MD_FLRMTPERM, 0, suppgid, 0); - - req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, - sizeof(struct mdt_remote_perm)); - - ptlrpc_request_set_replen(req); - - rc = ptlrpc_queue_wait(req); - if (rc) - ptlrpc_req_finished(req); - else - *request = req; - return rc; -} - static struct obd_ops mdc_obd_ops = { .owner = THIS_MODULE, .setup = mdc_setup, @@ -2514,7 +2455,6 @@ static struct md_ops mdc_md_ops = { .free_lustre_md = mdc_free_lustre_md, .set_open_replay_data = mdc_set_open_replay_data, .clear_open_replay_data = mdc_clear_open_replay_data, - .get_remote_perm = mdc_get_remote_perm, .intent_getattr_async = mdc_intent_getattr_async, .revalidate_lock = mdc_revalidate_lock }; diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index c404eb3..df7e47f 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -5,5 +5,4 @@ obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \ genops.o uuid.o lprocfs_status.o lprocfs_counters.o \ lustre_handles.o lustre_peer.o statfs_pack.o \ obdo.o obd_config.o obd_mount.o lu_object.o lu_ref.o \ - cl_object.o cl_page.o cl_lock.o cl_io.o \ - acl.o kernelcomm.o + cl_object.o cl_page.o cl_lock.o cl_io.o kernelcomm.o diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c deleted file mode 100644 index 30d8b42..0000000 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ /dev/null @@ -1,411 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/obdclass/acl.c - * - * Lustre Access Control List. - * - * Author: Fan Yong - */ - -#define DEBUG_SUBSYSTEM S_SEC -#include "../include/lu_object.h" -#include "../include/lustre_acl.h" -#include "../include/lustre_eacl.h" -#include "../include/obd_support.h" - -#ifdef CONFIG_FS_POSIX_ACL - -#define CFS_ACL_XATTR_VERSION POSIX_ACL_XATTR_VERSION - -enum { - ES_UNK = 0, /* unknown stat */ - ES_UNC = 1, /* ACL entry is not changed */ - ES_MOD = 2, /* ACL entry is modified */ - ES_ADD = 3, /* ACL entry is added */ - ES_DEL = 4 /* ACL entry is deleted */ -}; - -static inline void lustre_ext_acl_le_to_cpu(ext_acl_xattr_entry *d, - ext_acl_xattr_entry *s) -{ - d->e_tag = le16_to_cpu(s->e_tag); - d->e_perm = le16_to_cpu(s->e_perm); - d->e_id = le32_to_cpu(s->e_id); - d->e_stat = le32_to_cpu(s->e_stat); -} - -static inline void lustre_ext_acl_cpu_to_le(ext_acl_xattr_entry *d, - ext_acl_xattr_entry *s) -{ - d->e_tag = cpu_to_le16(s->e_tag); - d->e_perm = cpu_to_le16(s->e_perm); - d->e_id = cpu_to_le32(s->e_id); - d->e_stat = cpu_to_le32(s->e_stat); -} - -static inline void lustre_posix_acl_le_to_cpu(posix_acl_xattr_entry *d, - posix_acl_xattr_entry *s) -{ - d->e_tag = le16_to_cpu(s->e_tag); - d->e_perm = le16_to_cpu(s->e_perm); - d->e_id = le32_to_cpu(s->e_id); -} - -static inline void lustre_posix_acl_cpu_to_le(posix_acl_xattr_entry *d, - posix_acl_xattr_entry *s) -{ - d->e_tag = cpu_to_le16(s->e_tag); - d->e_perm = cpu_to_le16(s->e_perm); - d->e_id = cpu_to_le32(s->e_id); -} - -/* if "new_count == 0", then "new = {a_version, NULL}", NOT NULL. */ -static int lustre_posix_acl_xattr_reduce_space(posix_acl_xattr_header **header, - int old_count, int new_count) -{ - int old_size = CFS_ACL_XATTR_SIZE(old_count, posix_acl_xattr); - int new_size = CFS_ACL_XATTR_SIZE(new_count, posix_acl_xattr); - posix_acl_xattr_header *new; - - if (unlikely(old_count <= new_count)) - return old_size; - - new = kmemdup(*header, new_size, GFP_NOFS); - if (unlikely(!new)) - return -ENOMEM; - - kfree(*header); - *header = new; - return new_size; -} - -/* if "new_count == 0", then "new = {0, NULL}", NOT NULL. */ -static int lustre_ext_acl_xattr_reduce_space(ext_acl_xattr_header **header, - int old_count) -{ - int ext_count = le32_to_cpu((*header)->a_count); - int ext_size = CFS_ACL_XATTR_SIZE(ext_count, ext_acl_xattr); - ext_acl_xattr_header *new; - - if (unlikely(old_count <= ext_count)) - return 0; - - new = kmemdup(*header, ext_size, GFP_NOFS); - if (unlikely(!new)) - return -ENOMEM; - - kfree(*header); - *header = new; - return 0; -} - -/* - * Generate new extended ACL based on the posix ACL. - */ -ext_acl_xattr_header * -lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size) -{ - int count, i, esize; - ext_acl_xattr_header *new; - - if (unlikely(size < 0)) - return ERR_PTR(-EINVAL); - else if (!size) - count = 0; - else - count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr); - esize = CFS_ACL_XATTR_SIZE(count, ext_acl_xattr); - new = kzalloc(esize, GFP_NOFS); - if (unlikely(!new)) - return ERR_PTR(-ENOMEM); - - new->a_count = cpu_to_le32(count); - for (i = 0; i < count; i++) { - new->a_entries[i].e_tag = header->a_entries[i].e_tag; - new->a_entries[i].e_perm = header->a_entries[i].e_perm; - new->a_entries[i].e_id = header->a_entries[i].e_id; - new->a_entries[i].e_stat = cpu_to_le32(ES_UNK); - } - - return new; -} -EXPORT_SYMBOL(lustre_posix_acl_xattr_2ext); - -/* - * Filter out the "nobody" entries in the posix ACL. - */ -int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size, - posix_acl_xattr_header **out) -{ - int count, i, j, rc = 0; - __u32 id; - posix_acl_xattr_header *new; - - if (!size) - return 0; - if (size < sizeof(*new)) - return -EINVAL; - - new = kzalloc(size, GFP_NOFS); - if (unlikely(!new)) - return -ENOMEM; - - new->a_version = cpu_to_le32(CFS_ACL_XATTR_VERSION); - count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr); - for (i = 0, j = 0; i < count; i++) { - id = le32_to_cpu(header->a_entries[i].e_id); - switch (le16_to_cpu(header->a_entries[i].e_tag)) { - case ACL_USER_OBJ: - case ACL_GROUP_OBJ: - case ACL_MASK: - case ACL_OTHER: - if (id != ACL_UNDEFINED_ID) { - rc = -EIO; - goto _out; - } - - memcpy(&new->a_entries[j++], &header->a_entries[i], - sizeof(posix_acl_xattr_entry)); - break; - case ACL_USER: - if (id != NOBODY_UID) - memcpy(&new->a_entries[j++], - &header->a_entries[i], - sizeof(posix_acl_xattr_entry)); - break; - case ACL_GROUP: - if (id != NOBODY_GID) - memcpy(&new->a_entries[j++], - &header->a_entries[i], - sizeof(posix_acl_xattr_entry)); - break; - default: - rc = -EIO; - goto _out; - } - } - - /* free unused space. */ - rc = lustre_posix_acl_xattr_reduce_space(&new, count, j); - if (rc >= 0) { - size = rc; - *out = new; - rc = 0; - } - -_out: - if (rc) { - kfree(new); - size = rc; - } - return size; -} -EXPORT_SYMBOL(lustre_posix_acl_xattr_filter); - -/* - * Release the extended ACL space. - */ -void lustre_ext_acl_xattr_free(ext_acl_xattr_header *header) -{ - kfree(header); -} -EXPORT_SYMBOL(lustre_ext_acl_xattr_free); - -static ext_acl_xattr_entry * -lustre_ext_acl_xattr_search(ext_acl_xattr_header *header, - posix_acl_xattr_entry *entry, int *pos) -{ - int once, start, end, i, j, count = le32_to_cpu(header->a_count); - - once = 0; - start = *pos; - end = count; - -again: - for (i = start; i < end; i++) { - if (header->a_entries[i].e_tag == entry->e_tag && - header->a_entries[i].e_id == entry->e_id) { - j = i; - if (++i >= count) - i = 0; - *pos = i; - return &header->a_entries[j]; - } - } - - if (!once) { - once = 1; - start = 0; - end = *pos; - goto again; - } - - return NULL; -} - -/* - * Merge the posix ACL and the extended ACL into new extended ACL. - */ -ext_acl_xattr_header * -lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, - ext_acl_xattr_header *ext_header) -{ - int ori_ext_count, posix_count, ext_count, ext_size; - int i, j, pos = 0, rc = 0; - posix_acl_xattr_entry pae; - ext_acl_xattr_header *new; - ext_acl_xattr_entry *ee, eae; - - if (unlikely(size < 0)) - return ERR_PTR(-EINVAL); - else if (!size) - posix_count = 0; - else - posix_count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr); - ori_ext_count = le32_to_cpu(ext_header->a_count); - ext_count = posix_count + ori_ext_count; - ext_size = CFS_ACL_XATTR_SIZE(ext_count, ext_acl_xattr); - - new = kzalloc(ext_size, GFP_NOFS); - if (unlikely(!new)) - return ERR_PTR(-ENOMEM); - - for (i = 0, j = 0; i < posix_count; i++) { - lustre_posix_acl_le_to_cpu(&pae, &posix_header->a_entries[i]); - switch (pae.e_tag) { - case ACL_USER_OBJ: - case ACL_GROUP_OBJ: - case ACL_MASK: - case ACL_OTHER: - if (pae.e_id != ACL_UNDEFINED_ID) { - rc = -EIO; - goto out; - } - case ACL_USER: - /* ignore "nobody" entry. */ - if (pae.e_id == NOBODY_UID) - break; - - new->a_entries[j].e_tag = - posix_header->a_entries[i].e_tag; - new->a_entries[j].e_perm = - posix_header->a_entries[i].e_perm; - new->a_entries[j].e_id = - posix_header->a_entries[i].e_id; - ee = lustre_ext_acl_xattr_search(ext_header, - &posix_header->a_entries[i], &pos); - if (ee) { - if (posix_header->a_entries[i].e_perm != - ee->e_perm) - /* entry modified. */ - ee->e_stat = - new->a_entries[j++].e_stat = - cpu_to_le32(ES_MOD); - else - /* entry unchanged. */ - ee->e_stat = - new->a_entries[j++].e_stat = - cpu_to_le32(ES_UNC); - } else { - /* new entry. */ - new->a_entries[j++].e_stat = - cpu_to_le32(ES_ADD); - } - break; - case ACL_GROUP: - /* ignore "nobody" entry. */ - if (pae.e_id == NOBODY_GID) - break; - new->a_entries[j].e_tag = - posix_header->a_entries[i].e_tag; - new->a_entries[j].e_perm = - posix_header->a_entries[i].e_perm; - new->a_entries[j].e_id = - posix_header->a_entries[i].e_id; - ee = lustre_ext_acl_xattr_search(ext_header, - &posix_header->a_entries[i], &pos); - if (ee) { - if (posix_header->a_entries[i].e_perm != - ee->e_perm) - /* entry modified. */ - ee->e_stat = - new->a_entries[j++].e_stat = - cpu_to_le32(ES_MOD); - else - /* entry unchanged. */ - ee->e_stat = - new->a_entries[j++].e_stat = - cpu_to_le32(ES_UNC); - } else { - /* new entry. */ - new->a_entries[j++].e_stat = - cpu_to_le32(ES_ADD); - } - break; - default: - rc = -EIO; - goto out; - } - } - - /* process deleted entries. */ - for (i = 0; i < ori_ext_count; i++) { - lustre_ext_acl_le_to_cpu(&eae, &ext_header->a_entries[i]); - if (eae.e_stat == ES_UNK) { - /* ignore "nobody" entry. */ - if ((eae.e_tag == ACL_USER && eae.e_id == NOBODY_UID) || - (eae.e_tag == ACL_GROUP && eae.e_id == NOBODY_GID)) - continue; - - new->a_entries[j].e_tag = - ext_header->a_entries[i].e_tag; - new->a_entries[j].e_perm = - ext_header->a_entries[i].e_perm; - new->a_entries[j].e_id = ext_header->a_entries[i].e_id; - new->a_entries[j++].e_stat = cpu_to_le32(ES_DEL); - } - } - - new->a_count = cpu_to_le32(j); - /* free unused space. */ - rc = lustre_ext_acl_xattr_reduce_space(&new, ext_count); - -out: - if (rc) { - kfree(new); - new = ERR_PTR(rc); - } - return new; -} -EXPORT_SYMBOL(lustre_acl_xattr_merge2ext); - -#endif diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 1a6df43..4c78b53 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -2367,7 +2367,7 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, oap->oap_obj_off = offset; LASSERT(!(offset & ~PAGE_MASK)); - if (!client_is_remote(exp) && capable(CFS_CAP_SYS_RESOURCE)) + if (capable(CFS_CAP_SYS_RESOURCE)) oap->oap_brw_flags = OBD_BRW_NOQUOTA; INIT_LIST_HEAD(&oap->oap_pending_item); @@ -2406,8 +2406,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, /* Set the OBD_BRW_SRVLOCK before the page is queued. */ brw_flags |= ops->ops_srvlock ? OBD_BRW_SRVLOCK : 0; - if (!client_is_remote(osc_export(osc)) && - capable(CFS_CAP_SYS_RESOURCE)) { + if (capable(CFS_CAP_SYS_RESOURCE)) { brw_flags |= OBD_BRW_NOQUOTA; cmd |= OBD_BRW_NOQUOTA; } diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 57d8a5a..18c261b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -357,7 +357,6 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, enum cl_req_type crt, int brw_flags) { struct osc_async_page *oap = &opg->ops_oap; - struct osc_object *obj = oap->oap_obj; LASSERTF(oap->oap_magic == OAP_MAGIC, "Bad oap magic: oap %p, magic 0x%x\n", oap, oap->oap_magic); @@ -372,8 +371,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, if (osc_over_unstable_soft_limit(oap->oap_cli)) oap->oap_brw_flags |= OBD_BRW_SOFT_SYNC; - if (!client_is_remote(osc_export(obj)) && - capable(CFS_CAP_SYS_RESOURCE)) { + if (capable(CFS_CAP_SYS_RESOURCE)) { oap->oap_brw_flags |= OBD_BRW_NOQUOTA; oap->oap_cmd |= OBD_BRW_NOQUOTA; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c index e6ff97d..ab5d851 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/layout.c +++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c @@ -194,7 +194,7 @@ static const struct req_msg_field *mds_reint_create_slave_client[] = { &RMF_DLM_REQ }; -static const struct req_msg_field *mds_reint_create_rmt_acl_client[] = { +static const struct req_msg_field *mds_reint_create_acl_client[] = { &RMF_PTLRPC_BODY, &RMF_REC_REINT, &RMF_CAPA1, @@ -675,7 +675,7 @@ static struct req_format *req_formats[] = { &RQF_MDS_DONE_WRITING, &RQF_MDS_REINT, &RQF_MDS_REINT_CREATE, - &RQF_MDS_REINT_CREATE_RMT_ACL, + &RQF_MDS_REINT_CREATE_ACL, &RQF_MDS_REINT_CREATE_SLAVE, &RQF_MDS_REINT_CREATE_SYM, &RQF_MDS_REINT_OPEN, @@ -1238,10 +1238,10 @@ struct req_format RQF_MDS_REINT_CREATE = mds_reint_create_client, mdt_body_capa); EXPORT_SYMBOL(RQF_MDS_REINT_CREATE); -struct req_format RQF_MDS_REINT_CREATE_RMT_ACL = - DEFINE_REQ_FMT0("MDS_REINT_CREATE_RMT_ACL", - mds_reint_create_rmt_acl_client, mdt_body_capa); -EXPORT_SYMBOL(RQF_MDS_REINT_CREATE_RMT_ACL); +struct req_format RQF_MDS_REINT_CREATE_ACL = + DEFINE_REQ_FMT0("MDS_REINT_CREATE_ACL", + mds_reint_create_acl_client, mdt_body_capa); +EXPORT_SYMBOL(RQF_MDS_REINT_CREATE_ACL); struct req_format RQF_MDS_REINT_CREATE_SLAVE = DEFINE_REQ_FMT0("MDS_REINT_CREATE_EA", diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 9ff58a1..b514f18 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -1802,19 +1802,6 @@ void lustre_swab_obd_quotactl(struct obd_quotactl *q) } EXPORT_SYMBOL(lustre_swab_obd_quotactl); -void lustre_swab_mdt_remote_perm(struct mdt_remote_perm *p) -{ - __swab32s(&p->rp_uid); - __swab32s(&p->rp_gid); - __swab32s(&p->rp_fsuid); - __swab32s(&p->rp_fsuid_h); - __swab32s(&p->rp_fsgid); - __swab32s(&p->rp_fsgid_h); - __swab32s(&p->rp_access_perm); - __swab32s(&p->rp_padding); -}; -EXPORT_SYMBOL(lustre_swab_mdt_remote_perm); - void lustre_swab_fid2path(struct getinfo_fid2path *gf) { lustre_swab_lu_fid(&gf->gf_fid); diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c index 9fd9de9..6cc2b2e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c +++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c @@ -1265,8 +1265,6 @@ void lustre_assert_wire_constants(void) OBD_MD_FLXATTRRM); LASSERTF(OBD_MD_FLACL == (0x0000008000000000ULL), "found 0x%.16llxULL\n", OBD_MD_FLACL); - LASSERTF(OBD_MD_FLRMTPERM == (0x0000010000000000ULL), "found 0x%.16llxULL\n", - OBD_MD_FLRMTPERM); LASSERTF(OBD_MD_FLMDSCAPA == (0x0000020000000000ULL), "found 0x%.16llxULL\n", OBD_MD_FLMDSCAPA); LASSERTF(OBD_MD_FLOSSCAPA == (0x0000040000000000ULL), "found 0x%.16llxULL\n", @@ -1277,14 +1275,6 @@ void lustre_assert_wire_constants(void) OBD_MD_FLCROSSREF); LASSERTF(OBD_MD_FLGETATTRLOCK == (0x0000200000000000ULL), "found 0x%.16llxULL\n", OBD_MD_FLGETATTRLOCK); - LASSERTF(OBD_MD_FLRMTLSETFACL == (0x0001000000000000ULL), "found 0x%.16llxULL\n", - OBD_MD_FLRMTLSETFACL); - LASSERTF(OBD_MD_FLRMTLGETFACL == (0x0002000000000000ULL), "found 0x%.16llxULL\n", - OBD_MD_FLRMTLGETFACL); - LASSERTF(OBD_MD_FLRMTRSETFACL == (0x0004000000000000ULL), "found 0x%.16llxULL\n", - OBD_MD_FLRMTRSETFACL); - LASSERTF(OBD_MD_FLRMTRGETFACL == (0x0008000000000000ULL), "found 0x%.16llxULL\n", - OBD_MD_FLRMTRGETFACL); LASSERTF(OBD_MD_FLDATAVERSION == (0x0010000000000000ULL), "found 0x%.16llxULL\n", OBD_MD_FLDATAVERSION); CLASSERT(OBD_FL_INLINEDATA == 0x00000001); @@ -1891,44 +1881,6 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct mdt_ioepoch *)0)->padding) == 4, "found %lld\n", (long long)(int)sizeof(((struct mdt_ioepoch *)0)->padding)); - /* Checks for struct mdt_remote_perm */ - LASSERTF((int)sizeof(struct mdt_remote_perm) == 32, "found %lld\n", - (long long)(int)sizeof(struct mdt_remote_perm)); - LASSERTF((int)offsetof(struct mdt_remote_perm, rp_uid) == 0, "found %lld\n", - (long long)(int)offsetof(struct mdt_remote_perm, rp_uid)); - LASSERTF((int)sizeof(((struct mdt_remote_perm *)0)->rp_uid) == 4, "found %lld\n", - (long long)(int)sizeof(((struct mdt_remote_perm *)0)->rp_uid)); - LASSERTF((int)offsetof(struct mdt_remote_perm, rp_gid) == 4, "found %lld\n", - (long long)(int)offsetof(struct mdt_remote_perm, rp_gid)); - LASSERTF((int)sizeof(((struct mdt_remote_perm *)0)->rp_gid) == 4, "found %lld\n", - (long long)(int)sizeof(((struct mdt_remote_perm *)0)->rp_gid)); - LASSERTF((int)offsetof(struct mdt_remote_perm, rp_fsuid) == 8, "found %lld\n", - (long long)(int)offsetof(struct mdt_remote_perm, rp_fsuid)); - LASSERTF((int)sizeof(((struct mdt_remote_perm *)0)->rp_fsuid) == 4, "found %lld\n", - (long long)(int)sizeof(((struct mdt_remote_perm *)0)->rp_fsuid)); - LASSERTF((int)offsetof(struct mdt_remote_perm, rp_fsgid) == 16, "found %lld\n", - (long long)(int)offsetof(struct mdt_remote_perm, rp_fsgid)); - LASSERTF((int)sizeof(((struct mdt_remote_perm *)0)->rp_fsgid) == 4, "found %lld\n", - (long long)(int)sizeof(((struct mdt_remote_perm *)0)->rp_fsgid)); - LASSERTF((int)offsetof(struct mdt_remote_perm, rp_access_perm) == 24, "found %lld\n", - (long long)(int)offsetof(struct mdt_remote_perm, rp_access_perm)); - LASSERTF((int)sizeof(((struct mdt_remote_perm *)0)->rp_access_perm) == 4, "found %lld\n", - (long long)(int)sizeof(((struct mdt_remote_perm *)0)->rp_access_perm)); - LASSERTF((int)offsetof(struct mdt_remote_perm, rp_padding) == 28, "found %lld\n", - (long long)(int)offsetof(struct mdt_remote_perm, rp_padding)); - LASSERTF((int)sizeof(((struct mdt_remote_perm *)0)->rp_padding) == 4, "found %lld\n", - (long long)(int)sizeof(((struct mdt_remote_perm *)0)->rp_padding)); - LASSERTF(CFS_SETUID_PERM == 0x00000001UL, "found 0x%.8xUL\n", - (unsigned)CFS_SETUID_PERM); - LASSERTF(CFS_SETGID_PERM == 0x00000002UL, "found 0x%.8xUL\n", - (unsigned)CFS_SETGID_PERM); - LASSERTF(CFS_SETGRP_PERM == 0x00000004UL, "found 0x%.8xUL\n", - (unsigned)CFS_SETGRP_PERM); - LASSERTF(CFS_RMTACL_PERM == 0x00000008UL, "found 0x%.8xUL\n", - (unsigned)CFS_RMTACL_PERM); - LASSERTF(CFS_RMTOWN_PERM == 0x00000010UL, "found 0x%.8xUL\n", - (unsigned)CFS_RMTOWN_PERM); - /* Checks for struct mdt_rec_setattr */ LASSERTF((int)sizeof(struct mdt_rec_setattr) == 136, "found %lld\n", (long long)(int)sizeof(struct mdt_rec_setattr)); -- cgit v1.1 From 1b02bde3bce415a4c0541b911e6d9b3d98a80740 Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Mon, 20 Jun 2016 16:55:24 -0400 Subject: staging/lustre/llite: allocate and free client cache asynchronously Since the inflight request holds import refcount as well as export, sometimes obd_disconnect() in client_common_put_super() can't put the last refcount of OSC import (e.g. due to network disconnection), this will cause cl_cache being accessed after free. To fix this issue, ccc_users is used as cl_cache refcount, and lov/llite/osc all hold one cl_cache refcount respectively, to avoid the race that a new OST is being added into the system when the client is mounted. The following cl_cache functions are added: - cl_cache_init(): allocate and initialize cl_cache - cl_cache_incref(): increase cl_cache refcount - cl_cache_decref(): decrease cl_cache refcount and free the cache if refcount=0. Signed-off-by: Emoly Liu Reviewed-on: http://review.whamcloud.com/13746 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6173 Reviewed-by: Niu Yawei Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/cl_object.h | 10 ++++- drivers/staging/lustre/lustre/include/obd.h | 2 +- .../staging/lustre/lustre/llite/llite_internal.h | 2 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 35 +++++++--------- drivers/staging/lustre/lustre/llite/lproc_llite.c | 6 +-- drivers/staging/lustre/lustre/lov/lov_obd.c | 7 ++++ drivers/staging/lustre/lustre/obdclass/cl_page.c | 46 ++++++++++++++++++++++ drivers/staging/lustre/lustre/osc/osc_page.c | 4 +- drivers/staging/lustre/lustre/osc/osc_request.c | 4 +- 9 files changed, 86 insertions(+), 30 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index 36ca935..3cd4a25 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -2322,7 +2322,8 @@ void cl_lock_descr_print(const struct lu_env *env, void *cookie, */ struct cl_client_cache { /** - * # of users (OSCs) + * # of client cache refcount + * # of users (OSCs) + 2 (held by llite and lov) */ atomic_t ccc_users; /** @@ -2357,6 +2358,13 @@ struct cl_client_cache { }; +/** + * cl_cache functions + */ +struct cl_client_cache *cl_cache_init(unsigned long lru_page_max); +void cl_cache_incref(struct cl_client_cache *cache); +void cl_cache_decref(struct cl_client_cache *cache); + /** @} cl_page */ /** \defgroup cl_lock cl_lock diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 9971ee5..40909b0 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -415,7 +415,7 @@ struct lov_obd { enum lustre_sec_part lov_sp_me; /* Cached LRU and unstable data from upper layer */ - void *lov_cache; + struct cl_client_cache *lov_cache; struct rw_semaphore lov_notify_lock; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 8fe63bd..657ebd0 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -452,7 +452,7 @@ struct ll_sb_info { * any page which is sent to a server as part of a bulk request, * but is uncommitted to stable storage. */ - struct cl_client_cache ll_cache; + struct cl_client_cache *ll_cache; struct lprocfs_stats *ll_ra_stats; diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index ae6a571..4ab1f2b 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -83,15 +83,11 @@ static struct ll_sb_info *ll_init_sbi(struct super_block *sb) pages = si.totalram - si.totalhigh; lru_page_max = pages / 2; - /* initialize ll_cache data */ - atomic_set(&sbi->ll_cache.ccc_users, 0); - sbi->ll_cache.ccc_lru_max = lru_page_max; - atomic_set(&sbi->ll_cache.ccc_lru_left, lru_page_max); - spin_lock_init(&sbi->ll_cache.ccc_lru_lock); - INIT_LIST_HEAD(&sbi->ll_cache.ccc_lru); - - atomic_set(&sbi->ll_cache.ccc_unstable_nr, 0); - init_waitqueue_head(&sbi->ll_cache.ccc_unstable_waitq); + sbi->ll_cache = cl_cache_init(lru_page_max); + if (!sbi->ll_cache) { + kfree(sbi); + return NULL; + } sbi->ll_ra_info.ra_max_pages_per_file = min(pages / 32, SBI_DEFAULT_READAHEAD_MAX); @@ -131,6 +127,11 @@ static void ll_free_sbi(struct super_block *sb) { struct ll_sb_info *sbi = ll_s2sbi(sb); + if (sbi->ll_cache) { + cl_cache_decref(sbi->ll_cache); + sbi->ll_cache = NULL; + } + kfree(sbi); } @@ -488,8 +489,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, cl_sb_init(sb); err = obd_set_info_async(NULL, sbi->ll_dt_exp, sizeof(KEY_CACHE_SET), - KEY_CACHE_SET, sizeof(sbi->ll_cache), - &sbi->ll_cache, NULL); + KEY_CACHE_SET, sizeof(*sbi->ll_cache), + sbi->ll_cache, NULL); sb->s_root = d_make_root(root); if (!sb->s_root) { @@ -534,8 +535,6 @@ out_lock_cn_cb: out_dt: obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; - /* Make sure all OScs are gone, since cl_cache is accessing sbi. */ - obd_zombie_barrier(); out_md_fid: obd_fid_fini(sbi->ll_md_exp->exp_obd); out_md: @@ -585,10 +584,6 @@ static void client_common_put_super(struct super_block *sb) obd_fid_fini(sbi->ll_dt_exp->exp_obd); obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; - /* wait till all OSCs are gone, since cl_cache is accessing sbi. - * see LU-2543. - */ - obd_zombie_barrier(); ldebugfs_unregister_mountpoint(sbi); @@ -921,12 +916,12 @@ void ll_put_super(struct super_block *sb) if (!force) { struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); - rc = l_wait_event(sbi->ll_cache.ccc_unstable_waitq, - !atomic_read(&sbi->ll_cache.ccc_unstable_nr), + rc = l_wait_event(sbi->ll_cache->ccc_unstable_waitq, + !atomic_read(&sbi->ll_cache->ccc_unstable_nr), &lwi); } - ccc_count = atomic_read(&sbi->ll_cache.ccc_unstable_nr); + ccc_count = atomic_read(&sbi->ll_cache->ccc_unstable_nr); if (!force && rc != -EINTR) LASSERTF(!ccc_count, "count: %i\n", ccc_count); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 18a7775..e86bf3c 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -356,7 +356,7 @@ static int ll_max_cached_mb_seq_show(struct seq_file *m, void *v) { struct super_block *sb = m->private; struct ll_sb_info *sbi = ll_s2sbi(sb); - struct cl_client_cache *cache = &sbi->ll_cache; + struct cl_client_cache *cache = sbi->ll_cache; int shift = 20 - PAGE_SHIFT; int max_cached_mb; int unused_mb; @@ -383,7 +383,7 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, { struct super_block *sb = ((struct seq_file *)file->private_data)->private; struct ll_sb_info *sbi = ll_s2sbi(sb); - struct cl_client_cache *cache = &sbi->ll_cache; + struct cl_client_cache *cache = sbi->ll_cache; struct lu_env *env; int refcheck; int mult, rc, pages_number; @@ -822,7 +822,7 @@ static ssize_t unstable_stats_show(struct kobject *kobj, { struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info, ll_kobj); - struct cl_client_cache *cache = &sbi->ll_cache; + struct cl_client_cache *cache = sbi->ll_cache; int pages, mb; pages = atomic_read(&cache->ccc_unstable_nr); diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index c87096e..9b92d55 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -892,6 +892,12 @@ static int lov_cleanup(struct obd_device *obd) kfree(lov->lov_tgts); lov->lov_tgt_size = 0; } + + if (lov->lov_cache) { + cl_cache_decref(lov->lov_cache); + lov->lov_cache = NULL; + } + return 0; } @@ -2121,6 +2127,7 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, LASSERT(!lov->lov_cache); lov->lov_cache = val; do_inactive = 1; + cl_cache_incref(lov->lov_cache); } for (i = 0; i < count; i++, val = (char *)val + incr) { diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 71bff49..db2dc6b 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -1072,3 +1072,49 @@ void cl_page_slice_add(struct cl_page *page, struct cl_page_slice *slice, slice->cpl_page = page; } EXPORT_SYMBOL(cl_page_slice_add); + +/** + * Allocate and initialize cl_cache, called by ll_init_sbi(). + */ +struct cl_client_cache *cl_cache_init(unsigned long lru_page_max) +{ + struct cl_client_cache *cache = NULL; + + cache = kzalloc(sizeof(*cache), GFP_KERNEL); + if (!cache) + return NULL; + + /* Initialize cache data */ + atomic_set(&cache->ccc_users, 1); + cache->ccc_lru_max = lru_page_max; + atomic_set(&cache->ccc_lru_left, lru_page_max); + spin_lock_init(&cache->ccc_lru_lock); + INIT_LIST_HEAD(&cache->ccc_lru); + + atomic_set(&cache->ccc_unstable_nr, 0); + init_waitqueue_head(&cache->ccc_unstable_waitq); + + return cache; +} +EXPORT_SYMBOL(cl_cache_init); + +/** + * Increase cl_cache refcount + */ +void cl_cache_incref(struct cl_client_cache *cache) +{ + atomic_inc(&cache->ccc_users); +} +EXPORT_SYMBOL(cl_cache_incref); + +/** + * Decrease cl_cache refcount and free the cache if refcount=0. + * Since llite, lov and osc all hold cl_cache refcount, + * the free will not cause race. (LU-6173) + */ +void cl_cache_decref(struct cl_client_cache *cache) +{ + if (atomic_dec_and_test(&cache->ccc_users)) + kfree(cache); +} +EXPORT_SYMBOL(cl_cache_decref); diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 18c261b..355f496 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -412,7 +412,7 @@ static int osc_cache_too_much(struct client_obd *cli) int pages = atomic_read(&cli->cl_lru_in_list); unsigned long budget; - budget = cache->ccc_lru_max / atomic_read(&cache->ccc_users); + budget = cache->ccc_lru_max / (atomic_read(&cache->ccc_users) - 2); /* if it's going to run out LRU slots, we should free some, but not * too much to maintain fairness among OSCs. @@ -712,7 +712,7 @@ int osc_lru_reclaim(struct client_obd *cli) cache->ccc_lru_shrinkers++; list_move_tail(&cli->cl_lru_osc, &cache->ccc_lru); - max_scans = atomic_read(&cache->ccc_users); + max_scans = atomic_read(&cache->ccc_users) - 2; while (--max_scans > 0 && !list_empty(&cache->ccc_lru)) { cli = list_entry(cache->ccc_lru.next, struct client_obd, cl_lru_osc); diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 7260027..9334349 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2913,7 +2913,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, LASSERT(!cli->cl_cache); /* only once */ cli->cl_cache = val; - atomic_inc(&cli->cl_cache->ccc_users); + cl_cache_incref(cli->cl_cache); cli->cl_lru_left = &cli->cl_cache->ccc_lru_left; /* add this osc into entity list */ @@ -3293,7 +3293,7 @@ static int osc_cleanup(struct obd_device *obd) list_del_init(&cli->cl_lru_osc); spin_unlock(&cli->cl_cache->ccc_lru_lock); cli->cl_lru_left = NULL; - atomic_dec(&cli->cl_cache->ccc_users); + cl_cache_decref(cli->cl_cache); cli->cl_cache = NULL; } -- cgit v1.1 From 411c9699dfe346fe7e70734c34291ea83d9b70b5 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Mon, 20 Jun 2016 16:55:25 -0400 Subject: staging/lustre/llite: correct request handling after ll_lookup_it() In the FIFO cases of ll_atomic_open() and ll_lookup_nd() remove spurious calls to ptlrpc_req_finished(). Explain that these cases are unreachable in practice anyway. Signed-off-by: John L. Hammond Reviewed-on: http://review.whamcloud.com/17068 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7402 Reviewed-by: Dmitry Eremin Reviewed-by: Lai Siyao Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/namei.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index d7459bd..6414d52 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -622,13 +622,10 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, if (d_really_is_positive(dentry) && it_disposition(it, DISP_OPEN_OPEN)) { /* Open dentry. */ if (S_ISFIFO(d_inode(dentry)->i_mode)) { - /* We cannot call open here as it would - * deadlock. + /* We cannot call open here as it might + * deadlock. This case is unreachable in + * practice because of OBD_CONNECT_NODEVOH. */ - if (it_disposition(it, DISP_ENQ_OPEN_REF)) - ptlrpc_req_finished( - (struct ptlrpc_request *) - it->d.lustre.it_data); rc = finish_no_open(file, de); } else { file->private_data = it; -- cgit v1.1 From 2bbec0ed2c957541f22ba99202827b004267ab58 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Mon, 20 Jun 2016 16:55:26 -0400 Subject: staging/lustre/llite: Get rid of ll_lock_dcache/ll_unlock_dcache These are just doing spin_lock/unlock on inode's i_lock, so just do the spinlock directly to make the code more clear Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dcache.c | 4 ++-- drivers/staging/lustre/lustre/llite/llite_internal.h | 10 ---------- drivers/staging/lustre/lustre/llite/namei.c | 8 ++++---- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 9d13d5e..f002b3a 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -249,7 +249,7 @@ void ll_invalidate_aliases(struct inode *inode) CDEBUG(D_INODE, "marking dentries for ino "DFID"(%p) invalid\n", PFID(ll_inode2fid(inode)), inode); - ll_lock_dcache(inode); + spin_lock(&inode->i_lock); hlist_for_each_entry(dentry, &inode->i_dentry, d_u.d_alias) { CDEBUG(D_DENTRY, "dentry in drop %pd (%p) parent %p inode %p flags %d\n", dentry, dentry, dentry->d_parent, @@ -257,7 +257,7 @@ void ll_invalidate_aliases(struct inode *inode) d_lustre_invalidate(dentry, 0); } - ll_unlock_dcache(inode); + spin_unlock(&inode->i_lock); } int ll_revalidate_it_finish(struct ptlrpc_request *request, diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 657ebd0..973dcc7 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -1229,16 +1229,6 @@ static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode, *bits = it->d.lustre.it_lock_bits; } -static inline void ll_lock_dcache(struct inode *inode) -{ - spin_lock(&inode->i_lock); -} - -static inline void ll_unlock_dcache(struct inode *inode) -{ - spin_unlock(&inode->i_lock); -} - static inline int d_lustre_invalid(const struct dentry *dentry) { struct ll_dentry_data *lld = ll_d2d(dentry); diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 6414d52..e4df510 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -140,7 +140,7 @@ static void ll_invalidate_negative_children(struct inode *dir) { struct dentry *dentry, *tmp_subdir; - ll_lock_dcache(dir); + spin_lock(&dir->i_lock); hlist_for_each_entry(dentry, &dir->i_dentry, d_u.d_alias) { spin_lock(&dentry->d_lock); if (!list_empty(&dentry->d_subdirs)) { @@ -155,7 +155,7 @@ static void ll_invalidate_negative_children(struct inode *dir) } spin_unlock(&dentry->d_lock); } - ll_unlock_dcache(dir); + spin_unlock(&dir->i_lock); } int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, @@ -317,7 +317,7 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *dentry) discon_alias = NULL; invalid_alias = NULL; - ll_lock_dcache(inode); + spin_lock(&inode->i_lock); hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) { LASSERT(alias != dentry); @@ -342,7 +342,7 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *dentry) dget_dlock(alias); spin_unlock(&alias->d_lock); } - ll_unlock_dcache(inode); + spin_unlock(&inode->i_lock); return alias; } -- cgit v1.1 From c9cc8d0f6f770635b206784686a16157db3d43b8 Mon Sep 17 00:00:00 2001 From: Bruno Faccini Date: Mon, 20 Jun 2016 16:55:27 -0400 Subject: staging/lustre/llite: lock i_lock before __d_drop() There has been several Lustre Client crashes reported by sites running with Lustre versions 2.1/2.5, all showing the same dentry->d_hash->next corrupted pointer cause. This patch fixes a regression that has been introduced since a long time by commit : (LU-506 kernel: FC15 - support dcache scalability changes.) where i_lock protection usage has been removed and that is likely to cause racy condition during dentry [un]hashing and to be the root cause of these crashes. Signed-off-by: Bruno Faccini Reviewed-on: http://review.whamcloud.com/19287 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7973 Reviewed-by: Lai Siyao Reviewed-by: Yang Sheng Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 2d50d1c..c46e2ac 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2963,8 +2963,11 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits) * here to preserve get_cwd functionality on 2.6. * Bug 10503 */ - if (!d_inode(dentry)->i_nlink) + if (!d_inode(dentry)->i_nlink) { + spin_lock(&inode->i_lock); d_lustre_invalidate(dentry, 0); + spin_unlock(&inode->i_lock); + } ll_lookup_finish_locks(&oit, inode); } else if (!ll_have_md_lock(d_inode(dentry), &ibits, LCK_MINMODE)) { -- cgit v1.1 From a6307ff9aaeda8691204dc0ea30cd3680d06f6b3 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Mon, 20 Jun 2016 16:55:28 -0400 Subject: staging/lustre/osc: osc_lock_weight endless loop fix With huge number of pages to scan by osc_lock_weight() it is likely CLP_GANG_RESCHED is returned from osc_page_gang_lookup() and the scan will be repeated again from the start. To be sure that the scan is progressing across those restarts, next scan should be started from the last scanned page index plus one. Xyratex-bug-id: MRP-2145 Signed-off-by: Alexander Zarochentsev Signed-off-by: Jinshan Xiong Reviewed-on: http://review.whamcloud.com/12362 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5781 Reviewed-by: Bobi Jam Reviewed-by: James Simmons Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_lock.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 42def38..d856775 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -634,11 +634,10 @@ static int weigh_cb(const struct lu_env *env, struct cl_io *io, if (cl_page_is_vmlocked(env, page) || PageDirty(page->cp_vmpage) || PageWriteback(page->cp_vmpage) - ) { - (*(unsigned long *)cbdata)++; + ) return CLP_GANG_ABORT; - } + *(pgoff_t *)cbdata = osc_index(ops) + 1; return CLP_GANG_OKAY; } @@ -648,7 +647,7 @@ static unsigned long osc_lock_weight(const struct lu_env *env, { struct cl_io *io = &osc_env_info(env)->oti_io; struct cl_object *obj = cl_object_top(&oscobj->oo_cl); - unsigned long npages = 0; + pgoff_t page_index; int result; io->ci_obj = obj; @@ -657,11 +656,12 @@ static unsigned long osc_lock_weight(const struct lu_env *env, if (result != 0) return result; + page_index = cl_index(obj, extent->start); do { result = osc_page_gang_lookup(env, io, oscobj, - cl_index(obj, extent->start), + page_index, cl_index(obj, extent->end), - weigh_cb, (void *)&npages); + weigh_cb, (void *)&page_index); if (result == CLP_GANG_ABORT) break; if (result == CLP_GANG_RESCHED) @@ -669,7 +669,7 @@ static unsigned long osc_lock_weight(const struct lu_env *env, } while (result != CLP_GANG_OKAY); cl_io_fini(env, io); - return npages; + return result == CLP_GANG_ABORT ? 1 : 0; } /** -- cgit v1.1 From fbe0456482aa5c482342735f342483a75ada8b96 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Mon, 20 Jun 2016 16:55:29 -0400 Subject: staging/lustre/osc: Fix reverted condition in osc_lock_weight When imprting clio simplification patch, the check for pbject got reversed by mistake when converting from if (obj == NULL) it somehow became (if (obj) which is obviously wrong, and so when it does hit, a crash was happening as result. Fix the condition and all if fine now. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_lock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index d856775..5455d9d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -699,7 +699,7 @@ unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock) LASSERT(dlmlock->l_resource->lr_type == LDLM_EXTENT); obj = dlmlock->l_ast_data; - if (obj) { + if (!obj) { weight = 1; goto out; } -- cgit v1.1 From 32c8728d87dcd59949800d838e4e7dce0c625062 Mon Sep 17 00:00:00 2001 From: Liang Zhen Date: Mon, 20 Jun 2016 16:55:30 -0400 Subject: staging/lustre/ptlrpc: reorganize ptlrpc_request ptlrpc_request has some structure members are only for client side, and some others are only for server side, this patch moved these members to different structure then putting into an union. By doing this, size of ptlrpc_request is decreased about 300 bytes, besides saving memory, it also can reduce memory footprint while processing. Signed-off-by: Liang Zhen Reviewed-on: http://review.whamcloud.com/8806 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-181 Reviewed-by: Andreas Dilger Reviewed-by: Bobi Jam Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_net.h | 341 ++++++++++++--------- drivers/staging/lustre/lustre/ptlrpc/client.c | 49 +-- drivers/staging/lustre/lustre/ptlrpc/events.c | 5 +- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 2 +- .../staging/lustre/lustre/ptlrpc/ptlrpc_internal.h | 34 ++ drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 4 +- drivers/staging/lustre/lustre/ptlrpc/sec.c | 9 +- 7 files changed, 255 insertions(+), 189 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index bdd2ed5..65924d9 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -266,6 +266,11 @@ /* Macro to hide a typecast. */ #define ptlrpc_req_async_args(req) ((void *)&req->rq_async_args) +struct ptlrpc_replay_async_args { + int praa_old_state; + int praa_old_status; +}; + /** * Structure to single define portal connection. */ @@ -1243,22 +1248,100 @@ struct ptlrpc_hpreq_ops { void (*hpreq_fini)(struct ptlrpc_request *); }; -/** - * Represents remote procedure call. - * - * This is a staple structure used by everybody wanting to send a request - * in Lustre. - */ -struct ptlrpc_request { - /* Request type: one of PTL_RPC_MSG_* */ - int rq_type; - /** Result of request processing */ - int rq_status; +struct ptlrpc_cli_req { + /** For bulk requests on client only: bulk descriptor */ + struct ptlrpc_bulk_desc *cr_bulk; + /** optional time limit for send attempts */ + long cr_delay_limit; + /** time request was first queued */ + time_t cr_queued_time; + /** request sent timeval */ + struct timespec64 cr_sent_tv; + /** time for request really sent out */ + time_t cr_sent_out; + /** when req reply unlink must finish. */ + time_t cr_reply_deadline; + /** when req bulk unlink must finish. */ + time_t cr_bulk_deadline; + /** Portal to which this request would be sent */ + short cr_req_ptl; + /** Portal where to wait for reply and where reply would be sent */ + short cr_rep_ptl; + /** request resending number */ + unsigned int cr_resend_nr; + /** What was import generation when this request was sent */ + int cr_imp_gen; + enum lustre_imp_state cr_send_state; + /** Per-request waitq introduced by bug 21938 for recovery waiting */ + wait_queue_head_t cr_set_waitq; + /** Link item for request set lists */ + struct list_head cr_set_chain; + /** link to waited ctx */ + struct list_head cr_ctx_chain; + + /** client's half ctx */ + struct ptlrpc_cli_ctx *cr_cli_ctx; + /** Link back to the request set */ + struct ptlrpc_request_set *cr_set; + /** outgoing request MD handle */ + lnet_handle_md_t cr_req_md_h; + /** request-out callback parameter */ + struct ptlrpc_cb_id cr_req_cbid; + /** incoming reply MD handle */ + lnet_handle_md_t cr_reply_md_h; + wait_queue_head_t cr_reply_waitq; + /** reply callback parameter */ + struct ptlrpc_cb_id cr_reply_cbid; + /** Async completion handler, called when reply is received */ + ptlrpc_interpterer_t cr_reply_interp; + /** Async completion context */ + union ptlrpc_async_args cr_async_args; + /** Opaq data for replay and commit callbacks. */ + void *cr_cb_data; /** - * Linkage item through which this request is included into - * sending/delayed lists on client and into rqbd list on server + * Commit callback, called when request is committed and about to be + * freed. */ - struct list_head rq_list; + void (*cr_commit_cb)(struct ptlrpc_request *); + /** Replay callback, called after request is replayed at recovery */ + void (*cr_replay_cb)(struct ptlrpc_request *); +}; + +/** client request member alias */ +/* NB: these alias should NOT be used by any new code, instead they should + * be removed step by step to avoid potential abuse + */ +#define rq_bulk rq_cli.cr_bulk +#define rq_delay_limit rq_cli.cr_delay_limit +#define rq_queued_time rq_cli.cr_queued_time +#define rq_sent_tv rq_cli.cr_sent_tv +#define rq_real_sent rq_cli.cr_sent_out +#define rq_reply_deadline rq_cli.cr_reply_deadline +#define rq_bulk_deadline rq_cli.cr_bulk_deadline +#define rq_nr_resend rq_cli.cr_resend_nr +#define rq_request_portal rq_cli.cr_req_ptl +#define rq_reply_portal rq_cli.cr_rep_ptl +#define rq_import_generation rq_cli.cr_imp_gen +#define rq_send_state rq_cli.cr_send_state +#define rq_set_chain rq_cli.cr_set_chain +#define rq_ctx_chain rq_cli.cr_ctx_chain +#define rq_set rq_cli.cr_set +#define rq_set_waitq rq_cli.cr_set_waitq +#define rq_cli_ctx rq_cli.cr_cli_ctx +#define rq_req_md_h rq_cli.cr_req_md_h +#define rq_req_cbid rq_cli.cr_req_cbid +#define rq_reply_md_h rq_cli.cr_reply_md_h +#define rq_reply_waitq rq_cli.cr_reply_waitq +#define rq_reply_cbid rq_cli.cr_reply_cbid +#define rq_interpret_reply rq_cli.cr_reply_interp +#define rq_async_args rq_cli.cr_async_args +#define rq_cb_data rq_cli.cr_cb_data +#define rq_commit_cb rq_cli.cr_commit_cb +#define rq_replay_cb rq_cli.cr_replay_cb + +struct ptlrpc_srv_req { + /** initial thread servicing this request */ + struct ptlrpc_thread *sr_svc_thread; /** * Server side list of incoming unserved requests sorted by arrival * time. Traversed from time to time to notice about to expire @@ -1266,27 +1349,81 @@ struct ptlrpc_request { * know server is alive and well, just very busy to service their * requests in time */ - struct list_head rq_timed_list; - /** server-side history, used for debugging purposes. */ - struct list_head rq_history_list; + struct list_head sr_timed_list; /** server-side per-export list */ - struct list_head rq_exp_list; - /** server-side hp handlers */ - struct ptlrpc_hpreq_ops *rq_ops; - - /** initial thread servicing this request */ - struct ptlrpc_thread *rq_svc_thread; - + struct list_head sr_exp_list; + /** server-side history, used for debuging purposes. */ + struct list_head sr_hist_list; /** history sequence # */ - __u64 rq_history_seq; + __u64 sr_hist_seq; + /** the index of service's srv_at_array into which request is linked */ + time_t sr_at_index; + /** authed uid */ + uid_t sr_auth_uid; + /** authed uid mapped to */ + uid_t sr_auth_mapped_uid; + /** RPC is generated from what part of Lustre */ + enum lustre_sec_part sr_sp_from; + /** request session context */ + struct lu_context sr_ses; /** \addtogroup nrs * @{ */ /** stub for NRS request */ - struct ptlrpc_nrs_request rq_nrq; + struct ptlrpc_nrs_request sr_nrq; /** @} nrs */ - /** the index of service's srv_at_array into which request is linked */ - u32 rq_at_index; + /** request arrival time */ + struct timespec64 sr_arrival_time; + /** server's half ctx */ + struct ptlrpc_svc_ctx *sr_svc_ctx; + /** (server side), pointed directly into req buffer */ + struct ptlrpc_user_desc *sr_user_desc; + /** separated reply state */ + struct ptlrpc_reply_state *sr_reply_state; + /** server-side hp handlers */ + struct ptlrpc_hpreq_ops *sr_ops; + /** incoming request buffer */ + struct ptlrpc_request_buffer_desc *sr_rqbd; +}; + +/** server request member alias */ +/* NB: these alias should NOT be used by any new code, instead they should + * be removed step by step to avoid potential abuse + */ +#define rq_svc_thread rq_srv.sr_svc_thread +#define rq_timed_list rq_srv.sr_timed_list +#define rq_exp_list rq_srv.sr_exp_list +#define rq_history_list rq_srv.sr_hist_list +#define rq_history_seq rq_srv.sr_hist_seq +#define rq_at_index rq_srv.sr_at_index +#define rq_auth_uid rq_srv.sr_auth_uid +#define rq_auth_mapped_uid rq_srv.sr_auth_mapped_uid +#define rq_sp_from rq_srv.sr_sp_from +#define rq_session rq_srv.sr_ses +#define rq_nrq rq_srv.sr_nrq +#define rq_arrival_time rq_srv.sr_arrival_time +#define rq_reply_state rq_srv.sr_reply_state +#define rq_svc_ctx rq_srv.sr_svc_ctx +#define rq_user_desc rq_srv.sr_user_desc +#define rq_ops rq_srv.sr_ops +#define rq_rqbd rq_srv.sr_rqbd + +/** + * Represents remote procedure call. + * + * This is a staple structure used by everybody wanting to send a request + * in Lustre. + */ +struct ptlrpc_request { + /* Request type: one of PTL_RPC_MSG_* */ + int rq_type; + /** Result of request processing */ + int rq_status; + /** + * Linkage item through which this request is included into + * sending/delayed lists on client and into rqbd list on server + */ + struct list_head rq_list; /** Lock to protect request flags and some other important bits, like * rq_list */ @@ -1327,19 +1464,15 @@ struct ptlrpc_request { /* bulk request, sent to server, but uncommitted */ rq_unstable:1; - unsigned int rq_nr_resend; - - enum rq_phase rq_phase; /* one of RQ_PHASE_* */ - enum rq_phase rq_next_phase; /* one of RQ_PHASE_* to be used next */ - atomic_t rq_refcount; /* client-side refcount for SENT race, - * server-side refcount for multiple replies - */ - - /** Portal to which this request would be sent */ - short rq_request_portal; /* XXX FIXME bug 249 */ - /** Portal where to wait for reply and where reply would be sent */ - short rq_reply_portal; /* XXX FIXME bug 249 */ - + /** one of RQ_PHASE_* */ + enum rq_phase rq_phase; + /** one of RQ_PHASE_* to be used next */ + enum rq_phase rq_next_phase; + /** + * client-side refcount for SENT race, server-side refcount + * for multiple replies + */ + atomic_t rq_refcount; /** * client-side: * !rq_truncate : # reply bytes actually received, @@ -1350,6 +1483,8 @@ struct ptlrpc_request { int rq_reqlen; /** Reply length */ int rq_replen; + /** Pool if request is from preallocated list */ + struct ptlrpc_request_pool *rq_pool; /** Request message - what client sent */ struct lustre_msg *rq_reqmsg; /** Reply message - server response */ @@ -1362,19 +1497,20 @@ struct ptlrpc_request { * List item to for replay list. Not yet committed requests get linked * there. * Also see \a rq_replay comment above. + * It's also link chain on obd_export::exp_req_replay_queue */ struct list_head rq_replay_list; - + /** non-shared members for client & server request*/ + union { + struct ptlrpc_cli_req rq_cli; + struct ptlrpc_srv_req rq_srv; + }; /** * security and encryption data * @{ */ - struct ptlrpc_cli_ctx *rq_cli_ctx; /**< client's half ctx */ - struct ptlrpc_svc_ctx *rq_svc_ctx; /**< server's half ctx */ - struct list_head rq_ctx_chain; /**< link to waited ctx */ - - struct sptlrpc_flavor rq_flvr; /**< for client & server */ - enum lustre_sec_part rq_sp_from; + /** description of flavors for client & server */ + struct sptlrpc_flavor rq_flvr; /* client/server security flags */ unsigned int @@ -1392,19 +1528,15 @@ struct ptlrpc_request { rq_pack_bulk:1, /* doesn't expect reply FIXME */ rq_no_reply:1, - rq_pill_init:1; /* pill initialized */ - - uid_t rq_auth_uid; /* authed uid */ - uid_t rq_auth_mapped_uid; /* authed uid mapped to */ - - /* (server side), pointed directly into req buffer */ - struct ptlrpc_user_desc *rq_user_desc; - - /* various buffer pointers */ - struct lustre_msg *rq_reqbuf; /* req wrapper */ - char *rq_repbuf; /* rep buffer */ - struct lustre_msg *rq_repdata; /* rep wrapper msg */ - struct lustre_msg *rq_clrbuf; /* only in priv mode */ + rq_pill_init:1, /* pill initialized */ + rq_srv_req:1; /* server request */ + + /** various buffer pointers */ + struct lustre_msg *rq_reqbuf; /**< req wrapper */ + char *rq_repbuf; /**< rep buffer */ + struct lustre_msg *rq_repdata; /**< rep wrapper msg */ + /** only in priv mode */ + struct lustre_msg *rq_clrbuf; int rq_reqbuf_len; /* req wrapper buf len */ int rq_reqdata_len; /* req wrapper msg len */ int rq_repbuf_len; /* rep buffer len */ @@ -1421,97 +1553,28 @@ struct ptlrpc_request { __u32 rq_req_swab_mask; __u32 rq_rep_swab_mask; - /** What was import generation when this request was sent */ - int rq_import_generation; - enum lustre_imp_state rq_send_state; - /** how many early replies (for stats) */ int rq_early_count; - /** client+server request */ - lnet_handle_md_t rq_req_md_h; - struct ptlrpc_cb_id rq_req_cbid; - /** optional time limit for send attempts */ - long rq_delay_limit; - /** time request was first queued */ - unsigned long rq_queued_time; - - /* server-side... */ - /** request arrival time */ - struct timespec64 rq_arrival_time; - /** separated reply state */ - struct ptlrpc_reply_state *rq_reply_state; - /** incoming request buffer */ - struct ptlrpc_request_buffer_desc *rq_rqbd; - - /** client-only incoming reply */ - lnet_handle_md_t rq_reply_md_h; - wait_queue_head_t rq_reply_waitq; - struct ptlrpc_cb_id rq_reply_cbid; - + /** Server-side, export on which request was received */ + struct obd_export *rq_export; + /** import where request is being sent */ + struct obd_import *rq_import; /** our LNet NID */ lnet_nid_t rq_self; /** Peer description (the other side) */ lnet_process_id_t rq_peer; - /** Server-side, export on which request was received */ - struct obd_export *rq_export; - /** Client side, import where request is being sent */ - struct obd_import *rq_import; - - /** Replay callback, called after request is replayed at recovery */ - void (*rq_replay_cb)(struct ptlrpc_request *); /** - * Commit callback, called when request is committed and about to be - * freed. + * service time estimate (secs) + * If the request is not served by this time, it is marked as timed out. */ - void (*rq_commit_cb)(struct ptlrpc_request *); - /** Opaq data for replay and commit callbacks. */ - void *rq_cb_data; - - /** For bulk requests on client only: bulk descriptor */ - struct ptlrpc_bulk_desc *rq_bulk; - - /** client outgoing req */ + int rq_timeout; /** * when request/reply sent (secs), or time when request should be sent */ time64_t rq_sent; - /** time for request really sent out */ - time64_t rq_real_sent; - - /** when request must finish. volatile - * so that servers' early reply updates to the deadline aren't - * kept in per-cpu cache - */ - volatile time64_t rq_deadline; - /** when req reply unlink must finish. */ - time64_t rq_reply_deadline; - /** when req bulk unlink must finish. */ - time64_t rq_bulk_deadline; - /** - * service time estimate (secs) - * If the requestsis not served by this time, it is marked as timed out. - */ - int rq_timeout; - - /** Multi-rpc bits */ - /** Per-request waitq introduced by bug 21938 for recovery waiting */ - wait_queue_head_t rq_set_waitq; - /** Link item for request set lists */ - struct list_head rq_set_chain; - /** Link back to the request set */ - struct ptlrpc_request_set *rq_set; - /** Async completion handler, called when reply is received */ - ptlrpc_interpterer_t rq_interpret_reply; - /** Async completion context */ - union ptlrpc_async_args rq_async_args; - - /** Pool if request is from preallocated list */ - struct ptlrpc_request_pool *rq_pool; - - struct lu_context rq_session; - struct lu_context rq_recov_session; - + /** when request must finish. */ + time64_t rq_deadline; /** request format description */ struct req_capsule rq_pill; }; diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 22bf893..9abd469 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -611,7 +611,6 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request, lustre_msg_add_version(request->rq_reqmsg, version); request->rq_send_state = LUSTRE_IMP_FULL; request->rq_type = PTL_RPC_MSG_REQUEST; - request->rq_export = NULL; request->rq_req_cbid.cbid_fn = request_out_callback; request->rq_req_cbid.cbid_arg = request; @@ -628,19 +627,7 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request, ptlrpc_at_set_req_timeout(request); - spin_lock_init(&request->rq_lock); - INIT_LIST_HEAD(&request->rq_list); - INIT_LIST_HEAD(&request->rq_timed_list); - INIT_LIST_HEAD(&request->rq_replay_list); - INIT_LIST_HEAD(&request->rq_ctx_chain); - INIT_LIST_HEAD(&request->rq_set_chain); - INIT_LIST_HEAD(&request->rq_history_list); - INIT_LIST_HEAD(&request->rq_exp_list); - init_waitqueue_head(&request->rq_reply_waitq); - init_waitqueue_head(&request->rq_set_waitq); request->rq_xid = ptlrpc_next_xid(); - atomic_set(&request->rq_refcount, 1); - lustre_msg_set_opc(request->rq_reqmsg, opcode); return 0; @@ -718,7 +705,9 @@ struct ptlrpc_request *__ptlrpc_request_alloc(struct obd_import *imp, request = ptlrpc_prep_req_from_pool(pool); if (request) { - LASSERTF((unsigned long)imp > 0x1000, "%p\n", imp); + ptlrpc_cli_req_init(request); + + LASSERTF((unsigned long)imp > 0x1000, "%p", imp); LASSERT(imp != LP_POISON); LASSERTF((unsigned long)imp->imp_client > 0x1000, "%p\n", imp->imp_client); @@ -1235,8 +1224,9 @@ static int after_reply(struct ptlrpc_request *req) } ktime_get_real_ts64(&work_start); - timediff = (work_start.tv_sec - req->rq_arrival_time.tv_sec) * USEC_PER_SEC + - (work_start.tv_nsec - req->rq_arrival_time.tv_nsec) / NSEC_PER_USEC; + timediff = (work_start.tv_sec - req->rq_sent_tv.tv_sec) * USEC_PER_SEC + + (work_start.tv_nsec - req->rq_sent_tv.tv_nsec) / + NSEC_PER_USEC; if (obd->obd_svc_stats) { lprocfs_counter_add(obd->obd_svc_stats, PTLRPC_REQWAIT_CNTR, timediff); @@ -2191,11 +2181,11 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) { if (!request) return; + LASSERT(!request->rq_srv_req); + LASSERT(!request->rq_export); LASSERTF(!request->rq_receiving_reply, "req %p\n", request); - LASSERTF(!request->rq_rqbd, "req %p\n", request);/* client-side */ LASSERTF(list_empty(&request->rq_list), "req %p\n", request); LASSERTF(list_empty(&request->rq_set_chain), "req %p\n", request); - LASSERTF(list_empty(&request->rq_exp_list), "req %p\n", request); LASSERTF(!request->rq_replay, "req %p\n", request); req_capsule_fini(&request->rq_pill); @@ -2221,10 +2211,7 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) if (request->rq_repbuf) sptlrpc_cli_free_repbuf(request); - if (request->rq_export) { - class_export_put(request->rq_export); - request->rq_export = NULL; - } + if (request->rq_import) { class_import_put(request->rq_import); request->rq_import = NULL; @@ -2614,11 +2601,6 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req) } EXPORT_SYMBOL(ptlrpc_queue_wait); -struct ptlrpc_replay_async_args { - int praa_old_state; - int praa_old_status; -}; - /** * Callback used for replayed requests reply processing. * In case of successful reply calls registered request replay callback. @@ -3013,10 +2995,11 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, return ERR_PTR(-ENOMEM); } + ptlrpc_cli_req_init(req); + req->rq_send_state = LUSTRE_IMP_FULL; req->rq_type = PTL_RPC_MSG_REQUEST; req->rq_import = class_import_get(imp); - req->rq_export = NULL; req->rq_interpret_reply = work_interpreter; /* don't want reply */ req->rq_receiving_reply = 0; @@ -3026,16 +3009,6 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, req->rq_no_resend = 1; req->rq_pill.rc_fmt = (void *)&worker_format; - spin_lock_init(&req->rq_lock); - INIT_LIST_HEAD(&req->rq_list); - INIT_LIST_HEAD(&req->rq_replay_list); - INIT_LIST_HEAD(&req->rq_set_chain); - INIT_LIST_HEAD(&req->rq_history_list); - INIT_LIST_HEAD(&req->rq_exp_list); - init_waitqueue_head(&req->rq_reply_waitq); - init_waitqueue_head(&req->rq_set_waitq); - atomic_set(&req->rq_refcount, 1); - CLASSERT(sizeof(*args) <= sizeof(req->rq_async_args)); args = ptlrpc_req_async_args(req); args->cb = cb; diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index b8ca7d6..95be4aa 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -324,6 +324,7 @@ void request_in_callback(lnet_event_t *ev) } } + ptlrpc_srv_req_init(req); /* NB we ABSOLUTELY RELY on req being zeroed, so pointers are NULL, * flags are reset and scalars are zero. We only set the message * size to non-zero if this was a successful receive. @@ -337,10 +338,6 @@ void request_in_callback(lnet_event_t *ev) req->rq_self = ev->target.nid; req->rq_rqbd = rqbd; req->rq_phase = RQ_PHASE_NEW; - spin_lock_init(&req->rq_lock); - INIT_LIST_HEAD(&req->rq_timed_list); - INIT_LIST_HEAD(&req->rq_exp_list); - atomic_set(&req->rq_refcount, 1); if (ev->type == LNET_EVENT_PUT) CDEBUG(D_INFO, "incoming req@%p x%llu msgsize %u\n", req, req->rq_xid, ev->mlength); diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index ff9a95c..4e7d68f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -633,7 +633,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) OBD_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_DELAY_SEND, request->rq_timeout + 5); - ktime_get_real_ts64(&request->rq_arrival_time); + ktime_get_real_ts64(&request->rq_sent_tv); request->rq_sent = ktime_get_real_seconds(); /* We give the server rq_timeout secs to process the req, and * add the network latency for our local timeout. diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index 97e97e2..d3674cb 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -288,4 +288,38 @@ static inline void ptlrpc_reqset_put(struct ptlrpc_request_set *set) if (atomic_dec_and_test(&set->set_refcount)) kfree(set); } + +/** initialise ptlrpc common fields */ +static inline void ptlrpc_req_comm_init(struct ptlrpc_request *req) +{ + spin_lock_init(&req->rq_lock); + atomic_set(&req->rq_refcount, 1); + INIT_LIST_HEAD(&req->rq_list); + INIT_LIST_HEAD(&req->rq_replay_list); +} + +/** initialise client side ptlrpc request */ +static inline void ptlrpc_cli_req_init(struct ptlrpc_request *req) +{ + struct ptlrpc_cli_req *cr = &req->rq_cli; + + ptlrpc_req_comm_init(req); + INIT_LIST_HEAD(&cr->cr_set_chain); + INIT_LIST_HEAD(&cr->cr_ctx_chain); + init_waitqueue_head(&cr->cr_reply_waitq); + init_waitqueue_head(&cr->cr_set_waitq); +} + +/** initialise server side ptlrpc request */ +static inline void ptlrpc_srv_req_init(struct ptlrpc_request *req) +{ + struct ptlrpc_srv_req *sr = &req->rq_srv; + + ptlrpc_req_comm_init(req); + req->rq_srv_req = 1; + INIT_LIST_HEAD(&sr->sr_exp_list); + INIT_LIST_HEAD(&sr->sr_timed_list); + INIT_LIST_HEAD(&sr->sr_hist_list); +} + #endif /* PTLRPC_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index b0cf585..0a374b6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -157,9 +157,9 @@ static int ptlrpcd_users; void ptlrpcd_wake(struct ptlrpc_request *req) { - struct ptlrpc_request_set *rq_set = req->rq_set; + struct ptlrpc_request_set *set = req->rq_set; - wake_up(&rq_set->set_waitq); + wake_up(&set->set_waitq); } EXPORT_SYMBOL(ptlrpcd_wake); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index f3b4773..dbd819f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -863,11 +863,9 @@ int sptlrpc_import_check_ctx(struct obd_import *imp) if (!req) return -ENOMEM; - spin_lock_init(&req->rq_lock); + ptlrpc_cli_req_init(req); atomic_set(&req->rq_refcount, 10000); - INIT_LIST_HEAD(&req->rq_ctx_chain); - init_waitqueue_head(&req->rq_reply_waitq); - init_waitqueue_head(&req->rq_set_waitq); + req->rq_import = imp; req->rq_flvr = sec->ps_flvr; req->rq_cli_ctx = ctx; @@ -1047,6 +1045,8 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, if (!early_req) return -ENOMEM; + ptlrpc_cli_req_init(early_req); + early_size = req->rq_nob_received; early_bufsz = size_roundup_power2(early_size); early_buf = libcfs_kvzalloc(early_bufsz, GFP_NOFS); @@ -1095,7 +1095,6 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, memcpy(early_buf, req->rq_repbuf, early_size); spin_unlock(&req->rq_lock); - spin_lock_init(&early_req->rq_lock); early_req->rq_cli_ctx = sptlrpc_cli_ctx_get(req->rq_cli_ctx); early_req->rq_flvr = req->rq_flvr; early_req->rq_repbuf = early_buf; -- cgit v1.1 From 9faa2ade3fdaf00c6c45654071b325d3c88f9230 Mon Sep 17 00:00:00 2001 From: Liang Zhen Date: Mon, 20 Jun 2016 16:55:31 -0400 Subject: staging/lustre/ptlrpc: missing wakeup for ptlrpc_check_set This patch changes a few things: - There is no guarantee that request_out_callback will happen before reply_in_callback, if a request got reply and unlinked reply buffer before request_out_callback is called, then the thread waiting on ptlrpc_request_set will miss wakeup event. This may seriously impact performance of some IO workloads or result in RPC timeout - To make code more easier to understand, this patch changes action-bits "rq_req_unlink" and "rq_reply_unlink" to status-bits "rq_req_unlinked" and "rq_reply_unlinked" Signed-off-by: Liang Zhen Reviewed-on: http://review.whamcloud.com/12158 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5696 Reviewed-by: Johann Lombardi Reviewed-by: Li Wei Reviewed-by: Mike Pershin Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_net.h | 27 +++++++++++++--------- drivers/staging/lustre/lustre/ptlrpc/client.c | 12 ++++------ drivers/staging/lustre/lustre/ptlrpc/events.c | 22 +++++++++++------- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 14 +++++------ .../staging/lustre/lustre/ptlrpc/ptlrpc_internal.h | 9 ++++++++ 5 files changed, 51 insertions(+), 33 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 65924d9..0fedef9 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -1428,7 +1428,7 @@ struct ptlrpc_request { * rq_list */ spinlock_t rq_lock; - /** client-side flags are serialized by rq_lock */ + /** client-side flags are serialized by rq_lock @{ */ unsigned int rq_intr:1, rq_replied:1, rq_err:1, rq_timedout:1, rq_resend:1, rq_restart:1, /** @@ -1444,18 +1444,15 @@ struct ptlrpc_request { rq_no_resend:1, rq_waiting:1, rq_receiving_reply:1, rq_no_delay:1, rq_net_err:1, rq_wait_ctx:1, rq_early:1, - rq_req_unlink:1, rq_reply_unlink:1, + rq_req_unlinked:1, /* unlinked request buffer from lnet */ + rq_reply_unlinked:1, /* unlinked reply buffer from lnet */ rq_memalloc:1, /* req originated from "kswapd" */ - /* server-side flags */ - rq_packed_final:1, /* packed final reply */ - rq_hp:1, /* high priority RPC */ - rq_at_linked:1, /* link into service's srv_at_array */ - rq_reply_truncate:1, rq_committed:1, - /* whether the "rq_set" is a valid one */ + rq_reply_truncated:1, + /** whether the "rq_set" is a valid one */ rq_invalid_rqset:1, rq_generation_set:1, - /* do not resend request on -EINPROGRESS */ + /** do not resend request on -EINPROGRESS */ rq_no_retry_einprogress:1, /* allow the req to be sent if the import is in recovery * status @@ -1463,6 +1460,14 @@ struct ptlrpc_request { rq_allow_replay:1, /* bulk request, sent to server, but uncommitted */ rq_unstable:1; + /** @} */ + + /** server-side flags @{ */ + unsigned int + rq_hp:1, /**< high priority RPC */ + rq_at_linked:1, /**< link into service's srv_at_array */ + rq_packed_final:1; /**< packed final reply */ + /** @} */ /** one of RQ_PHASE_* */ enum rq_phase rq_phase; @@ -2784,8 +2789,8 @@ ptlrpc_client_recv_or_unlink(struct ptlrpc_request *req) spin_unlock(&req->rq_lock); return 1; } - rc = req->rq_receiving_reply; - rc = rc || req->rq_req_unlink || req->rq_reply_unlink; + rc = !req->rq_req_unlinked || !req->rq_reply_unlinked || + req->rq_receiving_reply; spin_unlock(&req->rq_lock); return rc; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 9abd469..ae1cef3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -1148,9 +1148,9 @@ static int after_reply(struct ptlrpc_request *req) LASSERT(obd); /* repbuf must be unlinked */ - LASSERT(!req->rq_receiving_reply && !req->rq_reply_unlink); + LASSERT(!req->rq_receiving_reply && req->rq_reply_unlinked); - if (req->rq_reply_truncate) { + if (req->rq_reply_truncated) { if (ptlrpc_no_resend(req)) { DEBUG_REQ(D_ERROR, req, "reply buffer overflow, expected: %d, actual size: %d", req->rq_nob_received, req->rq_repbuf_len); @@ -2342,9 +2342,10 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) LASSERT(rc == -ETIMEDOUT); DEBUG_REQ(D_WARNING, request, - "Unexpectedly long timeout rvcng=%d unlnk=%d/%d", + "Unexpectedly long timeout receiving_reply=%d req_ulinked=%d reply_unlinked=%d", request->rq_receiving_reply, - request->rq_req_unlink, request->rq_reply_unlink); + request->rq_req_unlinked, + request->rq_reply_unlinked); } return 0; } @@ -3002,9 +3003,6 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, req->rq_import = class_import_get(imp); req->rq_interpret_reply = work_interpreter; /* don't want reply */ - req->rq_receiving_reply = 0; - req->rq_req_unlink = 0; - req->rq_reply_unlink = 0; req->rq_no_delay = 1; req->rq_no_resend = 1; req->rq_pill.rc_fmt = (void *)&worker_format; diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index 95be4aa..a243342 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -51,27 +51,33 @@ void request_out_callback(lnet_event_t *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; + bool wakeup = false; - LASSERT(ev->type == LNET_EVENT_SEND || - ev->type == LNET_EVENT_UNLINK); + LASSERT(ev->type == LNET_EVENT_SEND || ev->type == LNET_EVENT_UNLINK); LASSERT(ev->unlinked); DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status); sptlrpc_request_out_callback(req); + spin_lock(&req->rq_lock); req->rq_real_sent = ktime_get_real_seconds(); - if (ev->unlinked) - req->rq_req_unlink = 0; + req->rq_req_unlinked = 1; + /* reply_in_callback happened before request_out_callback? */ + if (req->rq_reply_unlinked) + wakeup = true; if (ev->type == LNET_EVENT_UNLINK || ev->status != 0) { /* Failed send: make it seem like the reply timed out, just * like failing sends in client.c does currently... */ - req->rq_net_err = 1; - ptlrpc_client_wake_req(req); + wakeup = true; } + + if (wakeup) + ptlrpc_client_wake_req(req); + spin_unlock(&req->rq_lock); ptlrpc_req_finished(req); @@ -100,7 +106,7 @@ void reply_in_callback(lnet_event_t *ev) req->rq_receiving_reply = 0; req->rq_early = 0; if (ev->unlinked) - req->rq_reply_unlink = 0; + req->rq_reply_unlinked = 1; if (ev->status) goto out_wake; @@ -114,7 +120,7 @@ void reply_in_callback(lnet_event_t *ev) if (ev->mlength < ev->rlength) { CDEBUG(D_RPCTRACE, "truncate req %p rpc %d - %d+%d\n", req, req->rq_replen, ev->rlength, ev->offset); - req->rq_reply_truncate = 1; + req->rq_reply_truncated = 1; req->rq_replied = 1; req->rq_status = -EOVERFLOW; req->rq_nob_received = ev->rlength + ev->offset; diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index 4e7d68f..8c49f5e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -577,19 +577,18 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) } spin_lock(&request->rq_lock); - /* If the MD attach succeeds, there _will_ be a reply_in callback */ - request->rq_receiving_reply = !noreply; - request->rq_req_unlink = 1; /* We are responsible for unlinking the reply buffer */ - request->rq_reply_unlink = !noreply; + request->rq_reply_unlinked = noreply; + request->rq_receiving_reply = !noreply; /* Clear any flags that may be present from previous sends. */ + request->rq_req_unlinked = 0; request->rq_replied = 0; request->rq_err = 0; request->rq_timedout = 0; request->rq_net_err = 0; request->rq_resend = 0; request->rq_restart = 0; - request->rq_reply_truncate = 0; + request->rq_reply_truncated = 0; spin_unlock(&request->rq_lock); if (!noreply) { @@ -604,7 +603,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) reply_md.user_ptr = &request->rq_reply_cbid; reply_md.eq_handle = ptlrpc_eq_h; - /* We must see the unlink callback to unset rq_reply_unlink, + /* We must see the unlink callback to set rq_reply_unlinked, * so we can't auto-unlink */ rc = LNetMDAttach(reply_me_h, reply_md, LNET_RETAIN, @@ -651,9 +650,10 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) connection, request->rq_request_portal, request->rq_xid, 0); - if (rc == 0) + if (likely(rc == 0)) goto out; + request->rq_req_unlinked = 1; ptlrpc_req_finished(request); if (noreply) goto out; diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h index d3674cb..a9831fa 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h @@ -304,6 +304,15 @@ static inline void ptlrpc_cli_req_init(struct ptlrpc_request *req) struct ptlrpc_cli_req *cr = &req->rq_cli; ptlrpc_req_comm_init(req); + + req->rq_receiving_reply = 0; + req->rq_req_unlinked = 1; + req->rq_reply_unlinked = 1; + + req->rq_receiving_reply = 0; + req->rq_req_unlinked = 1; + req->rq_reply_unlinked = 1; + INIT_LIST_HEAD(&cr->cr_set_chain); INIT_LIST_HEAD(&cr->cr_ctx_chain); init_waitqueue_head(&cr->cr_reply_waitq); -- cgit v1.1 From af38abfcd971a10b6f41d03a765e85b59b841cfb Mon Sep 17 00:00:00 2001 From: Vitaly Fertman Date: Mon, 20 Jun 2016 16:55:32 -0400 Subject: staging/lustre/ptlrpc: Early Reply vs Reply MDunlink A race between unregister_reply & early reply. When buffers are busy for the early transfer, they cannon be unlinked by unregister_reply, so the RPC gets into UNREGISTERING state. The coming reply_in_callback for the early RPC already has unlinked flag set due to previous mdunlink attempt, but we handle it properly only for UNILNK event, whereas this is PUT in this case. Signed-off-by: Vitaly Fertman Seagate-bug-id: MRP-3323 Reviewed-by: Alexey Leonidovich Lyashkov Reviewed-by: Andriy Skulysh Tested-by: Parinay Vijayprakash Kondekar Reviewed-on: http://review.whamcloud.com/18934 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7434 Reviewed-by: Chris Horn Reviewed-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/events.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index a243342..b1ce725 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -137,7 +137,8 @@ void reply_in_callback(lnet_event_t *ev) req->rq_early_count++; /* number received, client side */ - if (req->rq_replied) /* already got the real reply */ + /* already got the real reply or buffers are already unlinked */ + if (req->rq_replied || req->rq_reply_unlinked == 1) goto out_wake; req->rq_early = 1; -- cgit v1.1 From 63a46519f2b38f2afc7767273460b86792f8d94d Mon Sep 17 00:00:00 2001 From: Ben Evans Date: Mon, 20 Jun 2016 16:55:33 -0400 Subject: staging/lustre/ptlrpc: Remove __ptlrpc_request_bufs_pack Combine __ptlrpc_request_bufs_pack into ptlrpc_request_bufs_pack because it was an unnecessary wrapper otherwise. Signed-off-by: Ben Evans Reviewed-on: http://review.whamcloud.com/16765 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7269 Reviewed-by: Frank Zago Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-by: Chris Horn Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/client.c | 34 ++++++++++----------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index ae1cef3..5d832eb 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -583,14 +583,19 @@ static void __ptlrpc_free_req_to_pool(struct ptlrpc_request *request) spin_unlock(&pool->prp_lock); } -static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request, - __u32 version, int opcode, - int count, __u32 *lengths, char **bufs, - struct ptlrpc_cli_ctx *ctx) +int ptlrpc_request_bufs_pack(struct ptlrpc_request *request, + __u32 version, int opcode, char **bufs, + struct ptlrpc_cli_ctx *ctx) { - struct obd_import *imp = request->rq_import; + int count; + struct obd_import *imp; + __u32 *lengths; int rc; + count = req_capsule_filled_sizes(&request->rq_pill, RCL_CLIENT); + imp = request->rq_import; + lengths = request->rq_pill.rc_area[RCL_CLIENT]; + if (unlikely(ctx)) { request->rq_cli_ctx = sptlrpc_cli_ctx_get(ctx); } else { @@ -598,15 +603,12 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request, if (rc) goto out_free; } - sptlrpc_req_set_flavor(request, opcode); rc = lustre_pack_request(request, imp->imp_msg_magic, count, lengths, bufs); - if (rc) { - LASSERT(!request->rq_pool); + if (rc) goto out_ctx; - } lustre_msg_add_version(request->rq_reqmsg, version); request->rq_send_state = LUSTRE_IMP_FULL; @@ -631,24 +633,14 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request, lustre_msg_set_opc(request->rq_reqmsg, opcode); return 0; + out_ctx: + LASSERT(!request->rq_pool); sptlrpc_cli_ctx_put(request->rq_cli_ctx, 1); out_free: class_import_put(imp); return rc; } - -int ptlrpc_request_bufs_pack(struct ptlrpc_request *request, - __u32 version, int opcode, char **bufs, - struct ptlrpc_cli_ctx *ctx) -{ - int count; - - count = req_capsule_filled_sizes(&request->rq_pill, RCL_CLIENT); - return __ptlrpc_request_bufs_pack(request, version, opcode, count, - request->rq_pill.rc_area[RCL_CLIENT], - bufs, ctx); -} EXPORT_SYMBOL(ptlrpc_request_bufs_pack); /** -- cgit v1.1 From 81ea39ecf963fe0c44b8772a19863ecb154782f6 Mon Sep 17 00:00:00 2001 From: Vitaly Fertman Date: Mon, 20 Jun 2016 16:55:34 -0400 Subject: staging/lustre/ptlrpc: lost bulk leads to a hang The reverse order of request_out_callback() and reply_in_callback() puts the RPC into UNREGISTERING state, which is waiting for RPC & bulk md unlink, whereas only RPC md unlink has been called so far. If bulk is lost, even expired_set does not check for UNREGISTERING state. The same for write if server returns an error. This phase is ambiguous, split to UNREG_RPC and UNREG_BULK. Signed-off-by: Vitaly Fertman Seagate-bug-id: MRP-2953, MRP-3206 Reviewed-by: Andriy Skulysh Reviewed-by: Alexey Leonidovich Lyashkov Tested-by: Elena V. Gryaznova Reviewed-on: http://review.whamcloud.com/19953 Reviewed-by: Chris Horn Reviewed-by: Ann Koehler Reviewed-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_net.h | 48 +++++++++------- .../staging/lustre/lustre/include/obd_support.h | 3 + drivers/staging/lustre/lustre/ptlrpc/client.c | 64 +++++++++++++++++++--- drivers/staging/lustre/lustre/ptlrpc/import.c | 3 +- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 4 +- 5 files changed, 91 insertions(+), 31 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 0fedef9..d5debd6 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -480,8 +480,9 @@ enum rq_phase { RQ_PHASE_BULK = 0xebc0de02, RQ_PHASE_INTERPRET = 0xebc0de03, RQ_PHASE_COMPLETE = 0xebc0de04, - RQ_PHASE_UNREGISTERING = 0xebc0de05, - RQ_PHASE_UNDEFINED = 0xebc0de06 + RQ_PHASE_UNREG_RPC = 0xebc0de05, + RQ_PHASE_UNREG_BULK = 0xebc0de06, + RQ_PHASE_UNDEFINED = 0xebc0de07 }; /** Type of request interpreter call-back */ @@ -1263,6 +1264,8 @@ struct ptlrpc_cli_req { time_t cr_reply_deadline; /** when req bulk unlink must finish. */ time_t cr_bulk_deadline; + /** when req unlink must finish. */ + time_t cr_req_deadline; /** Portal to which this request would be sent */ short cr_req_ptl; /** Portal where to wait for reply and where reply would be sent */ @@ -1318,6 +1321,7 @@ struct ptlrpc_cli_req { #define rq_real_sent rq_cli.cr_sent_out #define rq_reply_deadline rq_cli.cr_reply_deadline #define rq_bulk_deadline rq_cli.cr_bulk_deadline +#define rq_req_deadline rq_cli.cr_req_deadline #define rq_nr_resend rq_cli.cr_resend_nr #define rq_request_portal rq_cli.cr_req_ptl #define rq_reply_portal rq_cli.cr_rep_ptl @@ -1692,8 +1696,10 @@ ptlrpc_phase2str(enum rq_phase phase) return "Interpret"; case RQ_PHASE_COMPLETE: return "Complete"; - case RQ_PHASE_UNREGISTERING: - return "Unregistering"; + case RQ_PHASE_UNREG_RPC: + return "UnregRPC"; + case RQ_PHASE_UNREG_BULK: + return "UnregBULK"; default: return "?Phase?"; } @@ -1720,7 +1726,7 @@ ptlrpc_rqphase2str(struct ptlrpc_request *req) #define DEBUG_REQ_FLAGS(req) \ ptlrpc_rqphase2str(req), \ FLAG(req->rq_intr, "I"), FLAG(req->rq_replied, "R"), \ - FLAG(req->rq_err, "E"), \ + FLAG(req->rq_err, "E"), FLAG(req->rq_net_err, "e"), \ FLAG(req->rq_timedout, "X") /* eXpired */, FLAG(req->rq_resend, "S"), \ FLAG(req->rq_restart, "T"), FLAG(req->rq_replay, "P"), \ FLAG(req->rq_no_resend, "N"), \ @@ -1728,7 +1734,7 @@ ptlrpc_rqphase2str(struct ptlrpc_request *req) FLAG(req->rq_wait_ctx, "C"), FLAG(req->rq_hp, "H"), \ FLAG(req->rq_committed, "M") -#define REQ_FLAGS_FMT "%s:%s%s%s%s%s%s%s%s%s%s%s%s" +#define REQ_FLAGS_FMT "%s:%s%s%s%s%s%s%s%s%s%s%s%s%s" void _debug_req(struct ptlrpc_request *req, struct libcfs_debug_msg_data *data, const char *fmt, ...) @@ -2379,8 +2385,7 @@ static inline int ptlrpc_client_bulk_active(struct ptlrpc_request *req) desc = req->rq_bulk; - if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK) && - req->rq_bulk_deadline > ktime_get_real_seconds()) + if (req->rq_bulk_deadline > ktime_get_real_seconds()) return 1; if (!desc) @@ -2727,13 +2732,20 @@ ptlrpc_rqphase_move(struct ptlrpc_request *req, enum rq_phase new_phase) if (req->rq_phase == new_phase) return; - if (new_phase == RQ_PHASE_UNREGISTERING) { + if (new_phase == RQ_PHASE_UNREG_RPC || + new_phase == RQ_PHASE_UNREG_BULK) { + /* No embedded unregistering phases */ + if (req->rq_phase == RQ_PHASE_UNREG_RPC || + req->rq_phase == RQ_PHASE_UNREG_BULK) + return; + req->rq_next_phase = req->rq_phase; if (req->rq_import) atomic_inc(&req->rq_import->imp_unregistering); } - if (req->rq_phase == RQ_PHASE_UNREGISTERING) { + if (req->rq_phase == RQ_PHASE_UNREG_RPC || + req->rq_phase == RQ_PHASE_UNREG_BULK) { if (req->rq_import) atomic_dec(&req->rq_import->imp_unregistering); } @@ -2750,9 +2762,6 @@ ptlrpc_rqphase_move(struct ptlrpc_request *req, enum rq_phase new_phase) static inline int ptlrpc_client_early(struct ptlrpc_request *req) { - if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && - req->rq_reply_deadline > ktime_get_real_seconds()) - return 0; return req->rq_early; } @@ -2762,8 +2771,7 @@ ptlrpc_client_early(struct ptlrpc_request *req) static inline int ptlrpc_client_replied(struct ptlrpc_request *req) { - if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && - req->rq_reply_deadline > ktime_get_real_seconds()) + if (req->rq_reply_deadline > ktime_get_real_seconds()) return 0; return req->rq_replied; } @@ -2772,8 +2780,7 @@ ptlrpc_client_replied(struct ptlrpc_request *req) static inline int ptlrpc_client_recv(struct ptlrpc_request *req) { - if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && - req->rq_reply_deadline > ktime_get_real_seconds()) + if (req->rq_reply_deadline > ktime_get_real_seconds()) return 1; return req->rq_receiving_reply; } @@ -2784,8 +2791,11 @@ ptlrpc_client_recv_or_unlink(struct ptlrpc_request *req) int rc; spin_lock(&req->rq_lock); - if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && - req->rq_reply_deadline > ktime_get_real_seconds()) { + if (req->rq_reply_deadline > ktime_get_real_seconds()) { + spin_unlock(&req->rq_lock); + return 1; + } + if (req->rq_req_deadline > ktime_get_real_seconds()) { spin_unlock(&req->rq_lock); return 1; } diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index cdf20d6..845e64a5 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -364,6 +364,9 @@ extern char obd_jobid_var[]; #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2 0x515 #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x517 +#define OBD_FAIL_PTLRPC_DROP_BULK 0x51a +#define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b +#define OBD_FAIL_PTLRPC_LONG_BOTH_UNLINK 0x51c #define OBD_FAIL_OBD_PING_NET 0x600 #define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601 diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 5d832eb..d4463d7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -621,6 +621,8 @@ int ptlrpc_request_bufs_pack(struct ptlrpc_request *request, request->rq_reply_cbid.cbid_arg = request; request->rq_reply_deadline = 0; + request->rq_bulk_deadline = 0; + request->rq_req_deadline = 0; request->rq_phase = RQ_PHASE_NEW; request->rq_next_phase = RQ_PHASE_UNDEFINED; @@ -632,6 +634,37 @@ int ptlrpc_request_bufs_pack(struct ptlrpc_request *request, request->rq_xid = ptlrpc_next_xid(); lustre_msg_set_opc(request->rq_reqmsg, opcode); + /* Let's setup deadline for req/reply/bulk unlink for opcode. */ + if (cfs_fail_val == opcode) { + time_t *fail_t = NULL, *fail2_t = NULL; + + if (CFS_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK)) { + fail_t = &request->rq_bulk_deadline; + } else if (CFS_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK)) { + fail_t = &request->rq_reply_deadline; + } else if (CFS_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REQ_UNLINK)) { + fail_t = &request->rq_req_deadline; + } else if (CFS_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BOTH_UNLINK)) { + fail_t = &request->rq_reply_deadline; + fail2_t = &request->rq_bulk_deadline; + } + + if (fail_t) { + *fail_t = ktime_get_real_seconds() + LONG_UNLINK; + + if (fail2_t) + *fail2_t = ktime_get_real_seconds() + + LONG_UNLINK; + + /* The RPC is infected, let the test change the + * fail_loc + */ + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(cfs_time_seconds(2)); + set_current_state(TASK_RUNNING); + } + } + return 0; out_ctx: @@ -1481,16 +1514,28 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) if (!(req->rq_phase == RQ_PHASE_RPC || req->rq_phase == RQ_PHASE_BULK || req->rq_phase == RQ_PHASE_INTERPRET || - req->rq_phase == RQ_PHASE_UNREGISTERING || + req->rq_phase == RQ_PHASE_UNREG_RPC || + req->rq_phase == RQ_PHASE_UNREG_BULK || req->rq_phase == RQ_PHASE_COMPLETE)) { DEBUG_REQ(D_ERROR, req, "bad phase %x", req->rq_phase); LBUG(); } - if (req->rq_phase == RQ_PHASE_UNREGISTERING) { + if (req->rq_phase == RQ_PHASE_UNREG_RPC || + req->rq_phase == RQ_PHASE_UNREG_BULK) { LASSERT(req->rq_next_phase != req->rq_phase); LASSERT(req->rq_next_phase != RQ_PHASE_UNDEFINED); + if (req->rq_req_deadline && + !OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REQ_UNLINK)) + req->rq_req_deadline = 0; + if (req->rq_reply_deadline && + !OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK)) + req->rq_reply_deadline = 0; + if (req->rq_bulk_deadline && + !OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK)) + req->rq_bulk_deadline = 0; + /* * Skip processing until reply is unlinked. We * can't return to pool before that and we can't @@ -1498,7 +1543,10 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) * sure that all rdma transfers finished and will * not corrupt any data. */ - if (ptlrpc_client_recv_or_unlink(req) || + if (req->rq_phase == RQ_PHASE_UNREG_RPC && + ptlrpc_client_recv_or_unlink(req)) + continue; + if (req->rq_phase == RQ_PHASE_UNREG_BULK && ptlrpc_client_bulk_active(req)) continue; @@ -1976,7 +2024,7 @@ void ptlrpc_interrupted_set(void *data) list_entry(tmp, struct ptlrpc_request, rq_set_chain); if (req->rq_phase != RQ_PHASE_RPC && - req->rq_phase != RQ_PHASE_UNREGISTERING) + req->rq_phase != RQ_PHASE_UNREG_RPC) continue; ptlrpc_mark_interrupted(req); @@ -2288,8 +2336,9 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) /* Let's setup deadline for reply unlink. */ if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && - async && request->rq_reply_deadline == 0) - request->rq_reply_deadline = ktime_get_real_seconds()+LONG_UNLINK; + async && request->rq_reply_deadline == 0 && cfs_fail_val == 0) + request->rq_reply_deadline = + ktime_get_real_seconds() + LONG_UNLINK; /* Nothing left to do. */ if (!ptlrpc_client_recv_or_unlink(request)) @@ -2302,7 +2351,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) return 1; /* Move to "Unregistering" phase as reply was not unlinked yet. */ - ptlrpc_rqphase_move(request, RQ_PHASE_UNREGISTERING); + ptlrpc_rqphase_move(request, RQ_PHASE_UNREG_RPC); /* Do not wait for unlink to finish. */ if (async) @@ -2932,7 +2981,6 @@ static void ptlrpcd_add_work_req(struct ptlrpc_request *req) req->rq_timeout = obd_timeout; req->rq_sent = ktime_get_real_seconds(); req->rq_deadline = req->rq_sent + req->rq_timeout; - req->rq_reply_deadline = req->rq_deadline; req->rq_phase = RQ_PHASE_INTERPRET; req->rq_next_phase = RQ_PHASE_COMPLETE; req->rq_xid = ptlrpc_next_xid(); diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 914bbd2..3292e6e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -356,9 +356,8 @@ void ptlrpc_invalidate_import(struct obd_import *imp) "still on delayed list"); } - CERROR("%s: RPCs in \"%s\" phase found (%d). Network is sluggish? Waiting them to error out.\n", + CERROR("%s: Unregistering RPCs found (%d). Network is sluggish? Waiting them to error out.\n", cli_tgt, - ptlrpc_phase2str(RQ_PHASE_UNREGISTERING), atomic_read(&imp-> imp_unregistering)); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index 8c49f5e..11ec825 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -247,7 +247,7 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) /* Let's setup deadline for reply unlink. */ if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK) && - async && req->rq_bulk_deadline == 0) + async && req->rq_bulk_deadline == 0 && cfs_fail_val == 0) req->rq_bulk_deadline = ktime_get_real_seconds() + LONG_UNLINK; if (ptlrpc_client_bulk_active(req) == 0) /* completed or */ @@ -266,7 +266,7 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) return 1; /* never registered */ /* Move to "Unregistering" phase as bulk was not unlinked yet. */ - ptlrpc_rqphase_move(req, RQ_PHASE_UNREGISTERING); + ptlrpc_rqphase_move(req, RQ_PHASE_UNREG_BULK); /* Do not wait for unlink to finish. */ if (async) -- cgit v1.1 From 0e5fd06ca069a8edc32a035add93112f6681dd72 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Mon, 20 Jun 2016 16:55:35 -0400 Subject: staging/lustre/llite: take trunc_sem only at vvp layer The lli_trunc_sem is taken in 'read' mode in both ll_page_mkwrite and vvp_io_fault_start. This can lead to a deadlock with another thread which asks for the semaphore in write mode between thse two read calls. Since all users of lli_trunc_sem are in the vvp layer, we can satisfy the requirement to exclude truncate by taking the semaphore only in vvp_io_fault_start. Signed-off-by: Patrick Farrell Reviewed-on: http://review.whamcloud.com/19315 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7981 Reviewed-by: Jinshan Xiong Reviewed-by: Andriy Skulysh Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_mmap.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index fb1c3b6..66ee5db5 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -196,18 +196,11 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, set = cfs_block_sigsinv(sigmask(SIGKILL) | sigmask(SIGTERM)); - /* we grab lli_trunc_sem to exclude truncate case. - * Otherwise, we could add dirty pages into osc cache - * while truncate is on-going. - */ inode = vvp_object_inode(io->ci_obj); lli = ll_i2info(inode); - down_read(&lli->lli_trunc_sem); result = cl_io_loop(env, io); - up_read(&lli->lli_trunc_sem); - cfs_restore_sigs(set); if (result == 0) { -- cgit v1.1 From e93876dd730f0d87a6a79b1e867a9e8b4097674f Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Mon, 20 Jun 2016 16:55:36 -0400 Subject: staging/lustre: LDLM_DEBUG() shouldn't be passed \n as it adds own \n, so any extra \n break log format. Signed-off-by: Alex Zhuravlev Reviewed-on: http://review.whamcloud.com/17494 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7521 Reviewed-by: James Simmons Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 3 ++- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 2 +- drivers/staging/lustre/lustre/lov/lov_object.c | 4 ++-- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 2 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 4 ++-- drivers/staging/lustre/lustre/osc/osc_lock.c | 2 +- 8 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 1ecdfa2..b7254eb 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -1440,7 +1440,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, memcpy(data, lvb, size); break; default: - LDLM_ERROR(lock, "Unknown LVB type: %d\n", lock->l_lvb_type); + LDLM_ERROR(lock, "Unknown LVB type: %d", lock->l_lvb_type); dump_stack(); return -EINVAL; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 3eab059..8294703 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -637,7 +637,8 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) */ if ((ldlm_is_canceling(lock) && ldlm_is_bl_done(lock)) || ldlm_is_failed(lock)) { - LDLM_DEBUG(lock, "callback on lock %#llx - lock disappeared\n", + LDLM_DEBUG(lock, + "callback on lock %#llx - lock disappeared", dlm_req->lock_handle[0].cookie); unlock_res_and_lock(lock); LDLM_LOCK_RELEASE(lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 471ab08..d3a376e 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -711,7 +711,7 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, lock->l_req_extent = policy->l_extent; } - LDLM_DEBUG(lock, "client-side enqueue START, flags %llx\n", + LDLM_DEBUG(lock, "client-side enqueue START, flags %llx", *flags); } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index f7c95b7..51a28d9 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -1275,7 +1275,7 @@ void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head, { check_res_locked(res); - LDLM_DEBUG(lock, "About to add this lock:\n"); + LDLM_DEBUG(lock, "About to add this lock:"); if (ldlm_is_destroyed(lock)) { CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n"); diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index ec55b88..f9621b0 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -181,8 +181,8 @@ static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, } LU_OBJECT_DEBUG(mask, env, &stripe->co_lu, - "stripe %d is already owned.\n", idx); - LU_OBJECT_DEBUG(mask, env, old_obj, "owned.\n"); + "stripe %d is already owned.", idx); + LU_OBJECT_DEBUG(mask, env, old_obj, "owned."); LU_OBJECT_HEADER(mask, env, lov2lu(lov), "try to own.\n"); cl_object_put(env, stripe); } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index d55a5d8..b154aff 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -692,7 +692,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, if (lock && ldlm_has_layout(lock) && lvb_data) { void *lmm; - LDLM_DEBUG(lock, "layout lock returned by: %s, lvb_len: %d\n", + LDLM_DEBUG(lock, "layout lock returned by: %s, lvb_len: %d", ldlm_it2str(it->it_op), lvb_len); lmm = libcfs_kvzalloc(lvb_len, GFP_NOFS); diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 4c78b53..d1a7d6b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -123,9 +123,9 @@ static const char *oes_strings[] = { /* ----- part 4 ----- */ \ ## __VA_ARGS__); \ if (lvl == D_ERROR && __ext->oe_dlmlock) \ - LDLM_ERROR(__ext->oe_dlmlock, "extent: %p\n", __ext); \ + LDLM_ERROR(__ext->oe_dlmlock, "extent: %p", __ext); \ else \ - LDLM_DEBUG(__ext->oe_dlmlock, "extent: %p\n", __ext); \ + LDLM_DEBUG(__ext->oe_dlmlock, "extent: %p", __ext); \ } while (0) #undef EASSERTF diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 5455d9d..717d3ff 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -1168,7 +1168,7 @@ int osc_lock_init(const struct lu_env *env, osc_lock_set_writer(env, io, obj, oscl); - LDLM_DEBUG_NOLOCK("lock %p, osc lock %p, flags %llx\n", + LDLM_DEBUG_NOLOCK("lock %p, osc lock %p, flags %llx", lock, oscl, oscl->ols_flags); return 0; -- cgit v1.1 From d55d5e8f49574acb034eff08dff6dc250481354b Mon Sep 17 00:00:00 2001 From: Bob Glossman Date: Mon, 20 Jun 2016 16:55:37 -0400 Subject: staging/lustre: Add newline to LU_OBJECT_DEBUG() message LU_OBJECT_DEBUG expects non \n terminated message from the caller, so it should add it's own to keep debug logger happy. Signed-off-by: Bob Glossman Reviewed-on: http://review.whamcloud.com/19960 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8094 Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Reviewed-by: John L. Hammond Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lu_object.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index c6281e6..6e25c1b 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -779,7 +779,7 @@ do { \ if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM)) { \ LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, mask, NULL); \ lu_object_print(env, &msgdata, lu_cdebug_printer, object);\ - CDEBUG(mask, format, ## __VA_ARGS__); \ + CDEBUG(mask, format "\n", ## __VA_ARGS__); \ } \ } while (0) -- cgit v1.1 From e476f2e55aa9e6769875795eb1835a3ac7855379 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Mon, 20 Jun 2016 16:55:38 -0400 Subject: staging/lustre/llite: flatten struct lookup_intent Replace the union in struct lookup_intent with the members of struct lustre_indent_data. Remove the then unused struct lustre_intent_data. Signed-off-by: John L. Hammond Reviewed-on: http://review.whamcloud.com/17069 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7403 Reviewed-by: James Simmons Reviewed-by: Dmitry Eremin Reviewed-by: Frank Zago Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/include/lustre_intent.h | 15 ++-- drivers/staging/lustre/lustre/llite/dcache.c | 26 +++---- drivers/staging/lustre/lustre/llite/dir.c | 4 +- drivers/staging/lustre/lustre/llite/file.c | 44 ++++++------ .../staging/lustre/lustre/llite/llite_internal.h | 14 ++-- drivers/staging/lustre/lustre/llite/llite_lib.c | 4 +- drivers/staging/lustre/lustre/llite/namei.c | 8 +-- drivers/staging/lustre/lustre/llite/statahead.c | 10 +-- drivers/staging/lustre/lustre/llite/xattr_cache.c | 16 ++--- drivers/staging/lustre/lustre/lmv/lmv_intent.c | 26 +++---- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 8 +-- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 79 +++++++++++----------- drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +- 13 files changed, 125 insertions(+), 131 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_intent.h b/drivers/staging/lustre/lustre/include/lustre_intent.h index fdc6236..41c03d7 100644 --- a/drivers/staging/lustre/lustre/include/lustre_intent.h +++ b/drivers/staging/lustre/lustre/include/lustre_intent.h @@ -34,7 +34,11 @@ #define LUSTRE_INTENT_H /* intent IT_XXX are defined in lustre/include/obd.h */ -struct lustre_intent_data { + +struct lookup_intent { + int it_op; + int it_create_mode; + __u64 it_flags; int it_disposition; int it_status; __u64 it_lock_handle; @@ -46,13 +50,4 @@ struct lustre_intent_data { unsigned int it_lock_set:1; }; -struct lookup_intent { - int it_op; - int it_create_mode; - __u64 it_flags; - union { - struct lustre_intent_data lustre; - } d; -}; - #endif diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index f002b3a..c5789f7 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -202,27 +202,27 @@ int ll_d_init(struct dentry *de) void ll_intent_drop_lock(struct lookup_intent *it) { - if (it->it_op && it->d.lustre.it_lock_mode) { + if (it->it_op && it->it_lock_mode) { struct lustre_handle handle; - handle.cookie = it->d.lustre.it_lock_handle; + handle.cookie = it->it_lock_handle; CDEBUG(D_DLMTRACE, "releasing lock with cookie %#llx from it %p\n", handle.cookie, it); - ldlm_lock_decref(&handle, it->d.lustre.it_lock_mode); + ldlm_lock_decref(&handle, it->it_lock_mode); /* bug 494: intent_release may be called multiple times, from * this thread and we don't want to double-decref this lock */ - it->d.lustre.it_lock_mode = 0; - if (it->d.lustre.it_remote_lock_mode != 0) { - handle.cookie = it->d.lustre.it_remote_lock_handle; + it->it_lock_mode = 0; + if (it->it_remote_lock_mode != 0) { + handle.cookie = it->it_remote_lock_handle; CDEBUG(D_DLMTRACE, "releasing remote lock with cookie%#llx from it %p\n", handle.cookie, it); ldlm_lock_decref(&handle, - it->d.lustre.it_remote_lock_mode); - it->d.lustre.it_remote_lock_mode = 0; + it->it_remote_lock_mode); + it->it_remote_lock_mode = 0; } } } @@ -233,13 +233,13 @@ void ll_intent_release(struct lookup_intent *it) ll_intent_drop_lock(it); /* We are still holding extra reference on a request, need to free it */ if (it_disposition(it, DISP_ENQ_OPEN_REF)) - ptlrpc_req_finished(it->d.lustre.it_data); /* ll_file_open */ + ptlrpc_req_finished(it->it_data); /* ll_file_open */ if (it_disposition(it, DISP_ENQ_CREATE_REF)) /* create rec */ - ptlrpc_req_finished(it->d.lustre.it_data); + ptlrpc_req_finished(it->it_data); - it->d.lustre.it_disposition = 0; - it->d.lustre.it_data = NULL; + it->it_disposition = 0; + it->it_data = NULL; } void ll_invalidate_aliases(struct inode *inode) @@ -279,7 +279,7 @@ int ll_revalidate_it_finish(struct ptlrpc_request *request, void ll_lookup_finish_locks(struct lookup_intent *it, struct inode *inode) { - if (it->d.lustre.it_lock_mode && inode) { + if (it->it_lock_mode && inode) { struct ll_sb_info *sbi = ll_i2sbi(inode); CDEBUG(D_DLMTRACE, "setting l_data to inode "DFID"(%p)\n", diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 2f2c57e..8839e10 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -362,7 +362,7 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, ll_finish_md_op_data(op_data); - request = (struct ptlrpc_request *)it.d.lustre.it_data; + request = (struct ptlrpc_request *)it.it_data; if (request) ptlrpc_req_finished(request); if (rc < 0) { @@ -374,7 +374,7 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, CDEBUG(D_INODE, "setting lr_lvb_inode to inode "DFID"(%p)\n", PFID(ll_inode2fid(dir)), dir); md_set_lock_data(ll_i2sbi(dir)->ll_md_exp, - &it.d.lustre.it_lock_handle, dir, NULL); + &it.it_lock_handle, dir, NULL); } else { /* for cross-ref object, l_ast_data of the lock may not be set, * we reset it here diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index c46e2ac..6cee41f 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -437,7 +437,7 @@ static int ll_intent_file_open(struct dentry *dentry, void *lmm, } rc = ll_prep_inode(&inode, req, NULL, itp); - if (!rc && itp->d.lustre.it_lock_mode) + if (!rc && itp->it_lock_mode) ll_set_lock_data(sbi->ll_md_exp, inode, itp, NULL); out: @@ -464,13 +464,13 @@ void ll_ioepoch_open(struct ll_inode_info *lli, __u64 ioepoch) static int ll_och_fill(struct obd_export *md_exp, struct lookup_intent *it, struct obd_client_handle *och) { - struct ptlrpc_request *req = it->d.lustre.it_data; + struct ptlrpc_request *req = it->it_data; struct mdt_body *body; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); och->och_fh = body->handle; och->och_fid = body->fid1; - och->och_lease_handle.cookie = it->d.lustre.it_lock_handle; + och->och_lease_handle.cookie = it->it_lock_handle; och->och_magic = OBD_CLIENT_HANDLE_MAGIC; och->och_flags = it->it_flags; @@ -488,7 +488,7 @@ static int ll_local_open(struct file *file, struct lookup_intent *it, LASSERT(fd); if (och) { - struct ptlrpc_request *req = it->d.lustre.it_data; + struct ptlrpc_request *req = it->it_data; struct mdt_body *body; int rc; @@ -563,7 +563,7 @@ int ll_file_open(struct inode *inode, struct file *file) return 0; } - if (!it || !it->d.lustre.it_disposition) { + if (!it || !it->it_disposition) { /* Convert f_flags into access mode. We cannot use file->f_mode, * because everything but O_ACCMODE mask was stripped from * there @@ -633,7 +633,7 @@ restart: } } else { LASSERT(*och_usecount == 0); - if (!it->d.lustre.it_disposition) { + if (!it->it_disposition) { /* We cannot just request lock handle now, new ELC code * means that one of other OPEN locks for this file * could be cancelled, and since blocking ast handler @@ -670,7 +670,7 @@ restart: LASSERTF(it_disposition(it, DISP_ENQ_OPEN_REF), "inode %p: disposition %x, status %d\n", inode, - it_disposition(it, ~0), it->d.lustre.it_status); + it_disposition(it, ~0), it->it_status); rc = ll_local_open(file, it, fd, *och_p); if (rc) @@ -713,7 +713,7 @@ out_openerr: } if (it && it_disposition(it, DISP_ENQ_OPEN_REF)) { - ptlrpc_req_finished(it->d.lustre.it_data); + ptlrpc_req_finished(it->it_data); it_clear_disposition(it, DISP_ENQ_OPEN_REF); } @@ -854,12 +854,12 @@ ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode, /* already get lease, handle lease lock */ ll_set_lock_data(sbi->ll_md_exp, inode, &it, NULL); - if (it.d.lustre.it_lock_mode == 0 || - it.d.lustre.it_lock_bits != MDS_INODELOCK_OPEN) { + if (it.it_lock_mode == 0 || + it.it_lock_bits != MDS_INODELOCK_OPEN) { /* open lock must return for lease */ CERROR(DFID "lease granted but no open lock, %d/%llu.\n", - PFID(ll_inode2fid(inode)), it.d.lustre.it_lock_mode, - it.d.lustre.it_lock_bits); + PFID(ll_inode2fid(inode)), it.it_lock_mode, + it.it_lock_bits); rc = -EPROTO; goto out_close; } @@ -869,10 +869,10 @@ ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode, out_close: /* Cancel open lock */ - if (it.d.lustre.it_lock_mode != 0) { + if (it.it_lock_mode != 0) { ldlm_lock_decref_and_cancel(&och->och_lease_handle, - it.d.lustre.it_lock_mode); - it.d.lustre.it_lock_mode = 0; + it.it_lock_mode); + it.it_lock_mode = 0; och->och_lease_handle.cookie = 0ULL; } rc2 = ll_close_inode_openhandle(sbi->ll_md_exp, inode, och, NULL); @@ -1388,7 +1388,7 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct dentry *dentry, rc = ll_intent_file_open(dentry, lum, lum_size, &oit); if (rc) goto out_unlock; - rc = oit.d.lustre.it_status; + rc = oit.it_status; if (rc < 0) goto out_req_free; @@ -1401,7 +1401,7 @@ out_unlock: out: return rc; out_req_free: - ptlrpc_req_finished((struct ptlrpc_request *)oit.d.lustre.it_data); + ptlrpc_req_finished((struct ptlrpc_request *)oit.it_data); goto out; } @@ -1689,7 +1689,7 @@ int ll_release_openhandle(struct inode *inode, struct lookup_intent *it) out: /* this one is in place of ll_file_open */ if (it_disposition(it, DISP_ENQ_OPEN_REF)) { - ptlrpc_req_finished(it->d.lustre.it_data); + ptlrpc_req_finished(it->it_data); it_clear_disposition(it, DISP_ENQ_OPEN_REF); } return rc; @@ -3595,13 +3595,13 @@ again: rc = md_enqueue(sbi->ll_md_exp, &einfo, &it, op_data, &lockh, NULL, 0, NULL, 0); - ptlrpc_req_finished(it.d.lustre.it_data); - it.d.lustre.it_data = NULL; + ptlrpc_req_finished(it.it_data); + it.it_data = NULL; ll_finish_md_op_data(op_data); - mode = it.d.lustre.it_lock_mode; - it.d.lustre.it_lock_mode = 0; + mode = it.it_lock_mode; + it.it_lock_mode = 0; ll_intent_drop_lock(&it); if (rc == 0) { diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 973dcc7..08cc2c1 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -1196,7 +1196,7 @@ static inline int ll_file_nolock(const struct file *file) static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode, struct lookup_intent *it, __u64 *bits) { - if (!it->d.lustre.it_lock_set) { + if (!it->it_lock_set) { struct lustre_handle handle; /* If this inode is a remote object, it will get two @@ -1207,26 +1207,26 @@ static inline void ll_set_lock_data(struct obd_export *exp, struct inode *inode, * LOOKUP and PERM locks, so revoking either locks will * case the dcache being cleared */ - if (it->d.lustre.it_remote_lock_mode) { - handle.cookie = it->d.lustre.it_remote_lock_handle; + if (it->it_remote_lock_mode) { + handle.cookie = it->it_remote_lock_handle; CDEBUG(D_DLMTRACE, "setting l_data to inode "DFID"%p for remote lock %#llx\n", PFID(ll_inode2fid(inode)), inode, handle.cookie); md_set_lock_data(exp, &handle.cookie, inode, NULL); } - handle.cookie = it->d.lustre.it_lock_handle; + handle.cookie = it->it_lock_handle; CDEBUG(D_DLMTRACE, "setting l_data to inode "DFID"%p for lock %#llx\n", PFID(ll_inode2fid(inode)), inode, handle.cookie); md_set_lock_data(exp, &handle.cookie, inode, - &it->d.lustre.it_lock_bits); - it->d.lustre.it_lock_set = 1; + &it->it_lock_bits); + it->it_lock_set = 1; } if (bits) - *bits = it->d.lustre.it_lock_bits; + *bits = it->it_lock_bits; } static inline int d_lustre_invalid(const struct dentry *dentry) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 4ab1f2b..a741d6a 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1945,11 +1945,11 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, * 3. proc2: refresh layout and layout lock granted * 4. proc1: to apply a stale layout */ - if (it && it->d.lustre.it_lock_mode != 0) { + if (it && it->it_lock_mode != 0) { struct lustre_handle lockh; struct ldlm_lock *lock; - lockh.cookie = it->d.lustre.it_lock_handle; + lockh.cookie = it->it_lock_handle; lock = ldlm_handle2lock(&lockh); LASSERT(lock); if (ldlm_has_layout(lock)) { diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index e4df510..7a6da02 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -393,7 +393,7 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, * when I return */ CDEBUG(D_DENTRY, "it %p it_disposition %x\n", it, - it->d.lustre.it_disposition); + it->it_disposition); if (!it_disposition(it, DISP_LOOKUP_NEG)) { rc = ll_prep_inode(&inode, request, (*de)->d_sb, it); if (rc) @@ -445,7 +445,7 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request, /* Check that parent has UPDATE lock. */ struct lookup_intent parent_it = { .it_op = IT_GETATTR, - .d.lustre.it_lock_handle = 0 }; + .it_lock_handle = 0 }; if (md_revalidate_lock(ll_i2mdexp(parent), &parent_it, &ll_i2info(parent)->lli_fid, NULL)) { @@ -656,10 +656,10 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it) struct ll_sb_info *sbi = ll_i2sbi(dir); int rc; - LASSERT(it && it->d.lustre.it_disposition); + LASSERT(it && it->it_disposition); LASSERT(it_disposition(it, DISP_ENQ_CREATE_REF)); - request = it->d.lustre.it_data; + request = it->it_data; it_clear_disposition(it, DISP_ENQ_CREATE_REF); rc = ll_prep_inode(&inode, request, dir->i_sb, it); if (rc) { diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 03ad858..f775242 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -646,7 +646,7 @@ static void ll_post_statahead(struct ll_statahead_info *sai) } } - it->d.lustre.it_lock_handle = entry->se_handle; + it->it_lock_handle = entry->se_handle; rc = md_revalidate_lock(ll_i2mdexp(dir), it, ll_inode2fid(dir), NULL); if (rc != 1) { rc = -EAGAIN; @@ -700,7 +700,7 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, * process enqueues lock on child with parent lock held, eg. * unlink. */ - handle = it->d.lustre.it_lock_handle; + handle = it->it_lock_handle; ll_intent_drop_lock(it); } @@ -850,7 +850,7 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry, { struct inode *inode = d_inode(dentry); struct lookup_intent it = { .it_op = IT_GETATTR, - .d.lustre.it_lock_handle = 0 }; + .it_lock_handle = 0 }; struct md_enqueue_info *minfo; struct ldlm_enqueue_info *einfo; int rc; @@ -865,7 +865,7 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry, rc = md_revalidate_lock(ll_i2mdexp(dir), &it, ll_inode2fid(inode), NULL); if (rc == 1) { - entry->se_handle = it.d.lustre.it_lock_handle; + entry->se_handle = it.it_lock_handle; ll_intent_release(&it); return 1; } @@ -1569,7 +1569,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, if (entry->se_stat == SA_ENTRY_SUCC && entry->se_inode) { struct inode *inode = entry->se_inode; struct lookup_intent it = { .it_op = IT_GETATTR, - .d.lustre.it_lock_handle = + .it_lock_handle = entry->se_handle }; __u64 bits; diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index d7e17ab..0d19645 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -288,8 +288,8 @@ static int ll_xattr_find_get_lock(struct inode *inode, LCK_PR); if (mode != 0) { /* fake oit in mdc_revalidate_lock() manner */ - oit->d.lustre.it_lock_handle = lockh.cookie; - oit->d.lustre.it_lock_mode = mode; + oit->it_lock_handle = lockh.cookie; + oit->it_lock_mode = mode; goto out; } } @@ -315,7 +315,7 @@ static int ll_xattr_find_get_lock(struct inode *inode, return rc; } - *req = (struct ptlrpc_request *)oit->d.lustre.it_data; + *req = (struct ptlrpc_request *)oit->it_data; out: down_write(&lli->lli_xattrs_list_rwsem); mutex_unlock(&lli->lli_xattrs_enq_lock); @@ -362,10 +362,10 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) goto out_maybe_drop; } - if (oit->d.lustre.it_status < 0) { + if (oit->it_status < 0) { CDEBUG(D_CACHE, "getxattr intent returned %d for fid "DFID"\n", - oit->d.lustre.it_status, PFID(ll_inode2fid(inode))); - rc = oit->d.lustre.it_status; + oit->it_status, PFID(ll_inode2fid(inode))); + rc = oit->it_status; /* xattr data is so large that we don't want to cache it */ if (rc == -ERANGE) rc = -EAGAIN; @@ -448,8 +448,8 @@ out_destroy: up_write(&lli->lli_xattrs_list_rwsem); ldlm_lock_decref_and_cancel((struct lustre_handle *) - &oit->d.lustre.it_lock_handle, - oit->d.lustre.it_lock_mode); + &oit->it_lock_handle, + oit->it_lock_mode); goto out_no_unlock; } diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index 980c9d4..b3cff23 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -80,11 +80,11 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, /* * We got LOOKUP lock, but we really need attrs. */ - pmode = it->d.lustre.it_lock_mode; + pmode = it->it_lock_mode; if (pmode) { - plock.cookie = it->d.lustre.it_lock_handle; - it->d.lustre.it_lock_mode = 0; - it->d.lustre.it_data = NULL; + plock.cookie = it->it_lock_handle; + it->it_lock_mode = 0; + it->it_data = NULL; } LASSERT(fid_is_sane(&body->fid1)); @@ -130,14 +130,14 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, * maintain dcache consistency. Thus drop UPDATE|PERM lock here * and put LOOKUP in request. */ - if (it->d.lustre.it_lock_mode != 0) { - it->d.lustre.it_remote_lock_handle = - it->d.lustre.it_lock_handle; - it->d.lustre.it_remote_lock_mode = it->d.lustre.it_lock_mode; + if (it->it_lock_mode != 0) { + it->it_remote_lock_handle = + it->it_lock_handle; + it->it_remote_lock_mode = it->it_lock_mode; } - it->d.lustre.it_lock_handle = plock.cookie; - it->d.lustre.it_lock_mode = pmode; + it->it_lock_handle = plock.cookie; + it->it_lock_mode = pmode; out_free_op_data: kfree(op_data); @@ -197,9 +197,9 @@ static int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, * Nothing is found, do not access body->fid1 as it is zero and thus * pointless. */ - if ((it->d.lustre.it_disposition & DISP_LOOKUP_NEG) && - !(it->d.lustre.it_disposition & DISP_OPEN_CREATE) && - !(it->d.lustre.it_disposition & DISP_OPEN_OPEN)) + if ((it->it_disposition & DISP_LOOKUP_NEG) && + !(it->it_disposition & DISP_OPEN_CREATE) && + !(it->it_disposition & DISP_OPEN_OPEN)) return rc; body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY); diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 6483f2c..e6d7efa 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1679,7 +1679,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, struct lustre_handle *lockh, void *lmm, int lmmsize, __u64 extra_lock_flags) { - struct ptlrpc_request *req = it->d.lustre.it_data; + struct ptlrpc_request *req = it->it_data; struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct lustre_handle plock; @@ -1701,11 +1701,11 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, /* * We got LOOKUP lock, but we really need attrs. */ - pmode = it->d.lustre.it_lock_mode; + pmode = it->it_lock_mode; LASSERT(pmode != 0); memcpy(&plock, lockh, sizeof(plock)); - it->d.lustre.it_lock_mode = 0; - it->d.lustre.it_data = NULL; + it->it_lock_mode = 0; + it->it_data = NULL; fid1 = body->fid1; ptlrpc_req_finished(req); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index b154aff..53740d0 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -52,19 +52,19 @@ struct mdc_getattr_args { int it_disposition(struct lookup_intent *it, int flag) { - return it->d.lustre.it_disposition & flag; + return it->it_disposition & flag; } EXPORT_SYMBOL(it_disposition); void it_set_disposition(struct lookup_intent *it, int flag) { - it->d.lustre.it_disposition |= flag; + it->it_disposition |= flag; } EXPORT_SYMBOL(it_set_disposition); void it_clear_disposition(struct lookup_intent *it, int flag) { - it->d.lustre.it_disposition &= ~flag; + it->it_disposition &= ~flag; } EXPORT_SYMBOL(it_clear_disposition); @@ -72,39 +72,39 @@ int it_open_error(int phase, struct lookup_intent *it) { if (it_disposition(it, DISP_OPEN_LEASE)) { if (phase >= DISP_OPEN_LEASE) - return it->d.lustre.it_status; + return it->it_status; else return 0; } if (it_disposition(it, DISP_OPEN_OPEN)) { if (phase >= DISP_OPEN_OPEN) - return it->d.lustre.it_status; + return it->it_status; else return 0; } if (it_disposition(it, DISP_OPEN_CREATE)) { if (phase >= DISP_OPEN_CREATE) - return it->d.lustre.it_status; + return it->it_status; else return 0; } if (it_disposition(it, DISP_LOOKUP_EXECD)) { if (phase >= DISP_LOOKUP_EXECD) - return it->d.lustre.it_status; + return it->it_status; else return 0; } if (it_disposition(it, DISP_IT_EXECD)) { if (phase >= DISP_IT_EXECD) - return it->d.lustre.it_status; + return it->it_status; else return 0; } - CERROR("it disp: %X, status: %d\n", it->d.lustre.it_disposition, - it->d.lustre.it_status); + CERROR("it disp: %X, status: %d\n", it->it_disposition, + it->it_status); LBUG(); return 0; } @@ -542,7 +542,6 @@ static int mdc_finish_enqueue(struct obd_export *exp, struct req_capsule *pill = &req->rq_pill; struct ldlm_request *lockreq; struct ldlm_reply *lockrep; - struct lustre_intent_data *intent = &it->d.lustre; struct ldlm_lock *lock; void *lvb_data = NULL; int lvb_len = 0; @@ -576,17 +575,17 @@ static int mdc_finish_enqueue(struct obd_export *exp, lockrep = req_capsule_server_get(pill, &RMF_DLM_REP); - intent->it_disposition = (int)lockrep->lock_policy_res1; - intent->it_status = (int)lockrep->lock_policy_res2; - intent->it_lock_mode = einfo->ei_mode; - intent->it_lock_handle = lockh->cookie; - intent->it_data = req; + it->it_disposition = (int)lockrep->lock_policy_res1; + it->it_status = (int)lockrep->lock_policy_res2; + it->it_lock_mode = einfo->ei_mode; + it->it_lock_handle = lockh->cookie; + it->it_data = req; /* Technically speaking rq_transno must already be zero if * it_status is in error, so the check is a bit redundant */ - if ((!req->rq_transno || intent->it_status < 0) && req->rq_replay) - mdc_clear_replay_flag(req, intent->it_status); + if ((!req->rq_transno || it->it_status < 0) && req->rq_replay) + mdc_clear_replay_flag(req, it->it_status); /* If we're doing an IT_OPEN which did not result in an actual * successful open, then we need to remove the bit which saves @@ -597,11 +596,11 @@ static int mdc_finish_enqueue(struct obd_export *exp, * (bug 3440) */ if (it->it_op & IT_OPEN && req->rq_replay && - (!it_disposition(it, DISP_OPEN_OPEN) || intent->it_status != 0)) - mdc_clear_replay_flag(req, intent->it_status); + (!it_disposition(it, DISP_OPEN_OPEN) || it->it_status != 0)) + mdc_clear_replay_flag(req, it->it_status); DEBUG_REQ(D_RPCTRACE, req, "op: %d disposition: %x, status: %d", - it->it_op, intent->it_disposition, intent->it_status); + it->it_op, it->it_disposition, it->it_status); /* We know what to expect, so we do any byte flipping required here */ if (it->it_op & (IT_OPEN | IT_UNLINK | IT_LOOKUP | IT_GETATTR)) { @@ -900,9 +899,9 @@ resend: } ptlrpc_req_finished(req); - it->d.lustre.it_lock_handle = 0; - it->d.lustre.it_lock_mode = 0; - it->d.lustre.it_data = NULL; + it->it_lock_handle = 0; + it->it_lock_mode = 0; + it->it_data = NULL; } return rc; @@ -926,8 +925,8 @@ static int mdc_finish_intent_lock(struct obd_export *exp, /* The server failed before it even started executing the * intent, i.e. because it couldn't unpack the request. */ - LASSERT(it->d.lustre.it_status != 0); - return it->d.lustre.it_status; + LASSERT(it->it_status != 0); + return it->it_status; } rc = it_open_error(DISP_IT_EXECD, it); if (rc) @@ -1010,15 +1009,15 @@ static int mdc_finish_intent_lock(struct obd_export *exp, LDLM_IBITS, &policy, LCK_NL, &old_lock, 0)) { ldlm_lock_decref_and_cancel(lockh, - it->d.lustre.it_lock_mode); + it->it_lock_mode); memcpy(lockh, &old_lock, sizeof(old_lock)); - it->d.lustre.it_lock_handle = lockh->cookie; + it->it_lock_handle = lockh->cookie; } } CDEBUG(D_DENTRY, "D_IT dentry %.*s intent: %s status %d disp %x rc %d\n", op_data->op_namelen, op_data->op_name, ldlm_it2str(it->it_op), - it->d.lustre.it_status, it->d.lustre.it_disposition, rc); + it->it_status, it->it_disposition, rc); return rc; } @@ -1034,8 +1033,8 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, ldlm_policy_data_t policy; enum ldlm_mode mode; - if (it->d.lustre.it_lock_handle) { - lockh.cookie = it->d.lustre.it_lock_handle; + if (it->it_lock_handle) { + lockh.cookie = it->it_lock_handle; mode = ldlm_revalidate_lock_handle(&lockh, bits); } else { fid_build_reg_res_name(fid, &res_id); @@ -1076,11 +1075,11 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, } if (mode) { - it->d.lustre.it_lock_handle = lockh.cookie; - it->d.lustre.it_lock_mode = mode; + it->it_lock_handle = lockh.cookie; + it->it_lock_mode = mode; } else { - it->d.lustre.it_lock_handle = 0; - it->d.lustre.it_lock_mode = 0; + it->it_lock_handle = 0; + it->it_lock_mode = 0; } return !!mode; @@ -1102,15 +1101,15 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, * ll_create/ll_open gets called. * * The server will return to us, in it_disposition, an indication of - * exactly what d.lustre.it_status refers to. + * exactly what it_status refers to. * - * If DISP_OPEN_OPEN is set, then d.lustre.it_status refers to the open() call, + * If DISP_OPEN_OPEN is set, then it_status refers to the open() call, * otherwise if DISP_OPEN_CREATE is set, then it status is the * creation failure mode. In either case, one of DISP_LOOKUP_NEG or * DISP_LOOKUP_POS will be set, indicating whether the child lookup * was successful. * - * Else, if DISP_LOOKUP_EXECD then d.lustre.it_status is the rc of the + * Else, if DISP_LOOKUP_EXECD then it_status is the rc of the * child lookup. */ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, @@ -1143,7 +1142,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, * be called in revalidate_it if we already have a lock, let's * verify that. */ - it->d.lustre.it_lock_handle = 0; + it->it_lock_handle = 0; rc = mdc_revalidate_lock(exp, it, &op_data->op_fid2, NULL); /* Only return failure if it was not GETATTR by cfid * (from inode_revalidate) @@ -1165,7 +1164,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, if (rc < 0) return rc; - *reqp = it->d.lustre.it_data; + *reqp = it->it_data; rc = mdc_finish_intent_lock(exp, *reqp, op_data, it, &lockh); return rc; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index f7e30b1..d48910a 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -637,7 +637,7 @@ int mdc_set_open_replay_data(struct obd_export *exp, struct md_open_data *mod; struct mdt_rec_create *rec; struct mdt_body *body; - struct ptlrpc_request *open_req = it->d.lustre.it_data; + struct ptlrpc_request *open_req = it->it_data; struct obd_import *imp = open_req->rq_import; if (!open_req->rq_replay) -- cgit v1.1 From 51b39f1d3678604b546a90bb4e813a32c7f7f9ac Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Mon, 20 Jun 2016 16:55:39 -0400 Subject: staging/lustre: Inline Lustre intent disposition functions They are just one-liners, so no point in having them exported and called through a different module. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_intent.h | 15 +++++++++++++++ drivers/staging/lustre/lustre/include/lustre_mdc.h | 3 --- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 18 ------------------ 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_intent.h b/drivers/staging/lustre/lustre/include/lustre_intent.h index 41c03d7..3aed810 100644 --- a/drivers/staging/lustre/lustre/include/lustre_intent.h +++ b/drivers/staging/lustre/lustre/include/lustre_intent.h @@ -50,4 +50,19 @@ struct lookup_intent { unsigned int it_lock_set:1; }; +static inline int it_disposition(struct lookup_intent *it, int flag) +{ + return it->it_disposition & flag; +} + +static inline void it_set_disposition(struct lookup_intent *it, int flag) +{ + it->it_disposition |= flag; +} + +static inline void it_clear_disposition(struct lookup_intent *it, int flag) +{ + it->it_disposition &= ~flag; +} + #endif diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index 0ef4226..fa62b95 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h @@ -185,9 +185,6 @@ struct mdc_cache_waiter { }; /* mdc/mdc_locks.c */ -int it_disposition(struct lookup_intent *it, int flag); -void it_clear_disposition(struct lookup_intent *it, int flag); -void it_set_disposition(struct lookup_intent *it, int flag); int it_open_error(int phase, struct lookup_intent *it); static inline bool cl_is_lov_delay_create(unsigned int flags) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 53740d0..7c459b5 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -50,24 +50,6 @@ struct mdc_getattr_args { struct ldlm_enqueue_info *ga_einfo; }; -int it_disposition(struct lookup_intent *it, int flag) -{ - return it->it_disposition & flag; -} -EXPORT_SYMBOL(it_disposition); - -void it_set_disposition(struct lookup_intent *it, int flag) -{ - it->it_disposition |= flag; -} -EXPORT_SYMBOL(it_set_disposition); - -void it_clear_disposition(struct lookup_intent *it, int flag) -{ - it->it_disposition &= ~flag; -} -EXPORT_SYMBOL(it_clear_disposition); - int it_open_error(int phase, struct lookup_intent *it) { if (it_disposition(it, DISP_OPEN_LEASE)) { -- cgit v1.1 From 8bf86fd957e693ba69f63c3db1647e449a58f26d Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Mon, 20 Jun 2016 16:55:40 -0400 Subject: staging/lustre/llite: change it_data to it_request Change the void *it_data member of struct lookup_intent to struct ptlrpc_request *it_request. Signed-off-by: John L. Hammond Reviewed-on: http://review.whamcloud.com/17070 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7403 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_intent.h | 2 +- drivers/staging/lustre/lustre/llite/dcache.c | 6 +++--- drivers/staging/lustre/lustre/llite/dir.c | 2 +- drivers/staging/lustre/lustre/llite/file.c | 17 ++++++++--------- drivers/staging/lustre/lustre/llite/namei.c | 2 +- drivers/staging/lustre/lustre/llite/xattr_cache.c | 2 +- drivers/staging/lustre/lustre/lmv/lmv_intent.c | 2 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 4 ++-- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 6 +++--- drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +- 10 files changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_intent.h b/drivers/staging/lustre/lustre/include/lustre_intent.h index 3aed810..ed2b6c6 100644 --- a/drivers/staging/lustre/lustre/include/lustre_intent.h +++ b/drivers/staging/lustre/lustre/include/lustre_intent.h @@ -46,7 +46,7 @@ struct lookup_intent { int it_lock_mode; int it_remote_lock_mode; __u64 it_remote_lock_handle; - void *it_data; + struct ptlrpc_request *it_request; unsigned int it_lock_set:1; }; diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index c5789f7..d964f4f 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -233,13 +233,13 @@ void ll_intent_release(struct lookup_intent *it) ll_intent_drop_lock(it); /* We are still holding extra reference on a request, need to free it */ if (it_disposition(it, DISP_ENQ_OPEN_REF)) - ptlrpc_req_finished(it->it_data); /* ll_file_open */ + ptlrpc_req_finished(it->it_request); /* ll_file_open */ if (it_disposition(it, DISP_ENQ_CREATE_REF)) /* create rec */ - ptlrpc_req_finished(it->it_data); + ptlrpc_req_finished(it->it_request); it->it_disposition = 0; - it->it_data = NULL; + it->it_request = NULL; } void ll_invalidate_aliases(struct inode *inode) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 8839e10..92b01fd 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -362,7 +362,7 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, ll_finish_md_op_data(op_data); - request = (struct ptlrpc_request *)it.it_data; + request = (struct ptlrpc_request *)it.it_request; if (request) ptlrpc_req_finished(request); if (rc < 0) { diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 6cee41f..39c487d 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -464,10 +464,9 @@ void ll_ioepoch_open(struct ll_inode_info *lli, __u64 ioepoch) static int ll_och_fill(struct obd_export *md_exp, struct lookup_intent *it, struct obd_client_handle *och) { - struct ptlrpc_request *req = it->it_data; struct mdt_body *body; - body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); + body = req_capsule_server_get(&it->it_request->rq_pill, &RMF_MDT_BODY); och->och_fh = body->handle; och->och_fid = body->fid1; och->och_lease_handle.cookie = it->it_lock_handle; @@ -488,7 +487,6 @@ static int ll_local_open(struct file *file, struct lookup_intent *it, LASSERT(fd); if (och) { - struct ptlrpc_request *req = it->it_data; struct mdt_body *body; int rc; @@ -496,7 +494,8 @@ static int ll_local_open(struct file *file, struct lookup_intent *it, if (rc != 0) return rc; - body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); + body = req_capsule_server_get(&it->it_request->rq_pill, + &RMF_MDT_BODY); ll_ioepoch_open(lli, body->ioepoch); } @@ -713,7 +712,7 @@ out_openerr: } if (it && it_disposition(it, DISP_ENQ_OPEN_REF)) { - ptlrpc_req_finished(it->it_data); + ptlrpc_req_finished(it->it_request); it_clear_disposition(it, DISP_ENQ_OPEN_REF); } @@ -1401,7 +1400,7 @@ out_unlock: out: return rc; out_req_free: - ptlrpc_req_finished((struct ptlrpc_request *)oit.it_data); + ptlrpc_req_finished((struct ptlrpc_request *)oit.it_request); goto out; } @@ -1689,7 +1688,7 @@ int ll_release_openhandle(struct inode *inode, struct lookup_intent *it) out: /* this one is in place of ll_file_open */ if (it_disposition(it, DISP_ENQ_OPEN_REF)) { - ptlrpc_req_finished(it->it_data); + ptlrpc_req_finished(it->it_request); it_clear_disposition(it, DISP_ENQ_OPEN_REF); } return rc; @@ -3595,8 +3594,8 @@ again: rc = md_enqueue(sbi->ll_md_exp, &einfo, &it, op_data, &lockh, NULL, 0, NULL, 0); - ptlrpc_req_finished(it.it_data); - it.it_data = NULL; + ptlrpc_req_finished(it.it_request); + it.it_request = NULL; ll_finish_md_op_data(op_data); diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 7a6da02..3664bfd 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -659,7 +659,7 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it) LASSERT(it && it->it_disposition); LASSERT(it_disposition(it, DISP_ENQ_CREATE_REF)); - request = it->it_data; + request = it->it_request; it_clear_disposition(it, DISP_ENQ_CREATE_REF); rc = ll_prep_inode(&inode, request, dir->i_sb, it); if (rc) { diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index 0d19645..8089da8 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -315,7 +315,7 @@ static int ll_xattr_find_get_lock(struct inode *inode, return rc; } - *req = (struct ptlrpc_request *)oit->it_data; + *req = oit->it_request; out: down_write(&lli->lli_xattrs_list_rwsem); mutex_unlock(&lli->lli_xattrs_enq_lock); diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index b3cff23..2f58fda 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -84,7 +84,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, if (pmode) { plock.cookie = it->it_lock_handle; it->it_lock_mode = 0; - it->it_data = NULL; + it->it_request = NULL; } LASSERT(fid_is_sane(&body->fid1)); diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index e6d7efa..0e1588a 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1679,7 +1679,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, struct lustre_handle *lockh, void *lmm, int lmmsize, __u64 extra_lock_flags) { - struct ptlrpc_request *req = it->it_data; + struct ptlrpc_request *req = it->it_request; struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct lustre_handle plock; @@ -1705,7 +1705,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, LASSERT(pmode != 0); memcpy(&plock, lockh, sizeof(plock)); it->it_lock_mode = 0; - it->it_data = NULL; + it->it_request = NULL; fid1 = body->fid1; ptlrpc_req_finished(req); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 7c459b5..f48b584 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -561,7 +561,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, it->it_status = (int)lockrep->lock_policy_res2; it->it_lock_mode = einfo->ei_mode; it->it_lock_handle = lockh->cookie; - it->it_data = req; + it->it_request = req; /* Technically speaking rq_transno must already be zero if * it_status is in error, so the check is a bit redundant @@ -883,7 +883,7 @@ resend: it->it_lock_handle = 0; it->it_lock_mode = 0; - it->it_data = NULL; + it->it_request = NULL; } return rc; @@ -1146,7 +1146,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, if (rc < 0) return rc; - *reqp = it->it_data; + *reqp = it->it_request; rc = mdc_finish_intent_lock(exp, *reqp, op_data, it, &lockh); return rc; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index d48910a..d4cc73b 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -637,7 +637,7 @@ int mdc_set_open_replay_data(struct obd_export *exp, struct md_open_data *mod; struct mdt_rec_create *rec; struct mdt_body *body; - struct ptlrpc_request *open_req = it->it_data; + struct ptlrpc_request *open_req = it->it_request; struct obd_import *imp = open_req->rq_import; if (!open_req->rq_replay) -- cgit v1.1 From e8beaf670dc64f7b5601f9285c03d812f842ca2b Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Mon, 20 Jun 2016 16:55:41 -0400 Subject: staging/lustre/ldlm: const qualify struct lustre_handle * params Add a const qualifier to several struct lustre_handle * parameters in the LDLM interface. Signed-off-by: John L. Hammond Reviewed-on: http://review.whamcloud.com/17071 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7403 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_dlm.h | 18 +++++++++--------- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 14 +++++++------- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 63085a0..60051a5 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -1073,7 +1073,7 @@ void ldlm_lock2handle(const struct ldlm_lock *lock, struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *, __u64 flags); void ldlm_cancel_callback(struct ldlm_lock *); int ldlm_lock_remove_from_lru(struct ldlm_lock *); -int ldlm_lock_set_data(struct lustre_handle *, void *); +int ldlm_lock_set_data(const struct lustre_handle *lockh, void *data); /** * Obtain a lock reference by its handle. @@ -1162,10 +1162,10 @@ do { \ struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock); void ldlm_lock_put(struct ldlm_lock *lock); void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc); -void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode); -int ldlm_lock_addref_try(struct lustre_handle *lockh, __u32 mode); -void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode); -void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, __u32 mode); +void ldlm_lock_addref(const struct lustre_handle *lockh, __u32 mode); +int ldlm_lock_addref_try(const struct lustre_handle *lockh, __u32 mode); +void ldlm_lock_decref(const struct lustre_handle *lockh, __u32 mode); +void ldlm_lock_decref_and_cancel(const struct lustre_handle *lockh, __u32 mode); void ldlm_lock_fail_match_locked(struct ldlm_lock *lock); void ldlm_lock_allow_match(struct ldlm_lock *lock); void ldlm_lock_allow_match_locked(struct ldlm_lock *lock); @@ -1174,10 +1174,10 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, enum ldlm_type type, ldlm_policy_data_t *, enum ldlm_mode mode, struct lustre_handle *, int unref); -enum ldlm_mode ldlm_revalidate_lock_handle(struct lustre_handle *lockh, +enum ldlm_mode ldlm_revalidate_lock_handle(const struct lustre_handle *lockh, __u64 *bits); void ldlm_lock_cancel(struct ldlm_lock *lock); -void ldlm_lock_dump_handle(int level, struct lustre_handle *); +void ldlm_lock_dump_handle(int level, const struct lustre_handle *); void ldlm_unlink_lock_skiplist(struct ldlm_lock *req); /* resource.c */ @@ -1251,9 +1251,9 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, enum ldlm_type type, __u8 with_policy, enum ldlm_mode mode, __u64 *flags, void *lvb, __u32 lvb_len, - struct lustre_handle *lockh, int rc); + const struct lustre_handle *lockh, int rc); int ldlm_cli_update_pool(struct ptlrpc_request *req); -int ldlm_cli_cancel(struct lustre_handle *lockh, +int ldlm_cli_cancel(const struct lustre_handle *lockh, enum ldlm_cancel_flags cancel_flags); int ldlm_cli_cancel_unused(struct ldlm_namespace *, const struct ldlm_res_id *, enum ldlm_cancel_flags flags, void *opaque); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index b7254eb..a5993f7 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -658,7 +658,7 @@ static void ldlm_add_ast_work_item(struct ldlm_lock *lock, * r/w reference type is determined by \a mode * Calls ldlm_lock_addref_internal. */ -void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode) +void ldlm_lock_addref(const struct lustre_handle *lockh, __u32 mode) { struct ldlm_lock *lock; @@ -700,7 +700,7 @@ void ldlm_lock_addref_internal_nolock(struct ldlm_lock *lock, __u32 mode) * * \retval -EAGAIN lock is being canceled. */ -int ldlm_lock_addref_try(struct lustre_handle *lockh, __u32 mode) +int ldlm_lock_addref_try(const struct lustre_handle *lockh, __u32 mode) { struct ldlm_lock *lock; int result; @@ -832,7 +832,7 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) /** * Decrease reader/writer refcount for LDLM lock with handle \a lockh */ -void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode) +void ldlm_lock_decref(const struct lustre_handle *lockh, __u32 mode) { struct ldlm_lock *lock = __ldlm_handle2lock(lockh, 0); @@ -849,7 +849,7 @@ EXPORT_SYMBOL(ldlm_lock_decref); * * Typical usage is for GROUP locks which we cannot allow to be cached. */ -void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, __u32 mode) +void ldlm_lock_decref_and_cancel(const struct lustre_handle *lockh, __u32 mode) { struct ldlm_lock *lock = __ldlm_handle2lock(lockh, 0); @@ -1318,7 +1318,7 @@ enum ldlm_mode ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, } EXPORT_SYMBOL(ldlm_lock_match); -enum ldlm_mode ldlm_revalidate_lock_handle(struct lustre_handle *lockh, +enum ldlm_mode ldlm_revalidate_lock_handle(const struct lustre_handle *lockh, __u64 *bits) { struct ldlm_lock *lock; @@ -1849,7 +1849,7 @@ EXPORT_SYMBOL(ldlm_lock_cancel); /** * Set opaque data into the lock that only makes sense to upper layer. */ -int ldlm_lock_set_data(struct lustre_handle *lockh, void *data) +int ldlm_lock_set_data(const struct lustre_handle *lockh, void *data) { struct ldlm_lock *lock = ldlm_handle2lock(lockh); int rc = -EINVAL; @@ -1875,7 +1875,7 @@ struct export_cl_data { * * Used when printing all locks on a resource for debug purposes. */ -void ldlm_lock_dump_handle(int level, struct lustre_handle *lockh) +void ldlm_lock_dump_handle(int level, const struct lustre_handle *lockh) { struct ldlm_lock *lock; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 8294703..821939f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -499,7 +499,7 @@ static int ldlm_handle_setinfo(struct ptlrpc_request *req) static inline void ldlm_callback_errmsg(struct ptlrpc_request *req, const char *msg, int rc, - struct lustre_handle *handle) + const struct lustre_handle *handle) { DEBUG_REQ((req->rq_no_reply || rc) ? D_WARNING : D_DLMTRACE, req, "%s: [nid %s] [rc %d] [lock %#llx]", diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index d3a376e..af487f9 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -336,7 +336,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, enum ldlm_type type, __u8 with_policy, enum ldlm_mode mode, __u64 *flags, void *lvb, __u32 lvb_len, - struct lustre_handle *lockh, int rc) + const struct lustre_handle *lockh, int rc) { struct ldlm_namespace *ns = exp->exp_obd->obd_namespace; int is_replay = *flags & LDLM_FL_REPLAY; @@ -1023,7 +1023,7 @@ EXPORT_SYMBOL(ldlm_cli_update_pool); * * Lock must not have any readers or writers by this time. */ -int ldlm_cli_cancel(struct lustre_handle *lockh, +int ldlm_cli_cancel(const struct lustre_handle *lockh, enum ldlm_cancel_flags cancel_flags) { struct obd_export *exp; -- cgit v1.1 From 2323d6d8371d2e29ee159f225aaa1a012a4fc564 Mon Sep 17 00:00:00 2001 From: Yang Sheng Date: Mon, 20 Jun 2016 16:55:42 -0400 Subject: staging/lustre/llite: ensure obd is effective in onu_upcall The watched obd device may still not setup while onu_upcall invoked. So we need verify it in cl_ocd_update. Signed-off-by: Yang Sheng Reviewed-on: http://review.whamcloud.com/19597 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8027 Reviewed-by: Niu Yawei Reviewed-by: Lai Siyao Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/lcommon_misc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lcommon_misc.c b/drivers/staging/lustre/lustre/llite/lcommon_misc.c index 8a508ed..f6be105 100644 --- a/drivers/staging/lustre/lustre/llite/lcommon_misc.c +++ b/drivers/staging/lustre/lustre/llite/lcommon_misc.c @@ -96,7 +96,8 @@ int cl_ocd_update(struct obd_device *host, __u64 flags; int result; - if (!strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME)) { + if (!strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME) && + watched->obd_set_up && !watched->obd_stopping) { cli = &watched->u.cli; lco = owner; flags = cli->cl_import->imp_connect_data.ocd_connect_flags; @@ -111,9 +112,10 @@ int cl_ocd_update(struct obd_device *host, mutex_unlock(&lco->lco_lock); result = 0; } else { - CERROR("unexpected notification from %s %s!\n", + CERROR("unexpected notification from %s %s (setup:%d,stopping:%d)!\n", watched->obd_type->typ_name, - watched->obd_name); + watched->obd_name, watched->obd_set_up, + watched->obd_stopping); result = -EINVAL; } return result; -- cgit v1.1 From aea7ccd985a83d7ce55ebaa815108124c97af258 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Mon, 20 Jun 2016 16:55:43 -0400 Subject: staging/lustre/mdc: Zero atime in close RPC While atime on close is supposed to only increase, there's a bug in some older server versions where atime from a client is taken no matter the value that allows a stale client atime to overwrite a correct value. Update atime in close rpc to 0 to help such servers out. Signed-off-by: Niu Yawei Reviewed-on: http://review.whamcloud.com/19932 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8041 Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/mdc_lib.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index 2703113..143bd76 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -467,6 +467,18 @@ void mdc_close_pack(struct ptlrpc_request *req, struct md_op_data *op_data) rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); mdc_setattr_pack_rec(rec, op_data); + /* + * The client will zero out local timestamps when losing the IBITS lock + * so any new RPC timestamps will update the client inode's timestamps. + * There was a defect on the server side which allowed the atime to be + * overwritten by a zeroed-out atime packed into the close RPC. + * + * Proactively clear the MDS_ATTR_ATIME flag in the RPC in this case + * to avoid zeroing the atime on old unpatched servers. See LU-8041. + */ + if (rec->sa_atime == 0) + rec->sa_valid &= ~MDS_ATTR_ATIME; + mdc_ioepoch_pack(epoch, op_data); mdc_hsm_release_pack(req, op_data); } -- cgit v1.1 From c681528a2ba7c8ceb273c608ff26c38b5ee668e8 Mon Sep 17 00:00:00 2001 From: Sergey Cheremencev Date: Mon, 20 Jun 2016 16:55:44 -0400 Subject: staging/lustre/llite: don't panic when fid is insane LASSERT should never be done on data that is received to over the network. Return EINVAL when server returns invalid fid despite of it_status == 0. Signed-off-by: Sergey Cheremencev Seagate-bug-id: MRP-3073 Reviewed-on: http://review.whamcloud.com/17985 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7422 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index a741d6a..546063e 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1918,7 +1918,13 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, * At this point server returns to client's same fid as client * generated for creating. So using ->fid1 is okay here. */ - LASSERT(fid_is_sane(&md.body->fid1)); + if (!fid_is_sane(&md.body->fid1)) { + CERROR("%s: Fid is insane " DFID "\n", + ll_get_fsname(sb, NULL, 0), + PFID(&md.body->fid1)); + rc = -EINVAL; + goto out; + } *inode = ll_iget(sb, cl_fid_build_ino(&md.body->fid1, sbi->ll_flags & LL_SBI_32BIT_API), -- cgit v1.1 From 6dad4d8903a43b0e34d9527e54a52737b0f69690 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Mon, 20 Jun 2016 16:55:45 -0400 Subject: staging/lustre/llite: Restore proper opencache operations Mark dentries that came to us via NFS in a special way so that we can tell them apart during open and activate open cache (we really don't want to do open/close RPC for every NFS IO). This became needed since dentry revlidate no longer reimplements any RPCs for lookup, and as such if a dentry is valid, ll_revalidate_dentry returns 1 and ll_lookup_it() is never visited during opens, we get straght into ll_file_open() without a valid intent/RPC. This used to be only true for NFS, so opencache was engaged needlessly, and it carries a cost of it's own if there is in fact no repetitive file opening-closing going on Signed-off-by: Oleg Drokin Reviewed-on: http://review.whamcloud.com/20354 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8019 Reviewed-by: Andreas Dilger Reviewed-by: Li Xi Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 14 +++++++++++++- drivers/staging/lustre/lustre/llite/llite_internal.h | 1 + drivers/staging/lustre/lustre/llite/llite_nfs.c | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 39c487d..57281b9 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -399,7 +399,19 @@ static int ll_intent_file_open(struct dentry *dentry, void *lmm, * parameters. No need for the open lock */ if (!lmm && lmmsize == 0) { - itp->it_flags |= MDS_OPEN_LOCK; + struct ll_dentry_data *ldd = ll_d2d(dentry); + /* + * If we came via ll_iget_for_nfs, then we need to request + * struct ll_dentry_data *ldd = ll_d2d(file->f_dentry); + * + * NB: when ldd is NULL, it must have come via normal + * lookup path only, since ll_iget_for_nfs always calls + * ll_d_init(). + */ + if (ldd && ldd->lld_nfs_dentry) { + ldd->lld_nfs_dentry = 0; + itp->it_flags |= MDS_OPEN_LOCK; + } if (itp->it_flags & FMODE_WRITE) opc = LUSTRE_OPC_CREATE; } diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 08cc2c1..4d6d589 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -64,6 +64,7 @@ struct ll_dentry_data { struct lookup_intent *lld_it; unsigned int lld_sa_generation; unsigned int lld_invalid:1; + unsigned int lld_nfs_dentry:1; struct rcu_head lld_rcu_head; }; diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index d7878e5..65972c8 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -168,6 +168,24 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren /* N.B. d_obtain_alias() drops inode ref on error */ result = d_obtain_alias(inode); + if (!IS_ERR(result)) { + int rc; + + rc = ll_d_init(result); + if (rc < 0) { + dput(result); + result = ERR_PTR(rc); + } else { + struct ll_dentry_data *ldd = ll_d2d(result); + + /* + * Need to signal to the ll_intent_file_open that + * we came from NFS and so opencache needs to be + * enabled for this one + */ + ldd->lld_nfs_dentry = 1; + } + } return result; } -- cgit v1.1 From aae5d55a24f74d429f32895cf73b9839d0d5e6e1 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Mon, 20 Jun 2016 16:55:46 -0400 Subject: staging/lustre/llite: ll_revalidate_dentry update There are a couple of cases in ll_revalidate_dentry() where we are pretty sure the dentry is valid, so check for them early and save more expensive checks for later. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dcache.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index d964f4f..581a63a 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -302,6 +302,17 @@ static int ll_revalidate_dentry(struct dentry *dentry, { struct inode *dir = d_inode(dentry->d_parent); + /* If this is intermediate component path lookup and we were able to get + * to this dentry, then its lock has not been revoked and the + * path component is valid. + */ + if (lookup_flags & LOOKUP_PARENT) + return 1; + + /* Symlink - always valid as long as the dentry was found */ + if (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)) + return 1; + /* * if open&create is set, talk to MDS to make sure file is created if * necessary, because we can't do this in ->open() later since that's -- cgit v1.1 From d780846e0f3616214c0272ed2445445f69311a2c Mon Sep 17 00:00:00 2001 From: akam kumar bharathi Date: Mon, 20 Jun 2016 16:55:47 -0400 Subject: staging/lustre/llite: IOC_MDC_GETFILEINFO returns the wrong ino req_capsule_server_get() through __req_capsule_get in ll_dir_ioctl() returns a pointer to a PTLRPC request or reply buffer, which is assigned to struct mdt_body. If the command is IOC_MDS_GETFILEINFO then the inode "st.st_ino" should be assigned from one extracted from mdt_body through cl_fid_build_ino(). Signed-off-by: John Hammond Signed-off-by: akam kumar bharathi Reviewed-on: http://review.whamcloud.com/17618 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5954 Reviewed-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 92b01fd..5b38177 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1523,7 +1523,9 @@ skip_lmm: st.st_atime = body->atime; st.st_mtime = body->mtime; st.st_ctime = body->ctime; - st.st_ino = inode->i_ino; + st.st_ino = cl_fid_build_ino(&body->fid1, + sbi->ll_flags & + LL_SBI_32BIT_API); lmdp = (struct lov_user_mds_data __user *)arg; if (copy_to_user(&lmdp->lmd_st, &st, sizeof(st))) { -- cgit v1.1 From c32090fce9ed23576d3ee461f10a60777e91f5ee Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Mon, 20 Jun 2016 16:55:48 -0400 Subject: staging/lustre/osc: fix signed one bit field Bit field 'oi_lockless' and 'oi_is_active' has one bit and is signed which is confusing. Signed-off-by: Dmitry Eremin Reviewed-on: http://review.whamcloud.com/19196 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7258 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Frank Zago Reviewed-by: John L. Hammond Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_cl_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index 437c659..c8c3f1c 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -62,7 +62,7 @@ struct osc_io { /** super class */ struct cl_io_slice oi_cl; /** true if this io is lockless. */ - int oi_lockless; + unsigned int oi_lockless; /** how many LRU pages are reserved for this IO */ int oi_lru_reserved; -- cgit v1.1 From cb96191ff462214890cd8a0fb96794e42eeead71 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Mon, 20 Jun 2016 16:55:49 -0400 Subject: staging/lustre: Add documentation for unstable_stats in sysfs commit ac5b14810952 ("staging: lustre: osc: Track and limit "unstable" pages") added a new sysfs variable, but corresponding bit of documentation was not forgotten. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/sysfs-fs-lustre | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 873e2cf..20206ba 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -294,6 +294,14 @@ Description: Controls extended attributes client-side cache. 1 to enable, 0 to disable. +What: /sys/fs/lustre/llite/-/unstable_stats +Date: Apr 2016 +Contact: "Oleg Drokin" +Description: + Shows number of pages that were sent and acknowledged by + server but were not yet committed and therefore still + pinned in client memory even though no longer dirty. + What: /sys/fs/lustre/ldlm/cancel_unused_locks_before_replay Date: May 2015 Contact: "Oleg Drokin" -- cgit v1.1 From 025fd3c20bfb4e84972f174c7246f86d693f6544 Mon Sep 17 00:00:00 2001 From: Andriy Skulysh Date: Mon, 20 Jun 2016 16:55:50 -0400 Subject: staging/lustre/osc: glimpse lock should match only with granted locks A deadlock is possible during ccc_prep_size()->ldlm_lock_match() vs cl_io_lock() which is waiting for a matched lock and conflicts with already taken lock before ccc_prep_size(). It is better to send an additional lock request to avoid deadlock. Seagate-bug-id: MRP-3312 Signed-off-by: Andriy Skulysh Reviewed-on: http://review.whamcloud.com/18738 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7829 Reviewed-by: Jinshan Xiong Reviewed-by: Bobi Jam Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_request.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 9334349..536b868 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2246,7 +2246,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, struct lustre_handle lockh = { 0 }; struct ptlrpc_request *req = NULL; int intent = *flags & LDLM_FL_HAS_INTENT; - __u64 match_lvb = agl ? 0 : LDLM_FL_LVB_READY; + __u64 match_flags = *flags; enum ldlm_mode mode; int rc; @@ -2281,7 +2281,11 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, mode = einfo->ei_mode; if (einfo->ei_mode == LCK_PR) mode |= LCK_PW; - mode = ldlm_lock_match(obd->obd_namespace, *flags | match_lvb, res_id, + if (agl == 0) + match_flags |= LDLM_FL_LVB_READY; + if (intent != 0) + match_flags |= LDLM_FL_BLOCK_GRANTED; + mode = ldlm_lock_match(obd->obd_namespace, match_flags, res_id, einfo->ei_type, policy, mode, &lockh, 0); if (mode) { struct ldlm_lock *matched; -- cgit v1.1 From 281a8273f6d8664b14c9164ff6d659049c43b3f0 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Mon, 20 Jun 2016 16:55:51 -0400 Subject: staging/lustre/libcfs: Do not call kthread_run in wrong state kthread_run might sleep during an allocation, and so it's considered unsafe to call with a state that's not RUNNABLE. Move the state setting to after kthread_run call. Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/libcfs/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/libcfs/debug.c b/drivers/staging/lustre/lnet/libcfs/debug.c index 75a2a42..42b15a7 100644 --- a/drivers/staging/lustre/lnet/libcfs/debug.c +++ b/drivers/staging/lustre/lnet/libcfs/debug.c @@ -362,12 +362,12 @@ void libcfs_debug_dumplog(void) * get to schedule() */ init_waitqueue_entry(&wait, current); - set_current_state(TASK_INTERRUPTIBLE); add_wait_queue(&debug_ctlwq, &wait); dumper = kthread_run(libcfs_debug_dumplog_thread, (void *)(long)current_pid(), "libcfs_debug_dumper"); + set_current_state(TASK_INTERRUPTIBLE); if (IS_ERR(dumper)) pr_err("LustreError: cannot start log dump thread: %ld\n", PTR_ERR(dumper)); -- cgit v1.1 From 9936913e549bca6721157418bb5014118c3786e0 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Mon, 20 Jun 2016 16:55:52 -0400 Subject: staging: lustre: quiet lockdep recursive lock warning Lockdep complains about potential recursive locking during mount because the client configuration log is holding a lock on the MGC obd_device to prevent it from being torn down, while also getting mutexes on the MDC and OSC devices as they are instantiated: Lustre: Mounted myth-client ============================================= [ INFO: possible recursive locking detected ] 4.7.0-rc2-vm-nfs+ #127 Tainted: G C --------------------------------------------- May be due to missing lock nesting notation 2 locks held by ll_cfg_requeue/5928: #0: (&cli->cl_sem){.+.+.+}, at: mgc_requeue_thread+0x15d/0x730 [mgc] #1: (&cld->cld_lock){+.+.+.}, at: mgc_process_log+0x5e/0xf80 [mgc] CPU: 0 PID: 5928 Comm: ll_cfg_requeue Call Trace: [] dump_stack+0x86/0xc1 [] __lock_acquire+0x726/0x1210 [] lock_acquire+0xfe/0x1f0 [] down_read+0x51/0xa0 [] sptlrpc_conf_client_adapt+0x47/0x150 [ptlrpc] [] mdc_set_info_async+0x2b6/0x470 [mdc] [] class_notify_sptlrpc_conf+0x190/0x360 [obdclass] [] mgc_process_log+0x925/0xf80 [mgc] [] mgc_requeue_thread+0x1fa/0x730 [mgc] [] kthread+0x101/0x120 [] ret_from_fork+0x1f/0x40 Add a separate lock class for the MGC callpath, since it will always be held first, and none of the other obd_device locks should ever be held concurrently. Signed-off-by: Andreas Dilger Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/obd.h | 6 ++++++ drivers/staging/lustre/lustre/mgc/mgc_request.c | 4 +++- drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 40909b0..a1bc2c4 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -228,6 +228,12 @@ enum { #define MDC_MAX_RIF_DEFAULT 8 #define MDC_MAX_RIF_MAX 512 +enum obd_cl_sem_lock_class { + OBD_CLI_SEM_NORMAL, + OBD_CLI_SEM_MGC, + OBD_CLI_SEM_MDCOSC, +}; + struct mdc_rpc_lock; struct obd_import; struct client_obd { diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index fbbf276..9d0bd47 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -496,7 +496,9 @@ static void do_requeue(struct config_llog_data *cld) * export which is being disconnected. Take the client * semaphore to make the check non-racy. */ - down_read(&cld->cld_mgcexp->exp_obd->u.cli.cl_sem); + down_read_nested(&cld->cld_mgcexp->exp_obd->u.cli.cl_sem, + OBD_CLI_SEM_MGC); + if (cld->cld_mgcexp->exp_obd->u.cli.cl_conn_count != 0) { int rc; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index 1238c87..c140354 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -815,7 +815,7 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd) CDEBUG(D_SEC, "obd %s\n", obd->u.cli.cl_target_uuid.uuid); /* serialize with connect/disconnect import */ - down_read(&obd->u.cli.cl_sem); + down_read_nested(&obd->u.cli.cl_sem, OBD_CLI_SEM_MDCOSC); imp = obd->u.cli.cl_import; if (imp) { -- cgit v1.1 From fbc976c1eb540ae06b4201dd9707ddace77d15eb Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Mon, 13 Jun 2016 08:28:10 +0900 Subject: staging: wilc1000: change handle_cfg_param's return type to void When handle_cfg_param is called in hostIFthread that is a kernel thread, it is not checked return type of this function. This patch changes return type to void. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 9535842..aeb355e 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -417,8 +417,8 @@ static void handle_get_mac_address(struct wilc_vif *vif, complete(&hif_wait_response); } -static s32 handle_cfg_param(struct wilc_vif *vif, - struct cfg_param_attr *cfg_param_attr) +static void handle_cfg_param(struct wilc_vif *vif, + struct cfg_param_attr *cfg_param_attr) { s32 result = 0; struct wid wid_list[32]; @@ -436,7 +436,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.bss_type = (u8)cfg_param_attr->bss_type; } else { netdev_err(vif->ndev, "check value 6 over\n"); - result = -EINVAL; goto unlock; } i++; @@ -452,7 +451,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.auth_type = (u8)cfg_param_attr->auth_type; } else { netdev_err(vif->ndev, "Impossible value\n"); - result = -EINVAL; goto unlock; } i++; @@ -467,7 +465,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.auth_timeout = cfg_param_attr->auth_timeout; } else { netdev_err(vif->ndev, "Range(1 ~ 65535) over\n"); - result = -EINVAL; goto unlock; } i++; @@ -481,7 +478,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.power_mgmt_mode = (u8)cfg_param_attr->power_mgmt_mode; } else { netdev_err(vif->ndev, "Invalid power mode\n"); - result = -EINVAL; goto unlock; } i++; @@ -496,7 +492,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.short_retry_limit = cfg_param_attr->short_retry_limit; } else { netdev_err(vif->ndev, "Range(1~256) over\n"); - result = -EINVAL; goto unlock; } i++; @@ -511,7 +506,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.long_retry_limit = cfg_param_attr->long_retry_limit; } else { netdev_err(vif->ndev, "Range(1~256) over\n"); - result = -EINVAL; goto unlock; } i++; @@ -526,7 +520,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.frag_threshold = cfg_param_attr->frag_threshold; } else { netdev_err(vif->ndev, "Threshold Range fail\n"); - result = -EINVAL; goto unlock; } i++; @@ -541,7 +534,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.rts_threshold = cfg_param_attr->rts_threshold; } else { netdev_err(vif->ndev, "Threshold Range fail\n"); - result = -EINVAL; goto unlock; } i++; @@ -555,7 +547,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.preamble_type = cfg_param_attr->preamble_type; } else { netdev_err(vif->ndev, "Preamle Range(0~2) over\n"); - result = -EINVAL; goto unlock; } i++; @@ -569,7 +560,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.short_slot_allowed = (u8)cfg_param_attr->short_slot_allowed; } else { netdev_err(vif->ndev, "Short slot(2) over\n"); - result = -EINVAL; goto unlock; } i++; @@ -583,7 +573,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.txop_prot_disabled = (u8)cfg_param_attr->txop_prot_disabled; } else { netdev_err(vif->ndev, "TXOP prot disable\n"); - result = -EINVAL; goto unlock; } i++; @@ -598,7 +587,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.beacon_interval = cfg_param_attr->beacon_interval; } else { netdev_err(vif->ndev, "Beacon interval(1~65535)fail\n"); - result = -EINVAL; goto unlock; } i++; @@ -613,7 +601,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.dtim_period = cfg_param_attr->dtim_period; } else { netdev_err(vif->ndev, "DTIM range(1~255) fail\n"); - result = -EINVAL; goto unlock; } i++; @@ -627,7 +614,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.site_survey_enabled = (u8)cfg_param_attr->site_survey_enabled; } else { netdev_err(vif->ndev, "Site survey disable\n"); - result = -EINVAL; goto unlock; } i++; @@ -642,7 +628,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.site_survey_scan_time = cfg_param_attr->site_survey_scan_time; } else { netdev_err(vif->ndev, "Site scan time(1~65535) over\n"); - result = -EINVAL; goto unlock; } i++; @@ -657,7 +642,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.active_scan_time = cfg_param_attr->active_scan_time; } else { netdev_err(vif->ndev, "Active time(1~65535) over\n"); - result = -EINVAL; goto unlock; } i++; @@ -672,7 +656,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.passive_scan_time = cfg_param_attr->passive_scan_time; } else { netdev_err(vif->ndev, "Passive time(1~65535) over\n"); - result = -EINVAL; goto unlock; } i++; @@ -694,7 +677,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate; } else { netdev_err(vif->ndev, "out of TX rate\n"); - result = -EINVAL; goto unlock; } i++; @@ -708,7 +690,6 @@ static s32 handle_cfg_param(struct wilc_vif *vif, unlock: mutex_unlock(&hif_drv->cfg_values_lock); - return result; } static s32 handle_scan(struct wilc_vif *vif, struct scan_attr *scan_info) -- cgit v1.1 From eebb4df136a8b60b2fddda3886aaf20c8f3a644f Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Mon, 13 Jun 2016 08:28:11 +0900 Subject: staging: wilc1000: change data type of result in handle_cfg_param This patch changes data type of result variable from s32 to int. result is used to get return value from wilc_send_config_pkt that has return type of int. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index aeb355e..0220045 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -420,7 +420,7 @@ static void handle_get_mac_address(struct wilc_vif *vif, static void handle_cfg_param(struct wilc_vif *vif, struct cfg_param_attr *cfg_param_attr) { - s32 result = 0; + int result = 0; struct wid wid_list[32]; struct host_if_drv *hif_drv = vif->hif_drv; int i = 0; -- cgit v1.1 From a1e7df48832c28e8f65c489b1e312717f52218ab Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Mon, 13 Jun 2016 08:28:12 +0900 Subject: staging: wilc1000: rename result in handle_cfg_param This patch renames result to ret that is used to get return value from wilc_send_config_pkt. Some handle_*() functions are used as result, others are used as ret. It will be changed as ret in all handle_*() functions to match variable name. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 0220045..ea5cb2d 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -420,7 +420,7 @@ static void handle_get_mac_address(struct wilc_vif *vif, static void handle_cfg_param(struct wilc_vif *vif, struct cfg_param_attr *cfg_param_attr) { - int result = 0; + int ret = 0; struct wid wid_list[32]; struct host_if_drv *hif_drv = vif->hif_drv; int i = 0; @@ -682,10 +682,10 @@ static void handle_cfg_param(struct wilc_vif *vif, i++; } - result = wilc_send_config_pkt(vif, SET_CFG, wid_list, - i, wilc_get_vif_idx(vif)); + ret = wilc_send_config_pkt(vif, SET_CFG, wid_list, + i, wilc_get_vif_idx(vif)); - if (result) + if (ret) netdev_err(vif->ndev, "Error in setting CFG params\n"); unlock: -- cgit v1.1 From 783fa6431eb05c81640d0d2bb05cb878b924c50a Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Mon, 13 Jun 2016 08:28:13 +0900 Subject: staging: wilc1000: remove unused struct set_mac_addr struct set_mac_addr is not used anymore, so just remove it. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 1 - drivers/staging/wilc1000/host_interface.h | 4 ---- 2 files changed, 5 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index ea5cb2d..96821f6 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -181,7 +181,6 @@ union message_body { struct drv_handler drv; struct set_multicast multicast_info; struct op_mode mode; - struct set_mac_addr set_mac_info; struct get_mac_addr get_mac_info; struct ba_session_info session_info; struct remain_ch remain_on_ch; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 8d2dd0d..ddfea29 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -224,10 +224,6 @@ struct op_mode { u32 mode; }; -struct set_mac_addr { - u8 mac_addr[ETH_ALEN]; -}; - struct get_mac_addr { u8 *mac_addr; }; -- cgit v1.1 From 0cb7a5742d6d6ea094107ba0a3c7e3768483538c Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Mon, 13 Jun 2016 08:28:14 +0900 Subject: staging: wilc1000: add bss_type to remove line over 80 characters A local bss_type variable is added to remove checkpatch warning of line over 80 characters. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 96821f6..828efff 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -427,12 +427,14 @@ static void handle_cfg_param(struct wilc_vif *vif, mutex_lock(&hif_drv->cfg_values_lock); if (cfg_param_attr->flag & BSS_TYPE) { - if (cfg_param_attr->bss_type < 6) { + u8 bss_type = cfg_param_attr->bss_type; + + if (bss_type < 6) { wid_list[i].id = WID_BSS_TYPE; - wid_list[i].val = (s8 *)&cfg_param_attr->bss_type; + wid_list[i].val = (s8 *)&bss_type; wid_list[i].type = WID_CHAR; wid_list[i].size = sizeof(char); - hif_drv->cfg_values.bss_type = (u8)cfg_param_attr->bss_type; + hif_drv->cfg_values.bss_type = (u8)bss_type; } else { netdev_err(vif->ndev, "check value 6 over\n"); goto unlock; -- cgit v1.1 From 2938f208420d7f9c695d637ca92495c33bdfae5c Mon Sep 17 00:00:00 2001 From: Chaehyun Lim Date: Mon, 13 Jun 2016 08:28:15 +0900 Subject: staging: wilc1000: remove unnecesary type cast of bss_type There is no need to use type cast of bss_type because hif_drv->cfg_values.bss_type is u8. Signed-off-by: Chaehyun Lim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 828efff..5b2278b 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -434,7 +434,7 @@ static void handle_cfg_param(struct wilc_vif *vif, wid_list[i].val = (s8 *)&bss_type; wid_list[i].type = WID_CHAR; wid_list[i].size = sizeof(char); - hif_drv->cfg_values.bss_type = (u8)bss_type; + hif_drv->cfg_values.bss_type = bss_type; } else { netdev_err(vif->ndev, "check value 6 over\n"); goto unlock; -- cgit v1.1 From 95b8cb8917e358cdf8489b1101e3559ef868ff13 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 23 Jun 2016 14:14:07 +0100 Subject: staging: wilc1000: fix spelling mistake: "interupts" -> "interrupts" trivial fix to spelling mistake in dev_err messages Signed-off-by: Colin Ian King Reviewed-by: Julian Calaby Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_sdio.c | 2 +- drivers/staging/wilc1000/wilc_spi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index a839a79..39b73fb2 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -1006,7 +1006,7 @@ static int sdio_sync_ext(struct wilc *wilc, int nint) u32 reg; if (nint > MAX_NUM_INT) { - dev_err(&func->dev, "Too many interupts (%d)...\n", nint); + dev_err(&func->dev, "Too many interrupts (%d)...\n", nint); return 0; } if (nint > MAX_NUN_INT_THRPT_ENH2) { diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 4268e2f..22cf4b7 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -1082,7 +1082,7 @@ static int wilc_spi_sync_ext(struct wilc *wilc, int nint) int ret, i; if (nint > MAX_NUM_INT) { - dev_err(&spi->dev, "Too many interupts (%d)...\n", nint); + dev_err(&spi->dev, "Too many interrupts (%d)...\n", nint); return 0; } -- cgit v1.1 From b9811891a9f60ca9c314dcab3244c65930c4cf37 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Tue, 17 May 2016 16:38:43 +0200 Subject: staging: wilc1000: fix typo firmare -> firmware Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 4f93c11..274c390 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -362,7 +362,7 @@ int wilc_wlan_get_firmware(struct net_device *dev) goto _fail_; if (request_firmware(&wilc_firmware, firmware, wilc->dev) != 0) { - netdev_err(dev, "%s - firmare not available\n", firmware); + netdev_err(dev, "%s - firmware not available\n", firmware); ret = -1; goto _fail_; } -- cgit v1.1 From b27a6d5e636ac80b223a18ca2b3c892f1caef9e3 Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Wed, 15 Jun 2016 11:00:34 +0530 Subject: staging: wilc1000: Replace semaphore txq_event with completion The semaphore 'txq_event' is used as completion, so convert it to a struct completion type. Signed-off-by: Binoy Jayan Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 8 ++++---- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 3 ++- drivers/staging/wilc1000/wilc_wlan.c | 8 +++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 274c390..baf9326 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -316,7 +316,7 @@ static int linux_wlan_txq_task(void *vp) complete(&wl->txq_thread_started); while (1) { - down(&wl->txq_event); + wait_for_completion(&wl->txq_event); if (wl->close) { complete(&wl->txq_thread_started); @@ -650,7 +650,7 @@ void wilc1000_wlan_deinit(struct net_device *dev) mutex_unlock(&wl->hif_cs); } if (&wl->txq_event) - up(&wl->txq_event); + wait_for_completion(&wl->txq_event); wlan_deinitialize_threads(dev); deinit_irq(dev); @@ -681,7 +681,7 @@ static int wlan_init_locks(struct net_device *dev) spin_lock_init(&wl->txq_spinlock); sema_init(&wl->txq_add_to_head_cs, 1); - sema_init(&wl->txq_event, 0); + init_completion(&wl->txq_event); sema_init(&wl->cfg_event, 0); sema_init(&wl->sync_event, 0); @@ -738,7 +738,7 @@ static void wlan_deinitialize_threads(struct net_device *dev) wl->close = 1; if (&wl->txq_event) - up(&wl->txq_event); + complete(&wl->txq_event); if (wl->txq_thread) { kthread_stop(wl->txq_thread); diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 3a561df6..12d7c7b 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -42,6 +42,7 @@ #include "host_interface.h" #include "wilc_wlan.h" #include +#include #define FLOW_CONTROL_LOWER_THRESHOLD 128 #define FLOW_CONTROL_UPPER_THRESHOLD 256 @@ -178,7 +179,7 @@ struct wilc { struct semaphore cfg_event; struct semaphore sync_event; - struct semaphore txq_event; + struct completion txq_event; struct completion txq_thread_started; struct task_struct *txq_thread; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 11e16d5..1a57135 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -1,3 +1,4 @@ +#include #include "wilc_wlan_if.h" #include "wilc_wlan.h" #include "wilc_wfi_netdevice.h" @@ -89,7 +90,7 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - up(&wilc->txq_event); + complete(&wilc->txq_event); } static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif, @@ -119,7 +120,7 @@ static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif, spin_unlock_irqrestore(&wilc->txq_spinlock, flags); up(&wilc->txq_add_to_head_cs); - up(&wilc->txq_event); + complete(&wilc->txq_event); return 0; } @@ -287,7 +288,8 @@ static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) spin_unlock_irqrestore(&wilc->txq_spinlock, wilc->txq_spinlock_flags); while (dropped > 0) { - wilc_lock_timeout(wilc, &wilc->txq_event, 1); + wait_for_completion_timeout(&wilc->txq_event, + msecs_to_jiffies(1)); dropped--; } -- cgit v1.1 From 334bed089d3d74e64a34b0ebee52b146b6778a6b Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Wed, 15 Jun 2016 11:00:35 +0530 Subject: staging: wilc1000: Replace semaphore txq_add_to_head_cs with mutex The semaphore 'txq_add_to_head_cs' is a simple mutex, so it should be written as one. Semaphores are going away in the future. Also, removing the timeout scenario as the error handling code does not propagate the timeout properly. Signed-off-by: Binoy Jayan Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 4 ++-- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 3 ++- drivers/staging/wilc1000/wilc_wlan.c | 11 ++++------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index baf9326..5dc645c 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -20,7 +20,7 @@ #include #include #include - +#include #include #include @@ -679,7 +679,7 @@ static int wlan_init_locks(struct net_device *dev) mutex_init(&wl->rxq_cs); spin_lock_init(&wl->txq_spinlock); - sema_init(&wl->txq_add_to_head_cs, 1); + mutex_init(&wl->txq_add_to_head_cs); init_completion(&wl->txq_event); diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 12d7c7b..239cd43 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -43,6 +43,7 @@ #include "wilc_wlan.h" #include #include +#include #define FLOW_CONTROL_LOWER_THRESHOLD 128 #define FLOW_CONTROL_UPPER_THRESHOLD 256 @@ -171,7 +172,7 @@ struct wilc { struct wilc_vif *vif[NUM_CONCURRENT_IFC]; u8 open_ifcs; - struct semaphore txq_add_to_head_cs; + struct mutex txq_add_to_head_cs; spinlock_t txq_spinlock; struct mutex rxq_cs; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 1a57135..9afbe8d 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -99,9 +99,7 @@ static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif, unsigned long flags; struct wilc *wilc = vif->wilc; - if (wilc_lock_timeout(wilc, &wilc->txq_add_to_head_cs, - CFG_PKTS_TIMEOUT)) - return -1; + mutex_lock(&wilc->txq_add_to_head_cs); spin_lock_irqsave(&wilc->txq_spinlock, flags); @@ -119,7 +117,7 @@ static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif, wilc->txq_entries += 1; spin_unlock_irqrestore(&wilc->txq_spinlock, flags); - up(&wilc->txq_add_to_head_cs); + mutex_unlock(&wilc->txq_add_to_head_cs); complete(&wilc->txq_event); return 0; @@ -573,8 +571,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) if (wilc->quit) break; - wilc_lock_timeout(wilc, &wilc->txq_add_to_head_cs, - CFG_PKTS_TIMEOUT); + mutex_lock(&wilc->txq_add_to_head_cs); wilc_wlan_txq_filter_dup_tcp_ack(dev); tqe = wilc_wlan_txq_get_first(wilc); i = 0; @@ -755,7 +752,7 @@ _end_: if (ret != 1) break; } while (0); - up(&wilc->txq_add_to_head_cs); + mutex_unlock(&wilc->txq_add_to_head_cs); wilc->txq_exit = 1; *txq_count = wilc->txq_entries; -- cgit v1.1 From fa6596982f00e7c341c95174de2275062f14e3fa Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Wed, 15 Jun 2016 11:00:36 +0530 Subject: staging: wilc1000: Replace semaphore cfg_event with completion The semaphore 'cfg_event' is used as completion, so convert it to a struct completion type. Signed-off-by: Binoy Jayan Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 2 +- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 +- drivers/staging/wilc1000/wilc_wlan.c | 15 ++++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 5dc645c..5c5e8ad 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -683,7 +683,7 @@ static int wlan_init_locks(struct net_device *dev) init_completion(&wl->txq_event); - sema_init(&wl->cfg_event, 0); + init_completion(&wl->cfg_event); sema_init(&wl->sync_event, 0); init_completion(&wl->txq_thread_started); diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 239cd43..5fbc07c 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -178,7 +178,7 @@ struct wilc { struct mutex rxq_cs; struct mutex hif_cs; - struct semaphore cfg_event; + struct completion cfg_event; struct semaphore sync_event; struct completion txq_event; struct completion txq_thread_started; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 9afbe8d..19a5809 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -310,7 +310,7 @@ static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer, netdev_dbg(vif->ndev, "Adding config packet ...\n"); if (wilc->quit) { netdev_dbg(vif->ndev, "Return due to clear function\n"); - up(&wilc->cfg_event); + complete(&wilc->cfg_event); return 0; } @@ -769,7 +769,7 @@ static void wilc_wlan_handle_rxq(struct wilc *wilc) do { if (wilc->quit) { - up(&wilc->cfg_event); + complete(&wilc->cfg_event); break; } rqe = wilc_wlan_rxq_remove(wilc); @@ -820,7 +820,7 @@ static void wilc_wlan_handle_rxq(struct wilc *wilc) wilc_wlan_cfg_indicate_rx(wilc, &buffer[pkt_offset + offset], pkt_len, &rsp); if (rsp.type == WILC_CFG_RSP) { if (wilc->cfg_seq_no == rsp.seq_no) - up(&wilc->cfg_event); + complete(&wilc->cfg_event); } else if (rsp.type == WILC_CFG_RSP_STATUS) { wilc_mac_indicate(wilc, WILC_MAC_INDICATE_STATUS); @@ -1228,11 +1228,12 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, if (wilc_wlan_cfg_commit(vif, WILC_CFG_SET, drv_handler)) ret_size = 0; - if (wilc_lock_timeout(wilc, &wilc->cfg_event, - CFG_PKTS_TIMEOUT)) { + if (!wait_for_completion_timeout(&wilc->cfg_event, + msecs_to_jiffies(CFG_PKTS_TIMEOUT))) { netdev_dbg(vif->ndev, "Set Timed Out\n"); ret_size = 0; } + wilc->cfg_frame_in_use = 0; wilc->cfg_frame_offset = 0; wilc->cfg_seq_no += 1; @@ -1265,8 +1266,8 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, if (wilc_wlan_cfg_commit(vif, WILC_CFG_QUERY, drv_handler)) ret_size = 0; - if (wilc_lock_timeout(wilc, &wilc->cfg_event, - CFG_PKTS_TIMEOUT)) { + if (!wait_for_completion_timeout(&wilc->cfg_event, + msecs_to_jiffies(CFG_PKTS_TIMEOUT))) { netdev_dbg(vif->ndev, "Get Timed Out\n"); ret_size = 0; } -- cgit v1.1 From 04247e7d65c9ce80a7d19aae2fd7cdf64ce80800 Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Wed, 15 Jun 2016 11:00:37 +0530 Subject: staging: wilc1000: Replace semaphore sync_event with completion The semaphore 'sync_event' is used as completion, so convert it to a struct completion type. Also, return -ETIME if the return value of wait_for_completion_timeout is 0. Signed-off-by: Binoy Jayan Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 10 +++++----- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 5c5e8ad..e0890f5 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -241,7 +241,7 @@ void wilc_mac_indicate(struct wilc *wilc, int flag) (unsigned char *)&status, 4); if (wilc->mac_status == WILC_MAC_STATUS_INIT) { wilc->mac_status = status; - up(&wilc->sync_event); + complete(&wilc->sync_event); } else { wilc->mac_status = status; } @@ -386,9 +386,9 @@ static int linux_wlan_start_firmware(struct net_device *dev) if (ret < 0) return ret; - ret = wilc_lock_timeout(wilc, &wilc->sync_event, 5000); - if (ret) - return ret; + if (!wait_for_completion_timeout(&wilc->sync_event, + msecs_to_jiffies(5000))) + return -ETIME; return 0; } @@ -684,7 +684,7 @@ static int wlan_init_locks(struct net_device *dev) init_completion(&wl->txq_event); init_completion(&wl->cfg_event); - sema_init(&wl->sync_event, 0); + init_completion(&wl->sync_event); init_completion(&wl->txq_thread_started); return 0; diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 5fbc07c..5cc6a82 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -179,7 +179,7 @@ struct wilc { struct mutex hif_cs; struct completion cfg_event; - struct semaphore sync_event; + struct completion sync_event; struct completion txq_event; struct completion txq_thread_started; -- cgit v1.1 From 77eebe82eb114605c0ade45f1b4587c530660f4f Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Wed, 15 Jun 2016 11:00:38 +0530 Subject: staging: wilc1000: Remove semaphore close_exit_sync The semaphore 'close_exit_sync' does not serve any purpose other than delaying the deregistration of the device which it is trying to protect from shared access. 'up' is called only when a subdevice is closed and not when it is opened. So, the semaphore count only goes up when the device is used. Signed-off-by: Binoy Jayan Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index e0890f5..2ce9df5 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -31,8 +31,6 @@ static struct notifier_block g_dev_notifier = { .notifier_call = dev_state_ev_handler }; -static struct semaphore close_exit_sync; - static int wlan_deinit_locks(struct net_device *dev); static void wlan_deinitialize_threads(struct net_device *dev); @@ -1088,7 +1086,6 @@ int wilc_mac_close(struct net_device *ndev) WILC_WFI_deinit_mon_interface(); } - up(&close_exit_sync); vif->mac_opened = 0; return 0; @@ -1232,8 +1229,6 @@ void wilc_netdev_cleanup(struct wilc *wilc) } if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) { - wilc_lock_timeout(wilc, &close_exit_sync, 5 * 1000); - for (i = 0; i < NUM_CONCURRENT_IFC; i++) if (wilc->vif[i]->ndev) if (vif[i]->mac_opened) @@ -1258,8 +1253,6 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, struct net_device *ndev; struct wilc *wl; - sema_init(&close_exit_sync, 0); - wl = kzalloc(sizeof(*wl), GFP_KERNEL); if (!wl) return -ENOMEM; -- cgit v1.1 From c6bb38a5e82a26c6556e05d2140c3a1b4176c2ab Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Thu, 23 Jun 2016 11:11:50 +0530 Subject: staging: wilc1000: message_queue: Move code to host interface Move the contents of wilc_msgqueue.c and wilc_msgqueue.h into host_interface.c, remove 'wilc_msgqueue.c' and 'wilc_msgqueue.h'. This is done so as to restructure the implementation of the kthread 'hostIFthread' using a work queue. Signed-off-by: Binoy Jayan Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/Makefile | 1 - drivers/staging/wilc1000/host_interface.c | 163 +++++++++++++++++++++++++++++- drivers/staging/wilc1000/wilc_msgqueue.c | 144 -------------------------- drivers/staging/wilc1000/wilc_msgqueue.h | 28 ----- 4 files changed, 162 insertions(+), 174 deletions(-) delete mode 100644 drivers/staging/wilc1000/wilc_msgqueue.c delete mode 100644 drivers/staging/wilc1000/wilc_msgqueue.h diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index acc3f3e..d226283 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile @@ -6,7 +6,6 @@ ccflags-y += -DFIRMWARE_1002=\"atmel/wilc1002_firmware.bin\" \ ccflags-y += -I$(src)/ -DWILC_ASIC_A0 -DWILC_DEBUGFS wilc1000-objs := wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \ - wilc_msgqueue.o \ coreconfigurator.o host_interface.o \ wilc_wlan_cfg.o wilc_debugfs.o \ wilc_wlan.o diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 5b2278b..a34a1bb 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3,11 +3,13 @@ #include #include #include +#include #include "host_interface.h" +#include +#include #include "coreconfigurator.h" #include "wilc_wlan.h" #include "wilc_wlan_if.h" -#include "wilc_msgqueue.h" #include #include "wilc_wfi_netdevice.h" @@ -57,6 +59,20 @@ #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 #define DEFAULT_LINK_SPEED 72 +struct message { + void *buf; + u32 len; + struct list_head list; +}; + +struct message_queue { + struct semaphore sem; + spinlock_t lock; + bool exiting; + u32 recv_count; + struct list_head msg_list; +}; + struct host_if_wpa_attr { u8 *key; const u8 *mac_addr; @@ -263,6 +279,151 @@ static struct wilc_vif *join_req_vif; static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo); static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx); static s32 Handle_ScanDone(struct wilc_vif *vif, enum scan_event enuEvent); +static int wilc_mq_create(struct message_queue *mq); +static int wilc_mq_send(struct message_queue *mq, + const void *send_buf, u32 send_buf_size); +static int wilc_mq_recv(struct message_queue *mq, + void *recv_buf, u32 recv_buf_size, u32 *recv_len); +static int wilc_mq_destroy(struct message_queue *mq); + +/*! + * @author syounan + * @date 1 Sep 2010 + * @note copied from FLO glue implementatuion + * @version 1.0 + */ +static int wilc_mq_create(struct message_queue *mq) +{ + spin_lock_init(&mq->lock); + sema_init(&mq->sem, 0); + INIT_LIST_HEAD(&mq->msg_list); + mq->recv_count = 0; + mq->exiting = false; + return 0; +} + +/*! + * @author syounan + * @date 1 Sep 2010 + * @note copied from FLO glue implementatuion + * @version 1.0 + */ +static int wilc_mq_destroy(struct message_queue *mq) +{ + struct message *msg; + + mq->exiting = true; + + /* Release any waiting receiver thread. */ + while (mq->recv_count > 0) { + up(&mq->sem); + mq->recv_count--; + } + + while (!list_empty(&mq->msg_list)) { + msg = list_first_entry(&mq->msg_list, struct message, list); + list_del(&msg->list); + kfree(msg->buf); + } + + return 0; +} + +/*! + * @author syounan + * @date 1 Sep 2010 + * @note copied from FLO glue implementatuion + * @version 1.0 + */ +static int wilc_mq_send(struct message_queue *mq, + const void *send_buf, u32 send_buf_size) +{ + unsigned long flags; + struct message *new_msg = NULL; + + if (!mq || (send_buf_size == 0) || !send_buf) + return -EINVAL; + + if (mq->exiting) + return -EFAULT; + + /* construct a new message */ + new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC); + if (!new_msg) + return -ENOMEM; + + new_msg->len = send_buf_size; + INIT_LIST_HEAD(&new_msg->list); + new_msg->buf = kmemdup(send_buf, send_buf_size, GFP_ATOMIC); + if (!new_msg->buf) { + kfree(new_msg); + return -ENOMEM; + } + + spin_lock_irqsave(&mq->lock, flags); + + /* add it to the message queue */ + list_add_tail(&new_msg->list, &mq->msg_list); + + spin_unlock_irqrestore(&mq->lock, flags); + + up(&mq->sem); + + return 0; +} + +/*! + * @author syounan + * @date 1 Sep 2010 + * @note copied from FLO glue implementatuion + * @version 1.0 + */ +static int wilc_mq_recv(struct message_queue *mq, + void *recv_buf, u32 recv_buf_size, u32 *recv_len) +{ + struct message *msg; + unsigned long flags; + + if (!mq || (recv_buf_size == 0) || !recv_buf || !recv_len) + return -EINVAL; + + if (mq->exiting) + return -EFAULT; + + spin_lock_irqsave(&mq->lock, flags); + mq->recv_count++; + spin_unlock_irqrestore(&mq->lock, flags); + + down(&mq->sem); + spin_lock_irqsave(&mq->lock, flags); + + if (list_empty(&mq->msg_list)) { + spin_unlock_irqrestore(&mq->lock, flags); + up(&mq->sem); + return -EFAULT; + } + /* check buffer size */ + msg = list_first_entry(&mq->msg_list, struct message, list); + if (recv_buf_size < msg->len) { + spin_unlock_irqrestore(&mq->lock, flags); + up(&mq->sem); + return -EOVERFLOW; + } + + /* consume the message */ + mq->recv_count--; + memcpy(recv_buf, msg->buf, msg->len); + *recv_len = msg->len; + + list_del(&msg->list); + + kfree(msg->buf); + kfree(msg); + + spin_unlock_irqrestore(&mq->lock, flags); + + return 0; +} /* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as * special purpose in wilc device, so we add 1 to the index to starts from 1. diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c deleted file mode 100644 index 6cb894e..0000000 --- a/drivers/staging/wilc1000/wilc_msgqueue.c +++ /dev/null @@ -1,144 +0,0 @@ - -#include "wilc_msgqueue.h" -#include -#include -#include - -/*! - * @author syounan - * @date 1 Sep 2010 - * @note copied from FLO glue implementatuion - * @version 1.0 - */ -int wilc_mq_create(struct message_queue *mq) -{ - spin_lock_init(&mq->lock); - sema_init(&mq->sem, 0); - INIT_LIST_HEAD(&mq->msg_list); - mq->recv_count = 0; - mq->exiting = false; - return 0; -} - -/*! - * @author syounan - * @date 1 Sep 2010 - * @note copied from FLO glue implementatuion - * @version 1.0 - */ -int wilc_mq_destroy(struct message_queue *mq) -{ - struct message *msg; - - mq->exiting = true; - - /* Release any waiting receiver thread. */ - while (mq->recv_count > 0) { - up(&mq->sem); - mq->recv_count--; - } - - while (!list_empty(&mq->msg_list)) { - msg = list_first_entry(&mq->msg_list, struct message, list); - list_del(&msg->list); - kfree(msg->buf); - } - - return 0; -} - -/*! - * @author syounan - * @date 1 Sep 2010 - * @note copied from FLO glue implementatuion - * @version 1.0 - */ -int wilc_mq_send(struct message_queue *mq, - const void *send_buf, u32 send_buf_size) -{ - unsigned long flags; - struct message *new_msg = NULL; - - if (!mq || (send_buf_size == 0) || !send_buf) - return -EINVAL; - - if (mq->exiting) - return -EFAULT; - - /* construct a new message */ - new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC); - if (!new_msg) - return -ENOMEM; - - new_msg->len = send_buf_size; - INIT_LIST_HEAD(&new_msg->list); - new_msg->buf = kmemdup(send_buf, send_buf_size, GFP_ATOMIC); - if (!new_msg->buf) { - kfree(new_msg); - return -ENOMEM; - } - - spin_lock_irqsave(&mq->lock, flags); - - /* add it to the message queue */ - list_add_tail(&new_msg->list, &mq->msg_list); - - spin_unlock_irqrestore(&mq->lock, flags); - - up(&mq->sem); - - return 0; -} - -/*! - * @author syounan - * @date 1 Sep 2010 - * @note copied from FLO glue implementatuion - * @version 1.0 - */ -int wilc_mq_recv(struct message_queue *mq, - void *recv_buf, u32 recv_buf_size, u32 *recv_len) -{ - struct message *msg; - unsigned long flags; - - if (!mq || (recv_buf_size == 0) || !recv_buf || !recv_len) - return -EINVAL; - - if (mq->exiting) - return -EFAULT; - - spin_lock_irqsave(&mq->lock, flags); - mq->recv_count++; - spin_unlock_irqrestore(&mq->lock, flags); - - down(&mq->sem); - spin_lock_irqsave(&mq->lock, flags); - - if (list_empty(&mq->msg_list)) { - spin_unlock_irqrestore(&mq->lock, flags); - up(&mq->sem); - return -EFAULT; - } - /* check buffer size */ - msg = list_first_entry(&mq->msg_list, struct message, list); - if (recv_buf_size < msg->len) { - spin_unlock_irqrestore(&mq->lock, flags); - up(&mq->sem); - return -EOVERFLOW; - } - - /* consume the message */ - mq->recv_count--; - memcpy(recv_buf, msg->buf, msg->len); - *recv_len = msg->len; - - list_del(&msg->list); - - kfree(msg->buf); - kfree(msg); - - spin_unlock_irqrestore(&mq->lock, flags); - - return 0; -} diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h b/drivers/staging/wilc1000/wilc_msgqueue.h deleted file mode 100644 index 846a484..0000000 --- a/drivers/staging/wilc1000/wilc_msgqueue.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __WILC_MSG_QUEUE_H__ -#define __WILC_MSG_QUEUE_H__ - -#include -#include - -struct message { - void *buf; - u32 len; - struct list_head list; -}; - -struct message_queue { - struct semaphore sem; - spinlock_t lock; - bool exiting; - u32 recv_count; - struct list_head msg_list; -}; - -int wilc_mq_create(struct message_queue *mq); -int wilc_mq_send(struct message_queue *mq, - const void *send_buf, u32 send_buf_size); -int wilc_mq_recv(struct message_queue *mq, - void *recv_buf, u32 recv_buf_size, u32 *recv_len); -int wilc_mq_destroy(struct message_queue *mq); - -#endif -- cgit v1.1 From 2518ac59eb27ed003c5a97e8f9588adafdfe4a8a Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Thu, 23 Jun 2016 11:11:51 +0530 Subject: staging: wilc1000: Replace kthread with workqueue for host interface Deconstruct the kthread / message_queue logic, replacing it with create_singlethread_workqueue() / queue_work() setup, by adding a 'struct work_struct' to 'struct host_if_msg'. The current kthread hostIFthread() is converted to a work queue helper with the name 'host_if_work'. Signed-off-by: Binoy Jayan Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/TODO | 5 + drivers/staging/wilc1000/host_interface.c | 282 ++++++++---------------------- 2 files changed, 75 insertions(+), 212 deletions(-) diff --git a/drivers/staging/wilc1000/TODO b/drivers/staging/wilc1000/TODO index 95199d8..ec93b2e 100644 --- a/drivers/staging/wilc1000/TODO +++ b/drivers/staging/wilc1000/TODO @@ -4,6 +4,11 @@ TODO: - remove custom debug and tracing functions - rework comments and function headers(also coding style) - replace all semaphores with mutexes or completions +- Move handling for each individual members of 'union message_body' out + into a separate 'struct work_struct' and completely remove the multiplexer + that is currently part of host_if_work(), allowing movement of the + implementation of each message handler into the callsite of the function + that currently queues the 'host_if_msg'. - make spi and sdio components coexist in one build - turn compile-time platform configuration (BEAGLE_BOARD, PANDA_BOARD, PLAT_WMS8304, PLAT_RKXXXX, CUSTOMER_PLATFORM, ...) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index a34a1bb..98b9e7d 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "host_interface.h" #include #include @@ -210,6 +211,7 @@ struct host_if_msg { u16 id; union message_body body; struct wilc_vif *vif; + struct work_struct work; }; struct join_bss_param { @@ -244,7 +246,7 @@ struct join_bss_param { static struct host_if_drv *terminated_handle; bool wilc_optaining_ip; static u8 P2P_LISTEN_STATE; -static struct task_struct *hif_thread_handler; +static struct workqueue_struct *hif_workqueue; static struct message_queue hif_msg_q; static struct completion hif_thread_comp; static struct completion hif_driver_comp; @@ -279,55 +281,7 @@ static struct wilc_vif *join_req_vif; static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo); static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx); static s32 Handle_ScanDone(struct wilc_vif *vif, enum scan_event enuEvent); -static int wilc_mq_create(struct message_queue *mq); -static int wilc_mq_send(struct message_queue *mq, - const void *send_buf, u32 send_buf_size); -static int wilc_mq_recv(struct message_queue *mq, - void *recv_buf, u32 recv_buf_size, u32 *recv_len); -static int wilc_mq_destroy(struct message_queue *mq); - -/*! - * @author syounan - * @date 1 Sep 2010 - * @note copied from FLO glue implementatuion - * @version 1.0 - */ -static int wilc_mq_create(struct message_queue *mq) -{ - spin_lock_init(&mq->lock); - sema_init(&mq->sem, 0); - INIT_LIST_HEAD(&mq->msg_list); - mq->recv_count = 0; - mq->exiting = false; - return 0; -} - -/*! - * @author syounan - * @date 1 Sep 2010 - * @note copied from FLO glue implementatuion - * @version 1.0 - */ -static int wilc_mq_destroy(struct message_queue *mq) -{ - struct message *msg; - - mq->exiting = true; - - /* Release any waiting receiver thread. */ - while (mq->recv_count > 0) { - up(&mq->sem); - mq->recv_count--; - } - - while (!list_empty(&mq->msg_list)) { - msg = list_first_entry(&mq->msg_list, struct message, list); - list_del(&msg->list); - kfree(msg->buf); - } - - return 0; -} +static void host_if_work(struct work_struct *work); /*! * @author syounan @@ -338,92 +292,17 @@ static int wilc_mq_destroy(struct message_queue *mq) static int wilc_mq_send(struct message_queue *mq, const void *send_buf, u32 send_buf_size) { - unsigned long flags; - struct message *new_msg = NULL; + struct host_if_msg *new_msg; - if (!mq || (send_buf_size == 0) || !send_buf) - return -EINVAL; - - if (mq->exiting) - return -EFAULT; - - /* construct a new message */ - new_msg = kmalloc(sizeof(*new_msg), GFP_ATOMIC); + new_msg = kmemdup(send_buf, sizeof(*new_msg), GFP_ATOMIC); if (!new_msg) return -ENOMEM; - new_msg->len = send_buf_size; - INIT_LIST_HEAD(&new_msg->list); - new_msg->buf = kmemdup(send_buf, send_buf_size, GFP_ATOMIC); - if (!new_msg->buf) { - kfree(new_msg); - return -ENOMEM; - } - - spin_lock_irqsave(&mq->lock, flags); - - /* add it to the message queue */ - list_add_tail(&new_msg->list, &mq->msg_list); - - spin_unlock_irqrestore(&mq->lock, flags); - - up(&mq->sem); - + INIT_WORK(&new_msg->work, host_if_work); + queue_work(hif_workqueue, &new_msg->work); return 0; } -/*! - * @author syounan - * @date 1 Sep 2010 - * @note copied from FLO glue implementatuion - * @version 1.0 - */ -static int wilc_mq_recv(struct message_queue *mq, - void *recv_buf, u32 recv_buf_size, u32 *recv_len) -{ - struct message *msg; - unsigned long flags; - - if (!mq || (recv_buf_size == 0) || !recv_buf || !recv_len) - return -EINVAL; - - if (mq->exiting) - return -EFAULT; - - spin_lock_irqsave(&mq->lock, flags); - mq->recv_count++; - spin_unlock_irqrestore(&mq->lock, flags); - - down(&mq->sem); - spin_lock_irqsave(&mq->lock, flags); - - if (list_empty(&mq->msg_list)) { - spin_unlock_irqrestore(&mq->lock, flags); - up(&mq->sem); - return -EFAULT; - } - /* check buffer size */ - msg = list_first_entry(&mq->msg_list, struct message, list); - if (recv_buf_size < msg->len) { - spin_unlock_irqrestore(&mq->lock, flags); - up(&mq->sem); - return -EOVERFLOW; - } - - /* consume the message */ - mq->recv_count--; - memcpy(recv_buf, msg->buf, msg->len); - *recv_len = msg->len; - - list_del(&msg->list); - - kfree(msg->buf); - kfree(msg); - - spin_unlock_irqrestore(&mq->lock, flags); - - return 0; -} /* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as * special purpose in wilc device, so we add 1 to the index to starts from 1. @@ -2607,187 +2486,172 @@ static void handle_get_tx_pwr(struct wilc_vif *vif, u8 *tx_pwr) complete(&hif_wait_response); } -static int hostIFthread(void *pvArg) +static void host_if_work(struct work_struct *work) { - u32 u32Ret; - struct host_if_msg msg; - struct wilc *wilc = pvArg; - struct wilc_vif *vif; - - memset(&msg, 0, sizeof(struct host_if_msg)); + struct host_if_msg *msg; + struct wilc *wilc; - while (1) { - wilc_mq_recv(&hif_msg_q, &msg, sizeof(struct host_if_msg), &u32Ret); - vif = msg.vif; - if (msg.id == HOST_IF_MSG_EXIT) - break; + msg = container_of(work, struct host_if_msg, work); + wilc = msg->vif->wilc; - if ((!wilc_initialized)) { - usleep_range(200 * 1000, 200 * 1000); - wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); - continue; - } - - if (msg.id == HOST_IF_MSG_CONNECT && - vif->hif_drv->usr_scan_req.scan_result) { - wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); - usleep_range(2 * 1000, 2 * 1000); - continue; - } + if (msg->id == HOST_IF_MSG_CONNECT && + msg->vif->hif_drv->usr_scan_req.scan_result) { + wilc_mq_send(&hif_msg_q, msg, sizeof(struct host_if_msg)); + usleep_range(2 * 1000, 2 * 1000); + } else { - switch (msg.id) { + switch (msg->id) { case HOST_IF_MSG_SCAN: - handle_scan(msg.vif, &msg.body.scan_info); + handle_scan(msg->vif, &msg->body.scan_info); break; case HOST_IF_MSG_CONNECT: - Handle_Connect(msg.vif, &msg.body.con_info); + Handle_Connect(msg->vif, &msg->body.con_info); break; case HOST_IF_MSG_RCVD_NTWRK_INFO: - Handle_RcvdNtwrkInfo(msg.vif, &msg.body.net_info); + Handle_RcvdNtwrkInfo(msg->vif, &msg->body.net_info); break; case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO: - Handle_RcvdGnrlAsyncInfo(vif, - &msg.body.async_info); + Handle_RcvdGnrlAsyncInfo(msg->vif, + &msg->body.async_info); break; case HOST_IF_MSG_KEY: - Handle_Key(msg.vif, &msg.body.key_info); + Handle_Key(msg->vif, &msg->body.key_info); break; case HOST_IF_MSG_CFG_PARAMS: - handle_cfg_param(msg.vif, &msg.body.cfg_info); + handle_cfg_param(msg->vif, &msg->body.cfg_info); break; case HOST_IF_MSG_SET_CHANNEL: - handle_set_channel(msg.vif, &msg.body.channel_info); + handle_set_channel(msg->vif, &msg->body.channel_info); break; case HOST_IF_MSG_DISCONNECT: - Handle_Disconnect(msg.vif); + Handle_Disconnect(msg->vif); break; case HOST_IF_MSG_RCVD_SCAN_COMPLETE: - del_timer(&vif->hif_drv->scan_timer); + del_timer(&msg->vif->hif_drv->scan_timer); if (!wilc_wlan_get_num_conn_ifcs(wilc)) wilc_chip_sleep_manually(wilc); - Handle_ScanDone(msg.vif, SCAN_EVENT_DONE); + Handle_ScanDone(msg->vif, SCAN_EVENT_DONE); - if (vif->hif_drv->remain_on_ch_pending) - Handle_RemainOnChan(msg.vif, - &msg.body.remain_on_ch); + if (msg->vif->hif_drv->remain_on_ch_pending) + Handle_RemainOnChan(msg->vif, + &msg->body.remain_on_ch); break; case HOST_IF_MSG_GET_RSSI: - Handle_GetRssi(msg.vif); + Handle_GetRssi(msg->vif); break; case HOST_IF_MSG_GET_STATISTICS: - Handle_GetStatistics(msg.vif, - (struct rf_info *)msg.body.data); + Handle_GetStatistics(msg->vif, + (struct rf_info *)msg->body.data); break; case HOST_IF_MSG_ADD_BEACON: - Handle_AddBeacon(msg.vif, &msg.body.beacon_info); + Handle_AddBeacon(msg->vif, &msg->body.beacon_info); break; case HOST_IF_MSG_DEL_BEACON: - Handle_DelBeacon(msg.vif); + Handle_DelBeacon(msg->vif); break; case HOST_IF_MSG_ADD_STATION: - Handle_AddStation(msg.vif, &msg.body.add_sta_info); + Handle_AddStation(msg->vif, &msg->body.add_sta_info); break; case HOST_IF_MSG_DEL_STATION: - Handle_DelStation(msg.vif, &msg.body.del_sta_info); + Handle_DelStation(msg->vif, &msg->body.del_sta_info); break; case HOST_IF_MSG_EDIT_STATION: - Handle_EditStation(msg.vif, &msg.body.edit_sta_info); + Handle_EditStation(msg->vif, &msg->body.edit_sta_info); break; case HOST_IF_MSG_GET_INACTIVETIME: - Handle_Get_InActiveTime(msg.vif, &msg.body.mac_info); + Handle_Get_InActiveTime(msg->vif, &msg->body.mac_info); break; case HOST_IF_MSG_SCAN_TIMER_FIRED: - Handle_ScanDone(msg.vif, SCAN_EVENT_ABORTED); + Handle_ScanDone(msg->vif, SCAN_EVENT_ABORTED); break; case HOST_IF_MSG_CONNECT_TIMER_FIRED: - Handle_ConnectTimeout(msg.vif); + Handle_ConnectTimeout(msg->vif); break; case HOST_IF_MSG_POWER_MGMT: - Handle_PowerManagement(msg.vif, - &msg.body.pwr_mgmt_info); + Handle_PowerManagement(msg->vif, + &msg->body.pwr_mgmt_info); break; case HOST_IF_MSG_SET_WFIDRV_HANDLER: - handle_set_wfi_drv_handler(msg.vif, &msg.body.drv); + handle_set_wfi_drv_handler(msg->vif, &msg->body.drv); break; case HOST_IF_MSG_SET_OPERATION_MODE: - handle_set_operation_mode(msg.vif, &msg.body.mode); + handle_set_operation_mode(msg->vif, &msg->body.mode); break; case HOST_IF_MSG_SET_IPADDRESS: - handle_set_ip_address(vif, - msg.body.ip_info.ip_addr, - msg.body.ip_info.idx); + handle_set_ip_address(msg->vif, + msg->body.ip_info.ip_addr, + msg->body.ip_info.idx); break; case HOST_IF_MSG_GET_IPADDRESS: - handle_get_ip_address(vif, msg.body.ip_info.idx); + handle_get_ip_address(msg->vif, msg->body.ip_info.idx); break; case HOST_IF_MSG_GET_MAC_ADDRESS: - handle_get_mac_address(msg.vif, - &msg.body.get_mac_info); + handle_get_mac_address(msg->vif, + &msg->body.get_mac_info); break; case HOST_IF_MSG_REMAIN_ON_CHAN: - Handle_RemainOnChan(msg.vif, &msg.body.remain_on_ch); + Handle_RemainOnChan(msg->vif, &msg->body.remain_on_ch); break; case HOST_IF_MSG_REGISTER_FRAME: - Handle_RegisterFrame(msg.vif, &msg.body.reg_frame); + Handle_RegisterFrame(msg->vif, &msg->body.reg_frame); break; case HOST_IF_MSG_LISTEN_TIMER_FIRED: - Handle_ListenStateExpired(msg.vif, &msg.body.remain_on_ch); + Handle_ListenStateExpired(msg->vif, &msg->body.remain_on_ch); break; case HOST_IF_MSG_SET_MULTICAST_FILTER: - Handle_SetMulticastFilter(msg.vif, &msg.body.multicast_info); + Handle_SetMulticastFilter(msg->vif, &msg->body.multicast_info); break; case HOST_IF_MSG_DEL_ALL_STA: - Handle_DelAllSta(msg.vif, &msg.body.del_all_sta_info); + Handle_DelAllSta(msg->vif, &msg->body.del_all_sta_info); break; case HOST_IF_MSG_SET_TX_POWER: - handle_set_tx_pwr(msg.vif, msg.body.tx_power.tx_pwr); + handle_set_tx_pwr(msg->vif, msg->body.tx_power.tx_pwr); break; case HOST_IF_MSG_GET_TX_POWER: - handle_get_tx_pwr(msg.vif, &msg.body.tx_power.tx_pwr); + handle_get_tx_pwr(msg->vif, &msg->body.tx_power.tx_pwr); break; default: - netdev_err(vif->ndev, "[Host Interface] undefined\n"); + netdev_err(msg->vif->ndev, "[Host Interface] undefined\n"); break; } } - + kfree(msg); complete(&hif_thread_comp); - return 0; } static void TimerCB_Scan(unsigned long arg) @@ -3514,21 +3378,17 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) init_completion(&hif_drv->comp_inactive_time); if (clients_count == 0) { - result = wilc_mq_create(&hif_msg_q); - if (result < 0) { netdev_err(vif->ndev, "Failed to creat MQ\n"); goto _fail_; } - - hif_thread_handler = kthread_run(hostIFthread, wilc, - "WILC_kthread"); - - if (IS_ERR(hif_thread_handler)) { - netdev_err(vif->ndev, "Failed to creat Thread\n"); - result = -EFAULT; + hif_workqueue = create_singlethread_workqueue("WILC_wq"); + if (!hif_workqueue) { + netdev_err(vif->ndev, "Failed to create workqueue\n"); + result = -ENOMEM; goto _fail_mq_; } + setup_timer(&periodic_rssi, GetPeriodicRSSI, (unsigned long)vif); mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000)); @@ -3554,10 +3414,8 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) clients_count++; - return result; - _fail_mq_: - wilc_mq_destroy(&hif_msg_q); + destroy_workqueue(hif_workqueue); _fail_: return result; } @@ -3607,7 +3465,7 @@ int wilc_deinit(struct wilc_vif *vif) else wait_for_completion(&hif_thread_comp); - wilc_mq_destroy(&hif_msg_q); + destroy_workqueue(hif_workqueue); } kfree(hif_drv); -- cgit v1.1 From a5c84b2f67259e06d78e0dbf5ce55a9fdb77c084 Mon Sep 17 00:00:00 2001 From: Binoy Jayan Date: Thu, 23 Jun 2016 11:11:52 +0530 Subject: staging: wilc1000: Change interface wilc_mq_send to wilc_enqueue_cmd Replace the interface 'wilc_mq_send' with 'wilc_enqueue_cmd' and remove the now unused structures 'message' and 'message_queue'. Restructure switch statement in the work queue helper function host_if_work and remove unwanted indentation. Signed-off-by: Binoy Jayan Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 333 ++++++++++++++---------------- 1 file changed, 158 insertions(+), 175 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 98b9e7d..bee693a 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -60,20 +60,6 @@ #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 #define DEFAULT_LINK_SPEED 72 -struct message { - void *buf; - u32 len; - struct list_head list; -}; - -struct message_queue { - struct semaphore sem; - spinlock_t lock; - bool exiting; - u32 recv_count; - struct list_head msg_list; -}; - struct host_if_wpa_attr { u8 *key; const u8 *mac_addr; @@ -247,7 +233,6 @@ static struct host_if_drv *terminated_handle; bool wilc_optaining_ip; static u8 P2P_LISTEN_STATE; static struct workqueue_struct *hif_workqueue; -static struct message_queue hif_msg_q; static struct completion hif_thread_comp; static struct completion hif_driver_comp; static struct completion hif_wait_response; @@ -289,12 +274,11 @@ static void host_if_work(struct work_struct *work); * @note copied from FLO glue implementatuion * @version 1.0 */ -static int wilc_mq_send(struct message_queue *mq, - const void *send_buf, u32 send_buf_size) +static int wilc_enqueue_cmd(struct host_if_msg *msg) { struct host_if_msg *new_msg; - new_msg = kmemdup(send_buf, sizeof(*new_msg), GFP_ATOMIC); + new_msg = kmemdup(msg, sizeof(*new_msg), GFP_ATOMIC); if (!new_msg) return -ENOMEM; @@ -2386,7 +2370,7 @@ static void ListenTimerCB(unsigned long arg) msg.vif = vif; msg.body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc_mq_send fail\n"); } @@ -2496,160 +2480,159 @@ static void host_if_work(struct work_struct *work) if (msg->id == HOST_IF_MSG_CONNECT && msg->vif->hif_drv->usr_scan_req.scan_result) { - wilc_mq_send(&hif_msg_q, msg, sizeof(struct host_if_msg)); + wilc_enqueue_cmd(msg); usleep_range(2 * 1000, 2 * 1000); - } else { - - switch (msg->id) { - case HOST_IF_MSG_SCAN: - handle_scan(msg->vif, &msg->body.scan_info); - break; - - case HOST_IF_MSG_CONNECT: - Handle_Connect(msg->vif, &msg->body.con_info); - break; + goto free_msg; + } + switch (msg->id) { + case HOST_IF_MSG_SCAN: + handle_scan(msg->vif, &msg->body.scan_info); + break; - case HOST_IF_MSG_RCVD_NTWRK_INFO: - Handle_RcvdNtwrkInfo(msg->vif, &msg->body.net_info); - break; + case HOST_IF_MSG_CONNECT: + Handle_Connect(msg->vif, &msg->body.con_info); + break; - case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO: - Handle_RcvdGnrlAsyncInfo(msg->vif, - &msg->body.async_info); - break; + case HOST_IF_MSG_RCVD_NTWRK_INFO: + Handle_RcvdNtwrkInfo(msg->vif, &msg->body.net_info); + break; - case HOST_IF_MSG_KEY: - Handle_Key(msg->vif, &msg->body.key_info); - break; + case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO: + Handle_RcvdGnrlAsyncInfo(msg->vif, + &msg->body.async_info); + break; - case HOST_IF_MSG_CFG_PARAMS: - handle_cfg_param(msg->vif, &msg->body.cfg_info); - break; + case HOST_IF_MSG_KEY: + Handle_Key(msg->vif, &msg->body.key_info); + break; - case HOST_IF_MSG_SET_CHANNEL: - handle_set_channel(msg->vif, &msg->body.channel_info); - break; + case HOST_IF_MSG_CFG_PARAMS: + handle_cfg_param(msg->vif, &msg->body.cfg_info); + break; - case HOST_IF_MSG_DISCONNECT: - Handle_Disconnect(msg->vif); - break; + case HOST_IF_MSG_SET_CHANNEL: + handle_set_channel(msg->vif, &msg->body.channel_info); + break; - case HOST_IF_MSG_RCVD_SCAN_COMPLETE: - del_timer(&msg->vif->hif_drv->scan_timer); + case HOST_IF_MSG_DISCONNECT: + Handle_Disconnect(msg->vif); + break; - if (!wilc_wlan_get_num_conn_ifcs(wilc)) - wilc_chip_sleep_manually(wilc); + case HOST_IF_MSG_RCVD_SCAN_COMPLETE: + del_timer(&msg->vif->hif_drv->scan_timer); - Handle_ScanDone(msg->vif, SCAN_EVENT_DONE); + if (!wilc_wlan_get_num_conn_ifcs(wilc)) + wilc_chip_sleep_manually(wilc); - if (msg->vif->hif_drv->remain_on_ch_pending) - Handle_RemainOnChan(msg->vif, - &msg->body.remain_on_ch); + Handle_ScanDone(msg->vif, SCAN_EVENT_DONE); - break; + if (msg->vif->hif_drv->remain_on_ch_pending) + Handle_RemainOnChan(msg->vif, + &msg->body.remain_on_ch); - case HOST_IF_MSG_GET_RSSI: - Handle_GetRssi(msg->vif); - break; + break; - case HOST_IF_MSG_GET_STATISTICS: - Handle_GetStatistics(msg->vif, - (struct rf_info *)msg->body.data); - break; + case HOST_IF_MSG_GET_RSSI: + Handle_GetRssi(msg->vif); + break; - case HOST_IF_MSG_ADD_BEACON: - Handle_AddBeacon(msg->vif, &msg->body.beacon_info); - break; + case HOST_IF_MSG_GET_STATISTICS: + Handle_GetStatistics(msg->vif, + (struct rf_info *)msg->body.data); + break; - case HOST_IF_MSG_DEL_BEACON: - Handle_DelBeacon(msg->vif); - break; + case HOST_IF_MSG_ADD_BEACON: + Handle_AddBeacon(msg->vif, &msg->body.beacon_info); + break; - case HOST_IF_MSG_ADD_STATION: - Handle_AddStation(msg->vif, &msg->body.add_sta_info); - break; + case HOST_IF_MSG_DEL_BEACON: + Handle_DelBeacon(msg->vif); + break; - case HOST_IF_MSG_DEL_STATION: - Handle_DelStation(msg->vif, &msg->body.del_sta_info); - break; + case HOST_IF_MSG_ADD_STATION: + Handle_AddStation(msg->vif, &msg->body.add_sta_info); + break; - case HOST_IF_MSG_EDIT_STATION: - Handle_EditStation(msg->vif, &msg->body.edit_sta_info); - break; + case HOST_IF_MSG_DEL_STATION: + Handle_DelStation(msg->vif, &msg->body.del_sta_info); + break; - case HOST_IF_MSG_GET_INACTIVETIME: - Handle_Get_InActiveTime(msg->vif, &msg->body.mac_info); - break; + case HOST_IF_MSG_EDIT_STATION: + Handle_EditStation(msg->vif, &msg->body.edit_sta_info); + break; - case HOST_IF_MSG_SCAN_TIMER_FIRED: + case HOST_IF_MSG_GET_INACTIVETIME: + Handle_Get_InActiveTime(msg->vif, &msg->body.mac_info); + break; - Handle_ScanDone(msg->vif, SCAN_EVENT_ABORTED); - break; + case HOST_IF_MSG_SCAN_TIMER_FIRED: + Handle_ScanDone(msg->vif, SCAN_EVENT_ABORTED); + break; - case HOST_IF_MSG_CONNECT_TIMER_FIRED: - Handle_ConnectTimeout(msg->vif); - break; + case HOST_IF_MSG_CONNECT_TIMER_FIRED: + Handle_ConnectTimeout(msg->vif); + break; - case HOST_IF_MSG_POWER_MGMT: - Handle_PowerManagement(msg->vif, - &msg->body.pwr_mgmt_info); - break; + case HOST_IF_MSG_POWER_MGMT: + Handle_PowerManagement(msg->vif, + &msg->body.pwr_mgmt_info); + break; - case HOST_IF_MSG_SET_WFIDRV_HANDLER: - handle_set_wfi_drv_handler(msg->vif, &msg->body.drv); - break; + case HOST_IF_MSG_SET_WFIDRV_HANDLER: + handle_set_wfi_drv_handler(msg->vif, &msg->body.drv); + break; - case HOST_IF_MSG_SET_OPERATION_MODE: - handle_set_operation_mode(msg->vif, &msg->body.mode); - break; + case HOST_IF_MSG_SET_OPERATION_MODE: + handle_set_operation_mode(msg->vif, &msg->body.mode); + break; - case HOST_IF_MSG_SET_IPADDRESS: - handle_set_ip_address(msg->vif, - msg->body.ip_info.ip_addr, - msg->body.ip_info.idx); - break; + case HOST_IF_MSG_SET_IPADDRESS: + handle_set_ip_address(msg->vif, + msg->body.ip_info.ip_addr, + msg->body.ip_info.idx); + break; - case HOST_IF_MSG_GET_IPADDRESS: - handle_get_ip_address(msg->vif, msg->body.ip_info.idx); - break; + case HOST_IF_MSG_GET_IPADDRESS: + handle_get_ip_address(msg->vif, msg->body.ip_info.idx); + break; - case HOST_IF_MSG_GET_MAC_ADDRESS: - handle_get_mac_address(msg->vif, - &msg->body.get_mac_info); - break; + case HOST_IF_MSG_GET_MAC_ADDRESS: + handle_get_mac_address(msg->vif, + &msg->body.get_mac_info); + break; - case HOST_IF_MSG_REMAIN_ON_CHAN: - Handle_RemainOnChan(msg->vif, &msg->body.remain_on_ch); - break; + case HOST_IF_MSG_REMAIN_ON_CHAN: + Handle_RemainOnChan(msg->vif, &msg->body.remain_on_ch); + break; - case HOST_IF_MSG_REGISTER_FRAME: - Handle_RegisterFrame(msg->vif, &msg->body.reg_frame); - break; + case HOST_IF_MSG_REGISTER_FRAME: + Handle_RegisterFrame(msg->vif, &msg->body.reg_frame); + break; - case HOST_IF_MSG_LISTEN_TIMER_FIRED: - Handle_ListenStateExpired(msg->vif, &msg->body.remain_on_ch); - break; + case HOST_IF_MSG_LISTEN_TIMER_FIRED: + Handle_ListenStateExpired(msg->vif, &msg->body.remain_on_ch); + break; - case HOST_IF_MSG_SET_MULTICAST_FILTER: - Handle_SetMulticastFilter(msg->vif, &msg->body.multicast_info); - break; + case HOST_IF_MSG_SET_MULTICAST_FILTER: + Handle_SetMulticastFilter(msg->vif, &msg->body.multicast_info); + break; - case HOST_IF_MSG_DEL_ALL_STA: - Handle_DelAllSta(msg->vif, &msg->body.del_all_sta_info); - break; + case HOST_IF_MSG_DEL_ALL_STA: + Handle_DelAllSta(msg->vif, &msg->body.del_all_sta_info); + break; - case HOST_IF_MSG_SET_TX_POWER: - handle_set_tx_pwr(msg->vif, msg->body.tx_power.tx_pwr); - break; + case HOST_IF_MSG_SET_TX_POWER: + handle_set_tx_pwr(msg->vif, msg->body.tx_power.tx_pwr); + break; - case HOST_IF_MSG_GET_TX_POWER: - handle_get_tx_pwr(msg->vif, &msg->body.tx_power.tx_pwr); - break; - default: - netdev_err(msg->vif->ndev, "[Host Interface] undefined\n"); - break; - } + case HOST_IF_MSG_GET_TX_POWER: + handle_get_tx_pwr(msg->vif, &msg->body.tx_power.tx_pwr); + break; + default: + netdev_err(msg->vif->ndev, "[Host Interface] undefined\n"); + break; } +free_msg: kfree(msg); complete(&hif_thread_comp); } @@ -2663,7 +2646,7 @@ static void TimerCB_Scan(unsigned long arg) msg.vif = vif; msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED; - wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + wilc_enqueue_cmd(&msg); } static void TimerCB_Connect(unsigned long arg) @@ -2675,7 +2658,7 @@ static void TimerCB_Connect(unsigned long arg) msg.vif = vif; msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED; - wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + wilc_enqueue_cmd(&msg); } s32 wilc_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress) @@ -2710,7 +2693,7 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) msg.vif = vif; msg.body.key_info.attr.wep.index = index; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "Request to remove WEP key\n"); else @@ -2739,7 +2722,7 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) msg.vif = vif; msg.body.key_info.attr.wep.index = index; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "Default key index\n"); else @@ -2773,7 +2756,7 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, msg.body.key_info.attr.wep.key_len = len; msg.body.key_info.attr.wep.index = index; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "STA - WEP Key\n"); wait_for_completion(&hif_drv->comp_test_key_block); @@ -2808,7 +2791,7 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, msg.body.key_info.attr.wep.mode = mode; msg.body.key_info.attr.wep.auth_type = auth_type; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "AP - WEP Key\n"); @@ -2864,7 +2847,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, msg.body.key_info.attr.wpa.mode = cipher_mode; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "PTK Key\n"); @@ -2933,7 +2916,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, msg.body.key_info.attr.wpa.key_len = key_len; msg.body.key_info.attr.wpa.seq_len = key_rsc_len; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "RX GTK\n"); else @@ -2963,7 +2946,7 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, &pmkid->pmkidlist[i].pmkid, PMKID_LEN); } - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "PMKID Info\n"); @@ -2981,7 +2964,7 @@ int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) msg.body.get_mac_info.mac_addr = mac_addr; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) { netdev_err(vif->ndev, "Failed to send get mac address\n"); return -EFAULT; @@ -3045,7 +3028,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, if (hif_drv->hif_state < HOST_IF_CONNECTING) hif_drv->hif_state = HOST_IF_CONNECTING; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) { netdev_err(vif->ndev, "send message: Set join request\n"); return -EFAULT; @@ -3074,7 +3057,7 @@ int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) msg.id = HOST_IF_MSG_DISCONNECT; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "Failed to send message: disconnect\n"); else @@ -3118,7 +3101,7 @@ int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) msg.body.channel_info.set_ch = channel; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); return -EINVAL; @@ -3138,7 +3121,7 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mac_idx) msg.body.drv.mac_idx = mac_idx; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); result = -EINVAL; @@ -3157,7 +3140,7 @@ int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode) msg.body.mode.mode = mode; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) { netdev_err(vif->ndev, "wilc mq send fail\n"); result = -EINVAL; @@ -3184,7 +3167,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, msg.id = HOST_IF_MSG_GET_INACTIVETIME; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "Failed to send get host ch param\n"); else @@ -3205,7 +3188,7 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) msg.id = HOST_IF_MSG_GET_RSSI; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) { netdev_err(vif->ndev, "Failed to send get host ch param\n"); return -EFAULT; @@ -3233,7 +3216,7 @@ int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) msg.body.data = (char *)stats; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) { netdev_err(vif->ndev, "Failed to send get host channel\n"); return -EFAULT; @@ -3286,7 +3269,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, if (!scan_info->ies) return -ENOMEM; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) { netdev_err(vif->ndev, "Error in sending message queue\n"); return -EINVAL; @@ -3316,7 +3299,7 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, msg.body.cfg_info = *cfg_param; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); return result; } @@ -3459,7 +3442,7 @@ int wilc_deinit(struct wilc_vif *vif) msg.id = HOST_IF_MSG_EXIT; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result != 0) netdev_err(vif->ndev, "deinit : Error(%d)\n", result); else @@ -3505,7 +3488,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 *pu8Buffer, msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL); memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length); - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "message parameters (%d)\n", result); } @@ -3550,7 +3533,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer, msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL); memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length); - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "synchronous info (%d)\n", result); @@ -3581,7 +3564,7 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 *pu8Buffer, msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "complete param (%d)\n", result); } @@ -3607,7 +3590,7 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, msg.body.remain_on_ch.id = session_id; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc mq send fail\n"); @@ -3632,7 +3615,7 @@ int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) msg.vif = vif; msg.body.remain_on_ch.id = session_id; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc mq send fail\n"); @@ -3663,7 +3646,7 @@ int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) msg.body.reg_frame.reg = reg; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc mq send fail\n"); @@ -3701,7 +3684,7 @@ int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, beacon_info->tail = NULL; } - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc mq send fail\n"); @@ -3723,7 +3706,7 @@ int wilc_del_beacon(struct wilc_vif *vif) msg.id = HOST_IF_MSG_DEL_BEACON; msg.vif = vif; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc_mq_send fail\n"); @@ -3750,7 +3733,7 @@ int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param) return -ENOMEM; } - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc_mq_send fail\n"); return result; @@ -3772,7 +3755,7 @@ int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) else memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN); - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc_mq_send fail\n"); return result; @@ -3802,7 +3785,7 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) return result; del_all_sta_info->assoc_sta = assoc_sta; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc_mq_send fail\n"); @@ -3833,7 +3816,7 @@ int wilc_edit_station(struct wilc_vif *vif, return -ENOMEM; } - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc_mq_send fail\n"); @@ -3857,7 +3840,7 @@ int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) pwr_mgmt_info->enabled = enabled; pwr_mgmt_info->timeout = timeout; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc_mq_send fail\n"); return result; @@ -3878,7 +3861,7 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, multicast_filter_param->enabled = enabled; multicast_filter_param->cnt = count; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc_mq_send fail\n"); return result; @@ -4051,7 +4034,7 @@ int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) msg.vif = vif; msg.body.ip_info.idx = idx; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc_mq_send fail\n"); @@ -4071,7 +4054,7 @@ static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) msg.vif = vif; msg.body.ip_info.idx = idx; - result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + result = wilc_enqueue_cmd(&msg); if (result) netdev_err(vif->ndev, "wilc_mq_send fail\n"); @@ -4089,7 +4072,7 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) msg.body.tx_power.tx_pwr = tx_power; msg.vif = vif; - ret = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + ret = wilc_enqueue_cmd(&msg); if (ret) netdev_err(vif->ndev, "wilc_mq_send fail\n"); @@ -4106,7 +4089,7 @@ int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) msg.id = HOST_IF_MSG_GET_TX_POWER; msg.vif = vif; - ret = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg)); + ret = wilc_enqueue_cmd(&msg); if (ret) netdev_err(vif->ndev, "Failed to get TX PWR\n"); -- cgit v1.1 From 4562d224edbe62e5620abbf49ffa8ceae2b73762 Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Thu, 23 Jun 2016 18:57:09 +0100 Subject: staging: wilc1000: arrays can't be NULL hif_drv->usr_scan_req.net.net_info[i] contains found_net_info structs which have the following element: u8 bssid[6]; pstrNetworkInfo, of type network_info, also contains an u8 array named bssid. request->ssids is an array of cfg80211_ssid structs. Making ssid: u8 ssid[IEEE80211_MAX_SSID_LEN]; In these 3 cases the arrays are being checked against NULL, which can't happen. Removing the checks since they will always be true. Found with smatch: drivers/staging/wilc1000/host_interface.c:1234 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'hif_drv->usr_scan_req.net_info[i].bssid' drivers/staging/wilc1000/host_interface.c:1235 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'pstrNetworkInfo->bssid' drivers/staging/wilc1000/host_interface.c:1253 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid' drivers/staging/wilc1000/host_interface.c:1254 Handle_RcvdNtwrkInfo() warn: this array is probably non-NULL. 'pstrNetworkInfo->bssid' Signed-off-by: Luis de Bethencourt Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 38 ++++++++++------------- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 3 +- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index bee693a..0b1760c 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1237,17 +1237,14 @@ static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif, } for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) { - if ((hif_drv->usr_scan_req.net_info[i].bssid) && - (pstrNetworkInfo->bssid)) { - if (memcmp(hif_drv->usr_scan_req.net_info[i].bssid, - pstrNetworkInfo->bssid, 6) == 0) { - if (pstrNetworkInfo->rssi <= hif_drv->usr_scan_req.net_info[i].rssi) { - goto done; - } else { - hif_drv->usr_scan_req.net_info[i].rssi = pstrNetworkInfo->rssi; - bNewNtwrkFound = false; - break; - } + if (memcmp(hif_drv->usr_scan_req.net_info[i].bssid, + pstrNetworkInfo->bssid, 6) == 0) { + if (pstrNetworkInfo->rssi <= hif_drv->usr_scan_req.net_info[i].rssi) { + goto done; + } else { + hif_drv->usr_scan_req.net_info[i].rssi = pstrNetworkInfo->rssi; + bNewNtwrkFound = false; + break; } } } @@ -1256,20 +1253,17 @@ static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif, if (hif_drv->usr_scan_req.rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) { hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].rssi = pstrNetworkInfo->rssi; - if (hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid && - pstrNetworkInfo->bssid) { - memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid, - pstrNetworkInfo->bssid, 6); + memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid, + pstrNetworkInfo->bssid, 6); - hif_drv->usr_scan_req.rcvd_ch_cnt++; + hif_drv->usr_scan_req.rcvd_ch_cnt++; - pstrNetworkInfo->new_network = true; - pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo); + pstrNetworkInfo->new_network = true; + pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo); - hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo, - hif_drv->usr_scan_req.arg, - pJoinParams); - } + hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo, + hif_drv->usr_scan_req.arg, + pJoinParams); } } else { pstrNetworkInfo->new_network = false; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 51aff4f..3ddfa4a 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -625,8 +625,7 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) for (i = 0; i < request->n_ssids; i++) { - if (request->ssids[i].ssid && - request->ssids[i].ssid_len != 0) { + if (request->ssids[i].ssid_len != 0) { strHiddenNetwork.net_info[i].ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL); memcpy(strHiddenNetwork.net_info[i].ssid, request->ssids[i].ssid, request->ssids[i].ssid_len); strHiddenNetwork.net_info[i].ssid_len = request->ssids[i].ssid_len; -- cgit v1.1 From b3e6916d6edfdf12505efbfb4a019e8a96f2c674 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Fri, 17 Jun 2016 17:34:17 +0000 Subject: staging: wilc1000: fix return value check in wlan_initialize_threads() In case of error, the function kthread_run() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Signed-off-by: Wei Yongjun Reviewed-by: Julian Calaby Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 2ce9df5..3a66255 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -715,10 +715,10 @@ static int wlan_initialize_threads(struct net_device *dev) wilc->txq_thread = kthread_run(linux_wlan_txq_task, (void *)dev, "K_TXQ_TASK"); - if (!wilc->txq_thread) { + if (IS_ERR(wilc->txq_thread)) { netdev_err(dev, "couldn't create TXQ thread\n"); wilc->close = 0; - return -ENOBUFS; + return PTR_ERR(wilc->txq_thread); } wait_for_completion(&wilc->txq_thread_started); -- cgit v1.1 From 3d579c350842c7a46da2da76b3461f7cfa3f6df9 Mon Sep 17 00:00:00 2001 From: Stuart Yoder Date: Wed, 22 Jun 2016 16:40:42 -0500 Subject: staging: fsl-mc: add support for the modalias sysfs attribute In order to support uevent based module loading implement modalias support for the fsl-mc bus driver. Aliases are based on vendor and object/device id and are of the form "fsl-mc:vNdN". Signed-off-by: Stuart Yoder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-mc/bus/mc-bus.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c index 4053643..d8776dd 100644 --- a/drivers/staging/fsl-mc/bus/mc-bus.c +++ b/drivers/staging/fsl-mc/bus/mc-bus.c @@ -82,10 +82,35 @@ static int fsl_mc_bus_uevent(struct device *dev, struct kobj_uevent_env *env) return 0; } +static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); + + return sprintf(buf, "fsl-mc:v%08Xd%s\n", mc_dev->obj_desc.vendor, + mc_dev->obj_desc.type); +} +static DEVICE_ATTR_RO(modalias); + +static struct attribute *fsl_mc_dev_attrs[] = { + &dev_attr_modalias.attr, + NULL, +}; + +static const struct attribute_group fsl_mc_dev_group = { + .attrs = fsl_mc_dev_attrs, +}; + +static const struct attribute_group *fsl_mc_dev_groups[] = { + &fsl_mc_dev_group, + NULL, +}; + struct bus_type fsl_mc_bus_type = { .name = "fsl-mc", .match = fsl_mc_bus_match, .uevent = fsl_mc_bus_uevent, + .dev_groups = fsl_mc_dev_groups, }; EXPORT_SYMBOL_GPL(fsl_mc_bus_type); -- cgit v1.1 From d568b7679f03aca820e61a758a8b034cff8ccb40 Mon Sep 17 00:00:00 2001 From: Stuart Yoder Date: Wed, 22 Jun 2016 16:40:43 -0500 Subject: staging: fsl-mc: implement uevent callback and set the modalias Replace placeholder code in the uevent callback to properly set the MODALIAS env variable. Signed-off-by: Stuart Yoder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-mc/bus/mc-bus.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c index d8776dd..cf92a1c 100644 --- a/drivers/staging/fsl-mc/bus/mc-bus.c +++ b/drivers/staging/fsl-mc/bus/mc-bus.c @@ -78,7 +78,13 @@ out: */ static int fsl_mc_bus_uevent(struct device *dev, struct kobj_uevent_env *env) { - pr_debug("%s invoked\n", __func__); + struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); + + if (add_uevent_var(env, "MODALIAS=fsl-mc:v%08Xd%s", + mc_dev->obj_desc.vendor, + mc_dev->obj_desc.type)) + return -ENOMEM; + return 0; } -- cgit v1.1 From 57538afb42e492eb6984f89663361bcfd80d9745 Mon Sep 17 00:00:00 2001 From: Stuart Yoder Date: Wed, 22 Jun 2016 16:40:44 -0500 Subject: staging: fsl-mc: clean up the device id struct -rename the struct used for fsl-mc device ids to be more consistent with other busses -remove the now obsolete and unused version fields Signed-off-by: Stuart Yoder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-mc/bus/dprc-driver.c | 2 +- drivers/staging/fsl-mc/bus/mc-allocator.c | 2 +- drivers/staging/fsl-mc/bus/mc-bus.c | 2 +- drivers/staging/fsl-mc/include/mc.h | 10 +++------- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl-mc/bus/dprc-driver.c index 7fc4717..f865d18 100644 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c @@ -805,7 +805,7 @@ static int dprc_remove(struct fsl_mc_device *mc_dev) return 0; } -static const struct fsl_mc_device_match_id match_id_table[] = { +static const struct fsl_mc_device_id match_id_table[] = { { .vendor = FSL_MC_VENDOR_FREESCALE, .obj_type = "dprc"}, diff --git a/drivers/staging/fsl-mc/bus/mc-allocator.c b/drivers/staging/fsl-mc/bus/mc-allocator.c index fb08f22..e59d850 100644 --- a/drivers/staging/fsl-mc/bus/mc-allocator.c +++ b/drivers/staging/fsl-mc/bus/mc-allocator.c @@ -717,7 +717,7 @@ static int fsl_mc_allocator_remove(struct fsl_mc_device *mc_dev) return 0; } -static const struct fsl_mc_device_match_id match_id_table[] = { +static const struct fsl_mc_device_id match_id_table[] = { { .vendor = FSL_MC_VENDOR_FREESCALE, .obj_type = "dpbp", diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c index cf92a1c..e975adc 100644 --- a/drivers/staging/fsl-mc/bus/mc-bus.c +++ b/drivers/staging/fsl-mc/bus/mc-bus.c @@ -36,7 +36,7 @@ static bool fsl_mc_is_root_dprc(struct device *dev); */ static int fsl_mc_bus_match(struct device *dev, struct device_driver *drv) { - const struct fsl_mc_device_match_id *id; + const struct fsl_mc_device_id *id; struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(drv); bool found = false; diff --git a/drivers/staging/fsl-mc/include/mc.h b/drivers/staging/fsl-mc/include/mc.h index ac7c1ce..bc0d45c 100644 --- a/drivers/staging/fsl-mc/include/mc.h +++ b/drivers/staging/fsl-mc/include/mc.h @@ -39,7 +39,7 @@ struct fsl_mc_bus; */ struct fsl_mc_driver { struct device_driver driver; - const struct fsl_mc_device_match_id *match_id_table; + const struct fsl_mc_device_id *match_id_table; int (*probe)(struct fsl_mc_device *dev); int (*remove)(struct fsl_mc_device *dev); void (*shutdown)(struct fsl_mc_device *dev); @@ -51,20 +51,16 @@ struct fsl_mc_driver { container_of(_drv, struct fsl_mc_driver, driver) /** - * struct fsl_mc_device_match_id - MC object device Id entry for driver matching + * struct fsl_mc_device_id - MC object device Id entry for driver matching * @vendor: vendor ID * @obj_type: MC object type - * @ver_major: MC object version major number - * @ver_minor: MC object version minor number * * Type of entries in the "device Id" table for MC object devices supported by * a MC object device driver. The last entry of the table has vendor set to 0x0 */ -struct fsl_mc_device_match_id { +struct fsl_mc_device_id { u16 vendor; const char obj_type[16]; - u32 ver_major; - u32 ver_minor; }; /** -- cgit v1.1 From 0afef45654ae908536278ecb143ded5bbc713391 Mon Sep 17 00:00:00 2001 From: Stuart Yoder Date: Wed, 22 Jun 2016 16:40:45 -0500 Subject: staging: fsl-mc: add support for device table matching Move the definition of fsl_mc_device_id to its proper location in mod_devicetable.h, and add fsl-mc bus support to devicetable-offsets.c and file2alias.c to enable device table matching. With this patch udev based module loading of fsl-mc drivers is supported. Signed-off-by: Stuart Yoder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-mc/include/mc.h | 13 ------------- include/linux/mod_devicetable.h | 16 ++++++++++++++++ scripts/mod/devicetable-offsets.c | 4 ++++ scripts/mod/file2alias.c | 12 ++++++++++++ 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/drivers/staging/fsl-mc/include/mc.h b/drivers/staging/fsl-mc/include/mc.h index bc0d45c..a9a9d23 100644 --- a/drivers/staging/fsl-mc/include/mc.h +++ b/drivers/staging/fsl-mc/include/mc.h @@ -51,19 +51,6 @@ struct fsl_mc_driver { container_of(_drv, struct fsl_mc_driver, driver) /** - * struct fsl_mc_device_id - MC object device Id entry for driver matching - * @vendor: vendor ID - * @obj_type: MC object type - * - * Type of entries in the "device Id" table for MC object devices supported by - * a MC object device driver. The last entry of the table has vendor set to 0x0 - */ -struct fsl_mc_device_id { - u16 vendor; - const char obj_type[16]; -}; - -/** * enum fsl_mc_pool_type - Types of allocatable MC bus resources * * Entries in these enum are used as indices in the array of resource diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 6e4c645..ed84c07 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -657,4 +657,20 @@ struct ulpi_device_id { kernel_ulong_t driver_data; }; +/** + * struct fsl_mc_device_id - MC object device identifier + * @vendor: vendor ID + * @obj_type: MC object type + * @ver_major: MC object version major number + * @ver_minor: MC object version minor number + * + * Type of entries in the "device Id" table for MC object devices supported by + * a MC object device driver. The last entry of the table has vendor set to 0x0 + */ +struct fsl_mc_device_id { + __u16 vendor; + const char obj_type[16]; +}; + + #endif /* LINUX_MOD_DEVICETABLE_H */ diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index 840b973..e4d90e5 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -202,5 +202,9 @@ int main(void) DEVID_FIELD(hda_device_id, rev_id); DEVID_FIELD(hda_device_id, api_version); + DEVID(fsl_mc_device_id); + DEVID_FIELD(fsl_mc_device_id, vendor); + DEVID_FIELD(fsl_mc_device_id, obj_type); + return 0; } diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index fec7578..29d6699 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1289,6 +1289,18 @@ static int do_hda_entry(const char *filename, void *symval, char *alias) } ADD_TO_DEVTABLE("hdaudio", hda_device_id, do_hda_entry); +/* Looks like: fsl-mc:vNdN */ +static int do_fsl_mc_entry(const char *filename, void *symval, + char *alias) +{ + DEF_FIELD(symval, fsl_mc_device_id, vendor); + DEF_FIELD_ADDR(symval, fsl_mc_device_id, obj_type); + + sprintf(alias, "fsl-mc:v%08Xd%s", vendor, *obj_type); + return 1; +} +ADD_TO_DEVTABLE("fslmc", fsl_mc_device_id, do_fsl_mc_entry); + /* Does namelen bytes of name exactly match the symbol? */ static bool sym_is(const char *name, unsigned namelen, const char *symbol) { -- cgit v1.1 From ec8d35d430922273a6cc68cfafaeadc5eb767c12 Mon Sep 17 00:00:00 2001 From: Stuart Yoder Date: Wed, 22 Jun 2016 16:40:46 -0500 Subject: staging: fsl-mc: export mc_get_version some drivers (built as modules) rely on mc_get_version() Signed-off-by: Stuart Yoder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-mc/bus/dpmng.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/fsl-mc/bus/dpmng.c b/drivers/staging/fsl-mc/bus/dpmng.c index f633fcd..a31fa9b 100644 --- a/drivers/staging/fsl-mc/bus/dpmng.c +++ b/drivers/staging/fsl-mc/bus/dpmng.c @@ -67,6 +67,7 @@ int mc_get_version(struct fsl_mc_io *mc_io, return 0; } +EXPORT_SYMBOL(mc_get_version); /** * dpmng_get_container_id() - Get container ID associated with a given portal. -- cgit v1.1 From fde867d308f39dfd4744c8da1695547b20e002b1 Mon Sep 17 00:00:00 2001 From: Stuart Yoder Date: Wed, 22 Jun 2016 16:40:47 -0500 Subject: staging: fsl-mc: make fsl_mc_is_root_dprc() global make fsl_mc_is_root_dprc() global so that the dprc driver can use it Signed-off-by: Stuart Yoder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-mc/bus/mc-bus.c | 28 +++++++++++++--------------- drivers/staging/fsl-mc/include/mc.h | 2 ++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c index e975adc..a49186e 100644 --- a/drivers/staging/fsl-mc/bus/mc-bus.c +++ b/drivers/staging/fsl-mc/bus/mc-bus.c @@ -24,8 +24,6 @@ static struct kmem_cache *mc_dev_cache; -static bool fsl_mc_is_root_dprc(struct device *dev); - /** * fsl_mc_bus_match - device to driver matching callback * @dev: the MC object device structure to match against @@ -247,19 +245,6 @@ static void fsl_mc_get_root_dprc(struct device *dev, } } -/** - * fsl_mc_is_root_dprc - function to check if a given device is a root dprc - */ -static bool fsl_mc_is_root_dprc(struct device *dev) -{ - struct device *root_dprc_dev; - - fsl_mc_get_root_dprc(dev, &root_dprc_dev); - if (!root_dprc_dev) - return false; - return dev == root_dprc_dev; -} - static int get_dprc_attr(struct fsl_mc_io *mc_io, int container_id, struct dprc_attributes *attr) { @@ -424,6 +409,19 @@ error_cleanup_regions: } /** + * fsl_mc_is_root_dprc - function to check if a given device is a root dprc + */ +bool fsl_mc_is_root_dprc(struct device *dev) +{ + struct device *root_dprc_dev; + + fsl_mc_get_root_dprc(dev, &root_dprc_dev); + if (!root_dprc_dev) + return false; + return dev == root_dprc_dev; +} + +/** * Add a newly discovered MC object device to be visible in Linux */ int fsl_mc_device_add(struct dprc_obj_desc *obj_desc, diff --git a/drivers/staging/fsl-mc/include/mc.h b/drivers/staging/fsl-mc/include/mc.h index a9a9d23..853cbf3 100644 --- a/drivers/staging/fsl-mc/include/mc.h +++ b/drivers/staging/fsl-mc/include/mc.h @@ -207,6 +207,8 @@ int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device *mc_dev); void fsl_mc_free_irqs(struct fsl_mc_device *mc_dev); +bool fsl_mc_is_root_dprc(struct device *dev); + extern struct bus_type fsl_mc_bus_type; #endif /* _FSL_MC_H_ */ -- cgit v1.1 From f93627146f0e371093966ed3d44c065aa077cfb1 Mon Sep 17 00:00:00 2001 From: Bharat Bhushan Date: Wed, 22 Jun 2016 16:40:48 -0500 Subject: staging: fsl-mc: fix asymmetry in destroy of mc_io An mc_io represents a mapped MC portal. Previously, an mc_io was created for the root dprc in fsl_mc_bus_probe() and for child dprcs in dprc_probe(). But the free of that data structure happened in the general bus remove callback. This asymmetry resulted in some bugs due to unwanted destroys of mc_io object in some scenarios (e.g. vfio). Fix this bug by making things symmetric-- mc_io created in fsl_mc_bus_probe() is freed in fsl_mc_bus_remove(). The mc_io created in dprc_probe() is freed in dprc_remove(). Signed-off-by: Bharat Bhushan [Stuart: added check for root dprc and reworded commit message] Signed-off-by: Stuart Yoder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-mc/bus/dprc-driver.c | 5 +++++ drivers/staging/fsl-mc/bus/mc-bus.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl-mc/bus/dprc-driver.c index f865d18..1a6bcc4 100644 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c @@ -801,6 +801,11 @@ static int dprc_remove(struct fsl_mc_device *mc_dev) dev_set_msi_domain(&mc_dev->dev, NULL); } + if (!fsl_mc_is_root_dprc(&mc_dev->dev)) { + fsl_destroy_mc_io(mc_dev->mc_io); + mc_dev->mc_io = NULL; + } + dev_info(&mc_dev->dev, "DPRC device unbound from driver"); return 0; } diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c index a49186e..db3afdb 100644 --- a/drivers/staging/fsl-mc/bus/mc-bus.c +++ b/drivers/staging/fsl-mc/bus/mc-bus.c @@ -579,10 +579,6 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev) if (strcmp(mc_dev->obj_desc.type, "dprc") == 0) { mc_bus = to_fsl_mc_bus(mc_dev); - if (mc_dev->mc_io) { - fsl_destroy_mc_io(mc_dev->mc_io); - mc_dev->mc_io = NULL; - } if (fsl_mc_is_root_dprc(&mc_dev->dev)) { if (atomic_read(&root_dprc_count) > 0) @@ -810,6 +806,10 @@ static int fsl_mc_bus_remove(struct platform_device *pdev) return -EINVAL; fsl_mc_device_remove(mc->root_mc_bus_dev); + + fsl_destroy_mc_io(mc->root_mc_bus_dev->mc_io); + mc->root_mc_bus_dev->mc_io = NULL; + dev_info(&pdev->dev, "Root MC bus device removed"); return 0; } -- cgit v1.1 From ae34934f9c8c504df6c0b412352e2850dcba495e Mon Sep 17 00:00:00 2001 From: Stuart Yoder Date: Wed, 22 Jun 2016 16:40:49 -0500 Subject: staging: fsl-mc: dprc: add missing irq free add missing free of the Linux irq when tearing down interrupts Signed-off-by: Stuart Yoder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-mc/bus/dprc-driver.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl-mc/bus/dprc-driver.c index 1a6bcc4..96ee1b7 100644 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c @@ -760,7 +760,12 @@ error_cleanup_msi_domain: */ static void dprc_teardown_irq(struct fsl_mc_device *mc_dev) { + struct fsl_mc_device_irq *irq = mc_dev->irqs[0]; + (void)disable_dprc_irq(mc_dev); + + devm_free_irq(&mc_dev->dev, irq->msi_desc->irq, &mc_dev->dev); + fsl_mc_free_irqs(mc_dev); } -- cgit v1.1 From a137fc805838a444fa934bfd918eba30396f933c Mon Sep 17 00:00:00 2001 From: Stuart Yoder Date: Wed, 22 Jun 2016 16:40:50 -0500 Subject: staging: fsl-mc: dprc: fix ordering problem freeing resources in remove of dprc When unbinding a dprc from the dprc driver the cleanup of the resource pools must happen after irq pool cleanup is done. Signed-off-by: Stuart Yoder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-mc/bus/dprc-driver.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl-mc/bus/dprc-driver.c index 96ee1b7..d2a71f1 100644 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c @@ -796,16 +796,18 @@ static int dprc_remove(struct fsl_mc_device *mc_dev) dprc_teardown_irq(mc_dev); device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove); - dprc_cleanup_all_resource_pools(mc_dev); - error = dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle); - if (error < 0) - dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error); if (dev_get_msi_domain(&mc_dev->dev)) { fsl_mc_cleanup_irq_pool(mc_bus); dev_set_msi_domain(&mc_dev->dev, NULL); } + dprc_cleanup_all_resource_pools(mc_dev); + + error = dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle); + if (error < 0) + dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error); + if (!fsl_mc_is_root_dprc(&mc_dev->dev)) { fsl_destroy_mc_io(mc_dev->mc_io); mc_dev->mc_io = NULL; -- cgit v1.1 From adf72b5ba372ca9006f8cdcf9c0b902579f7da9f Mon Sep 17 00:00:00 2001 From: Stuart Yoder Date: Wed, 22 Jun 2016 16:40:51 -0500 Subject: staging: fsl-mc: properly set hwirq in msi set_desc For an MSI domain the hwirq is an arbitrary but unique id to identify an interrupt. Previously the hwirq was set to the MSI index of the interrupt, but that only works if there is one DPRC. Additional DPRCs require an expanded namespace. Use both the ICID (which is unique per DPRC) and the MSI index to compose a hwirq value. Signed-off-by: Stuart Yoder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-mc/bus/mc-msi.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/staging/fsl-mc/bus/mc-msi.c b/drivers/staging/fsl-mc/bus/mc-msi.c index e202b2b..c7be156 100644 --- a/drivers/staging/fsl-mc/bus/mc-msi.c +++ b/drivers/staging/fsl-mc/bus/mc-msi.c @@ -20,11 +20,26 @@ #include "../include/mc-sys.h" #include "dprc-cmd.h" +/* + * Generate a unique ID identifying the interrupt (only used within the MSI + * irqdomain. Combine the icid with the interrupt index. + */ +static irq_hw_number_t fsl_mc_domain_calc_hwirq(struct fsl_mc_device *dev, + struct msi_desc *desc) +{ + /* + * Make the base hwirq value for ICID*10000 so it is readable + * as a decimal value in /proc/interrupts. + */ + return (irq_hw_number_t)(desc->fsl_mc.msi_index + (dev->icid * 10000)); +} + static void fsl_mc_msi_set_desc(msi_alloc_info_t *arg, struct msi_desc *desc) { arg->desc = desc; - arg->hwirq = (irq_hw_number_t)desc->fsl_mc.msi_index; + arg->hwirq = fsl_mc_domain_calc_hwirq(to_fsl_mc_device(desc->dev), + desc); } static void fsl_mc_msi_update_dom_ops(struct msi_domain_info *info) -- cgit v1.1 From 9989b59961a8ad55d92df4588b556f0c6c838ec7 Mon Sep 17 00:00:00 2001 From: Ioana Radulescu Date: Wed, 22 Jun 2016 16:40:52 -0500 Subject: staging: fsl-mc: convert mc command build/parse to use C structs The layer abstracting the building of commands and extracting responses is currently based on macros that shift and mask the command fields and requires exposing offset/size values as macro parameters and makes the code harder to read. For clarity and maintainability, instead use an implementation based on mapping the MC command definitions to C structures. These structures contain the hardware command fields (which are naturally-aligned) and individual fields are little-endian ordering (the byte ordering of the hardware). As such, there is no need to perform the conversion between core and hardware (LE) endianness in mc_send_command(), but instead each individual field in a command will be converted separately if needed by the function building the command or extracting the response. This patch does not introduce functional changes, both the hardware ABIs and the APIs exposed for the DPAA2 objects remain the same. Signed-off-by: Ioana Radulescu Signed-off-by: Stuart Yoder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-mc/bus/dpbp.c | 132 ++++-- drivers/staging/fsl-mc/bus/dpmcp-cmd.h | 86 +++- drivers/staging/fsl-mc/bus/dpmcp.c | 89 ++-- drivers/staging/fsl-mc/bus/dpmng-cmd.h | 12 +- drivers/staging/fsl-mc/bus/dpmng.c | 14 +- drivers/staging/fsl-mc/bus/dprc-cmd.h | 379 +++++++++++++++- drivers/staging/fsl-mc/bus/dprc.c | 715 ++++++++++-------------------- drivers/staging/fsl-mc/bus/mc-sys.c | 46 +- drivers/staging/fsl-mc/include/dpbp-cmd.h | 125 +++++- drivers/staging/fsl-mc/include/mc-cmd.h | 91 ++-- 10 files changed, 1056 insertions(+), 633 deletions(-) diff --git a/drivers/staging/fsl-mc/bus/dpbp.c b/drivers/staging/fsl-mc/bus/dpbp.c index c31fe1b..fe271fb 100644 --- a/drivers/staging/fsl-mc/bus/dpbp.c +++ b/drivers/staging/fsl-mc/bus/dpbp.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2014 Freescale Semiconductor Inc. +/* Copyright 2013-2016 Freescale Semiconductor Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -57,12 +57,14 @@ int dpbp_open(struct fsl_mc_io *mc_io, u16 *token) { struct mc_command cmd = { 0 }; + struct dpbp_cmd_open *cmd_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_OPEN, cmd_flags, 0); - cmd.params[0] |= mc_enc(0, 32, dpbp_id); + cmd_params = (struct dpbp_cmd_open *)cmd.params; + cmd_params->dpbp_id = cpu_to_le32(dpbp_id); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -70,7 +72,7 @@ int dpbp_open(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd); return err; } @@ -143,7 +145,7 @@ int dpbp_create(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd); return 0; } @@ -231,6 +233,7 @@ int dpbp_is_enabled(struct fsl_mc_io *mc_io, int *en) { struct mc_command cmd = { 0 }; + struct dpbp_rsp_is_enabled *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_IS_ENABLED, cmd_flags, @@ -242,7 +245,8 @@ int dpbp_is_enabled(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *en = (int)mc_dec(cmd.params[0], 0, 1); + rsp_params = (struct dpbp_rsp_is_enabled *)cmd.params; + *en = rsp_params->enabled & DPBP_ENABLE; return 0; } @@ -286,14 +290,16 @@ int dpbp_set_irq(struct fsl_mc_io *mc_io, struct dpbp_irq_cfg *irq_cfg) { struct mc_command cmd = { 0 }; + struct dpbp_cmd_set_irq *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_IRQ, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 8, irq_index); - cmd.params[0] |= mc_enc(32, 32, irq_cfg->val); - cmd.params[1] |= mc_enc(0, 64, irq_cfg->addr); - cmd.params[2] |= mc_enc(0, 32, irq_cfg->irq_num); + cmd_params = (struct dpbp_cmd_set_irq *)cmd.params; + cmd_params->irq_index = irq_index; + cmd_params->irq_val = cpu_to_le32(irq_cfg->val); + cmd_params->irq_addr = cpu_to_le64(irq_cfg->addr); + cmd_params->irq_num = cpu_to_le32(irq_cfg->irq_num); /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -319,12 +325,15 @@ int dpbp_get_irq(struct fsl_mc_io *mc_io, struct dpbp_irq_cfg *irq_cfg) { struct mc_command cmd = { 0 }; + struct dpbp_cmd_get_irq *cmd_params; + struct dpbp_rsp_get_irq *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ, cmd_flags, token); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dpbp_cmd_get_irq *)cmd.params; + cmd_params->irq_index = irq_index; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -332,10 +341,12 @@ int dpbp_get_irq(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - irq_cfg->val = (u32)mc_dec(cmd.params[0], 0, 32); - irq_cfg->addr = (u64)mc_dec(cmd.params[1], 0, 64); - irq_cfg->irq_num = (int)mc_dec(cmd.params[2], 0, 32); - *type = (int)mc_dec(cmd.params[2], 32, 32); + rsp_params = (struct dpbp_rsp_get_irq *)cmd.params; + irq_cfg->val = le32_to_cpu(rsp_params->irq_val); + irq_cfg->addr = le64_to_cpu(rsp_params->irq_addr); + irq_cfg->irq_num = le32_to_cpu(rsp_params->irq_num); + *type = le32_to_cpu(rsp_params->type); + return 0; } @@ -361,12 +372,14 @@ int dpbp_set_irq_enable(struct fsl_mc_io *mc_io, u8 en) { struct mc_command cmd = { 0 }; + struct dpbp_cmd_set_irq_enable *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_IRQ_ENABLE, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 8, en); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dpbp_cmd_set_irq_enable *)cmd.params; + cmd_params->enable = en & DPBP_ENABLE; + cmd_params->irq_index = irq_index; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -389,12 +402,15 @@ int dpbp_get_irq_enable(struct fsl_mc_io *mc_io, u8 *en) { struct mc_command cmd = { 0 }; + struct dpbp_cmd_get_irq_enable *cmd_params; + struct dpbp_rsp_get_irq_enable *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_ENABLE, cmd_flags, token); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dpbp_cmd_get_irq_enable *)cmd.params; + cmd_params->irq_index = irq_index; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -402,7 +418,8 @@ int dpbp_get_irq_enable(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *en = (u8)mc_dec(cmd.params[0], 0, 8); + rsp_params = (struct dpbp_rsp_get_irq_enable *)cmd.params; + *en = rsp_params->enabled & DPBP_ENABLE; return 0; } @@ -429,12 +446,14 @@ int dpbp_set_irq_mask(struct fsl_mc_io *mc_io, u32 mask) { struct mc_command cmd = { 0 }; + struct dpbp_cmd_set_irq_mask *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_IRQ_MASK, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, mask); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dpbp_cmd_set_irq_mask *)cmd.params; + cmd_params->mask = cpu_to_le32(mask); + cmd_params->irq_index = irq_index; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -460,12 +479,15 @@ int dpbp_get_irq_mask(struct fsl_mc_io *mc_io, u32 *mask) { struct mc_command cmd = { 0 }; + struct dpbp_cmd_get_irq_mask *cmd_params; + struct dpbp_rsp_get_irq_mask *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_MASK, cmd_flags, token); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dpbp_cmd_get_irq_mask *)cmd.params; + cmd_params->irq_index = irq_index; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -473,7 +495,9 @@ int dpbp_get_irq_mask(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *mask = (u32)mc_dec(cmd.params[0], 0, 32); + rsp_params = (struct dpbp_rsp_get_irq_mask *)cmd.params; + *mask = le32_to_cpu(rsp_params->mask); + return 0; } @@ -497,13 +521,16 @@ int dpbp_get_irq_status(struct fsl_mc_io *mc_io, u32 *status) { struct mc_command cmd = { 0 }; + struct dpbp_cmd_get_irq_status *cmd_params; + struct dpbp_rsp_get_irq_status *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_STATUS, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, *status); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dpbp_cmd_get_irq_status *)cmd.params; + cmd_params->status = cpu_to_le32(*status); + cmd_params->irq_index = irq_index; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -511,7 +538,9 @@ int dpbp_get_irq_status(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *status = (u32)mc_dec(cmd.params[0], 0, 32); + rsp_params = (struct dpbp_rsp_get_irq_status *)cmd.params; + *status = le32_to_cpu(rsp_params->status); + return 0; } @@ -535,12 +564,14 @@ int dpbp_clear_irq_status(struct fsl_mc_io *mc_io, u32 status) { struct mc_command cmd = { 0 }; + struct dpbp_cmd_clear_irq_status *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_CLEAR_IRQ_STATUS, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, status); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dpbp_cmd_clear_irq_status *)cmd.params; + cmd_params->status = cpu_to_le32(status); + cmd_params->irq_index = irq_index; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -562,6 +593,7 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io, struct dpbp_attr *attr) { struct mc_command cmd = { 0 }; + struct dpbp_rsp_get_attributes *rsp_params; int err; /* prepare command */ @@ -574,10 +606,12 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - attr->bpid = (u16)mc_dec(cmd.params[0], 16, 16); - attr->id = (int)mc_dec(cmd.params[0], 32, 32); - attr->version.major = (u16)mc_dec(cmd.params[1], 0, 16); - attr->version.minor = (u16)mc_dec(cmd.params[1], 16, 16); + rsp_params = (struct dpbp_rsp_get_attributes *)cmd.params; + attr->bpid = le16_to_cpu(rsp_params->bpid); + attr->id = le32_to_cpu(rsp_params->id); + attr->version.major = le16_to_cpu(rsp_params->version_major); + attr->version.minor = le16_to_cpu(rsp_params->version_minor); + return 0; } EXPORT_SYMBOL(dpbp_get_attributes); @@ -597,19 +631,19 @@ int dpbp_set_notifications(struct fsl_mc_io *mc_io, struct dpbp_notification_cfg *cfg) { struct mc_command cmd = { 0 }; + struct dpbp_cmd_set_notifications *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_NOTIFICATIONS, - cmd_flags, - token); - - cmd.params[0] |= mc_enc(0, 32, cfg->depletion_entry); - cmd.params[0] |= mc_enc(32, 32, cfg->depletion_exit); - cmd.params[1] |= mc_enc(0, 32, cfg->surplus_entry); - cmd.params[1] |= mc_enc(32, 32, cfg->surplus_exit); - cmd.params[2] |= mc_enc(0, 16, cfg->options); - cmd.params[3] |= mc_enc(0, 64, cfg->message_ctx); - cmd.params[4] |= mc_enc(0, 64, cfg->message_iova); + cmd_flags, token); + cmd_params = (struct dpbp_cmd_set_notifications *)cmd.params; + cmd_params->depletion_entry = cpu_to_le32(cfg->depletion_entry); + cmd_params->depletion_exit = cpu_to_le32(cfg->depletion_exit); + cmd_params->surplus_entry = cpu_to_le32(cfg->surplus_entry); + cmd_params->surplus_exit = cpu_to_le32(cfg->surplus_exit); + cmd_params->options = cpu_to_le16(cfg->options); + cmd_params->message_ctx = cpu_to_le64(cfg->message_ctx); + cmd_params->message_iova = cpu_to_le64(cfg->message_iova); /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -630,6 +664,7 @@ int dpbp_get_notifications(struct fsl_mc_io *mc_io, struct dpbp_notification_cfg *cfg) { struct mc_command cmd = { 0 }; + struct dpbp_rsp_get_notifications *rsp_params; int err; /* prepare command */ @@ -643,13 +678,14 @@ int dpbp_get_notifications(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - cfg->depletion_entry = (u32)mc_dec(cmd.params[0], 0, 32); - cfg->depletion_exit = (u32)mc_dec(cmd.params[0], 32, 32); - cfg->surplus_entry = (u32)mc_dec(cmd.params[1], 0, 32); - cfg->surplus_exit = (u32)mc_dec(cmd.params[1], 32, 32); - cfg->options = (u16)mc_dec(cmd.params[2], 0, 16); - cfg->message_ctx = (u64)mc_dec(cmd.params[3], 0, 64); - cfg->message_iova = (u64)mc_dec(cmd.params[4], 0, 64); + rsp_params = (struct dpbp_rsp_get_notifications *)cmd.params; + cfg->depletion_entry = le32_to_cpu(rsp_params->depletion_entry); + cfg->depletion_exit = le32_to_cpu(rsp_params->depletion_exit); + cfg->surplus_entry = le32_to_cpu(rsp_params->surplus_entry); + cfg->surplus_exit = le32_to_cpu(rsp_params->surplus_exit); + cfg->options = le16_to_cpu(rsp_params->options); + cfg->message_ctx = le64_to_cpu(rsp_params->message_ctx); + cfg->message_iova = le64_to_cpu(rsp_params->message_iova); return 0; } diff --git a/drivers/staging/fsl-mc/bus/dpmcp-cmd.h b/drivers/staging/fsl-mc/bus/dpmcp-cmd.h index c9b52dd..d098a6d 100644 --- a/drivers/staging/fsl-mc/bus/dpmcp-cmd.h +++ b/drivers/staging/fsl-mc/bus/dpmcp-cmd.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2015 Freescale Semiconductor Inc. +/* Copyright 2013-2016 Freescale Semiconductor Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -53,4 +53,88 @@ #define DPMCP_CMDID_GET_IRQ_MASK 0x015 #define DPMCP_CMDID_GET_IRQ_STATUS 0x016 +struct dpmcp_cmd_open { + __le32 dpmcp_id; +}; + +struct dpmcp_cmd_create { + __le32 portal_id; +}; + +struct dpmcp_cmd_set_irq { + /* cmd word 0 */ + u8 irq_index; + u8 pad[3]; + __le32 irq_val; + /* cmd word 1 */ + __le64 irq_addr; + /* cmd word 2 */ + __le32 irq_num; +}; + +struct dpmcp_cmd_get_irq { + __le32 pad; + u8 irq_index; +}; + +struct dpmcp_rsp_get_irq { + /* cmd word 0 */ + __le32 irq_val; + __le32 pad; + /* cmd word 1 */ + __le64 irq_paddr; + /* cmd word 2 */ + __le32 irq_num; + __le32 type; +}; + +#define DPMCP_ENABLE 0x1 + +struct dpmcp_cmd_set_irq_enable { + u8 enable; + u8 pad[3]; + u8 irq_index; +}; + +struct dpmcp_cmd_get_irq_enable { + __le32 pad; + u8 irq_index; +}; + +struct dpmcp_rsp_get_irq_enable { + u8 enabled; +}; + +struct dpmcp_cmd_set_irq_mask { + __le32 mask; + u8 irq_index; +}; + +struct dpmcp_cmd_get_irq_mask { + __le32 pad; + u8 irq_index; +}; + +struct dpmcp_rsp_get_irq_mask { + __le32 mask; +}; + +struct dpmcp_cmd_get_irq_status { + __le32 status; + u8 irq_index; +}; + +struct dpmcp_rsp_get_irq_status { + __le32 status; +}; + +struct dpmcp_rsp_get_attributes { + /* response word 0 */ + __le32 pad; + __le32 id; + /* response word 1 */ + __le16 version_major; + __le16 version_minor; +}; + #endif /* _FSL_DPMCP_CMD_H */ diff --git a/drivers/staging/fsl-mc/bus/dpmcp.c b/drivers/staging/fsl-mc/bus/dpmcp.c index fd6dd4e..0644017 100644 --- a/drivers/staging/fsl-mc/bus/dpmcp.c +++ b/drivers/staging/fsl-mc/bus/dpmcp.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2015 Freescale Semiconductor Inc. +/* Copyright 2013-2016 Freescale Semiconductor Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -57,12 +57,14 @@ int dpmcp_open(struct fsl_mc_io *mc_io, u16 *token) { struct mc_command cmd = { 0 }; + struct dpmcp_cmd_open *cmd_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPMCP_CMDID_OPEN, cmd_flags, 0); - cmd.params[0] |= mc_enc(0, 32, dpmcp_id); + cmd_params = (struct dpmcp_cmd_open *)cmd.params; + cmd_params->dpmcp_id = cpu_to_le32(dpmcp_id); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -70,7 +72,7 @@ int dpmcp_open(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd); return err; } @@ -127,12 +129,15 @@ int dpmcp_create(struct fsl_mc_io *mc_io, u16 *token) { struct mc_command cmd = { 0 }; + struct dpmcp_cmd_create *cmd_params; + int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CREATE, cmd_flags, 0); - cmd.params[0] |= mc_enc(0, 32, cfg->portal_id); + cmd_params = (struct dpmcp_cmd_create *)cmd.params; + cmd_params->portal_id = cpu_to_le32(cfg->portal_id); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -140,7 +145,7 @@ int dpmcp_create(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd); return 0; } @@ -206,14 +211,16 @@ int dpmcp_set_irq(struct fsl_mc_io *mc_io, struct dpmcp_irq_cfg *irq_cfg) { struct mc_command cmd = { 0 }; + struct dpmcp_cmd_set_irq *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPMCP_CMDID_SET_IRQ, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 8, irq_index); - cmd.params[0] |= mc_enc(32, 32, irq_cfg->val); - cmd.params[1] |= mc_enc(0, 64, irq_cfg->paddr); - cmd.params[2] |= mc_enc(0, 32, irq_cfg->irq_num); + cmd_params = (struct dpmcp_cmd_set_irq *)cmd.params; + cmd_params->irq_index = irq_index; + cmd_params->irq_val = cpu_to_le32(irq_cfg->val); + cmd_params->irq_addr = cpu_to_le64(irq_cfg->paddr); + cmd_params->irq_num = cpu_to_le32(irq_cfg->irq_num); /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -239,12 +246,15 @@ int dpmcp_get_irq(struct fsl_mc_io *mc_io, struct dpmcp_irq_cfg *irq_cfg) { struct mc_command cmd = { 0 }; + struct dpmcp_cmd_get_irq *cmd_params; + struct dpmcp_rsp_get_irq *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ, cmd_flags, token); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dpmcp_cmd_get_irq *)cmd.params; + cmd_params->irq_index = irq_index; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -252,10 +262,11 @@ int dpmcp_get_irq(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - irq_cfg->val = (u32)mc_dec(cmd.params[0], 0, 32); - irq_cfg->paddr = (u64)mc_dec(cmd.params[1], 0, 64); - irq_cfg->irq_num = (int)mc_dec(cmd.params[2], 0, 32); - *type = (int)mc_dec(cmd.params[2], 32, 32); + rsp_params = (struct dpmcp_rsp_get_irq *)cmd.params; + irq_cfg->val = le32_to_cpu(rsp_params->irq_val); + irq_cfg->paddr = le64_to_cpu(rsp_params->irq_paddr); + irq_cfg->irq_num = le32_to_cpu(rsp_params->irq_num); + *type = le32_to_cpu(rsp_params->type); return 0; } @@ -281,12 +292,14 @@ int dpmcp_set_irq_enable(struct fsl_mc_io *mc_io, u8 en) { struct mc_command cmd = { 0 }; + struct dpmcp_cmd_set_irq_enable *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPMCP_CMDID_SET_IRQ_ENABLE, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 8, en); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dpmcp_cmd_set_irq_enable *)cmd.params; + cmd_params->enable = en & DPMCP_ENABLE; + cmd_params->irq_index = irq_index; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -309,12 +322,15 @@ int dpmcp_get_irq_enable(struct fsl_mc_io *mc_io, u8 *en) { struct mc_command cmd = { 0 }; + struct dpmcp_cmd_get_irq_enable *cmd_params; + struct dpmcp_rsp_get_irq_enable *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ_ENABLE, cmd_flags, token); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dpmcp_cmd_get_irq_enable *)cmd.params; + cmd_params->irq_index = irq_index; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -322,7 +338,8 @@ int dpmcp_get_irq_enable(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *en = (u8)mc_dec(cmd.params[0], 0, 8); + rsp_params = (struct dpmcp_rsp_get_irq_enable *)cmd.params; + *en = rsp_params->enabled & DPMCP_ENABLE; return 0; } @@ -349,12 +366,15 @@ int dpmcp_set_irq_mask(struct fsl_mc_io *mc_io, u32 mask) { struct mc_command cmd = { 0 }; + struct dpmcp_cmd_set_irq_mask *cmd_params; + /* prepare command */ cmd.header = mc_encode_cmd_header(DPMCP_CMDID_SET_IRQ_MASK, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, mask); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dpmcp_cmd_set_irq_mask *)cmd.params; + cmd_params->mask = cpu_to_le32(mask); + cmd_params->irq_index = irq_index; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -380,12 +400,16 @@ int dpmcp_get_irq_mask(struct fsl_mc_io *mc_io, u32 *mask) { struct mc_command cmd = { 0 }; + struct dpmcp_cmd_get_irq_mask *cmd_params; + struct dpmcp_rsp_get_irq_mask *rsp_params; + int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ_MASK, cmd_flags, token); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dpmcp_cmd_get_irq_mask *)cmd.params; + cmd_params->irq_index = irq_index; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -393,7 +417,9 @@ int dpmcp_get_irq_mask(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *mask = (u32)mc_dec(cmd.params[0], 0, 32); + rsp_params = (struct dpmcp_rsp_get_irq_mask *)cmd.params; + *mask = le32_to_cpu(rsp_params->mask); + return 0; } @@ -417,12 +443,16 @@ int dpmcp_get_irq_status(struct fsl_mc_io *mc_io, u32 *status) { struct mc_command cmd = { 0 }; + struct dpmcp_cmd_get_irq_status *cmd_params; + struct dpmcp_rsp_get_irq_status *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ_STATUS, cmd_flags, token); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dpmcp_cmd_get_irq_status *)cmd.params; + cmd_params->status = cpu_to_le32(*status); + cmd_params->irq_index = irq_index; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -430,7 +460,9 @@ int dpmcp_get_irq_status(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *status = (u32)mc_dec(cmd.params[0], 0, 32); + rsp_params = (struct dpmcp_rsp_get_irq_status *)cmd.params; + *status = le32_to_cpu(rsp_params->status); + return 0; } @@ -450,6 +482,7 @@ int dpmcp_get_attributes(struct fsl_mc_io *mc_io, struct dpmcp_attr *attr) { struct mc_command cmd = { 0 }; + struct dpmcp_rsp_get_attributes *rsp_params; int err; /* prepare command */ @@ -462,8 +495,10 @@ int dpmcp_get_attributes(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - attr->id = (int)mc_dec(cmd.params[0], 32, 32); - attr->version.major = (u16)mc_dec(cmd.params[1], 0, 16); - attr->version.minor = (u16)mc_dec(cmd.params[1], 16, 16); + rsp_params = (struct dpmcp_rsp_get_attributes *)cmd.params; + attr->id = le32_to_cpu(rsp_params->id); + attr->version.major = le16_to_cpu(rsp_params->version_major); + attr->version.minor = le16_to_cpu(rsp_params->version_minor); + return 0; } diff --git a/drivers/staging/fsl-mc/bus/dpmng-cmd.h b/drivers/staging/fsl-mc/bus/dpmng-cmd.h index ba8cfa9..779bf9c 100644 --- a/drivers/staging/fsl-mc/bus/dpmng-cmd.h +++ b/drivers/staging/fsl-mc/bus/dpmng-cmd.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2014 Freescale Semiconductor Inc. +/* Copyright 2013-2016 Freescale Semiconductor Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -44,4 +44,14 @@ #define DPMNG_CMDID_GET_CONT_ID 0x830 #define DPMNG_CMDID_GET_VERSION 0x831 +struct dpmng_rsp_get_container_id { + __le32 container_id; +}; + +struct dpmng_rsp_get_version { + __le32 revision; + __le32 version_major; + __le32 version_minor; +}; + #endif /* __FSL_DPMNG_CMD_H */ diff --git a/drivers/staging/fsl-mc/bus/dpmng.c b/drivers/staging/fsl-mc/bus/dpmng.c index a31fa9b..660bbe7 100644 --- a/drivers/staging/fsl-mc/bus/dpmng.c +++ b/drivers/staging/fsl-mc/bus/dpmng.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2014 Freescale Semiconductor Inc. +/* Copyright 2013-2016 Freescale Semiconductor Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -48,6 +48,7 @@ int mc_get_version(struct fsl_mc_io *mc_io, struct mc_version *mc_ver_info) { struct mc_command cmd = { 0 }; + struct dpmng_rsp_get_version *rsp_params; int err; /* prepare command */ @@ -61,9 +62,10 @@ int mc_get_version(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - mc_ver_info->revision = mc_dec(cmd.params[0], 0, 32); - mc_ver_info->major = mc_dec(cmd.params[0], 32, 32); - mc_ver_info->minor = mc_dec(cmd.params[1], 0, 32); + rsp_params = (struct dpmng_rsp_get_version *)cmd.params; + mc_ver_info->revision = le32_to_cpu(rsp_params->revision); + mc_ver_info->major = le32_to_cpu(rsp_params->version_major); + mc_ver_info->minor = le32_to_cpu(rsp_params->version_minor); return 0; } @@ -82,6 +84,7 @@ int dpmng_get_container_id(struct fsl_mc_io *mc_io, int *container_id) { struct mc_command cmd = { 0 }; + struct dpmng_rsp_get_container_id *rsp_params; int err; /* prepare command */ @@ -95,7 +98,8 @@ int dpmng_get_container_id(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *container_id = mc_dec(cmd.params[0], 0, 32); + rsp_params = (struct dpmng_rsp_get_container_id *)cmd.params; + *container_id = le32_to_cpu(rsp_params->container_id); return 0; } diff --git a/drivers/staging/fsl-mc/bus/dprc-cmd.h b/drivers/staging/fsl-mc/bus/dprc-cmd.h index 9b854fa..bb127f4 100644 --- a/drivers/staging/fsl-mc/bus/dprc-cmd.h +++ b/drivers/staging/fsl-mc/bus/dprc-cmd.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2014 Freescale Semiconductor Inc. +/* Copyright 2013-2016 Freescale Semiconductor Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -84,4 +84,381 @@ #define DPRC_CMDID_GET_CONNECTION 0x16C +struct dprc_cmd_open { + __le32 container_id; +}; + +struct dprc_cmd_create_container { + /* cmd word 0 */ + __le32 options; + __le16 icid; + __le16 pad0; + /* cmd word 1 */ + __le32 pad1; + __le32 portal_id; + /* cmd words 2-3 */ + u8 label[16]; +}; + +struct dprc_rsp_create_container { + /* response word 0 */ + __le64 pad0; + /* response word 1 */ + __le32 child_container_id; + __le32 pad1; + /* response word 2 */ + __le64 child_portal_addr; +}; + +struct dprc_cmd_destroy_container { + __le32 child_container_id; +}; + +struct dprc_cmd_reset_container { + __le32 child_container_id; +}; + +struct dprc_cmd_set_irq { + /* cmd word 0 */ + __le32 irq_val; + u8 irq_index; + u8 pad[3]; + /* cmd word 1 */ + __le64 irq_addr; + /* cmd word 2 */ + __le32 irq_num; +}; + +struct dprc_cmd_get_irq { + __le32 pad; + u8 irq_index; +}; + +struct dprc_rsp_get_irq { + /* response word 0 */ + __le32 irq_val; + __le32 pad; + /* response word 1 */ + __le64 irq_addr; + /* response word 2 */ + __le32 irq_num; + __le32 type; +}; + +#define DPRC_ENABLE 0x1 + +struct dprc_cmd_set_irq_enable { + u8 enable; + u8 pad[3]; + u8 irq_index; +}; + +struct dprc_cmd_get_irq_enable { + __le32 pad; + u8 irq_index; +}; + +struct dprc_rsp_get_irq_enable { + u8 enabled; +}; + +struct dprc_cmd_set_irq_mask { + __le32 mask; + u8 irq_index; +}; + +struct dprc_cmd_get_irq_mask { + __le32 pad; + u8 irq_index; +}; + +struct dprc_rsp_get_irq_mask { + __le32 mask; +}; + +struct dprc_cmd_get_irq_status { + __le32 status; + u8 irq_index; +}; + +struct dprc_rsp_get_irq_status { + __le32 status; +}; + +struct dprc_cmd_clear_irq_status { + __le32 status; + u8 irq_index; +}; + +struct dprc_rsp_get_attributes { + /* response word 0 */ + __le32 container_id; + __le16 icid; + __le16 pad; + /* response word 1 */ + __le32 options; + __le32 portal_id; + /* response word 2 */ + __le16 version_major; + __le16 version_minor; +}; + +struct dprc_cmd_set_res_quota { + /* cmd word 0 */ + __le32 child_container_id; + __le16 quota; + __le16 pad; + /* cmd words 1-2 */ + u8 type[16]; +}; + +struct dprc_cmd_get_res_quota { + /* cmd word 0 */ + __le32 child_container_id; + __le32 pad; + /* cmd word 1-2 */ + u8 type[16]; +}; + +struct dprc_rsp_get_res_quota { + __le32 pad; + __le16 quota; +}; + +struct dprc_cmd_assign { + /* cmd word 0 */ + __le32 container_id; + __le32 options; + /* cmd word 1 */ + __le32 num; + __le32 id_base_align; + /* cmd word 2-3 */ + u8 type[16]; +}; + +struct dprc_cmd_unassign { + /* cmd word 0 */ + __le32 child_container_id; + __le32 options; + /* cmd word 1 */ + __le32 num; + __le32 id_base_align; + /* cmd word 2-3 */ + u8 type[16]; +}; + +struct dprc_rsp_get_pool_count { + __le32 pool_count; +}; + +struct dprc_cmd_get_pool { + __le32 pool_index; +}; + +struct dprc_rsp_get_pool { + /* response word 0 */ + __le64 pad; + /* response word 1-2 */ + u8 type[16]; +}; + +struct dprc_rsp_get_obj_count { + __le32 pad; + __le32 obj_count; +}; + +struct dprc_cmd_get_obj { + __le32 obj_index; +}; + +struct dprc_rsp_get_obj { + /* response word 0 */ + __le32 pad0; + __le32 id; + /* response word 1 */ + __le16 vendor; + u8 irq_count; + u8 region_count; + __le32 state; + /* response word 2 */ + __le16 version_major; + __le16 version_minor; + __le16 flags; + __le16 pad1; + /* response word 3-4 */ + u8 type[16]; + /* response word 5-6 */ + u8 label[16]; +}; + +struct dprc_cmd_get_obj_desc { + /* cmd word 0 */ + __le32 obj_id; + __le32 pad; + /* cmd word 1-2 */ + u8 type[16]; +}; + +struct dprc_rsp_get_obj_desc { + /* response word 0 */ + __le32 pad0; + __le32 id; + /* response word 1 */ + __le16 vendor; + u8 irq_count; + u8 region_count; + __le32 state; + /* response word 2 */ + __le16 version_major; + __le16 version_minor; + __le16 flags; + __le16 pad1; + /* response word 3-4 */ + u8 type[16]; + /* response word 5-6 */ + u8 label[16]; +}; + +struct dprc_cmd_get_res_count { + /* cmd word 0 */ + __le64 pad; + /* cmd word 1-2 */ + u8 type[16]; +}; + +struct dprc_rsp_get_res_count { + __le32 res_count; +}; + +struct dprc_cmd_get_res_ids { + /* cmd word 0 */ + u8 pad0[5]; + u8 iter_status; + __le16 pad1; + /* cmd word 1 */ + __le32 base_id; + __le32 last_id; + /* cmd word 2-3 */ + u8 type[16]; +}; + +struct dprc_rsp_get_res_ids { + /* response word 0 */ + u8 pad0[5]; + u8 iter_status; + __le16 pad1; + /* response word 1 */ + __le32 base_id; + __le32 last_id; +}; + +struct dprc_cmd_get_obj_region { + /* cmd word 0 */ + __le32 obj_id; + __le16 pad0; + u8 region_index; + u8 pad1; + /* cmd word 1-2 */ + __le64 pad2[2]; + /* cmd word 3-4 */ + u8 obj_type[16]; +}; + +struct dprc_rsp_get_obj_region { + /* response word 0 */ + __le64 pad; + /* response word 1 */ + __le64 base_addr; + /* response word 2 */ + __le32 size; +}; + +struct dprc_cmd_set_obj_label { + /* cmd word 0 */ + __le32 obj_id; + __le32 pad; + /* cmd word 1-2 */ + u8 label[16]; + /* cmd word 3-4 */ + u8 obj_type[16]; +}; + +struct dprc_cmd_set_obj_irq { + /* cmd word 0 */ + __le32 irq_val; + u8 irq_index; + u8 pad[3]; + /* cmd word 1 */ + __le64 irq_addr; + /* cmd word 2 */ + __le32 irq_num; + __le32 obj_id; + /* cmd word 3-4 */ + u8 obj_type[16]; +}; + +struct dprc_cmd_get_obj_irq { + /* cmd word 0 */ + __le32 obj_id; + u8 irq_index; + u8 pad[3]; + /* cmd word 1-2 */ + u8 obj_type[16]; +}; + +struct dprc_rsp_get_obj_irq { + /* response word 0 */ + __le32 irq_val; + __le32 pad; + /* response word 1 */ + __le64 irq_addr; + /* response word 2 */ + __le32 irq_num; + __le32 type; +}; + +struct dprc_cmd_connect { + /* cmd word 0 */ + __le32 ep1_id; + __le32 ep1_interface_id; + /* cmd word 1 */ + __le32 ep2_id; + __le32 ep2_interface_id; + /* cmd word 2-3 */ + u8 ep1_type[16]; + /* cmd word 4 */ + __le32 max_rate; + __le32 committed_rate; + /* cmd word 5-6 */ + u8 ep2_type[16]; +}; + +struct dprc_cmd_disconnect { + /* cmd word 0 */ + __le32 id; + __le32 interface_id; + /* cmd word 1-2 */ + u8 type[16]; +}; + +struct dprc_cmd_get_connection { + /* cmd word 0 */ + __le32 ep1_id; + __le32 ep1_interface_id; + /* cmd word 1-2 */ + u8 ep1_type[16]; +}; + +struct dprc_rsp_get_connection { + /* response word 0-2 */ + __le64 pad[3]; + /* response word 3 */ + __le32 ep2_id; + __le32 ep2_interface_id; + /* response word 4-5 */ + u8 ep2_type[16]; + /* response word 6 */ + __le32 state; +}; + #endif /* _FSL_DPRC_CMD_H */ diff --git a/drivers/staging/fsl-mc/bus/dprc.c b/drivers/staging/fsl-mc/bus/dprc.c index a2c4737..c260549 100644 --- a/drivers/staging/fsl-mc/bus/dprc.c +++ b/drivers/staging/fsl-mc/bus/dprc.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2014 Freescale Semiconductor Inc. +/* Copyright 2013-2016 Freescale Semiconductor Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -51,12 +51,14 @@ int dprc_open(struct fsl_mc_io *mc_io, u16 *token) { struct mc_command cmd = { 0 }; + struct dprc_cmd_open *cmd_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_OPEN, cmd_flags, 0); - cmd.params[0] |= mc_enc(0, 32, container_id); + cmd_params = (struct dprc_cmd_open *)cmd.params; + cmd_params->container_id = cpu_to_le32(container_id); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -64,7 +66,7 @@ int dprc_open(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *token = MC_CMD_HDR_READ_TOKEN(cmd.header); + *token = mc_cmd_hdr_read_token(&cmd); return 0; } @@ -115,28 +117,17 @@ int dprc_create_container(struct fsl_mc_io *mc_io, u64 *child_portal_offset) { struct mc_command cmd = { 0 }; + struct dprc_cmd_create_container *cmd_params; + struct dprc_rsp_create_container *rsp_params; int err; /* prepare command */ - cmd.params[0] |= mc_enc(32, 16, cfg->icid); - cmd.params[0] |= mc_enc(0, 32, cfg->options); - cmd.params[1] |= mc_enc(32, 32, cfg->portal_id); - cmd.params[2] |= mc_enc(0, 8, cfg->label[0]); - cmd.params[2] |= mc_enc(8, 8, cfg->label[1]); - cmd.params[2] |= mc_enc(16, 8, cfg->label[2]); - cmd.params[2] |= mc_enc(24, 8, cfg->label[3]); - cmd.params[2] |= mc_enc(32, 8, cfg->label[4]); - cmd.params[2] |= mc_enc(40, 8, cfg->label[5]); - cmd.params[2] |= mc_enc(48, 8, cfg->label[6]); - cmd.params[2] |= mc_enc(56, 8, cfg->label[7]); - cmd.params[3] |= mc_enc(0, 8, cfg->label[8]); - cmd.params[3] |= mc_enc(8, 8, cfg->label[9]); - cmd.params[3] |= mc_enc(16, 8, cfg->label[10]); - cmd.params[3] |= mc_enc(24, 8, cfg->label[11]); - cmd.params[3] |= mc_enc(32, 8, cfg->label[12]); - cmd.params[3] |= mc_enc(40, 8, cfg->label[13]); - cmd.params[3] |= mc_enc(48, 8, cfg->label[14]); - cmd.params[3] |= mc_enc(56, 8, cfg->label[15]); + cmd_params = (struct dprc_cmd_create_container *)cmd.params; + cmd_params->options = cpu_to_le32(cfg->options); + cmd_params->icid = cpu_to_le16(cfg->icid); + cmd_params->portal_id = cpu_to_le32(cfg->portal_id); + strncpy(cmd_params->label, cfg->label, 16); + cmd_params->label[15] = '\0'; cmd.header = mc_encode_cmd_header(DPRC_CMDID_CREATE_CONT, cmd_flags, token); @@ -147,8 +138,9 @@ int dprc_create_container(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *child_container_id = mc_dec(cmd.params[1], 0, 32); - *child_portal_offset = mc_dec(cmd.params[2], 0, 64); + rsp_params = (struct dprc_rsp_create_container *)cmd.params; + *child_container_id = le32_to_cpu(rsp_params->child_container_id); + *child_portal_offset = le64_to_cpu(rsp_params->child_portal_addr); return 0; } @@ -181,11 +173,13 @@ int dprc_destroy_container(struct fsl_mc_io *mc_io, int child_container_id) { struct mc_command cmd = { 0 }; + struct dprc_cmd_destroy_container *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_DESTROY_CONT, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, child_container_id); + cmd_params = (struct dprc_cmd_destroy_container *)cmd.params; + cmd_params->child_container_id = cpu_to_le32(child_container_id); /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -219,11 +213,13 @@ int dprc_reset_container(struct fsl_mc_io *mc_io, int child_container_id) { struct mc_command cmd = { 0 }; + struct dprc_cmd_reset_container *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_RESET_CONT, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, child_container_id); + cmd_params = (struct dprc_cmd_reset_container *)cmd.params; + cmd_params->child_container_id = cpu_to_le32(child_container_id); /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -249,13 +245,16 @@ int dprc_get_irq(struct fsl_mc_io *mc_io, struct dprc_irq_cfg *irq_cfg) { struct mc_command cmd = { 0 }; + struct dprc_cmd_get_irq *cmd_params; + struct dprc_rsp_get_irq *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ, cmd_flags, token); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dprc_cmd_get_irq *)cmd.params; + cmd_params->irq_index = irq_index; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -263,10 +262,11 @@ int dprc_get_irq(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - irq_cfg->val = mc_dec(cmd.params[0], 0, 32); - irq_cfg->paddr = mc_dec(cmd.params[1], 0, 64); - irq_cfg->irq_num = mc_dec(cmd.params[2], 0, 32); - *type = mc_dec(cmd.params[2], 32, 32); + rsp_params = (struct dprc_rsp_get_irq *)cmd.params; + irq_cfg->val = le32_to_cpu(rsp_params->irq_val); + irq_cfg->paddr = le64_to_cpu(rsp_params->irq_addr); + irq_cfg->irq_num = le32_to_cpu(rsp_params->irq_num); + *type = le32_to_cpu(rsp_params->type); return 0; } @@ -288,15 +288,17 @@ int dprc_set_irq(struct fsl_mc_io *mc_io, struct dprc_irq_cfg *irq_cfg) { struct mc_command cmd = { 0 }; + struct dprc_cmd_set_irq *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_IRQ, cmd_flags, token); - cmd.params[0] |= mc_enc(32, 8, irq_index); - cmd.params[0] |= mc_enc(0, 32, irq_cfg->val); - cmd.params[1] |= mc_enc(0, 64, irq_cfg->paddr); - cmd.params[2] |= mc_enc(0, 32, irq_cfg->irq_num); + cmd_params = (struct dprc_cmd_set_irq *)cmd.params; + cmd_params->irq_val = cpu_to_le32(irq_cfg->val); + cmd_params->irq_index = irq_index; + cmd_params->irq_addr = cpu_to_le64(irq_cfg->paddr); + cmd_params->irq_num = cpu_to_le32(irq_cfg->irq_num); /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -319,12 +321,15 @@ int dprc_get_irq_enable(struct fsl_mc_io *mc_io, u8 *en) { struct mc_command cmd = { 0 }; + struct dprc_cmd_get_irq_enable *cmd_params; + struct dprc_rsp_get_irq_enable *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_ENABLE, cmd_flags, token); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dprc_cmd_get_irq_enable *)cmd.params; + cmd_params->irq_index = irq_index; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -332,7 +337,8 @@ int dprc_get_irq_enable(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *en = mc_dec(cmd.params[0], 0, 8); + rsp_params = (struct dprc_rsp_get_irq_enable *)cmd.params; + *en = rsp_params->enabled & DPRC_ENABLE; return 0; } @@ -359,12 +365,14 @@ int dprc_set_irq_enable(struct fsl_mc_io *mc_io, u8 en) { struct mc_command cmd = { 0 }; + struct dprc_cmd_set_irq_enable *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_IRQ_ENABLE, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 8, en); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dprc_cmd_set_irq_enable *)cmd.params; + cmd_params->enable = en & DPRC_ENABLE; + cmd_params->irq_index = irq_index; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -390,12 +398,15 @@ int dprc_get_irq_mask(struct fsl_mc_io *mc_io, u32 *mask) { struct mc_command cmd = { 0 }; + struct dprc_cmd_get_irq_mask *cmd_params; + struct dprc_rsp_get_irq_mask *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_MASK, cmd_flags, token); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dprc_cmd_get_irq_mask *)cmd.params; + cmd_params->irq_index = irq_index; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -403,7 +414,8 @@ int dprc_get_irq_mask(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *mask = mc_dec(cmd.params[0], 0, 32); + rsp_params = (struct dprc_rsp_get_irq_mask *)cmd.params; + *mask = le32_to_cpu(rsp_params->mask); return 0; } @@ -431,12 +443,14 @@ int dprc_set_irq_mask(struct fsl_mc_io *mc_io, u32 mask) { struct mc_command cmd = { 0 }; + struct dprc_cmd_set_irq_mask *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_IRQ_MASK, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, mask); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dprc_cmd_set_irq_mask *)cmd.params; + cmd_params->mask = cpu_to_le32(mask); + cmd_params->irq_index = irq_index; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -461,13 +475,16 @@ int dprc_get_irq_status(struct fsl_mc_io *mc_io, u32 *status) { struct mc_command cmd = { 0 }; + struct dprc_cmd_get_irq_status *cmd_params; + struct dprc_rsp_get_irq_status *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_STATUS, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, *status); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dprc_cmd_get_irq_status *)cmd.params; + cmd_params->status = cpu_to_le32(*status); + cmd_params->irq_index = irq_index; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -475,7 +492,8 @@ int dprc_get_irq_status(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *status = mc_dec(cmd.params[0], 0, 32); + rsp_params = (struct dprc_rsp_get_irq_status *)cmd.params; + *status = le32_to_cpu(rsp_params->status); return 0; } @@ -499,12 +517,14 @@ int dprc_clear_irq_status(struct fsl_mc_io *mc_io, u32 status) { struct mc_command cmd = { 0 }; + struct dprc_cmd_clear_irq_status *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_CLEAR_IRQ_STATUS, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, status); - cmd.params[0] |= mc_enc(32, 8, irq_index); + cmd_params = (struct dprc_cmd_clear_irq_status *)cmd.params; + cmd_params->status = cpu_to_le32(status); + cmd_params->irq_index = irq_index; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -525,6 +545,7 @@ int dprc_get_attributes(struct fsl_mc_io *mc_io, struct dprc_attributes *attr) { struct mc_command cmd = { 0 }; + struct dprc_rsp_get_attributes *rsp_params; int err; /* prepare command */ @@ -538,12 +559,13 @@ int dprc_get_attributes(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - attr->container_id = mc_dec(cmd.params[0], 0, 32); - attr->icid = mc_dec(cmd.params[0], 32, 16); - attr->options = mc_dec(cmd.params[1], 0, 32); - attr->portal_id = mc_dec(cmd.params[1], 32, 32); - attr->version.major = mc_dec(cmd.params[2], 0, 16); - attr->version.minor = mc_dec(cmd.params[2], 16, 16); + rsp_params = (struct dprc_rsp_get_attributes *)cmd.params; + attr->container_id = le32_to_cpu(rsp_params->container_id); + attr->icid = le16_to_cpu(rsp_params->icid); + attr->options = le32_to_cpu(rsp_params->options); + attr->portal_id = le32_to_cpu(rsp_params->portal_id); + attr->version.major = le16_to_cpu(rsp_params->version_major); + attr->version.minor = le16_to_cpu(rsp_params->version_minor); return 0; } @@ -581,28 +603,16 @@ int dprc_set_res_quota(struct fsl_mc_io *mc_io, u16 quota) { struct mc_command cmd = { 0 }; + struct dprc_cmd_set_res_quota *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_RES_QUOTA, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, child_container_id); - cmd.params[0] |= mc_enc(32, 16, quota); - cmd.params[1] |= mc_enc(0, 8, type[0]); - cmd.params[1] |= mc_enc(8, 8, type[1]); - cmd.params[1] |= mc_enc(16, 8, type[2]); - cmd.params[1] |= mc_enc(24, 8, type[3]); - cmd.params[1] |= mc_enc(32, 8, type[4]); - cmd.params[1] |= mc_enc(40, 8, type[5]); - cmd.params[1] |= mc_enc(48, 8, type[6]); - cmd.params[1] |= mc_enc(56, 8, type[7]); - cmd.params[2] |= mc_enc(0, 8, type[8]); - cmd.params[2] |= mc_enc(8, 8, type[9]); - cmd.params[2] |= mc_enc(16, 8, type[10]); - cmd.params[2] |= mc_enc(24, 8, type[11]); - cmd.params[2] |= mc_enc(32, 8, type[12]); - cmd.params[2] |= mc_enc(40, 8, type[13]); - cmd.params[2] |= mc_enc(48, 8, type[14]); - cmd.params[2] |= mc_enc(56, 8, '\0'); + cmd_params = (struct dprc_cmd_set_res_quota *)cmd.params; + cmd_params->child_container_id = cpu_to_le32(child_container_id); + cmd_params->quota = cpu_to_le16(quota); + strncpy(cmd_params->type, type, 16); + cmd_params->type[15] = '\0'; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -631,28 +641,17 @@ int dprc_get_res_quota(struct fsl_mc_io *mc_io, u16 *quota) { struct mc_command cmd = { 0 }; + struct dprc_cmd_get_res_quota *cmd_params; + struct dprc_rsp_get_res_quota *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_QUOTA, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, child_container_id); - cmd.params[1] |= mc_enc(0, 8, type[0]); - cmd.params[1] |= mc_enc(8, 8, type[1]); - cmd.params[1] |= mc_enc(16, 8, type[2]); - cmd.params[1] |= mc_enc(24, 8, type[3]); - cmd.params[1] |= mc_enc(32, 8, type[4]); - cmd.params[1] |= mc_enc(40, 8, type[5]); - cmd.params[1] |= mc_enc(48, 8, type[6]); - cmd.params[1] |= mc_enc(56, 8, type[7]); - cmd.params[2] |= mc_enc(0, 8, type[8]); - cmd.params[2] |= mc_enc(8, 8, type[9]); - cmd.params[2] |= mc_enc(16, 8, type[10]); - cmd.params[2] |= mc_enc(24, 8, type[11]); - cmd.params[2] |= mc_enc(32, 8, type[12]); - cmd.params[2] |= mc_enc(40, 8, type[13]); - cmd.params[2] |= mc_enc(48, 8, type[14]); - cmd.params[2] |= mc_enc(56, 8, '\0'); + cmd_params = (struct dprc_cmd_get_res_quota *)cmd.params; + cmd_params->child_container_id = cpu_to_le32(child_container_id); + strncpy(cmd_params->type, type, 16); + cmd_params->type[15] = '\0'; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -660,7 +659,8 @@ int dprc_get_res_quota(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *quota = mc_dec(cmd.params[0], 32, 16); + rsp_params = (struct dprc_rsp_get_res_quota *)cmd.params; + *quota = le16_to_cpu(rsp_params->quota); return 0; } @@ -704,30 +704,18 @@ int dprc_assign(struct fsl_mc_io *mc_io, struct dprc_res_req *res_req) { struct mc_command cmd = { 0 }; + struct dprc_cmd_assign *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_ASSIGN, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, container_id); - cmd.params[0] |= mc_enc(32, 32, res_req->options); - cmd.params[1] |= mc_enc(0, 32, res_req->num); - cmd.params[1] |= mc_enc(32, 32, res_req->id_base_align); - cmd.params[2] |= mc_enc(0, 8, res_req->type[0]); - cmd.params[2] |= mc_enc(8, 8, res_req->type[1]); - cmd.params[2] |= mc_enc(16, 8, res_req->type[2]); - cmd.params[2] |= mc_enc(24, 8, res_req->type[3]); - cmd.params[2] |= mc_enc(32, 8, res_req->type[4]); - cmd.params[2] |= mc_enc(40, 8, res_req->type[5]); - cmd.params[2] |= mc_enc(48, 8, res_req->type[6]); - cmd.params[2] |= mc_enc(56, 8, res_req->type[7]); - cmd.params[3] |= mc_enc(0, 8, res_req->type[8]); - cmd.params[3] |= mc_enc(8, 8, res_req->type[9]); - cmd.params[3] |= mc_enc(16, 8, res_req->type[10]); - cmd.params[3] |= mc_enc(24, 8, res_req->type[11]); - cmd.params[3] |= mc_enc(32, 8, res_req->type[12]); - cmd.params[3] |= mc_enc(40, 8, res_req->type[13]); - cmd.params[3] |= mc_enc(48, 8, res_req->type[14]); - cmd.params[3] |= mc_enc(56, 8, res_req->type[15]); + cmd_params = (struct dprc_cmd_assign *)cmd.params; + cmd_params->container_id = cpu_to_le32(container_id); + cmd_params->options = cpu_to_le32(res_req->options); + cmd_params->num = cpu_to_le32(res_req->num); + cmd_params->id_base_align = cpu_to_le32(res_req->id_base_align); + strncpy(cmd_params->type, res_req->type, 16); + cmd_params->type[15] = '\0'; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -755,31 +743,19 @@ int dprc_unassign(struct fsl_mc_io *mc_io, struct dprc_res_req *res_req) { struct mc_command cmd = { 0 }; + struct dprc_cmd_unassign *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_UNASSIGN, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, child_container_id); - cmd.params[0] |= mc_enc(32, 32, res_req->options); - cmd.params[1] |= mc_enc(0, 32, res_req->num); - cmd.params[1] |= mc_enc(32, 32, res_req->id_base_align); - cmd.params[2] |= mc_enc(0, 8, res_req->type[0]); - cmd.params[2] |= mc_enc(8, 8, res_req->type[1]); - cmd.params[2] |= mc_enc(16, 8, res_req->type[2]); - cmd.params[2] |= mc_enc(24, 8, res_req->type[3]); - cmd.params[2] |= mc_enc(32, 8, res_req->type[4]); - cmd.params[2] |= mc_enc(40, 8, res_req->type[5]); - cmd.params[2] |= mc_enc(48, 8, res_req->type[6]); - cmd.params[2] |= mc_enc(56, 8, res_req->type[7]); - cmd.params[3] |= mc_enc(0, 8, res_req->type[8]); - cmd.params[3] |= mc_enc(8, 8, res_req->type[9]); - cmd.params[3] |= mc_enc(16, 8, res_req->type[10]); - cmd.params[3] |= mc_enc(24, 8, res_req->type[11]); - cmd.params[3] |= mc_enc(32, 8, res_req->type[12]); - cmd.params[3] |= mc_enc(40, 8, res_req->type[13]); - cmd.params[3] |= mc_enc(48, 8, res_req->type[14]); - cmd.params[3] |= mc_enc(56, 8, res_req->type[15]); + cmd_params = (struct dprc_cmd_unassign *)cmd.params; + cmd_params->child_container_id = cpu_to_le32(child_container_id); + cmd_params->options = cpu_to_le32(res_req->options); + cmd_params->num = cpu_to_le32(res_req->num); + cmd_params->id_base_align = cpu_to_le32(res_req->id_base_align); + strncpy(cmd_params->type, res_req->type, 16); + cmd_params->type[15] = '\0'; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -800,6 +776,7 @@ int dprc_get_pool_count(struct fsl_mc_io *mc_io, int *pool_count) { struct mc_command cmd = { 0 }; + struct dprc_rsp_get_pool_count *rsp_params; int err; /* prepare command */ @@ -812,7 +789,8 @@ int dprc_get_pool_count(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *pool_count = mc_dec(cmd.params[0], 0, 32); + rsp_params = (struct dprc_rsp_get_pool_count *)cmd.params; + *pool_count = le32_to_cpu(rsp_params->pool_count); return 0; } @@ -839,13 +817,16 @@ int dprc_get_pool(struct fsl_mc_io *mc_io, char *type) { struct mc_command cmd = { 0 }; + struct dprc_cmd_get_pool *cmd_params; + struct dprc_rsp_get_pool *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_POOL, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, pool_index); + cmd_params = (struct dprc_cmd_get_pool *)cmd.params; + cmd_params->pool_index = cpu_to_le32(pool_index); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -853,21 +834,8 @@ int dprc_get_pool(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - type[0] = mc_dec(cmd.params[1], 0, 8); - type[1] = mc_dec(cmd.params[1], 8, 8); - type[2] = mc_dec(cmd.params[1], 16, 8); - type[3] = mc_dec(cmd.params[1], 24, 8); - type[4] = mc_dec(cmd.params[1], 32, 8); - type[5] = mc_dec(cmd.params[1], 40, 8); - type[6] = mc_dec(cmd.params[1], 48, 8); - type[7] = mc_dec(cmd.params[1], 56, 8); - type[8] = mc_dec(cmd.params[2], 0, 8); - type[9] = mc_dec(cmd.params[2], 8, 8); - type[10] = mc_dec(cmd.params[2], 16, 8); - type[11] = mc_dec(cmd.params[2], 24, 8); - type[12] = mc_dec(cmd.params[2], 32, 8); - type[13] = mc_dec(cmd.params[2], 40, 8); - type[14] = mc_dec(cmd.params[2], 48, 8); + rsp_params = (struct dprc_rsp_get_pool *)cmd.params; + strncpy(type, rsp_params->type, 16); type[15] = '\0'; return 0; @@ -888,6 +856,7 @@ int dprc_get_obj_count(struct fsl_mc_io *mc_io, int *obj_count) { struct mc_command cmd = { 0 }; + struct dprc_rsp_get_obj_count *rsp_params; int err; /* prepare command */ @@ -900,7 +869,8 @@ int dprc_get_obj_count(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *obj_count = mc_dec(cmd.params[0], 32, 32); + rsp_params = (struct dprc_rsp_get_obj_count *)cmd.params; + *obj_count = le32_to_cpu(rsp_params->obj_count); return 0; } @@ -928,13 +898,16 @@ int dprc_get_obj(struct fsl_mc_io *mc_io, struct dprc_obj_desc *obj_desc) { struct mc_command cmd = { 0 }; + struct dprc_cmd_get_obj *cmd_params; + struct dprc_rsp_get_obj *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, obj_index); + cmd_params = (struct dprc_cmd_get_obj *)cmd.params; + cmd_params->obj_index = cpu_to_le32(obj_index); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -942,45 +915,18 @@ int dprc_get_obj(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - obj_desc->id = mc_dec(cmd.params[0], 32, 32); - obj_desc->vendor = mc_dec(cmd.params[1], 0, 16); - obj_desc->irq_count = mc_dec(cmd.params[1], 16, 8); - obj_desc->region_count = mc_dec(cmd.params[1], 24, 8); - obj_desc->state = mc_dec(cmd.params[1], 32, 32); - obj_desc->ver_major = mc_dec(cmd.params[2], 0, 16); - obj_desc->ver_minor = mc_dec(cmd.params[2], 16, 16); - obj_desc->flags = mc_dec(cmd.params[2], 32, 16); - obj_desc->type[0] = mc_dec(cmd.params[3], 0, 8); - obj_desc->type[1] = mc_dec(cmd.params[3], 8, 8); - obj_desc->type[2] = mc_dec(cmd.params[3], 16, 8); - obj_desc->type[3] = mc_dec(cmd.params[3], 24, 8); - obj_desc->type[4] = mc_dec(cmd.params[3], 32, 8); - obj_desc->type[5] = mc_dec(cmd.params[3], 40, 8); - obj_desc->type[6] = mc_dec(cmd.params[3], 48, 8); - obj_desc->type[7] = mc_dec(cmd.params[3], 56, 8); - obj_desc->type[8] = mc_dec(cmd.params[4], 0, 8); - obj_desc->type[9] = mc_dec(cmd.params[4], 8, 8); - obj_desc->type[10] = mc_dec(cmd.params[4], 16, 8); - obj_desc->type[11] = mc_dec(cmd.params[4], 24, 8); - obj_desc->type[12] = mc_dec(cmd.params[4], 32, 8); - obj_desc->type[13] = mc_dec(cmd.params[4], 40, 8); - obj_desc->type[14] = mc_dec(cmd.params[4], 48, 8); + rsp_params = (struct dprc_rsp_get_obj *)cmd.params; + obj_desc->id = le32_to_cpu(rsp_params->id); + obj_desc->vendor = le16_to_cpu(rsp_params->vendor); + obj_desc->irq_count = rsp_params->irq_count; + obj_desc->region_count = rsp_params->region_count; + obj_desc->state = le32_to_cpu(rsp_params->state); + obj_desc->ver_major = le16_to_cpu(rsp_params->version_major); + obj_desc->ver_minor = le16_to_cpu(rsp_params->version_minor); + obj_desc->flags = le16_to_cpu(rsp_params->flags); + strncpy(obj_desc->type, rsp_params->type, 16); obj_desc->type[15] = '\0'; - obj_desc->label[0] = mc_dec(cmd.params[5], 0, 8); - obj_desc->label[1] = mc_dec(cmd.params[5], 8, 8); - obj_desc->label[2] = mc_dec(cmd.params[5], 16, 8); - obj_desc->label[3] = mc_dec(cmd.params[5], 24, 8); - obj_desc->label[4] = mc_dec(cmd.params[5], 32, 8); - obj_desc->label[5] = mc_dec(cmd.params[5], 40, 8); - obj_desc->label[6] = mc_dec(cmd.params[5], 48, 8); - obj_desc->label[7] = mc_dec(cmd.params[5], 56, 8); - obj_desc->label[8] = mc_dec(cmd.params[6], 0, 8); - obj_desc->label[9] = mc_dec(cmd.params[6], 8, 8); - obj_desc->label[10] = mc_dec(cmd.params[6], 16, 8); - obj_desc->label[11] = mc_dec(cmd.params[6], 24, 8); - obj_desc->label[12] = mc_dec(cmd.params[6], 32, 8); - obj_desc->label[13] = mc_dec(cmd.params[6], 40, 8); - obj_desc->label[14] = mc_dec(cmd.params[6], 48, 8); + strncpy(obj_desc->label, rsp_params->label, 16); obj_desc->label[15] = '\0'; return 0; } @@ -1007,29 +953,18 @@ int dprc_get_obj_desc(struct fsl_mc_io *mc_io, struct dprc_obj_desc *obj_desc) { struct mc_command cmd = { 0 }; + struct dprc_cmd_get_obj_desc *cmd_params; + struct dprc_rsp_get_obj_desc *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_DESC, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, obj_id); - cmd.params[1] |= mc_enc(0, 8, obj_type[0]); - cmd.params[1] |= mc_enc(8, 8, obj_type[1]); - cmd.params[1] |= mc_enc(16, 8, obj_type[2]); - cmd.params[1] |= mc_enc(24, 8, obj_type[3]); - cmd.params[1] |= mc_enc(32, 8, obj_type[4]); - cmd.params[1] |= mc_enc(40, 8, obj_type[5]); - cmd.params[1] |= mc_enc(48, 8, obj_type[6]); - cmd.params[1] |= mc_enc(56, 8, obj_type[7]); - cmd.params[2] |= mc_enc(0, 8, obj_type[8]); - cmd.params[2] |= mc_enc(8, 8, obj_type[9]); - cmd.params[2] |= mc_enc(16, 8, obj_type[10]); - cmd.params[2] |= mc_enc(24, 8, obj_type[11]); - cmd.params[2] |= mc_enc(32, 8, obj_type[12]); - cmd.params[2] |= mc_enc(40, 8, obj_type[13]); - cmd.params[2] |= mc_enc(48, 8, obj_type[14]); - cmd.params[2] |= mc_enc(56, 8, obj_type[15]); + cmd_params = (struct dprc_cmd_get_obj_desc *)cmd.params; + cmd_params->obj_id = cpu_to_le32(obj_id); + strncpy(cmd_params->type, obj_type, 16); + cmd_params->type[15] = '\0'; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -1037,46 +972,19 @@ int dprc_get_obj_desc(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - obj_desc->id = (int)mc_dec(cmd.params[0], 32, 32); - obj_desc->vendor = (u16)mc_dec(cmd.params[1], 0, 16); - obj_desc->vendor = (u8)mc_dec(cmd.params[1], 16, 8); - obj_desc->region_count = (u8)mc_dec(cmd.params[1], 24, 8); - obj_desc->state = (u32)mc_dec(cmd.params[1], 32, 32); - obj_desc->ver_major = (u16)mc_dec(cmd.params[2], 0, 16); - obj_desc->ver_minor = (u16)mc_dec(cmd.params[2], 16, 16); - obj_desc->flags = mc_dec(cmd.params[2], 32, 16); - obj_desc->type[0] = (char)mc_dec(cmd.params[3], 0, 8); - obj_desc->type[1] = (char)mc_dec(cmd.params[3], 8, 8); - obj_desc->type[2] = (char)mc_dec(cmd.params[3], 16, 8); - obj_desc->type[3] = (char)mc_dec(cmd.params[3], 24, 8); - obj_desc->type[4] = (char)mc_dec(cmd.params[3], 32, 8); - obj_desc->type[5] = (char)mc_dec(cmd.params[3], 40, 8); - obj_desc->type[6] = (char)mc_dec(cmd.params[3], 48, 8); - obj_desc->type[7] = (char)mc_dec(cmd.params[3], 56, 8); - obj_desc->type[8] = (char)mc_dec(cmd.params[4], 0, 8); - obj_desc->type[9] = (char)mc_dec(cmd.params[4], 8, 8); - obj_desc->type[10] = (char)mc_dec(cmd.params[4], 16, 8); - obj_desc->type[11] = (char)mc_dec(cmd.params[4], 24, 8); - obj_desc->type[12] = (char)mc_dec(cmd.params[4], 32, 8); - obj_desc->type[13] = (char)mc_dec(cmd.params[4], 40, 8); - obj_desc->type[14] = (char)mc_dec(cmd.params[4], 48, 8); - obj_desc->type[15] = (char)mc_dec(cmd.params[4], 56, 8); - obj_desc->label[0] = (char)mc_dec(cmd.params[5], 0, 8); - obj_desc->label[1] = (char)mc_dec(cmd.params[5], 8, 8); - obj_desc->label[2] = (char)mc_dec(cmd.params[5], 16, 8); - obj_desc->label[3] = (char)mc_dec(cmd.params[5], 24, 8); - obj_desc->label[4] = (char)mc_dec(cmd.params[5], 32, 8); - obj_desc->label[5] = (char)mc_dec(cmd.params[5], 40, 8); - obj_desc->label[6] = (char)mc_dec(cmd.params[5], 48, 8); - obj_desc->label[7] = (char)mc_dec(cmd.params[5], 56, 8); - obj_desc->label[8] = (char)mc_dec(cmd.params[6], 0, 8); - obj_desc->label[9] = (char)mc_dec(cmd.params[6], 8, 8); - obj_desc->label[10] = (char)mc_dec(cmd.params[6], 16, 8); - obj_desc->label[11] = (char)mc_dec(cmd.params[6], 24, 8); - obj_desc->label[12] = (char)mc_dec(cmd.params[6], 32, 8); - obj_desc->label[13] = (char)mc_dec(cmd.params[6], 40, 8); - obj_desc->label[14] = (char)mc_dec(cmd.params[6], 48, 8); - obj_desc->label[15] = (char)mc_dec(cmd.params[6], 56, 8); + rsp_params = (struct dprc_rsp_get_obj_desc *)cmd.params; + obj_desc->id = le32_to_cpu(rsp_params->id); + obj_desc->vendor = le16_to_cpu(rsp_params->vendor); + obj_desc->irq_count = rsp_params->irq_count; + obj_desc->region_count = rsp_params->region_count; + obj_desc->state = le32_to_cpu(rsp_params->state); + obj_desc->ver_major = le16_to_cpu(rsp_params->version_major); + obj_desc->ver_minor = le16_to_cpu(rsp_params->version_minor); + obj_desc->flags = le16_to_cpu(rsp_params->flags); + strncpy(obj_desc->type, rsp_params->type, 16); + obj_desc->type[15] = '\0'; + strncpy(obj_desc->label, rsp_params->label, 16); + obj_desc->label[15] = '\0'; return 0; } @@ -1103,32 +1011,20 @@ int dprc_set_obj_irq(struct fsl_mc_io *mc_io, struct dprc_irq_cfg *irq_cfg) { struct mc_command cmd = { 0 }; + struct dprc_cmd_set_obj_irq *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_OBJ_IRQ, cmd_flags, token); - cmd.params[0] |= mc_enc(32, 8, irq_index); - cmd.params[0] |= mc_enc(0, 32, irq_cfg->val); - cmd.params[1] |= mc_enc(0, 64, irq_cfg->paddr); - cmd.params[2] |= mc_enc(0, 32, irq_cfg->irq_num); - cmd.params[2] |= mc_enc(32, 32, obj_id); - cmd.params[3] |= mc_enc(0, 8, obj_type[0]); - cmd.params[3] |= mc_enc(8, 8, obj_type[1]); - cmd.params[3] |= mc_enc(16, 8, obj_type[2]); - cmd.params[3] |= mc_enc(24, 8, obj_type[3]); - cmd.params[3] |= mc_enc(32, 8, obj_type[4]); - cmd.params[3] |= mc_enc(40, 8, obj_type[5]); - cmd.params[3] |= mc_enc(48, 8, obj_type[6]); - cmd.params[3] |= mc_enc(56, 8, obj_type[7]); - cmd.params[4] |= mc_enc(0, 8, obj_type[8]); - cmd.params[4] |= mc_enc(8, 8, obj_type[9]); - cmd.params[4] |= mc_enc(16, 8, obj_type[10]); - cmd.params[4] |= mc_enc(24, 8, obj_type[11]); - cmd.params[4] |= mc_enc(32, 8, obj_type[12]); - cmd.params[4] |= mc_enc(40, 8, obj_type[13]); - cmd.params[4] |= mc_enc(48, 8, obj_type[14]); - cmd.params[4] |= mc_enc(56, 8, obj_type[15]); + cmd_params = (struct dprc_cmd_set_obj_irq *)cmd.params; + cmd_params->irq_val = cpu_to_le32(irq_cfg->val); + cmd_params->irq_index = irq_index; + cmd_params->irq_addr = cpu_to_le64(irq_cfg->paddr); + cmd_params->irq_num = cpu_to_le32(irq_cfg->irq_num); + cmd_params->obj_id = cpu_to_le32(obj_id); + strncpy(cmd_params->obj_type, obj_type, 16); + cmd_params->obj_type[15] = '\0'; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -1159,30 +1055,19 @@ int dprc_get_obj_irq(struct fsl_mc_io *mc_io, struct dprc_irq_cfg *irq_cfg) { struct mc_command cmd = { 0 }; + struct dprc_cmd_get_obj_irq *cmd_params; + struct dprc_rsp_get_obj_irq *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_IRQ, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, obj_id); - cmd.params[0] |= mc_enc(32, 8, irq_index); - cmd.params[1] |= mc_enc(0, 8, obj_type[0]); - cmd.params[1] |= mc_enc(8, 8, obj_type[1]); - cmd.params[1] |= mc_enc(16, 8, obj_type[2]); - cmd.params[1] |= mc_enc(24, 8, obj_type[3]); - cmd.params[1] |= mc_enc(32, 8, obj_type[4]); - cmd.params[1] |= mc_enc(40, 8, obj_type[5]); - cmd.params[1] |= mc_enc(48, 8, obj_type[6]); - cmd.params[1] |= mc_enc(56, 8, obj_type[7]); - cmd.params[2] |= mc_enc(0, 8, obj_type[8]); - cmd.params[2] |= mc_enc(8, 8, obj_type[9]); - cmd.params[2] |= mc_enc(16, 8, obj_type[10]); - cmd.params[2] |= mc_enc(24, 8, obj_type[11]); - cmd.params[2] |= mc_enc(32, 8, obj_type[12]); - cmd.params[2] |= mc_enc(40, 8, obj_type[13]); - cmd.params[2] |= mc_enc(48, 8, obj_type[14]); - cmd.params[2] |= mc_enc(56, 8, obj_type[15]); + cmd_params = (struct dprc_cmd_get_obj_irq *)cmd.params; + cmd_params->obj_id = cpu_to_le32(obj_id); + cmd_params->irq_index = irq_index; + strncpy(cmd_params->obj_type, obj_type, 16); + cmd_params->obj_type[15] = '\0'; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -1190,10 +1075,11 @@ int dprc_get_obj_irq(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - irq_cfg->val = (u32)mc_dec(cmd.params[0], 0, 32); - irq_cfg->paddr = (u64)mc_dec(cmd.params[1], 0, 64); - irq_cfg->irq_num = (int)mc_dec(cmd.params[2], 0, 32); - *type = (int)mc_dec(cmd.params[2], 32, 32); + rsp_params = (struct dprc_rsp_get_obj_irq *)cmd.params; + irq_cfg->val = le32_to_cpu(rsp_params->irq_val); + irq_cfg->paddr = le64_to_cpu(rsp_params->irq_addr); + irq_cfg->irq_num = le32_to_cpu(rsp_params->irq_num); + *type = le32_to_cpu(rsp_params->type); return 0; } @@ -1218,29 +1104,16 @@ int dprc_get_res_count(struct fsl_mc_io *mc_io, int *res_count) { struct mc_command cmd = { 0 }; + struct dprc_cmd_get_res_count *cmd_params; + struct dprc_rsp_get_res_count *rsp_params; int err; - *res_count = 0; - /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_COUNT, cmd_flags, token); - cmd.params[1] |= mc_enc(0, 8, type[0]); - cmd.params[1] |= mc_enc(8, 8, type[1]); - cmd.params[1] |= mc_enc(16, 8, type[2]); - cmd.params[1] |= mc_enc(24, 8, type[3]); - cmd.params[1] |= mc_enc(32, 8, type[4]); - cmd.params[1] |= mc_enc(40, 8, type[5]); - cmd.params[1] |= mc_enc(48, 8, type[6]); - cmd.params[1] |= mc_enc(56, 8, type[7]); - cmd.params[2] |= mc_enc(0, 8, type[8]); - cmd.params[2] |= mc_enc(8, 8, type[9]); - cmd.params[2] |= mc_enc(16, 8, type[10]); - cmd.params[2] |= mc_enc(24, 8, type[11]); - cmd.params[2] |= mc_enc(32, 8, type[12]); - cmd.params[2] |= mc_enc(40, 8, type[13]); - cmd.params[2] |= mc_enc(48, 8, type[14]); - cmd.params[2] |= mc_enc(56, 8, '\0'); + cmd_params = (struct dprc_cmd_get_res_count *)cmd.params; + strncpy(cmd_params->type, type, 16); + cmd_params->type[15] = '\0'; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -1248,7 +1121,8 @@ int dprc_get_res_count(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *res_count = mc_dec(cmd.params[0], 0, 32); + rsp_params = (struct dprc_rsp_get_res_count *)cmd.params; + *res_count = le32_to_cpu(rsp_params->res_count); return 0; } @@ -1271,30 +1145,19 @@ int dprc_get_res_ids(struct fsl_mc_io *mc_io, struct dprc_res_ids_range_desc *range_desc) { struct mc_command cmd = { 0 }; + struct dprc_cmd_get_res_ids *cmd_params; + struct dprc_rsp_get_res_ids *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_IDS, cmd_flags, token); - cmd.params[0] |= mc_enc(42, 7, range_desc->iter_status); - cmd.params[1] |= mc_enc(0, 32, range_desc->base_id); - cmd.params[1] |= mc_enc(32, 32, range_desc->last_id); - cmd.params[2] |= mc_enc(0, 8, type[0]); - cmd.params[2] |= mc_enc(8, 8, type[1]); - cmd.params[2] |= mc_enc(16, 8, type[2]); - cmd.params[2] |= mc_enc(24, 8, type[3]); - cmd.params[2] |= mc_enc(32, 8, type[4]); - cmd.params[2] |= mc_enc(40, 8, type[5]); - cmd.params[2] |= mc_enc(48, 8, type[6]); - cmd.params[2] |= mc_enc(56, 8, type[7]); - cmd.params[3] |= mc_enc(0, 8, type[8]); - cmd.params[3] |= mc_enc(8, 8, type[9]); - cmd.params[3] |= mc_enc(16, 8, type[10]); - cmd.params[3] |= mc_enc(24, 8, type[11]); - cmd.params[3] |= mc_enc(32, 8, type[12]); - cmd.params[3] |= mc_enc(40, 8, type[13]); - cmd.params[3] |= mc_enc(48, 8, type[14]); - cmd.params[3] |= mc_enc(56, 8, '\0'); + cmd_params = (struct dprc_cmd_get_res_ids *)cmd.params; + cmd_params->iter_status = range_desc->iter_status; + cmd_params->base_id = cpu_to_le32(range_desc->base_id); + cmd_params->last_id = cpu_to_le32(range_desc->last_id); + strncpy(cmd_params->type, type, 16); + cmd_params->type[15] = '\0'; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -1302,9 +1165,10 @@ int dprc_get_res_ids(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - range_desc->iter_status = mc_dec(cmd.params[0], 42, 7); - range_desc->base_id = mc_dec(cmd.params[1], 0, 32); - range_desc->last_id = mc_dec(cmd.params[1], 32, 32); + rsp_params = (struct dprc_rsp_get_res_ids *)cmd.params; + range_desc->iter_status = rsp_params->iter_status; + range_desc->base_id = le32_to_cpu(rsp_params->base_id); + range_desc->last_id = le32_to_cpu(rsp_params->last_id); return 0; } @@ -1331,29 +1195,18 @@ int dprc_get_obj_region(struct fsl_mc_io *mc_io, struct dprc_region_desc *region_desc) { struct mc_command cmd = { 0 }; + struct dprc_cmd_get_obj_region *cmd_params; + struct dprc_rsp_get_obj_region *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_REG, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, obj_id); - cmd.params[0] |= mc_enc(48, 8, region_index); - cmd.params[3] |= mc_enc(0, 8, obj_type[0]); - cmd.params[3] |= mc_enc(8, 8, obj_type[1]); - cmd.params[3] |= mc_enc(16, 8, obj_type[2]); - cmd.params[3] |= mc_enc(24, 8, obj_type[3]); - cmd.params[3] |= mc_enc(32, 8, obj_type[4]); - cmd.params[3] |= mc_enc(40, 8, obj_type[5]); - cmd.params[3] |= mc_enc(48, 8, obj_type[6]); - cmd.params[3] |= mc_enc(56, 8, obj_type[7]); - cmd.params[4] |= mc_enc(0, 8, obj_type[8]); - cmd.params[4] |= mc_enc(8, 8, obj_type[9]); - cmd.params[4] |= mc_enc(16, 8, obj_type[10]); - cmd.params[4] |= mc_enc(24, 8, obj_type[11]); - cmd.params[4] |= mc_enc(32, 8, obj_type[12]); - cmd.params[4] |= mc_enc(40, 8, obj_type[13]); - cmd.params[4] |= mc_enc(48, 8, obj_type[14]); - cmd.params[4] |= mc_enc(56, 8, '\0'); + cmd_params = (struct dprc_cmd_get_obj_region *)cmd.params; + cmd_params->obj_id = cpu_to_le32(obj_id); + cmd_params->region_index = region_index; + strncpy(cmd_params->obj_type, obj_type, 16); + cmd_params->obj_type[15] = '\0'; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -1361,8 +1214,9 @@ int dprc_get_obj_region(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - region_desc->base_offset = mc_dec(cmd.params[1], 0, 64); - region_desc->size = mc_dec(cmd.params[2], 0, 32); + rsp_params = (struct dprc_rsp_get_obj_region *)cmd.params; + region_desc->base_offset = le64_to_cpu(rsp_params->base_addr); + region_desc->size = le32_to_cpu(rsp_params->size); return 0; } @@ -1387,45 +1241,18 @@ int dprc_set_obj_label(struct fsl_mc_io *mc_io, char *label) { struct mc_command cmd = { 0 }; + struct dprc_cmd_set_obj_label *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_OBJ_LABEL, cmd_flags, token); - - cmd.params[0] |= mc_enc(0, 32, obj_id); - cmd.params[1] |= mc_enc(0, 8, label[0]); - cmd.params[1] |= mc_enc(8, 8, label[1]); - cmd.params[1] |= mc_enc(16, 8, label[2]); - cmd.params[1] |= mc_enc(24, 8, label[3]); - cmd.params[1] |= mc_enc(32, 8, label[4]); - cmd.params[1] |= mc_enc(40, 8, label[5]); - cmd.params[1] |= mc_enc(48, 8, label[6]); - cmd.params[1] |= mc_enc(56, 8, label[7]); - cmd.params[2] |= mc_enc(0, 8, label[8]); - cmd.params[2] |= mc_enc(8, 8, label[9]); - cmd.params[2] |= mc_enc(16, 8, label[10]); - cmd.params[2] |= mc_enc(24, 8, label[11]); - cmd.params[2] |= mc_enc(32, 8, label[12]); - cmd.params[2] |= mc_enc(40, 8, label[13]); - cmd.params[2] |= mc_enc(48, 8, label[14]); - cmd.params[2] |= mc_enc(56, 8, label[15]); - cmd.params[3] |= mc_enc(0, 8, obj_type[0]); - cmd.params[3] |= mc_enc(8, 8, obj_type[1]); - cmd.params[3] |= mc_enc(16, 8, obj_type[2]); - cmd.params[3] |= mc_enc(24, 8, obj_type[3]); - cmd.params[3] |= mc_enc(32, 8, obj_type[4]); - cmd.params[3] |= mc_enc(40, 8, obj_type[5]); - cmd.params[3] |= mc_enc(48, 8, obj_type[6]); - cmd.params[3] |= mc_enc(56, 8, obj_type[7]); - cmd.params[4] |= mc_enc(0, 8, obj_type[8]); - cmd.params[4] |= mc_enc(8, 8, obj_type[9]); - cmd.params[4] |= mc_enc(16, 8, obj_type[10]); - cmd.params[4] |= mc_enc(24, 8, obj_type[11]); - cmd.params[4] |= mc_enc(32, 8, obj_type[12]); - cmd.params[4] |= mc_enc(40, 8, obj_type[13]); - cmd.params[4] |= mc_enc(48, 8, obj_type[14]); - cmd.params[4] |= mc_enc(56, 8, obj_type[15]); + cmd_params = (struct dprc_cmd_set_obj_label *)cmd.params; + cmd_params->obj_id = cpu_to_le32(obj_id); + strncpy(cmd_params->label, label, 16); + cmd_params->label[15] = '\0'; + strncpy(cmd_params->obj_type, obj_type, 16); + cmd_params->obj_type[15] = '\0'; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -1453,49 +1280,23 @@ int dprc_connect(struct fsl_mc_io *mc_io, const struct dprc_connection_cfg *cfg) { struct mc_command cmd = { 0 }; + struct dprc_cmd_connect *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_CONNECT, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, endpoint1->id); - cmd.params[0] |= mc_enc(32, 32, endpoint1->if_id); - cmd.params[1] |= mc_enc(0, 32, endpoint2->id); - cmd.params[1] |= mc_enc(32, 32, endpoint2->if_id); - cmd.params[2] |= mc_enc(0, 8, endpoint1->type[0]); - cmd.params[2] |= mc_enc(8, 8, endpoint1->type[1]); - cmd.params[2] |= mc_enc(16, 8, endpoint1->type[2]); - cmd.params[2] |= mc_enc(24, 8, endpoint1->type[3]); - cmd.params[2] |= mc_enc(32, 8, endpoint1->type[4]); - cmd.params[2] |= mc_enc(40, 8, endpoint1->type[5]); - cmd.params[2] |= mc_enc(48, 8, endpoint1->type[6]); - cmd.params[2] |= mc_enc(56, 8, endpoint1->type[7]); - cmd.params[3] |= mc_enc(0, 8, endpoint1->type[8]); - cmd.params[3] |= mc_enc(8, 8, endpoint1->type[9]); - cmd.params[3] |= mc_enc(16, 8, endpoint1->type[10]); - cmd.params[3] |= mc_enc(24, 8, endpoint1->type[11]); - cmd.params[3] |= mc_enc(32, 8, endpoint1->type[12]); - cmd.params[3] |= mc_enc(40, 8, endpoint1->type[13]); - cmd.params[3] |= mc_enc(48, 8, endpoint1->type[14]); - cmd.params[3] |= mc_enc(56, 8, endpoint1->type[15]); - cmd.params[4] |= mc_enc(0, 32, cfg->max_rate); - cmd.params[4] |= mc_enc(32, 32, cfg->committed_rate); - cmd.params[5] |= mc_enc(0, 8, endpoint2->type[0]); - cmd.params[5] |= mc_enc(8, 8, endpoint2->type[1]); - cmd.params[5] |= mc_enc(16, 8, endpoint2->type[2]); - cmd.params[5] |= mc_enc(24, 8, endpoint2->type[3]); - cmd.params[5] |= mc_enc(32, 8, endpoint2->type[4]); - cmd.params[5] |= mc_enc(40, 8, endpoint2->type[5]); - cmd.params[5] |= mc_enc(48, 8, endpoint2->type[6]); - cmd.params[5] |= mc_enc(56, 8, endpoint2->type[7]); - cmd.params[6] |= mc_enc(0, 8, endpoint2->type[8]); - cmd.params[6] |= mc_enc(8, 8, endpoint2->type[9]); - cmd.params[6] |= mc_enc(16, 8, endpoint2->type[10]); - cmd.params[6] |= mc_enc(24, 8, endpoint2->type[11]); - cmd.params[6] |= mc_enc(32, 8, endpoint2->type[12]); - cmd.params[6] |= mc_enc(40, 8, endpoint2->type[13]); - cmd.params[6] |= mc_enc(48, 8, endpoint2->type[14]); - cmd.params[6] |= mc_enc(56, 8, endpoint2->type[15]); + cmd_params = (struct dprc_cmd_connect *)cmd.params; + cmd_params->ep1_id = cpu_to_le32(endpoint1->id); + cmd_params->ep1_interface_id = cpu_to_le32(endpoint1->if_id); + cmd_params->ep2_id = cpu_to_le32(endpoint2->id); + cmd_params->ep2_interface_id = cpu_to_le32(endpoint2->if_id); + strncpy(cmd_params->ep1_type, endpoint1->type, 16); + cmd_params->ep1_type[15] = '\0'; + cmd_params->max_rate = cpu_to_le32(cfg->max_rate); + cmd_params->committed_rate = cpu_to_le32(cfg->committed_rate); + strncpy(cmd_params->ep2_type, endpoint2->type, 16); + cmd_params->ep2_type[15] = '\0'; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -1516,29 +1317,17 @@ int dprc_disconnect(struct fsl_mc_io *mc_io, const struct dprc_endpoint *endpoint) { struct mc_command cmd = { 0 }; + struct dprc_cmd_disconnect *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_DISCONNECT, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, endpoint->id); - cmd.params[0] |= mc_enc(32, 32, endpoint->if_id); - cmd.params[1] |= mc_enc(0, 8, endpoint->type[0]); - cmd.params[1] |= mc_enc(8, 8, endpoint->type[1]); - cmd.params[1] |= mc_enc(16, 8, endpoint->type[2]); - cmd.params[1] |= mc_enc(24, 8, endpoint->type[3]); - cmd.params[1] |= mc_enc(32, 8, endpoint->type[4]); - cmd.params[1] |= mc_enc(40, 8, endpoint->type[5]); - cmd.params[1] |= mc_enc(48, 8, endpoint->type[6]); - cmd.params[1] |= mc_enc(56, 8, endpoint->type[7]); - cmd.params[2] |= mc_enc(0, 8, endpoint->type[8]); - cmd.params[2] |= mc_enc(8, 8, endpoint->type[9]); - cmd.params[2] |= mc_enc(16, 8, endpoint->type[10]); - cmd.params[2] |= mc_enc(24, 8, endpoint->type[11]); - cmd.params[2] |= mc_enc(32, 8, endpoint->type[12]); - cmd.params[2] |= mc_enc(40, 8, endpoint->type[13]); - cmd.params[2] |= mc_enc(48, 8, endpoint->type[14]); - cmd.params[2] |= mc_enc(56, 8, endpoint->type[15]); + cmd_params = (struct dprc_cmd_disconnect *)cmd.params; + cmd_params->id = cpu_to_le32(endpoint->id); + cmd_params->interface_id = cpu_to_le32(endpoint->if_id); + strncpy(cmd_params->type, endpoint->type, 16); + cmd_params->type[15] = '\0'; /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -1567,30 +1356,19 @@ int dprc_get_connection(struct fsl_mc_io *mc_io, int *state) { struct mc_command cmd = { 0 }; + struct dprc_cmd_get_connection *cmd_params; + struct dprc_rsp_get_connection *rsp_params; int err; /* prepare command */ cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_CONNECTION, cmd_flags, token); - cmd.params[0] |= mc_enc(0, 32, endpoint1->id); - cmd.params[0] |= mc_enc(32, 32, endpoint1->if_id); - cmd.params[1] |= mc_enc(0, 8, endpoint1->type[0]); - cmd.params[1] |= mc_enc(8, 8, endpoint1->type[1]); - cmd.params[1] |= mc_enc(16, 8, endpoint1->type[2]); - cmd.params[1] |= mc_enc(24, 8, endpoint1->type[3]); - cmd.params[1] |= mc_enc(32, 8, endpoint1->type[4]); - cmd.params[1] |= mc_enc(40, 8, endpoint1->type[5]); - cmd.params[1] |= mc_enc(48, 8, endpoint1->type[6]); - cmd.params[1] |= mc_enc(56, 8, endpoint1->type[7]); - cmd.params[2] |= mc_enc(0, 8, endpoint1->type[8]); - cmd.params[2] |= mc_enc(8, 8, endpoint1->type[9]); - cmd.params[2] |= mc_enc(16, 8, endpoint1->type[10]); - cmd.params[2] |= mc_enc(24, 8, endpoint1->type[11]); - cmd.params[2] |= mc_enc(32, 8, endpoint1->type[12]); - cmd.params[2] |= mc_enc(40, 8, endpoint1->type[13]); - cmd.params[2] |= mc_enc(48, 8, endpoint1->type[14]); - cmd.params[2] |= mc_enc(56, 8, endpoint1->type[15]); + cmd_params = (struct dprc_cmd_get_connection *)cmd.params; + cmd_params->ep1_id = cpu_to_le32(endpoint1->id); + cmd_params->ep1_interface_id = cpu_to_le32(endpoint1->if_id); + strncpy(cmd_params->ep1_type, endpoint1->type, 16); + cmd_params->ep1_type[15] = '\0'; /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -1598,25 +1376,12 @@ int dprc_get_connection(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - endpoint2->id = mc_dec(cmd.params[3], 0, 32); - endpoint2->if_id = mc_dec(cmd.params[3], 32, 32); - endpoint2->type[0] = mc_dec(cmd.params[4], 0, 8); - endpoint2->type[1] = mc_dec(cmd.params[4], 8, 8); - endpoint2->type[2] = mc_dec(cmd.params[4], 16, 8); - endpoint2->type[3] = mc_dec(cmd.params[4], 24, 8); - endpoint2->type[4] = mc_dec(cmd.params[4], 32, 8); - endpoint2->type[5] = mc_dec(cmd.params[4], 40, 8); - endpoint2->type[6] = mc_dec(cmd.params[4], 48, 8); - endpoint2->type[7] = mc_dec(cmd.params[4], 56, 8); - endpoint2->type[8] = mc_dec(cmd.params[5], 0, 8); - endpoint2->type[9] = mc_dec(cmd.params[5], 8, 8); - endpoint2->type[10] = mc_dec(cmd.params[5], 16, 8); - endpoint2->type[11] = mc_dec(cmd.params[5], 24, 8); - endpoint2->type[12] = mc_dec(cmd.params[5], 32, 8); - endpoint2->type[13] = mc_dec(cmd.params[5], 40, 8); - endpoint2->type[14] = mc_dec(cmd.params[5], 48, 8); - endpoint2->type[15] = mc_dec(cmd.params[5], 56, 8); - *state = mc_dec(cmd.params[6], 0, 32); + rsp_params = (struct dprc_rsp_get_connection *)cmd.params; + endpoint2->id = le32_to_cpu(rsp_params->ep2_id); + endpoint2->if_id = le32_to_cpu(rsp_params->ep2_interface_id); + strncpy(endpoint2->type, rsp_params->ep2_type, 16); + endpoint2->type[15] = '\0'; + *state = le32_to_cpu(rsp_params->state); return 0; } diff --git a/drivers/staging/fsl-mc/bus/mc-sys.c b/drivers/staging/fsl-mc/bus/mc-sys.c index 810a611..0c185ab 100644 --- a/drivers/staging/fsl-mc/bus/mc-sys.c +++ b/drivers/staging/fsl-mc/bus/mc-sys.c @@ -53,8 +53,20 @@ #define MC_CMD_COMPLETION_POLLING_MIN_SLEEP_USECS 10 #define MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS 500 -#define MC_CMD_HDR_READ_CMDID(_hdr) \ - ((u16)mc_dec((_hdr), MC_CMD_HDR_CMDID_O, MC_CMD_HDR_CMDID_S)) +static enum mc_cmd_status mc_cmd_hdr_read_status(struct mc_command *cmd) +{ + struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header; + + return (enum mc_cmd_status)hdr->status; +} + +static u16 mc_cmd_hdr_read_cmdid(struct mc_command *cmd) +{ + struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header; + u16 cmd_id = le16_to_cpu(hdr->cmd_id); + + return (cmd_id & MC_CMD_HDR_CMDID_MASK) >> MC_CMD_HDR_CMDID_SHIFT; +} /** * Creates an MC I/O object @@ -261,10 +273,11 @@ static inline void mc_write_command(struct mc_command __iomem *portal, /* copy command parameters into the portal */ for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++) - writeq(cmd->params[i], &portal->params[i]); + __raw_writeq(cmd->params[i], &portal->params[i]); + __iowmb(); /* submit the command by writing the header */ - writeq(cmd->header, &portal->header); + __raw_writeq(cmd->header, &portal->header); } /** @@ -284,14 +297,17 @@ static inline enum mc_cmd_status mc_read_response(struct mc_command __iomem * enum mc_cmd_status status; /* Copy command response header from MC portal: */ - resp->header = readq(&portal->header); - status = MC_CMD_HDR_READ_STATUS(resp->header); + __iormb(); + resp->header = __raw_readq(&portal->header); + __iormb(); + status = mc_cmd_hdr_read_status(resp); if (status != MC_CMD_STATUS_OK) return status; /* Copy command response data from MC portal: */ for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++) - resp->params[i] = readq(&portal->params[i]); + resp->params[i] = __raw_readq(&portal->params[i]); + __iormb(); return status; } @@ -331,10 +347,8 @@ static int mc_polling_wait_preemptible(struct fsl_mc_io *mc_io, dev_dbg(mc_io->dev, "MC command timed out (portal: %#llx, obj handle: %#x, command: %#x)\n", mc_io->portal_phys_addr, - (unsigned int) - MC_CMD_HDR_READ_TOKEN(cmd->header), - (unsigned int) - MC_CMD_HDR_READ_CMDID(cmd->header)); + (unsigned int)mc_cmd_hdr_read_token(cmd), + (unsigned int)mc_cmd_hdr_read_cmdid(cmd)); return -ETIMEDOUT; } @@ -373,10 +387,8 @@ static int mc_polling_wait_atomic(struct fsl_mc_io *mc_io, dev_dbg(mc_io->dev, "MC command timed out (portal: %#llx, obj handle: %#x, command: %#x)\n", mc_io->portal_phys_addr, - (unsigned int) - MC_CMD_HDR_READ_TOKEN(cmd->header), - (unsigned int) - MC_CMD_HDR_READ_CMDID(cmd->header)); + (unsigned int)mc_cmd_hdr_read_token(cmd), + (unsigned int)mc_cmd_hdr_read_cmdid(cmd)); return -ETIMEDOUT; } @@ -429,8 +441,8 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd) dev_dbg(mc_io->dev, "MC command failed: portal: %#llx, obj handle: %#x, command: %#x, status: %s (%#x)\n", mc_io->portal_phys_addr, - (unsigned int)MC_CMD_HDR_READ_TOKEN(cmd->header), - (unsigned int)MC_CMD_HDR_READ_CMDID(cmd->header), + (unsigned int)mc_cmd_hdr_read_token(cmd), + (unsigned int)mc_cmd_hdr_read_cmdid(cmd), mc_status_to_string(status), (unsigned int)status); diff --git a/drivers/staging/fsl-mc/include/dpbp-cmd.h b/drivers/staging/fsl-mc/include/dpbp-cmd.h index c57b454..4828ccd 100644 --- a/drivers/staging/fsl-mc/include/dpbp-cmd.h +++ b/drivers/staging/fsl-mc/include/dpbp-cmd.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2014 Freescale Semiconductor Inc. +/* Copyright 2013-2016 Freescale Semiconductor Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -59,4 +59,127 @@ #define DPBP_CMDID_SET_NOTIFICATIONS 0x01b0 #define DPBP_CMDID_GET_NOTIFICATIONS 0x01b1 + +struct dpbp_cmd_open { + __le32 dpbp_id; +}; + +#define DPBP_ENABLE 0x1 + +struct dpbp_rsp_is_enabled { + u8 enabled; +}; + +struct dpbp_cmd_set_irq { + /* cmd word 0 */ + u8 irq_index; + u8 pad[3]; + __le32 irq_val; + /* cmd word 1 */ + __le64 irq_addr; + /* cmd word 2 */ + __le32 irq_num; +}; + +struct dpbp_cmd_get_irq { + __le32 pad; + u8 irq_index; +}; + +struct dpbp_rsp_get_irq { + /* response word 0 */ + __le32 irq_val; + __le32 pad; + /* response word 1 */ + __le64 irq_addr; + /* response word 2 */ + __le32 irq_num; + __le32 type; +}; + +struct dpbp_cmd_set_irq_enable { + u8 enable; + u8 pad[3]; + u8 irq_index; +}; + +struct dpbp_cmd_get_irq_enable { + __le32 pad; + u8 irq_index; +}; + +struct dpbp_rsp_get_irq_enable { + u8 enabled; +}; + +struct dpbp_cmd_set_irq_mask { + __le32 mask; + u8 irq_index; +}; + +struct dpbp_cmd_get_irq_mask { + __le32 pad; + u8 irq_index; +}; + +struct dpbp_rsp_get_irq_mask { + __le32 mask; +}; + +struct dpbp_cmd_get_irq_status { + __le32 status; + u8 irq_index; +}; + +struct dpbp_rsp_get_irq_status { + __le32 status; +}; + +struct dpbp_cmd_clear_irq_status { + __le32 status; + u8 irq_index; +}; + +struct dpbp_rsp_get_attributes { + /* response word 0 */ + __le16 pad; + __le16 bpid; + __le32 id; + /* response word 1 */ + __le16 version_major; + __le16 version_minor; +}; + +struct dpbp_cmd_set_notifications { + /* cmd word 0 */ + __le32 depletion_entry; + __le32 depletion_exit; + /* cmd word 1 */ + __le32 surplus_entry; + __le32 surplus_exit; + /* cmd word 2 */ + __le16 options; + __le16 pad[3]; + /* cmd word 3 */ + __le64 message_ctx; + /* cmd word 4 */ + __le64 message_iova; +}; + +struct dpbp_rsp_get_notifications { + /* response word 0 */ + __le32 depletion_entry; + __le32 depletion_exit; + /* response word 1 */ + __le32 surplus_entry; + __le32 surplus_exit; + /* response word 2 */ + __le16 options; + __le16 pad[3]; + /* response word 3 */ + __le64 message_ctx; + /* response word 4 */ + __le64 message_iova; +}; + #endif /* _FSL_DPBP_CMD_H */ diff --git a/drivers/staging/fsl-mc/include/mc-cmd.h b/drivers/staging/fsl-mc/include/mc-cmd.h index 65277e3..5decb98 100644 --- a/drivers/staging/fsl-mc/include/mc-cmd.h +++ b/drivers/staging/fsl-mc/include/mc-cmd.h @@ -34,18 +34,14 @@ #define MC_CMD_NUM_OF_PARAMS 7 -#define MAKE_UMASK64(_width) \ - ((u64)((_width) < 64 ? ((u64)1 << (_width)) - 1 : -1)) - -static inline u64 mc_enc(int lsoffset, int width, u64 val) -{ - return (u64)(((u64)val & MAKE_UMASK64(width)) << lsoffset); -} - -static inline u64 mc_dec(u64 val, int lsoffset, int width) -{ - return (u64)((val >> lsoffset) & MAKE_UMASK64(width)); -} +struct mc_cmd_header { + u8 src_id; + u8 flags_hw; + u8 status; + u8 flags_sw; + __le16 token; + __le16 cmd_id; +}; struct mc_command { u64 header; @@ -72,60 +68,41 @@ enum mc_cmd_status { */ /* High priority flag */ -#define MC_CMD_FLAG_PRI 0x00008000 +#define MC_CMD_FLAG_PRI 0x80 /* Command completion flag */ -#define MC_CMD_FLAG_INTR_DIS 0x01000000 - -/* - * TODO Remove following two defines after completion of flib 8.0.0 - * integration - */ -#define MC_CMD_PRI_LOW 0 /*!< Low Priority command indication */ -#define MC_CMD_PRI_HIGH 1 /*!< High Priority command indication */ - -#define MC_CMD_HDR_CMDID_O 52 /* Command ID field offset */ -#define MC_CMD_HDR_CMDID_S 12 /* Command ID field size */ -#define MC_CMD_HDR_TOKEN_O 38 /* Token field offset */ -#define MC_CMD_HDR_TOKEN_S 10 /* Token field size */ -#define MC_CMD_HDR_STATUS_O 16 /* Status field offset */ -#define MC_CMD_HDR_STATUS_S 8 /* Status field size*/ -#define MC_CMD_HDR_FLAGS_O 0 /* Flags field offset */ -#define MC_CMD_HDR_FLAGS_S 32 /* Flags field size*/ -#define MC_CMD_HDR_FLAGS_MASK 0xFF00FF00 /* Command flags mask */ - -#define MC_CMD_HDR_READ_STATUS(_hdr) \ - ((enum mc_cmd_status)mc_dec((_hdr), \ - MC_CMD_HDR_STATUS_O, MC_CMD_HDR_STATUS_S)) - -#define MC_CMD_HDR_READ_TOKEN(_hdr) \ - ((u16)mc_dec((_hdr), MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S)) - -#define MC_CMD_HDR_READ_FLAGS(_hdr) \ - ((u32)mc_dec((_hdr), MC_CMD_HDR_FLAGS_O, MC_CMD_HDR_FLAGS_S)) +#define MC_CMD_FLAG_INTR_DIS 0x01 -#define MC_EXT_OP(_ext, _param, _offset, _width, _type, _arg) \ - ((_ext)[_param] |= mc_enc((_offset), (_width), _arg)) - -#define MC_CMD_OP(_cmd, _param, _offset, _width, _type, _arg) \ - ((_cmd).params[_param] |= mc_enc((_offset), (_width), _arg)) - -#define MC_RSP_OP(_cmd, _param, _offset, _width, _type, _arg) \ - (_arg = (_type)mc_dec(_cmd.params[_param], (_offset), (_width))) +#define MC_CMD_HDR_CMDID_MASK 0xFFF0 +#define MC_CMD_HDR_CMDID_SHIFT 4 +#define MC_CMD_HDR_TOKEN_MASK 0xFFC0 +#define MC_CMD_HDR_TOKEN_SHIFT 6 static inline u64 mc_encode_cmd_header(u16 cmd_id, u32 cmd_flags, u16 token) { - u64 hdr; + u64 header = 0; + struct mc_cmd_header *hdr = (struct mc_cmd_header *)&header; + + hdr->cmd_id = cpu_to_le16((cmd_id << MC_CMD_HDR_CMDID_SHIFT) & + MC_CMD_HDR_CMDID_MASK); + hdr->token = cpu_to_le16((token << MC_CMD_HDR_TOKEN_SHIFT) & + MC_CMD_HDR_TOKEN_MASK); + hdr->status = MC_CMD_STATUS_READY; + if (cmd_flags & MC_CMD_FLAG_PRI) + hdr->flags_hw = MC_CMD_FLAG_PRI; + if (cmd_flags & MC_CMD_FLAG_INTR_DIS) + hdr->flags_sw = MC_CMD_FLAG_INTR_DIS; + + return header; +} - hdr = mc_enc(MC_CMD_HDR_CMDID_O, MC_CMD_HDR_CMDID_S, cmd_id); - hdr |= mc_enc(MC_CMD_HDR_FLAGS_O, MC_CMD_HDR_FLAGS_S, - (cmd_flags & MC_CMD_HDR_FLAGS_MASK)); - hdr |= mc_enc(MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S, token); - hdr |= mc_enc(MC_CMD_HDR_STATUS_O, MC_CMD_HDR_STATUS_S, - MC_CMD_STATUS_READY); +static inline u16 mc_cmd_hdr_read_token(struct mc_command *cmd) +{ + struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header; + u16 token = le16_to_cpu(hdr->token); - return hdr; + return (token & MC_CMD_HDR_TOKEN_MASK) >> MC_CMD_HDR_TOKEN_SHIFT; } #endif /* __FSL_MC_CMD_H */ -- cgit v1.1 From 3b8e73ec822cecf62e68e12c5320cf329d69923a Mon Sep 17 00:00:00 2001 From: Crestez Dan Leonard Date: Mon, 23 May 2016 21:40:01 +0300 Subject: iio: Refuse to register triggers with duplicate names The trigger name is documented as unique but drivers are currently allowed to register triggers with duplicate names. This should be considered a bug since it makes the 'current_trigger' interface unusable. Signed-off-by: Crestez Dan Leonard Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-trigger.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 6729112..b3ca308 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -64,6 +64,8 @@ static struct attribute *iio_trig_dev_attrs[] = { }; 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 ret; @@ -86,11 +88,19 @@ int iio_trigger_register(struct iio_trigger *trig_info) /* Add to list of available triggers held by the IIO core */ mutex_lock(&iio_trigger_list_lock); + if (__iio_trigger_find_by_name(trig_info->name)) { + pr_err("Duplicate trigger name '%s'\n", trig_info->name); + ret = -EEXIST; + goto error_device_del; + } list_add_tail(&trig_info->list, &iio_trigger_list); mutex_unlock(&iio_trigger_list_lock); return 0; +error_device_del: + mutex_unlock(&iio_trigger_list_lock); + device_del(&trig_info->dev); error_unregister_id: ida_simple_remove(&iio_trigger_ida, trig_info->id); return ret; @@ -109,6 +119,18 @@ void iio_trigger_unregister(struct iio_trigger *trig_info) } EXPORT_SYMBOL(iio_trigger_unregister); +/* Search for trigger by name, assuming iio_trigger_list_lock held */ +static struct iio_trigger *__iio_trigger_find_by_name(const char *name) +{ + struct iio_trigger *iter; + + list_for_each_entry(iter, &iio_trigger_list, list) + if (!strcmp(iter->name, name)) + return iter; + + return NULL; +} + static struct iio_trigger *iio_trigger_find_by_name(const char *name, size_t len) { -- cgit v1.1 From 7feae871b263b509625b3bf946d4f1d72bb77c70 Mon Sep 17 00:00:00 2001 From: Dan O'Donovan Date: Fri, 27 May 2016 18:37:30 +0100 Subject: iio: adc: ti-adc081c: add ACPI device ID matching Add ACPI device ID matching for TI ADC081C/ADC101C/ADC121C ADCs. Signed-off-by: Dan O'Donovan Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-adc081c.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c index 9fd032d..f8807ad 100644 --- a/drivers/iio/adc/ti-adc081c.c +++ b/drivers/iio/adc/ti-adc081c.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -149,12 +150,24 @@ static int adc081c_probe(struct i2c_client *client, { struct iio_dev *iio; struct adc081c *adc; - struct adcxx1c_model *model = &adcxx1c_models[id->driver_data]; + struct adcxx1c_model *model; int err; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) return -EOPNOTSUPP; + if (ACPI_COMPANION(&client->dev)) { + const struct acpi_device_id *ad_id; + + ad_id = acpi_match_device(client->dev.driver->acpi_match_table, + &client->dev); + if (!ad_id) + return -ENODEV; + model = &adcxx1c_models[ad_id->driver_data]; + } else { + model = &adcxx1c_models[id->driver_data]; + } + iio = devm_iio_device_alloc(&client->dev, sizeof(*adc)); if (!iio) return -ENOMEM; @@ -231,10 +244,21 @@ static const struct of_device_id adc081c_of_match[] = { MODULE_DEVICE_TABLE(of, adc081c_of_match); #endif +#ifdef CONFIG_ACPI +static const struct acpi_device_id adc081c_acpi_match[] = { + { "ADC081C", ADC081C }, + { "ADC101C", ADC101C }, + { "ADC121C", ADC121C }, + { } +}; +MODULE_DEVICE_TABLE(acpi, adc081c_acpi_match); +#endif + static struct i2c_driver adc081c_driver = { .driver = { .name = "adc081c", .of_match_table = of_match_ptr(adc081c_of_match), + .acpi_match_table = ACPI_PTR(adc081c_acpi_match), }, .probe = adc081c_probe, .remove = adc081c_remove, -- cgit v1.1 From aea7b1dc2bb7405f2d7827b202788fbee3912c1a Mon Sep 17 00:00:00 2001 From: Luis de Bethencourt Date: Wed, 22 Jun 2016 20:43:31 +0100 Subject: staging: iio: accel: add error check Go to error_ret if sca3000_read_ctrl_reg() failed. Signed-off-by: Luis de Bethencourt Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/sca3000_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index a8f533a..53c5425 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -1046,6 +1046,8 @@ static int sca3000_clean_setup(struct sca3000_state *st) /* Disable ring buffer */ ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL); + if (ret < 0) + goto error_ret; ret = sca3000_write_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL, (ret & SCA3000_OUT_CTRL_PROT_MASK) | SCA3000_OUT_CTRL_BUF_X_EN -- cgit v1.1 From 22ed1a1c1cceebff380b3f6f84d520a0b398509a Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 30 May 2016 16:52:04 +0200 Subject: iio: as3935: improve error reporting in as3935_event_work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc warns about a potentially uninitialized variable use in as3935_event_work: drivers/iio/proximity/as3935.c: In function ‘as3935_event_work’: drivers/iio/proximity/as3935.c:231:6: error: ‘val’ may be used uninitialized in this function [-Werror=maybe-uninitialized] This case specifically happens when spi_w8r8() fails with a negative return code. We check all other users of this function except this one. As the error is rather unlikely to happen after the device has already been initialized, this just adds a dev_warn(). Another warning already exists in the same function, but is missing a trailing '\n' character, so I'm fixing that too. Signed-off-by: Arnd Bergmann Reviewed-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/as3935.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c index c12fde2..a9d5847 100644 --- a/drivers/iio/proximity/as3935.c +++ b/drivers/iio/proximity/as3935.c @@ -224,10 +224,16 @@ static void as3935_event_work(struct work_struct *work) { struct as3935_state *st; int val; + int ret; st = container_of(work, struct as3935_state, work.work); - as3935_read(st, AS3935_INT, &val); + ret = as3935_read(st, AS3935_INT, &val); + if (ret) { + dev_warn(&st->spi->dev, "read error\n"); + return; + } + val &= AS3935_INT_MASK; switch (val) { @@ -235,7 +241,7 @@ static void as3935_event_work(struct work_struct *work) iio_trigger_poll(st->trig); break; case AS3935_NOISE_INT: - dev_warn(&st->spi->dev, "noise level is too high"); + dev_warn(&st->spi->dev, "noise level is too high\n"); break; } } -- cgit v1.1 From 765550e4d98d8f5931a3863781acb7c6b995161c Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Mon, 13 Jun 2016 09:06:48 -0400 Subject: iio: stx104: Add GPIO support for the Apex Embedded Systems STX104 The Apex Embedded Systems STX104 device features eight lines of digital I/O (four digital inputs and four digital outputs). This patch adds GPIO support for these eight lines of digital I/O via GPIOLIB. Cc: Alexandre Courbot Signed-off-by: William Breathitt Gray Reviewed-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/dac/Kconfig | 11 +++-- drivers/iio/dac/stx104.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 129 insertions(+), 7 deletions(-) diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig index 61d5008..b3feb0bf 100644 --- a/drivers/iio/dac/Kconfig +++ b/drivers/iio/dac/Kconfig @@ -246,13 +246,14 @@ config MCP4922 will be called mcp4922. config STX104 - tristate "Apex Embedded Systems STX104 DAC driver" + tristate "Apex Embedded Systems STX104 driver" depends on ISA + select GPIOLIB help - Say yes here to build support for the 2-channel DAC on the Apex - Embedded Systems STX104 integrated analog PC/104 card. The base port - addresses for the devices may be configured via the "base" module - parameter array. + Say yes here to build support for the 2-channel DAC and GPIO on the + Apex Embedded Systems STX104 integrated analog PC/104 card. The base + port addresses for the devices may be configured via the base array + module parameter. config VF610_DAC tristate "Vybrid vf610 DAC driver" diff --git a/drivers/iio/dac/stx104.c b/drivers/iio/dac/stx104.c index 174f4b7..e0f31a1 100644 --- a/drivers/iio/dac/stx104.c +++ b/drivers/iio/dac/stx104.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,7 @@ #include #include #include +#include #define STX104_NUM_CHAN 2 @@ -56,6 +58,20 @@ struct stx104_iio { unsigned base; }; +/** + * struct stx104_gpio - GPIO device private data structure + * @chip: instance of the gpio_chip + * @lock: synchronization lock to prevent I/O race conditions + * @base: base port address of the GPIO device + * @out_state: output bits state + */ +struct stx104_gpio { + struct gpio_chip chip; + spinlock_t lock; + unsigned int base; + unsigned int out_state; +}; + static int stx104_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { @@ -95,15 +111,81 @@ static const struct iio_chan_spec stx104_channels[STX104_NUM_CHAN] = { STX104_CHAN(1) }; +static int stx104_gpio_get_direction(struct gpio_chip *chip, + unsigned int offset) +{ + if (offset < 4) + return 1; + + return 0; +} + +static int stx104_gpio_direction_input(struct gpio_chip *chip, + unsigned int offset) +{ + if (offset >= 4) + return -EINVAL; + + return 0; +} + +static int stx104_gpio_direction_output(struct gpio_chip *chip, + unsigned int offset, int value) +{ + if (offset < 4) + return -EINVAL; + + chip->set(chip, offset, value); + return 0; +} + +static int stx104_gpio_get(struct gpio_chip *chip, unsigned int offset) +{ + struct stx104_gpio *const stx104gpio = gpiochip_get_data(chip); + + if (offset >= 4) + return -EINVAL; + + return !!(inb(stx104gpio->base) & BIT(offset)); +} + +static void stx104_gpio_set(struct gpio_chip *chip, unsigned int offset, + int value) +{ + struct stx104_gpio *const stx104gpio = gpiochip_get_data(chip); + const unsigned int mask = BIT(offset) >> 4; + unsigned long flags; + + if (offset < 4) + return; + + spin_lock_irqsave(&stx104gpio->lock, flags); + + if (value) + stx104gpio->out_state |= mask; + else + stx104gpio->out_state &= ~mask; + + outb(stx104gpio->out_state, stx104gpio->base); + + spin_unlock_irqrestore(&stx104gpio->lock, flags); +} + static int stx104_probe(struct device *dev, unsigned int id) { struct iio_dev *indio_dev; struct stx104_iio *priv; + struct stx104_gpio *stx104gpio; + int err; indio_dev = devm_iio_device_alloc(dev, sizeof(*priv)); if (!indio_dev) return -ENOMEM; + stx104gpio = devm_kzalloc(dev, sizeof(*stx104gpio), GFP_KERNEL); + if (!stx104gpio) + return -ENOMEM; + if (!devm_request_region(dev, base[id], STX104_EXTENT, dev_name(dev))) { dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n", @@ -124,14 +206,53 @@ static int stx104_probe(struct device *dev, unsigned int id) outw(0, base[id] + 4); outw(0, base[id] + 6); - return devm_iio_device_register(dev, indio_dev); + err = devm_iio_device_register(dev, indio_dev); + if (err) { + dev_err(dev, "IIO device registering failed (%d)\n", err); + return err; + } + + stx104gpio->chip.label = dev_name(dev); + stx104gpio->chip.parent = dev; + stx104gpio->chip.owner = THIS_MODULE; + stx104gpio->chip.base = -1; + stx104gpio->chip.ngpio = 8; + stx104gpio->chip.get_direction = stx104_gpio_get_direction; + stx104gpio->chip.direction_input = stx104_gpio_direction_input; + stx104gpio->chip.direction_output = stx104_gpio_direction_output; + stx104gpio->chip.get = stx104_gpio_get; + stx104gpio->chip.set = stx104_gpio_set; + stx104gpio->base = base[id] + 3; + stx104gpio->out_state = 0x0; + + spin_lock_init(&stx104gpio->lock); + + dev_set_drvdata(dev, stx104gpio); + + err = gpiochip_add_data(&stx104gpio->chip, stx104gpio); + if (err) { + dev_err(dev, "GPIO registering failed (%d)\n", err); + return err; + } + + return 0; +} + +static int stx104_remove(struct device *dev, unsigned int id) +{ + struct stx104_gpio *const stx104gpio = dev_get_drvdata(dev); + + gpiochip_remove(&stx104gpio->chip); + + return 0; } static struct isa_driver stx104_driver = { .probe = stx104_probe, .driver = { .name = "stx104" - } + }, + .remove = stx104_remove }; static void __exit stx104_exit(void) -- cgit v1.1 From 4d462b85e727d482e6fa95252b909f3fce6851e0 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Wed, 15 Jun 2016 18:47:02 -0700 Subject: iio: proximity: as3935: remove redundant zeroing of tune_cap This is redundant as the containing stucture is allocated as part of iio_device_alloc using kzalloc and hence is already 0. Signed-off-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/as3935.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c index a9d5847..0566cb4 100644 --- a/drivers/iio/proximity/as3935.c +++ b/drivers/iio/proximity/as3935.c @@ -345,7 +345,6 @@ static int as3935_probe(struct spi_device *spi) st = iio_priv(indio_dev); st->spi = spi; - st->tune_cap = 0; spi_set_drvdata(spi, indio_dev); mutex_init(&st->lock); -- cgit v1.1 From c48c7b2e470ede9bfae2bff3ab8ba1fe5e832f64 Mon Sep 17 00:00:00 2001 From: Florian Vaussard Date: Tue, 21 Jun 2016 09:09:27 +0200 Subject: iio: adc: max1363: Fix missing i2c_device_id for MAX1164x parts The driver supports MAX11644, MAX11645, MAX11646 and MAX11647 parts. But the corresponding i2c_device_id are missing. Add them! Signed-off-by: Florian Vaussard Signed-off-by: Jonathan Cameron --- drivers/iio/adc/max1363.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index 929508e..b5d28c0 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -1680,6 +1680,10 @@ static const struct i2c_device_id max1363_id[] = { { "max11615", max11615 }, { "max11616", max11616 }, { "max11617", max11617 }, + { "max11644", max11644 }, + { "max11645", max11645 }, + { "max11646", max11646 }, + { "max11647", max11647 }, {} }; -- cgit v1.1 From 29e3e06d893105febb9c9ccaff856fcdcbe3f712 Mon Sep 17 00:00:00 2001 From: Phil Reid Date: Mon, 27 Jun 2016 11:17:56 +0800 Subject: iio: buffer-dma: Use ARRAY_SIZE in for loop range Use the ARRAY_SIZE macro in the for loops that access queue->fileio.blocks. Macro is already used in a couple of places where this access occurs, but range was hardcoded in these locations. Signed-off-by: Phil Reid Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/buffer/industrialio-buffer-dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/buffer/industrialio-buffer-dma.c b/drivers/iio/buffer/industrialio-buffer-dma.c index 212cbed..dd99d27 100644 --- a/drivers/iio/buffer/industrialio-buffer-dma.c +++ b/drivers/iio/buffer/industrialio-buffer-dma.c @@ -305,7 +305,7 @@ int iio_dma_buffer_request_update(struct iio_buffer *buffer) queue->fileio.active_block = NULL; spin_lock_irq(&queue->list_lock); - for (i = 0; i < 2; i++) { + for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) { block = queue->fileio.blocks[i]; /* If we can't re-use it free it */ @@ -323,7 +323,7 @@ int iio_dma_buffer_request_update(struct iio_buffer *buffer) INIT_LIST_HEAD(&queue->incoming); - for (i = 0; i < 2; i++) { + for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) { if (queue->fileio.blocks[i]) { block = queue->fileio.blocks[i]; if (block->state == IIO_BLOCK_STATE_DEAD) { -- cgit v1.1 From c947459979c6c9c8aff9c9b5027b31dbf8055106 Mon Sep 17 00:00:00 2001 From: Sean Nyekjaer Date: Mon, 27 Jun 2016 10:27:17 +0200 Subject: iio: ad5755: add support for dt bindings Devicetree can provide platform data Signed-off-by: Sean Nyekjaer Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5755.c | 188 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 187 insertions(+), 1 deletion(-) diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c index bfb350a..0fde593 100644 --- a/drivers/iio/dac/ad5755.c +++ b/drivers/iio/dac/ad5755.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -109,6 +110,51 @@ enum ad5755_type { ID_AD5737, }; +#ifdef CONFIG_OF +static const int ad5755_dcdc_freq_table[][2] = { + { 250000, AD5755_DC_DC_FREQ_250kHZ }, + { 410000, AD5755_DC_DC_FREQ_410kHZ }, + { 650000, AD5755_DC_DC_FREQ_650kHZ } +}; + +static const int ad5755_dcdc_maxv_table[][2] = { + { 23000000, AD5755_DC_DC_MAXV_23V }, + { 24500000, AD5755_DC_DC_MAXV_24V5 }, + { 27000000, AD5755_DC_DC_MAXV_27V }, + { 29500000, AD5755_DC_DC_MAXV_29V5 }, +}; + +static const int ad5755_slew_rate_table[][2] = { + { 64000, AD5755_SLEW_RATE_64k }, + { 32000, AD5755_SLEW_RATE_32k }, + { 16000, AD5755_SLEW_RATE_16k }, + { 8000, AD5755_SLEW_RATE_8k }, + { 4000, AD5755_SLEW_RATE_4k }, + { 2000, AD5755_SLEW_RATE_2k }, + { 1000, AD5755_SLEW_RATE_1k }, + { 500, AD5755_SLEW_RATE_500 }, + { 250, AD5755_SLEW_RATE_250 }, + { 125, AD5755_SLEW_RATE_125 }, + { 64, AD5755_SLEW_RATE_64 }, + { 32, AD5755_SLEW_RATE_32 }, + { 16, AD5755_SLEW_RATE_16 }, + { 8, AD5755_SLEW_RATE_8 }, + { 4, AD5755_SLEW_RATE_4 }, + { 0, AD5755_SLEW_RATE_0_5 }, +}; + +static const int ad5755_slew_step_table[][2] = { + { 256, AD5755_SLEW_STEP_SIZE_256 }, + { 128, AD5755_SLEW_STEP_SIZE_128 }, + { 64, AD5755_SLEW_STEP_SIZE_64 }, + { 32, AD5755_SLEW_STEP_SIZE_32 }, + { 16, AD5755_SLEW_STEP_SIZE_16 }, + { 4, AD5755_SLEW_STEP_SIZE_4 }, + { 2, AD5755_SLEW_STEP_SIZE_2 }, + { 1, AD5755_SLEW_STEP_SIZE_1 }, +}; +#endif + static int ad5755_write_unlocked(struct iio_dev *indio_dev, unsigned int reg, unsigned int val) { @@ -556,6 +602,129 @@ static const struct ad5755_platform_data ad5755_default_pdata = { }, }; +#ifdef CONFIG_OF +static struct ad5755_platform_data *ad5755_parse_dt(struct device *dev) +{ + struct device_node *np = dev->of_node; + struct device_node *pp; + struct ad5755_platform_data *pdata; + unsigned int tmp; + unsigned int tmparray[3]; + int devnr, i; + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return NULL; + + pdata->ext_dc_dc_compenstation_resistor = + of_property_read_bool(np, "adi,ext-dc-dc-compenstation-resistor"); + + if (!of_property_read_u32(np, "adi,dc-dc-phase", &tmp)) + pdata->dc_dc_phase = tmp; + else + pdata->dc_dc_phase = AD5755_DC_DC_PHASE_ALL_SAME_EDGE; + + pdata->dc_dc_freq = AD5755_DC_DC_FREQ_410kHZ; + if (!of_property_read_u32(np, "adi,dc-dc-freq-hz", &tmp)) { + for (i = 0; i < ARRAY_SIZE(ad5755_dcdc_freq_table); i++) { + if (tmp == ad5755_dcdc_freq_table[i][0]) { + pdata->dc_dc_freq = ad5755_dcdc_freq_table[i][1]; + break; + } + } + + if (i == ARRAY_SIZE(ad5755_dcdc_freq_table)) { + dev_err(dev, + "adi,dc-dc-freq out of range selecting 410kHz"); + } + } + + pdata->dc_dc_maxv = AD5755_DC_DC_MAXV_23V; + if (!of_property_read_u32(np, "adi,dc-dc-max-microvolt", &tmp)) { + for (i = 0; i < ARRAY_SIZE(ad5755_dcdc_maxv_table); i++) { + if (tmp == ad5755_dcdc_maxv_table[i][0]) { + pdata->dc_dc_maxv = ad5755_dcdc_maxv_table[i][1]; + break; + } + } + if (i == ARRAY_SIZE(ad5755_dcdc_maxv_table)) { + dev_err(dev, + "adi,dc-dc-maxv out of range selecting 23V"); + } + } + + devnr = 0; + for_each_child_of_node(np, pp) { + if (devnr > AD5755_NUM_CHANNELS) { + dev_err(dev, + "There is to many channels defined in DT\n"); + goto error_out; + } + + if (!of_property_read_u32(pp, "adi,mode", &tmp)) + pdata->dac[devnr].mode = tmp; + else + pdata->dac[devnr].mode = AD5755_MODE_CURRENT_4mA_20mA; + + pdata->dac[devnr].ext_current_sense_resistor = + of_property_read_bool(pp, "adi,ext-current-sense-resistor"); + + pdata->dac[devnr].enable_voltage_overrange = + of_property_read_bool(pp, "adi,enable-voltage-overrange"); + + if (!of_property_read_u32_array(pp, "adi,slew", tmparray, 3)) { + pdata->dac[devnr].slew.enable = tmparray[0]; + + pdata->dac[devnr].slew.rate = AD5755_SLEW_RATE_64k; + for (i = 0; i < ARRAY_SIZE(ad5755_slew_rate_table); i++) { + if (tmparray[1] == ad5755_slew_rate_table[i][0]) { + pdata->dac[devnr].slew.rate = + ad5755_slew_rate_table[i][1]; + break; + } + } + if (i == ARRAY_SIZE(ad5755_slew_rate_table)) { + dev_err(dev, + "channel %d slew rate out of range selecting 64kHz", + devnr); + } + + pdata->dac[devnr].slew.step_size = AD5755_SLEW_STEP_SIZE_1; + for (i = 0; i < ARRAY_SIZE(ad5755_slew_step_table); i++) { + if (tmparray[2] == ad5755_slew_step_table[i][0]) { + pdata->dac[devnr].slew.step_size = + ad5755_slew_step_table[i][1]; + break; + } + } + if (i == ARRAY_SIZE(ad5755_slew_step_table)) { + dev_err(dev, + "channel %d slew step size out of range selecting 1 LSB", + devnr); + } + } else { + pdata->dac[devnr].slew.enable = false; + pdata->dac[devnr].slew.rate = AD5755_SLEW_RATE_64k; + pdata->dac[devnr].slew.step_size = + AD5755_SLEW_STEP_SIZE_1; + } + devnr++; + } + + return pdata; + + error_out: + devm_kfree(dev, pdata); + return NULL; +} +#else +static +struct ad5755_platform_data *ad5755_parse_dt(struct device *dev) +{ + return NULL; +} +#endif + static int ad5755_probe(struct spi_device *spi) { enum ad5755_type type = spi_get_device_id(spi)->driver_data; @@ -583,8 +752,15 @@ static int ad5755_probe(struct spi_device *spi) indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->num_channels = AD5755_NUM_CHANNELS; - if (!pdata) + if (spi->dev.of_node) + pdata = ad5755_parse_dt(&spi->dev); + else + pdata = spi->dev.platform_data; + + if (!pdata) { + dev_warn(&spi->dev, "no platform data? using default\n"); pdata = &ad5755_default_pdata; + } ret = ad5755_init_channels(indio_dev, pdata); if (ret) @@ -607,6 +783,16 @@ static const struct spi_device_id ad5755_id[] = { }; MODULE_DEVICE_TABLE(spi, ad5755_id); +static const struct of_device_id ad5755_of_match[] = { + { .compatible = "adi,ad5755" }, + { .compatible = "adi,ad5755-1" }, + { .compatible = "adi,ad5757" }, + { .compatible = "adi,ad5735" }, + { .compatible = "adi,ad5737" }, + { } +}; +MODULE_DEVICE_TABLE(of, ad5755_of_match); + static struct spi_driver ad5755_driver = { .driver = { .name = "ad5755", -- cgit v1.1 From 67626cc1a0f7bd6700b6f2f547244382247f5bb3 Mon Sep 17 00:00:00 2001 From: Sean Nyekjaer Date: Mon, 27 Jun 2016 10:27:18 +0200 Subject: iio: ad5755: Add DT binding documentation Signed-off-by: Sean Nyekjaer Acked-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/dac/ad5755.txt | 124 +++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/dac/ad5755.txt diff --git a/Documentation/devicetree/bindings/iio/dac/ad5755.txt b/Documentation/devicetree/bindings/iio/dac/ad5755.txt new file mode 100644 index 0000000..f0bbd7e --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/ad5755.txt @@ -0,0 +1,124 @@ +* Analog Device AD5755 IIO Multi-Channel DAC Linux Driver + +Required properties: + - compatible: Has to contain one of the following: + adi,ad5755 + adi,ad5755-1 + adi,ad5757 + adi,ad5735 + adi,ad5737 + + - reg: spi chip select number for the device + - spi-cpha or spi-cpol: is the only modes that is supported + +Recommended properties: + - spi-max-frequency: Definition as per + Documentation/devicetree/bindings/spi/spi-bus.txt + +Optional properties: +See include/dt-bindings/iio/ad5755.h + - adi,ext-dc-dc-compenstation-resistor: boolean set if the hardware have an + external resistor and thereby bypasses + the internal compensation resistor. + - adi,dc-dc-phase: + Valid values for DC DC Phase control is: + 0: All dc-to-dc converters clock on the same edge. + 1: Channel A and Channel B clock on the same edge, + Channel C and Channel D clock on opposite edges. + 2: Channel A and Channel C clock on the same edge, + Channel B and Channel D clock on opposite edges. + 3: Channel A, Channel B, Channel C, and Channel D + clock 90 degrees out of phase from each other. + - adi,dc-dc-freq-hz: + Valid values for DC DC frequency is [Hz]: + 250000 + 410000 + 650000 + - adi,dc-dc-max-microvolt: + Valid values for the maximum allowed Vboost voltage supplied by + the dc-to-dc converter is: + 23000000 + 24500000 + 27000000 + 29500000 + +Optional for every channel: + - adi,mode: + Valid values for DAC modes is: + 0: 0 V to 5 V voltage range. + 1: 0 V to 10 V voltage range. + 2: Plus minus 5 V voltage range. + 3: Plus minus 10 V voltage range. + 4: 4 mA to 20 mA current range. + 5: 0 mA to 20 mA current range. + 6: 0 mA to 24 mA current range. + - adi,ext-current-sense-resistor: boolean set if the hardware a external + current sense resistor. + - adi,enable-voltage-overrange: boolean enable voltage overrange + - adi,slew: Array of slewrate settings should contain 3 fields: + 1: Should be either 0 or 1 in order to enable or disable slewrate. + 2: Slew rate settings: + Valid values for the slew rate update frequency: + 64000 + 32000 + 16000 + 8000 + 4000 + 2000 + 1000 + 500 + 250 + 125 + 64 + 32 + 16 + 8 + 4 + 0 + 3: Slew step size: + Valid values for the step size LSBs: + 1 + 2 + 4 + 16 + 32 + 64 + 128 + 256 + +Example: +dac@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "adi,ad5755"; + reg = <0>; + spi-max-frequency = <1000000>; + spi-cpha; + adi,dc-dc-phase = <0>; + adi,dc-dc-freq-hz = <410000>; + adi,dc-dc-max-microvolt = <23000000>; + channel@0 { + reg = <0>; + adi,mode = <4>; + adi,ext-current-sense-resistor; + adi,slew = <0 64000 1>; + }; + channel@1 { + reg = <1>; + adi,mode = <4>; + adi,ext-current-sense-resistor; + adi,slew = <0 64000 1>; + }; + channel@2 { + reg = <2>; + adi,mode = <4>; + adi,ext-current-sense-resistor; + adi,slew = <0 64000 1>; + }; + channel@3 { + reg = <3>; + adi,mode = <4>; + adi,ext-current-sense-resistor; + adi,slew = <0 64000 1>; + }; +}; -- cgit v1.1 From eaaa7ec71bff4cb34d9025ed89068d4b3cac3df0 Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Wed, 9 Mar 2016 19:05:48 +0100 Subject: timekeeping: export get_monotonic_coarse64 symbol EXPORT_SYMBOL() get_monotonic_coarse64 for new IIO timestamping clock selection usage. This provides user apps the ability to request a particular IIO device to timestamp samples using a monotonic coarse clock granularity. Signed-off-by: Gregor Boirie Signed-off-by: Jonathan Cameron --- kernel/time/timekeeping.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 479d25c..255e225 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -2186,6 +2186,7 @@ struct timespec64 get_monotonic_coarse64(void) return now; } +EXPORT_SYMBOL(get_monotonic_coarse64); /* * Must hold jiffies_lock -- cgit v1.1 From bc2b7dab629a51e8beb5fda4222c62a23b729f26 Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Wed, 9 Mar 2016 19:05:49 +0100 Subject: iio:core: timestamping clock selection support Adds a new per-device sysfs attribute "current_timestamp_clock" to allow userspace to select a particular POSIX clock for buffered samples and events timestamping. Following clocks, as listed in clock_gettime(2), are supported: CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_MONOTONIC_RAW, CLOCK_REALTIME_COARSE, CLOCK_MONOTONIC_COARSE, CLOCK_BOOTTIME and CLOCK_TAI. Signed-off-by: Gregor Boirie Acked-by: Sanchayan Maity Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 7 + Documentation/DocBook/iio.tmpl | 2 +- drivers/iio/accel/bma180.c | 2 +- drivers/iio/accel/bmc150-accel-core.c | 4 +- drivers/iio/accel/kxcjk-1013.c | 2 +- drivers/iio/accel/mma7455_core.c | 3 +- drivers/iio/accel/mma8452.c | 4 +- drivers/iio/accel/mma9551.c | 2 +- drivers/iio/accel/mma9553.c | 2 +- drivers/iio/adc/ad7291.c | 2 +- drivers/iio/adc/ad7298.c | 2 +- drivers/iio/adc/ad7476.c | 2 +- drivers/iio/adc/ad7887.c | 2 +- drivers/iio/adc/ad7923.c | 2 +- drivers/iio/adc/ad799x.c | 4 +- drivers/iio/adc/cc10001_adc.c | 2 +- drivers/iio/adc/hi8435.c | 2 +- drivers/iio/adc/ina2xx-adc.c | 6 +- drivers/iio/adc/max1363.c | 5 +- drivers/iio/adc/ti-adc081c.c | 3 +- drivers/iio/adc/ti-ads1015.c | 3 +- drivers/iio/adc/vf610_adc.c | 3 +- drivers/iio/adc/xilinx-xadc-events.c | 4 +- drivers/iio/chemical/atlas-ph-sensor.c | 2 +- drivers/iio/common/st_sensors/st_sensors_buffer.c | 2 +- drivers/iio/common/st_sensors/st_sensors_trigger.c | 2 +- drivers/iio/dac/ad5421.c | 6 +- drivers/iio/dac/ad5504.c | 2 +- drivers/iio/dummy/iio_simple_dummy_buffer.c | 3 +- drivers/iio/dummy/iio_simple_dummy_events.c | 2 +- drivers/iio/gyro/bmg160_core.c | 30 ++-- drivers/iio/iio_core.h | 3 + drivers/iio/imu/bmi160/bmi160_core.c | 3 +- drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c | 2 +- drivers/iio/industrialio-core.c | 179 ++++++++++++++++++++- drivers/iio/industrialio-event.c | 19 ++- drivers/iio/industrialio-trigger.c | 2 +- drivers/iio/light/acpi-als.c | 2 +- drivers/iio/light/adjd_s311.c | 2 +- drivers/iio/light/apds9300.c | 2 +- drivers/iio/light/apds9960.c | 4 +- drivers/iio/light/cm36651.c | 2 +- drivers/iio/light/gp2ap020a00f.c | 8 +- drivers/iio/light/isl29125.c | 2 +- drivers/iio/light/lm3533-als.c | 2 +- drivers/iio/light/ltr501.c | 7 +- drivers/iio/light/max44000.c | 3 +- drivers/iio/light/opt3001.c | 4 +- drivers/iio/light/stk3310.c | 2 +- drivers/iio/light/tcs3414.c | 2 +- drivers/iio/light/tcs3472.c | 2 +- drivers/iio/light/tsl2563.c | 2 +- drivers/iio/light/us5182d.c | 2 +- drivers/iio/magnetometer/ak8975.c | 3 +- drivers/iio/magnetometer/hmc5843_core.c | 2 +- drivers/iio/magnetometer/mag3110.c | 2 +- drivers/iio/pressure/mpl3115.c | 2 +- drivers/iio/pressure/ms5611_core.c | 3 +- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 2 +- drivers/iio/proximity/sx9500.c | 4 +- drivers/staging/iio/accel/lis3l02dq_core.c | 2 +- drivers/staging/iio/accel/sca3000_core.c | 2 +- drivers/staging/iio/adc/ad7280a.c | 8 +- drivers/staging/iio/adc/ad7606_ring.c | 3 +- drivers/staging/iio/adc/ad7816.c | 3 +- drivers/staging/iio/addac/adt7316.c | 4 +- drivers/staging/iio/cdc/ad7150.c | 2 +- drivers/staging/iio/light/tsl2x7x_core.c | 2 +- include/linux/iio/iio.h | 22 ++- 69 files changed, 327 insertions(+), 114 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index e7f590c..fee35c0 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -32,6 +32,13 @@ Description: Description of the physical chip / device for device X. Typically a part number. +What: /sys/bus/iio/devices/iio:deviceX/timestamp_clock +KernelVersion: 4.5 +Contact: linux-iio@vger.kernel.org +Description: + String identifying current posix clock used to timestamp + buffered samples and events for device X. + What: /sys/bus/iio/devices/iio:deviceX/sampling_frequency What: /sys/bus/iio/devices/iio:deviceX/buffer/sampling_frequency What: /sys/bus/iio/devices/triggerX/sampling_frequency diff --git a/Documentation/DocBook/iio.tmpl b/Documentation/DocBook/iio.tmpl index f525bf5..e2ab6a1 100644 --- a/Documentation/DocBook/iio.tmpl +++ b/Documentation/DocBook/iio.tmpl @@ -594,7 +594,7 @@ irqreturn_t sensor_iio_pollfunc(int irq, void *p) { - pf->timestamp = iio_get_time_ns(); + pf->timestamp = iio_get_time_ns((struct indio_dev *)p); return IRQ_WAKE_THREAD; } diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index f04b884..e3f88ba 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -654,7 +654,7 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct bma180_data *data = iio_priv(indio_dev); - int64_t time_ns = iio_get_time_ns(); + s64 time_ns = iio_get_time_ns(indio_dev); int bit, ret, i = 0; mutex_lock(&data->mutex); diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 197e693..bf17aae 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -901,7 +901,7 @@ static int __bmc150_accel_fifo_flush(struct iio_dev *indio_dev, */ if (!irq) { data->old_timestamp = data->timestamp; - data->timestamp = iio_get_time_ns(); + data->timestamp = iio_get_time_ns(indio_dev); } /* @@ -1303,7 +1303,7 @@ static irqreturn_t bmc150_accel_irq_handler(int irq, void *private) int i; data->old_timestamp = data->timestamp; - data->timestamp = iio_get_time_ns(); + data->timestamp = iio_get_time_ns(indio_dev); for (i = 0; i < BMC150_ACCEL_TRIGGERS; i++) { if (data->triggers[i].enabled) { diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index bfe219a..765a723 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -1129,7 +1129,7 @@ static irqreturn_t kxcjk1013_data_rdy_trig_poll(int irq, void *private) struct iio_dev *indio_dev = private; struct kxcjk1013_data *data = iio_priv(indio_dev); - data->timestamp = iio_get_time_ns(); + data->timestamp = iio_get_time_ns(indio_dev); if (data->dready_trigger_on) iio_trigger_poll(data->dready_trig); diff --git a/drivers/iio/accel/mma7455_core.c b/drivers/iio/accel/mma7455_core.c index c902f54..6551085 100644 --- a/drivers/iio/accel/mma7455_core.c +++ b/drivers/iio/accel/mma7455_core.c @@ -97,7 +97,8 @@ static irqreturn_t mma7455_trigger_handler(int irq, void *p) if (ret) goto done; - iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns()); + iio_push_to_buffers_with_timestamp(indio_dev, buf, + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 799fe64..c0df283 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -917,7 +917,7 @@ static int mma8452_write_event_config(struct iio_dev *indio_dev, static void mma8452_transient_interrupt(struct iio_dev *indio_dev) { struct mma8452_data *data = iio_priv(indio_dev); - s64 ts = iio_get_time_ns(); + s64 ts = iio_get_time_ns(indio_dev); int src; src = i2c_smbus_read_byte_data(data->client, data->chip_info->ev_src); @@ -997,7 +997,7 @@ static irqreturn_t mma8452_trigger_handler(int irq, void *p) goto done; iio_push_to_buffers_with_timestamp(indio_dev, buffer, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c index d899a4d..bf27044 100644 --- a/drivers/iio/accel/mma9551.c +++ b/drivers/iio/accel/mma9551.c @@ -391,7 +391,7 @@ static irqreturn_t mma9551_event_handler(int irq, void *private) iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_INCLI, 0, (mma_axis + 1), IIO_EV_TYPE_ROC, IIO_EV_DIR_RISING), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); out: mutex_unlock(&data->mutex); diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c index bb05f3e..36bf197 100644 --- a/drivers/iio/accel/mma9553.c +++ b/drivers/iio/accel/mma9553.c @@ -1001,7 +1001,7 @@ static irqreturn_t mma9553_irq_handler(int irq, void *private) struct iio_dev *indio_dev = private; struct mma9553_data *data = iio_priv(indio_dev); - data->timestamp = iio_get_time_ns(); + data->timestamp = iio_get_time_ns(indio_dev); /* * Since we only configure the interrupt pin when an * event is enabled, we are sure we have at least diff --git a/drivers/iio/adc/ad7291.c b/drivers/iio/adc/ad7291.c index c0eabf1..0376309 100644 --- a/drivers/iio/adc/ad7291.c +++ b/drivers/iio/adc/ad7291.c @@ -115,7 +115,7 @@ static irqreturn_t ad7291_event_handler(int irq, void *private) u16 t_status, v_status; u16 command; int i; - s64 timestamp = iio_get_time_ns(); + s64 timestamp = iio_get_time_ns(indio_dev); if (ad7291_i2c_read(chip, AD7291_T_ALERT_STATUS, &t_status)) return IRQ_HANDLED; diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index 62bb8f7..5dd0742 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c @@ -163,7 +163,7 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p) goto done; iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c index 810c9a9..a819be2 100644 --- a/drivers/iio/adc/ad7476.c +++ b/drivers/iio/adc/ad7476.c @@ -70,7 +70,7 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p) goto done; iio_push_to_buffers_with_timestamp(indio_dev, st->data, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c index ee2ccc1..1bc363b 100644 --- a/drivers/iio/adc/ad7887.c +++ b/drivers/iio/adc/ad7887.c @@ -122,7 +122,7 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p) goto done; iio_push_to_buffers_with_timestamp(indio_dev, st->data, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index ff444c1..1337116 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -181,7 +181,7 @@ static irqreturn_t ad7923_trigger_handler(int irq, void *p) goto done; iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index ec0200d..5428476 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -212,7 +212,7 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p) goto out; iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); @@ -502,7 +502,7 @@ static irqreturn_t ad799x_event_handler(int irq, void *private) (i >> 1), IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } done: diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c index 8254f52..91636c0 100644 --- a/drivers/iio/adc/cc10001_adc.c +++ b/drivers/iio/adc/cc10001_adc.c @@ -186,7 +186,7 @@ done: if (!sample_invalid) iio_push_to_buffers_with_timestamp(indio_dev, data, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; diff --git a/drivers/iio/adc/hi8435.c b/drivers/iio/adc/hi8435.c index c73c6c6..c62bdb0 100644 --- a/drivers/iio/adc/hi8435.c +++ b/drivers/iio/adc/hi8435.c @@ -400,7 +400,7 @@ static void hi8435_iio_push_event(struct iio_dev *idev, unsigned int val) iio_push_event(idev, IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, i, IIO_EV_TYPE_THRESH, dir), - iio_get_time_ns()); + iio_get_time_ns(idev)); } } diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c index 502f2fb..b95ce5d 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -465,7 +465,7 @@ static int ina2xx_work_buffer(struct iio_dev *indio_dev) s64 time_a, time_b; unsigned int alert; - time_a = iio_get_time_ns(); + time_a = iio_get_time_ns(indio_dev); /* * Because the timer thread and the chip conversion clock @@ -504,7 +504,7 @@ static int ina2xx_work_buffer(struct iio_dev *indio_dev) data[i++] = val; } - time_b = iio_get_time_ns(); + time_b = iio_get_time_ns(indio_dev); iio_push_to_buffers_with_timestamp(indio_dev, (unsigned int *)data, time_a); @@ -554,7 +554,7 @@ static int ina2xx_buffer_enable(struct iio_dev *indio_dev) dev_dbg(&indio_dev->dev, "Async readout mode: %d\n", chip->allow_async_readout); - chip->prev_ns = iio_get_time_ns(); + chip->prev_ns = iio_get_time_ns(indio_dev); chip->task = kthread_run(ina2xx_capture_thread, (void *)indio_dev, "%s:%d-%uus", indio_dev->name, indio_dev->id, diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index 998dc3c..73af306 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -788,7 +788,7 @@ static irqreturn_t max1363_event_handler(int irq, void *private) { struct iio_dev *indio_dev = private; struct max1363_state *st = iio_priv(indio_dev); - s64 timestamp = iio_get_time_ns(); + s64 timestamp = iio_get_time_ns(indio_dev); unsigned long mask, loc; u8 rx; u8 tx[2] = { st->setupbyte, @@ -1506,7 +1506,8 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p) if (b_sent < 0) goto done_free; - iio_push_to_buffers_with_timestamp(indio_dev, rxbuf, iio_get_time_ns()); + iio_push_to_buffers_with_timestamp(indio_dev, rxbuf, + iio_get_time_ns(indio_dev)); done_free: kfree(rxbuf); diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c index f8807ad..283d2a1 100644 --- a/drivers/iio/adc/ti-adc081c.c +++ b/drivers/iio/adc/ti-adc081c.c @@ -139,7 +139,8 @@ static irqreturn_t adc081c_trigger_handler(int irq, void *p) if (ret < 0) goto out; buf[0] = ret; - iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns()); + iio_push_to_buffers_with_timestamp(indio_dev, buf, + iio_get_time_ns(indio_dev)); out: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index 8be192a..c9574af0 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -288,7 +288,8 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p) buf[0] = res; mutex_unlock(&data->lock); - iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns()); + iio_push_to_buffers_with_timestamp(indio_dev, buf, + iio_get_time_ns(indio_dev)); err: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c index 653bf13..228a003 100644 --- a/drivers/iio/adc/vf610_adc.c +++ b/drivers/iio/adc/vf610_adc.c @@ -594,7 +594,8 @@ static irqreturn_t vf610_adc_isr(int irq, void *dev_id) if (iio_buffer_enabled(indio_dev)) { info->buffer[0] = info->value; iio_push_to_buffers_with_timestamp(indio_dev, - info->buffer, iio_get_time_ns()); + info->buffer, + iio_get_time_ns(indio_dev)); iio_trigger_notify_done(indio_dev->trig); } else complete(&info->completion); diff --git a/drivers/iio/adc/xilinx-xadc-events.c b/drivers/iio/adc/xilinx-xadc-events.c index edcf3aa..6d5c2a6 100644 --- a/drivers/iio/adc/xilinx-xadc-events.c +++ b/drivers/iio/adc/xilinx-xadc-events.c @@ -46,7 +46,7 @@ static void xadc_handle_event(struct iio_dev *indio_dev, unsigned int event) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(chan->type, chan->channel, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } else { /* * For other channels we don't know whether it is a upper or @@ -56,7 +56,7 @@ static void xadc_handle_event(struct iio_dev *indio_dev, unsigned int event) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(chan->type, chan->channel, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } } diff --git a/drivers/iio/chemical/atlas-ph-sensor.c b/drivers/iio/chemical/atlas-ph-sensor.c index 02e85db..ae038a5 100644 --- a/drivers/iio/chemical/atlas-ph-sensor.c +++ b/drivers/iio/chemical/atlas-ph-sensor.c @@ -343,7 +343,7 @@ static irqreturn_t atlas_trigger_handler(int irq, void *private) if (!ret) iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c index 50afc0f..7c84e90 100644 --- a/drivers/iio/common/st_sensors/st_sensors_buffer.c +++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c @@ -62,7 +62,7 @@ irqreturn_t st_sensors_trigger_handler(int irq, void *p) if (sdata->hw_irq_trigger) timestamp = sdata->hw_timestamp; else - timestamp = iio_get_time_ns(); + timestamp = iio_get_time_ns(indio_dev); len = st_sensors_get_buffer_element(indio_dev, sdata->buffer_data); if (len < 0) diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c index 296e4ff..fab494d 100644 --- a/drivers/iio/common/st_sensors/st_sensors_trigger.c +++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c @@ -29,7 +29,7 @@ irqreturn_t st_sensors_irq_handler(int irq, void *p) struct st_sensor_data *sdata = iio_priv(indio_dev); /* Get the time stamp as close in time as possible */ - sdata->hw_timestamp = iio_get_time_ns(); + sdata->hw_timestamp = iio_get_time_ns(indio_dev); return IRQ_WAKE_THREAD; } diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c index 968712b..559061a 100644 --- a/drivers/iio/dac/ad5421.c +++ b/drivers/iio/dac/ad5421.c @@ -242,7 +242,7 @@ static irqreturn_t ad5421_fault_handler(int irq, void *data) 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } if (events & AD5421_FAULT_UNDER_CURRENT) { @@ -251,7 +251,7 @@ static irqreturn_t ad5421_fault_handler(int irq, void *data) 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } if (events & AD5421_FAULT_TEMP_OVER_140) { @@ -260,7 +260,7 @@ static irqreturn_t ad5421_fault_handler(int irq, void *data) 0, IIO_EV_TYPE_MAG, IIO_EV_DIR_RISING), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } old_fault = fault; diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c index 4e4c20d..788b3d6 100644 --- a/drivers/iio/dac/ad5504.c +++ b/drivers/iio/dac/ad5504.c @@ -223,7 +223,7 @@ static irqreturn_t ad5504_event_handler(int irq, void *private) 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), - iio_get_time_ns()); + iio_get_time_ns((struct iio_dev *)private)); return IRQ_HANDLED; } diff --git a/drivers/iio/dummy/iio_simple_dummy_buffer.c b/drivers/iio/dummy/iio_simple_dummy_buffer.c index cf44a6f..b383892 100644 --- a/drivers/iio/dummy/iio_simple_dummy_buffer.c +++ b/drivers/iio/dummy/iio_simple_dummy_buffer.c @@ -85,7 +85,8 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p) } } - iio_push_to_buffers_with_timestamp(indio_dev, data, iio_get_time_ns()); + iio_push_to_buffers_with_timestamp(indio_dev, data, + iio_get_time_ns(indio_dev)); kfree(data); diff --git a/drivers/iio/dummy/iio_simple_dummy_events.c b/drivers/iio/dummy/iio_simple_dummy_events.c index 6eb600f..ed63ffd 100644 --- a/drivers/iio/dummy/iio_simple_dummy_events.c +++ b/drivers/iio/dummy/iio_simple_dummy_events.c @@ -158,7 +158,7 @@ static irqreturn_t iio_simple_dummy_get_timestamp(int irq, void *private) struct iio_dev *indio_dev = private; struct iio_dummy_state *st = iio_priv(indio_dev); - st->event_timestamp = iio_get_time_ns(); + st->event_timestamp = iio_get_time_ns(indio_dev); return IRQ_WAKE_THREAD; } diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index 7ccc044..8155251 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c @@ -885,25 +885,25 @@ static irqreturn_t bmg160_event_handler(int irq, void *private) if (val & BMG160_ANY_MOTION_BIT_X) iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL, - 0, - IIO_MOD_X, - IIO_EV_TYPE_ROC, - dir), - iio_get_time_ns()); + 0, + IIO_MOD_X, + IIO_EV_TYPE_ROC, + dir), + iio_get_time_ns(indio_dev)); if (val & BMG160_ANY_MOTION_BIT_Y) iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL, - 0, - IIO_MOD_Y, - IIO_EV_TYPE_ROC, - dir), - iio_get_time_ns()); + 0, + IIO_MOD_Y, + IIO_EV_TYPE_ROC, + dir), + iio_get_time_ns(indio_dev)); if (val & BMG160_ANY_MOTION_BIT_Z) iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL, - 0, - IIO_MOD_Z, - IIO_EV_TYPE_ROC, - dir), - iio_get_time_ns()); + 0, + IIO_MOD_Z, + IIO_EV_TYPE_ROC, + dir), + iio_get_time_ns(indio_dev)); ack_intr_status: if (!data->dready_trigger_on) { diff --git a/drivers/iio/iio_core.h b/drivers/iio/iio_core.h index 3598835..4c45488 100644 --- a/drivers/iio/iio_core.h +++ b/drivers/iio/iio_core.h @@ -79,4 +79,7 @@ void iio_device_unregister_eventset(struct iio_dev *indio_dev); void iio_device_wakeup_eventset(struct iio_dev *indio_dev); int iio_event_getfd(struct iio_dev *indio_dev); +struct iio_event_interface; +bool iio_event_enabled(const struct iio_event_interface *ev_int); + #endif diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c index 97928d5..e0251b8 100644 --- a/drivers/iio/imu/bmi160/bmi160_core.c +++ b/drivers/iio/imu/bmi160/bmi160_core.c @@ -411,7 +411,8 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p) buf[j++] = sample; } - iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns()); + iio_push_to_buffers_with_timestamp(indio_dev, buf, + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c index d070062..3a9f3ea 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c @@ -107,7 +107,7 @@ irqreturn_t inv_mpu6050_irq_handler(int irq, void *p) struct inv_mpu6050_state *st = iio_priv(indio_dev); s64 timestamp; - timestamp = iio_get_time_ns(); + timestamp = iio_get_time_ns(indio_dev); kfifo_in_spinlocked(&st->timestamps, ×tamp, 1, &st->time_stamp_lock); diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 2a85bd8..f914d5d 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -178,6 +178,86 @@ ssize_t iio_read_const_attr(struct device *dev, } EXPORT_SYMBOL(iio_read_const_attr); +static int iio_device_set_clock(struct iio_dev *indio_dev, clockid_t clock_id) +{ + int ret; + const struct iio_event_interface *ev_int = indio_dev->event_interface; + + ret = mutex_lock_interruptible(&indio_dev->mlock); + if (ret) + return ret; + if ((ev_int && iio_event_enabled(ev_int)) || + iio_buffer_enabled(indio_dev)) { + mutex_unlock(&indio_dev->mlock); + return -EBUSY; + } + indio_dev->clock_id = clock_id; + mutex_unlock(&indio_dev->mlock); + + return 0; +} + +/** + * iio_get_time_ns() - utility function to get a time stamp for events etc + * @indio_dev: device + */ +s64 iio_get_time_ns(const struct iio_dev *indio_dev) +{ + struct timespec tp; + + switch (iio_device_get_clock(indio_dev)) { + case CLOCK_REALTIME: + ktime_get_real_ts(&tp); + break; + case CLOCK_MONOTONIC: + ktime_get_ts(&tp); + break; + case CLOCK_MONOTONIC_RAW: + getrawmonotonic(&tp); + break; + case CLOCK_REALTIME_COARSE: + tp = current_kernel_time(); + break; + case CLOCK_MONOTONIC_COARSE: + tp = get_monotonic_coarse(); + break; + case CLOCK_BOOTTIME: + get_monotonic_boottime(&tp); + break; + case CLOCK_TAI: + timekeeping_clocktai(&tp); + break; + default: + BUG(); + } + + return timespec_to_ns(&tp); +} +EXPORT_SYMBOL(iio_get_time_ns); + +/** + * iio_get_time_res() - utility function to get time stamp clock resolution in + * nano seconds. + * @indio_dev: device + */ +unsigned int iio_get_time_res(const struct iio_dev *indio_dev) +{ + switch (iio_device_get_clock(indio_dev)) { + case CLOCK_REALTIME: + case CLOCK_MONOTONIC: + case CLOCK_MONOTONIC_RAW: + case CLOCK_BOOTTIME: + case CLOCK_TAI: + return hrtimer_resolution; + case CLOCK_REALTIME_COARSE: + case CLOCK_MONOTONIC_COARSE: + return LOW_RES_NSEC; + default: + BUG(); + } +} +EXPORT_SYMBOL(iio_get_time_res); + static int __init iio_init(void) { int ret; @@ -990,11 +1070,91 @@ static ssize_t iio_show_dev_name(struct device *dev, static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL); +static ssize_t iio_show_timestamp_clock(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + const struct iio_dev *indio_dev = dev_to_iio_dev(dev); + const clockid_t clk = iio_device_get_clock(indio_dev); + const char *name; + ssize_t sz; + + switch (clk) { + case CLOCK_REALTIME: + name = "realtime\n"; + sz = sizeof("realtime\n"); + break; + case CLOCK_MONOTONIC: + name = "monotonic\n"; + sz = sizeof("monotonic\n"); + break; + case CLOCK_MONOTONIC_RAW: + name = "monotonic_raw\n"; + sz = sizeof("monotonic_raw\n"); + break; + case CLOCK_REALTIME_COARSE: + name = "realtime_coarse\n"; + sz = sizeof("realtime_coarse\n"); + break; + case CLOCK_MONOTONIC_COARSE: + name = "monotonic_coarse\n"; + sz = sizeof("monotonic_coarse\n"); + break; + case CLOCK_BOOTTIME: + name = "boottime\n"; + sz = sizeof("boottime\n"); + break; + case CLOCK_TAI: + name = "tai\n"; + sz = sizeof("tai\n"); + break; + default: + BUG(); + } + + memcpy(buf, name, sz); + return sz; +} + +static ssize_t iio_store_timestamp_clock(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + clockid_t clk; + int ret; + + if (sysfs_streq(buf, "realtime")) + clk = CLOCK_REALTIME; + else if (sysfs_streq(buf, "monotonic")) + clk = CLOCK_MONOTONIC; + else if (sysfs_streq(buf, "monotonic_raw")) + clk = CLOCK_MONOTONIC_RAW; + else if (sysfs_streq(buf, "realtime_coarse")) + clk = CLOCK_REALTIME_COARSE; + else if (sysfs_streq(buf, "monotonic_coarse")) + clk = CLOCK_MONOTONIC_COARSE; + else if (sysfs_streq(buf, "boottime")) + clk = CLOCK_BOOTTIME; + else if (sysfs_streq(buf, "tai")) + clk = CLOCK_TAI; + else + return -EINVAL; + + ret = iio_device_set_clock(dev_to_iio_dev(dev), clk); + if (ret) + return ret; + + return len; +} + +static DEVICE_ATTR(current_timestamp_clock, S_IRUGO | S_IWUSR, + iio_show_timestamp_clock, iio_store_timestamp_clock); + static int iio_device_register_sysfs(struct iio_dev *indio_dev) { int i, ret = 0, attrcount, attrn, attrcount_orig = 0; struct iio_dev_attr *p; - struct attribute **attr; + struct attribute **attr, *clk = NULL; /* First count elements in any existing group */ if (indio_dev->info->attrs) { @@ -1009,16 +1169,25 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev) */ if (indio_dev->channels) for (i = 0; i < indio_dev->num_channels; i++) { - ret = iio_device_add_channel_sysfs(indio_dev, - &indio_dev - ->channels[i]); + const struct iio_chan_spec *chan = + &indio_dev->channels[i]; + + if (chan->type == IIO_TIMESTAMP) + clk = &dev_attr_current_timestamp_clock.attr; + + ret = iio_device_add_channel_sysfs(indio_dev, chan); if (ret < 0) goto error_clear_attrs; attrcount += ret; } + if (indio_dev->event_interface) + clk = &dev_attr_current_timestamp_clock.attr; + if (indio_dev->name) attrcount++; + if (clk) + attrcount++; indio_dev->chan_attr_group.attrs = kcalloc(attrcount + 1, sizeof(indio_dev->chan_attr_group.attrs[0]), @@ -1039,6 +1208,8 @@ static int iio_device_register_sysfs(struct iio_dev *indio_dev) indio_dev->chan_attr_group.attrs[attrn++] = &p->dev_attr.attr; if (indio_dev->name) indio_dev->chan_attr_group.attrs[attrn++] = &dev_attr_name.attr; + if (clk) + indio_dev->chan_attr_group.attrs[attrn++] = clk; indio_dev->groups[indio_dev->groupcounter++] = &indio_dev->chan_attr_group; diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index cae332b..0ebfc92 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c @@ -44,6 +44,11 @@ struct iio_event_interface { struct mutex read_lock; }; +bool iio_event_enabled(const struct iio_event_interface *ev_int) +{ + return !!test_bit(IIO_BUSY_BIT_POS, &ev_int->flags); +} + /** * iio_push_event() - try to add event to the list for userspace reading * @indio_dev: IIO device structure @@ -60,7 +65,7 @@ int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp) int copied; /* Does anyone care? */ - if (test_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) { + if (iio_event_enabled(ev_int)) { ev.id = ev_code; ev.timestamp = timestamp; @@ -180,8 +185,14 @@ int iio_event_getfd(struct iio_dev *indio_dev) if (ev_int == NULL) return -ENODEV; - if (test_and_set_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) - return -EBUSY; + fd = mutex_lock_interruptible(&indio_dev->mlock); + if (fd) + return fd; + + if (test_and_set_bit(IIO_BUSY_BIT_POS, &ev_int->flags)) { + fd = -EBUSY; + goto unlock; + } iio_device_get(indio_dev); @@ -194,6 +205,8 @@ int iio_event_getfd(struct iio_dev *indio_dev) kfifo_reset_out(&ev_int->det_events); } +unlock: + mutex_unlock(&indio_dev->mlock); return fd; } diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 98457f0..7ad82fd 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -289,7 +289,7 @@ static int iio_trigger_detach_poll_func(struct iio_trigger *trig, irqreturn_t iio_pollfunc_store_time(int irq, void *p) { struct iio_poll_func *pf = p; - pf->timestamp = iio_get_time_ns(); + pf->timestamp = iio_get_time_ns(pf->indio_dev); return IRQ_WAKE_THREAD; } EXPORT_SYMBOL(iio_pollfunc_store_time); diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c index 53201d9..f0b47c5 100644 --- a/drivers/iio/light/acpi-als.c +++ b/drivers/iio/light/acpi-als.c @@ -118,7 +118,7 @@ static void acpi_als_notify(struct acpi_device *device, u32 event) struct iio_dev *indio_dev = acpi_driver_data(device); struct acpi_als *als = iio_priv(indio_dev); s32 *buffer = als->evt_buffer; - s64 time_ns = iio_get_time_ns(); + s64 time_ns = iio_get_time_ns(indio_dev); s32 val; int ret; diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c index 09ad5f1..0113fc8 100644 --- a/drivers/iio/light/adjd_s311.c +++ b/drivers/iio/light/adjd_s311.c @@ -118,7 +118,7 @@ static irqreturn_t adjd_s311_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct adjd_s311_data *data = iio_priv(indio_dev); - s64 time_ns = iio_get_time_ns(); + s64 time_ns = iio_get_time_ns(indio_dev); int i, j = 0; int ret = adjd_s311_req_data(indio_dev); diff --git a/drivers/iio/light/apds9300.c b/drivers/iio/light/apds9300.c index e1b9fa5..649b26f 100644 --- a/drivers/iio/light/apds9300.c +++ b/drivers/iio/light/apds9300.c @@ -396,7 +396,7 @@ static irqreturn_t apds9300_interrupt_handler(int irq, void *private) IIO_UNMOD_EVENT_CODE(IIO_INTENSITY, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), - iio_get_time_ns()); + iio_get_time_ns(dev_info)); apds9300_clear_intr(data); diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c index 651d57b..a4304ed 100644 --- a/drivers/iio/light/apds9960.c +++ b/drivers/iio/light/apds9960.c @@ -807,7 +807,7 @@ static irqreturn_t apds9960_interrupt_handler(int irq, void *private) IIO_UNMOD_EVENT_CODE(IIO_INTENSITY, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); regmap_write(data->regmap, APDS9960_REG_CICLEAR, 1); } @@ -816,7 +816,7 @@ static irqreturn_t apds9960_interrupt_handler(int irq, void *private) IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); regmap_write(data->regmap, APDS9960_REG_PICLEAR, 1); } diff --git a/drivers/iio/light/cm36651.c b/drivers/iio/light/cm36651.c index c8d7b5e..9d66e89 100644 --- a/drivers/iio/light/cm36651.c +++ b/drivers/iio/light/cm36651.c @@ -268,7 +268,7 @@ static irqreturn_t cm36651_irq_handler(int irq, void *data) CM36651_CMD_READ_RAW_PROXIMITY, IIO_EV_TYPE_THRESH, ev_dir); - iio_push_event(indio_dev, ev_code, iio_get_time_ns()); + iio_push_event(indio_dev, ev_code, iio_get_time_ns(indio_dev)); return IRQ_HANDLED; } diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c index af73af3..6ada914 100644 --- a/drivers/iio/light/gp2ap020a00f.c +++ b/drivers/iio/light/gp2ap020a00f.c @@ -851,7 +851,7 @@ static irqreturn_t gp2ap020a00f_prox_sensing_handler(int irq, void *data) GP2AP020A00F_SCAN_MODE_PROXIMITY, IIO_EV_TYPE_ROC, IIO_EV_DIR_RISING), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } else { iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE( @@ -859,7 +859,7 @@ static irqreturn_t gp2ap020a00f_prox_sensing_handler(int irq, void *data) GP2AP020A00F_SCAN_MODE_PROXIMITY, IIO_EV_TYPE_ROC, IIO_EV_DIR_FALLING), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } } @@ -925,7 +925,7 @@ static irqreturn_t gp2ap020a00f_thresh_event_handler(int irq, void *data) IIO_MOD_LIGHT_CLEAR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } if (test_bit(GP2AP020A00F_FLAG_ALS_FALLING_EV, &priv->flags)) { @@ -939,7 +939,7 @@ static irqreturn_t gp2ap020a00f_thresh_event_handler(int irq, void *data) IIO_MOD_LIGHT_CLEAR, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } } diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c index a6b9d66..f48b9e5 100644 --- a/drivers/iio/light/isl29125.c +++ b/drivers/iio/light/isl29125.c @@ -188,7 +188,7 @@ static irqreturn_t isl29125_trigger_handler(int irq, void *p) } iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/light/lm3533-als.c b/drivers/iio/light/lm3533-als.c index e56937c..f409c20 100644 --- a/drivers/iio/light/lm3533-als.c +++ b/drivers/iio/light/lm3533-als.c @@ -267,7 +267,7 @@ static irqreturn_t lm3533_als_isr(int irq, void *dev_id) 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); out: return IRQ_HANDLED; } diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index 6bf89d8..3afc53a 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c @@ -1256,7 +1256,8 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p) buf[j++] = psdata & LTR501_PS_DATA_MASK; } - iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns()); + iio_push_to_buffers_with_timestamp(indio_dev, buf, + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); @@ -1282,14 +1283,14 @@ static irqreturn_t ltr501_interrupt_handler(int irq, void *private) IIO_UNMOD_EVENT_CODE(IIO_INTENSITY, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); if (status & LTR501_STATUS_PS_INTR) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); return IRQ_HANDLED; } diff --git a/drivers/iio/light/max44000.c b/drivers/iio/light/max44000.c index f17cb2e..6511b20 100644 --- a/drivers/iio/light/max44000.c +++ b/drivers/iio/light/max44000.c @@ -511,7 +511,8 @@ static irqreturn_t max44000_trigger_handler(int irq, void *p) } mutex_unlock(&data->lock); - iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns()); + iio_push_to_buffers_with_timestamp(indio_dev, buf, + iio_get_time_ns(indio_dev)); iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c index b776c8e..78c9b3a 100644 --- a/drivers/iio/light/opt3001.c +++ b/drivers/iio/light/opt3001.c @@ -713,13 +713,13 @@ static irqreturn_t opt3001_irq(int irq, void *_iio) IIO_UNMOD_EVENT_CODE(IIO_LIGHT, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), - iio_get_time_ns()); + iio_get_time_ns(iio)); if (ret & OPT3001_CONFIGURATION_FL) iio_push_event(iio, IIO_UNMOD_EVENT_CODE(IIO_LIGHT, 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), - iio_get_time_ns()); + iio_get_time_ns(iio)); } else if (ret & OPT3001_CONFIGURATION_CRF) { ret = i2c_smbus_read_word_swapped(opt->client, OPT3001_RESULT); if (ret < 0) { diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index 9e847f8..45cf8b0 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -528,7 +528,7 @@ static irqreturn_t stk3310_irq_handler(int irq, void *private) struct iio_dev *indio_dev = private; struct stk3310_data *data = iio_priv(indio_dev); - data->timestamp = iio_get_time_ns(); + data->timestamp = iio_get_time_ns(indio_dev); return IRQ_WAKE_THREAD; } diff --git a/drivers/iio/light/tcs3414.c b/drivers/iio/light/tcs3414.c index 8a15fb5..a795afb 100644 --- a/drivers/iio/light/tcs3414.c +++ b/drivers/iio/light/tcs3414.c @@ -216,7 +216,7 @@ static irqreturn_t tcs3414_trigger_handler(int irq, void *p) } iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c index b29312f..3aa71e3 100644 --- a/drivers/iio/light/tcs3472.c +++ b/drivers/iio/light/tcs3472.c @@ -202,7 +202,7 @@ static irqreturn_t tcs3472_trigger_handler(int irq, void *p) } iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c index 57b108c..04598ae 100644 --- a/drivers/iio/light/tsl2563.c +++ b/drivers/iio/light/tsl2563.c @@ -630,7 +630,7 @@ static irqreturn_t tsl2563_event_handler(int irq, void *private) 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER), - iio_get_time_ns()); + iio_get_time_ns(dev_info)); /* clear the interrupt and push the event */ i2c_smbus_write_byte(chip->client, TSL2563_CMD | TSL2563_CLEARINT); diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c index 45bc2f7..20c40f7 100644 --- a/drivers/iio/light/us5182d.c +++ b/drivers/iio/light/us5182d.c @@ -833,7 +833,7 @@ static irqreturn_t us5182d_irq_thread_handler(int irq, void *private) dir = ret & US5182D_CFG0_PROX ? IIO_EV_DIR_RISING : IIO_EV_DIR_FALLING; ev = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 1, IIO_EV_TYPE_THRESH, dir); - iio_push_event(indio_dev, ev, iio_get_time_ns()); + iio_push_event(indio_dev, ev, iio_get_time_ns(indio_dev)); ret = i2c_smbus_write_byte_data(data->client, US5182D_REG_CFG0, ret & ~US5182D_CFG0_PX_IRQ); diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index 57d3654..2121b50 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -829,7 +829,8 @@ static void ak8975_fill_buffer(struct iio_dev *indio_dev) buff[1] = clamp_t(s16, le16_to_cpu(buff[1]), -def->range, def->range); buff[2] = clamp_t(s16, le16_to_cpu(buff[2]), -def->range, def->range); - iio_push_to_buffers_with_timestamp(indio_dev, buff, iio_get_time_ns()); + iio_push_to_buffers_with_timestamp(indio_dev, buff, + iio_get_time_ns(indio_dev)); return; unlock: diff --git a/drivers/iio/magnetometer/hmc5843_core.c b/drivers/iio/magnetometer/hmc5843_core.c index 77882b4..ba3e2a3 100644 --- a/drivers/iio/magnetometer/hmc5843_core.c +++ b/drivers/iio/magnetometer/hmc5843_core.c @@ -451,7 +451,7 @@ static irqreturn_t hmc5843_trigger_handler(int irq, void *p) goto done; iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c index 261d517..f2be4a0 100644 --- a/drivers/iio/magnetometer/mag3110.c +++ b/drivers/iio/magnetometer/mag3110.c @@ -261,7 +261,7 @@ static irqreturn_t mag3110_trigger_handler(int irq, void *p) } iio_push_to_buffers_with_timestamp(indio_dev, buffer, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c index 01b2e0b..6392d7b 100644 --- a/drivers/iio/pressure/mpl3115.c +++ b/drivers/iio/pressure/mpl3115.c @@ -171,7 +171,7 @@ static irqreturn_t mpl3115_trigger_handler(int irq, void *p) mutex_unlock(&data->lock); iio_push_to_buffers_with_timestamp(indio_dev, buffer, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); done: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/pressure/ms5611_core.c b/drivers/iio/pressure/ms5611_core.c index 76578b0..feb41f8 100644 --- a/drivers/iio/pressure/ms5611_core.c +++ b/drivers/iio/pressure/ms5611_core.c @@ -224,7 +224,8 @@ static irqreturn_t ms5611_trigger_handler(int irq, void *p) if (ret < 0) goto err; - iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns()); + iio_push_to_buffers_with_timestamp(indio_dev, buf, + iio_get_time_ns(indio_dev)); err: iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c index c0b0e82..3141c3c 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -238,7 +238,7 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private) ret = lidar_get_measurement(data, data->buffer); if (!ret) { iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } else if (ret != -EINVAL) { dev_err(&data->client->dev, "cannot read LIDAR measurement"); } diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c index 66cd09a..1d74b3a 100644 --- a/drivers/iio/proximity/sx9500.c +++ b/drivers/iio/proximity/sx9500.c @@ -492,7 +492,7 @@ static void sx9500_push_events(struct iio_dev *indio_dev) dir = new_prox ? IIO_EV_DIR_FALLING : IIO_EV_DIR_RISING; ev = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, chan, IIO_EV_TYPE_THRESH, dir); - iio_push_event(indio_dev, ev, iio_get_time_ns()); + iio_push_event(indio_dev, ev, iio_get_time_ns(indio_dev)); data->prox_stat[chan] = new_prox; } } @@ -669,7 +669,7 @@ static irqreturn_t sx9500_trigger_handler(int irq, void *private) } iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); out: mutex_unlock(&data->mutex); diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 7a6fed3..5c3410a 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -451,7 +451,7 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private) struct iio_dev *indio_dev = private; u8 t; - s64 timestamp = iio_get_time_ns(); + s64 timestamp = iio_get_time_ns(indio_dev); lis3l02dq_spi_read_reg_8(indio_dev, LIS3L02DQ_REG_WAKE_UP_SRC_ADDR, diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 53c5425..aacf643 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -774,7 +774,7 @@ static irqreturn_t sca3000_event_handler(int irq, void *private) struct iio_dev *indio_dev = private; struct sca3000_state *st = iio_priv(indio_dev); int ret, val; - s64 last_timestamp = iio_get_time_ns(); + s64 last_timestamp = iio_get_time_ns(indio_dev); /* * Could lead if badly timed to an extra read of status reg, diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index a06b46c..2177f1d 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -705,7 +705,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) IIO_EV_DIR_RISING, IIO_EV_TYPE_THRESH, 0, 0, 0), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); else if (((channels[i] >> 11) & 0xFFF) <= st->cell_threshlow) iio_push_event(indio_dev, @@ -715,7 +715,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) IIO_EV_DIR_FALLING, IIO_EV_TYPE_THRESH, 0, 0, 0), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } else { if (((channels[i] >> 11) & 0xFFF) >= st->aux_threshhigh) iio_push_event(indio_dev, @@ -724,7 +724,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); else if (((channels[i] >> 11) & 0xFFF) <= st->aux_threshlow) iio_push_event(indio_dev, @@ -733,7 +733,7 @@ static irqreturn_t ad7280_event_handler(int irq, void *private) 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } } diff --git a/drivers/staging/iio/adc/ad7606_ring.c b/drivers/staging/iio/adc/ad7606_ring.c index a6f8eb1..0572df9 100644 --- a/drivers/staging/iio/adc/ad7606_ring.c +++ b/drivers/staging/iio/adc/ad7606_ring.c @@ -77,7 +77,8 @@ static void ad7606_poll_bh_to_ring(struct work_struct *work_s) goto done; } - iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns()); + iio_push_to_buffers_with_timestamp(indio_dev, buf, + iio_get_time_ns(indio_dev)); done: gpio_set_value(st->pdata->gpio_convst, 0); iio_trigger_notify_done(indio_dev->trig); diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index ac3735c..5e8115b 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -253,7 +253,8 @@ static const struct attribute_group ad7816_attribute_group = { static irqreturn_t ad7816_event_handler(int irq, void *private) { - iio_push_event(private, IIO_EVENT_CODE_AD7816_OTI, iio_get_time_ns()); + iio_push_event(private, IIO_EVENT_CODE_AD7816_OTI, + iio_get_time_ns((struct iio_dev *)private)); return IRQ_HANDLED; } diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index a10e7d8..3faffe5 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1752,7 +1752,7 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) if ((chip->id & ID_FAMILY_MASK) != ID_ADT75XX) stat1 &= 0x1F; - time = iio_get_time_ns(); + time = iio_get_time_ns(indio_dev); if (stat1 & BIT(0)) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, @@ -1804,7 +1804,7 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) 0, IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), - iio_get_time_ns()); + iio_get_time_ns(indio_dev)); } return IRQ_HANDLED; diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index f6b9a10..5578a07 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -493,7 +493,7 @@ static irqreturn_t ad7150_event_handler(int irq, void *private) struct iio_dev *indio_dev = private; struct ad7150_chip_info *chip = iio_priv(indio_dev); u8 int_status; - s64 timestamp = iio_get_time_ns(); + s64 timestamp = iio_get_time_ns(indio_dev); int ret; ret = i2c_smbus_read_byte_data(chip->client, AD7150_STATUS); diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c index d553c8e..ea15bc1 100644 --- a/drivers/staging/iio/light/tsl2x7x_core.c +++ b/drivers/staging/iio/light/tsl2x7x_core.c @@ -1554,7 +1554,7 @@ static irqreturn_t tsl2x7x_event_handler(int irq, void *private) { struct iio_dev *indio_dev = private; struct tsl2X7X_chip *chip = iio_priv(indio_dev); - s64 timestamp = iio_get_time_ns(); + s64 timestamp = iio_get_time_ns(indio_dev); int ret; u8 value; diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 7c29cb0..854e2da 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -312,13 +312,8 @@ static inline bool iio_channel_has_info(const struct iio_chan_spec *chan, }, \ } -/** - * iio_get_time_ns() - utility function to get a time stamp for events etc - **/ -static inline s64 iio_get_time_ns(void) -{ - return ktime_get_real_ns(); -} +s64 iio_get_time_ns(const struct iio_dev *indio_dev); +unsigned int iio_get_time_res(const struct iio_dev *indio_dev); /* Device operating modes */ #define INDIO_DIRECT_MODE 0x01 @@ -497,6 +492,7 @@ struct iio_buffer_setup_ops { * @chan_attr_group: [INTERN] group for all attrs in base directory * @name: [DRIVER] name of the device. * @info: [DRIVER] callbacks and constant info from driver + * @clock_id: [INTERN] timestamping clock posix identifier * @info_exist_lock: [INTERN] lock to prevent use during removal * @setup_ops: [DRIVER] callbacks to call before and after buffer * enable/disable @@ -537,6 +533,7 @@ struct iio_dev { struct attribute_group chan_attr_group; const char *name; const struct iio_info *info; + clockid_t clock_id; struct mutex info_exist_lock; const struct iio_buffer_setup_ops *setup_ops; struct cdev chrdev; @@ -565,7 +562,7 @@ extern struct bus_type iio_bus_type; /** * iio_device_put() - reference counted deallocation of struct device - * @indio_dev: IIO device structure containing the device + * @indio_dev: IIO device structure containing the device **/ static inline void iio_device_put(struct iio_dev *indio_dev) { @@ -574,6 +571,15 @@ static inline void iio_device_put(struct iio_dev *indio_dev) } /** + * iio_device_get_clock() - Retrieve current timestamping clock for the device + * @indio_dev: IIO device structure containing the device + */ +static inline clockid_t iio_device_get_clock(const struct iio_dev *indio_dev) +{ + return indio_dev->clock_id; +} + +/** * dev_to_iio_dev() - Get IIO device struct from a device struct * @dev: The device embedded in the IIO device * -- cgit v1.1 From 8d2c7ef80bc8a66b8c6d657a857403f93952604f Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Jun 2016 03:48:45 +0200 Subject: iio: pressure: bmp280: augment DT bindings This adds standard device tree bindings for a reset GPIO line, and the VDDD and VDDA power regulators. Cc: devicetree@vger.kernel.org Acked-by: Rob Herring Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/pressure/bmp085.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/pressure/bmp085.txt b/Documentation/devicetree/bindings/iio/pressure/bmp085.txt index d7a6deb..c7198a0 100644 --- a/Documentation/devicetree/bindings/iio/pressure/bmp085.txt +++ b/Documentation/devicetree/bindings/iio/pressure/bmp085.txt @@ -1,7 +1,11 @@ -BMP085/BMP18x digital pressure sensors +BMP085/BMP18x/BMP28x digital pressure sensors Required properties: -- compatible: bosch,bmp085 +- compatible: must be one of: + "bosch,bmp085" + "bosch,bmp180" + "bosch,bmp280" + "bosch,bme280" Optional properties: - chip-id: configurable chip id for non-default chip revisions @@ -10,6 +14,10 @@ Optional properties: value range is 0-3 with rising sensitivity. - interrupt-parent: should be the phandle for the interrupt controller - interrupts: interrupt mapping for IRQ +- reset-gpios: a GPIO line handling reset of the sensor: as the line is + active low, it should be marked GPIO_ACTIVE_LOW (see gpio/gpio.txt) +- vddd-supply: digital voltage regulator (see regulator/regulator.txt) +- vdda-supply: analog voltage regulator (see regulator/regulator.txt) Example: @@ -21,4 +29,7 @@ pressure@77 { default-oversampling = <2>; interrupt-parent = <&gpio0>; interrupts = <25 IRQ_TYPE_EDGE_RISING>; + reset-gpios = <&gpio0 26 GPIO_ACTIVE_LOW>; + vddd-supply = <&foo>; + vdda-supply = <&bar>; }; -- cgit v1.1 From 78f5027132243b7071dc59ea6f717e2c48e12031 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Jun 2016 03:48:46 +0200 Subject: iio: pressure: bmp280: support device tree initialization This adds device tree support to the BMP085, BMP180 and BMP280 pressure sensors. Tested on the Qualcomm APQ8060 Dragonboard: iio:device1$ cat in_temp_input 26700 iio:device1$ cat in_pressure_input 99.185000000 Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/bmp280.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c index dbbcd6d..a147ce2 100644 --- a/drivers/iio/pressure/bmp280.c +++ b/drivers/iio/pressure/bmp280.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1094,6 +1095,19 @@ static const struct acpi_device_id bmp280_acpi_match[] = { }; MODULE_DEVICE_TABLE(acpi, bmp280_acpi_match); +#ifdef CONFIG_OF +static const struct of_device_id bmp280_of_match[] = { + { .compatible = "bosch,bme280", .data = (void *)BME280_CHIP_ID }, + { .compatible = "bosch,bmp280", .data = (void *)BMP280_CHIP_ID }, + { .compatible = "bosch,bmp180", .data = (void *)BMP180_CHIP_ID }, + { .compatible = "bosch,bmp085", .data = (void *)BMP180_CHIP_ID }, + { }, +}; +MODULE_DEVICE_TABLE(of, bmp280_of_match); +#else +#define bmp280_of_match NULL +#endif + static const struct i2c_device_id bmp280_id[] = { {"bmp280", BMP280_CHIP_ID }, {"bmp180", BMP180_CHIP_ID }, @@ -1107,6 +1121,7 @@ static struct i2c_driver bmp280_driver = { .driver = { .name = "bmp280", .acpi_match_table = ACPI_PTR(bmp280_acpi_match), + .of_match_table = of_match_ptr(bmp280_of_match), }, .probe = bmp280_probe, .id_table = bmp280_id, -- cgit v1.1 From c5842b47b2945d6db24b4db6b2c7364e94cbc78b Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Jun 2016 03:48:47 +0200 Subject: iio: pressure: bmp280: add reset GPIO line handling On the APQ8060 Dragonboard the reset line to the BMP085 pressure sensor is not deasserted on boot, so the driver needs to handle this. For a simple GPIO line supplied as a descriptor (from a board file, device tree or ACPI) this does the trick. Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/bmp280.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c index a147ce2..77172f0 100644 --- a/drivers/iio/pressure/bmp280.c +++ b/drivers/iio/pressure/bmp280.c @@ -23,6 +23,7 @@ #include #include #include +#include /* BMP280 specific registers */ #define BMP280_REG_HUMIDITY_LSB 0xFE @@ -1024,6 +1025,7 @@ static int bmp280_probe(struct i2c_client *client, struct iio_dev *indio_dev; struct bmp280_data *data; unsigned int chip_id; + struct gpio_desc *gpiod; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); if (!indio_dev) @@ -1063,6 +1065,14 @@ static int bmp280_probe(struct i2c_client *client, return -EINVAL; } + /* Bring chip out of reset if there is an assigned GPIO line */ + gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH); + /* Deassert the signal */ + if (!IS_ERR(gpiod)) { + dev_info(&client->dev, "release reset\n"); + gpiod_set_value(gpiod, 0); + } + data->regmap = devm_regmap_init_i2c(client, data->chip_info->regmap_config); if (IS_ERR(data->regmap)) { -- cgit v1.1 From 90e96fdd012925871a1a21b5eaeab4b027682d6a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 29 Jun 2016 14:08:33 +0200 Subject: iio: magn: ak8975: fix regulator usage IS_ERR_OR_NULL() should never be used with regulators because a NULL pointer may be a perfectly valid dummy regulator We should always succeed to fetch and enable a regulator, but it may be a dummy. That is fine, so bail out for any real errors or probe deferrals Include the error code in the warning print so we know what kind of problem we're dealing with (for example it is nice to see if it is a probe deferral). As we will bail out of probe if the regulator is erroneous, just issue regulator_disable() on the poweroff path: it will succeed. Cc: Mark Brown Cc: Lars-Peter Clausen Lars-Peter Clausen Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/ak8975.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index 2121b50..def693c 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -389,17 +389,16 @@ static int ak8975_power_on(struct i2c_client *client) int ret; data->vdd = devm_regulator_get(&client->dev, "vdd"); - if (IS_ERR_OR_NULL(data->vdd)) { + if (IS_ERR(data->vdd)) { ret = PTR_ERR(data->vdd); - if (ret == -ENODEV) - ret = 0; } else { ret = regulator_enable(data->vdd); } - - if (ret) - dev_err(&client->dev, "failed to enable Vdd supply: %d\n", ret); - return ret; + if (ret) { + dev_warn(&client->dev, + "Failed to enable specified Vdd supply\n"); + return ret; + } } /* Disable attached power regulator if any. */ @@ -408,8 +407,7 @@ static void ak8975_power_off(const struct i2c_client *client) const struct iio_dev *indio_dev = i2c_get_clientdata(client); const struct ak8975_data *data = iio_priv(indio_dev); - if (!IS_ERR_OR_NULL(data->vdd)) - regulator_disable(data->vdd); + regulator_disable(data->vdd); } /* -- cgit v1.1 From b21d3f3452ec3a060c8f576a97adfdd4329b3157 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 29 Jun 2016 14:08:34 +0200 Subject: iio: magn: ak8975: add Vid regulator The AK8975 has two power sources: Vdd (analog voltage supply) and Vid (digital voltage supply). Optionally also obtain the Vid supply regulator and enable it. If an error occurs when enabling one of the regulators: bail out. Cc: Gregor Boirie Cc: Richard Leitner Cc: Krzysztof Kozlowski Cc: Lars-Peter Clausen Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/ak8975.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index def693c..ca69f8d 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -379,6 +379,7 @@ struct ak8975_data { u8 cntl_cache; struct iio_mount_matrix orientation; struct regulator *vdd; + struct regulator *vid; }; /* Enable attached power regulator if any. */ @@ -399,6 +400,19 @@ static int ak8975_power_on(struct i2c_client *client) "Failed to enable specified Vdd supply\n"); return ret; } + + data->vid = devm_regulator_get(&client->dev, "vid"); + if (IS_ERR(data->vid)) { + ret = PTR_ERR(data->vid); + } else { + ret = regulator_enable(data->vid); + } + if (ret) { + dev_warn(&client->dev, + "Failed to enable specified Vid supply\n"); + return ret; + } + return 0; } /* Disable attached power regulator if any. */ @@ -407,6 +421,7 @@ static void ak8975_power_off(const struct i2c_client *client) const struct iio_dev *indio_dev = i2c_get_clientdata(client); const struct ak8975_data *data = iio_priv(indio_dev); + regulator_disable(data->vid); regulator_disable(data->vdd); } -- cgit v1.1 From 9e6c16d98987f6d5df8e59f61b20140d2f1bdcb4 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 29 Jun 2016 14:08:35 +0200 Subject: iio: magn: ak8975: refactor regulator handlers Move the regulator_get() calls directly into the probe() function, keep only the power_on()/power_off() functions to flick the regulators on/off. Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/ak8975.c | 43 ++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index ca69f8d..6915bd1 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -383,32 +383,19 @@ struct ak8975_data { }; /* Enable attached power regulator if any. */ -static int ak8975_power_on(struct i2c_client *client) +static int ak8975_power_on(const struct ak8975_data *data) { - const struct iio_dev *indio_dev = i2c_get_clientdata(client); - struct ak8975_data *data = iio_priv(indio_dev); int ret; - data->vdd = devm_regulator_get(&client->dev, "vdd"); - if (IS_ERR(data->vdd)) { - ret = PTR_ERR(data->vdd); - } else { - ret = regulator_enable(data->vdd); - } + ret = regulator_enable(data->vdd); if (ret) { - dev_warn(&client->dev, + dev_warn(&data->client->dev, "Failed to enable specified Vdd supply\n"); return ret; } - - data->vid = devm_regulator_get(&client->dev, "vid"); - if (IS_ERR(data->vid)) { - ret = PTR_ERR(data->vid); - } else { - ret = regulator_enable(data->vid); - } + ret = regulator_enable(data->vid); if (ret) { - dev_warn(&client->dev, + dev_warn(&data->client->dev, "Failed to enable specified Vid supply\n"); return ret; } @@ -416,11 +403,8 @@ static int ak8975_power_on(struct i2c_client *client) } /* Disable attached power regulator if any. */ -static void ak8975_power_off(const struct i2c_client *client) +static void ak8975_power_off(const struct ak8975_data *data) { - const struct iio_dev *indio_dev = i2c_get_clientdata(client); - const struct ak8975_data *data = iio_priv(indio_dev); - regulator_disable(data->vid); regulator_disable(data->vdd); } @@ -937,7 +921,15 @@ static int ak8975_probe(struct i2c_client *client, data->def = &ak_def_array[chipset]; - err = ak8975_power_on(client); + /* Fetch the regulators */ + data->vdd = devm_regulator_get(&client->dev, "vdd"); + if (IS_ERR(data->vdd)) + return PTR_ERR(data->vdd); + data->vid = devm_regulator_get(&client->dev, "vid"); + if (IS_ERR(data->vid)) + return PTR_ERR(data->vid); + + err = ak8975_power_on(data); if (err) return err; @@ -982,17 +974,18 @@ static int ak8975_probe(struct i2c_client *client, cleanup_buffer: iio_triggered_buffer_cleanup(indio_dev); power_off: - ak8975_power_off(client); + ak8975_power_off(data); return err; } static int ak8975_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct ak8975_data *data = iio_priv(indio_dev); iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); - ak8975_power_off(client); + ak8975_power_off(data); return 0; } -- cgit v1.1 From b1037c1a498f9bb3b5a81c2f243c605c190da754 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 29 Jun 2016 14:08:36 +0200 Subject: iio: magn: ak8975: allow a delay after enabling regulators The datasheet actually specifies that we need to wait atleast 500us after powering on the device before trying to set mode. Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/ak8975.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index 6915bd1..bf3ffc4 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -399,6 +399,12 @@ static int ak8975_power_on(const struct ak8975_data *data) "Failed to enable specified Vid supply\n"); return ret; } + /* + * According to the datasheet the power supply rise time i 200us + * and the minimum wait time before mode setting is 100us, in + * total 300 us. Add some margin and say minimum 500us here. + */ + usleep_range(500, 1000); return 0; } -- cgit v1.1 From 8d06cd25f745db8905e303cc915932cc50aa0ae5 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 29 Jun 2016 14:08:37 +0200 Subject: iio: magn: ak8975: make sure to power down at remove() The code was not powering the magnetometer down properly at remove(): just cutting the regulators without first setting the device in power off mode. Fix this. Signed-off-by: Linus Walleij Reviewed-by: Ulf Hansson Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/ak8975.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index bf3ffc4..3e12201 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -991,6 +991,7 @@ static int ak8975_remove(struct i2c_client *client) iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); + ak8975_set_mode(data, POWER_DOWN); ak8975_power_off(data); return 0; -- cgit v1.1 From cde4cb5dd4221a3999ea804e85ad3dc48f3f5b78 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 29 Jun 2016 14:08:38 +0200 Subject: iio: magn: ak8975: deploy runtime and system PM This adds runtime PM support to the AK8975 driver. It solves two problems: - After reading the first value the chip was left in MODE_ONCE, meaning (presumably) it may be consuming more power. Now the runtime PM hooks kick in and set it to POWER_DOWN. - Regulators were simply enabled and left on, making it impossible to turn the power consuming regulators off because of the increased refcount. We now disable the regulators at autosuspend. - We also handle system suspend: by using pm_runtime_force_suspend() and pm_runtime_force_resume() from the system PM sleep hooks, the runtime PM code is managing the power also for this case. It is currently not completely optimal: when the system resumes the AK8975 goes into active mode even if noone is going to use it: currently the force calls need to be paired, but the runtime PM people are working on making it possible to leave devices runtime suspended when coming back from sleep. Inspired by my work on the BH1780 light sensor driver. Signed-off-by: Linus Walleij Reviewed-by: Ulf Hansson Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/ak8975.c | 72 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index 3e12201..af8606c 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -692,6 +693,8 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val) u16 buff; int ret; + pm_runtime_get_sync(&data->client->dev); + mutex_lock(&data->lock); ret = ak8975_start_read_axis(data, client); @@ -706,6 +709,9 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val) mutex_unlock(&data->lock); + pm_runtime_mark_last_busy(&data->client->dev); + pm_runtime_put_autosuspend(&data->client->dev); + /* Swap bytes and convert to valid range. */ buff = le16_to_cpu(buff); *val = clamp_t(s16, buff, -def->range, def->range); @@ -975,6 +981,18 @@ static int ak8975_probe(struct i2c_client *client, goto cleanup_buffer; } + /* Enable runtime PM */ + pm_runtime_get_noresume(&client->dev); + pm_runtime_set_active(&client->dev); + pm_runtime_enable(&client->dev); + /* + * The device comes online in 500us, so add two orders of magnitude + * of delay before autosuspending: 50 ms. + */ + pm_runtime_set_autosuspend_delay(&client->dev, 50); + pm_runtime_use_autosuspend(&client->dev); + pm_runtime_put(&client->dev); + return 0; cleanup_buffer: @@ -989,6 +1007,9 @@ static int ak8975_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); struct ak8975_data *data = iio_priv(indio_dev); + pm_runtime_get_sync(&client->dev); + pm_runtime_put_noidle(&client->dev); + pm_runtime_disable(&client->dev); iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); ak8975_set_mode(data, POWER_DOWN); @@ -997,6 +1018,56 @@ static int ak8975_remove(struct i2c_client *client) return 0; } +#ifdef CONFIG_PM +static int ak8975_runtime_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct ak8975_data *data = iio_priv(indio_dev); + int ret; + + /* Set the device in power down if it wasn't already */ + ret = ak8975_set_mode(data, POWER_DOWN); + if (ret < 0) { + dev_err(&client->dev, "Error in setting power-down mode\n"); + return ret; + } + /* Next cut the regulators */ + ak8975_power_off(data); + + return 0; +} + +static int ak8975_runtime_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct ak8975_data *data = iio_priv(indio_dev); + int ret; + + /* Take up the regulators */ + ak8975_power_on(data); + /* + * We come up in powered down mode, the reading routines will + * put us in the mode to read values later. + */ + ret = ak8975_set_mode(data, POWER_DOWN); + if (ret < 0) { + dev_err(&client->dev, "Error in setting power-down mode\n"); + return ret; + } + + return 0; +} +#endif /* CONFIG_PM */ + +static const struct dev_pm_ops ak8975_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) + SET_RUNTIME_PM_OPS(ak8975_runtime_suspend, + ak8975_runtime_resume, NULL) +}; + static const struct i2c_device_id ak8975_id[] = { {"ak8975", AK8975}, {"ak8963", AK8963}, @@ -1024,6 +1095,7 @@ MODULE_DEVICE_TABLE(of, ak8975_of_match); static struct i2c_driver ak8975_driver = { .driver = { .name = "ak8975", + .pm = &ak8975_dev_pm_ops, .of_match_table = of_match_ptr(ak8975_of_match), .acpi_match_table = ACPI_PTR(ak_acpi_match), }, -- cgit v1.1 From 90efe05562921768d34e44c0292703ea3168ba8d Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 29 Jun 2016 15:14:42 +0200 Subject: iio: st_sensors: harden interrupt handling Leonard Crestez observed the following phenomenon: when using hard interrupt triggers (the DRDY line coming out of an ST sensor) sometimes a new value would arrive while reading the previous value, due to latencies in the system. We discovered that the ST hardware as far as can be observed is designed for level interrupts: the DRDY line will be held asserted as long as there are new values coming. The interrupt handler should be re-entered until we're out of values to handle from the sensor. If interrupts were handled as occurring on the edges (usually low-to-high) new values could appear and the line be held asserted after that, and these values would be missed, the interrupt handler would also lock up as new data was available, but as no new edges occurs on the DRDY signal, nothing happens: the edge detector only detects edges. To counter this, do the following: - Accept interrupt lines to be flagged as level interrupts using IRQF_TRIGGER_HIGH and IRQF_TRIGGER_LOW. If the line is marked like this (in the device tree node or ACPI table or similar) it will be utilized as a level IRQ. We mark the line with IRQF_ONESHOT and mask the IRQ while processing a sample, then the top half will be entered again if new values are available. - If we are flagged as using edge interrupts with IRQF_TRIGGER_RISING or IRQF_TRIGGER_FALLING: remove IRQF_ONESHOT so that the interrupt line is not masked while running the thread part of the interrupt. This way we will never miss an interrupt, then introduce a loop that polls the data ready registers repeatedly until no new samples are available, then exit the interrupt handler. This way we know no new values are available when the interrupt handler exits and new (edge) interrupts will be triggered when data arrives. Take some extra care to update the timestamp in the poll loop if this happens. The timestamp will not be 100% perfect, but it will at least be closer to the actual events. Usually the extra poll loop will handle the new samples, but once in a blue moon, we get a new IRQ while exiting the loop, before returning from the thread IRQ bottom half with IRQ_HANDLED. On these rare occasions, the removal of IRQF_ONESHOT means the interrupt will immediately fire again. - If no interrupt type is indicated from the DT/ACPI, choose IRQF_TRIGGER_RISING as default, as this is necessary for legacy boards. Tested successfully on the LIS331DL and L3G4200D by setting sampling frequency to 400Hz/800Hz and stressing the system: extra reads in the threaded interrupt handler occurs. Cc: Giuseppe Barba Cc: Denis Ciocca Tested-by: Crestez Dan Leonard Reported-by: Crestez Dan Leonard Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/common/st_sensors/st_sensors_buffer.c | 7 +- drivers/iio/common/st_sensors/st_sensors_trigger.c | 154 +++++++++++++++------ include/linux/iio/common/st_sensors.h | 2 + 3 files changed, 117 insertions(+), 46 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c index 7c84e90..2371fc8 100644 --- a/drivers/iio/common/st_sensors/st_sensors_buffer.c +++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c @@ -58,7 +58,12 @@ irqreturn_t st_sensors_trigger_handler(int irq, void *p) struct st_sensor_data *sdata = iio_priv(indio_dev); s64 timestamp; - /* If we do timetamping here, do it before reading the values */ + /* + * If we do timetamping here, do it before reading the values, because + * once we've read the values, new interrupts can occur (when using + * the hardware trigger) and the hw_timestamp may get updated. + * By storing it in a local variable first, we are safe. + */ if (sdata->hw_irq_trigger) timestamp = sdata->hw_timestamp; else diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c index fab494d..e66f12e 100644 --- a/drivers/iio/common/st_sensors/st_sensors_trigger.c +++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c @@ -18,6 +18,50 @@ #include "st_sensors_core.h" /** + * st_sensors_new_samples_available() - check if more samples came in + * returns: + * 0 - no new samples available + * 1 - new samples available + * negative - error or unknown + */ +static int st_sensors_new_samples_available(struct iio_dev *indio_dev, + struct st_sensor_data *sdata) +{ + u8 status; + int ret; + + /* How would I know if I can't check it? */ + if (!sdata->sensor_settings->drdy_irq.addr_stat_drdy) + return -EINVAL; + + /* No scan mask, no interrupt */ + if (!indio_dev->active_scan_mask) + return 0; + + ret = sdata->tf->read_byte(&sdata->tb, sdata->dev, + sdata->sensor_settings->drdy_irq.addr_stat_drdy, + &status); + if (ret < 0) { + dev_err(sdata->dev, + "error checking samples available\n"); + return ret; + } + /* + * the lower bits of .active_scan_mask[0] is directly mapped + * to the channels on the sensor: either bit 0 for + * one-dimensional sensors, or e.g. x,y,z for accelerometers, + * gyroscopes or magnetometers. No sensor use more than 3 + * channels, so cut the other status bits here. + */ + status &= 0x07; + + if (status & (u8)indio_dev->active_scan_mask[0]) + return 1; + + return 0; +} + +/** * st_sensors_irq_handler() - top half of the IRQ-based triggers * @irq: irq number * @p: private handler data @@ -43,44 +87,43 @@ irqreturn_t st_sensors_irq_thread(int irq, void *p) struct iio_trigger *trig = p; struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); struct st_sensor_data *sdata = iio_priv(indio_dev); - int ret; /* * If this trigger is backed by a hardware interrupt and we have a - * status register, check if this IRQ came from us + * status register, check if this IRQ came from us. Notice that + * we will process also if st_sensors_new_samples_available() + * returns negative: if we can't check status, then poll + * unconditionally. */ - if (sdata->sensor_settings->drdy_irq.addr_stat_drdy) { - u8 status; - - ret = sdata->tf->read_byte(&sdata->tb, sdata->dev, - sdata->sensor_settings->drdy_irq.addr_stat_drdy, - &status); - if (ret < 0) { - dev_err(sdata->dev, "could not read channel status\n"); - goto out_poll; - } - /* - * the lower bits of .active_scan_mask[0] is directly mapped - * to the channels on the sensor: either bit 0 for - * one-dimensional sensors, or e.g. x,y,z for accelerometers, - * gyroscopes or magnetometers. No sensor use more than 3 - * channels, so cut the other status bits here. - */ - status &= 0x07; + if (sdata->hw_irq_trigger && + st_sensors_new_samples_available(indio_dev, sdata)) { + iio_trigger_poll_chained(p); + } else { + dev_dbg(sdata->dev, "spurious IRQ\n"); + return IRQ_NONE; + } - /* - * If this was not caused by any channels on this sensor, - * return IRQ_NONE - */ - if (!indio_dev->active_scan_mask) - return IRQ_NONE; - if (!(status & (u8)indio_dev->active_scan_mask[0])) - return IRQ_NONE; + /* + * If we have proper level IRQs the handler will be re-entered if + * the line is still active, so return here and come back in through + * the top half if need be. + */ + if (!sdata->edge_irq) + return IRQ_HANDLED; + + /* + * If we are using egde IRQs, new samples arrived while processing + * the IRQ and those may be missed unless we pick them here, so poll + * again. If the sensor delivery frequency is very high, this thread + * turns into a polled loop handler. + */ + while (sdata->hw_irq_trigger && + st_sensors_new_samples_available(indio_dev, sdata)) { + dev_dbg(sdata->dev, "more samples came in during polling\n"); + sdata->hw_timestamp = iio_get_time_ns(indio_dev); + iio_trigger_poll_chained(p); } -out_poll: - /* It's our IRQ: proceed to handle the register polling */ - iio_trigger_poll_chained(p); return IRQ_HANDLED; } @@ -107,13 +150,18 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev, * If the IRQ is triggered on falling edge, we need to mark the * interrupt as active low, if the hardware supports this. */ - if (irq_trig == IRQF_TRIGGER_FALLING) { + switch(irq_trig) { + case IRQF_TRIGGER_FALLING: + case IRQF_TRIGGER_LOW: if (!sdata->sensor_settings->drdy_irq.addr_ihl) { dev_err(&indio_dev->dev, - "falling edge specified for IRQ but hardware " - "only support rising edge, will request " - "rising edge\n"); - irq_trig = IRQF_TRIGGER_RISING; + "falling/low specified for IRQ " + "but hardware only support rising/high: " + "will request rising/high\n"); + if (irq_trig == IRQF_TRIGGER_FALLING) + irq_trig = IRQF_TRIGGER_RISING; + if (irq_trig == IRQF_TRIGGER_LOW) + irq_trig = IRQF_TRIGGER_HIGH; } else { /* Set up INT active low i.e. falling edge */ err = st_sensors_write_data_with_mask(indio_dev, @@ -122,20 +170,39 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev, if (err < 0) goto iio_trigger_free; dev_info(&indio_dev->dev, - "interrupts on the falling edge\n"); + "interrupts on the falling edge or " + "active low level\n"); } - } else if (irq_trig == IRQF_TRIGGER_RISING) { + break; + case IRQF_TRIGGER_RISING: dev_info(&indio_dev->dev, "interrupts on the rising edge\n"); - - } else { + break; + case IRQF_TRIGGER_HIGH: + dev_info(&indio_dev->dev, + "interrupts active high level\n"); + break; + default: + /* This is the most preferred mode, if possible */ dev_err(&indio_dev->dev, - "unsupported IRQ trigger specified (%lx), only " - "rising and falling edges supported, enforce " + "unsupported IRQ trigger specified (%lx), enforce " "rising edge\n", irq_trig); irq_trig = IRQF_TRIGGER_RISING; } + /* Tell the interrupt handler that we're dealing with edges */ + if (irq_trig == IRQF_TRIGGER_FALLING || + irq_trig == IRQF_TRIGGER_RISING) + sdata->edge_irq = true; + else + /* + * If we're not using edges (i.e. level interrupts) we + * just mask off the IRQ, handle one interrupt, then + * if the line is still low, we return to the + * interrupt handler top half again and start over. + */ + irq_trig |= IRQF_ONESHOT; + /* * If the interrupt pin is Open Drain, by definition this * means that the interrupt line may be shared with other @@ -148,9 +215,6 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev, sdata->sensor_settings->drdy_irq.addr_stat_drdy) irq_trig |= IRQF_SHARED; - /* Let's create an interrupt thread masking the hard IRQ here */ - irq_trig |= IRQF_ONESHOT; - err = request_threaded_irq(sdata->get_irq_data_ready(indio_dev), st_sensors_irq_handler, st_sensors_irq_thread, diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index 28052cd..228bd44 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -223,6 +223,7 @@ struct st_sensor_settings { * @get_irq_data_ready: Function to get the IRQ used for data ready signal. * @tf: Transfer function structure used by I/O operations. * @tb: Transfer buffers and mutex used by I/O operations. + * @edge_irq: the IRQ triggers on edges and need special handling. * @hw_irq_trigger: if we're using the hardware interrupt on the sensor. * @hw_timestamp: Latest timestamp from the interrupt handler, when in use. */ @@ -250,6 +251,7 @@ struct st_sensor_data { const struct st_sensor_transfer_function *tf; struct st_sensor_transfer_buffer tb; + bool edge_irq; bool hw_irq_trigger; s64 hw_timestamp; }; -- cgit v1.1 From 60b1addba2de4267bfd07ce7e769b30e9f074c2a Mon Sep 17 00:00:00 2001 From: Bijosh Thykkoottathil Date: Mon, 27 Jun 2016 15:37:41 +0000 Subject: drivers:iio:light:isl29125: added macros for sensing range Added macros for sensing range as the corresponding magic numbers were used at multiple places. - ISL29125_SENSING_RANGE_0 for 375 lux full range - ISL29125_SENSING_RANGE_1 for 10k lux full range Signed-off-by: Bijosh Thykkoottathil Signed-off-by: Jonathan Cameron --- drivers/iio/light/isl29125.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c index f48b9e5..1d2c0c8 100644 --- a/drivers/iio/light/isl29125.c +++ b/drivers/iio/light/isl29125.c @@ -44,6 +44,9 @@ #define ISL29125_MODE_B 0x3 #define ISL29125_MODE_RGB 0x5 +#define ISL29125_SENSING_RANGE_0 5722 /* 375 lux full range */ +#define ISL29125_SENSING_RANGE_1 152590 /* 10k lux full range */ + #define ISL29125_MODE_RANGE BIT(3) #define ISL29125_STATUS_CONV BIT(1) @@ -139,9 +142,9 @@ static int isl29125_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: *val = 0; if (data->conf1 & ISL29125_MODE_RANGE) - *val2 = 152590; /* 10k lux full range */ + *val2 = ISL29125_SENSING_RANGE_1; /*10k lux full range*/ else - *val2 = 5722; /* 375 lux full range */ + *val2 = ISL29125_SENSING_RANGE_0; /*375 lux full range*/ return IIO_VAL_INT_PLUS_MICRO; } return -EINVAL; @@ -157,9 +160,9 @@ static int isl29125_write_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: if (val != 0) return -EINVAL; - if (val2 == 152590) + if (val2 == ISL29125_SENSING_RANGE_1) data->conf1 |= ISL29125_MODE_RANGE; - else if (val2 == 5722) + else if (val2 == ISL29125_SENSING_RANGE_0) data->conf1 &= ~ISL29125_MODE_RANGE; else return -EINVAL; -- cgit v1.1 From bd525e6c7521c45785c87d6ecade4e047634cd3c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Jun 2016 03:48:48 +0200 Subject: iio: pressure: bmp280: support supply regulators The BMP085/BMP180/BMP280 is supplied with two power sources: VDDA (analog power) and VDDD (digital power). As these may come from regulators (as on the APQ8060 Dragonboard) we need the driver to attempt to fetch and enable these regulators. We FAIL if we cannot: boards should either define: - Proper regulators if present - Define fixed regulators if power is hardwired to the component - Rely on dummy regulators (will be present on all DT systems and any boardfile system that calls regulator_has_full_constraints(). Cc: Mark Brown Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/bmp280.c | 66 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c index 77172f0..f5d0875 100644 --- a/drivers/iio/pressure/bmp280.c +++ b/drivers/iio/pressure/bmp280.c @@ -24,6 +24,7 @@ #include #include #include +#include /* BMP280 specific registers */ #define BMP280_REG_HUMIDITY_LSB 0xFE @@ -124,6 +125,9 @@ struct bmp280_data { struct mutex lock; struct regmap *regmap; const struct bmp280_chip_info *chip_info; + struct regulator *vddd; + struct regulator *vdda; + unsigned int start_up_time; /* in milliseconds */ /* log of base 2 of oversampling rate */ u8 oversampling_press; @@ -1047,12 +1051,14 @@ static int bmp280_probe(struct i2c_client *client, data->chip_info = &bmp180_chip_info; data->oversampling_press = ilog2(8); data->oversampling_temp = ilog2(1); + data->start_up_time = 10; break; case BMP280_CHIP_ID: indio_dev->num_channels = 2; data->chip_info = &bmp280_chip_info; data->oversampling_press = ilog2(16); data->oversampling_temp = ilog2(2); + data->start_up_time = 2; break; case BME280_CHIP_ID: indio_dev->num_channels = 3; @@ -1060,11 +1066,37 @@ static int bmp280_probe(struct i2c_client *client, data->oversampling_press = ilog2(16); data->oversampling_humid = ilog2(16); data->oversampling_temp = ilog2(2); + data->start_up_time = 2; break; default: return -EINVAL; } + /* Bring up regulators */ + data->vddd = devm_regulator_get(&client->dev, "vddd"); + if (IS_ERR(data->vddd)) { + dev_err(&client->dev, "failed to get VDDD regulator\n"); + return PTR_ERR(data->vddd); + } + ret = regulator_enable(data->vddd); + if (ret) { + dev_err(&client->dev, "failed to enable VDDD regulator\n"); + return ret; + } + data->vdda = devm_regulator_get(&client->dev, "vdda"); + if (IS_ERR(data->vdda)) { + dev_err(&client->dev, "failed to get VDDA regulator\n"); + ret = PTR_ERR(data->vddd); + goto out_disable_vddd; + } + ret = regulator_enable(data->vdda); + if (ret) { + dev_err(&client->dev, "failed to enable VDDA regulator\n"); + goto out_disable_vddd; + } + /* Wait to make sure we started up properly */ + mdelay(data->start_up_time); + /* Bring chip out of reset if there is an assigned GPIO line */ gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH); /* Deassert the signal */ @@ -1077,7 +1109,8 @@ static int bmp280_probe(struct i2c_client *client, data->chip_info->regmap_config); if (IS_ERR(data->regmap)) { dev_err(&client->dev, "failed to allocate register map\n"); - return PTR_ERR(data->regmap); + ret = PTR_ERR(data->regmap); + goto out_disable_vdda; } ret = regmap_read(data->regmap, BMP280_REG_ID, &chip_id); @@ -1086,14 +1119,38 @@ static int bmp280_probe(struct i2c_client *client, if (chip_id != id->driver_data) { dev_err(&client->dev, "bad chip id. expected %lx got %x\n", id->driver_data, chip_id); - return -EINVAL; + ret = -EINVAL; + goto out_disable_vdda; } ret = data->chip_info->chip_config(data); if (ret < 0) - return ret; + goto out_disable_vdda; - return devm_iio_device_register(&client->dev, indio_dev); + i2c_set_clientdata(client, indio_dev); + + ret = iio_device_register(indio_dev); + if (ret) + goto out_disable_vdda; + + return 0; + +out_disable_vdda: + regulator_disable(data->vdda); +out_disable_vddd: + regulator_disable(data->vddd); + return ret; +} + +static int bmp280_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct bmp280_data *data = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + regulator_disable(data->vdda); + regulator_disable(data->vddd); + return 0; } static const struct acpi_device_id bmp280_acpi_match[] = { @@ -1134,6 +1191,7 @@ static struct i2c_driver bmp280_driver = { .of_match_table = of_match_ptr(bmp280_of_match), }, .probe = bmp280_probe, + .remove = bmp280_remove, .id_table = bmp280_id, }; module_i2c_driver(bmp280_driver); -- cgit v1.1 From 14e8015f8569d9634479a4a461e7c138d60d99ca Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Jun 2016 03:48:49 +0200 Subject: iio: pressure: bmp280: split driver in logical parts This splits the BMP280 driver in three logical parts: the core driver bmp280-core that only operated on a struct device * and a struct regmap *, the regmap driver bmp280-regmap that can be shared between I2C and other transports and the I2C module driver bmp280-i2c. Cleverly bake all functionality into a single object bmp280.o so that we still get the same module binary built for the device in the end, without any fuzz exporting symbols to the left and right. Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/bmp280-core.c | 968 +++++++++++++++++++++++++++ drivers/iio/pressure/bmp280-i2c.c | 89 +++ drivers/iio/pressure/bmp280-regmap.c | 81 +++ drivers/iio/pressure/bmp280.c | 1201 ---------------------------------- drivers/iio/pressure/bmp280.h | 108 +++ 6 files changed, 1247 insertions(+), 1201 deletions(-) create mode 100644 drivers/iio/pressure/bmp280-core.c create mode 100644 drivers/iio/pressure/bmp280-i2c.c create mode 100644 drivers/iio/pressure/bmp280-regmap.c delete mode 100644 drivers/iio/pressure/bmp280.c create mode 100644 drivers/iio/pressure/bmp280.h diff --git a/drivers/iio/pressure/Makefile b/drivers/iio/pressure/Makefile index 17d6e7a..2d98a7f 100644 --- a/drivers/iio/pressure/Makefile +++ b/drivers/iio/pressure/Makefile @@ -4,6 +4,7 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_BMP280) += bmp280.o +bmp280-objs := bmp280-core.o bmp280-regmap.o bmp280-i2c.o obj-$(CONFIG_HID_SENSOR_PRESS) += hid-sensor-press.o obj-$(CONFIG_HP03) += hp03.o obj-$(CONFIG_MPL115) += mpl115.o diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c new file mode 100644 index 0000000..83b96fe --- /dev/null +++ b/drivers/iio/pressure/bmp280-core.c @@ -0,0 +1,968 @@ +/* + * Copyright (c) 2014 Intel Corporation + * + * Driver for Bosch Sensortec BMP180 and BMP280 digital pressure sensor. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Datasheet: + * https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMP180-DS000-121.pdf + * https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMP280-DS001-12.pdf + * https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME280_DS001-11.pdf + */ + +#define pr_fmt(fmt) "bmp280: " fmt + +#include +#include +#include +#include +#include +#include +#include + +#include "bmp280.h" + +struct bmp280_data { + struct device *dev; + struct mutex lock; + struct regmap *regmap; + const struct bmp280_chip_info *chip_info; + struct regulator *vddd; + struct regulator *vdda; + unsigned int start_up_time; /* in milliseconds */ + + /* log of base 2 of oversampling rate */ + u8 oversampling_press; + u8 oversampling_temp; + u8 oversampling_humid; + + /* + * Carryover value from temperature conversion, used in pressure + * calculation. + */ + s32 t_fine; +}; + +struct bmp280_chip_info { + const int *oversampling_temp_avail; + int num_oversampling_temp_avail; + + const int *oversampling_press_avail; + int num_oversampling_press_avail; + + const int *oversampling_humid_avail; + int num_oversampling_humid_avail; + + int (*chip_config)(struct bmp280_data *); + int (*read_temp)(struct bmp280_data *, int *); + int (*read_press)(struct bmp280_data *, int *, int *); + int (*read_humid)(struct bmp280_data *, int *, int *); +}; + +/* + * These enums are used for indexing into the array of compensation + * parameters for BMP280. + */ +enum { T1, T2, T3 }; +enum { P1, P2, P3, P4, P5, P6, P7, P8, P9 }; + +static const struct iio_chan_spec bmp280_channels[] = { + { + .type = IIO_PRESSURE, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), + }, + { + .type = IIO_TEMP, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), + }, + { + .type = IIO_HUMIDITYRELATIVE, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), + }, +}; + +/* + * Returns humidity in percent, resolution is 0.01 percent. Output value of + * "47445" represents 47445/1024 = 46.333 %RH. + * + * Taken from BME280 datasheet, Section 4.2.3, "Compensation formula". + */ + +static u32 bmp280_compensate_humidity(struct bmp280_data *data, + s32 adc_humidity) +{ + struct device *dev = data->dev; + unsigned int H1, H3, tmp; + int H2, H4, H5, H6, ret, var; + + ret = regmap_read(data->regmap, BMP280_REG_COMP_H1, &H1); + if (ret < 0) { + dev_err(dev, "failed to read H1 comp value\n"); + return ret; + } + + ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H2, &tmp, 2); + if (ret < 0) { + dev_err(dev, "failed to read H2 comp value\n"); + return ret; + } + H2 = sign_extend32(le16_to_cpu(tmp), 15); + + ret = regmap_read(data->regmap, BMP280_REG_COMP_H3, &H3); + if (ret < 0) { + dev_err(dev, "failed to read H3 comp value\n"); + return ret; + } + + ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H4, &tmp, 2); + if (ret < 0) { + dev_err(dev, "failed to read H4 comp value\n"); + return ret; + } + H4 = sign_extend32(((be16_to_cpu(tmp) >> 4) & 0xff0) | + (be16_to_cpu(tmp) & 0xf), 11); + + ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H5, &tmp, 2); + if (ret < 0) { + dev_err(dev, "failed to read H5 comp value\n"); + return ret; + } + H5 = sign_extend32(((le16_to_cpu(tmp) >> 4) & 0xfff), 11); + + ret = regmap_read(data->regmap, BMP280_REG_COMP_H6, &tmp); + if (ret < 0) { + dev_err(dev, "failed to read H6 comp value\n"); + return ret; + } + H6 = sign_extend32(tmp, 7); + + var = ((s32)data->t_fine) - 76800; + var = ((((adc_humidity << 14) - (H4 << 20) - (H5 * var)) + 16384) >> 15) + * (((((((var * H6) >> 10) * (((var * H3) >> 11) + 32768)) >> 10) + + 2097152) * H2 + 8192) >> 14); + var -= ((((var >> 15) * (var >> 15)) >> 7) * H1) >> 4; + + return var >> 12; +}; + +/* + * Returns temperature in DegC, resolution is 0.01 DegC. Output value of + * "5123" equals 51.23 DegC. t_fine carries fine temperature as global + * value. + * + * Taken from datasheet, Section 3.11.3, "Compensation formula". + */ +static s32 bmp280_compensate_temp(struct bmp280_data *data, + s32 adc_temp) +{ + int ret; + s32 var1, var2; + __le16 buf[BMP280_COMP_TEMP_REG_COUNT / 2]; + + ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_TEMP_START, + buf, BMP280_COMP_TEMP_REG_COUNT); + if (ret < 0) { + dev_err(data->dev, + "failed to read temperature calibration parameters\n"); + return ret; + } + + /* + * The double casts are necessary because le16_to_cpu returns an + * unsigned 16-bit value. Casting that value directly to a + * signed 32-bit will not do proper sign extension. + * + * Conversely, T1 and P1 are unsigned values, so they can be + * cast straight to the larger type. + */ + var1 = (((adc_temp >> 3) - ((s32)le16_to_cpu(buf[T1]) << 1)) * + ((s32)(s16)le16_to_cpu(buf[T2]))) >> 11; + var2 = (((((adc_temp >> 4) - ((s32)le16_to_cpu(buf[T1]))) * + ((adc_temp >> 4) - ((s32)le16_to_cpu(buf[T1])))) >> 12) * + ((s32)(s16)le16_to_cpu(buf[T3]))) >> 14; + data->t_fine = var1 + var2; + + return (data->t_fine * 5 + 128) >> 8; +} + +/* + * Returns pressure in Pa as unsigned 32 bit integer in Q24.8 format (24 + * integer bits and 8 fractional bits). Output value of "24674867" + * represents 24674867/256 = 96386.2 Pa = 963.862 hPa + * + * Taken from datasheet, Section 3.11.3, "Compensation formula". + */ +static u32 bmp280_compensate_press(struct bmp280_data *data, + s32 adc_press) +{ + int ret; + s64 var1, var2, p; + __le16 buf[BMP280_COMP_PRESS_REG_COUNT / 2]; + + ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_PRESS_START, + buf, BMP280_COMP_PRESS_REG_COUNT); + if (ret < 0) { + dev_err(data->dev, + "failed to read pressure calibration parameters\n"); + return ret; + } + + var1 = ((s64)data->t_fine) - 128000; + var2 = var1 * var1 * (s64)(s16)le16_to_cpu(buf[P6]); + var2 += (var1 * (s64)(s16)le16_to_cpu(buf[P5])) << 17; + var2 += ((s64)(s16)le16_to_cpu(buf[P4])) << 35; + var1 = ((var1 * var1 * (s64)(s16)le16_to_cpu(buf[P3])) >> 8) + + ((var1 * (s64)(s16)le16_to_cpu(buf[P2])) << 12); + var1 = ((((s64)1) << 47) + var1) * ((s64)le16_to_cpu(buf[P1])) >> 33; + + if (var1 == 0) + return 0; + + p = ((((s64)1048576 - adc_press) << 31) - var2) * 3125; + p = div64_s64(p, var1); + var1 = (((s64)(s16)le16_to_cpu(buf[P9])) * (p >> 13) * (p >> 13)) >> 25; + var2 = (((s64)(s16)le16_to_cpu(buf[P8])) * p) >> 19; + p = ((p + var1 + var2) >> 8) + (((s64)(s16)le16_to_cpu(buf[P7])) << 4); + + return (u32)p; +} + +static int bmp280_read_temp(struct bmp280_data *data, + int *val) +{ + int ret; + __be32 tmp = 0; + s32 adc_temp, comp_temp; + + ret = regmap_bulk_read(data->regmap, BMP280_REG_TEMP_MSB, + (u8 *) &tmp, 3); + if (ret < 0) { + dev_err(data->dev, "failed to read temperature\n"); + return ret; + } + + adc_temp = be32_to_cpu(tmp) >> 12; + comp_temp = bmp280_compensate_temp(data, adc_temp); + + /* + * val might be NULL if we're called by the read_press routine, + * who only cares about the carry over t_fine value. + */ + if (val) { + *val = comp_temp * 10; + return IIO_VAL_INT; + } + + return 0; +} + +static int bmp280_read_press(struct bmp280_data *data, + int *val, int *val2) +{ + int ret; + __be32 tmp = 0; + s32 adc_press; + u32 comp_press; + + /* Read and compensate temperature so we get a reading of t_fine. */ + ret = bmp280_read_temp(data, NULL); + if (ret < 0) + return ret; + + ret = regmap_bulk_read(data->regmap, BMP280_REG_PRESS_MSB, + (u8 *) &tmp, 3); + if (ret < 0) { + dev_err(data->dev, "failed to read pressure\n"); + return ret; + } + + adc_press = be32_to_cpu(tmp) >> 12; + comp_press = bmp280_compensate_press(data, adc_press); + + *val = comp_press; + *val2 = 256000; + + return IIO_VAL_FRACTIONAL; +} + +static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2) +{ + int ret; + __be16 tmp = 0; + s32 adc_humidity; + u32 comp_humidity; + + /* Read and compensate temperature so we get a reading of t_fine. */ + ret = bmp280_read_temp(data, NULL); + if (ret < 0) + return ret; + + ret = regmap_bulk_read(data->regmap, BMP280_REG_HUMIDITY_MSB, + (u8 *) &tmp, 2); + if (ret < 0) { + dev_err(data->dev, "failed to read humidity\n"); + return ret; + } + + adc_humidity = be16_to_cpu(tmp); + comp_humidity = bmp280_compensate_humidity(data, adc_humidity); + + *val = comp_humidity; + *val2 = 1024; + + return IIO_VAL_FRACTIONAL; +} + +static int bmp280_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + int ret; + struct bmp280_data *data = iio_priv(indio_dev); + + mutex_lock(&data->lock); + + switch (mask) { + case IIO_CHAN_INFO_PROCESSED: + switch (chan->type) { + case IIO_HUMIDITYRELATIVE: + ret = data->chip_info->read_humid(data, val, val2); + break; + case IIO_PRESSURE: + ret = data->chip_info->read_press(data, val, val2); + break; + case IIO_TEMP: + ret = data->chip_info->read_temp(data, val); + break; + default: + ret = -EINVAL; + break; + } + break; + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + switch (chan->type) { + case IIO_HUMIDITYRELATIVE: + *val = 1 << data->oversampling_humid; + ret = IIO_VAL_INT; + break; + case IIO_PRESSURE: + *val = 1 << data->oversampling_press; + ret = IIO_VAL_INT; + break; + case IIO_TEMP: + *val = 1 << data->oversampling_temp; + ret = IIO_VAL_INT; + break; + default: + ret = -EINVAL; + break; + } + break; + default: + ret = -EINVAL; + break; + } + + mutex_unlock(&data->lock); + + return ret; +} + +static int bmp280_write_oversampling_ratio_humid(struct bmp280_data *data, + int val) +{ + int i; + const int *avail = data->chip_info->oversampling_humid_avail; + const int n = data->chip_info->num_oversampling_humid_avail; + + for (i = 0; i < n; i++) { + if (avail[i] == val) { + data->oversampling_humid = ilog2(val); + + return data->chip_info->chip_config(data); + } + } + return -EINVAL; +} + +static int bmp280_write_oversampling_ratio_temp(struct bmp280_data *data, + int val) +{ + int i; + const int *avail = data->chip_info->oversampling_temp_avail; + const int n = data->chip_info->num_oversampling_temp_avail; + + for (i = 0; i < n; i++) { + if (avail[i] == val) { + data->oversampling_temp = ilog2(val); + + return data->chip_info->chip_config(data); + } + } + return -EINVAL; +} + +static int bmp280_write_oversampling_ratio_press(struct bmp280_data *data, + int val) +{ + int i; + const int *avail = data->chip_info->oversampling_press_avail; + const int n = data->chip_info->num_oversampling_press_avail; + + for (i = 0; i < n; i++) { + if (avail[i] == val) { + data->oversampling_press = ilog2(val); + + return data->chip_info->chip_config(data); + } + } + return -EINVAL; +} + +static int bmp280_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + int ret = 0; + struct bmp280_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + mutex_lock(&data->lock); + switch (chan->type) { + case IIO_HUMIDITYRELATIVE: + ret = bmp280_write_oversampling_ratio_humid(data, val); + break; + case IIO_PRESSURE: + ret = bmp280_write_oversampling_ratio_press(data, val); + break; + case IIO_TEMP: + ret = bmp280_write_oversampling_ratio_temp(data, val); + break; + default: + ret = -EINVAL; + break; + } + mutex_unlock(&data->lock); + break; + default: + return -EINVAL; + } + + return ret; +} + +static ssize_t bmp280_show_avail(char *buf, const int *vals, const int n) +{ + size_t len = 0; + int i; + + for (i = 0; i < n; i++) + len += scnprintf(buf + len, PAGE_SIZE - len, "%d ", vals[i]); + + buf[len - 1] = '\n'; + + return len; +} + +static ssize_t bmp280_show_temp_oversampling_avail(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct bmp280_data *data = iio_priv(dev_to_iio_dev(dev)); + + return bmp280_show_avail(buf, data->chip_info->oversampling_temp_avail, + data->chip_info->num_oversampling_temp_avail); +} + +static ssize_t bmp280_show_press_oversampling_avail(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct bmp280_data *data = iio_priv(dev_to_iio_dev(dev)); + + return bmp280_show_avail(buf, data->chip_info->oversampling_press_avail, + data->chip_info->num_oversampling_press_avail); +} + +static IIO_DEVICE_ATTR(in_temp_oversampling_ratio_available, + S_IRUGO, bmp280_show_temp_oversampling_avail, NULL, 0); + +static IIO_DEVICE_ATTR(in_pressure_oversampling_ratio_available, + S_IRUGO, bmp280_show_press_oversampling_avail, NULL, 0); + +static struct attribute *bmp280_attributes[] = { + &iio_dev_attr_in_temp_oversampling_ratio_available.dev_attr.attr, + &iio_dev_attr_in_pressure_oversampling_ratio_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group bmp280_attrs_group = { + .attrs = bmp280_attributes, +}; + +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, +}; + +static int bmp280_chip_config(struct bmp280_data *data) +{ + int ret; + u8 osrs = BMP280_OSRS_TEMP_X(data->oversampling_temp + 1) | + BMP280_OSRS_PRESS_X(data->oversampling_press + 1); + + ret = regmap_update_bits(data->regmap, BMP280_REG_CTRL_MEAS, + BMP280_OSRS_TEMP_MASK | + BMP280_OSRS_PRESS_MASK | + BMP280_MODE_MASK, + osrs | BMP280_MODE_NORMAL); + if (ret < 0) { + dev_err(data->dev, + "failed to write ctrl_meas register\n"); + return ret; + } + + ret = regmap_update_bits(data->regmap, BMP280_REG_CONFIG, + BMP280_FILTER_MASK, + BMP280_FILTER_4X); + if (ret < 0) { + dev_err(data->dev, + "failed to write config register\n"); + return ret; + } + + return ret; +} + +static const int bmp280_oversampling_avail[] = { 1, 2, 4, 8, 16 }; + +static const struct bmp280_chip_info bmp280_chip_info = { + .oversampling_temp_avail = bmp280_oversampling_avail, + .num_oversampling_temp_avail = ARRAY_SIZE(bmp280_oversampling_avail), + + .oversampling_press_avail = bmp280_oversampling_avail, + .num_oversampling_press_avail = ARRAY_SIZE(bmp280_oversampling_avail), + + .chip_config = bmp280_chip_config, + .read_temp = bmp280_read_temp, + .read_press = bmp280_read_press, +}; + +static int bme280_chip_config(struct bmp280_data *data) +{ + int ret = bmp280_chip_config(data); + u8 osrs = BMP280_OSRS_HUMIDITIY_X(data->oversampling_humid + 1); + + if (ret < 0) + return ret; + + return regmap_update_bits(data->regmap, BMP280_REG_CTRL_HUMIDITY, + BMP280_OSRS_HUMIDITY_MASK, osrs); +} + +static const struct bmp280_chip_info bme280_chip_info = { + .oversampling_temp_avail = bmp280_oversampling_avail, + .num_oversampling_temp_avail = ARRAY_SIZE(bmp280_oversampling_avail), + + .oversampling_press_avail = bmp280_oversampling_avail, + .num_oversampling_press_avail = ARRAY_SIZE(bmp280_oversampling_avail), + + .oversampling_humid_avail = bmp280_oversampling_avail, + .num_oversampling_humid_avail = ARRAY_SIZE(bmp280_oversampling_avail), + + .chip_config = bme280_chip_config, + .read_temp = bmp280_read_temp, + .read_press = bmp280_read_press, + .read_humid = bmp280_read_humid, +}; + +static int bmp180_measure(struct bmp280_data *data, u8 ctrl_meas) +{ + int ret; + const int conversion_time_max[] = { 4500, 7500, 13500, 25500 }; + unsigned int delay_us; + unsigned int ctrl; + + ret = regmap_write(data->regmap, BMP280_REG_CTRL_MEAS, ctrl_meas); + if (ret) + return ret; + + if (ctrl_meas == BMP180_MEAS_TEMP) + delay_us = 4500; + else + delay_us = conversion_time_max[data->oversampling_press]; + + usleep_range(delay_us, delay_us + 1000); + + ret = regmap_read(data->regmap, BMP280_REG_CTRL_MEAS, &ctrl); + if (ret) + return ret; + + /* The value of this bit reset to "0" after conversion is complete */ + if (ctrl & BMP180_MEAS_SCO) + return -EIO; + + return 0; +} + +static int bmp180_read_adc_temp(struct bmp280_data *data, int *val) +{ + int ret; + __be16 tmp = 0; + + ret = bmp180_measure(data, BMP180_MEAS_TEMP); + if (ret) + return ret; + + ret = regmap_bulk_read(data->regmap, BMP180_REG_OUT_MSB, (u8 *)&tmp, 2); + if (ret) + return ret; + + *val = be16_to_cpu(tmp); + + return 0; +} + +/* + * These enums are used for indexing into the array of calibration + * coefficients for BMP180. + */ +enum { AC1, AC2, AC3, AC4, AC5, AC6, B1, B2, MB, MC, MD }; + +struct bmp180_calib { + s16 AC1; + s16 AC2; + s16 AC3; + u16 AC4; + u16 AC5; + u16 AC6; + s16 B1; + s16 B2; + s16 MB; + s16 MC; + s16 MD; +}; + +static int bmp180_read_calib(struct bmp280_data *data, + struct bmp180_calib *calib) +{ + int ret; + int i; + __be16 buf[BMP180_REG_CALIB_COUNT / 2]; + + ret = regmap_bulk_read(data->regmap, BMP180_REG_CALIB_START, buf, + sizeof(buf)); + + if (ret < 0) + return ret; + + /* None of the words has the value 0 or 0xFFFF */ + for (i = 0; i < ARRAY_SIZE(buf); i++) { + if (buf[i] == cpu_to_be16(0) || buf[i] == cpu_to_be16(0xffff)) + return -EIO; + } + + calib->AC1 = be16_to_cpu(buf[AC1]); + calib->AC2 = be16_to_cpu(buf[AC2]); + calib->AC3 = be16_to_cpu(buf[AC3]); + calib->AC4 = be16_to_cpu(buf[AC4]); + calib->AC5 = be16_to_cpu(buf[AC5]); + calib->AC6 = be16_to_cpu(buf[AC6]); + calib->B1 = be16_to_cpu(buf[B1]); + calib->B2 = be16_to_cpu(buf[B2]); + calib->MB = be16_to_cpu(buf[MB]); + calib->MC = be16_to_cpu(buf[MC]); + calib->MD = be16_to_cpu(buf[MD]); + + return 0; +} + +/* + * Returns temperature in DegC, resolution is 0.1 DegC. + * t_fine carries fine temperature as global value. + * + * Taken from datasheet, Section 3.5, "Calculating pressure and temperature". + */ +static s32 bmp180_compensate_temp(struct bmp280_data *data, s32 adc_temp) +{ + int ret; + s32 x1, x2; + struct bmp180_calib calib; + + ret = bmp180_read_calib(data, &calib); + if (ret < 0) { + dev_err(data->dev, + "failed to read calibration coefficients\n"); + return ret; + } + + x1 = ((adc_temp - calib.AC6) * calib.AC5) >> 15; + x2 = (calib.MC << 11) / (x1 + calib.MD); + data->t_fine = x1 + x2; + + return (data->t_fine + 8) >> 4; +} + +static int bmp180_read_temp(struct bmp280_data *data, int *val) +{ + int ret; + s32 adc_temp, comp_temp; + + ret = bmp180_read_adc_temp(data, &adc_temp); + if (ret) + return ret; + + comp_temp = bmp180_compensate_temp(data, adc_temp); + + /* + * val might be NULL if we're called by the read_press routine, + * who only cares about the carry over t_fine value. + */ + if (val) { + *val = comp_temp * 100; + return IIO_VAL_INT; + } + + return 0; +} + +static int bmp180_read_adc_press(struct bmp280_data *data, int *val) +{ + int ret; + __be32 tmp = 0; + u8 oss = data->oversampling_press; + + ret = bmp180_measure(data, BMP180_MEAS_PRESS_X(oss)); + if (ret) + return ret; + + ret = regmap_bulk_read(data->regmap, BMP180_REG_OUT_MSB, (u8 *)&tmp, 3); + if (ret) + return ret; + + *val = (be32_to_cpu(tmp) >> 8) >> (8 - oss); + + return 0; +} + +/* + * Returns pressure in Pa, resolution is 1 Pa. + * + * Taken from datasheet, Section 3.5, "Calculating pressure and temperature". + */ +static u32 bmp180_compensate_press(struct bmp280_data *data, s32 adc_press) +{ + int ret; + s32 x1, x2, x3, p; + s32 b3, b6; + u32 b4, b7; + s32 oss = data->oversampling_press; + struct bmp180_calib calib; + + ret = bmp180_read_calib(data, &calib); + if (ret < 0) { + dev_err(data->dev, + "failed to read calibration coefficients\n"); + return ret; + } + + b6 = data->t_fine - 4000; + x1 = (calib.B2 * (b6 * b6 >> 12)) >> 11; + x2 = calib.AC2 * b6 >> 11; + x3 = x1 + x2; + b3 = ((((s32)calib.AC1 * 4 + x3) << oss) + 2) / 4; + x1 = calib.AC3 * b6 >> 13; + x2 = (calib.B1 * ((b6 * b6) >> 12)) >> 16; + x3 = (x1 + x2 + 2) >> 2; + b4 = calib.AC4 * (u32)(x3 + 32768) >> 15; + b7 = ((u32)adc_press - b3) * (50000 >> oss); + if (b7 < 0x80000000) + p = (b7 * 2) / b4; + else + p = (b7 / b4) * 2; + + x1 = (p >> 8) * (p >> 8); + x1 = (x1 * 3038) >> 16; + x2 = (-7357 * p) >> 16; + + return p + ((x1 + x2 + 3791) >> 4); +} + +static int bmp180_read_press(struct bmp280_data *data, + int *val, int *val2) +{ + int ret; + s32 adc_press; + u32 comp_press; + + /* Read and compensate temperature so we get a reading of t_fine. */ + ret = bmp180_read_temp(data, NULL); + if (ret) + return ret; + + ret = bmp180_read_adc_press(data, &adc_press); + if (ret) + return ret; + + comp_press = bmp180_compensate_press(data, adc_press); + + *val = comp_press; + *val2 = 1000; + + return IIO_VAL_FRACTIONAL; +} + +static int bmp180_chip_config(struct bmp280_data *data) +{ + return 0; +} + +static const int bmp180_oversampling_temp_avail[] = { 1 }; +static const int bmp180_oversampling_press_avail[] = { 1, 2, 4, 8 }; + +static const struct bmp280_chip_info bmp180_chip_info = { + .oversampling_temp_avail = bmp180_oversampling_temp_avail, + .num_oversampling_temp_avail = + ARRAY_SIZE(bmp180_oversampling_temp_avail), + + .oversampling_press_avail = bmp180_oversampling_press_avail, + .num_oversampling_press_avail = + ARRAY_SIZE(bmp180_oversampling_press_avail), + + .chip_config = bmp180_chip_config, + .read_temp = bmp180_read_temp, + .read_press = bmp180_read_press, +}; + +int bmp280_common_probe(struct device *dev, + struct regmap *regmap, + unsigned int chip, + const char *name) +{ + int ret; + struct iio_dev *indio_dev; + struct bmp280_data *data; + unsigned int chip_id; + struct gpio_desc *gpiod; + + indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + data = iio_priv(indio_dev); + mutex_init(&data->lock); + data->dev = dev; + + indio_dev->dev.parent = dev; + indio_dev->name = name; + indio_dev->channels = bmp280_channels; + indio_dev->info = &bmp280_info; + indio_dev->modes = INDIO_DIRECT_MODE; + + switch (chip) { + case BMP180_CHIP_ID: + indio_dev->num_channels = 2; + data->chip_info = &bmp180_chip_info; + data->oversampling_press = ilog2(8); + data->oversampling_temp = ilog2(1); + data->start_up_time = 10; + break; + case BMP280_CHIP_ID: + indio_dev->num_channels = 2; + data->chip_info = &bmp280_chip_info; + data->oversampling_press = ilog2(16); + data->oversampling_temp = ilog2(2); + data->start_up_time = 2; + break; + case BME280_CHIP_ID: + indio_dev->num_channels = 3; + data->chip_info = &bme280_chip_info; + data->oversampling_press = ilog2(16); + data->oversampling_humid = ilog2(16); + data->oversampling_temp = ilog2(2); + data->start_up_time = 2; + break; + default: + return -EINVAL; + } + + /* Bring up regulators */ + data->vddd = devm_regulator_get(dev, "vddd"); + if (IS_ERR(data->vddd)) { + dev_err(dev, "failed to get VDDD regulator\n"); + return PTR_ERR(data->vddd); + } + ret = regulator_enable(data->vddd); + if (ret) { + dev_err(dev, "failed to enable VDDD regulator\n"); + return ret; + } + data->vdda = devm_regulator_get(dev, "vdda"); + if (IS_ERR(data->vdda)) { + dev_err(dev, "failed to get VDDA regulator\n"); + ret = PTR_ERR(data->vddd); + goto out_disable_vddd; + } + ret = regulator_enable(data->vdda); + if (ret) { + dev_err(dev, "failed to enable VDDA regulator\n"); + goto out_disable_vddd; + } + /* Wait to make sure we started up properly */ + mdelay(data->start_up_time); + + /* Bring chip out of reset if there is an assigned GPIO line */ + gpiod = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); + /* Deassert the signal */ + if (!IS_ERR(gpiod)) { + dev_info(dev, "release reset\n"); + gpiod_set_value(gpiod, 0); + } + + data->regmap = regmap; + ret = regmap_read(regmap, BMP280_REG_ID, &chip_id); + if (ret < 0) + goto out_disable_vdda; + if (chip_id != chip) { + dev_err(dev, "bad chip id: expected %x got %x\n", + chip, chip_id); + ret = -EINVAL; + goto out_disable_vdda; + } + + ret = data->chip_info->chip_config(data); + if (ret < 0) + goto out_disable_vdda; + + dev_set_drvdata(dev, indio_dev); + + ret = iio_device_register(indio_dev); + if (ret) + goto out_disable_vdda; + + return 0; + +out_disable_vdda: + regulator_disable(data->vdda); +out_disable_vddd: + regulator_disable(data->vddd); + return ret; +} + +int bmp280_common_remove(struct device *dev) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct bmp280_data *data = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + regulator_disable(data->vdda); + regulator_disable(data->vddd); + return 0; +} diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c new file mode 100644 index 0000000..7c70ee1 --- /dev/null +++ b/drivers/iio/pressure/bmp280-i2c.c @@ -0,0 +1,89 @@ +#include +#include +#include +#include +#include + +#include "bmp280.h" + +static int bmp280_i2c_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct regmap *regmap; + const struct regmap_config *regmap_config; + + switch (id->driver_data) { + case BMP180_CHIP_ID: + regmap_config = &bmp180_regmap_config; + break; + case BMP280_CHIP_ID: + case BME280_CHIP_ID: + regmap_config = &bmp280_regmap_config; + break; + default: + return -EINVAL; + } + + regmap = devm_regmap_init_i2c(client, regmap_config); + if (IS_ERR(regmap)) { + dev_err(&client->dev, "failed to allocate register map\n"); + return PTR_ERR(regmap); + } + + return bmp280_common_probe(&client->dev, + regmap, + id->driver_data, + id->name); +} + +static int bmp280_i2c_remove(struct i2c_client *client) +{ + return bmp280_common_remove(&client->dev); +} + +static const struct acpi_device_id bmp280_acpi_i2c_match[] = { + {"BMP0280", BMP280_CHIP_ID }, + {"BMP0180", BMP180_CHIP_ID }, + {"BMP0085", BMP180_CHIP_ID }, + {"BME0280", BME280_CHIP_ID }, + { }, +}; +MODULE_DEVICE_TABLE(acpi, bmp280_acpi_i2c_match); + +#ifdef CONFIG_OF +static const struct of_device_id bmp280_of_i2c_match[] = { + { .compatible = "bosch,bme280", .data = (void *)BME280_CHIP_ID }, + { .compatible = "bosch,bmp280", .data = (void *)BMP280_CHIP_ID }, + { .compatible = "bosch,bmp180", .data = (void *)BMP180_CHIP_ID }, + { .compatible = "bosch,bmp085", .data = (void *)BMP180_CHIP_ID }, + { }, +}; +MODULE_DEVICE_TABLE(of, bmp280_of_i2c_match); +#else +#define bmp280_of_i2c_match NULL +#endif + +static const struct i2c_device_id bmp280_i2c_id[] = { + {"bmp280", BMP280_CHIP_ID }, + {"bmp180", BMP180_CHIP_ID }, + {"bmp085", BMP180_CHIP_ID }, + {"bme280", BME280_CHIP_ID }, + { }, +}; +MODULE_DEVICE_TABLE(i2c, bmp280_i2c_id); + +static struct i2c_driver bmp280_i2c_driver = { + .driver = { + .name = "bmp280", + .acpi_match_table = ACPI_PTR(bmp280_acpi_i2c_match), + .of_match_table = of_match_ptr(bmp280_of_i2c_match), + }, + .probe = bmp280_i2c_probe, + .remove = bmp280_i2c_remove, + .id_table = bmp280_i2c_id, +}; +module_i2c_driver(bmp280_i2c_driver); + +MODULE_AUTHOR("Vlad Dogaru "); +MODULE_DESCRIPTION("Driver for Bosch Sensortec BMP180/BMP280 pressure and temperature sensor"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iio/pressure/bmp280-regmap.c b/drivers/iio/pressure/bmp280-regmap.c new file mode 100644 index 0000000..3341189 --- /dev/null +++ b/drivers/iio/pressure/bmp280-regmap.c @@ -0,0 +1,81 @@ +#include +#include + +#include "bmp280.h" + +static bool bmp180_is_writeable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case BMP280_REG_CTRL_MEAS: + case BMP280_REG_RESET: + return true; + default: + return false; + }; +} + +static bool bmp180_is_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case BMP180_REG_OUT_XLSB: + case BMP180_REG_OUT_LSB: + case BMP180_REG_OUT_MSB: + case BMP280_REG_CTRL_MEAS: + return true; + default: + return false; + } +} + +const struct regmap_config bmp180_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = BMP180_REG_OUT_XLSB, + .cache_type = REGCACHE_RBTREE, + + .writeable_reg = bmp180_is_writeable_reg, + .volatile_reg = bmp180_is_volatile_reg, +}; + +static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case BMP280_REG_CONFIG: + case BMP280_REG_CTRL_HUMIDITY: + case BMP280_REG_CTRL_MEAS: + case BMP280_REG_RESET: + return true; + default: + return false; + }; +} + +static bool bmp280_is_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case BMP280_REG_HUMIDITY_LSB: + case BMP280_REG_HUMIDITY_MSB: + case BMP280_REG_TEMP_XLSB: + case BMP280_REG_TEMP_LSB: + case BMP280_REG_TEMP_MSB: + case BMP280_REG_PRESS_XLSB: + case BMP280_REG_PRESS_LSB: + case BMP280_REG_PRESS_MSB: + case BMP280_REG_STATUS: + return true; + default: + return false; + } +} + +const struct regmap_config bmp280_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = BMP280_REG_HUMIDITY_LSB, + .cache_type = REGCACHE_RBTREE, + + .writeable_reg = bmp280_is_writeable_reg, + .volatile_reg = bmp280_is_volatile_reg, +}; diff --git a/drivers/iio/pressure/bmp280.c b/drivers/iio/pressure/bmp280.c deleted file mode 100644 index f5d0875..0000000 --- a/drivers/iio/pressure/bmp280.c +++ /dev/null @@ -1,1201 +0,0 @@ -/* - * Copyright (c) 2014 Intel Corporation - * - * Driver for Bosch Sensortec BMP180 and BMP280 digital pressure sensor. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * Datasheet: - * https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMP180-DS000-121.pdf - * https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMP280-DS001-12.pdf - * https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME280_DS001-11.pdf - */ - -#define pr_fmt(fmt) "bmp280: " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* BMP280 specific registers */ -#define BMP280_REG_HUMIDITY_LSB 0xFE -#define BMP280_REG_HUMIDITY_MSB 0xFD -#define BMP280_REG_TEMP_XLSB 0xFC -#define BMP280_REG_TEMP_LSB 0xFB -#define BMP280_REG_TEMP_MSB 0xFA -#define BMP280_REG_PRESS_XLSB 0xF9 -#define BMP280_REG_PRESS_LSB 0xF8 -#define BMP280_REG_PRESS_MSB 0xF7 - -#define BMP280_REG_CONFIG 0xF5 -#define BMP280_REG_CTRL_MEAS 0xF4 -#define BMP280_REG_STATUS 0xF3 -#define BMP280_REG_CTRL_HUMIDITY 0xF2 - -/* Due to non linear mapping, and data sizes we can't do a bulk read */ -#define BMP280_REG_COMP_H1 0xA1 -#define BMP280_REG_COMP_H2 0xE1 -#define BMP280_REG_COMP_H3 0xE3 -#define BMP280_REG_COMP_H4 0xE4 -#define BMP280_REG_COMP_H5 0xE5 -#define BMP280_REG_COMP_H6 0xE7 - -#define BMP280_REG_COMP_TEMP_START 0x88 -#define BMP280_COMP_TEMP_REG_COUNT 6 - -#define BMP280_REG_COMP_PRESS_START 0x8E -#define BMP280_COMP_PRESS_REG_COUNT 18 - -#define BMP280_FILTER_MASK (BIT(4) | BIT(3) | BIT(2)) -#define BMP280_FILTER_OFF 0 -#define BMP280_FILTER_2X BIT(2) -#define BMP280_FILTER_4X BIT(3) -#define BMP280_FILTER_8X (BIT(3) | BIT(2)) -#define BMP280_FILTER_16X BIT(4) - -#define BMP280_OSRS_HUMIDITY_MASK (BIT(2) | BIT(1) | BIT(0)) -#define BMP280_OSRS_HUMIDITIY_X(osrs_h) ((osrs_h) << 0) -#define BMP280_OSRS_HUMIDITY_SKIP 0 -#define BMP280_OSRS_HUMIDITY_1X BMP280_OSRS_HUMIDITIY_X(1) -#define BMP280_OSRS_HUMIDITY_2X BMP280_OSRS_HUMIDITIY_X(2) -#define BMP280_OSRS_HUMIDITY_4X BMP280_OSRS_HUMIDITIY_X(3) -#define BMP280_OSRS_HUMIDITY_8X BMP280_OSRS_HUMIDITIY_X(4) -#define BMP280_OSRS_HUMIDITY_16X BMP280_OSRS_HUMIDITIY_X(5) - -#define BMP280_OSRS_TEMP_MASK (BIT(7) | BIT(6) | BIT(5)) -#define BMP280_OSRS_TEMP_SKIP 0 -#define BMP280_OSRS_TEMP_X(osrs_t) ((osrs_t) << 5) -#define BMP280_OSRS_TEMP_1X BMP280_OSRS_TEMP_X(1) -#define BMP280_OSRS_TEMP_2X BMP280_OSRS_TEMP_X(2) -#define BMP280_OSRS_TEMP_4X BMP280_OSRS_TEMP_X(3) -#define BMP280_OSRS_TEMP_8X BMP280_OSRS_TEMP_X(4) -#define BMP280_OSRS_TEMP_16X BMP280_OSRS_TEMP_X(5) - -#define BMP280_OSRS_PRESS_MASK (BIT(4) | BIT(3) | BIT(2)) -#define BMP280_OSRS_PRESS_SKIP 0 -#define BMP280_OSRS_PRESS_X(osrs_p) ((osrs_p) << 2) -#define BMP280_OSRS_PRESS_1X BMP280_OSRS_PRESS_X(1) -#define BMP280_OSRS_PRESS_2X BMP280_OSRS_PRESS_X(2) -#define BMP280_OSRS_PRESS_4X BMP280_OSRS_PRESS_X(3) -#define BMP280_OSRS_PRESS_8X BMP280_OSRS_PRESS_X(4) -#define BMP280_OSRS_PRESS_16X BMP280_OSRS_PRESS_X(5) - -#define BMP280_MODE_MASK (BIT(1) | BIT(0)) -#define BMP280_MODE_SLEEP 0 -#define BMP280_MODE_FORCED BIT(0) -#define BMP280_MODE_NORMAL (BIT(1) | BIT(0)) - -/* BMP180 specific registers */ -#define BMP180_REG_OUT_XLSB 0xF8 -#define BMP180_REG_OUT_LSB 0xF7 -#define BMP180_REG_OUT_MSB 0xF6 - -#define BMP180_REG_CALIB_START 0xAA -#define BMP180_REG_CALIB_COUNT 22 - -#define BMP180_MEAS_SCO BIT(5) -#define BMP180_MEAS_TEMP (0x0E | BMP180_MEAS_SCO) -#define BMP180_MEAS_PRESS_X(oss) ((oss) << 6 | 0x14 | BMP180_MEAS_SCO) -#define BMP180_MEAS_PRESS_1X BMP180_MEAS_PRESS_X(0) -#define BMP180_MEAS_PRESS_2X BMP180_MEAS_PRESS_X(1) -#define BMP180_MEAS_PRESS_4X BMP180_MEAS_PRESS_X(2) -#define BMP180_MEAS_PRESS_8X BMP180_MEAS_PRESS_X(3) - -/* BMP180 and BMP280 common registers */ -#define BMP280_REG_CTRL_MEAS 0xF4 -#define BMP280_REG_RESET 0xE0 -#define BMP280_REG_ID 0xD0 - -#define BMP180_CHIP_ID 0x55 -#define BMP280_CHIP_ID 0x58 -#define BME280_CHIP_ID 0x60 -#define BMP280_SOFT_RESET_VAL 0xB6 - -struct bmp280_data { - struct i2c_client *client; - struct mutex lock; - struct regmap *regmap; - const struct bmp280_chip_info *chip_info; - struct regulator *vddd; - struct regulator *vdda; - unsigned int start_up_time; /* in milliseconds */ - - /* log of base 2 of oversampling rate */ - u8 oversampling_press; - u8 oversampling_temp; - u8 oversampling_humid; - - /* - * Carryover value from temperature conversion, used in pressure - * calculation. - */ - s32 t_fine; -}; - -struct bmp280_chip_info { - const struct regmap_config *regmap_config; - - const int *oversampling_temp_avail; - int num_oversampling_temp_avail; - - const int *oversampling_press_avail; - int num_oversampling_press_avail; - - const int *oversampling_humid_avail; - int num_oversampling_humid_avail; - - int (*chip_config)(struct bmp280_data *); - int (*read_temp)(struct bmp280_data *, int *); - int (*read_press)(struct bmp280_data *, int *, int *); - int (*read_humid)(struct bmp280_data *, int *, int *); -}; - -/* - * These enums are used for indexing into the array of compensation - * parameters for BMP280. - */ -enum { T1, T2, T3 }; -enum { P1, P2, P3, P4, P5, P6, P7, P8, P9 }; - -static const struct iio_chan_spec bmp280_channels[] = { - { - .type = IIO_PRESSURE, - .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | - BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), - }, - { - .type = IIO_TEMP, - .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | - BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), - }, - { - .type = IIO_HUMIDITYRELATIVE, - .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | - BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), - }, -}; - -static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg) -{ - switch (reg) { - case BMP280_REG_CONFIG: - case BMP280_REG_CTRL_HUMIDITY: - case BMP280_REG_CTRL_MEAS: - case BMP280_REG_RESET: - return true; - default: - return false; - }; -} - -static bool bmp280_is_volatile_reg(struct device *dev, unsigned int reg) -{ - switch (reg) { - case BMP280_REG_HUMIDITY_LSB: - case BMP280_REG_HUMIDITY_MSB: - case BMP280_REG_TEMP_XLSB: - case BMP280_REG_TEMP_LSB: - case BMP280_REG_TEMP_MSB: - case BMP280_REG_PRESS_XLSB: - case BMP280_REG_PRESS_LSB: - case BMP280_REG_PRESS_MSB: - case BMP280_REG_STATUS: - return true; - default: - return false; - } -} - -static const struct regmap_config bmp280_regmap_config = { - .reg_bits = 8, - .val_bits = 8, - - .max_register = BMP280_REG_HUMIDITY_LSB, - .cache_type = REGCACHE_RBTREE, - - .writeable_reg = bmp280_is_writeable_reg, - .volatile_reg = bmp280_is_volatile_reg, -}; - -/* - * Returns humidity in percent, resolution is 0.01 percent. Output value of - * "47445" represents 47445/1024 = 46.333 %RH. - * - * Taken from BME280 datasheet, Section 4.2.3, "Compensation formula". - */ - -static u32 bmp280_compensate_humidity(struct bmp280_data *data, - s32 adc_humidity) -{ - struct device *dev = &data->client->dev; - unsigned int H1, H3, tmp; - int H2, H4, H5, H6, ret, var; - - ret = regmap_read(data->regmap, BMP280_REG_COMP_H1, &H1); - if (ret < 0) { - dev_err(dev, "failed to read H1 comp value\n"); - return ret; - } - - ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H2, &tmp, 2); - if (ret < 0) { - dev_err(dev, "failed to read H2 comp value\n"); - return ret; - } - H2 = sign_extend32(le16_to_cpu(tmp), 15); - - ret = regmap_read(data->regmap, BMP280_REG_COMP_H3, &H3); - if (ret < 0) { - dev_err(dev, "failed to read H3 comp value\n"); - return ret; - } - - ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H4, &tmp, 2); - if (ret < 0) { - dev_err(dev, "failed to read H4 comp value\n"); - return ret; - } - H4 = sign_extend32(((be16_to_cpu(tmp) >> 4) & 0xff0) | - (be16_to_cpu(tmp) & 0xf), 11); - - ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_H5, &tmp, 2); - if (ret < 0) { - dev_err(dev, "failed to read H5 comp value\n"); - return ret; - } - H5 = sign_extend32(((le16_to_cpu(tmp) >> 4) & 0xfff), 11); - - ret = regmap_read(data->regmap, BMP280_REG_COMP_H6, &tmp); - if (ret < 0) { - dev_err(dev, "failed to read H6 comp value\n"); - return ret; - } - H6 = sign_extend32(tmp, 7); - - var = ((s32)data->t_fine) - 76800; - var = ((((adc_humidity << 14) - (H4 << 20) - (H5 * var)) + 16384) >> 15) - * (((((((var * H6) >> 10) * (((var * H3) >> 11) + 32768)) >> 10) - + 2097152) * H2 + 8192) >> 14); - var -= ((((var >> 15) * (var >> 15)) >> 7) * H1) >> 4; - - return var >> 12; -}; - -/* - * Returns temperature in DegC, resolution is 0.01 DegC. Output value of - * "5123" equals 51.23 DegC. t_fine carries fine temperature as global - * value. - * - * Taken from datasheet, Section 3.11.3, "Compensation formula". - */ -static s32 bmp280_compensate_temp(struct bmp280_data *data, - s32 adc_temp) -{ - int ret; - s32 var1, var2; - __le16 buf[BMP280_COMP_TEMP_REG_COUNT / 2]; - - ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_TEMP_START, - buf, BMP280_COMP_TEMP_REG_COUNT); - if (ret < 0) { - dev_err(&data->client->dev, - "failed to read temperature calibration parameters\n"); - return ret; - } - - /* - * The double casts are necessary because le16_to_cpu returns an - * unsigned 16-bit value. Casting that value directly to a - * signed 32-bit will not do proper sign extension. - * - * Conversely, T1 and P1 are unsigned values, so they can be - * cast straight to the larger type. - */ - var1 = (((adc_temp >> 3) - ((s32)le16_to_cpu(buf[T1]) << 1)) * - ((s32)(s16)le16_to_cpu(buf[T2]))) >> 11; - var2 = (((((adc_temp >> 4) - ((s32)le16_to_cpu(buf[T1]))) * - ((adc_temp >> 4) - ((s32)le16_to_cpu(buf[T1])))) >> 12) * - ((s32)(s16)le16_to_cpu(buf[T3]))) >> 14; - data->t_fine = var1 + var2; - - return (data->t_fine * 5 + 128) >> 8; -} - -/* - * Returns pressure in Pa as unsigned 32 bit integer in Q24.8 format (24 - * integer bits and 8 fractional bits). Output value of "24674867" - * represents 24674867/256 = 96386.2 Pa = 963.862 hPa - * - * Taken from datasheet, Section 3.11.3, "Compensation formula". - */ -static u32 bmp280_compensate_press(struct bmp280_data *data, - s32 adc_press) -{ - int ret; - s64 var1, var2, p; - __le16 buf[BMP280_COMP_PRESS_REG_COUNT / 2]; - - ret = regmap_bulk_read(data->regmap, BMP280_REG_COMP_PRESS_START, - buf, BMP280_COMP_PRESS_REG_COUNT); - if (ret < 0) { - dev_err(&data->client->dev, - "failed to read pressure calibration parameters\n"); - return ret; - } - - var1 = ((s64)data->t_fine) - 128000; - var2 = var1 * var1 * (s64)(s16)le16_to_cpu(buf[P6]); - var2 += (var1 * (s64)(s16)le16_to_cpu(buf[P5])) << 17; - var2 += ((s64)(s16)le16_to_cpu(buf[P4])) << 35; - var1 = ((var1 * var1 * (s64)(s16)le16_to_cpu(buf[P3])) >> 8) + - ((var1 * (s64)(s16)le16_to_cpu(buf[P2])) << 12); - var1 = ((((s64)1) << 47) + var1) * ((s64)le16_to_cpu(buf[P1])) >> 33; - - if (var1 == 0) - return 0; - - p = ((((s64)1048576 - adc_press) << 31) - var2) * 3125; - p = div64_s64(p, var1); - var1 = (((s64)(s16)le16_to_cpu(buf[P9])) * (p >> 13) * (p >> 13)) >> 25; - var2 = (((s64)(s16)le16_to_cpu(buf[P8])) * p) >> 19; - p = ((p + var1 + var2) >> 8) + (((s64)(s16)le16_to_cpu(buf[P7])) << 4); - - return (u32)p; -} - -static int bmp280_read_temp(struct bmp280_data *data, - int *val) -{ - int ret; - __be32 tmp = 0; - s32 adc_temp, comp_temp; - - ret = regmap_bulk_read(data->regmap, BMP280_REG_TEMP_MSB, - (u8 *) &tmp, 3); - if (ret < 0) { - dev_err(&data->client->dev, "failed to read temperature\n"); - return ret; - } - - adc_temp = be32_to_cpu(tmp) >> 12; - comp_temp = bmp280_compensate_temp(data, adc_temp); - - /* - * val might be NULL if we're called by the read_press routine, - * who only cares about the carry over t_fine value. - */ - if (val) { - *val = comp_temp * 10; - return IIO_VAL_INT; - } - - return 0; -} - -static int bmp280_read_press(struct bmp280_data *data, - int *val, int *val2) -{ - int ret; - __be32 tmp = 0; - s32 adc_press; - u32 comp_press; - - /* Read and compensate temperature so we get a reading of t_fine. */ - ret = bmp280_read_temp(data, NULL); - if (ret < 0) - return ret; - - ret = regmap_bulk_read(data->regmap, BMP280_REG_PRESS_MSB, - (u8 *) &tmp, 3); - if (ret < 0) { - dev_err(&data->client->dev, "failed to read pressure\n"); - return ret; - } - - adc_press = be32_to_cpu(tmp) >> 12; - comp_press = bmp280_compensate_press(data, adc_press); - - *val = comp_press; - *val2 = 256000; - - return IIO_VAL_FRACTIONAL; -} - -static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2) -{ - int ret; - __be16 tmp = 0; - s32 adc_humidity; - u32 comp_humidity; - - /* Read and compensate temperature so we get a reading of t_fine. */ - ret = bmp280_read_temp(data, NULL); - if (ret < 0) - return ret; - - ret = regmap_bulk_read(data->regmap, BMP280_REG_HUMIDITY_MSB, - (u8 *) &tmp, 2); - if (ret < 0) { - dev_err(&data->client->dev, "failed to read humidity\n"); - return ret; - } - - adc_humidity = be16_to_cpu(tmp); - comp_humidity = bmp280_compensate_humidity(data, adc_humidity); - - *val = comp_humidity; - *val2 = 1024; - - return IIO_VAL_FRACTIONAL; -} - -static int bmp280_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, int *val2, long mask) -{ - int ret; - struct bmp280_data *data = iio_priv(indio_dev); - - mutex_lock(&data->lock); - - switch (mask) { - case IIO_CHAN_INFO_PROCESSED: - switch (chan->type) { - case IIO_HUMIDITYRELATIVE: - ret = data->chip_info->read_humid(data, val, val2); - break; - case IIO_PRESSURE: - ret = data->chip_info->read_press(data, val, val2); - break; - case IIO_TEMP: - ret = data->chip_info->read_temp(data, val); - break; - default: - ret = -EINVAL; - break; - } - break; - case IIO_CHAN_INFO_OVERSAMPLING_RATIO: - switch (chan->type) { - case IIO_HUMIDITYRELATIVE: - *val = 1 << data->oversampling_humid; - ret = IIO_VAL_INT; - break; - case IIO_PRESSURE: - *val = 1 << data->oversampling_press; - ret = IIO_VAL_INT; - break; - case IIO_TEMP: - *val = 1 << data->oversampling_temp; - ret = IIO_VAL_INT; - break; - default: - ret = -EINVAL; - break; - } - break; - default: - ret = -EINVAL; - break; - } - - mutex_unlock(&data->lock); - - return ret; -} - -static int bmp280_write_oversampling_ratio_humid(struct bmp280_data *data, - int val) -{ - int i; - const int *avail = data->chip_info->oversampling_humid_avail; - const int n = data->chip_info->num_oversampling_humid_avail; - - for (i = 0; i < n; i++) { - if (avail[i] == val) { - data->oversampling_humid = ilog2(val); - - return data->chip_info->chip_config(data); - } - } - return -EINVAL; -} - -static int bmp280_write_oversampling_ratio_temp(struct bmp280_data *data, - int val) -{ - int i; - const int *avail = data->chip_info->oversampling_temp_avail; - const int n = data->chip_info->num_oversampling_temp_avail; - - for (i = 0; i < n; i++) { - if (avail[i] == val) { - data->oversampling_temp = ilog2(val); - - return data->chip_info->chip_config(data); - } - } - return -EINVAL; -} - -static int bmp280_write_oversampling_ratio_press(struct bmp280_data *data, - int val) -{ - int i; - const int *avail = data->chip_info->oversampling_press_avail; - const int n = data->chip_info->num_oversampling_press_avail; - - for (i = 0; i < n; i++) { - if (avail[i] == val) { - data->oversampling_press = ilog2(val); - - return data->chip_info->chip_config(data); - } - } - return -EINVAL; -} - -static int bmp280_write_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int val, int val2, long mask) -{ - int ret = 0; - struct bmp280_data *data = iio_priv(indio_dev); - - switch (mask) { - case IIO_CHAN_INFO_OVERSAMPLING_RATIO: - mutex_lock(&data->lock); - switch (chan->type) { - case IIO_HUMIDITYRELATIVE: - ret = bmp280_write_oversampling_ratio_humid(data, val); - break; - case IIO_PRESSURE: - ret = bmp280_write_oversampling_ratio_press(data, val); - break; - case IIO_TEMP: - ret = bmp280_write_oversampling_ratio_temp(data, val); - break; - default: - ret = -EINVAL; - break; - } - mutex_unlock(&data->lock); - break; - default: - return -EINVAL; - } - - return ret; -} - -static ssize_t bmp280_show_avail(char *buf, const int *vals, const int n) -{ - size_t len = 0; - int i; - - for (i = 0; i < n; i++) - len += scnprintf(buf + len, PAGE_SIZE - len, "%d ", vals[i]); - - buf[len - 1] = '\n'; - - return len; -} - -static ssize_t bmp280_show_temp_oversampling_avail(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct bmp280_data *data = iio_priv(dev_to_iio_dev(dev)); - - return bmp280_show_avail(buf, data->chip_info->oversampling_temp_avail, - data->chip_info->num_oversampling_temp_avail); -} - -static ssize_t bmp280_show_press_oversampling_avail(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct bmp280_data *data = iio_priv(dev_to_iio_dev(dev)); - - return bmp280_show_avail(buf, data->chip_info->oversampling_press_avail, - data->chip_info->num_oversampling_press_avail); -} - -static IIO_DEVICE_ATTR(in_temp_oversampling_ratio_available, - S_IRUGO, bmp280_show_temp_oversampling_avail, NULL, 0); - -static IIO_DEVICE_ATTR(in_pressure_oversampling_ratio_available, - S_IRUGO, bmp280_show_press_oversampling_avail, NULL, 0); - -static struct attribute *bmp280_attributes[] = { - &iio_dev_attr_in_temp_oversampling_ratio_available.dev_attr.attr, - &iio_dev_attr_in_pressure_oversampling_ratio_available.dev_attr.attr, - NULL, -}; - -static const struct attribute_group bmp280_attrs_group = { - .attrs = bmp280_attributes, -}; - -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, -}; - -static int bmp280_chip_config(struct bmp280_data *data) -{ - int ret; - u8 osrs = BMP280_OSRS_TEMP_X(data->oversampling_temp + 1) | - BMP280_OSRS_PRESS_X(data->oversampling_press + 1); - - ret = regmap_update_bits(data->regmap, BMP280_REG_CTRL_MEAS, - BMP280_OSRS_TEMP_MASK | - BMP280_OSRS_PRESS_MASK | - BMP280_MODE_MASK, - osrs | BMP280_MODE_NORMAL); - if (ret < 0) { - dev_err(&data->client->dev, - "failed to write ctrl_meas register\n"); - return ret; - } - - ret = regmap_update_bits(data->regmap, BMP280_REG_CONFIG, - BMP280_FILTER_MASK, - BMP280_FILTER_4X); - if (ret < 0) { - dev_err(&data->client->dev, - "failed to write config register\n"); - return ret; - } - - return ret; -} - -static const int bmp280_oversampling_avail[] = { 1, 2, 4, 8, 16 }; - -static const struct bmp280_chip_info bmp280_chip_info = { - .regmap_config = &bmp280_regmap_config, - - .oversampling_temp_avail = bmp280_oversampling_avail, - .num_oversampling_temp_avail = ARRAY_SIZE(bmp280_oversampling_avail), - - .oversampling_press_avail = bmp280_oversampling_avail, - .num_oversampling_press_avail = ARRAY_SIZE(bmp280_oversampling_avail), - - .chip_config = bmp280_chip_config, - .read_temp = bmp280_read_temp, - .read_press = bmp280_read_press, -}; - -static int bme280_chip_config(struct bmp280_data *data) -{ - int ret = bmp280_chip_config(data); - u8 osrs = BMP280_OSRS_HUMIDITIY_X(data->oversampling_humid + 1); - - if (ret < 0) - return ret; - - return regmap_update_bits(data->regmap, BMP280_REG_CTRL_HUMIDITY, - BMP280_OSRS_HUMIDITY_MASK, osrs); -} - -static const struct bmp280_chip_info bme280_chip_info = { - .regmap_config = &bmp280_regmap_config, - - .oversampling_temp_avail = bmp280_oversampling_avail, - .num_oversampling_temp_avail = ARRAY_SIZE(bmp280_oversampling_avail), - - .oversampling_press_avail = bmp280_oversampling_avail, - .num_oversampling_press_avail = ARRAY_SIZE(bmp280_oversampling_avail), - - .oversampling_humid_avail = bmp280_oversampling_avail, - .num_oversampling_humid_avail = ARRAY_SIZE(bmp280_oversampling_avail), - - .chip_config = bme280_chip_config, - .read_temp = bmp280_read_temp, - .read_press = bmp280_read_press, - .read_humid = bmp280_read_humid, -}; - - -static bool bmp180_is_writeable_reg(struct device *dev, unsigned int reg) -{ - switch (reg) { - case BMP280_REG_CTRL_MEAS: - case BMP280_REG_RESET: - return true; - default: - return false; - }; -} - -static bool bmp180_is_volatile_reg(struct device *dev, unsigned int reg) -{ - switch (reg) { - case BMP180_REG_OUT_XLSB: - case BMP180_REG_OUT_LSB: - case BMP180_REG_OUT_MSB: - case BMP280_REG_CTRL_MEAS: - return true; - default: - return false; - } -} - -static const struct regmap_config bmp180_regmap_config = { - .reg_bits = 8, - .val_bits = 8, - - .max_register = BMP180_REG_OUT_XLSB, - .cache_type = REGCACHE_RBTREE, - - .writeable_reg = bmp180_is_writeable_reg, - .volatile_reg = bmp180_is_volatile_reg, -}; - -static int bmp180_measure(struct bmp280_data *data, u8 ctrl_meas) -{ - int ret; - const int conversion_time_max[] = { 4500, 7500, 13500, 25500 }; - unsigned int delay_us; - unsigned int ctrl; - - ret = regmap_write(data->regmap, BMP280_REG_CTRL_MEAS, ctrl_meas); - if (ret) - return ret; - - if (ctrl_meas == BMP180_MEAS_TEMP) - delay_us = 4500; - else - delay_us = conversion_time_max[data->oversampling_press]; - - usleep_range(delay_us, delay_us + 1000); - - ret = regmap_read(data->regmap, BMP280_REG_CTRL_MEAS, &ctrl); - if (ret) - return ret; - - /* The value of this bit reset to "0" after conversion is complete */ - if (ctrl & BMP180_MEAS_SCO) - return -EIO; - - return 0; -} - -static int bmp180_read_adc_temp(struct bmp280_data *data, int *val) -{ - int ret; - __be16 tmp = 0; - - ret = bmp180_measure(data, BMP180_MEAS_TEMP); - if (ret) - return ret; - - ret = regmap_bulk_read(data->regmap, BMP180_REG_OUT_MSB, (u8 *)&tmp, 2); - if (ret) - return ret; - - *val = be16_to_cpu(tmp); - - return 0; -} - -/* - * These enums are used for indexing into the array of calibration - * coefficients for BMP180. - */ -enum { AC1, AC2, AC3, AC4, AC5, AC6, B1, B2, MB, MC, MD }; - -struct bmp180_calib { - s16 AC1; - s16 AC2; - s16 AC3; - u16 AC4; - u16 AC5; - u16 AC6; - s16 B1; - s16 B2; - s16 MB; - s16 MC; - s16 MD; -}; - -static int bmp180_read_calib(struct bmp280_data *data, - struct bmp180_calib *calib) -{ - int ret; - int i; - __be16 buf[BMP180_REG_CALIB_COUNT / 2]; - - ret = regmap_bulk_read(data->regmap, BMP180_REG_CALIB_START, buf, - sizeof(buf)); - - if (ret < 0) - return ret; - - /* None of the words has the value 0 or 0xFFFF */ - for (i = 0; i < ARRAY_SIZE(buf); i++) { - if (buf[i] == cpu_to_be16(0) || buf[i] == cpu_to_be16(0xffff)) - return -EIO; - } - - calib->AC1 = be16_to_cpu(buf[AC1]); - calib->AC2 = be16_to_cpu(buf[AC2]); - calib->AC3 = be16_to_cpu(buf[AC3]); - calib->AC4 = be16_to_cpu(buf[AC4]); - calib->AC5 = be16_to_cpu(buf[AC5]); - calib->AC6 = be16_to_cpu(buf[AC6]); - calib->B1 = be16_to_cpu(buf[B1]); - calib->B2 = be16_to_cpu(buf[B2]); - calib->MB = be16_to_cpu(buf[MB]); - calib->MC = be16_to_cpu(buf[MC]); - calib->MD = be16_to_cpu(buf[MD]); - - return 0; -} - -/* - * Returns temperature in DegC, resolution is 0.1 DegC. - * t_fine carries fine temperature as global value. - * - * Taken from datasheet, Section 3.5, "Calculating pressure and temperature". - */ -static s32 bmp180_compensate_temp(struct bmp280_data *data, s32 adc_temp) -{ - int ret; - s32 x1, x2; - struct bmp180_calib calib; - - ret = bmp180_read_calib(data, &calib); - if (ret < 0) { - dev_err(&data->client->dev, - "failed to read calibration coefficients\n"); - return ret; - } - - x1 = ((adc_temp - calib.AC6) * calib.AC5) >> 15; - x2 = (calib.MC << 11) / (x1 + calib.MD); - data->t_fine = x1 + x2; - - return (data->t_fine + 8) >> 4; -} - -static int bmp180_read_temp(struct bmp280_data *data, int *val) -{ - int ret; - s32 adc_temp, comp_temp; - - ret = bmp180_read_adc_temp(data, &adc_temp); - if (ret) - return ret; - - comp_temp = bmp180_compensate_temp(data, adc_temp); - - /* - * val might be NULL if we're called by the read_press routine, - * who only cares about the carry over t_fine value. - */ - if (val) { - *val = comp_temp * 100; - return IIO_VAL_INT; - } - - return 0; -} - -static int bmp180_read_adc_press(struct bmp280_data *data, int *val) -{ - int ret; - __be32 tmp = 0; - u8 oss = data->oversampling_press; - - ret = bmp180_measure(data, BMP180_MEAS_PRESS_X(oss)); - if (ret) - return ret; - - ret = regmap_bulk_read(data->regmap, BMP180_REG_OUT_MSB, (u8 *)&tmp, 3); - if (ret) - return ret; - - *val = (be32_to_cpu(tmp) >> 8) >> (8 - oss); - - return 0; -} - -/* - * Returns pressure in Pa, resolution is 1 Pa. - * - * Taken from datasheet, Section 3.5, "Calculating pressure and temperature". - */ -static u32 bmp180_compensate_press(struct bmp280_data *data, s32 adc_press) -{ - int ret; - s32 x1, x2, x3, p; - s32 b3, b6; - u32 b4, b7; - s32 oss = data->oversampling_press; - struct bmp180_calib calib; - - ret = bmp180_read_calib(data, &calib); - if (ret < 0) { - dev_err(&data->client->dev, - "failed to read calibration coefficients\n"); - return ret; - } - - b6 = data->t_fine - 4000; - x1 = (calib.B2 * (b6 * b6 >> 12)) >> 11; - x2 = calib.AC2 * b6 >> 11; - x3 = x1 + x2; - b3 = ((((s32)calib.AC1 * 4 + x3) << oss) + 2) / 4; - x1 = calib.AC3 * b6 >> 13; - x2 = (calib.B1 * ((b6 * b6) >> 12)) >> 16; - x3 = (x1 + x2 + 2) >> 2; - b4 = calib.AC4 * (u32)(x3 + 32768) >> 15; - b7 = ((u32)adc_press - b3) * (50000 >> oss); - if (b7 < 0x80000000) - p = (b7 * 2) / b4; - else - p = (b7 / b4) * 2; - - x1 = (p >> 8) * (p >> 8); - x1 = (x1 * 3038) >> 16; - x2 = (-7357 * p) >> 16; - - return p + ((x1 + x2 + 3791) >> 4); -} - -static int bmp180_read_press(struct bmp280_data *data, - int *val, int *val2) -{ - int ret; - s32 adc_press; - u32 comp_press; - - /* Read and compensate temperature so we get a reading of t_fine. */ - ret = bmp180_read_temp(data, NULL); - if (ret) - return ret; - - ret = bmp180_read_adc_press(data, &adc_press); - if (ret) - return ret; - - comp_press = bmp180_compensate_press(data, adc_press); - - *val = comp_press; - *val2 = 1000; - - return IIO_VAL_FRACTIONAL; -} - -static int bmp180_chip_config(struct bmp280_data *data) -{ - return 0; -} - -static const int bmp180_oversampling_temp_avail[] = { 1 }; -static const int bmp180_oversampling_press_avail[] = { 1, 2, 4, 8 }; - -static const struct bmp280_chip_info bmp180_chip_info = { - .regmap_config = &bmp180_regmap_config, - - .oversampling_temp_avail = bmp180_oversampling_temp_avail, - .num_oversampling_temp_avail = - ARRAY_SIZE(bmp180_oversampling_temp_avail), - - .oversampling_press_avail = bmp180_oversampling_press_avail, - .num_oversampling_press_avail = - ARRAY_SIZE(bmp180_oversampling_press_avail), - - .chip_config = bmp180_chip_config, - .read_temp = bmp180_read_temp, - .read_press = bmp180_read_press, -}; - -static int bmp280_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int ret; - struct iio_dev *indio_dev; - struct bmp280_data *data; - unsigned int chip_id; - struct gpio_desc *gpiod; - - indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); - if (!indio_dev) - return -ENOMEM; - - data = iio_priv(indio_dev); - mutex_init(&data->lock); - data->client = client; - - indio_dev->dev.parent = &client->dev; - indio_dev->name = id->name; - indio_dev->channels = bmp280_channels; - indio_dev->info = &bmp280_info; - indio_dev->modes = INDIO_DIRECT_MODE; - - switch (id->driver_data) { - case BMP180_CHIP_ID: - indio_dev->num_channels = 2; - data->chip_info = &bmp180_chip_info; - data->oversampling_press = ilog2(8); - data->oversampling_temp = ilog2(1); - data->start_up_time = 10; - break; - case BMP280_CHIP_ID: - indio_dev->num_channels = 2; - data->chip_info = &bmp280_chip_info; - data->oversampling_press = ilog2(16); - data->oversampling_temp = ilog2(2); - data->start_up_time = 2; - break; - case BME280_CHIP_ID: - indio_dev->num_channels = 3; - data->chip_info = &bme280_chip_info; - data->oversampling_press = ilog2(16); - data->oversampling_humid = ilog2(16); - data->oversampling_temp = ilog2(2); - data->start_up_time = 2; - break; - default: - return -EINVAL; - } - - /* Bring up regulators */ - data->vddd = devm_regulator_get(&client->dev, "vddd"); - if (IS_ERR(data->vddd)) { - dev_err(&client->dev, "failed to get VDDD regulator\n"); - return PTR_ERR(data->vddd); - } - ret = regulator_enable(data->vddd); - if (ret) { - dev_err(&client->dev, "failed to enable VDDD regulator\n"); - return ret; - } - data->vdda = devm_regulator_get(&client->dev, "vdda"); - if (IS_ERR(data->vdda)) { - dev_err(&client->dev, "failed to get VDDA regulator\n"); - ret = PTR_ERR(data->vddd); - goto out_disable_vddd; - } - ret = regulator_enable(data->vdda); - if (ret) { - dev_err(&client->dev, "failed to enable VDDA regulator\n"); - goto out_disable_vddd; - } - /* Wait to make sure we started up properly */ - mdelay(data->start_up_time); - - /* Bring chip out of reset if there is an assigned GPIO line */ - gpiod = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH); - /* Deassert the signal */ - if (!IS_ERR(gpiod)) { - dev_info(&client->dev, "release reset\n"); - gpiod_set_value(gpiod, 0); - } - - data->regmap = devm_regmap_init_i2c(client, - data->chip_info->regmap_config); - if (IS_ERR(data->regmap)) { - dev_err(&client->dev, "failed to allocate register map\n"); - ret = PTR_ERR(data->regmap); - goto out_disable_vdda; - } - - ret = regmap_read(data->regmap, BMP280_REG_ID, &chip_id); - if (ret < 0) - return ret; - if (chip_id != id->driver_data) { - dev_err(&client->dev, "bad chip id. expected %lx got %x\n", - id->driver_data, chip_id); - ret = -EINVAL; - goto out_disable_vdda; - } - - ret = data->chip_info->chip_config(data); - if (ret < 0) - goto out_disable_vdda; - - i2c_set_clientdata(client, indio_dev); - - ret = iio_device_register(indio_dev); - if (ret) - goto out_disable_vdda; - - return 0; - -out_disable_vdda: - regulator_disable(data->vdda); -out_disable_vddd: - regulator_disable(data->vddd); - return ret; -} - -static int bmp280_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - struct bmp280_data *data = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - regulator_disable(data->vdda); - regulator_disable(data->vddd); - return 0; -} - -static const struct acpi_device_id bmp280_acpi_match[] = { - {"BMP0280", BMP280_CHIP_ID }, - {"BMP0180", BMP180_CHIP_ID }, - {"BMP0085", BMP180_CHIP_ID }, - {"BME0280", BME280_CHIP_ID }, - { }, -}; -MODULE_DEVICE_TABLE(acpi, bmp280_acpi_match); - -#ifdef CONFIG_OF -static const struct of_device_id bmp280_of_match[] = { - { .compatible = "bosch,bme280", .data = (void *)BME280_CHIP_ID }, - { .compatible = "bosch,bmp280", .data = (void *)BMP280_CHIP_ID }, - { .compatible = "bosch,bmp180", .data = (void *)BMP180_CHIP_ID }, - { .compatible = "bosch,bmp085", .data = (void *)BMP180_CHIP_ID }, - { }, -}; -MODULE_DEVICE_TABLE(of, bmp280_of_match); -#else -#define bmp280_of_match NULL -#endif - -static const struct i2c_device_id bmp280_id[] = { - {"bmp280", BMP280_CHIP_ID }, - {"bmp180", BMP180_CHIP_ID }, - {"bmp085", BMP180_CHIP_ID }, - {"bme280", BME280_CHIP_ID }, - { }, -}; -MODULE_DEVICE_TABLE(i2c, bmp280_id); - -static struct i2c_driver bmp280_driver = { - .driver = { - .name = "bmp280", - .acpi_match_table = ACPI_PTR(bmp280_acpi_match), - .of_match_table = of_match_ptr(bmp280_of_match), - }, - .probe = bmp280_probe, - .remove = bmp280_remove, - .id_table = bmp280_id, -}; -module_i2c_driver(bmp280_driver); - -MODULE_AUTHOR("Vlad Dogaru "); -MODULE_DESCRIPTION("Driver for Bosch Sensortec BMP180/BMP280 pressure and temperature sensor"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h new file mode 100644 index 0000000..b9fc28c --- /dev/null +++ b/drivers/iio/pressure/bmp280.h @@ -0,0 +1,108 @@ +#include +#include +#include + +/* BMP280 specific registers */ +#define BMP280_REG_HUMIDITY_LSB 0xFE +#define BMP280_REG_HUMIDITY_MSB 0xFD +#define BMP280_REG_TEMP_XLSB 0xFC +#define BMP280_REG_TEMP_LSB 0xFB +#define BMP280_REG_TEMP_MSB 0xFA +#define BMP280_REG_PRESS_XLSB 0xF9 +#define BMP280_REG_PRESS_LSB 0xF8 +#define BMP280_REG_PRESS_MSB 0xF7 + +#define BMP280_REG_CONFIG 0xF5 +#define BMP280_REG_CTRL_MEAS 0xF4 +#define BMP280_REG_STATUS 0xF3 +#define BMP280_REG_CTRL_HUMIDITY 0xF2 + +/* Due to non linear mapping, and data sizes we can't do a bulk read */ +#define BMP280_REG_COMP_H1 0xA1 +#define BMP280_REG_COMP_H2 0xE1 +#define BMP280_REG_COMP_H3 0xE3 +#define BMP280_REG_COMP_H4 0xE4 +#define BMP280_REG_COMP_H5 0xE5 +#define BMP280_REG_COMP_H6 0xE7 + +#define BMP280_REG_COMP_TEMP_START 0x88 +#define BMP280_COMP_TEMP_REG_COUNT 6 + +#define BMP280_REG_COMP_PRESS_START 0x8E +#define BMP280_COMP_PRESS_REG_COUNT 18 + +#define BMP280_FILTER_MASK (BIT(4) | BIT(3) | BIT(2)) +#define BMP280_FILTER_OFF 0 +#define BMP280_FILTER_2X BIT(2) +#define BMP280_FILTER_4X BIT(3) +#define BMP280_FILTER_8X (BIT(3) | BIT(2)) +#define BMP280_FILTER_16X BIT(4) + +#define BMP280_OSRS_HUMIDITY_MASK (BIT(2) | BIT(1) | BIT(0)) +#define BMP280_OSRS_HUMIDITIY_X(osrs_h) ((osrs_h) << 0) +#define BMP280_OSRS_HUMIDITY_SKIP 0 +#define BMP280_OSRS_HUMIDITY_1X BMP280_OSRS_HUMIDITIY_X(1) +#define BMP280_OSRS_HUMIDITY_2X BMP280_OSRS_HUMIDITIY_X(2) +#define BMP280_OSRS_HUMIDITY_4X BMP280_OSRS_HUMIDITIY_X(3) +#define BMP280_OSRS_HUMIDITY_8X BMP280_OSRS_HUMIDITIY_X(4) +#define BMP280_OSRS_HUMIDITY_16X BMP280_OSRS_HUMIDITIY_X(5) + +#define BMP280_OSRS_TEMP_MASK (BIT(7) | BIT(6) | BIT(5)) +#define BMP280_OSRS_TEMP_SKIP 0 +#define BMP280_OSRS_TEMP_X(osrs_t) ((osrs_t) << 5) +#define BMP280_OSRS_TEMP_1X BMP280_OSRS_TEMP_X(1) +#define BMP280_OSRS_TEMP_2X BMP280_OSRS_TEMP_X(2) +#define BMP280_OSRS_TEMP_4X BMP280_OSRS_TEMP_X(3) +#define BMP280_OSRS_TEMP_8X BMP280_OSRS_TEMP_X(4) +#define BMP280_OSRS_TEMP_16X BMP280_OSRS_TEMP_X(5) + +#define BMP280_OSRS_PRESS_MASK (BIT(4) | BIT(3) | BIT(2)) +#define BMP280_OSRS_PRESS_SKIP 0 +#define BMP280_OSRS_PRESS_X(osrs_p) ((osrs_p) << 2) +#define BMP280_OSRS_PRESS_1X BMP280_OSRS_PRESS_X(1) +#define BMP280_OSRS_PRESS_2X BMP280_OSRS_PRESS_X(2) +#define BMP280_OSRS_PRESS_4X BMP280_OSRS_PRESS_X(3) +#define BMP280_OSRS_PRESS_8X BMP280_OSRS_PRESS_X(4) +#define BMP280_OSRS_PRESS_16X BMP280_OSRS_PRESS_X(5) + +#define BMP280_MODE_MASK (BIT(1) | BIT(0)) +#define BMP280_MODE_SLEEP 0 +#define BMP280_MODE_FORCED BIT(0) +#define BMP280_MODE_NORMAL (BIT(1) | BIT(0)) + +/* BMP180 specific registers */ +#define BMP180_REG_OUT_XLSB 0xF8 +#define BMP180_REG_OUT_LSB 0xF7 +#define BMP180_REG_OUT_MSB 0xF6 + +#define BMP180_REG_CALIB_START 0xAA +#define BMP180_REG_CALIB_COUNT 22 + +#define BMP180_MEAS_SCO BIT(5) +#define BMP180_MEAS_TEMP (0x0E | BMP180_MEAS_SCO) +#define BMP180_MEAS_PRESS_X(oss) ((oss) << 6 | 0x14 | BMP180_MEAS_SCO) +#define BMP180_MEAS_PRESS_1X BMP180_MEAS_PRESS_X(0) +#define BMP180_MEAS_PRESS_2X BMP180_MEAS_PRESS_X(1) +#define BMP180_MEAS_PRESS_4X BMP180_MEAS_PRESS_X(2) +#define BMP180_MEAS_PRESS_8X BMP180_MEAS_PRESS_X(3) + +/* BMP180 and BMP280 common registers */ +#define BMP280_REG_CTRL_MEAS 0xF4 +#define BMP280_REG_RESET 0xE0 +#define BMP280_REG_ID 0xD0 + +#define BMP180_CHIP_ID 0x55 +#define BMP280_CHIP_ID 0x58 +#define BME280_CHIP_ID 0x60 +#define BMP280_SOFT_RESET_VAL 0xB6 + +/* Regmap configurations */ +extern const struct regmap_config bmp180_regmap_config; +extern const struct regmap_config bmp280_regmap_config; + +/* Probe called from different transports */ +int bmp280_common_probe(struct device *dev, + struct regmap *regmap, + unsigned int chip, + const char *name); +int bmp280_common_remove(struct device *dev); -- cgit v1.1 From 17118843a563c681aaafb29621befba02f28c592 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Jun 2016 03:48:50 +0200 Subject: iio: pressure: bmp280: split off an I2C Kconfig entry This creates a separate BMP280_I2C Kconfig entry that gets selected by BMP280 for I2C transport. As we currently only support I2C transport there is not much practical change other than getting a separate object file (or module) for the I2C driver part. The old Kconfig symbol BMP280 will still select the stuff we need so that oldconfig and old defconfigs works fine. Tested-by: Akinobu Mita Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/Kconfig | 17 ++++++++++++----- drivers/iio/pressure/Makefile | 3 ++- drivers/iio/pressure/bmp280-core.c | 7 +++++++ drivers/iio/pressure/bmp280-regmap.c | 3 +++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index 8d654f6..3d0d311 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -6,17 +6,24 @@ menu "Pressure sensors" config BMP280 - tristate "Bosch Sensortec BMP180 and BMP280 pressure sensor driver" + tristate "Bosch Sensortec BMP180/BMP280 pressure sensor I2C driver" depends on I2C depends on !(BMP085_I2C=y || BMP085_I2C=m) - select REGMAP_I2C + select REGMAP + select BMP280_I2C if (I2C) help Say yes here to build support for Bosch Sensortec BMP180 and BMP280 pressure and temperature sensors. Also supports the BE280 with - an additional humidty sensor channel. + an additional humidity sensor channel. - To compile this driver as a module, choose M here: the module - will be called bmp280. + To compile this driver as a module, choose M here: the modules + will be called bmp280-i2c and bmp280. + +config BMP280_I2C + tristate + depends on BMP280 + depends on I2C + select REGMAP_I2C config HID_SENSOR_PRESS depends on HID_SENSOR_HUB diff --git a/drivers/iio/pressure/Makefile b/drivers/iio/pressure/Makefile index 2d98a7f..736f430 100644 --- a/drivers/iio/pressure/Makefile +++ b/drivers/iio/pressure/Makefile @@ -4,7 +4,8 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_BMP280) += bmp280.o -bmp280-objs := bmp280-core.o bmp280-regmap.o bmp280-i2c.o +bmp280-objs := bmp280-core.o bmp280-regmap.o +obj-$(CONFIG_BMP280_I2C) += bmp280-i2c.o obj-$(CONFIG_HID_SENSOR_PRESS) += hid-sensor-press.o obj-$(CONFIG_HP03) += hp03.o obj-$(CONFIG_MPL115) += mpl115.o diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index 83b96fe..f1b5f8c 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -16,6 +16,7 @@ #define pr_fmt(fmt) "bmp280: " fmt #include +#include #include #include #include @@ -955,6 +956,7 @@ out_disable_vddd: regulator_disable(data->vddd); return ret; } +EXPORT_SYMBOL(bmp280_common_probe); int bmp280_common_remove(struct device *dev) { @@ -966,3 +968,8 @@ int bmp280_common_remove(struct device *dev) regulator_disable(data->vddd); return 0; } +EXPORT_SYMBOL(bmp280_common_remove); + +MODULE_AUTHOR("Vlad Dogaru "); +MODULE_DESCRIPTION("Driver for Bosch Sensortec BMP180/BMP280 pressure and temperature sensor"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iio/pressure/bmp280-regmap.c b/drivers/iio/pressure/bmp280-regmap.c index 3341189..6807113 100644 --- a/drivers/iio/pressure/bmp280-regmap.c +++ b/drivers/iio/pressure/bmp280-regmap.c @@ -1,4 +1,5 @@ #include +#include #include #include "bmp280.h" @@ -37,6 +38,7 @@ const struct regmap_config bmp180_regmap_config = { .writeable_reg = bmp180_is_writeable_reg, .volatile_reg = bmp180_is_volatile_reg, }; +EXPORT_SYMBOL(bmp180_regmap_config); static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg) { @@ -79,3 +81,4 @@ const struct regmap_config bmp280_regmap_config = { .writeable_reg = bmp280_is_writeable_reg, .volatile_reg = bmp280_is_volatile_reg, }; +EXPORT_SYMBOL(bmp280_regmap_config); -- cgit v1.1 From b26b4e91700ff45d033eeaac91597d6d479378a4 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Jun 2016 03:48:51 +0200 Subject: iio: pressure: bmp280: add SPI interface driver This patch mimics the SPI functionality found in the misc driver in drivers/misc/bh085-spi.c to make it possible to reuse the existing BMP280/BMP180/BMP085 driver with all clients of the other driver. The adoption is straight-forward since like the other driver, it is a simple matter of using regmap. This driver is also so obviously inspired/copied from the old misc driver in drivers/misc/bmp085.c that I just took the liberty to add in the authors of the other drivers + self in the core driver file. The MISC driver also supports a variant named "BMP181" so include that here to be complete in comparison to the old driver. The bus mapping code for SPI was written by Akinobu Mita. Signed-off-by: Akinobu Mita Tested-by: Akinobu Mita Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/Kconfig | 15 ++++- drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/bmp280-core.c | 4 ++ drivers/iio/pressure/bmp280-spi.c | 123 +++++++++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 drivers/iio/pressure/bmp280-spi.c diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index 3d0d311..d130cdc 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -7,17 +7,20 @@ menu "Pressure sensors" config BMP280 tristate "Bosch Sensortec BMP180/BMP280 pressure sensor I2C driver" - depends on I2C + depends on (I2C || SPI_MASTER) depends on !(BMP085_I2C=y || BMP085_I2C=m) + depends on !(BMP085_SPI=y || BMP085_SPI=m) select REGMAP select BMP280_I2C if (I2C) + select BMP280_SPI if (SPI_MASTER) help Say yes here to build support for Bosch Sensortec BMP180 and BMP280 pressure and temperature sensors. Also supports the BE280 with an additional humidity sensor channel. - To compile this driver as a module, choose M here: the modules - will be called bmp280-i2c and bmp280. + To compile this driver as a module, choose M here: the core module + will be called bmp280 and you will also get bmp280-i2c for I2C + and/or bmp280-spi for SPI support. config BMP280_I2C tristate @@ -25,6 +28,12 @@ config BMP280_I2C depends on I2C select REGMAP_I2C +config BMP280_SPI + tristate + depends on BMP280 + depends on SPI_MASTER + select REGMAP + config HID_SENSOR_PRESS depends on HID_SENSOR_HUB select IIO_BUFFER diff --git a/drivers/iio/pressure/Makefile b/drivers/iio/pressure/Makefile index 736f430..7f395be 100644 --- a/drivers/iio/pressure/Makefile +++ b/drivers/iio/pressure/Makefile @@ -6,6 +6,7 @@ obj-$(CONFIG_BMP280) += bmp280.o bmp280-objs := bmp280-core.o bmp280-regmap.o obj-$(CONFIG_BMP280_I2C) += bmp280-i2c.o +obj-$(CONFIG_BMP280_SPI) += bmp280-spi.o obj-$(CONFIG_HID_SENSOR_PRESS) += hid-sensor-press.o obj-$(CONFIG_HP03) += hp03.o obj-$(CONFIG_MPL115) += mpl115.o diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index f1b5f8c..43bd0b0 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -1,5 +1,9 @@ /* + * Copyright (c) 2010 Christoph Mair + * Copyright (c) 2012 Bosch Sensortec GmbH + * Copyright (c) 2012 Unixphere AB * Copyright (c) 2014 Intel Corporation + * Copyright (c) 2016 Linus Walleij * * Driver for Bosch Sensortec BMP180 and BMP280 digital pressure sensor. * diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c new file mode 100644 index 0000000..216e64b --- /dev/null +++ b/drivers/iio/pressure/bmp280-spi.c @@ -0,0 +1,123 @@ +/* + * SPI interface for the BMP280 driver + * + * Inspired by the older BMP085 driver drivers/misc/bmp085-spi.c + */ +#include +#include +#include +#include + +#include "bmp280.h" + +static int bmp280_regmap_spi_write(void *context, const void *data, + size_t count) +{ + struct device *dev = context; + struct spi_device *spi = to_spi_device(dev); + u8 buf[2]; + + memcpy(buf, data, 2); + /* + * The SPI register address (= full register address without bit 7) and + * the write command (bit7 = RW = '0') + */ + buf[0] &= ~0x80; + + return spi_write_then_read(spi, buf, 2, NULL, 0); +} + +static int bmp280_regmap_spi_read(void *context, const void *reg, + size_t reg_size, void *val, size_t val_size) +{ + struct device *dev = context; + struct spi_device *spi = to_spi_device(dev); + + return spi_write_then_read(spi, reg, reg_size, val, val_size); +} + +static struct regmap_bus bmp280_regmap_bus = { + .write = bmp280_regmap_spi_write, + .read = bmp280_regmap_spi_read, + .reg_format_endian_default = REGMAP_ENDIAN_BIG, + .val_format_endian_default = REGMAP_ENDIAN_BIG, +}; + +static int bmp280_spi_probe(struct spi_device *spi) +{ + const struct spi_device_id *id = spi_get_device_id(spi); + struct regmap *regmap; + const struct regmap_config *regmap_config; + int ret; + + spi->bits_per_word = 8; + ret = spi_setup(spi); + if (ret < 0) { + dev_err(&spi->dev, "spi_setup failed!\n"); + return ret; + } + + switch (id->driver_data) { + case BMP180_CHIP_ID: + regmap_config = &bmp180_regmap_config; + break; + case BMP280_CHIP_ID: + case BME280_CHIP_ID: + regmap_config = &bmp280_regmap_config; + break; + default: + return -EINVAL; + } + + regmap = devm_regmap_init(&spi->dev, + &bmp280_regmap_bus, + &spi->dev, + regmap_config); + if (IS_ERR(regmap)) { + dev_err(&spi->dev, "failed to allocate register map\n"); + return PTR_ERR(regmap); + } + + return bmp280_common_probe(&spi->dev, + regmap, + id->driver_data, + id->name); +} + +static int bmp280_spi_remove(struct spi_device *spi) +{ + return bmp280_common_remove(&spi->dev); +} + +static const struct of_device_id bmp280_of_spi_match[] = { + { .compatible = "bosch,bmp085", }, + { .compatible = "bosch,bmp180", }, + { .compatible = "bosch,bmp181", }, + { .compatible = "bosch,bmp280", }, + { .compatible = "bosch,bme280", }, + { }, +}; +MODULE_DEVICE_TABLE(of, bmp280_of_spi_match); + +static const struct spi_device_id bmp280_spi_id[] = { + { "bmp180", BMP180_CHIP_ID }, + { "bmp181", BMP180_CHIP_ID }, + { "bmp280", BMP280_CHIP_ID }, + { "bme280", BME280_CHIP_ID }, + { } +}; +MODULE_DEVICE_TABLE(spi, bmp280_spi_id); + +static struct spi_driver bmp280_spi_driver = { + .driver = { + .name = "bmp280", + .of_match_table = bmp280_of_spi_match, + }, + .id_table = bmp280_spi_id, + .probe = bmp280_spi_probe, + .remove = bmp280_spi_remove, +}; +module_spi_driver(bmp280_spi_driver); + +MODULE_DESCRIPTION("BMP280 SPI bus driver"); +MODULE_LICENSE("GPL"); -- cgit v1.1 From aae9539496510a728bfe7d555b3ecfd5a146359a Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Jun 2016 03:48:52 +0200 Subject: iio: pressure: bmp280: add support for BMP085 EOC interrupt The first version of this sensor, BMP085, supports sending an End-of-Conversion (EOC) interrupt. Add code to support this using a completion, in a similar vein as drivers/misc/bmp085.c does. Make sure to check that we are given a rising edge, because the EOC line goes from low-to-high when the conversion is ready. Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/bmp280-core.c | 87 +++++++++++++++++++++++++++++++++++--- drivers/iio/pressure/bmp280-i2c.c | 3 +- drivers/iio/pressure/bmp280-spi.c | 3 +- drivers/iio/pressure/bmp280.h | 3 +- 4 files changed, 86 insertions(+), 10 deletions(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index 43bd0b0..3ebd84f 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -27,6 +27,9 @@ #include #include #include +#include +#include /* For irq_get_irq_data() */ +#include #include "bmp280.h" @@ -34,6 +37,8 @@ struct bmp280_data { struct device *dev; struct mutex lock; struct regmap *regmap; + struct completion done; + bool use_eoc; const struct bmp280_chip_info *chip_info; struct regulator *vddd; struct regulator *vdda; @@ -595,16 +600,32 @@ static int bmp180_measure(struct bmp280_data *data, u8 ctrl_meas) unsigned int delay_us; unsigned int ctrl; + if (data->use_eoc) + init_completion(&data->done); + ret = regmap_write(data->regmap, BMP280_REG_CTRL_MEAS, ctrl_meas); if (ret) return ret; - if (ctrl_meas == BMP180_MEAS_TEMP) - delay_us = 4500; - else - delay_us = conversion_time_max[data->oversampling_press]; - - usleep_range(delay_us, delay_us + 1000); + if (data->use_eoc) { + /* + * If we have a completion interrupt, use it, wait up to + * 100ms. The longest conversion time listed is 76.5 ms for + * advanced resolution mode. + */ + ret = wait_for_completion_timeout(&data->done, + 1 + msecs_to_jiffies(100)); + if (!ret) + dev_err(data->dev, "timeout waiting for completion\n"); + } else { + if (ctrl_meas == BMP180_MEAS_TEMP) + delay_us = 4500; + else + delay_us = + conversion_time_max[data->oversampling_press]; + + usleep_range(delay_us, delay_us + 1000); + } ret = regmap_read(data->regmap, BMP280_REG_CTRL_MEAS, &ctrl); if (ret) @@ -846,10 +867,51 @@ static const struct bmp280_chip_info bmp180_chip_info = { .read_press = bmp180_read_press, }; +static irqreturn_t bmp085_eoc_irq(int irq, void *d) +{ + struct bmp280_data *data = d; + + complete(&data->done); + + return IRQ_HANDLED; +} + +static int bmp085_fetch_eoc_irq(struct device *dev, + const char *name, + int irq, + struct bmp280_data *data) +{ + unsigned long irq_trig; + int ret; + + irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq)); + if (irq_trig != IRQF_TRIGGER_RISING) { + dev_err(dev, "non-rising trigger given for EOC interrupt, " + "trying to enforce it\n"); + irq_trig = IRQF_TRIGGER_RISING; + } + ret = devm_request_threaded_irq(dev, + irq, + bmp085_eoc_irq, + NULL, + irq_trig, + name, + data); + if (ret) { + /* Bail out without IRQ but keep the driver in place */ + dev_err(dev, "unable to request DRDY IRQ\n"); + return 0; + } + + data->use_eoc = true; + return 0; +} + int bmp280_common_probe(struct device *dev, struct regmap *regmap, unsigned int chip, - const char *name) + const char *name, + int irq) { int ret; struct iio_dev *indio_dev; @@ -948,6 +1010,17 @@ int bmp280_common_probe(struct device *dev, dev_set_drvdata(dev, indio_dev); + /* + * Attempt to grab an optional EOC IRQ - only the BMP085 has this + * however as it happens, the BMP085 shares the chip ID of BMP180 + * so we look for an IRQ if we have that. + */ + if (irq > 0 || (chip_id == BMP180_CHIP_ID)) { + ret = bmp085_fetch_eoc_irq(dev, name, irq, data); + if (ret) + goto out_disable_vdda; + } + ret = iio_device_register(indio_dev); if (ret) goto out_disable_vdda; diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c index 7c70ee1..8cf8a90 100644 --- a/drivers/iio/pressure/bmp280-i2c.c +++ b/drivers/iio/pressure/bmp280-i2c.c @@ -33,7 +33,8 @@ static int bmp280_i2c_probe(struct i2c_client *client, return bmp280_common_probe(&client->dev, regmap, id->driver_data, - id->name); + id->name, + client->irq); } static int bmp280_i2c_remove(struct i2c_client *client) diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c index 216e64b..cd365ba 100644 --- a/drivers/iio/pressure/bmp280-spi.c +++ b/drivers/iio/pressure/bmp280-spi.c @@ -81,7 +81,8 @@ static int bmp280_spi_probe(struct spi_device *spi) return bmp280_common_probe(&spi->dev, regmap, id->driver_data, - id->name); + id->name, + spi->irq); } static int bmp280_spi_remove(struct spi_device *spi) diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h index b9fc28c..573334b8 100644 --- a/drivers/iio/pressure/bmp280.h +++ b/drivers/iio/pressure/bmp280.h @@ -104,5 +104,6 @@ extern const struct regmap_config bmp280_regmap_config; int bmp280_common_probe(struct device *dev, struct regmap *regmap, unsigned int chip, - const char *name); + const char *name, + int irq); int bmp280_common_remove(struct device *dev); -- cgit v1.1 From 3d838118c6aa73ae28e49bd9a014e2e9bd6ed3ab Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Jun 2016 03:48:53 +0200 Subject: iio: pressure: bmp280: add power management The PM280 has an internal standby-mode, but to really save power we should shut the sensor down and disconnect the power. With the proper .pm hooks we can enable both runtime and system power management of the sensor. We use the *force callbacks from the system PM hooks. When the sensor comes back we always reconfigure it to make sure it is ready to roll as expected. Cc: Ulf Hansson Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/bmp280-core.c | 65 +++++++++++++++++++++++++++++++++++++- drivers/iio/pressure/bmp280-i2c.c | 1 + drivers/iio/pressure/bmp280-spi.c | 1 + drivers/iio/pressure/bmp280.h | 3 ++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index 3ebd84f..f25df7f 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -30,6 +30,7 @@ #include #include /* For irq_get_irq_data() */ #include +#include #include "bmp280.h" @@ -336,6 +337,7 @@ static int bmp280_read_raw(struct iio_dev *indio_dev, int ret; struct bmp280_data *data = iio_priv(indio_dev); + pm_runtime_get_sync(data->dev); mutex_lock(&data->lock); switch (mask) { @@ -380,6 +382,8 @@ static int bmp280_read_raw(struct iio_dev *indio_dev, } mutex_unlock(&data->lock); + pm_runtime_mark_last_busy(data->dev); + pm_runtime_put_autosuspend(data->dev); return ret; } @@ -444,6 +448,7 @@ static int bmp280_write_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + pm_runtime_get_sync(data->dev); mutex_lock(&data->lock); switch (chan->type) { case IIO_HUMIDITYRELATIVE: @@ -460,6 +465,8 @@ static int bmp280_write_raw(struct iio_dev *indio_dev, break; } mutex_unlock(&data->lock); + pm_runtime_mark_last_busy(data->dev); + pm_runtime_put_autosuspend(data->dev); break; default: return -EINVAL; @@ -1021,12 +1028,29 @@ int bmp280_common_probe(struct device *dev, goto out_disable_vdda; } + /* Enable runtime PM */ + pm_runtime_get_noresume(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + /* + * Set autosuspend to two orders of magnitude larger than the + * start-up time. + */ + pm_runtime_set_autosuspend_delay(dev, data->start_up_time *100); + pm_runtime_use_autosuspend(dev); + pm_runtime_put(dev); + ret = iio_device_register(indio_dev); if (ret) - goto out_disable_vdda; + goto out_runtime_pm_disable; + return 0; +out_runtime_pm_disable: + pm_runtime_get_sync(data->dev); + pm_runtime_put_noidle(data->dev); + pm_runtime_disable(data->dev); out_disable_vdda: regulator_disable(data->vdda); out_disable_vddd: @@ -1041,12 +1065,51 @@ int bmp280_common_remove(struct device *dev) struct bmp280_data *data = iio_priv(indio_dev); iio_device_unregister(indio_dev); + pm_runtime_get_sync(data->dev); + pm_runtime_put_noidle(data->dev); + pm_runtime_disable(data->dev); regulator_disable(data->vdda); regulator_disable(data->vddd); return 0; } EXPORT_SYMBOL(bmp280_common_remove); +#ifdef CONFIG_PM +static int bmp280_runtime_suspend(struct device *dev) +{ + struct bmp280_data *data = dev_get_drvdata(dev); + int ret; + + ret = regulator_disable(data->vdda); + if (ret) + return ret; + return regulator_disable(data->vddd); +} + +static int bmp280_runtime_resume(struct device *dev) +{ + struct bmp280_data *data = dev_get_drvdata(dev); + int ret; + + ret = regulator_enable(data->vddd); + if (ret) + return ret; + ret = regulator_enable(data->vdda); + if (ret) + return ret; + msleep(data->start_up_time); + return data->chip_info->chip_config(data); +} +#endif /* CONFIG_PM */ + +const struct dev_pm_ops bmp280_dev_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) + SET_RUNTIME_PM_OPS(bmp280_runtime_suspend, + bmp280_runtime_resume, NULL) +}; +EXPORT_SYMBOL(bmp280_dev_pm_ops); + MODULE_AUTHOR("Vlad Dogaru "); MODULE_DESCRIPTION("Driver for Bosch Sensortec BMP180/BMP280 pressure and temperature sensor"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/iio/pressure/bmp280-i2c.c b/drivers/iio/pressure/bmp280-i2c.c index 8cf8a90..03742b1 100644 --- a/drivers/iio/pressure/bmp280-i2c.c +++ b/drivers/iio/pressure/bmp280-i2c.c @@ -78,6 +78,7 @@ static struct i2c_driver bmp280_i2c_driver = { .name = "bmp280", .acpi_match_table = ACPI_PTR(bmp280_acpi_i2c_match), .of_match_table = of_match_ptr(bmp280_of_i2c_match), + .pm = &bmp280_dev_pm_ops, }, .probe = bmp280_i2c_probe, .remove = bmp280_i2c_remove, diff --git a/drivers/iio/pressure/bmp280-spi.c b/drivers/iio/pressure/bmp280-spi.c index cd365ba..17bc955 100644 --- a/drivers/iio/pressure/bmp280-spi.c +++ b/drivers/iio/pressure/bmp280-spi.c @@ -113,6 +113,7 @@ static struct spi_driver bmp280_spi_driver = { .driver = { .name = "bmp280", .of_match_table = bmp280_of_spi_match, + .pm = &bmp280_dev_pm_ops, }, .id_table = bmp280_spi_id, .probe = bmp280_spi_probe, diff --git a/drivers/iio/pressure/bmp280.h b/drivers/iio/pressure/bmp280.h index 573334b8..2c770e1 100644 --- a/drivers/iio/pressure/bmp280.h +++ b/drivers/iio/pressure/bmp280.h @@ -107,3 +107,6 @@ int bmp280_common_probe(struct device *dev, const char *name, int irq); int bmp280_common_remove(struct device *dev); + +/* PM ops */ +extern const struct dev_pm_ops bmp280_dev_pm_ops; -- cgit v1.1 From b33b7d5ac30616aca73cc13a3dc06ac45d166ea0 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 30 Jun 2016 03:48:54 +0200 Subject: iio: pressure: bmp280: read calibration data once The calibration data is described as coming from an E2PROM and that means it does not change. Just read it once at probe time and store it in the device state container. Also toss the calibration data into the entropy pool since it is device unique. Reviewed-by: Vlad Dogaru Signed-off-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/bmp280-core.c | 94 +++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index f25df7f..6943688 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -31,9 +31,30 @@ #include /* For irq_get_irq_data() */ #include #include +#include #include "bmp280.h" +/* + * These enums are used for indexing into the array of calibration + * coefficients for BMP180. + */ +enum { AC1, AC2, AC3, AC4, AC5, AC6, B1, B2, MB, MC, MD }; + +struct bmp180_calib { + s16 AC1; + s16 AC2; + s16 AC3; + u16 AC4; + u16 AC5; + u16 AC6; + s16 B1; + s16 B2; + s16 MB; + s16 MC; + s16 MD; +}; + struct bmp280_data { struct device *dev; struct mutex lock; @@ -41,6 +62,7 @@ struct bmp280_data { struct completion done; bool use_eoc; const struct bmp280_chip_info *chip_info; + struct bmp180_calib calib; struct regulator *vddd; struct regulator *vdda; unsigned int start_up_time; /* in milliseconds */ @@ -663,26 +685,6 @@ static int bmp180_read_adc_temp(struct bmp280_data *data, int *val) return 0; } -/* - * These enums are used for indexing into the array of calibration - * coefficients for BMP180. - */ -enum { AC1, AC2, AC3, AC4, AC5, AC6, B1, B2, MB, MC, MD }; - -struct bmp180_calib { - s16 AC1; - s16 AC2; - s16 AC3; - u16 AC4; - u16 AC5; - u16 AC6; - s16 B1; - s16 B2; - s16 MB; - s16 MC; - s16 MD; -}; - static int bmp180_read_calib(struct bmp280_data *data, struct bmp180_calib *calib) { @@ -702,6 +704,9 @@ static int bmp180_read_calib(struct bmp280_data *data, return -EIO; } + /* Toss the calibration data into the entropy pool */ + add_device_randomness(buf, sizeof(buf)); + calib->AC1 = be16_to_cpu(buf[AC1]); calib->AC2 = be16_to_cpu(buf[AC2]); calib->AC3 = be16_to_cpu(buf[AC3]); @@ -725,19 +730,11 @@ static int bmp180_read_calib(struct bmp280_data *data, */ static s32 bmp180_compensate_temp(struct bmp280_data *data, s32 adc_temp) { - int ret; s32 x1, x2; - struct bmp180_calib calib; + struct bmp180_calib *calib = &data->calib; - ret = bmp180_read_calib(data, &calib); - if (ret < 0) { - dev_err(data->dev, - "failed to read calibration coefficients\n"); - return ret; - } - - x1 = ((adc_temp - calib.AC6) * calib.AC5) >> 15; - x2 = (calib.MC << 11) / (x1 + calib.MD); + x1 = ((adc_temp - calib->AC6) * calib->AC5) >> 15; + x2 = (calib->MC << 11) / (x1 + calib->MD); data->t_fine = x1 + x2; return (data->t_fine + 8) >> 4; @@ -792,29 +789,21 @@ static int bmp180_read_adc_press(struct bmp280_data *data, int *val) */ static u32 bmp180_compensate_press(struct bmp280_data *data, s32 adc_press) { - int ret; s32 x1, x2, x3, p; s32 b3, b6; u32 b4, b7; s32 oss = data->oversampling_press; - struct bmp180_calib calib; - - ret = bmp180_read_calib(data, &calib); - if (ret < 0) { - dev_err(data->dev, - "failed to read calibration coefficients\n"); - return ret; - } + struct bmp180_calib *calib = &data->calib; b6 = data->t_fine - 4000; - x1 = (calib.B2 * (b6 * b6 >> 12)) >> 11; - x2 = calib.AC2 * b6 >> 11; + x1 = (calib->B2 * (b6 * b6 >> 12)) >> 11; + x2 = calib->AC2 * b6 >> 11; x3 = x1 + x2; - b3 = ((((s32)calib.AC1 * 4 + x3) << oss) + 2) / 4; - x1 = calib.AC3 * b6 >> 13; - x2 = (calib.B1 * ((b6 * b6) >> 12)) >> 16; + b3 = ((((s32)calib->AC1 * 4 + x3) << oss) + 2) / 4; + x1 = calib->AC3 * b6 >> 13; + x2 = (calib->B1 * ((b6 * b6) >> 12)) >> 16; x3 = (x1 + x2 + 2) >> 2; - b4 = calib.AC4 * (u32)(x3 + 32768) >> 15; + b4 = calib->AC4 * (u32)(x3 + 32768) >> 15; b7 = ((u32)adc_press - b3) * (50000 >> oss); if (b7 < 0x80000000) p = (b7 * 2) / b4; @@ -1018,6 +1007,19 @@ int bmp280_common_probe(struct device *dev, dev_set_drvdata(dev, indio_dev); /* + * The BMP085 and BMP180 has calibration in an E2PROM, read it out + * at probe time. It will not change. + */ + if (chip_id == BMP180_CHIP_ID) { + ret = bmp180_read_calib(data, &data->calib); + if (ret < 0) { + dev_err(data->dev, + "failed to read calibration coefficients\n"); + goto out_disable_vdda; + } + } + + /* * Attempt to grab an optional EOC IRQ - only the BMP085 has this * however as it happens, the BMP085 shares the chip ID of BMP180 * so we look for an IRQ if we have that. -- cgit v1.1 From d3c4d0ab3b4e7cdfe5a209ba4d58bf5787e7c47f Mon Sep 17 00:00:00 2001 From: Raveendra Padasalagi Date: Tue, 28 Jun 2016 13:10:34 +0530 Subject: Documentation: DT: Add iproc-static-adc binding The patch adds devicetree binding document for broadcom's iproc-static-adc controller driver. Signed-off-by: Raveendra Padasalagi Reviewed-by: Ray Jui Reviewed-by: Scott Branden Acked-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../bindings/iio/adc/brcm,iproc-static-adc.txt | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt diff --git a/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt new file mode 100644 index 0000000..caaaed7 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt @@ -0,0 +1,41 @@ +* Broadcom's IPROC Static ADC controller + +Broadcom iProc ADC controller has 8 channels 10bit ADC. +Allows user to convert analog input voltage values to digital. + +Required properties: + +- compatible: Must be "brcm,iproc-static-adc" + +- adc-syscon: Handler of syscon node defining physical base address of the + controller and length of memory mapped region. + +- #io-channel-cells = <1>; As ADC has multiple outputs + refer to Documentation/devicetree/bindings/iio/iio-bindings.txt for details. + +- io-channel-ranges: + refer to Documentation/devicetree/bindings/iio/iio-bindings.txt for details. + +- clocks: Clock used for this block. + +- clock-names: Clock name should be given as tsc_clk. + +- interrupts: interrupt line number. + +For example: + + ts_adc_syscon: ts_adc_syscon@180a6000 { + compatible = "brcm,iproc-ts-adc-syscon","syscon"; + reg = <0x180a6000 0xc30>; + }; + + adc: adc@180a6000 { + compatible = "brcm,iproc-static-adc"; + adc-syscon = <&ts_adc_syscon>; + #io-channel-cells = <1>; + io-channel-ranges; + clocks = <&asiu_clks BCM_CYGNUS_ASIU_ADC_CLK>; + clock-names = "tsc_clk"; + interrupts = ; + status = "disabled"; + }; -- cgit v1.1 From 4324c97ecedcba8a548bcff9d620880e11359425 Mon Sep 17 00:00:00 2001 From: Raveendra Padasalagi Date: Tue, 28 Jun 2016 13:10:35 +0530 Subject: iio: Add driver for Broadcom iproc-static-adc This patch adds basic driver implementation for Broadcom's static adc controller used in iProc SoC's family. Signed-off-by: Raveendra Padasalagi Reviewed-by: Ray Jui Reviewed-by: Scott Branden Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 12 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/bcm_iproc_adc.c | 644 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 657 insertions(+) create mode 100644 drivers/iio/adc/bcm_iproc_adc.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 25378c5..1de31bd 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -153,6 +153,18 @@ config AXP288_ADC To compile this driver as a module, choose M here: the module will be called axp288_adc. +config BCM_IPROC_ADC + tristate "Broadcom IPROC ADC driver" + depends on ARCH_BCM_IPROC || COMPILE_TEST + depends on MFD_SYSCON + default ARCH_BCM_CYGNUS + help + Say Y here if you want to add support for the Broadcom static + ADC driver. + + Broadcom iProc ADC driver. Broadcom iProc ADC controller has 8 + channels. The driver allows the user to read voltage values. + config BERLIN2_ADC tristate "Marvell Berlin2 ADC driver" depends on ARCH_BERLIN diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 38638d4..0ba0d50 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_AD799X) += ad799x.o obj-$(CONFIG_AT91_ADC) += at91_adc.o obj-$(CONFIG_AT91_SAMA5D2_ADC) += at91-sama5d2_adc.o obj-$(CONFIG_AXP288_ADC) += axp288_adc.o +obj-$(CONFIG_BCM_IPROC_ADC) += bcm_iproc_adc.o obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c new file mode 100644 index 0000000..21d38c8 --- /dev/null +++ b/drivers/iio/adc/bcm_iproc_adc.c @@ -0,0 +1,644 @@ +/* + * Copyright 2016 Broadcom + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* Below Register's are common to IPROC ADC and Touchscreen IP */ +#define IPROC_REGCTL1 0x00 +#define IPROC_REGCTL2 0x04 +#define IPROC_INTERRUPT_THRES 0x08 +#define IPROC_INTERRUPT_MASK 0x0c +#define IPROC_INTERRUPT_STATUS 0x10 +#define IPROC_ANALOG_CONTROL 0x1c +#define IPROC_CONTROLLER_STATUS 0x14 +#define IPROC_AUX_DATA 0x20 +#define IPROC_SOFT_BYPASS_CONTROL 0x38 +#define IPROC_SOFT_BYPASS_DATA 0x3C + +/* IPROC ADC Channel register offsets */ +#define IPROC_ADC_CHANNEL_REGCTL1 0x800 +#define IPROC_ADC_CHANNEL_REGCTL2 0x804 +#define IPROC_ADC_CHANNEL_STATUS 0x808 +#define IPROC_ADC_CHANNEL_INTERRUPT_STATUS 0x80c +#define IPROC_ADC_CHANNEL_INTERRUPT_MASK 0x810 +#define IPROC_ADC_CHANNEL_DATA 0x814 +#define IPROC_ADC_CHANNEL_OFFSET 0x20 + +/* Bit definitions for IPROC_REGCTL2 */ +#define IPROC_ADC_AUXIN_SCAN_ENA BIT(0) +#define IPROC_ADC_PWR_LDO BIT(5) +#define IPROC_ADC_PWR_ADC BIT(4) +#define IPROC_ADC_PWR_BG BIT(3) +#define IPROC_ADC_CONTROLLER_EN BIT(17) + +/* Bit definitions for IPROC_INTERRUPT_MASK and IPROC_INTERRUPT_STATUS */ +#define IPROC_ADC_AUXDATA_RDY_INTR BIT(3) +#define IPROC_ADC_INTR 9 +#define IPROC_ADC_INTR_MASK (0xFF << IPROC_ADC_INTR) + +/* Bit definitions for IPROC_ANALOG_CONTROL */ +#define IPROC_ADC_CHANNEL_SEL 11 +#define IPROC_ADC_CHANNEL_SEL_MASK (0x7 << IPROC_ADC_CHANNEL_SEL) + +/* Bit definitions for IPROC_ADC_CHANNEL_REGCTL1 */ +#define IPROC_ADC_CHANNEL_ROUNDS 0x2 +#define IPROC_ADC_CHANNEL_ROUNDS_MASK (0x3F << IPROC_ADC_CHANNEL_ROUNDS) +#define IPROC_ADC_CHANNEL_MODE 0x1 +#define IPROC_ADC_CHANNEL_MODE_MASK (0x1 << IPROC_ADC_CHANNEL_MODE) +#define IPROC_ADC_CHANNEL_MODE_TDM 0x1 +#define IPROC_ADC_CHANNEL_MODE_SNAPSHOT 0x0 +#define IPROC_ADC_CHANNEL_ENABLE 0x0 +#define IPROC_ADC_CHANNEL_ENABLE_MASK 0x1 + +/* Bit definitions for IPROC_ADC_CHANNEL_REGCTL2 */ +#define IPROC_ADC_CHANNEL_WATERMARK 0x0 +#define IPROC_ADC_CHANNEL_WATERMARK_MASK \ + (0x3F << IPROC_ADC_CHANNEL_WATERMARK) + +#define IPROC_ADC_WATER_MARK_LEVEL 0x1 + +/* Bit definitions for IPROC_ADC_CHANNEL_STATUS */ +#define IPROC_ADC_CHANNEL_DATA_LOST 0x0 +#define IPROC_ADC_CHANNEL_DATA_LOST_MASK \ + (0x0 << IPROC_ADC_CHANNEL_DATA_LOST) +#define IPROC_ADC_CHANNEL_VALID_ENTERIES 0x1 +#define IPROC_ADC_CHANNEL_VALID_ENTERIES_MASK \ + (0xFF << IPROC_ADC_CHANNEL_VALID_ENTERIES) +#define IPROC_ADC_CHANNEL_TOTAL_ENTERIES 0x9 +#define IPROC_ADC_CHANNEL_TOTAL_ENTERIES_MASK \ + (0xFF << IPROC_ADC_CHANNEL_TOTAL_ENTERIES) + +/* Bit definitions for IPROC_ADC_CHANNEL_INTERRUPT_MASK */ +#define IPROC_ADC_CHANNEL_WTRMRK_INTR 0x0 +#define IPROC_ADC_CHANNEL_WTRMRK_INTR_MASK \ + (0x1 << IPROC_ADC_CHANNEL_WTRMRK_INTR) +#define IPROC_ADC_CHANNEL_FULL_INTR 0x1 +#define IPROC_ADC_CHANNEL_FULL_INTR_MASK \ + (0x1 << IPROC_ADC_IPROC_ADC_CHANNEL_FULL_INTR) +#define IPROC_ADC_CHANNEL_EMPTY_INTR 0x2 +#define IPROC_ADC_CHANNEL_EMPTY_INTR_MASK \ + (0x1 << IPROC_ADC_CHANNEL_EMPTY_INTR) + +#define IPROC_ADC_WATER_MARK_INTR_ENABLE 0x1 + +/* Number of time to retry a set of the interrupt mask reg */ +#define IPROC_ADC_INTMASK_RETRY_ATTEMPTS 10 + +#define IPROC_ADC_READ_TIMEOUT (HZ*2) + +#define iproc_adc_dbg_reg(dev, priv, reg) \ +do { \ + u32 val; \ + regmap_read(priv->regmap, reg, &val); \ + dev_dbg(dev, "%20s= 0x%08x\n", #reg, val); \ +} while (0) + +struct iproc_adc_priv { + struct regmap *regmap; + struct clk *adc_clk; + struct mutex mutex; + int irqno; + int chan_val; + int chan_id; + struct completion completion; +}; + +static void iproc_adc_reg_dump(struct iio_dev *indio_dev) +{ + struct device *dev = &indio_dev->dev; + struct iproc_adc_priv *adc_priv = iio_priv(indio_dev); + + iproc_adc_dbg_reg(dev, adc_priv, IPROC_REGCTL1); + iproc_adc_dbg_reg(dev, adc_priv, IPROC_REGCTL2); + iproc_adc_dbg_reg(dev, adc_priv, IPROC_INTERRUPT_THRES); + iproc_adc_dbg_reg(dev, adc_priv, IPROC_INTERRUPT_MASK); + iproc_adc_dbg_reg(dev, adc_priv, IPROC_INTERRUPT_STATUS); + iproc_adc_dbg_reg(dev, adc_priv, IPROC_CONTROLLER_STATUS); + iproc_adc_dbg_reg(dev, adc_priv, IPROC_ANALOG_CONTROL); + iproc_adc_dbg_reg(dev, adc_priv, IPROC_AUX_DATA); + iproc_adc_dbg_reg(dev, adc_priv, IPROC_SOFT_BYPASS_CONTROL); + iproc_adc_dbg_reg(dev, adc_priv, IPROC_SOFT_BYPASS_DATA); +} + +static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data) +{ + u32 channel_intr_status; + u32 intr_status; + u32 intr_mask; + struct iio_dev *indio_dev = data; + struct iproc_adc_priv *adc_priv = iio_priv(indio_dev); + + /* + * This interrupt is shared with the touchscreen driver. + * Make sure this interrupt is intended for us. + * Handle only ADC channel specific interrupts. + */ + regmap_read(adc_priv->regmap, IPROC_INTERRUPT_STATUS, &intr_status); + regmap_read(adc_priv->regmap, IPROC_INTERRUPT_MASK, &intr_mask); + intr_status = intr_status & intr_mask; + channel_intr_status = (intr_status & IPROC_ADC_INTR_MASK) >> + IPROC_ADC_INTR; + if (channel_intr_status) + return IRQ_WAKE_THREAD; + + return IRQ_NONE; +} + +static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data) +{ + irqreturn_t retval = IRQ_NONE; + struct iproc_adc_priv *adc_priv; + struct iio_dev *indio_dev = data; + unsigned int valid_entries; + u32 intr_status; + u32 intr_channels; + u32 channel_status; + u32 ch_intr_status; + + adc_priv = iio_priv(indio_dev); + + regmap_read(adc_priv->regmap, IPROC_INTERRUPT_STATUS, &intr_status); + dev_dbg(&indio_dev->dev, "iproc_adc_interrupt_thread(),INTRPT_STS:%x\n", + intr_status); + + intr_channels = (intr_status & IPROC_ADC_INTR_MASK) >> IPROC_ADC_INTR; + if (intr_channels) { + regmap_read(adc_priv->regmap, + IPROC_ADC_CHANNEL_INTERRUPT_STATUS + + IPROC_ADC_CHANNEL_OFFSET * adc_priv->chan_id, + &ch_intr_status); + + if (ch_intr_status & IPROC_ADC_CHANNEL_WTRMRK_INTR_MASK) { + regmap_read(adc_priv->regmap, + IPROC_ADC_CHANNEL_STATUS + + IPROC_ADC_CHANNEL_OFFSET * + adc_priv->chan_id, + &channel_status); + + valid_entries = ((channel_status & + IPROC_ADC_CHANNEL_VALID_ENTERIES_MASK) >> + IPROC_ADC_CHANNEL_VALID_ENTERIES); + if (valid_entries >= 1) { + regmap_read(adc_priv->regmap, + IPROC_ADC_CHANNEL_DATA + + IPROC_ADC_CHANNEL_OFFSET * + adc_priv->chan_id, + &adc_priv->chan_val); + complete(&adc_priv->completion); + } else { + dev_err(&indio_dev->dev, + "No data rcvd on channel %d\n", + adc_priv->chan_id); + } + regmap_write(adc_priv->regmap, + IPROC_ADC_CHANNEL_INTERRUPT_MASK + + IPROC_ADC_CHANNEL_OFFSET * + adc_priv->chan_id, + (ch_intr_status & + ~(IPROC_ADC_CHANNEL_WTRMRK_INTR_MASK))); + } + regmap_write(adc_priv->regmap, + IPROC_ADC_CHANNEL_INTERRUPT_STATUS + + IPROC_ADC_CHANNEL_OFFSET * adc_priv->chan_id, + ch_intr_status); + regmap_write(adc_priv->regmap, IPROC_INTERRUPT_STATUS, + intr_channels); + retval = IRQ_HANDLED; + } + + return retval; +} + +static int iproc_adc_do_read(struct iio_dev *indio_dev, + int channel, + u16 *p_adc_data) +{ + int read_len = 0; + u32 val; + u32 mask; + u32 val_check; + int failed_cnt = 0; + struct iproc_adc_priv *adc_priv = iio_priv(indio_dev); + + mutex_lock(&adc_priv->mutex); + + /* + * After a read is complete the ADC interrupts will be disabled so + * we can assume this section of code is safe from interrupts. + */ + adc_priv->chan_val = -1; + adc_priv->chan_id = channel; + + reinit_completion(&adc_priv->completion); + /* Clear any pending interrupt */ + regmap_update_bits(adc_priv->regmap, IPROC_INTERRUPT_STATUS, + IPROC_ADC_INTR_MASK | IPROC_ADC_AUXDATA_RDY_INTR, + ((0x0 << channel) << IPROC_ADC_INTR) | + IPROC_ADC_AUXDATA_RDY_INTR); + + /* Configure channel for snapshot mode and enable */ + val = (BIT(IPROC_ADC_CHANNEL_ROUNDS) | + (IPROC_ADC_CHANNEL_MODE_SNAPSHOT << IPROC_ADC_CHANNEL_MODE) | + (0x1 << IPROC_ADC_CHANNEL_ENABLE)); + + mask = IPROC_ADC_CHANNEL_ROUNDS_MASK | IPROC_ADC_CHANNEL_MODE_MASK | + IPROC_ADC_CHANNEL_ENABLE_MASK; + regmap_update_bits(adc_priv->regmap, (IPROC_ADC_CHANNEL_REGCTL1 + + IPROC_ADC_CHANNEL_OFFSET * channel), + mask, val); + + /* Set the Watermark for a channel */ + regmap_update_bits(adc_priv->regmap, (IPROC_ADC_CHANNEL_REGCTL2 + + IPROC_ADC_CHANNEL_OFFSET * channel), + IPROC_ADC_CHANNEL_WATERMARK_MASK, + 0x1); + + /* Enable water mark interrupt */ + regmap_update_bits(adc_priv->regmap, (IPROC_ADC_CHANNEL_INTERRUPT_MASK + + IPROC_ADC_CHANNEL_OFFSET * + channel), + IPROC_ADC_CHANNEL_WTRMRK_INTR_MASK, + IPROC_ADC_WATER_MARK_INTR_ENABLE); + regmap_read(adc_priv->regmap, IPROC_INTERRUPT_MASK, &val); + + /* Enable ADC interrupt for a channel */ + val |= (BIT(channel) << IPROC_ADC_INTR); + regmap_write(adc_priv->regmap, IPROC_INTERRUPT_MASK, val); + + /* + * There seems to be a very rare issue where writing to this register + * does not take effect. To work around the issue we will try multiple + * writes. In total we will spend about 10*10 = 100 us attempting this. + * Testing has shown that this may loop a few time, but we have never + * hit the full count. + */ + regmap_read(adc_priv->regmap, IPROC_INTERRUPT_MASK, &val_check); + while (val_check != val) { + failed_cnt++; + + if (failed_cnt > IPROC_ADC_INTMASK_RETRY_ATTEMPTS) + break; + + udelay(10); + regmap_update_bits(adc_priv->regmap, IPROC_INTERRUPT_MASK, + IPROC_ADC_INTR_MASK, + ((0x1 << channel) << + IPROC_ADC_INTR)); + + regmap_read(adc_priv->regmap, IPROC_INTERRUPT_MASK, &val_check); + } + + if (failed_cnt) { + dev_dbg(&indio_dev->dev, + "IntMask failed (%d times)", failed_cnt); + if (failed_cnt > IPROC_ADC_INTMASK_RETRY_ATTEMPTS) { + dev_err(&indio_dev->dev, + "IntMask set failed. Read will likely fail."); + read_len = -EIO; + goto adc_err; + }; + } + regmap_read(adc_priv->regmap, IPROC_INTERRUPT_MASK, &val_check); + + if (wait_for_completion_timeout(&adc_priv->completion, + IPROC_ADC_READ_TIMEOUT) > 0) { + + /* Only the lower 16 bits are relevant */ + *p_adc_data = adc_priv->chan_val & 0xFFFF; + read_len = sizeof(*p_adc_data); + + } else { + /* + * We never got the interrupt, something went wrong. + * Perhaps the interrupt may still be coming, we do not want + * that now. Lets disable the ADC interrupt, and clear the + * status to put it back in to normal state. + */ + read_len = -ETIMEDOUT; + goto adc_err; + } + mutex_unlock(&adc_priv->mutex); + + return read_len; + +adc_err: + regmap_update_bits(adc_priv->regmap, IPROC_INTERRUPT_MASK, + IPROC_ADC_INTR_MASK, + ((0x0 << channel) << IPROC_ADC_INTR)); + + regmap_update_bits(adc_priv->regmap, IPROC_INTERRUPT_STATUS, + IPROC_ADC_INTR_MASK, + ((0x0 << channel) << IPROC_ADC_INTR)); + + dev_err(&indio_dev->dev, "Timed out waiting for ADC data!\n"); + iproc_adc_reg_dump(indio_dev); + mutex_unlock(&adc_priv->mutex); + + return read_len; +} + +static int iproc_adc_enable(struct iio_dev *indio_dev) +{ + u32 val; + u32 channel_id; + struct iproc_adc_priv *adc_priv = iio_priv(indio_dev); + int ret; + + /* Set i_amux = 3b'000, select channel 0 */ + ret = regmap_update_bits(adc_priv->regmap, IPROC_ANALOG_CONTROL, + IPROC_ADC_CHANNEL_SEL_MASK, 0); + if (ret) { + dev_err(&indio_dev->dev, + "failed to write IPROC_ANALOG_CONTROL %d\n", ret); + return ret; + } + adc_priv->chan_val = -1; + + /* + * PWR up LDO, ADC, and Band Gap (0 to enable) + * Also enable ADC controller (set high) + */ + ret = regmap_read(adc_priv->regmap, IPROC_REGCTL2, &val); + if (ret) { + dev_err(&indio_dev->dev, + "failed to read IPROC_REGCTL2 %d\n", ret); + return ret; + } + + val &= ~(IPROC_ADC_PWR_LDO | IPROC_ADC_PWR_ADC | IPROC_ADC_PWR_BG); + + ret = regmap_write(adc_priv->regmap, IPROC_REGCTL2, val); + if (ret) { + dev_err(&indio_dev->dev, + "failed to write IPROC_REGCTL2 %d\n", ret); + return ret; + } + + ret = regmap_read(adc_priv->regmap, IPROC_REGCTL2, &val); + if (ret) { + dev_err(&indio_dev->dev, + "failed to read IPROC_REGCTL2 %d\n", ret); + return ret; + } + + val |= IPROC_ADC_CONTROLLER_EN; + ret = regmap_write(adc_priv->regmap, IPROC_REGCTL2, val); + if (ret) { + dev_err(&indio_dev->dev, + "failed to write IPROC_REGCTL2 %d\n", ret); + return ret; + } + + for (channel_id = 0; channel_id < indio_dev->num_channels; + channel_id++) { + ret = regmap_write(adc_priv->regmap, + IPROC_ADC_CHANNEL_INTERRUPT_MASK + + IPROC_ADC_CHANNEL_OFFSET * channel_id, 0); + if (ret) { + dev_err(&indio_dev->dev, + "failed to write ADC_CHANNEL_INTERRUPT_MASK %d\n", + ret); + return ret; + } + + ret = regmap_write(adc_priv->regmap, + IPROC_ADC_CHANNEL_INTERRUPT_STATUS + + IPROC_ADC_CHANNEL_OFFSET * channel_id, 0); + if (ret) { + dev_err(&indio_dev->dev, + "failed to write ADC_CHANNEL_INTERRUPT_STATUS %d\n", + ret); + return ret; + } + } + + return 0; +} + +static void iproc_adc_disable(struct iio_dev *indio_dev) +{ + u32 val; + int ret; + struct iproc_adc_priv *adc_priv = iio_priv(indio_dev); + + ret = regmap_read(adc_priv->regmap, IPROC_REGCTL2, &val); + if (ret) { + dev_err(&indio_dev->dev, + "failed to read IPROC_REGCTL2 %d\n", ret); + return; + } + + val &= ~IPROC_ADC_CONTROLLER_EN; + ret = regmap_write(adc_priv->regmap, IPROC_REGCTL2, val); + if (ret) { + dev_err(&indio_dev->dev, + "failed to write IPROC_REGCTL2 %d\n", ret); + return; + } +} + +static int iproc_adc_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long mask) +{ + u16 adc_data; + int err; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + err = iproc_adc_do_read(indio_dev, chan->channel, &adc_data); + if (err < 0) + return err; + *val = adc_data; + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_VOLTAGE: + *val = 1800; + *val2 = 10; + return IIO_VAL_FRACTIONAL_LOG2; + default: + return -EINVAL; + } + default: + return -EINVAL; + } +} + +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) { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .channel = _index, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .datasheet_name = _id, \ +} + +static const struct iio_chan_spec iproc_adc_iio_channels[] = { + IPROC_ADC_CHANNEL(0, "adc0"), + IPROC_ADC_CHANNEL(1, "adc1"), + IPROC_ADC_CHANNEL(2, "adc2"), + IPROC_ADC_CHANNEL(3, "adc3"), + IPROC_ADC_CHANNEL(4, "adc4"), + IPROC_ADC_CHANNEL(5, "adc5"), + IPROC_ADC_CHANNEL(6, "adc6"), + IPROC_ADC_CHANNEL(7, "adc7"), +}; + +static int iproc_adc_probe(struct platform_device *pdev) +{ + struct iproc_adc_priv *adc_priv; + struct iio_dev *indio_dev = NULL; + int ret; + + indio_dev = devm_iio_device_alloc(&pdev->dev, + sizeof(*adc_priv)); + if (!indio_dev) { + dev_err(&pdev->dev, "failed to allocate iio device\n"); + return -ENOMEM; + } + + adc_priv = iio_priv(indio_dev); + platform_set_drvdata(pdev, indio_dev); + + mutex_init(&adc_priv->mutex); + + init_completion(&adc_priv->completion); + + adc_priv->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, + "adc-syscon"); + if (IS_ERR(adc_priv->regmap)) { + dev_err(&pdev->dev, "failed to get handle for tsc syscon\n"); + ret = PTR_ERR(adc_priv->regmap); + return ret; + } + + adc_priv->adc_clk = devm_clk_get(&pdev->dev, "tsc_clk"); + if (IS_ERR(adc_priv->adc_clk)) { + dev_err(&pdev->dev, + "failed getting clock tsc_clk\n"); + ret = PTR_ERR(adc_priv->adc_clk); + return ret; + } + + adc_priv->irqno = platform_get_irq(pdev, 0); + if (adc_priv->irqno <= 0) { + dev_err(&pdev->dev, "platform_get_irq failed\n"); + ret = -ENODEV; + return ret; + } + + ret = regmap_update_bits(adc_priv->regmap, IPROC_REGCTL2, + IPROC_ADC_AUXIN_SCAN_ENA, 0); + if (ret) { + dev_err(&pdev->dev, "failed to write IPROC_REGCTL2 %d\n", ret); + return ret; + } + + ret = devm_request_threaded_irq(&pdev->dev, adc_priv->irqno, + iproc_adc_interrupt_thread, + iproc_adc_interrupt_handler, + IRQF_SHARED, "iproc-adc", indio_dev); + if (ret) { + dev_err(&pdev->dev, "request_irq error %d\n", ret); + return ret; + } + + ret = clk_prepare_enable(adc_priv->adc_clk); + if (ret) { + dev_err(&pdev->dev, + "clk_prepare_enable failed %d\n", ret); + return ret; + } + + ret = iproc_adc_enable(indio_dev); + if (ret) { + dev_err(&pdev->dev, "failed to enable adc %d\n", ret); + goto err_adc_enable; + } + + indio_dev->name = "iproc-static-adc"; + indio_dev->dev.parent = &pdev->dev; + indio_dev->dev.of_node = pdev->dev.of_node; + indio_dev->info = &iproc_adc_iio_info; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = iproc_adc_iio_channels; + indio_dev->num_channels = ARRAY_SIZE(iproc_adc_iio_channels); + + ret = iio_device_register(indio_dev); + if (ret) { + dev_err(&pdev->dev, "iio_device_register failed:err %d\n", ret); + goto err_clk; + } + + return 0; + +err_clk: + iproc_adc_disable(indio_dev); +err_adc_enable: + clk_disable_unprepare(adc_priv->adc_clk); + + return ret; +} + +static int iproc_adc_remove(struct platform_device *pdev) +{ + struct iio_dev *indio_dev = platform_get_drvdata(pdev); + struct iproc_adc_priv *adc_priv = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + iproc_adc_disable(indio_dev); + clk_disable_unprepare(adc_priv->adc_clk); + + return 0; +} + +static const struct of_device_id iproc_adc_of_match[] = { + {.compatible = "brcm,iproc-static-adc", }, + { }, +}; +MODULE_DEVICE_TABLE(of, iproc_adc_of_match); + +static struct platform_driver iproc_adc_driver = { + .probe = iproc_adc_probe, + .remove = iproc_adc_remove, + .driver = { + .name = "iproc-static-adc", + .of_match_table = of_match_ptr(iproc_adc_of_match), + }, +}; +module_platform_driver(iproc_adc_driver); + +MODULE_DESCRIPTION("Broadcom iProc ADC controller driver"); +MODULE_AUTHOR("Raveendra Padasalagi "); +MODULE_LICENSE("GPL v2"); -- cgit v1.1 From bf61f5d2266cc6c117483c8ca4c73771a32e2fba Mon Sep 17 00:00:00 2001 From: Steffen Trumtrar Date: Thu, 21 Apr 2016 12:49:00 +0200 Subject: iio: bmg160: add callbacks for the filter frequency The filter frequency and sample rate have a fixed relationship. Only the filter frequency is unique, however. Currently the driver ignores the filter settings for 32 Hz and 64 Hz. This patch adds the necessary callbacks to be able to configure and read the filter setting from sysfs. Signed-off-by: Steffen Trumtrar Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/bmg160_core.c | 108 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 96 insertions(+), 12 deletions(-) diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index 8155251..f7fcfa8 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c @@ -50,6 +50,7 @@ #define BMG160_REG_PMU_BW 0x10 #define BMG160_NO_FILTER 0 #define BMG160_DEF_BW 100 +#define BMG160_REG_PMU_BW_RES BIT(7) #define BMG160_REG_INT_MAP_0 0x17 #define BMG160_INT_MAP_0_BIT_ANY BIT(1) @@ -100,7 +101,6 @@ struct bmg160_data { struct iio_trigger *motion_trig; struct mutex mutex; s16 buffer[8]; - u8 bw_bits; u32 dps_range; int ev_enable_state; int slope_thres; @@ -117,13 +117,16 @@ enum bmg160_axis { }; static const struct { - int val; + int odr; + int filter; int bw_bits; -} bmg160_samp_freq_table[] = { {100, 0x07}, - {200, 0x06}, - {400, 0x03}, - {1000, 0x02}, - {2000, 0x01} }; +} bmg160_samp_freq_table[] = { {100, 32, 0x07}, + {200, 64, 0x06}, + {100, 12, 0x05}, + {200, 23, 0x04}, + {400, 47, 0x03}, + {1000, 116, 0x02}, + {2000, 230, 0x01} }; static const struct { int scale; @@ -153,7 +156,7 @@ static int bmg160_convert_freq_to_bit(int val) int i; for (i = 0; i < ARRAY_SIZE(bmg160_samp_freq_table); ++i) { - if (bmg160_samp_freq_table[i].val == val) + if (bmg160_samp_freq_table[i].odr == val) return bmg160_samp_freq_table[i].bw_bits; } @@ -176,7 +179,53 @@ static int bmg160_set_bw(struct bmg160_data *data, int val) return ret; } - data->bw_bits = bw_bits; + return 0; +} + +static int bmg160_get_filter(struct bmg160_data *data, int *val) +{ + struct device *dev = regmap_get_device(data->regmap); + int ret; + int i; + unsigned int bw_bits; + + ret = regmap_read(data->regmap, BMG160_REG_PMU_BW, &bw_bits); + if (ret < 0) { + dev_err(dev, "Error reading reg_pmu_bw\n"); + return ret; + } + + /* Ignore the readonly reserved bit. */ + bw_bits &= ~BMG160_REG_PMU_BW_RES; + + for (i = 0; i < ARRAY_SIZE(bmg160_samp_freq_table); ++i) { + if (bmg160_samp_freq_table[i].bw_bits == bw_bits) + break; + } + + *val = bmg160_samp_freq_table[i].filter; + + return ret ? ret : IIO_VAL_INT; +} + + +static int bmg160_set_filter(struct bmg160_data *data, int val) +{ + struct device *dev = regmap_get_device(data->regmap); + int ret; + int i; + + for (i = 0; i < ARRAY_SIZE(bmg160_samp_freq_table); ++i) { + if (bmg160_samp_freq_table[i].filter == val) + break; + } + + ret = regmap_write(data->regmap, BMG160_REG_PMU_BW, + bmg160_samp_freq_table[i].bw_bits); + if (ret < 0) { + dev_err(dev, "Error writing reg_pmu_bw\n"); + return ret; + } return 0; } @@ -386,11 +435,23 @@ static int bmg160_setup_new_data_interrupt(struct bmg160_data *data, static int bmg160_get_bw(struct bmg160_data *data, int *val) { + struct device *dev = regmap_get_device(data->regmap); int i; + unsigned int bw_bits; + int ret; + + ret = regmap_read(data->regmap, BMG160_REG_PMU_BW, &bw_bits); + if (ret < 0) { + dev_err(dev, "Error reading reg_pmu_bw\n"); + return ret; + } + + /* Ignore the readonly reserved bit. */ + bw_bits &= ~BMG160_REG_PMU_BW_RES; for (i = 0; i < ARRAY_SIZE(bmg160_samp_freq_table); ++i) { - if (bmg160_samp_freq_table[i].bw_bits == data->bw_bits) { - *val = bmg160_samp_freq_table[i].val; + if (bmg160_samp_freq_table[i].bw_bits == bw_bits) { + *val = bmg160_samp_freq_table[i].odr; return IIO_VAL_INT; } } @@ -507,6 +568,8 @@ static int bmg160_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; } else return -EINVAL; + case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: + return bmg160_get_filter(data, val); case IIO_CHAN_INFO_SCALE: *val = 0; switch (chan->type) { @@ -571,6 +634,26 @@ static int bmg160_write_raw(struct iio_dev *indio_dev, ret = bmg160_set_power_state(data, false); mutex_unlock(&data->mutex); return ret; + case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: + if (val2) + return -EINVAL; + + mutex_lock(&data->mutex); + ret = bmg160_set_power_state(data, true); + if (ret < 0) { + bmg160_set_power_state(data, false); + mutex_unlock(&data->mutex); + return ret; + } + ret = bmg160_set_filter(data, val); + if (ret < 0) { + bmg160_set_power_state(data, false); + mutex_unlock(&data->mutex); + return ret; + } + ret = bmg160_set_power_state(data, false); + mutex_unlock(&data->mutex); + return ret; case IIO_CHAN_INFO_SCALE: if (val) return -EINVAL; @@ -728,7 +811,8 @@ static const struct iio_event_spec bmg160_event = { .channel2 = IIO_MOD_##_axis, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ - BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ + BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \ .scan_index = AXIS_##_axis, \ .scan_type = { \ .sign = 's', \ -- cgit v1.1 From 55389e8bc5dce8931d9c46d83c534c4997565e97 Mon Sep 17 00:00:00 2001 From: Florian Vaussard Date: Thu, 30 Jun 2016 09:43:05 +0200 Subject: iio: adc: max1363: Add device tree binding documentation Add the device tree documentation for all the supported parts. Mandatory binding is the compatible string and the slave I2C address. Optional properties can be used to specify the Vcc / Vref regulators, as well as the IRQ line if available. Acked-by: Rob Herring Signed-off-by: Florian Vaussard Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/max1363.txt | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/max1363.txt diff --git a/Documentation/devicetree/bindings/iio/adc/max1363.txt b/Documentation/devicetree/bindings/iio/adc/max1363.txt new file mode 100644 index 0000000..94a9011 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/max1363.txt @@ -0,0 +1,63 @@ +* Maxim 1x3x/136x/116xx Analog to Digital Converter (ADC) + +The node for this driver must be a child node of a I2C controller, hence +all mandatory properties for your controller must be specified. See directory: + + Documentation/devicetree/bindings/i2c + +for more details. + +Required properties: + - compatible: Should be one of + "maxim,max1361" + "maxim,max1362" + "maxim,max1363" + "maxim,max1364" + "maxim,max1036" + "maxim,max1037" + "maxim,max1038" + "maxim,max1039" + "maxim,max1136" + "maxim,max1137" + "maxim,max1138" + "maxim,max1139" + "maxim,max1236" + "maxim,max1237" + "maxim,max1238" + "maxim,max1239" + "maxim,max11600" + "maxim,max11601" + "maxim,max11602" + "maxim,max11603" + "maxim,max11604" + "maxim,max11605" + "maxim,max11606" + "maxim,max11607" + "maxim,max11608" + "maxim,max11609" + "maxim,max11610" + "maxim,max11611" + "maxim,max11612" + "maxim,max11613" + "maxim,max11614" + "maxim,max11615" + "maxim,max11616" + "maxim,max11617" + "maxim,max11644" + "maxim,max11645" + "maxim,max11646" + "maxim,max11647" + - reg: Should contain the ADC I2C address + +Optional properties: + - vcc-supply: phandle to the regulator that provides power to the ADC. + - vref-supply: phandle to the regulator for ADC reference voltage. + - interrupts: IRQ line for the ADC. If not used the driver will use + polling. + +Example: +adc: max11644@36 { + compatible = "maxim,max11644"; + reg = <0x36>; + vref-supply = <&adc_vref>; +}; -- cgit v1.1 From 152c9aa00d546dac55095f620ea068965ef06dc7 Mon Sep 17 00:00:00 2001 From: Florian Vaussard Date: Thu, 30 Jun 2016 09:43:06 +0200 Subject: iio: adc: max1363: Add device tree binding This patch adds the necessary device tree binding to allow DT probing of currently supported parts. Signed-off-by: Florian Vaussard Signed-off-by: Jonathan Cameron --- drivers/iio/adc/max1363.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index 73af306..3b53c2e 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include @@ -1517,6 +1519,56 @@ done: return IRQ_HANDLED; } +#ifdef CONFIG_OF + +#define MAX1363_COMPATIBLE(of_compatible, cfg) { \ + .compatible = of_compatible, \ + .data = &max1363_chip_info_tbl[cfg], \ +} + +static const struct of_device_id max1363_of_match[] = { + MAX1363_COMPATIBLE("maxim,max1361", max1361), + MAX1363_COMPATIBLE("maxim,max1362", max1362), + MAX1363_COMPATIBLE("maxim,max1363", max1363), + MAX1363_COMPATIBLE("maxim,max1364", max1364), + MAX1363_COMPATIBLE("maxim,max1036", max1036), + MAX1363_COMPATIBLE("maxim,max1037", max1037), + MAX1363_COMPATIBLE("maxim,max1038", max1038), + MAX1363_COMPATIBLE("maxim,max1039", max1039), + MAX1363_COMPATIBLE("maxim,max1136", max1136), + MAX1363_COMPATIBLE("maxim,max1137", max1137), + MAX1363_COMPATIBLE("maxim,max1138", max1138), + MAX1363_COMPATIBLE("maxim,max1139", max1139), + MAX1363_COMPATIBLE("maxim,max1236", max1236), + MAX1363_COMPATIBLE("maxim,max1237", max1237), + MAX1363_COMPATIBLE("maxim,max1238", max1238), + MAX1363_COMPATIBLE("maxim,max1239", max1239), + MAX1363_COMPATIBLE("maxim,max11600", max11600), + MAX1363_COMPATIBLE("maxim,max11601", max11601), + MAX1363_COMPATIBLE("maxim,max11602", max11602), + MAX1363_COMPATIBLE("maxim,max11603", max11603), + MAX1363_COMPATIBLE("maxim,max11604", max11604), + MAX1363_COMPATIBLE("maxim,max11605", max11605), + MAX1363_COMPATIBLE("maxim,max11606", max11606), + MAX1363_COMPATIBLE("maxim,max11607", max11607), + MAX1363_COMPATIBLE("maxim,max11608", max11608), + MAX1363_COMPATIBLE("maxim,max11609", max11609), + MAX1363_COMPATIBLE("maxim,max11610", max11610), + MAX1363_COMPATIBLE("maxim,max11611", max11611), + MAX1363_COMPATIBLE("maxim,max11612", max11612), + MAX1363_COMPATIBLE("maxim,max11613", max11613), + MAX1363_COMPATIBLE("maxim,max11614", max11614), + MAX1363_COMPATIBLE("maxim,max11615", max11615), + MAX1363_COMPATIBLE("maxim,max11616", max11616), + MAX1363_COMPATIBLE("maxim,max11617", max11617), + MAX1363_COMPATIBLE("maxim,max11644", max11644), + MAX1363_COMPATIBLE("maxim,max11645", max11645), + MAX1363_COMPATIBLE("maxim,max11646", max11646), + MAX1363_COMPATIBLE("maxim,max11647", max11647), + { /* sentinel */ } +}; +#endif + static int max1363_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1524,6 +1576,7 @@ static int max1363_probe(struct i2c_client *client, struct max1363_state *st; struct iio_dev *indio_dev; struct regulator *vref; + const struct of_device_id *match; indio_dev = devm_iio_device_alloc(&client->dev, sizeof(struct max1363_state)); @@ -1550,7 +1603,12 @@ static int max1363_probe(struct i2c_client *client, /* this is only used for device removal purposes */ i2c_set_clientdata(client, indio_dev); - st->chip_info = &max1363_chip_info_tbl[id->driver_data]; + match = of_match_device(of_match_ptr(max1363_of_match), + &client->dev); + if (match) + st->chip_info = of_device_get_match_data(&client->dev); + else + st->chip_info = &max1363_chip_info_tbl[id->driver_data]; st->client = client; st->vref_uv = st->chip_info->int_vref_mv * 1000; @@ -1693,6 +1751,7 @@ MODULE_DEVICE_TABLE(i2c, max1363_id); static struct i2c_driver max1363_driver = { .driver = { .name = "max1363", + .of_match_table = of_match_ptr(max1363_of_match), }, .probe = max1363_probe, .remove = max1363_remove, -- cgit v1.1 From 468c5620d094e9ead2a0b6802d3c490b4fb6ed03 Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Thu, 30 Jun 2016 19:06:34 +0200 Subject: iio:imu:mpu6050: icm20608 initial support Introduce support for Invense ICM20608 IMU, a 6-axis motion tracking device that combines a 3-axis gyroscope and a 3-axis accelerometer: http://www.invensense.com/products/motion-tracking/6-axis/icm-20608-2 Signed-off-by: Gregor Boirie Signed-off-by: Jonathan Cameron --- drivers/iio/imu/inv_mpu6050/Kconfig | 8 ++++---- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 6 ++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 1 + drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 ++ drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 1 + 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/Kconfig b/drivers/iio/imu/inv_mpu6050/Kconfig index f756fee..5483b2e 100644 --- a/drivers/iio/imu/inv_mpu6050/Kconfig +++ b/drivers/iio/imu/inv_mpu6050/Kconfig @@ -13,8 +13,8 @@ config INV_MPU6050_I2C select INV_MPU6050_IIO select REGMAP_I2C help - This driver supports the Invensense MPU6050/6500/9150 motion tracking - devices over I2C. + This driver supports the Invensense MPU6050/6500/9150 and ICM20608 + motion tracking devices over I2C. This driver can be built as a module. The module will be called inv-mpu6050-i2c. @@ -24,7 +24,7 @@ config INV_MPU6050_SPI select INV_MPU6050_IIO select REGMAP_SPI help - This driver supports the Invensense MPU6000/6500/9150 motion tracking - devices over SPI. + This driver supports the Invensense MPU6050/6500/9150 and ICM20608 + motion tracking devices over SPI. This driver can be built as a module. The module will be called inv-mpu6050-spi. diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index ee40dae..b9fcbf1 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -113,6 +113,12 @@ static const struct inv_mpu6050_hw hw_info[] = { .reg = ®_set_6050, .config = &chip_config_6050, }, + { + .whoami = INV_ICM20608_WHOAMI_VALUE, + .name = "ICM20608", + .reg = ®_set_6500, + .config = &chip_config_6050, + }, }; int inv_mpu6050_switch_engine(struct inv_mpu6050_state *st, bool en, u32 mask) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c index e1fd7fa..19580d1 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c @@ -170,6 +170,7 @@ static const struct i2c_device_id inv_mpu_id[] = { {"mpu6050", INV_MPU6050}, {"mpu6500", INV_MPU6500}, {"mpu9150", INV_MPU9150}, + {"icm20608", INV_ICM20608}, {} }; diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index 3bf8544c..f0e8c5d 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -70,6 +70,7 @@ enum inv_devices { INV_MPU6500, INV_MPU6000, INV_MPU9150, + INV_ICM20608, INV_NUM_PARTS }; @@ -225,6 +226,7 @@ struct inv_mpu6050_state { #define INV_MPU6050_WHOAMI_VALUE 0x68 #define INV_MPU6500_WHOAMI_VALUE 0x70 #define INV_MPU9150_WHOAMI_VALUE 0x68 +#define INV_ICM20608_WHOAMI_VALUE 0xAF /* scan element definition */ enum inv_mpu6050_scan { diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c index 190a4a5..6e6476d 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c @@ -82,6 +82,7 @@ static const struct spi_device_id inv_mpu_id[] = { {"mpu6000", INV_MPU6000}, {"mpu6500", INV_MPU6500}, {"mpu9150", INV_MPU9150}, + {"icm20608", INV_ICM20608}, {} }; -- cgit v1.1 From 294ea6f3a162fc0091e80170b8176bf326962d1c Mon Sep 17 00:00:00 2001 From: Florian Vaussard Date: Thu, 30 Jun 2016 09:34:48 +0200 Subject: iio: potentiometer: mcp4531: Add support for MCP454x, MCP456x, MCP464x and MCP466x This patch adds support for MCP454x, MCP456x, MCP464x and MCP466x parts. The main difference with currently supported parts (MCP453x and alike) is the addition of a non-volatile memory in order to recall the wiper setting at power-on. This feature is currently not supported and only the volatile memory is used to set the wiper. Signed-off-by: Florian Vaussard Acked-by: Peter Rosin Signed-off-by: Jonathan Cameron --- drivers/iio/potentiometer/Kconfig | 6 ++-- drivers/iio/potentiometer/mcp4531.c | 72 +++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/drivers/iio/potentiometer/Kconfig b/drivers/iio/potentiometer/Kconfig index 0941c8d4..55c2414 100644 --- a/drivers/iio/potentiometer/Kconfig +++ b/drivers/iio/potentiometer/Kconfig @@ -49,8 +49,10 @@ config MCP4531 depends on I2C help Say yes here to build support for the Microchip - MCP4531, MCP4532, MCP4551, MCP4552, - MCP4631, MCP4632, MCP4651, MCP4652 + MCP4531, MCP4532, MCP4541, MCP4542, + MCP4551, MCP4552, MCP4561, MCP4562, + MCP4631, MCP4632, MCP4641, MCP4642, + MCP4651, MCP4652, MCP4661, MCP4662 digital potentiomenter chips. To compile this driver as a module, choose M here: the diff --git a/drivers/iio/potentiometer/mcp4531.c b/drivers/iio/potentiometer/mcp4531.c index 3b72e1a..2251173 100644 --- a/drivers/iio/potentiometer/mcp4531.c +++ b/drivers/iio/potentiometer/mcp4531.c @@ -8,12 +8,20 @@ * DEVID #Wipers #Positions Resistor Opts (kOhm) i2c address * mcp4531 1 129 5, 10, 50, 100 010111x * mcp4532 1 129 5, 10, 50, 100 01011xx + * mcp4541 1 129 5, 10, 50, 100 010111x + * mcp4542 1 129 5, 10, 50, 100 01011xx * mcp4551 1 257 5, 10, 50, 100 010111x * mcp4552 1 257 5, 10, 50, 100 01011xx + * mcp4561 1 257 5, 10, 50, 100 010111x + * mcp4562 1 257 5, 10, 50, 100 01011xx * mcp4631 2 129 5, 10, 50, 100 0101xxx * mcp4632 2 129 5, 10, 50, 100 01011xx + * mcp4641 2 129 5, 10, 50, 100 0101xxx + * mcp4642 2 129 5, 10, 50, 100 01011xx * mcp4651 2 257 5, 10, 50, 100 0101xxx * mcp4652 2 257 5, 10, 50, 100 01011xx + * mcp4661 2 257 5, 10, 50, 100 0101xxx + * mcp4662 2 257 5, 10, 50, 100 01011xx * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by @@ -37,18 +45,34 @@ enum mcp4531_type { MCP453x_103, MCP453x_503, MCP453x_104, + MCP454x_502, + MCP454x_103, + MCP454x_503, + MCP454x_104, MCP455x_502, MCP455x_103, MCP455x_503, MCP455x_104, + MCP456x_502, + MCP456x_103, + MCP456x_503, + MCP456x_104, MCP463x_502, MCP463x_103, MCP463x_503, MCP463x_104, + MCP464x_502, + MCP464x_103, + MCP464x_503, + MCP464x_104, MCP465x_502, MCP465x_103, MCP465x_503, MCP465x_104, + MCP466x_502, + MCP466x_103, + MCP466x_503, + MCP466x_104, }; static const struct mcp4531_cfg mcp4531_cfg[] = { @@ -56,18 +80,34 @@ static const struct mcp4531_cfg mcp4531_cfg[] = { [MCP453x_103] = { .wipers = 1, .max_pos = 128, .kohms = 10, }, [MCP453x_503] = { .wipers = 1, .max_pos = 128, .kohms = 50, }, [MCP453x_104] = { .wipers = 1, .max_pos = 128, .kohms = 100, }, + [MCP454x_502] = { .wipers = 1, .max_pos = 128, .kohms = 5, }, + [MCP454x_103] = { .wipers = 1, .max_pos = 128, .kohms = 10, }, + [MCP454x_503] = { .wipers = 1, .max_pos = 128, .kohms = 50, }, + [MCP454x_104] = { .wipers = 1, .max_pos = 128, .kohms = 100, }, [MCP455x_502] = { .wipers = 1, .max_pos = 256, .kohms = 5, }, [MCP455x_103] = { .wipers = 1, .max_pos = 256, .kohms = 10, }, [MCP455x_503] = { .wipers = 1, .max_pos = 256, .kohms = 50, }, [MCP455x_104] = { .wipers = 1, .max_pos = 256, .kohms = 100, }, + [MCP456x_502] = { .wipers = 1, .max_pos = 256, .kohms = 5, }, + [MCP456x_103] = { .wipers = 1, .max_pos = 256, .kohms = 10, }, + [MCP456x_503] = { .wipers = 1, .max_pos = 256, .kohms = 50, }, + [MCP456x_104] = { .wipers = 1, .max_pos = 256, .kohms = 100, }, [MCP463x_502] = { .wipers = 2, .max_pos = 128, .kohms = 5, }, [MCP463x_103] = { .wipers = 2, .max_pos = 128, .kohms = 10, }, [MCP463x_503] = { .wipers = 2, .max_pos = 128, .kohms = 50, }, [MCP463x_104] = { .wipers = 2, .max_pos = 128, .kohms = 100, }, + [MCP464x_502] = { .wipers = 2, .max_pos = 128, .kohms = 5, }, + [MCP464x_103] = { .wipers = 2, .max_pos = 128, .kohms = 10, }, + [MCP464x_503] = { .wipers = 2, .max_pos = 128, .kohms = 50, }, + [MCP464x_104] = { .wipers = 2, .max_pos = 128, .kohms = 100, }, [MCP465x_502] = { .wipers = 2, .max_pos = 256, .kohms = 5, }, [MCP465x_103] = { .wipers = 2, .max_pos = 256, .kohms = 10, }, [MCP465x_503] = { .wipers = 2, .max_pos = 256, .kohms = 50, }, [MCP465x_104] = { .wipers = 2, .max_pos = 256, .kohms = 100, }, + [MCP466x_502] = { .wipers = 2, .max_pos = 256, .kohms = 5, }, + [MCP466x_103] = { .wipers = 2, .max_pos = 256, .kohms = 10, }, + [MCP466x_503] = { .wipers = 2, .max_pos = 256, .kohms = 50, }, + [MCP466x_104] = { .wipers = 2, .max_pos = 256, .kohms = 100, }, }; #define MCP4531_WRITE (0 << 2) @@ -187,6 +227,14 @@ static const struct i2c_device_id mcp4531_id[] = { { "mcp4532-103", MCP453x_103 }, { "mcp4532-503", MCP453x_503 }, { "mcp4532-104", MCP453x_104 }, + { "mcp4541-502", MCP454x_502 }, + { "mcp4541-103", MCP454x_103 }, + { "mcp4541-503", MCP454x_503 }, + { "mcp4541-104", MCP454x_104 }, + { "mcp4542-502", MCP454x_502 }, + { "mcp4542-103", MCP454x_103 }, + { "mcp4542-503", MCP454x_503 }, + { "mcp4542-104", MCP454x_104 }, { "mcp4551-502", MCP455x_502 }, { "mcp4551-103", MCP455x_103 }, { "mcp4551-503", MCP455x_503 }, @@ -195,6 +243,14 @@ static const struct i2c_device_id mcp4531_id[] = { { "mcp4552-103", MCP455x_103 }, { "mcp4552-503", MCP455x_503 }, { "mcp4552-104", MCP455x_104 }, + { "mcp4561-502", MCP456x_502 }, + { "mcp4561-103", MCP456x_103 }, + { "mcp4561-503", MCP456x_503 }, + { "mcp4561-104", MCP456x_104 }, + { "mcp4562-502", MCP456x_502 }, + { "mcp4562-103", MCP456x_103 }, + { "mcp4562-503", MCP456x_503 }, + { "mcp4562-104", MCP456x_104 }, { "mcp4631-502", MCP463x_502 }, { "mcp4631-103", MCP463x_103 }, { "mcp4631-503", MCP463x_503 }, @@ -203,6 +259,14 @@ static const struct i2c_device_id mcp4531_id[] = { { "mcp4632-103", MCP463x_103 }, { "mcp4632-503", MCP463x_503 }, { "mcp4632-104", MCP463x_104 }, + { "mcp4641-502", MCP464x_502 }, + { "mcp4641-103", MCP464x_103 }, + { "mcp4641-503", MCP464x_503 }, + { "mcp4641-104", MCP464x_104 }, + { "mcp4642-502", MCP464x_502 }, + { "mcp4642-103", MCP464x_103 }, + { "mcp4642-503", MCP464x_503 }, + { "mcp4642-104", MCP464x_104 }, { "mcp4651-502", MCP465x_502 }, { "mcp4651-103", MCP465x_103 }, { "mcp4651-503", MCP465x_503 }, @@ -211,6 +275,14 @@ static const struct i2c_device_id mcp4531_id[] = { { "mcp4652-103", MCP465x_103 }, { "mcp4652-503", MCP465x_503 }, { "mcp4652-104", MCP465x_104 }, + { "mcp4661-502", MCP466x_502 }, + { "mcp4661-103", MCP466x_103 }, + { "mcp4661-503", MCP466x_503 }, + { "mcp4661-104", MCP466x_104 }, + { "mcp4662-502", MCP466x_502 }, + { "mcp4662-103", MCP466x_103 }, + { "mcp4662-503", MCP466x_503 }, + { "mcp4662-104", MCP466x_104 }, {} }; MODULE_DEVICE_TABLE(i2c, mcp4531_id); -- cgit v1.1 From deec2fadff6aa6a26e96cc12c7c8bacdc145b5af Mon Sep 17 00:00:00 2001 From: Florian Vaussard Date: Thu, 30 Jun 2016 09:34:49 +0200 Subject: iio: potentiometer: mcp4531: Add device tree binding documentation Add the device tree documentation for all the supported parts. Apart the compatible string and standard I2C binding, no other binding is currently needed. Signed-off-by: Florian Vaussard Acked-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/i2c/trivial-devices.txt | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/trivial-devices.txt b/Documentation/devicetree/bindings/i2c/trivial-devices.txt index 53987449..acc5cd6 100644 --- a/Documentation/devicetree/bindings/i2c/trivial-devices.txt +++ b/Documentation/devicetree/bindings/i2c/trivial-devices.txt @@ -56,6 +56,70 @@ maxim,ds1050 5 Bit Programmable, Pulse-Width Modulator maxim,max1237 Low-Power, 4-/12-Channel, 2-Wire Serial, 12-Bit ADCs maxim,max6625 9-Bit/12-Bit Temperature Sensors with I²C-Compatible Serial Interface mc,rv3029c2 Real Time Clock Module with I2C-Bus +microchip,mcp4531-502 Microchip 7-bit Single I2C Digital Potentiometer (5k) +microchip,mcp4531-103 Microchip 7-bit Single I2C Digital Potentiometer (10k) +microchip,mcp4531-503 Microchip 7-bit Single I2C Digital Potentiometer (50k) +microchip,mcp4531-104 Microchip 7-bit Single I2C Digital Potentiometer (100k) +microchip,mcp4532-502 Microchip 7-bit Single I2C Digital Potentiometer (5k) +microchip,mcp4532-103 Microchip 7-bit Single I2C Digital Potentiometer (10k) +microchip,mcp4532-503 Microchip 7-bit Single I2C Digital Potentiometer (50k) +microchip,mcp4532-104 Microchip 7-bit Single I2C Digital Potentiometer (100k) +microchip,mcp4541-502 Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (5k) +microchip,mcp4541-103 Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (10k) +microchip,mcp4541-503 Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (50k) +microchip,mcp4541-104 Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (100k) +microchip,mcp4542-502 Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (5k) +microchip,mcp4542-103 Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (10k) +microchip,mcp4542-503 Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (50k) +microchip,mcp4542-104 Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (100k) +microchip,mcp4551-502 Microchip 8-bit Single I2C Digital Potentiometer (5k) +microchip,mcp4551-103 Microchip 8-bit Single I2C Digital Potentiometer (10k) +microchip,mcp4551-503 Microchip 8-bit Single I2C Digital Potentiometer (50k) +microchip,mcp4551-104 Microchip 8-bit Single I2C Digital Potentiometer (100k) +microchip,mcp4552-502 Microchip 8-bit Single I2C Digital Potentiometer (5k) +microchip,mcp4552-103 Microchip 8-bit Single I2C Digital Potentiometer (10k) +microchip,mcp4552-503 Microchip 8-bit Single I2C Digital Potentiometer (50k) +microchip,mcp4552-104 Microchip 8-bit Single I2C Digital Potentiometer (100k) +microchip,mcp4561-502 Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (5k) +microchip,mcp4561-103 Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (10k) +microchip,mcp4561-503 Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (50k) +microchip,mcp4561-104 Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (100k) +microchip,mcp4562-502 Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (5k) +microchip,mcp4562-103 Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (10k) +microchip,mcp4562-503 Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (50k) +microchip,mcp4562-104 Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (100k) +microchip,mcp4631-502 Microchip 7-bit Dual I2C Digital Potentiometer (5k) +microchip,mcp4631-103 Microchip 7-bit Dual I2C Digital Potentiometer (10k) +microchip,mcp4631-503 Microchip 7-bit Dual I2C Digital Potentiometer (50k) +microchip,mcp4631-104 Microchip 7-bit Dual I2C Digital Potentiometer (100k) +microchip,mcp4632-502 Microchip 7-bit Dual I2C Digital Potentiometer (5k) +microchip,mcp4632-103 Microchip 7-bit Dual I2C Digital Potentiometer (10k) +microchip,mcp4632-503 Microchip 7-bit Dual I2C Digital Potentiometer (50k) +microchip,mcp4632-104 Microchip 7-bit Dual I2C Digital Potentiometer (100k) +microchip,mcp4641-502 Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (5k) +microchip,mcp4641-103 Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (10k) +microchip,mcp4641-503 Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (50k) +microchip,mcp4641-104 Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (100k) +microchip,mcp4642-502 Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (5k) +microchip,mcp4642-103 Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (10k) +microchip,mcp4642-503 Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (50k) +microchip,mcp4642-104 Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (100k) +microchip,mcp4651-502 Microchip 8-bit Dual I2C Digital Potentiometer (5k) +microchip,mcp4651-103 Microchip 8-bit Dual I2C Digital Potentiometer (10k) +microchip,mcp4651-503 Microchip 8-bit Dual I2C Digital Potentiometer (50k) +microchip,mcp4651-104 Microchip 8-bit Dual I2C Digital Potentiometer (100k) +microchip,mcp4652-502 Microchip 8-bit Dual I2C Digital Potentiometer (5k) +microchip,mcp4652-103 Microchip 8-bit Dual I2C Digital Potentiometer (10k) +microchip,mcp4652-503 Microchip 8-bit Dual I2C Digital Potentiometer (50k) +microchip,mcp4652-104 Microchip 8-bit Dual I2C Digital Potentiometer (100k) +microchip,mcp4661-502 Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (5k) +microchip,mcp4661-103 Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (10k) +microchip,mcp4661-503 Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (50k) +microchip,mcp4661-104 Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (100k) +microchip,mcp4662-502 Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (5k) +microchip,mcp4662-103 Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (10k) +microchip,mcp4662-503 Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (50k) +microchip,mcp4662-104 Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (100k) national,lm63 Temperature sensor with integrated fan control national,lm75 I2C TEMP SENSOR national,lm80 Serial Interface ACPI-Compatible Microprocessor System Hardware Monitor -- cgit v1.1 From 2dc2e1899ec140153b26f51b4d985a5072ba642e Mon Sep 17 00:00:00 2001 From: Florian Vaussard Date: Thu, 30 Jun 2016 09:34:50 +0200 Subject: iio: potentiometer: mcp4531: Add device tree binding This patch adds the necessary device tree binding to allow DT probing of currently supported parts. Signed-off-by: Florian Vaussard Acked-by: Peter Rosin Signed-off-by: Jonathan Cameron --- drivers/iio/potentiometer/mcp4531.c | 87 ++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/drivers/iio/potentiometer/mcp4531.c b/drivers/iio/potentiometer/mcp4531.c index 2251173..13b6ae2 100644 --- a/drivers/iio/potentiometer/mcp4531.c +++ b/drivers/iio/potentiometer/mcp4531.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include @@ -188,12 +190,89 @@ static const struct iio_info mcp4531_info = { .driver_module = THIS_MODULE, }; +#ifdef CONFIG_OF + +#define MCP4531_COMPATIBLE(of_compatible, cfg) { \ + .compatible = of_compatible, \ + .data = &mcp4531_cfg[cfg], \ +} + +static const struct of_device_id mcp4531_of_match[] = { + MCP4531_COMPATIBLE("microchip,mcp4531-502", MCP453x_502), + MCP4531_COMPATIBLE("microchip,mcp4531-103", MCP453x_103), + MCP4531_COMPATIBLE("microchip,mcp4531-503", MCP453x_503), + MCP4531_COMPATIBLE("microchip,mcp4531-104", MCP453x_104), + MCP4531_COMPATIBLE("microchip,mcp4532-502", MCP453x_502), + MCP4531_COMPATIBLE("microchip,mcp4532-103", MCP453x_103), + MCP4531_COMPATIBLE("microchip,mcp4532-503", MCP453x_503), + MCP4531_COMPATIBLE("microchip,mcp4532-104", MCP453x_104), + MCP4531_COMPATIBLE("microchip,mcp4541-502", MCP454x_502), + MCP4531_COMPATIBLE("microchip,mcp4541-103", MCP454x_103), + MCP4531_COMPATIBLE("microchip,mcp4541-503", MCP454x_503), + MCP4531_COMPATIBLE("microchip,mcp4541-104", MCP454x_104), + MCP4531_COMPATIBLE("microchip,mcp4542-502", MCP454x_502), + MCP4531_COMPATIBLE("microchip,mcp4542-103", MCP454x_103), + MCP4531_COMPATIBLE("microchip,mcp4542-503", MCP454x_503), + MCP4531_COMPATIBLE("microchip,mcp4542-104", MCP454x_104), + MCP4531_COMPATIBLE("microchip,mcp4551-502", MCP455x_502), + MCP4531_COMPATIBLE("microchip,mcp4551-103", MCP455x_103), + MCP4531_COMPATIBLE("microchip,mcp4551-503", MCP455x_503), + MCP4531_COMPATIBLE("microchip,mcp4551-104", MCP455x_104), + MCP4531_COMPATIBLE("microchip,mcp4552-502", MCP455x_502), + MCP4531_COMPATIBLE("microchip,mcp4552-103", MCP455x_103), + MCP4531_COMPATIBLE("microchip,mcp4552-503", MCP455x_503), + MCP4531_COMPATIBLE("microchip,mcp4552-104", MCP455x_104), + MCP4531_COMPATIBLE("microchip,mcp4561-502", MCP456x_502), + MCP4531_COMPATIBLE("microchip,mcp4561-103", MCP456x_103), + MCP4531_COMPATIBLE("microchip,mcp4561-503", MCP456x_503), + MCP4531_COMPATIBLE("microchip,mcp4561-104", MCP456x_104), + MCP4531_COMPATIBLE("microchip,mcp4562-502", MCP456x_502), + MCP4531_COMPATIBLE("microchip,mcp4562-103", MCP456x_103), + MCP4531_COMPATIBLE("microchip,mcp4562-503", MCP456x_503), + MCP4531_COMPATIBLE("microchip,mcp4562-104", MCP456x_104), + MCP4531_COMPATIBLE("microchip,mcp4631-502", MCP463x_502), + MCP4531_COMPATIBLE("microchip,mcp4631-103", MCP463x_103), + MCP4531_COMPATIBLE("microchip,mcp4631-503", MCP463x_503), + MCP4531_COMPATIBLE("microchip,mcp4631-104", MCP463x_104), + MCP4531_COMPATIBLE("microchip,mcp4632-502", MCP463x_502), + MCP4531_COMPATIBLE("microchip,mcp4632-103", MCP463x_103), + MCP4531_COMPATIBLE("microchip,mcp4632-503", MCP463x_503), + MCP4531_COMPATIBLE("microchip,mcp4632-104", MCP463x_104), + MCP4531_COMPATIBLE("microchip,mcp4641-502", MCP464x_502), + MCP4531_COMPATIBLE("microchip,mcp4641-103", MCP464x_103), + MCP4531_COMPATIBLE("microchip,mcp4641-503", MCP464x_503), + MCP4531_COMPATIBLE("microchip,mcp4641-104", MCP464x_104), + MCP4531_COMPATIBLE("microchip,mcp4642-502", MCP464x_502), + MCP4531_COMPATIBLE("microchip,mcp4642-103", MCP464x_103), + MCP4531_COMPATIBLE("microchip,mcp4642-503", MCP464x_503), + MCP4531_COMPATIBLE("microchip,mcp4642-104", MCP464x_104), + MCP4531_COMPATIBLE("microchip,mcp4651-502", MCP465x_502), + MCP4531_COMPATIBLE("microchip,mcp4651-103", MCP465x_103), + MCP4531_COMPATIBLE("microchip,mcp4651-503", MCP465x_503), + MCP4531_COMPATIBLE("microchip,mcp4651-104", MCP465x_104), + MCP4531_COMPATIBLE("microchip,mcp4652-502", MCP465x_502), + MCP4531_COMPATIBLE("microchip,mcp4652-103", MCP465x_103), + MCP4531_COMPATIBLE("microchip,mcp4652-503", MCP465x_503), + MCP4531_COMPATIBLE("microchip,mcp4652-104", MCP465x_104), + MCP4531_COMPATIBLE("microchip,mcp4661-502", MCP466x_502), + MCP4531_COMPATIBLE("microchip,mcp4661-103", MCP466x_103), + MCP4531_COMPATIBLE("microchip,mcp4661-503", MCP466x_503), + MCP4531_COMPATIBLE("microchip,mcp4661-104", MCP466x_104), + MCP4531_COMPATIBLE("microchip,mcp4662-502", MCP466x_502), + MCP4531_COMPATIBLE("microchip,mcp4662-103", MCP466x_103), + MCP4531_COMPATIBLE("microchip,mcp4662-503", MCP466x_503), + MCP4531_COMPATIBLE("microchip,mcp4662-104", MCP466x_104), + { /* sentinel */ } +}; +#endif + static int mcp4531_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct device *dev = &client->dev; struct mcp4531_data *data; struct iio_dev *indio_dev; + const struct of_device_id *match; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) { @@ -207,7 +286,12 @@ static int mcp4531_probe(struct i2c_client *client, data = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); data->client = client; - data->cfg = &mcp4531_cfg[id->driver_data]; + + match = of_match_device(of_match_ptr(mcp4531_of_match), dev); + if (match) + data->cfg = of_device_get_match_data(dev); + else + data->cfg = &mcp4531_cfg[id->driver_data]; indio_dev->dev.parent = dev; indio_dev->info = &mcp4531_info; @@ -290,6 +374,7 @@ MODULE_DEVICE_TABLE(i2c, mcp4531_id); static struct i2c_driver mcp4531_driver = { .driver = { .name = "mcp4531", + .of_match_table = of_match_ptr(mcp4531_of_match), }, .probe = mcp4531_probe, .id_table = mcp4531_id, -- cgit v1.1 From 3629153ce154cf475841d3d0d8cbb1bb1718269e Mon Sep 17 00:00:00 2001 From: Florian Vaussard Date: Thu, 30 Jun 2016 09:34:51 +0200 Subject: iio: potentiometer: Fix typo in Kconfig Fix s/potentiomenter/potentiometer/. Suggested-by: Peter Meerwald-Stadler Signed-off-by: Florian Vaussard Signed-off-by: Jonathan Cameron --- drivers/iio/potentiometer/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/potentiometer/Kconfig b/drivers/iio/potentiometer/Kconfig index 55c2414..2e9da1c 100644 --- a/drivers/iio/potentiometer/Kconfig +++ b/drivers/iio/potentiometer/Kconfig @@ -10,7 +10,7 @@ config DS1803 depends on I2C help Say yes here to build support for the Maxim Integrated DS1803 - digital potentiomenter chip. + digital potentiometer chip. To compile this driver as a module, choose M here: the module will be called ds1803. @@ -39,7 +39,7 @@ config MCP4131 MCP4241, MCP4242, MCP4251, MCP4252, MCP4261, MCP4262, - digital potentiomenter chips. + digital potentiometer chips. To compile this driver as a module, choose M here: the module will be called mcp4131. @@ -53,7 +53,7 @@ config MCP4531 MCP4551, MCP4552, MCP4561, MCP4562, MCP4631, MCP4632, MCP4641, MCP4642, MCP4651, MCP4652, MCP4661, MCP4662 - digital potentiomenter chips. + digital potentiometer chips. To compile this driver as a module, choose M here: the module will be called mcp4531. -- cgit v1.1 From f5241dbdfef4404b4e80f0bda13e5c7ceba3ee4a Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Thu, 30 Jun 2016 19:33:50 -0700 Subject: iio: adc: ti-ads1015: add indio_dev->dev.of_node reference Add the pointer to the device tree node of the ADC so that iio consumers can reference the respective channels. Signed-off-by: Matt Ranostay Acked-by: Daniel Baluta Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-ads1015.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index c9574af0..1ef39877 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -586,6 +586,7 @@ static int ads1015_probe(struct i2c_client *client, mutex_init(&data->lock); indio_dev->dev.parent = &client->dev; + indio_dev->dev.of_node = client->dev.of_node; indio_dev->name = ADS1015_DRV_NAME; indio_dev->modes = INDIO_DIRECT_MODE; -- cgit v1.1 From b541eaff4917a7429cd0e83cb3962383276db357 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Sat, 2 Jul 2016 17:26:33 -0700 Subject: iio: adc: add missing of_node references to iio_dev Adding missing indio_dev->dev.of_node references to allow iio consumers to access the device channels. Signed-off-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7266.c | 1 + drivers/iio/adc/ad7291.c | 1 + drivers/iio/adc/ad7298.c | 1 + drivers/iio/adc/ad7476.c | 1 + drivers/iio/adc/ad7791.c | 1 + drivers/iio/adc/ad7793.c | 1 + drivers/iio/adc/ad7887.c | 1 + drivers/iio/adc/ad7923.c | 1 + drivers/iio/adc/ad799x.c | 1 + drivers/iio/adc/hi8435.c | 1 + drivers/iio/adc/ina2xx-adc.c | 1 + drivers/iio/adc/max1027.c | 1 + drivers/iio/adc/max1363.c | 1 + drivers/iio/adc/mcp320x.c | 1 + drivers/iio/adc/mcp3422.c | 1 + drivers/iio/adc/nau7802.c | 1 + drivers/iio/adc/ti-adc081c.c | 1 + drivers/iio/adc/ti-adc0832.c | 1 + drivers/iio/adc/ti-adc128s052.c | 1 + drivers/iio/adc/ti-ads8688.c | 1 + 20 files changed, 20 insertions(+) diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c index 01240ae..e527bb6 100644 --- a/drivers/iio/adc/ad7266.c +++ b/drivers/iio/adc/ad7266.c @@ -437,6 +437,7 @@ static int ad7266_probe(struct spi_device *spi) st->spi = spi; indio_dev->dev.parent = &spi->dev; + indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &ad7266_info; diff --git a/drivers/iio/adc/ad7291.c b/drivers/iio/adc/ad7291.c index 0376309..1d90b02 100644 --- a/drivers/iio/adc/ad7291.c +++ b/drivers/iio/adc/ad7291.c @@ -505,6 +505,7 @@ static int ad7291_probe(struct i2c_client *client, indio_dev->num_channels = ARRAY_SIZE(ad7291_channels); indio_dev->dev.parent = &client->dev; + indio_dev->dev.of_node = client->dev.of_node; indio_dev->info = &ad7291_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index 5dd0742..10ec8fc 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c @@ -315,6 +315,7 @@ static int ad7298_probe(struct spi_device *spi) indio_dev->name = spi_get_device_id(spi)->name; indio_dev->dev.parent = &spi->dev; + indio_dev->dev.of_node = spi->dev.of_node; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = ad7298_channels; indio_dev->num_channels = ARRAY_SIZE(ad7298_channels); diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c index a819be2..b7ecf9a 100644 --- a/drivers/iio/adc/ad7476.c +++ b/drivers/iio/adc/ad7476.c @@ -227,6 +227,7 @@ static int ad7476_probe(struct spi_device *spi) /* Establish that the iio_dev is a child of the spi device */ indio_dev->dev.parent = &spi->dev; + indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = st->chip_info->channel; diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c index 1dfe641..1817ebf 100644 --- a/drivers/iio/adc/ad7791.c +++ b/drivers/iio/adc/ad7791.c @@ -375,6 +375,7 @@ static int ad7791_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); indio_dev->dev.parent = &spi->dev; + indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = st->info->channels; diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c index a43722f..847789b 100644 --- a/drivers/iio/adc/ad7793.c +++ b/drivers/iio/adc/ad7793.c @@ -784,6 +784,7 @@ static int ad7793_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); indio_dev->dev.parent = &spi->dev; + indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = st->chip_info->channels; diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c index 1bc363b..7a483bf 100644 --- a/drivers/iio/adc/ad7887.c +++ b/drivers/iio/adc/ad7887.c @@ -264,6 +264,7 @@ static int ad7887_probe(struct spi_device *spi) /* Estabilish that the iio_dev is a child of the spi device */ indio_dev->dev.parent = &spi->dev; + indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad7887_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index 1337116..77a675e 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -288,6 +288,7 @@ static int ad7923_probe(struct spi_device *spi) indio_dev->name = spi_get_device_id(spi)->name; indio_dev->dev.parent = &spi->dev; + indio_dev->dev.of_node = spi->dev.of_node; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = info->channels; indio_dev->num_channels = info->num_channels; diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c index 5428476..b616376 100644 --- a/drivers/iio/adc/ad799x.c +++ b/drivers/iio/adc/ad799x.c @@ -806,6 +806,7 @@ static int ad799x_probe(struct i2c_client *client, st->client = client; indio_dev->dev.parent = &client->dev; + indio_dev->dev.of_node = client->dev.of_node; indio_dev->name = id->name; indio_dev->info = st->chip_config->info; diff --git a/drivers/iio/adc/hi8435.c b/drivers/iio/adc/hi8435.c index c62bdb0..678e8c7 100644 --- a/drivers/iio/adc/hi8435.c +++ b/drivers/iio/adc/hi8435.c @@ -455,6 +455,7 @@ static int hi8435_probe(struct spi_device *spi) mutex_init(&priv->lock); idev->dev.parent = &spi->dev; + idev->dev.of_node = spi->dev.of_node; idev->name = spi_get_device_id(spi)->name; idev->modes = INDIO_DIRECT_MODE; idev->info = &hi8435_info; diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c index b95ce5d..955f3fd 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -691,6 +691,7 @@ static int ina2xx_probe(struct i2c_client *client, indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE; indio_dev->dev.parent = &client->dev; + indio_dev->dev.of_node = client->dev.of_node; indio_dev->channels = ina2xx_channels; indio_dev->num_channels = ARRAY_SIZE(ina2xx_channels); indio_dev->name = id->name; diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c index 41d495c..712fbd2 100644 --- a/drivers/iio/adc/max1027.c +++ b/drivers/iio/adc/max1027.c @@ -426,6 +426,7 @@ static int max1027_probe(struct spi_device *spi) indio_dev->name = spi_get_device_id(spi)->name; indio_dev->dev.parent = &spi->dev; + indio_dev->dev.of_node = spi->dev.of_node; indio_dev->info = &max1027_info; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = st->info->channels; diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index 3b53c2e..841a13c 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -1646,6 +1646,7 @@ static int max1363_probe(struct i2c_client *client, /* Establish that the iio_dev is a child of the i2c device */ indio_dev->dev.parent = &client->dev; + indio_dev->dev.of_node = client->dev.of_node; indio_dev->name = id->name; indio_dev->channels = st->chip_info->channels; indio_dev->num_channels = st->chip_info->num_channels; diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c index a850ca7..634717a 100644 --- a/drivers/iio/adc/mcp320x.c +++ b/drivers/iio/adc/mcp320x.c @@ -308,6 +308,7 @@ static int mcp320x_probe(struct spi_device *spi) adc->spi = spi; indio_dev->dev.parent = &spi->dev; + indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &mcp320x_info; diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c index d1172dc1..254135e 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -352,6 +352,7 @@ static int mcp3422_probe(struct i2c_client *client, mutex_init(&adc->lock); indio_dev->dev.parent = &client->dev; + indio_dev->dev.of_node = client->dev.of_node; indio_dev->name = dev_name(&client->dev); indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &mcp3422_info; diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c index 57365c5..db9b829 100644 --- a/drivers/iio/adc/nau7802.c +++ b/drivers/iio/adc/nau7802.c @@ -433,6 +433,7 @@ static int nau7802_probe(struct i2c_client *client, i2c_set_clientdata(client, indio_dev); indio_dev->dev.parent = &client->dev; + indio_dev->dev.of_node = client->dev.of_node; indio_dev->name = dev_name(&client->dev); indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &nau7802_info; diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c index 283d2a1..319172c 100644 --- a/drivers/iio/adc/ti-adc081c.c +++ b/drivers/iio/adc/ti-adc081c.c @@ -186,6 +186,7 @@ static int adc081c_probe(struct i2c_client *client, return err; iio->dev.parent = &client->dev; + iio->dev.of_node = client->dev.of_node; iio->name = dev_name(&client->dev); iio->modes = INDIO_DIRECT_MODE; iio->info = &adc081c_info; diff --git a/drivers/iio/adc/ti-adc0832.c b/drivers/iio/adc/ti-adc0832.c index 0afeac0..f4ba23e 100644 --- a/drivers/iio/adc/ti-adc0832.c +++ b/drivers/iio/adc/ti-adc0832.c @@ -194,6 +194,7 @@ static int adc0832_probe(struct spi_device *spi) indio_dev->name = spi_get_device_id(spi)->name; indio_dev->dev.parent = &spi->dev; + indio_dev->dev.of_node = spi->dev.of_node; indio_dev->info = &adc0832_info; indio_dev->modes = INDIO_DIRECT_MODE; diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index bc58867..89dfbd3 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -150,6 +150,7 @@ static int adc128_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); indio_dev->dev.parent = &spi->dev; + indio_dev->dev.of_node = spi->dev.of_node; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &adc128_info; diff --git a/drivers/iio/adc/ti-ads8688.c b/drivers/iio/adc/ti-ads8688.c index 03e9070..c400439 100644 --- a/drivers/iio/adc/ti-ads8688.c +++ b/drivers/iio/adc/ti-ads8688.c @@ -421,6 +421,7 @@ static int ads8688_probe(struct spi_device *spi) indio_dev->name = spi_get_device_id(spi)->name; indio_dev->dev.parent = &spi->dev; + indio_dev->dev.of_node = spi->dev.of_node; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->channels = st->chip_info->channels; indio_dev->num_channels = st->chip_info->num_channels; -- cgit v1.1 From 4e68cfbf345c3b9109242483cd56d551d38c8b85 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 22 May 2016 20:39:29 +0100 Subject: iio: accel: st_accel: Add lis3l02dq support Time to finally kill off the venerable (it was one of my first drivers) lis3l02dq driver in favour of adding support in the st sensors framework. This does loose us the event support that driver always had, but I think that will reappear at some point and in the meantime the maintenance advantages of dropping the 'special' driver for this one part outweigh the issues. It's worth noting this part is ancient and I may well be the only person who still has any on hardware running recent kernels. It has a few 'quirks'. - No WAI register so that just became optional. - A BDU option that really does block updates. Completely. Whatever you do, you don't get any more data with it set. It is documented the same as more modern parts but I presume they are actually clearing for updates after a read of both bytes! - Fixed scale. - It's too quick. Even at slowest rate (280Hz) I can't read out fast enough on my board (stargate 2) to beat new data coming in. Linus' repeat read patch doesn't help in this case. It just means I get 10 readings before dying... So in reality this will get used with software triggers only unless someone has this long out of production device on a quick board. Signed-off-by: Jonathan Cameron Reviewed-by: Linus Walleij Cc: Denis CIOCCA Cc: Crestez Dan Leonard Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel.h | 1 + drivers/iio/accel/st_accel_core.c | 64 +++++++++++++++++++++++++ drivers/iio/accel/st_accel_i2c.c | 5 ++ drivers/iio/accel/st_accel_spi.c | 1 + drivers/iio/common/st_sensors/st_sensors_core.c | 26 +++++----- 5 files changed, 86 insertions(+), 11 deletions(-) diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h index 57f83a6..f8dfdb6 100644 --- a/drivers/iio/accel/st_accel.h +++ b/drivers/iio/accel/st_accel.h @@ -29,6 +29,7 @@ #define LSM330_ACCEL_DEV_NAME "lsm330_accel" #define LSM303AGR_ACCEL_DEV_NAME "lsm303agr_accel" #define LIS2DH12_ACCEL_DEV_NAME "lis2dh12_accel" +#define LIS3L02DQ_ACCEL_DEV_NAME "lis3l02dq" /** * struct st_sensors_platform_data - default accel platform data diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index dce289a..da3fb06 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -215,6 +215,22 @@ #define ST_ACCEL_6_IHL_IRQ_MASK 0x80 #define ST_ACCEL_6_MULTIREAD_BIT true +/* CUSTOM VALUES FOR SENSOR 7 */ +#define ST_ACCEL_7_ODR_ADDR 0x20 +#define ST_ACCEL_7_ODR_MASK 0x30 +#define ST_ACCEL_7_ODR_AVL_280HZ_VAL 0x00 +#define ST_ACCEL_7_ODR_AVL_560HZ_VAL 0x01 +#define ST_ACCEL_7_ODR_AVL_1120HZ_VAL 0x02 +#define ST_ACCEL_7_ODR_AVL_4480HZ_VAL 0x03 +#define ST_ACCEL_7_PW_ADDR 0x20 +#define ST_ACCEL_7_PW_MASK 0xc0 +#define ST_ACCEL_7_FS_AVL_2_GAIN IIO_G_TO_M_S_2(488) +#define ST_ACCEL_7_BDU_ADDR 0x21 +#define ST_ACCEL_7_BDU_MASK 0x40 +#define ST_ACCEL_7_DRDY_IRQ_ADDR 0x21 +#define ST_ACCEL_7_DRDY_IRQ_INT1_MASK 0x04 +#define ST_ACCEL_7_MULTIREAD_BIT false + static const struct iio_chan_spec st_accel_8bit_channels[] = { ST_SENSORS_LSM_CHANNELS(IIO_ACCEL, BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), @@ -662,6 +678,54 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { .multi_read_bit = ST_ACCEL_6_MULTIREAD_BIT, .bootime = 2, }, + { + /* No WAI register present */ + .sensors_supported = { + [0] = LIS3L02DQ_ACCEL_DEV_NAME, + }, + .ch = (struct iio_chan_spec *)st_accel_12bit_channels, + .odr = { + .addr = ST_ACCEL_7_ODR_ADDR, + .mask = ST_ACCEL_7_ODR_MASK, + .odr_avl = { + { 280, ST_ACCEL_7_ODR_AVL_280HZ_VAL, }, + { 560, ST_ACCEL_7_ODR_AVL_560HZ_VAL, }, + { 1120, ST_ACCEL_7_ODR_AVL_1120HZ_VAL, }, + { 4480, ST_ACCEL_7_ODR_AVL_4480HZ_VAL, }, + }, + }, + .pw = { + .addr = ST_ACCEL_7_PW_ADDR, + .mask = ST_ACCEL_7_PW_MASK, + .value_on = ST_SENSORS_DEFAULT_POWER_ON_VALUE, + .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE, + }, + .enable_axis = { + .addr = ST_SENSORS_DEFAULT_AXIS_ADDR, + .mask = ST_SENSORS_DEFAULT_AXIS_MASK, + }, + .fs = { + .fs_avl = { + [0] = { + .num = ST_ACCEL_FS_AVL_2G, + .gain = ST_ACCEL_7_FS_AVL_2_GAIN, + }, + }, + }, + /* + * The part has a BDU bit but if set the data is never + * updated so don't set it. + */ + .bdu = { + }, + .drdy_irq = { + .addr = ST_ACCEL_7_DRDY_IRQ_ADDR, + .mask_int1 = ST_ACCEL_7_DRDY_IRQ_INT1_MASK, + .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, + }, + .multi_read_bit = ST_ACCEL_7_MULTIREAD_BIT, + .bootime = 2, + }, }; static int st_accel_read_raw(struct iio_dev *indio_dev, diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index 7333ee9..e9d427a 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -80,6 +80,10 @@ static const struct of_device_id st_accel_of_match[] = { .compatible = "st,h3lis331dl-accel", .data = H3LIS331DL_DRIVER_NAME, }, + { + .compatible = "st,lis3l02dq", + .data = LIS3L02DQ_ACCEL_DEV_NAME, + }, {}, }; MODULE_DEVICE_TABLE(of, st_accel_of_match); @@ -130,6 +134,7 @@ static const struct i2c_device_id st_accel_id_table[] = { { LSM330_ACCEL_DEV_NAME }, { LSM303AGR_ACCEL_DEV_NAME }, { LIS2DH12_ACCEL_DEV_NAME }, + { LIS3L02DQ_ACCEL_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(i2c, st_accel_id_table); diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c index fcd5847..efd4394 100644 --- a/drivers/iio/accel/st_accel_spi.c +++ b/drivers/iio/accel/st_accel_spi.c @@ -59,6 +59,7 @@ static const struct spi_device_id st_accel_id_table[] = { { LSM330_ACCEL_DEV_NAME }, { LSM303AGR_ACCEL_DEV_NAME }, { LIS2DH12_ACCEL_DEV_NAME }, + { LIS3L02DQ_ACCEL_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(spi, st_accel_id_table); diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 6db12ea..26ce325 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -550,7 +550,7 @@ int st_sensors_check_device_support(struct iio_dev *indio_dev, int num_sensors_list, const struct st_sensor_settings *sensor_settings) { - int i, n, err; + int i, n, err = 0; u8 wai; struct st_sensor_data *sdata = iio_priv(indio_dev); @@ -570,17 +570,21 @@ int st_sensors_check_device_support(struct iio_dev *indio_dev, return -ENODEV; } - err = sdata->tf->read_byte(&sdata->tb, sdata->dev, - sensor_settings[i].wai_addr, &wai); - if (err < 0) { - dev_err(&indio_dev->dev, "failed to read Who-Am-I register.\n"); - return err; - } + if (sensor_settings[i].wai_addr) { + err = sdata->tf->read_byte(&sdata->tb, sdata->dev, + sensor_settings[i].wai_addr, &wai); + if (err < 0) { + dev_err(&indio_dev->dev, + "failed to read Who-Am-I register.\n"); + return err; + } - if (sensor_settings[i].wai != wai) { - dev_err(&indio_dev->dev, "%s: WhoAmI mismatch (0x%x).\n", - indio_dev->name, wai); - return -EINVAL; + if (sensor_settings[i].wai != wai) { + dev_err(&indio_dev->dev, + "%s: WhoAmI mismatch (0x%x).\n", + indio_dev->name, wai); + return -EINVAL; + } } sdata->sensor_settings = -- cgit v1.1 From fc6bd7275bd4c1d7fce50c55370b0a3526869bd7 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 3 Jul 2016 14:55:50 +0100 Subject: staging:iio:lis3l02dq drop separate driver Retire this venerable driver as the basic support is now in the generic st-sensors accelerometer driver. There are a few missing features in the new driver: * Threshold events. * Access to the calibration adjustment registers (patch shortly) In exchange it brings a cleaner and more maintainable code base that actually gets tested more than once every few years. I'll actually be suprised if anyone other than me has a board with one of these on that is running an up to date kernel. Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/Kconfig | 14 - drivers/staging/iio/accel/Makefile | 4 - drivers/staging/iio/accel/lis3l02dq.h | 217 -------- drivers/staging/iio/accel/lis3l02dq_core.c | 814 ----------------------------- drivers/staging/iio/accel/lis3l02dq_ring.c | 428 --------------- 5 files changed, 1477 deletions(-) delete mode 100644 drivers/staging/iio/accel/lis3l02dq.h delete mode 100644 drivers/staging/iio/accel/lis3l02dq_core.c delete mode 100644 drivers/staging/iio/accel/lis3l02dq_ring.c diff --git a/drivers/staging/iio/accel/Kconfig b/drivers/staging/iio/accel/Kconfig index f066aa3..1c994b5 100644 --- a/drivers/staging/iio/accel/Kconfig +++ b/drivers/staging/iio/accel/Kconfig @@ -51,20 +51,6 @@ config ADIS16240 To compile this driver as a module, say M here: the module will be called adis16240. -config LIS3L02DQ - tristate "ST Microelectronics LIS3L02DQ Accelerometer Driver" - depends on SPI - select IIO_TRIGGER if IIO_BUFFER - depends on !IIO_BUFFER || IIO_KFIFO_BUF - depends on GPIOLIB || COMPILE_TEST - help - Say Y here to build SPI support for the ST microelectronics - accelerometer. The driver supplies direct access via sysfs files - and an event interface via a character device. - - To compile this driver as a module, say M here: the module will be - called lis3l02dq. - config SCA3000 depends on IIO_BUFFER depends on SPI diff --git a/drivers/staging/iio/accel/Makefile b/drivers/staging/iio/accel/Makefile index 415329c..1810a43 100644 --- a/drivers/staging/iio/accel/Makefile +++ b/drivers/staging/iio/accel/Makefile @@ -14,9 +14,5 @@ obj-$(CONFIG_ADIS16209) += adis16209.o adis16240-y := adis16240_core.o obj-$(CONFIG_ADIS16240) += adis16240.o -lis3l02dq-y := lis3l02dq_core.o -lis3l02dq-$(CONFIG_IIO_BUFFER) += lis3l02dq_ring.o -obj-$(CONFIG_LIS3L02DQ) += lis3l02dq.o - sca3000-y := sca3000_core.o sca3000_ring.o obj-$(CONFIG_SCA3000) += sca3000.o diff --git a/drivers/staging/iio/accel/lis3l02dq.h b/drivers/staging/iio/accel/lis3l02dq.h deleted file mode 100644 index 6bd3d4d..0000000 --- a/drivers/staging/iio/accel/lis3l02dq.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * LISL02DQ.h -- support STMicroelectronics LISD02DQ - * 3d 2g Linear Accelerometers via SPI - * - * Copyright (c) 2007 Jonathan Cameron - * - * Loosely based upon tle62x0.c - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef SPI_LIS3L02DQ_H_ -#define SPI_LIS3L02DQ_H_ -#define LIS3L02DQ_READ_REG(a) ((a) | 0x80) -#define LIS3L02DQ_WRITE_REG(a) a - -/* Calibration parameters */ -#define LIS3L02DQ_REG_OFFSET_X_ADDR 0x16 -#define LIS3L02DQ_REG_OFFSET_Y_ADDR 0x17 -#define LIS3L02DQ_REG_OFFSET_Z_ADDR 0x18 - -#define LIS3L02DQ_REG_GAIN_X_ADDR 0x19 -#define LIS3L02DQ_REG_GAIN_Y_ADDR 0x1A -#define LIS3L02DQ_REG_GAIN_Z_ADDR 0x1B - -/* Control Register (1 of 2) */ -#define LIS3L02DQ_REG_CTRL_1_ADDR 0x20 -/* Power ctrl - either bit set corresponds to on*/ -#define LIS3L02DQ_REG_CTRL_1_PD_ON 0xC0 - -/* Decimation Factor */ -#define LIS3L02DQ_DEC_MASK 0x30 -#define LIS3L02DQ_REG_CTRL_1_DF_128 0x00 -#define LIS3L02DQ_REG_CTRL_1_DF_64 0x10 -#define LIS3L02DQ_REG_CTRL_1_DF_32 0x20 -#define LIS3L02DQ_REG_CTRL_1_DF_8 (0x10 | 0x20) - -/* Self Test Enable */ -#define LIS3L02DQ_REG_CTRL_1_SELF_TEST_ON 0x08 - -/* Axes enable ctrls */ -#define LIS3L02DQ_REG_CTRL_1_AXES_Z_ENABLE 0x04 -#define LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE 0x02 -#define LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE 0x01 - -/* Control Register (2 of 2) */ -#define LIS3L02DQ_REG_CTRL_2_ADDR 0x21 - -/* Block Data Update only after MSB and LSB read */ -#define LIS3L02DQ_REG_CTRL_2_BLOCK_UPDATE 0x40 - -/* Set to big endian output */ -#define LIS3L02DQ_REG_CTRL_2_BIG_ENDIAN 0x20 - -/* Reboot memory content */ -#define LIS3L02DQ_REG_CTRL_2_REBOOT_MEMORY 0x10 - -/* Interrupt Enable - applies data ready to the RDY pad */ -#define LIS3L02DQ_REG_CTRL_2_ENABLE_INTERRUPT 0x08 - -/* Enable Data Ready Generation - relationship with previous unclear in docs */ -#define LIS3L02DQ_REG_CTRL_2_ENABLE_DATA_READY_GENERATION 0x04 - -/* SPI 3 wire mode */ -#define LIS3L02DQ_REG_CTRL_2_THREE_WIRE_SPI_MODE 0x02 - -/* Data alignment, default is 12 bit right justified - * - option for 16 bit left justified - */ -#define LIS3L02DQ_REG_CTRL_2_DATA_ALIGNMENT_16_BIT_LEFT_JUSTIFIED 0x01 - -/* Interrupt related stuff */ -#define LIS3L02DQ_REG_WAKE_UP_CFG_ADDR 0x23 - -/* Switch from or combination of conditions to and */ -#define LIS3L02DQ_REG_WAKE_UP_CFG_BOOLEAN_AND 0x80 - -/* Latch interrupt request, - * if on ack must be given by reading the ack register - */ -#define LIS3L02DQ_REG_WAKE_UP_CFG_LATCH_SRC 0x40 - -/* Z Interrupt on High (above threshold) */ -#define LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Z_HIGH 0x20 -/* Z Interrupt on Low */ -#define LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Z_LOW 0x10 -/* Y Interrupt on High */ -#define LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Y_HIGH 0x08 -/* Y Interrupt on Low */ -#define LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_Y_LOW 0x04 -/* X Interrupt on High */ -#define LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_X_HIGH 0x02 -/* X Interrupt on Low */ -#define LIS3L02DQ_REG_WAKE_UP_CFG_INTERRUPT_X_LOW 0x01 - -/* Register that gives description of what caused interrupt - * - latched if set in CFG_ADDRES - */ -#define LIS3L02DQ_REG_WAKE_UP_SRC_ADDR 0x24 -/* top bit ignored */ -/* Interrupt Active */ -#define LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_ACTIVATED 0x40 -/* Interupts that have been triggered */ -#define LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_HIGH 0x20 -#define LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_LOW 0x10 -#define LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_HIGH 0x08 -#define LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_LOW 0x04 -#define LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_HIGH 0x02 -#define LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_LOW 0x01 - -#define LIS3L02DQ_REG_WAKE_UP_ACK_ADDR 0x25 - -/* Status register */ -#define LIS3L02DQ_REG_STATUS_ADDR 0x27 -/* XYZ axis data overrun - first is all overrun? */ -#define LIS3L02DQ_REG_STATUS_XYZ_OVERRUN 0x80 -#define LIS3L02DQ_REG_STATUS_Z_OVERRUN 0x40 -#define LIS3L02DQ_REG_STATUS_Y_OVERRUN 0x20 -#define LIS3L02DQ_REG_STATUS_X_OVERRUN 0x10 -/* XYZ new data available - first is all 3 available? */ -#define LIS3L02DQ_REG_STATUS_XYZ_NEW_DATA 0x08 -#define LIS3L02DQ_REG_STATUS_Z_NEW_DATA 0x04 -#define LIS3L02DQ_REG_STATUS_Y_NEW_DATA 0x02 -#define LIS3L02DQ_REG_STATUS_X_NEW_DATA 0x01 - -/* The accelerometer readings - low and high bytes. - * Form of high byte dependent on justification set in ctrl reg - */ -#define LIS3L02DQ_REG_OUT_X_L_ADDR 0x28 -#define LIS3L02DQ_REG_OUT_X_H_ADDR 0x29 -#define LIS3L02DQ_REG_OUT_Y_L_ADDR 0x2A -#define LIS3L02DQ_REG_OUT_Y_H_ADDR 0x2B -#define LIS3L02DQ_REG_OUT_Z_L_ADDR 0x2C -#define LIS3L02DQ_REG_OUT_Z_H_ADDR 0x2D - -/* Threshold values for all axes and both above and below thresholds - * - i.e. there is only one value - */ -#define LIS3L02DQ_REG_THS_L_ADDR 0x2E -#define LIS3L02DQ_REG_THS_H_ADDR 0x2F - -#define LIS3L02DQ_DEFAULT_CTRL1 (LIS3L02DQ_REG_CTRL_1_PD_ON \ - | LIS3L02DQ_REG_CTRL_1_AXES_Z_ENABLE \ - | LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE \ - | LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE \ - | LIS3L02DQ_REG_CTRL_1_DF_128) - -#define LIS3L02DQ_DEFAULT_CTRL2 0 - -#define LIS3L02DQ_MAX_TX 12 -#define LIS3L02DQ_MAX_RX 12 -/** - * struct lis3l02dq_state - device instance specific data - * @us: actual spi_device - * @trig: data ready trigger registered with iio - * @buf_lock: mutex to protect tx and rx - * @tx: transmit buffer - * @rx: receive buffer - **/ -struct lis3l02dq_state { - struct spi_device *us; - struct iio_trigger *trig; - struct mutex buf_lock; - int gpio; - bool trigger_on; - - u8 tx[LIS3L02DQ_MAX_RX] ____cacheline_aligned; - u8 rx[LIS3L02DQ_MAX_RX] ____cacheline_aligned; -}; - -int lis3l02dq_spi_read_reg_8(struct iio_dev *indio_dev, - u8 reg_address, - u8 *val); - -int lis3l02dq_spi_write_reg_8(struct iio_dev *indio_dev, - u8 reg_address, - u8 val); - -int lis3l02dq_disable_all_events(struct iio_dev *indio_dev); - -#ifdef CONFIG_IIO_BUFFER -/* At the moment triggers are only used for buffer - * filling. This may change! - */ -void lis3l02dq_remove_trigger(struct iio_dev *indio_dev); -int lis3l02dq_probe_trigger(struct iio_dev *indio_dev); - -int lis3l02dq_configure_buffer(struct iio_dev *indio_dev); -void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev); - -irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private); -#define lis3l02dq_th lis3l02dq_data_rdy_trig_poll - -#else /* CONFIG_IIO_BUFFER */ -#define lis3l02dq_th lis3l02dq_nobuffer - -static inline void lis3l02dq_remove_trigger(struct iio_dev *indio_dev) -{ -} - -static inline int lis3l02dq_probe_trigger(struct iio_dev *indio_dev) -{ - return 0; -} - -static int lis3l02dq_configure_buffer(struct iio_dev *indio_dev) -{ - return 0; -} - -static inline void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev) -{ -} -#endif /* CONFIG_IIO_BUFFER */ -#endif /* SPI_LIS3L02DQ_H_ */ diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c deleted file mode 100644 index 5c3410a..0000000 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ /dev/null @@ -1,814 +0,0 @@ -/* - * lis3l02dq.c support STMicroelectronics LISD02DQ - * 3d 2g Linear Accelerometers via SPI - * - * Copyright (c) 2007 Jonathan Cameron - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * Settings: - * 16 bit left justified mode used. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "lis3l02dq.h" - -/* At the moment the spi framework doesn't allow global setting of cs_change. - * It's in the likely to be added comment at the top of spi.h. - * This means that use cannot be made of spi_write etc. - */ -/* direct copy of the irq_default_primary_handler */ -#ifndef CONFIG_IIO_BUFFER -static irqreturn_t lis3l02dq_nobuffer(int irq, void *private) -{ - return IRQ_WAKE_THREAD; -} -#endif - -/** - * lis3l02dq_spi_read_reg_8() - read single byte from a single register - * @indio_dev: iio_dev for this actual device - * @reg_address: the address of the register to be read - * @val: pass back the resulting value - **/ -int lis3l02dq_spi_read_reg_8(struct iio_dev *indio_dev, - u8 reg_address, u8 *val) -{ - struct lis3l02dq_state *st = iio_priv(indio_dev); - int ret; - struct spi_transfer xfer = { - .tx_buf = st->tx, - .rx_buf = st->rx, - .bits_per_word = 8, - .len = 2, - }; - - mutex_lock(&st->buf_lock); - st->tx[0] = LIS3L02DQ_READ_REG(reg_address); - st->tx[1] = 0; - - ret = spi_sync_transfer(st->us, &xfer, 1); - *val = st->rx[1]; - mutex_unlock(&st->buf_lock); - - return ret; -} - -/** - * lis3l02dq_spi_write_reg_8() - write single byte to a register - * @indio_dev: iio_dev for this device - * @reg_address: the address of the register to be written - * @val: the value to write - **/ -int lis3l02dq_spi_write_reg_8(struct iio_dev *indio_dev, - u8 reg_address, - u8 val) -{ - int ret; - struct lis3l02dq_state *st = iio_priv(indio_dev); - - mutex_lock(&st->buf_lock); - st->tx[0] = LIS3L02DQ_WRITE_REG(reg_address); - st->tx[1] = val; - ret = spi_write(st->us, st->tx, 2); - mutex_unlock(&st->buf_lock); - - return ret; -} - -/** - * lisl302dq_spi_write_reg_s16() - write 2 bytes to a pair of registers - * @indio_dev: iio_dev for this device - * @lower_reg_address: the address of the lower of the two registers. - * Second register is assumed to have address one greater. - * @value: value to be written - **/ -static int lis3l02dq_spi_write_reg_s16(struct iio_dev *indio_dev, - u8 lower_reg_address, - s16 value) -{ - int ret; - struct lis3l02dq_state *st = iio_priv(indio_dev); - struct spi_transfer xfers[] = { { - .tx_buf = st->tx, - .bits_per_word = 8, - .len = 2, - .cs_change = 1, - }, { - .tx_buf = st->tx + 2, - .bits_per_word = 8, - .len = 2, - }, - }; - - mutex_lock(&st->buf_lock); - st->tx[0] = LIS3L02DQ_WRITE_REG(lower_reg_address); - st->tx[1] = value & 0xFF; - st->tx[2] = LIS3L02DQ_WRITE_REG(lower_reg_address + 1); - st->tx[3] = (value >> 8) & 0xFF; - - ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); - mutex_unlock(&st->buf_lock); - - return ret; -} - -static int lis3l02dq_read_reg_s16(struct iio_dev *indio_dev, - u8 lower_reg_address, - int *val) -{ - struct lis3l02dq_state *st = iio_priv(indio_dev); - int ret; - s16 tempval; - struct spi_transfer xfers[] = { { - .tx_buf = st->tx, - .rx_buf = st->rx, - .bits_per_word = 8, - .len = 2, - .cs_change = 1, - }, { - .tx_buf = st->tx + 2, - .rx_buf = st->rx + 2, - .bits_per_word = 8, - .len = 2, - }, - }; - - mutex_lock(&st->buf_lock); - st->tx[0] = LIS3L02DQ_READ_REG(lower_reg_address); - st->tx[1] = 0; - st->tx[2] = LIS3L02DQ_READ_REG(lower_reg_address + 1); - st->tx[3] = 0; - - ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); - if (ret) { - dev_err(&st->us->dev, "problem when reading 16 bit register"); - goto error_ret; - } - tempval = (s16)(st->rx[1]) | ((s16)(st->rx[3]) << 8); - - *val = tempval; -error_ret: - mutex_unlock(&st->buf_lock); - return ret; -} - -enum lis3l02dq_rm_ind { - LIS3L02DQ_ACCEL, - LIS3L02DQ_GAIN, - LIS3L02DQ_BIAS, -}; - -static u8 lis3l02dq_axis_map[3][3] = { - [LIS3L02DQ_ACCEL] = { LIS3L02DQ_REG_OUT_X_L_ADDR, - LIS3L02DQ_REG_OUT_Y_L_ADDR, - LIS3L02DQ_REG_OUT_Z_L_ADDR }, - [LIS3L02DQ_GAIN] = { LIS3L02DQ_REG_GAIN_X_ADDR, - LIS3L02DQ_REG_GAIN_Y_ADDR, - LIS3L02DQ_REG_GAIN_Z_ADDR }, - [LIS3L02DQ_BIAS] = { LIS3L02DQ_REG_OFFSET_X_ADDR, - LIS3L02DQ_REG_OFFSET_Y_ADDR, - LIS3L02DQ_REG_OFFSET_Z_ADDR } -}; - -static int lis3l02dq_read_thresh(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) -{ - int ret; - - ret = lis3l02dq_read_reg_s16(indio_dev, LIS3L02DQ_REG_THS_L_ADDR, val); - if (ret) - return ret; - return IIO_VAL_INT; -} - -static int lis3l02dq_write_thresh(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) -{ - u16 value = val; - - return lis3l02dq_spi_write_reg_s16(indio_dev, - LIS3L02DQ_REG_THS_L_ADDR, - value); -} - -static int lis3l02dq_write_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int val, - int val2, - long mask) -{ - int ret = -EINVAL, reg; - u8 uval; - s8 sval; - - switch (mask) { - case IIO_CHAN_INFO_CALIBBIAS: - if (val > 255 || val < -256) - return -EINVAL; - sval = val; - reg = lis3l02dq_axis_map[LIS3L02DQ_BIAS][chan->address]; - ret = lis3l02dq_spi_write_reg_8(indio_dev, reg, sval); - break; - case IIO_CHAN_INFO_CALIBSCALE: - if (val & ~0xFF) - return -EINVAL; - uval = val; - reg = lis3l02dq_axis_map[LIS3L02DQ_GAIN][chan->address]; - ret = lis3l02dq_spi_write_reg_8(indio_dev, reg, uval); - break; - } - return ret; -} - -static int lis3l02dq_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long mask) -{ - u8 utemp; - s8 stemp; - ssize_t ret = 0; - u8 reg; - - switch (mask) { - case IIO_CHAN_INFO_RAW: - /* Take the iio_dev status lock */ - mutex_lock(&indio_dev->mlock); - if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) { - ret = -EBUSY; - } else { - reg = lis3l02dq_axis_map - [LIS3L02DQ_ACCEL][chan->address]; - ret = lis3l02dq_read_reg_s16(indio_dev, reg, val); - } - mutex_unlock(&indio_dev->mlock); - if (ret < 0) - goto error_ret; - return IIO_VAL_INT; - case IIO_CHAN_INFO_SCALE: - *val = 0; - *val2 = 9580; - return IIO_VAL_INT_PLUS_MICRO; - case IIO_CHAN_INFO_CALIBSCALE: - reg = lis3l02dq_axis_map[LIS3L02DQ_GAIN][chan->address]; - ret = lis3l02dq_spi_read_reg_8(indio_dev, reg, &utemp); - if (ret) - goto error_ret; - /* to match with what previous code does */ - *val = utemp; - return IIO_VAL_INT; - - case IIO_CHAN_INFO_CALIBBIAS: - reg = lis3l02dq_axis_map[LIS3L02DQ_BIAS][chan->address]; - ret = lis3l02dq_spi_read_reg_8(indio_dev, reg, (u8 *)&stemp); - /* to match with what previous code does */ - *val = stemp; - return IIO_VAL_INT; - } -error_ret: - return ret; -} - -static ssize_t lis3l02dq_read_frequency(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - int ret, len = 0; - s8 t; - - ret = lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_1_ADDR, - (u8 *)&t); - if (ret) - return ret; - t &= LIS3L02DQ_DEC_MASK; - switch (t) { - case LIS3L02DQ_REG_CTRL_1_DF_128: - len = sprintf(buf, "280\n"); - break; - case LIS3L02DQ_REG_CTRL_1_DF_64: - len = sprintf(buf, "560\n"); - break; - case LIS3L02DQ_REG_CTRL_1_DF_32: - len = sprintf(buf, "1120\n"); - break; - case LIS3L02DQ_REG_CTRL_1_DF_8: - len = sprintf(buf, "4480\n"); - break; - } - return len; -} - -static ssize_t lis3l02dq_write_frequency(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - unsigned long val; - int ret; - u8 t; - - ret = kstrtoul(buf, 10, &val); - if (ret) - return ret; - - mutex_lock(&indio_dev->mlock); - ret = lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_1_ADDR, - &t); - if (ret) - goto error_ret_mutex; - /* Wipe the bits clean */ - t &= ~LIS3L02DQ_DEC_MASK; - switch (val) { - case 280: - t |= LIS3L02DQ_REG_CTRL_1_DF_128; - break; - case 560: - t |= LIS3L02DQ_REG_CTRL_1_DF_64; - break; - case 1120: - t |= LIS3L02DQ_REG_CTRL_1_DF_32; - break; - case 4480: - t |= LIS3L02DQ_REG_CTRL_1_DF_8; - break; - default: - ret = -EINVAL; - goto error_ret_mutex; - } - - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_1_ADDR, - t); - -error_ret_mutex: - mutex_unlock(&indio_dev->mlock); - - return ret ? ret : len; -} - -static int lis3l02dq_initial_setup(struct iio_dev *indio_dev) -{ - struct lis3l02dq_state *st = iio_priv(indio_dev); - int ret; - u8 val, valtest; - - st->us->mode = SPI_MODE_3; - - spi_setup(st->us); - - val = LIS3L02DQ_DEFAULT_CTRL1; - /* Write suitable defaults to ctrl1 */ - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_1_ADDR, - val); - if (ret) { - dev_err(&st->us->dev, "problem with setup control register 1"); - goto err_ret; - } - /* Repeat as sometimes doesn't work first time? */ - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_1_ADDR, - val); - if (ret) { - dev_err(&st->us->dev, "problem with setup control register 1"); - goto err_ret; - } - - /* - * Read back to check this has worked acts as loose test of correct - * chip - */ - ret = lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_1_ADDR, - &valtest); - if (ret || (valtest != val)) { - dev_err(&indio_dev->dev, - "device not playing ball %d %d\n", valtest, val); - ret = -EINVAL; - goto err_ret; - } - - val = LIS3L02DQ_DEFAULT_CTRL2; - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_2_ADDR, - val); - if (ret) { - dev_err(&st->us->dev, "problem with setup control register 2"); - goto err_ret; - } - - val = LIS3L02DQ_REG_WAKE_UP_CFG_LATCH_SRC; - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_WAKE_UP_CFG_ADDR, - val); - if (ret) - dev_err(&st->us->dev, "problem with interrupt cfg register"); -err_ret: - - return ret; -} - -static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, - lis3l02dq_read_frequency, - lis3l02dq_write_frequency); - -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("280 560 1120 4480"); - -static irqreturn_t lis3l02dq_event_handler(int irq, void *private) -{ - struct iio_dev *indio_dev = private; - u8 t; - - s64 timestamp = iio_get_time_ns(indio_dev); - - lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_WAKE_UP_SRC_ADDR, - &t); - - if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_HIGH) - iio_push_event(indio_dev, - IIO_MOD_EVENT_CODE(IIO_ACCEL, - 0, - IIO_MOD_Z, - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_RISING), - timestamp); - - if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Z_LOW) - iio_push_event(indio_dev, - IIO_MOD_EVENT_CODE(IIO_ACCEL, - 0, - IIO_MOD_Z, - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_FALLING), - timestamp); - - if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_HIGH) - iio_push_event(indio_dev, - IIO_MOD_EVENT_CODE(IIO_ACCEL, - 0, - IIO_MOD_Y, - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_RISING), - timestamp); - - if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_Y_LOW) - iio_push_event(indio_dev, - IIO_MOD_EVENT_CODE(IIO_ACCEL, - 0, - IIO_MOD_Y, - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_FALLING), - timestamp); - - if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_HIGH) - iio_push_event(indio_dev, - IIO_MOD_EVENT_CODE(IIO_ACCEL, - 0, - IIO_MOD_X, - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_RISING), - timestamp); - - if (t & LIS3L02DQ_REG_WAKE_UP_SRC_INTERRUPT_X_LOW) - iio_push_event(indio_dev, - IIO_MOD_EVENT_CODE(IIO_ACCEL, - 0, - IIO_MOD_X, - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_FALLING), - timestamp); - - /* Ack and allow for new interrupts */ - lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_WAKE_UP_ACK_ADDR, - &t); - - return IRQ_HANDLED; -} - -static const struct iio_event_spec lis3l02dq_event[] = { - { - .type = IIO_EV_TYPE_THRESH, - .dir = IIO_EV_DIR_RISING, - .mask_separate = BIT(IIO_EV_INFO_ENABLE), - .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE), - }, { - .type = IIO_EV_TYPE_THRESH, - .dir = IIO_EV_DIR_FALLING, - .mask_separate = BIT(IIO_EV_INFO_ENABLE), - .mask_shared_by_type = BIT(IIO_EV_INFO_VALUE), - } -}; - -#define LIS3L02DQ_CHAN(index, mod) \ - { \ - .type = IIO_ACCEL, \ - .modified = 1, \ - .channel2 = mod, \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ - BIT(IIO_CHAN_INFO_CALIBSCALE) | \ - BIT(IIO_CHAN_INFO_CALIBBIAS), \ - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ - .address = index, \ - .scan_index = index, \ - .scan_type = { \ - .sign = 's', \ - .realbits = 12, \ - .storagebits = 16, \ - }, \ - .event_spec = lis3l02dq_event, \ - .num_event_specs = ARRAY_SIZE(lis3l02dq_event), \ - } - -static const struct iio_chan_spec lis3l02dq_channels[] = { - LIS3L02DQ_CHAN(0, IIO_MOD_X), - LIS3L02DQ_CHAN(1, IIO_MOD_Y), - LIS3L02DQ_CHAN(2, IIO_MOD_Z), - IIO_CHAN_SOFT_TIMESTAMP(3) -}; - -static int lis3l02dq_read_event_config(struct iio_dev *indio_dev, - const struct iio_chan_spec *chan, - enum iio_event_type type, - enum iio_event_direction dir) -{ - u8 val; - int ret; - u8 mask = 1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING)); - - ret = lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_WAKE_UP_CFG_ADDR, - &val); - if (ret < 0) - return ret; - - return !!(val & mask); -} - -int lis3l02dq_disable_all_events(struct iio_dev *indio_dev) -{ - int ret; - u8 control, val; - - ret = lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_2_ADDR, - &control); - - control &= ~LIS3L02DQ_REG_CTRL_2_ENABLE_INTERRUPT; - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_2_ADDR, - control); - if (ret) - goto error_ret; - /* Also for consistency clear the mask */ - ret = lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_WAKE_UP_CFG_ADDR, - &val); - if (ret) - goto error_ret; - val &= ~0x3f; - - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_WAKE_UP_CFG_ADDR, - val); - if (ret) - goto error_ret; - - ret = control; -error_ret: - return ret; -} - -static int lis3l02dq_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) -{ - int ret = 0; - u8 val, control; - u8 currentlyset; - bool changed = false; - u8 mask = 1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING)); - - mutex_lock(&indio_dev->mlock); - /* read current control */ - ret = lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_2_ADDR, - &control); - if (ret) - goto error_ret; - ret = lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_WAKE_UP_CFG_ADDR, - &val); - if (ret < 0) - goto error_ret; - currentlyset = val & mask; - - if (!currentlyset && state) { - changed = true; - val |= mask; - } else if (currentlyset && !state) { - changed = true; - val &= ~mask; - } - - if (changed) { - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_WAKE_UP_CFG_ADDR, - val); - if (ret) - goto error_ret; - control = val & 0x3f ? - (control | LIS3L02DQ_REG_CTRL_2_ENABLE_INTERRUPT) : - (control & ~LIS3L02DQ_REG_CTRL_2_ENABLE_INTERRUPT); - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_2_ADDR, - control); - if (ret) - goto error_ret; - } - -error_ret: - mutex_unlock(&indio_dev->mlock); - return ret; -} - -static struct attribute *lis3l02dq_attributes[] = { - &iio_dev_attr_sampling_frequency.dev_attr.attr, - &iio_const_attr_sampling_frequency_available.dev_attr.attr, - NULL -}; - -static const struct attribute_group lis3l02dq_attribute_group = { - .attrs = lis3l02dq_attributes, -}; - -static const struct iio_info lis3l02dq_info = { - .read_raw = &lis3l02dq_read_raw, - .write_raw = &lis3l02dq_write_raw, - .read_event_value = &lis3l02dq_read_thresh, - .write_event_value = &lis3l02dq_write_thresh, - .write_event_config = &lis3l02dq_write_event_config, - .read_event_config = &lis3l02dq_read_event_config, - .driver_module = THIS_MODULE, - .attrs = &lis3l02dq_attribute_group, -}; - -static int lis3l02dq_probe(struct spi_device *spi) -{ - int ret; - struct lis3l02dq_state *st; - struct iio_dev *indio_dev; - - indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); - if (!indio_dev) - return -ENOMEM; - st = iio_priv(indio_dev); - /* this is only used for removal purposes */ - spi_set_drvdata(spi, indio_dev); - - st->us = spi; - st->gpio = of_get_gpio(spi->dev.of_node, 0); - mutex_init(&st->buf_lock); - indio_dev->name = spi->dev.driver->name; - indio_dev->dev.parent = &spi->dev; - indio_dev->info = &lis3l02dq_info; - indio_dev->channels = lis3l02dq_channels; - indio_dev->num_channels = ARRAY_SIZE(lis3l02dq_channels); - - indio_dev->modes = INDIO_DIRECT_MODE; - - ret = lis3l02dq_configure_buffer(indio_dev); - if (ret) - return ret; - - if (spi->irq) { - ret = request_threaded_irq(st->us->irq, - &lis3l02dq_th, - &lis3l02dq_event_handler, - IRQF_TRIGGER_RISING, - "lis3l02dq", - indio_dev); - if (ret) - goto error_unreg_buffer_funcs; - - ret = lis3l02dq_probe_trigger(indio_dev); - if (ret) - goto error_free_interrupt; - } - - /* Get the device into a sane initial state */ - ret = lis3l02dq_initial_setup(indio_dev); - if (ret) - goto error_remove_trigger; - - ret = iio_device_register(indio_dev); - if (ret) - goto error_remove_trigger; - - return 0; - -error_remove_trigger: - if (spi->irq) - lis3l02dq_remove_trigger(indio_dev); -error_free_interrupt: - if (spi->irq) - free_irq(st->us->irq, indio_dev); -error_unreg_buffer_funcs: - lis3l02dq_unconfigure_buffer(indio_dev); - return ret; -} - -/* Power down the device */ -static int lis3l02dq_stop_device(struct iio_dev *indio_dev) -{ - int ret; - struct lis3l02dq_state *st = iio_priv(indio_dev); - u8 val = 0; - - mutex_lock(&indio_dev->mlock); - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_1_ADDR, - val); - if (ret) { - dev_err(&st->us->dev, "problem with turning device off: ctrl1"); - goto err_ret; - } - - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_2_ADDR, - val); - if (ret) - dev_err(&st->us->dev, "problem with turning device off: ctrl2"); -err_ret: - mutex_unlock(&indio_dev->mlock); - return ret; -} - -/* fixme, confirm ordering in this function */ -static int lis3l02dq_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct lis3l02dq_state *st = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - - lis3l02dq_disable_all_events(indio_dev); - lis3l02dq_stop_device(indio_dev); - - if (spi->irq) - free_irq(st->us->irq, indio_dev); - - lis3l02dq_remove_trigger(indio_dev); - lis3l02dq_unconfigure_buffer(indio_dev); - - return 0; -} - -static struct spi_driver lis3l02dq_driver = { - .driver = { - .name = "lis3l02dq", - }, - .probe = lis3l02dq_probe, - .remove = lis3l02dq_remove, -}; -module_spi_driver(lis3l02dq_driver); - -MODULE_AUTHOR("Jonathan Cameron "); -MODULE_DESCRIPTION("ST LIS3L02DQ Accelerometer SPI driver"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("spi:lis3l02dq"); diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c deleted file mode 100644 index 50c162e..0000000 --- a/drivers/staging/iio/accel/lis3l02dq_ring.c +++ /dev/null @@ -1,428 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include "lis3l02dq.h" - -/** - * combine_8_to_16() utility function to munge two u8s into u16 - **/ -static inline u16 combine_8_to_16(u8 lower, u8 upper) -{ - u16 _lower = lower; - u16 _upper = upper; - - return _lower | (_upper << 8); -} - -/** - * lis3l02dq_data_rdy_trig_poll() the event handler for the data rdy trig - **/ -irqreturn_t lis3l02dq_data_rdy_trig_poll(int irq, void *private) -{ - struct iio_dev *indio_dev = private; - struct lis3l02dq_state *st = iio_priv(indio_dev); - - if (st->trigger_on) { - iio_trigger_poll(st->trig); - return IRQ_HANDLED; - } - - return IRQ_WAKE_THREAD; -} - -static const u8 read_all_tx_array[] = { - LIS3L02DQ_READ_REG(LIS3L02DQ_REG_OUT_X_L_ADDR), 0, - LIS3L02DQ_READ_REG(LIS3L02DQ_REG_OUT_X_H_ADDR), 0, - LIS3L02DQ_READ_REG(LIS3L02DQ_REG_OUT_Y_L_ADDR), 0, - LIS3L02DQ_READ_REG(LIS3L02DQ_REG_OUT_Y_H_ADDR), 0, - LIS3L02DQ_READ_REG(LIS3L02DQ_REG_OUT_Z_L_ADDR), 0, - LIS3L02DQ_READ_REG(LIS3L02DQ_REG_OUT_Z_H_ADDR), 0, -}; - -/** - * lis3l02dq_read_all() Reads all channels currently selected - * @indio_dev: IIO device state - * @rx_array: (dma capable) receive array, must be at least - * 4*number of channels - **/ -static int lis3l02dq_read_all(struct iio_dev *indio_dev, u8 *rx_array) -{ - struct lis3l02dq_state *st = iio_priv(indio_dev); - struct spi_transfer *xfers; - struct spi_message msg; - int ret, i, j = 0; - - xfers = kcalloc(bitmap_weight(indio_dev->active_scan_mask, - indio_dev->masklength) * 2, - sizeof(*xfers), GFP_KERNEL); - if (!xfers) - return -ENOMEM; - - mutex_lock(&st->buf_lock); - - for (i = 0; i < ARRAY_SIZE(read_all_tx_array) / 4; i++) - if (test_bit(i, indio_dev->active_scan_mask)) { - /* lower byte */ - xfers[j].tx_buf = st->tx + (2 * j); - st->tx[2 * j] = read_all_tx_array[i * 4]; - st->tx[2 * j + 1] = 0; - if (rx_array) - xfers[j].rx_buf = rx_array + (j * 2); - xfers[j].bits_per_word = 8; - xfers[j].len = 2; - xfers[j].cs_change = 1; - j++; - - /* upper byte */ - xfers[j].tx_buf = st->tx + (2 * j); - st->tx[2 * j] = read_all_tx_array[i * 4 + 2]; - st->tx[2 * j + 1] = 0; - if (rx_array) - xfers[j].rx_buf = rx_array + (j * 2); - xfers[j].bits_per_word = 8; - xfers[j].len = 2; - xfers[j].cs_change = 1; - j++; - } - - /* After these are transmitted, the rx_buff should have - * values in alternate bytes - */ - spi_message_init(&msg); - for (j = 0; j < bitmap_weight(indio_dev->active_scan_mask, - indio_dev->masklength) * 2; j++) - spi_message_add_tail(&xfers[j], &msg); - - ret = spi_sync(st->us, &msg); - mutex_unlock(&st->buf_lock); - kfree(xfers); - - return ret; -} - -static int lis3l02dq_get_buffer_element(struct iio_dev *indio_dev, - u8 *buf) -{ - int ret, i; - u8 *rx_array; - s16 *data = (s16 *)buf; - int scan_count = bitmap_weight(indio_dev->active_scan_mask, - indio_dev->masklength); - - rx_array = kcalloc(4, scan_count, GFP_KERNEL); - if (!rx_array) - return -ENOMEM; - ret = lis3l02dq_read_all(indio_dev, rx_array); - if (ret < 0) { - kfree(rx_array); - return ret; - } - for (i = 0; i < scan_count; i++) - data[i] = combine_8_to_16(rx_array[i * 4 + 1], - rx_array[i * 4 + 3]); - kfree(rx_array); - - return i * sizeof(data[0]); -} - -static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p) -{ - struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->indio_dev; - int len = 0; - char *data; - - data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); - if (!data) - goto done; - - if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) - len = lis3l02dq_get_buffer_element(indio_dev, data); - - iio_push_to_buffers_with_timestamp(indio_dev, data, pf->timestamp); - - kfree(data); -done: - iio_trigger_notify_done(indio_dev->trig); - return IRQ_HANDLED; -} - -/* Caller responsible for locking as necessary. */ -static int -__lis3l02dq_write_data_ready_config(struct iio_dev *indio_dev, bool state) -{ - int ret; - u8 valold; - bool currentlyset; - struct lis3l02dq_state *st = iio_priv(indio_dev); - - /* Get the current event mask register */ - ret = lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_2_ADDR, - &valold); - if (ret) - goto error_ret; - /* Find out if data ready is already on */ - currentlyset - = valold & LIS3L02DQ_REG_CTRL_2_ENABLE_DATA_READY_GENERATION; - - /* Disable requested */ - if (!state && currentlyset) { - /* Disable the data ready signal */ - valold &= ~LIS3L02DQ_REG_CTRL_2_ENABLE_DATA_READY_GENERATION; - - /* The double write is to overcome a hardware bug? */ - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_2_ADDR, - valold); - if (ret) - goto error_ret; - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_2_ADDR, - valold); - if (ret) - goto error_ret; - st->trigger_on = false; - /* Enable requested */ - } else if (state && !currentlyset) { - /* If not set, enable requested - * first disable all events - */ - ret = lis3l02dq_disable_all_events(indio_dev); - if (ret < 0) - goto error_ret; - - valold = ret | - LIS3L02DQ_REG_CTRL_2_ENABLE_DATA_READY_GENERATION; - - st->trigger_on = true; - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_2_ADDR, - valold); - if (ret) - goto error_ret; - } - - return 0; -error_ret: - return ret; -} - -/** - * lis3l02dq_data_rdy_trigger_set_state() set datardy interrupt state - * - * If disabling the interrupt also does a final read to ensure it is clear. - * This is only important in some cases where the scan enable elements are - * switched before the buffer is reenabled. - **/ -static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig, - bool state) -{ - struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); - int ret = 0; - u8 t; - - __lis3l02dq_write_data_ready_config(indio_dev, state); - if (!state) { - /* - * A possible quirk with the handler is currently worked around - * by ensuring outstanding read events are cleared. - */ - ret = lis3l02dq_read_all(indio_dev, NULL); - } - lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_WAKE_UP_SRC_ADDR, - &t); - return ret; -} - -/** - * lis3l02dq_trig_try_reen() try reenabling irq for data rdy trigger - * @trig: the datardy trigger - */ -static int lis3l02dq_trig_try_reen(struct iio_trigger *trig) -{ - struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); - struct lis3l02dq_state *st = iio_priv(indio_dev); - int i; - - /* If gpio still high (or high again) - * In theory possible we will need to do this several times - */ - for (i = 0; i < 5; i++) - if (gpio_get_value(st->gpio)) - lis3l02dq_read_all(indio_dev, NULL); - else - break; - if (i == 5) - pr_info("Failed to clear the interrupt for lis3l02dq\n"); - - /* irq reenabled so success! */ - return 0; -} - -static const struct iio_trigger_ops lis3l02dq_trigger_ops = { - .owner = THIS_MODULE, - .set_trigger_state = &lis3l02dq_data_rdy_trigger_set_state, - .try_reenable = &lis3l02dq_trig_try_reen, -}; - -int lis3l02dq_probe_trigger(struct iio_dev *indio_dev) -{ - int ret; - struct lis3l02dq_state *st = iio_priv(indio_dev); - - st->trig = iio_trigger_alloc("lis3l02dq-dev%d", indio_dev->id); - if (!st->trig) { - ret = -ENOMEM; - goto error_ret; - } - - st->trig->dev.parent = &st->us->dev; - st->trig->ops = &lis3l02dq_trigger_ops; - iio_trigger_set_drvdata(st->trig, indio_dev); - ret = iio_trigger_register(st->trig); - if (ret) - goto error_free_trig; - - return 0; - -error_free_trig: - iio_trigger_free(st->trig); -error_ret: - return ret; -} - -void lis3l02dq_remove_trigger(struct iio_dev *indio_dev) -{ - struct lis3l02dq_state *st = iio_priv(indio_dev); - - iio_trigger_unregister(st->trig); - iio_trigger_free(st->trig); -} - -void lis3l02dq_unconfigure_buffer(struct iio_dev *indio_dev) -{ - iio_dealloc_pollfunc(indio_dev->pollfunc); - iio_kfifo_free(indio_dev->buffer); -} - -static int lis3l02dq_buffer_postenable(struct iio_dev *indio_dev) -{ - /* Disable unwanted channels otherwise the interrupt will not clear */ - u8 t; - int ret; - bool oneenabled = false; - - ret = lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_1_ADDR, - &t); - if (ret) - goto error_ret; - - if (test_bit(0, indio_dev->active_scan_mask)) { - t |= LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE; - oneenabled = true; - } else { - t &= ~LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE; - } - if (test_bit(1, indio_dev->active_scan_mask)) { - t |= LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE; - oneenabled = true; - } else { - t &= ~LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE; - } - if (test_bit(2, indio_dev->active_scan_mask)) { - t |= LIS3L02DQ_REG_CTRL_1_AXES_Z_ENABLE; - oneenabled = true; - } else { - t &= ~LIS3L02DQ_REG_CTRL_1_AXES_Z_ENABLE; - } - if (!oneenabled) /* what happens in this case is unknown */ - return -EINVAL; - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_1_ADDR, - t); - if (ret) - goto error_ret; - - return iio_triggered_buffer_postenable(indio_dev); -error_ret: - return ret; -} - -/* Turn all channels on again */ -static int lis3l02dq_buffer_predisable(struct iio_dev *indio_dev) -{ - u8 t; - int ret; - - ret = iio_triggered_buffer_predisable(indio_dev); - if (ret) - goto error_ret; - - ret = lis3l02dq_spi_read_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_1_ADDR, - &t); - if (ret) - goto error_ret; - t |= LIS3L02DQ_REG_CTRL_1_AXES_X_ENABLE | - LIS3L02DQ_REG_CTRL_1_AXES_Y_ENABLE | - LIS3L02DQ_REG_CTRL_1_AXES_Z_ENABLE; - - ret = lis3l02dq_spi_write_reg_8(indio_dev, - LIS3L02DQ_REG_CTRL_1_ADDR, - t); - -error_ret: - return ret; -} - -static const struct iio_buffer_setup_ops lis3l02dq_buffer_setup_ops = { - .postenable = &lis3l02dq_buffer_postenable, - .predisable = &lis3l02dq_buffer_predisable, -}; - -int lis3l02dq_configure_buffer(struct iio_dev *indio_dev) -{ - int ret; - struct iio_buffer *buffer; - - buffer = iio_kfifo_allocate(); - if (!buffer) - return -ENOMEM; - - iio_device_attach_buffer(indio_dev, buffer); - - buffer->scan_timestamp = true; - indio_dev->setup_ops = &lis3l02dq_buffer_setup_ops; - - /* Functions are NULL as we set handler below */ - indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time, - &lis3l02dq_trigger_handler, - 0, - indio_dev, - "lis3l02dq_consumer%d", - indio_dev->id); - - if (!indio_dev->pollfunc) { - ret = -ENOMEM; - goto error_iio_sw_rb_free; - } - - indio_dev->modes |= INDIO_BUFFER_TRIGGERED; - return 0; - -error_iio_sw_rb_free: - iio_kfifo_free(indio_dev->buffer); - return ret; -} -- cgit v1.1 From e7385de5291e347f5bc85985acdce3a3f5096667 Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Mon, 27 Jun 2016 12:38:52 +0200 Subject: iio:st_sensors: align on storagebits boundaries Ensure triggered buffering memory accesses are properly aligned on per channel storagebits boundaries. Signed-off-by: Gregor Boirie Tested-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/common/st_sensors/st_sensors_buffer.c | 37 +++++++++++------------ drivers/iio/common/st_sensors/st_sensors_core.c | 2 +- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_buffer.c b/drivers/iio/common/st_sensors/st_sensors_buffer.c index 2371fc8..d06e728 100644 --- a/drivers/iio/common/st_sensors/st_sensors_buffer.c +++ b/drivers/iio/common/st_sensors/st_sensors_buffer.c @@ -24,30 +24,29 @@ static int st_sensors_get_buffer_element(struct iio_dev *indio_dev, u8 *buf) { - int i, len; - int total = 0; + int i; struct st_sensor_data *sdata = iio_priv(indio_dev); unsigned int num_data_channels = sdata->num_data_channels; - for (i = 0; i < num_data_channels; i++) { - unsigned int bytes_to_read; - - if (test_bit(i, indio_dev->active_scan_mask)) { - bytes_to_read = indio_dev->channels[i].scan_type.storagebits >> 3; - len = sdata->tf->read_multiple_byte(&sdata->tb, - sdata->dev, indio_dev->channels[i].address, - bytes_to_read, - buf + total, sdata->multiread_bit); - - if (len < bytes_to_read) - return -EIO; - - /* Advance the buffer pointer */ - total += len; - } + for_each_set_bit(i, indio_dev->active_scan_mask, num_data_channels) { + const struct iio_chan_spec *channel = &indio_dev->channels[i]; + unsigned int bytes_to_read = channel->scan_type.realbits >> 3; + unsigned int storage_bytes = + channel->scan_type.storagebits >> 3; + + buf = PTR_ALIGN(buf, storage_bytes); + if (sdata->tf->read_multiple_byte(&sdata->tb, sdata->dev, + channel->address, + bytes_to_read, buf, + sdata->multiread_bit) < + bytes_to_read) + return -EIO; + + /* Advance the buffer pointer */ + buf += storage_bytes; } - return total; + return 0; } irqreturn_t st_sensors_trigger_handler(int irq, void *p) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 26ce325..2d5282e 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -490,7 +490,7 @@ static int st_sensors_read_axis_data(struct iio_dev *indio_dev, int err; u8 *outdata; struct st_sensor_data *sdata = iio_priv(indio_dev); - unsigned int byte_for_channel = ch->scan_type.storagebits >> 3; + unsigned int byte_for_channel = ch->scan_type.realbits >> 3; outdata = kmalloc(byte_for_channel, GFP_KERNEL); if (!outdata) -- cgit v1.1 From c9d5e5b97e8723e20204b430edde2f3dc5f5c0cf Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Mon, 27 Jun 2016 12:38:53 +0200 Subject: iio:st_pressure: align storagebits on power of 2 Sampled pressure data are 24 bits long and should be stored in a 32 bits word. Signed-off-by: Gregor Boirie Tested-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/st_pressure_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 56d8f5e..8fa3d81 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -146,7 +146,7 @@ static const struct iio_chan_spec st_press_1_channels[] = { .scan_type = { .sign = 'u', .realbits = 24, - .storagebits = 24, + .storagebits = 32, .endianness = IIO_LE, }, .info_mask_separate = @@ -218,7 +218,7 @@ static const struct iio_chan_spec st_press_lps22hb_channels[] = { .scan_type = { .sign = 'u', .realbits = 24, - .storagebits = 24, + .storagebits = 32, .endianness = IIO_LE, }, .info_mask_separate = -- cgit v1.1 From 19b7b8a89b8d98fdafd80b61160a167deb75888d Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Mon, 27 Jun 2016 12:38:54 +0200 Subject: iio:st_pressure: document sampling gains Details scaling factors and offsets applied to raw temperature and pressure samples. Signed-off-by: Gregor Boirie Tested-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/st_pressure_core.c | 92 +++++++++++++++++++++++++++++++-- 1 file changed, 88 insertions(+), 4 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 8fa3d81..2ab1056 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -28,6 +28,72 @@ #include #include "st_pressure.h" +/* + * About determining pressure scaling factors + * ------------------------------------------ + * + * Datasheets specify typical pressure sensitivity so that pressure is computed + * according to the following equation : + * pressure[mBar] = raw / sensitivity + * where : + * raw the 24 bits long raw sampled pressure + * sensitivity a scaling factor specified by the datasheet in LSB/mBar + * + * IIO ABI expects pressure to be expressed as kPascal, hence pressure should be + * computed according to : + * pressure[kPascal] = pressure[mBar] / 10 + * = raw / (sensitivity * 10) (1) + * + * Finally, st_press_read_raw() returns pressure scaling factor as an + * IIO_VAL_INT_PLUS_NANO with a zero integral part and "gain" as decimal part. + * Therefore, from (1), "gain" becomes : + * gain = 10^9 / (sensitivity * 10) + * = 10^8 / sensitivity + * + * About determining temperature scaling factors and offsets + * --------------------------------------------------------- + * + * Datasheets specify typical temperature sensitivity and offset so that + * temperature is computed according to the following equation : + * temp[Celsius] = offset[Celsius] + (raw / sensitivity) + * where : + * raw the 16 bits long raw sampled temperature + * offset a constant specified by the datasheet in degree Celsius + * (sometimes zero) + * sensitivity a scaling factor specified by the datasheet in LSB/Celsius + * + * IIO ABI expects temperature to be expressed as milli degree Celsius such as + * user space should compute temperature according to : + * temp[mCelsius] = temp[Celsius] * 10^3 + * = (offset[Celsius] + (raw / sensitivity)) * 10^3 + * = ((offset[Celsius] * sensitivity) + raw) * + * (10^3 / sensitivity) (2) + * + * IIO ABI expects user space to apply offset and scaling factors to raw samples + * according to : + * temp[mCelsius] = (OFFSET + raw) * SCALE + * where : + * OFFSET an arbitrary constant exposed by device + * SCALE an arbitrary scaling factor exposed by device + * + * Matching OFFSET and SCALE with members of (2) gives : + * OFFSET = offset[Celsius] * sensitivity (3) + * SCALE = 10^3 / sensitivity (4) + * + * st_press_read_raw() returns temperature scaling factor as an + * IIO_VAL_FRACTIONAL with a 10^3 numerator and "gain2" as denominator. + * Therefore, from (3), "gain2" becomes : + * gain2 = sensitivity + * + * When declared within channel, i.e. for a non zero specified offset, + * st_press_read_raw() will return the latter as an IIO_VAL_FRACTIONAL such as : + * numerator = OFFSET * 10^3 + * denominator = 10^3 + * giving from (4): + * numerator = offset[Celsius] * 10^3 * sensitivity + * = offset[mCelsius] * gain2 + */ + #define MCELSIUS_PER_CELSIUS 1000 /* Default pressure sensitivity */ @@ -48,7 +114,11 @@ #define ST_PRESS_1_OUT_XL_ADDR 0x28 #define ST_TEMP_1_OUT_L_ADDR 0x2b -/* CUSTOM VALUES FOR LPS331AP SENSOR */ +/* + * CUSTOM VALUES FOR LPS331AP SENSOR + * See LPS331AP datasheet: + * http://www2.st.com/resource/en/datasheet/lps331ap.pdf + */ #define ST_PRESS_LPS331AP_WAI_EXP 0xbb #define ST_PRESS_LPS331AP_ODR_ADDR 0x20 #define ST_PRESS_LPS331AP_ODR_MASK 0x70 @@ -71,7 +141,9 @@ #define ST_PRESS_LPS331AP_OD_IRQ_MASK 0x40 #define ST_PRESS_LPS331AP_MULTIREAD_BIT true -/* CUSTOM VALUES FOR LPS001WP SENSOR */ +/* + * CUSTOM VALUES FOR THE OBSOLETE LPS001WP SENSOR + */ /* LPS001WP pressure resolution */ #define ST_PRESS_LPS001WP_LSB_PER_MBAR 16UL @@ -94,7 +166,11 @@ #define ST_PRESS_LPS001WP_OUT_L_ADDR 0x28 #define ST_TEMP_LPS001WP_OUT_L_ADDR 0x2a -/* CUSTOM VALUES FOR LPS25H SENSOR */ +/* + * CUSTOM VALUES FOR LPS25H SENSOR + * See LPS25H datasheet: + * http://www2.st.com/resource/en/datasheet/lps25h.pdf + */ #define ST_PRESS_LPS25H_WAI_EXP 0xbd #define ST_PRESS_LPS25H_ODR_ADDR 0x20 #define ST_PRESS_LPS25H_ODR_MASK 0x70 @@ -117,7 +193,11 @@ #define ST_PRESS_LPS25H_OUT_XL_ADDR 0x28 #define ST_TEMP_LPS25H_OUT_L_ADDR 0x2b -/* CUSTOM VALUES FOR LPS22HB SENSOR */ +/* + * CUSTOM VALUES FOR LPS22HB SENSOR + * See LPS22HB datasheet: + * http://www2.st.com/resource/en/datasheet/lps22hb.pdf + */ #define ST_PRESS_LPS22HB_WAI_EXP 0xb1 #define ST_PRESS_LPS22HB_ODR_ADDR 0x10 #define ST_PRESS_LPS22HB_ODR_MASK 0x70 @@ -413,6 +493,10 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { }, .fs = { .fs_avl = { + /* + * Sensitivity values as defined in table 3 of + * LPS22HB datasheet. + */ [0] = { .num = ST_PRESS_FS_AVL_1260MB, .gain = ST_PRESS_KPASCAL_NANO_SCALE, -- cgit v1.1 From b4701fd6922d9ebb4dab7cb015fa7ac8775814bd Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Mon, 27 Jun 2016 12:38:55 +0200 Subject: iio:st_pressure: temperature triggered buffering Enable support for triggered buffering of temperature samples. Signed-off-by: Gregor Boirie Tested-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/st_pressure_core.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 2ab1056..ea8241f 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -105,8 +105,6 @@ #define ST_PRESS_LSB_PER_CELSIUS 480UL #define ST_PRESS_MILLI_CELSIUS_OFFSET 42500UL -#define ST_PRESS_NUMBER_DATA_CHANNELS 1 - /* FULLSCALE */ #define ST_PRESS_FS_AVL_1100MB 1100 #define ST_PRESS_FS_AVL_1260MB 1260 @@ -222,7 +220,7 @@ static const struct iio_chan_spec st_press_1_channels[] = { .type = IIO_PRESSURE, .channel2 = IIO_NO_MOD, .address = ST_PRESS_1_OUT_XL_ADDR, - .scan_index = ST_SENSORS_SCAN_X, + .scan_index = 0, .scan_type = { .sign = 'u', .realbits = 24, @@ -237,7 +235,7 @@ static const struct iio_chan_spec st_press_1_channels[] = { .type = IIO_TEMP, .channel2 = IIO_NO_MOD, .address = ST_TEMP_1_OUT_L_ADDR, - .scan_index = -1, + .scan_index = 1, .scan_type = { .sign = 'u', .realbits = 16, @@ -250,7 +248,7 @@ static const struct iio_chan_spec st_press_1_channels[] = { BIT(IIO_CHAN_INFO_OFFSET), .modified = 0, }, - IIO_CHAN_SOFT_TIMESTAMP(1) + IIO_CHAN_SOFT_TIMESTAMP(2) }; static const struct iio_chan_spec st_press_lps001wp_channels[] = { @@ -258,7 +256,7 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = { .type = IIO_PRESSURE, .channel2 = IIO_NO_MOD, .address = ST_PRESS_LPS001WP_OUT_L_ADDR, - .scan_index = ST_SENSORS_SCAN_X, + .scan_index = 0, .scan_type = { .sign = 'u', .realbits = 16, @@ -274,7 +272,7 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = { .type = IIO_TEMP, .channel2 = IIO_NO_MOD, .address = ST_TEMP_LPS001WP_OUT_L_ADDR, - .scan_index = -1, + .scan_index = 1, .scan_type = { .sign = 'u', .realbits = 16, @@ -286,7 +284,7 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = { BIT(IIO_CHAN_INFO_SCALE), .modified = 0, }, - IIO_CHAN_SOFT_TIMESTAMP(1) + IIO_CHAN_SOFT_TIMESTAMP(2) }; static const struct iio_chan_spec st_press_lps22hb_channels[] = { @@ -642,7 +640,13 @@ int st_press_common_probe(struct iio_dev *indio_dev) if (err < 0) goto st_press_power_off; - press_data->num_data_channels = ST_PRESS_NUMBER_DATA_CHANNELS; + /* + * Skip timestamping channel while declaring available channels to + * common st_sensor layer. Look at st_sensors_get_buffer_element() to + * see how timestamps are explicitly pushed as last samples block + * element. + */ + press_data->num_data_channels = press_data->sensor_settings->num_ch - 1; press_data->multiread_bit = press_data->sensor_settings->multi_read_bit; indio_dev->channels = press_data->sensor_settings->ch; indio_dev->num_channels = press_data->sensor_settings->num_ch; -- cgit v1.1 From 05167cdce057910125c535a120d7ba0a4a3617b8 Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Mon, 27 Jun 2016 12:38:56 +0200 Subject: iio:st_pressure:lps22hb: open drain support Add support for open drain interrupt line. Signed-off-by: Gregor Boirie Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/st_pressure_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index ea8241f..70230a1 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -213,6 +213,8 @@ #define ST_PRESS_LPS22HB_DRDY_IRQ_INT2_MASK 0x08 #define ST_PRESS_LPS22HB_IHL_IRQ_ADDR 0x12 #define ST_PRESS_LPS22HB_IHL_IRQ_MASK 0x80 +#define ST_PRESS_LPS22HB_OD_IRQ_ADDR 0x12 +#define ST_PRESS_LPS22HB_OD_IRQ_MASK 0x40 #define ST_PRESS_LPS22HB_MULTIREAD_BIT true static const struct iio_chan_spec st_press_1_channels[] = { @@ -511,6 +513,9 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { .mask_int2 = ST_PRESS_LPS22HB_DRDY_IRQ_INT2_MASK, .addr_ihl = ST_PRESS_LPS22HB_IHL_IRQ_ADDR, .mask_ihl = ST_PRESS_LPS22HB_IHL_IRQ_MASK, + .addr_od = ST_PRESS_LPS22HB_OD_IRQ_ADDR, + .mask_od = ST_PRESS_LPS22HB_OD_IRQ_MASK, + .addr_stat_drdy = ST_SENSORS_DEFAULT_STAT_ADDR, }, .multi_read_bit = ST_PRESS_LPS22HB_MULTIREAD_BIT, }, -- cgit v1.1 From 85d79136d3080729b13d1dcd433727223038e830 Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Mon, 27 Jun 2016 12:38:57 +0200 Subject: iio:st_pressure:lps22hb: temperature support Implement lps22hb temperature sampling channel. Signed-off-by: Gregor Boirie Tested-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/st_pressure_core.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 70230a1..274cdec 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -196,6 +196,10 @@ * See LPS22HB datasheet: * http://www2.st.com/resource/en/datasheet/lps22hb.pdf */ + +/* LPS22HB temperature sensitivity */ +#define ST_PRESS_LPS22HB_LSB_PER_CELSIUS 100UL + #define ST_PRESS_LPS22HB_WAI_EXP 0xb1 #define ST_PRESS_LPS22HB_ODR_ADDR 0x10 #define ST_PRESS_LPS22HB_ODR_MASK 0x70 @@ -307,7 +311,22 @@ static const struct iio_chan_spec st_press_lps22hb_channels[] = { .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), .modified = 0, }, - IIO_CHAN_SOFT_TIMESTAMP(1) + { + .type = IIO_TEMP, + .address = ST_TEMP_1_OUT_L_ADDR, + .scan_index = 1, + .scan_type = { + .sign = 's', + .realbits = 16, + .storagebits = 16, + .endianness = IIO_LE, + }, + .info_mask_separate = + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), + }, + IIO_CHAN_SOFT_TIMESTAMP(2) }; static const struct st_sensor_settings st_press_sensors_settings[] = { @@ -494,12 +513,13 @@ static const struct st_sensor_settings st_press_sensors_settings[] = { .fs = { .fs_avl = { /* - * Sensitivity values as defined in table 3 of - * LPS22HB datasheet. + * Pressure and temperature sensitivity values + * as defined in table 3 of LPS22HB datasheet. */ [0] = { .num = ST_PRESS_FS_AVL_1260MB, .gain = ST_PRESS_KPASCAL_NANO_SCALE, + .gain2 = ST_PRESS_LPS22HB_LSB_PER_CELSIUS, }, }, }, -- cgit v1.1 From 060a518eda493aa680a64a1a12089b850f8f9f5c Mon Sep 17 00:00:00 2001 From: Gregor Boirie Date: Mon, 27 Jun 2016 12:38:58 +0200 Subject: iio:st_pressure: clean useless static channel initializers Some static channels are explicitly initialized with default values. Remove them to enhance readability. Signed-off-by: Gregor Boirie Tested-by: Linus Walleij Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/st_pressure_core.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 274cdec..55df9a7 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -224,7 +224,6 @@ static const struct iio_chan_spec st_press_1_channels[] = { { .type = IIO_PRESSURE, - .channel2 = IIO_NO_MOD, .address = ST_PRESS_1_OUT_XL_ADDR, .scan_index = 0, .scan_type = { @@ -235,11 +234,9 @@ static const struct iio_chan_spec st_press_1_channels[] = { }, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), - .modified = 0, }, { .type = IIO_TEMP, - .channel2 = IIO_NO_MOD, .address = ST_TEMP_1_OUT_L_ADDR, .scan_index = 1, .scan_type = { @@ -252,7 +249,6 @@ static const struct iio_chan_spec st_press_1_channels[] = { BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_OFFSET), - .modified = 0, }, IIO_CHAN_SOFT_TIMESTAMP(2) }; @@ -260,7 +256,6 @@ static const struct iio_chan_spec st_press_1_channels[] = { static const struct iio_chan_spec st_press_lps001wp_channels[] = { { .type = IIO_PRESSURE, - .channel2 = IIO_NO_MOD, .address = ST_PRESS_LPS001WP_OUT_L_ADDR, .scan_index = 0, .scan_type = { @@ -272,11 +267,9 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = { .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), - .modified = 0, }, { .type = IIO_TEMP, - .channel2 = IIO_NO_MOD, .address = ST_TEMP_LPS001WP_OUT_L_ADDR, .scan_index = 1, .scan_type = { @@ -288,7 +281,6 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = { .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), - .modified = 0, }, IIO_CHAN_SOFT_TIMESTAMP(2) }; @@ -296,7 +288,6 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = { static const struct iio_chan_spec st_press_lps22hb_channels[] = { { .type = IIO_PRESSURE, - .channel2 = IIO_NO_MOD, .address = ST_PRESS_1_OUT_XL_ADDR, .scan_index = 0, .scan_type = { @@ -309,7 +300,6 @@ static const struct iio_chan_spec st_press_lps22hb_channels[] = { BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), - .modified = 0, }, { .type = IIO_TEMP, -- cgit v1.1 From 21d41655f5dde155caa2e5c004ac45bb76291449 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 3 Jul 2016 10:18:03 +0100 Subject: iio: Add iio.git tree to MAINTAINERS The tree has been in the same location for a long time. Putting it in MAINTAINERS makes it easy for those new to, or less familiar with IIO to find the correct tree to base patches on. Mostly basing on staging-next is fine as well unless working on a very active driver. Signed-off-by: Jonathan Cameron --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index c1e4bf3..345e757 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5785,6 +5785,7 @@ R: Hartmut Knaack R: Lars-Peter Clausen R: Peter Meerwald-Stadler L: linux-iio@vger.kernel.org +T: git git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git S: Maintained F: Documentation/devicetree/bindings/iio/ F: drivers/iio/ -- cgit v1.1 From 1a965d405fc6f6b1e3454baad7001fed91c9c458 Mon Sep 17 00:00:00 2001 From: Bijosh Thykkoottathil Date: Mon, 4 Jul 2016 10:08:53 +0000 Subject: drivers:iio:accel:mma8452: added cleanup provision in case of failure. mma8452_set_freefall_mode can return -ve value in case if i2c_smbus_read_byte_data fails. This function is called from mma8452_probe, and returning -ve value from probe indicates probe failure. Need to call iio_triggered_buffer_cleanup & iio_trigger_cleanup in this case. Signed-off-by: Bijosh Thykkoottathil Acked-by: Martin Kepplinger Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index c0df283..9ba2f7f 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -1579,8 +1579,8 @@ static int mma8452_probe(struct i2c_client *client, goto buffer_cleanup; ret = mma8452_set_freefall_mode(data, false); - if (ret) - return ret; + if (ret < 0) + goto buffer_cleanup; return 0; -- cgit v1.1 From 0ddfd857130d16b1fb1e45c5ab2321a65738d70b Mon Sep 17 00:00:00 2001 From: Bijosh Thykkoottathil Date: Mon, 4 Jul 2016 11:15:08 +0000 Subject: drivers:iio:accel:mma8452: removed unwanted return statements Removed unwanted return statements from the function mma8452_set_freefall_mode. Signed-off-by: Bijosh Thykkoottathil Acked-by: Martin Kepplinger Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 9ba2f7f..d41e1b5 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -634,11 +634,7 @@ static int mma8452_set_freefall_mode(struct mma8452_data *data, bool state) val |= MMA8452_FF_MT_CFG_OAE; } - val = mma8452_change_config(data, chip->ev_cfg, val); - if (val) - return val; - - return 0; + return mma8452_change_config(data, chip->ev_cfg, val); } static int mma8452_set_hp_filter_frequency(struct mma8452_data *data, -- cgit v1.1