Re: [PATCH] Staging iio/adc: fixes parenthesis alignment
On Tue, 2018-10-16 at 13:01 -0300, Marcelo Schmitt wrote: > Fixes close parenthesis alignment to match open parenthesis at > iio/drivers/staging/iio/adc/ad7606.c line 379. > > Signed-of-by: Marcelo Schmitt Hi Marcelo, Some suggestions from my side 1) Your subject line should look like "Staging: iio: adc:" instead of "Staging iio/adc:" This is the pattern that everyone in the Linux Kernel community has to follow for having consistency around. 2) Your subject line and commit message should be in the imperative form. For example :- Staging: iio: adc: Match alignment with open parenthesis Similar should be the case for commit message. 3) Try to avoid the word 'fix' as it becomes an easy way for people to avoid explanation for the patch. Try giving more information about what you are doing and why are you doing that. You can have a look here https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/comm it/?id=efd44cf468fe7e7ff9150dc52879426e0d0801eb Bdw, good try if it's your first patch :) Thanks > --- > drivers/staging/iio/adc/ad7606.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/iio/adc/ad7606.c > b/drivers/staging/iio/adc/ad7606.c > index 0b728b6ea135..230faae38c12 100644 > --- a/drivers/staging/iio/adc/ad7606.c > +++ b/drivers/staging/iio/adc/ad7606.c > @@ -376,7 +376,7 @@ static int ad7606_request_gpios(struct > ad7606_state *st) > return 0; > > st->gpio_os = devm_gpiod_get_array_optional(dev, > "oversampling-ratio", > - GPIOD_OUT_LOW); > + GPIOD_OUT_LOW); > return PTR_ERR_OR_ZERO(st->gpio_os); > } > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: iio: adt7316: Switch to the gpio descriptor interface
On Mon, 2018-10-22 at 22:44 +0530, Nishad Kamdar wrote: > Use the gpiod interface instead of the deprecated old non-descriptor > interface for ldac_pin. > > Signed-off-by: Nishad Kamdar > --- Hi Nishad, I have been working on implementing device tree bindings for this driver and removing platform data from it. I've sent a series of patches for it to Jonathan. I didn't send it on the mailing list as I wanted to confirm from Jonathan if we wants something more to be done in the series. That series also includes the change which you are proposing here. I am really sorry that you didn't know about this. If you are planning to send any other patches for this driver then let me know before you start implementing it so that we can co-ordinate before doing any work. Thanks > drivers/staging/iio/addac/adt7316.c | 17 - > 1 file changed, 12 insertions(+), 5 deletions(-) > > diff --git a/drivers/staging/iio/addac/adt7316.c > b/drivers/staging/iio/addac/adt7316.c > index 3f22d1088713..94f945ba0097 100644 > --- a/drivers/staging/iio/addac/adt7316.c > +++ b/drivers/staging/iio/addac/adt7316.c > @@ -8,7 +8,7 @@ > */ > > #include > -#include > +#include > #include > #include > #include > @@ -177,7 +177,7 @@ > > struct adt7316_chip_info { > struct adt7316_bus bus; > - u16 ldac_pin; > + struct gpio_desc*ldac_pin; > u16 int_mask; /* 0x2f */ > u8 config1; > u8 config2; > @@ -950,8 +950,8 @@ static ssize_t adt7316_store_update_DAC(struct > device *dev, > if (ret) > return -EIO; > } else { > - gpio_set_value(chip->ldac_pin, 0); > - gpio_set_value(chip->ldac_pin, 1); > + gpiod_set_value(chip->ldac_pin, 0); > + gpiod_set_value(chip->ldac_pin, 1); > } > > return len; > @@ -2120,7 +2120,14 @@ int adt7316_probe(struct device *dev, struct > adt7316_bus *bus, > else > return -ENODEV; > > - chip->ldac_pin = adt7316_platform_data[1]; > + chip->ldac_pin = devm_gpiod_get(dev, "ldac", > GPIOD_OUT_HIGH); > + if (IS_ERR(chip->ldac_pin)) { > + ret = PTR_ERR(chip->ldac_pin); > + dev_err(dev, "Failed to request ldac GPIO: %d\n", > + ret); > + return ret; > + } > + > if (chip->ldac_pin) { > chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA; > if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/7] Remove platform data and introduce DT bindings
This patchset introduces device tree bindings for adt7316 driver and removes the usage of platform data from it. Also, it sets the data field to it's appropriate value in the i2c read function which was nowhere being set before. Shreeya Patel (7): Staging: iio: adt7316: Set the data field Staging: iio: adt7316: Add an extra check for 'ret' equals to 0 Staging: iio: adt7316: Add of_device_id table Staging: iio: adt7316: Use device tree data to set ldac_pin Staging: iio: adt7316: Switch irq_flags to a local variable Staging: iio: adt7316: Change the name from irq_flags to irq_type Staging: iio: adt7316: Use device tree data to assign irq_type drivers/staging/iio/addac/adt7316-i2c.c | 19 +++- drivers/staging/iio/addac/adt7316-spi.c | 1 - drivers/staging/iio/addac/adt7316.c | 39 ++--- drivers/staging/iio/addac/adt7316.h | 1 - 4 files changed, 47 insertions(+), 13 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/7] Staging: iio: adt7316: Set the data field
adt7316_i2c_read function nowhere sets the data field. It is necessary to have an appropriate value for it. Hence, assign the value stored in 'ret' variable to data field. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index f66dd3ebbab1..856bcfa60c6c 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -35,6 +35,8 @@ static int adt7316_i2c_read(void *client, u8 reg, u8 *data) return ret; } + *data = ret; + return 0; } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/7] Staging: iio: adt7316: Add an extra check for 'ret' equals to 0
ret = 0 indicates a case of no error but no data read from the bus which is an invalid case. This case doesn't ever happen in reality. It should perhaps be handled for correctness though. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 856bcfa60c6c..473e5e34ec00 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -30,6 +30,10 @@ static int adt7316_i2c_read(void *client, u8 reg, u8 *data) } ret = i2c_smbus_read_byte(client); + + if (!ret) + return -EIO; + if (ret < 0) { dev_err(&cl->dev, "I2C read error\n"); return ret; -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/7] Staging: iio: adt7316: Add of_device_id table
When the kernel starts up, it kicks off compiled-in drivers that match “compatible” entries it finds in the device tree. At a later stage (when /lib/modules is available), all kernel modules that match “compatible” entries in the device tree are loaded. Hence to be able to use device tree for ADT7316, add of_device_id table which specifies the supported devices through compatible property. Note that there is a fall back path in i2c that will result in i2c_device_id table being used if there is no of_devcie_id table. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 473e5e34ec00..d4b5060c18ee 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -126,6 +126,18 @@ static const struct i2c_device_id adt7316_i2c_id[] = { MODULE_DEVICE_TABLE(i2c, adt7316_i2c_id); +static const struct of_device_id adt7316_of_match[] = { + { .compatible = "adi,adt7316" }, + { .compatible = "adi,adt7317" }, + { .compatible = "adi,adt7318" }, + { .compatible = "adi,adt7516" }, + { .compatible = "adi,adt7517" }, + { .compatible = "adi,adt7519" }, + { }, +}; + +MODULE_DEVICE_TABLE(of, adt7316_of_match); + static struct i2c_driver adt7316_driver = { .driver = { .name = "adt7316", -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/7] Staging: iio: adt7316: Use device tree data to set ldac_pin
Make the driver use device tree instead of the platform data. Hence, use devm_gpiod_get_optional function to get the data from device tree for ldac-pin and accordingly make the needed changes in the driver. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 3f22d1088713..deb2f7b40f60 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -177,7 +177,7 @@ struct adt7316_chip_info { struct adt7316_bus bus; - u16 ldac_pin; + struct gpio_desc*ldac_pin; u16 int_mask; /* 0x2f */ u8 config1; u8 config2; @@ -950,8 +950,8 @@ static ssize_t adt7316_store_update_DAC(struct device *dev, if (ret) return -EIO; } else { - gpio_set_value(chip->ldac_pin, 0); - gpio_set_value(chip->ldac_pin, 1); + gpiod_set_value(chip->ldac_pin, 0); + gpiod_set_value(chip->ldac_pin, 1); } return len; @@ -2120,7 +2120,13 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, else return -ENODEV; - chip->ldac_pin = adt7316_platform_data[1]; + chip->ldac_pin = devm_gpiod_get_optional(dev, "ldac", GPIOD_OUT_LOW); + if (IS_ERR(chip->ldac_pin)) { + ret = PTR_ERR(chip->ldac_pin); + dev_err(dev, "Failed to request ldac GPIO: %d\n", ret); + return ret; + } + if (chip->ldac_pin) { chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA; if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 5/7] Staging: iio: adt7316: Switch irq_flags to a local variable
There is no need to store irq_flags into the structure as it is always set to the same thing. Hence switch irq_flags to a local variable. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 1 - drivers/staging/iio/addac/adt7316-spi.c | 1 - drivers/staging/iio/addac/adt7316.c | 8 drivers/staging/iio/addac/adt7316.h | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index d4b5060c18ee..91d6cdcb747e 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -104,7 +104,6 @@ static int adt7316_i2c_probe(struct i2c_client *client, struct adt7316_bus bus = { .client = client, .irq = client->irq, - .irq_flags = IRQF_TRIGGER_LOW, .read = adt7316_i2c_read, .write = adt7316_i2c_write, .multi_read = adt7316_i2c_multi_read, diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 5cd22743e140..e75827e326a6 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -94,7 +94,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) struct adt7316_bus bus = { .client = spi_dev, .irq = spi_dev->irq, - .irq_flags = IRQF_TRIGGER_LOW, .read = adt7316_spi_read, .write = adt7316_spi_write, .multi_read = adt7316_spi_multi_read, diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index deb2f7b40f60..dfae22619287 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2102,6 +2102,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, struct adt7316_chip_info *chip; struct iio_dev *indio_dev; unsigned short *adt7316_platform_data = dev->platform_data; + int irq_flags = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,19 +2147,18 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, if (chip->bus.irq > 0) { if (adt7316_platform_data[0]) - chip->bus.irq_flags = adt7316_platform_data[0]; + irq_flags = adt7316_platform_data[0]; ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, adt7316_event_handler, - chip->bus.irq_flags | - IRQF_ONESHOT, + irq_flags | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) return ret; - if (chip->bus.irq_flags & IRQF_TRIGGER_HIGH) + if (irq_flags & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; } diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index ec40fbb698a6..fd7c5c92b599 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -17,7 +17,6 @@ struct adt7316_bus { void *client; int irq; - int irq_flags; int (*read)(void *client, u8 reg, u8 *data); int (*write)(void *client, u8 reg, u8 val); int (*multi_read)(void *client, u8 first_reg, u8 count, u8 *data); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 6/7] Staging: iio: adt7316: Change the name from irq_flags to irq_type
Most of the drivers in IIO uses irq_type as the name for storing the interrupt type and hence change the name from irq_flags to irq_type for maintaining the consistency. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index dfae22619287..9c72538baf9e 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2102,7 +2102,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, struct adt7316_chip_info *chip; struct iio_dev *indio_dev; unsigned short *adt7316_platform_data = dev->platform_data; - int irq_flags = IRQF_TRIGGER_LOW; + int irq_type = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2147,18 +2147,18 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, if (chip->bus.irq > 0) { if (adt7316_platform_data[0]) - irq_flags = adt7316_platform_data[0]; + irq_type = adt7316_platform_data[0]; ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, adt7316_event_handler, - irq_flags | IRQF_ONESHOT, + irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) return ret; - if (irq_flags & IRQF_TRIGGER_HIGH) + if (irq_type & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 7/7] Staging: iio: adt7316: Use device tree data to assign irq_type
ADT7316 driver no more uses platform data and hence use device tree data instead of platform data for assigning irq_type field. Switch case figures out the type of irq and if it's the default case then assign the default value to the irq_type i.e. irq_type = IRQF_TRIGGER_LOW Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 21 + 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 9c72538baf9e..c647875a64f5 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2101,8 +2101,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; - unsigned short *adt7316_platform_data = dev->platform_data; - int irq_type = IRQF_TRIGGER_LOW; + int irq_type; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,8 +2145,22 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->modes = INDIO_DIRECT_MODE; if (chip->bus.irq > 0) { - if (adt7316_platform_data[0]) - irq_type = adt7316_platform_data[0]; + irq_type = + irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); + + switch (irq_type) { + case IRQF_TRIGGER_HIGH: + case IRQF_TRIGGER_RISING: + break; + case IRQF_TRIGGER_LOW: + case IRQF_TRIGGER_FALLING: + break; + default: + dev_info(dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", +irq_type); + irq_type = IRQF_TRIGGER_LOW; + break; + } ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 0/5] Remove platform data and introduce DT bindings
This patchset introduces device tree bindings for adt7316 driver and removes the usage of platform data from it. Also, it sets the data field to it's appropriate value in the i2c read function which was nowhere being set before. Changes in v2: - Make the commit message of patch *[1/5] appropriate. Shreeya Patel (5): Staging: iio: adt7316: Add of_device_id table Staging: iio: adt7316: Use device tree data to set ldac_pin Staging: iio: adt7316: Switch irq_flags to a local variable Staging: iio: adt7316: Change the name from irq_flags to irq_type Staging: iio: adt7316: Use device tree data to assign irq_type drivers/staging/iio/addac/adt7316-i2c.c | 14 - drivers/staging/iio/addac/adt7316-spi.c | 1 - drivers/staging/iio/addac/adt7316.c | 39 ++--- drivers/staging/iio/addac/adt7316.h | 1 - 4 files changed, 42 insertions(+), 13 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 1/5] Staging: iio: adt7316: Add of_device_id table
When the kernel starts up, it kicks off compiled-in drivers that match “compatible” entries it finds in the device tree. At a later stage (when /lib/modules is available), all kernel modules that match “compatible” entries in the device tree are loaded. But if there is no dt table then there should be a fall back path with which desired kernel modules can be loaded. Hence, add of_device_id table in the i2c driver to be able to use when there is no dt table. Signed-off-by: Shreeya Patel --- Changes in v2: - Make the commit message appropriate and assign of_match_table in the driver structure. drivers/staging/iio/addac/adt7316-i2c.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 473e5e34ec00..41bc4ca008bc 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -126,9 +126,22 @@ static const struct i2c_device_id adt7316_i2c_id[] = { MODULE_DEVICE_TABLE(i2c, adt7316_i2c_id); +static const struct of_device_id adt7316_of_match[] = { + { .compatible = "adi,adt7316" }, + { .compatible = "adi,adt7317" }, + { .compatible = "adi,adt7318" }, + { .compatible = "adi,adt7516" }, + { .compatible = "adi,adt7517" }, + { .compatible = "adi,adt7519" }, + { }, +}; + +MODULE_DEVICE_TABLE(of, adt7316_of_match); + static struct i2c_driver adt7316_driver = { .driver = { .name = "adt7316", + .of_match_table = adt7316_of_match, .pm = ADT7316_PM_OPS, }, .probe = adt7316_i2c_probe, -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/5] Staging: iio: adt7316: Use device tree data to set ldac_pin
Make the driver use device tree instead of the platform data. Hence, use devm_gpiod_get_optional function to get the data from device tree for ldac-pin and accordingly make the needed changes in the driver. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 3f22d1088713..deb2f7b40f60 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -177,7 +177,7 @@ struct adt7316_chip_info { struct adt7316_bus bus; - u16 ldac_pin; + struct gpio_desc*ldac_pin; u16 int_mask; /* 0x2f */ u8 config1; u8 config2; @@ -950,8 +950,8 @@ static ssize_t adt7316_store_update_DAC(struct device *dev, if (ret) return -EIO; } else { - gpio_set_value(chip->ldac_pin, 0); - gpio_set_value(chip->ldac_pin, 1); + gpiod_set_value(chip->ldac_pin, 0); + gpiod_set_value(chip->ldac_pin, 1); } return len; @@ -2120,7 +2120,13 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, else return -ENODEV; - chip->ldac_pin = adt7316_platform_data[1]; + chip->ldac_pin = devm_gpiod_get_optional(dev, "ldac", GPIOD_OUT_LOW); + if (IS_ERR(chip->ldac_pin)) { + ret = PTR_ERR(chip->ldac_pin); + dev_err(dev, "Failed to request ldac GPIO: %d\n", ret); + return ret; + } + if (chip->ldac_pin) { chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA; if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 3/5] Staging: iio: adt7316: Switch irq_flags to a local variable
There is no need to store irq_flags into the structure as it is always set to the same thing. Hence switch irq_flags to a local variable. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 1 - drivers/staging/iio/addac/adt7316-spi.c | 1 - drivers/staging/iio/addac/adt7316.c | 8 drivers/staging/iio/addac/adt7316.h | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 41bc4ca008bc..ac91163656b5 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -104,7 +104,6 @@ static int adt7316_i2c_probe(struct i2c_client *client, struct adt7316_bus bus = { .client = client, .irq = client->irq, - .irq_flags = IRQF_TRIGGER_LOW, .read = adt7316_i2c_read, .write = adt7316_i2c_write, .multi_read = adt7316_i2c_multi_read, diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 5cd22743e140..e75827e326a6 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -94,7 +94,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) struct adt7316_bus bus = { .client = spi_dev, .irq = spi_dev->irq, - .irq_flags = IRQF_TRIGGER_LOW, .read = adt7316_spi_read, .write = adt7316_spi_write, .multi_read = adt7316_spi_multi_read, diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index deb2f7b40f60..dfae22619287 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2102,6 +2102,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, struct adt7316_chip_info *chip; struct iio_dev *indio_dev; unsigned short *adt7316_platform_data = dev->platform_data; + int irq_flags = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,19 +2147,18 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, if (chip->bus.irq > 0) { if (adt7316_platform_data[0]) - chip->bus.irq_flags = adt7316_platform_data[0]; + irq_flags = adt7316_platform_data[0]; ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, adt7316_event_handler, - chip->bus.irq_flags | - IRQF_ONESHOT, + irq_flags | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) return ret; - if (chip->bus.irq_flags & IRQF_TRIGGER_HIGH) + if (irq_flags & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; } diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index ec40fbb698a6..fd7c5c92b599 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -17,7 +17,6 @@ struct adt7316_bus { void *client; int irq; - int irq_flags; int (*read)(void *client, u8 reg, u8 *data); int (*write)(void *client, u8 reg, u8 val); int (*multi_read)(void *client, u8 first_reg, u8 count, u8 *data); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 4/5] Staging: iio: adt7316: Change the name from irq_flags to irq_type
Most of the drivers in IIO uses irq_type as the name for storing the interrupt type and hence change the name from irq_flags to irq_type for maintaining the consistency. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index dfae22619287..9c72538baf9e 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2102,7 +2102,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, struct adt7316_chip_info *chip; struct iio_dev *indio_dev; unsigned short *adt7316_platform_data = dev->platform_data; - int irq_flags = IRQF_TRIGGER_LOW; + int irq_type = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2147,18 +2147,18 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, if (chip->bus.irq > 0) { if (adt7316_platform_data[0]) - irq_flags = adt7316_platform_data[0]; + irq_type = adt7316_platform_data[0]; ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, adt7316_event_handler, - irq_flags | IRQF_ONESHOT, + irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) return ret; - if (irq_flags & IRQF_TRIGGER_HIGH) + if (irq_type & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 5/5] Staging: iio: adt7316: Use device tree data to assign irq_type
ADT7316 driver no more uses platform data and hence use device tree data instead of platform data for assigning irq_type field. Switch case figures out the type of irq and if it's the default case then assign the default value to the irq_type i.e. irq_type = IRQF_TRIGGER_LOW Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 21 + 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 9c72538baf9e..c647875a64f5 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2101,8 +2101,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; - unsigned short *adt7316_platform_data = dev->platform_data; - int irq_type = IRQF_TRIGGER_LOW; + int irq_type; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,8 +2145,22 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->modes = INDIO_DIRECT_MODE; if (chip->bus.irq > 0) { - if (adt7316_platform_data[0]) - irq_type = adt7316_platform_data[0]; + irq_type = + irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); + + switch (irq_type) { + case IRQF_TRIGGER_HIGH: + case IRQF_TRIGGER_RISING: + break; + case IRQF_TRIGGER_LOW: + case IRQF_TRIGGER_FALLING: + break; + default: + dev_info(dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", +irq_type); + irq_type = IRQF_TRIGGER_LOW; + break; + } ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2 5/5] Staging: iio: adt7316: Use device tree data to assign irq_type
On Wed, 2018-11-21 at 08:21 +, Ardelean, Alexandru wrote: > On Tue, 2018-11-20 at 22:30 +0530, Shreeya Patel wrote: > > ADT7316 driver no more uses platform data and hence use device tree > > data instead of platform data for assigning irq_type field. > > Switch case figures out the type of irq and if it's the default > > case > > then assign the default value to the irq_type i.e. > > irq_type = IRQF_TRIGGER_LOW > > > > 1 comment inline > > > Signed-off-by: Shreeya Patel > > --- > > drivers/staging/iio/addac/adt7316.c | 21 + > > 1 file changed, 17 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/staging/iio/addac/adt7316.c > > b/drivers/staging/iio/addac/adt7316.c > > index 9c72538baf9e..c647875a64f5 100644 > > --- a/drivers/staging/iio/addac/adt7316.c > > +++ b/drivers/staging/iio/addac/adt7316.c > > @@ -2101,8 +2101,7 @@ int adt7316_probe(struct device *dev, struct > > adt7316_bus *bus, > > { > > struct adt7316_chip_info *chip; > > struct iio_dev *indio_dev; > > - unsigned short *adt7316_platform_data = dev- > > >platform_data; > > - int irq_type = IRQF_TRIGGER_LOW; > > + int irq_type; > > int ret = 0; > > > > indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); > > @@ -2146,8 +2145,22 @@ int adt7316_probe(struct device *dev, struct > > adt7316_bus *bus, > > indio_dev->modes = INDIO_DIRECT_MODE; > > > > if (chip->bus.irq > 0) { > > - if (adt7316_platform_data[0]) > > - irq_type = adt7316_platform_data[0]; > > + irq_type = > > + irqd_get_trigger_type(irq_get_irq_data(chi > > p- > > > bus.irq)); > > > > + > > + switch (irq_type) { > > + case IRQF_TRIGGER_HIGH: > > + case IRQF_TRIGGER_RISING: > > + break; > > + case IRQF_TRIGGER_LOW: > > + case IRQF_TRIGGER_FALLING: > > + break; > > + default: > > + dev_info(dev, "mode %d unsupported, using > > IRQF_TRIGGER_LOW\n", > > +irq_type); > > + irq_type = IRQF_TRIGGER_LOW; > > + break; > > + } > > It would be an idea to move this part [together with > devm_request_threaded_irq()] into a "adt7316_setup_irq()" function. > To un- > clutter the code in the adt7316_probe() function. > Yes, seems like a good idea! Even other drivers are doing the same as you told me to do...thanks :) I'll do the change after Jonathan picks up the other patches and will wait for some other reviews to come up if there are any. Thanks > > > > ret = devm_request_threaded_irq(dev, chip- > > >bus.irq, > > NULL, ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Revert "Staging: iio: adt7316: Add an extra check for 'ret' equals to 0"
On Tue, 2018-12-04 at 18:49 -0700, Jeremy Fertic wrote: > This reverts commit 00426e99789357dbff7e719a092ce36a3ce49d94. > > i2c_smbus_read_byte() returns 0 when a byte with the value 0 is read > from > the device. This is a valid read so revert the check for 0. > > Signed-off-by: Jeremy Fertic > --- Hi Jeremy, As per my understanding, 0 value indicates no error but no data read. Then how can this be a valid case? Can you please make me understand that how can we consider this as a valid case even when no data has been read? Thanks > drivers/staging/iio/addac/adt7316-i2c.c | 4 > 1 file changed, 4 deletions(-) > > diff --git a/drivers/staging/iio/addac/adt7316-i2c.c > b/drivers/staging/iio/addac/adt7316-i2c.c > index ac91163656b5..2d51bd425662 100644 > --- a/drivers/staging/iio/addac/adt7316-i2c.c > +++ b/drivers/staging/iio/addac/adt7316-i2c.c > @@ -30,10 +30,6 @@ static int adt7316_i2c_read(void *client, u8 reg, > u8 *data) > } > > ret = i2c_smbus_read_byte(client); > - > - if (!ret) > - return -EIO; > - > if (ret < 0) { > dev_err(&cl->dev, "I2C read error\n"); > return ret; ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Revert "Staging: iio: adt7316: Add an extra check for 'ret' equals to 0"
On Thu, 2018-12-06 at 15:40 +0300, Dan Carpenter wrote: > On Wed, Dec 05, 2018 at 02:59:53PM -0700, Jeremy Fertic wrote: > > On Thu, Dec 06, 2018 at 01:25:55AM +0530, Shreeya Patel wrote: > > > On Tue, 2018-12-04 at 18:49 -0700, Jeremy Fertic wrote: > > > > This reverts commit 00426e99789357dbff7e719a092ce36a3ce49d94. > > > > > > > > i2c_smbus_read_byte() returns 0 when a byte with the value 0 is > > > > read > > > > from > > > > the device. This is a valid read so revert the check for 0. > > > > > > > > Signed-off-by: Jeremy Fertic > > > > --- > > > > > > Hi Jeremy, > > > > > > As per my understanding, 0 value indicates no error but no data > > > read. > > > Then how can this be a valid case? > > > > > > Can you please make me understand that how can we consider this > > > as a > > > valid case even when no data has been read? > > It's not reading no data. It's reading one byte of data and > returning > it. > > > > > > > > > > Thanks > > > > I'm not sure I understand why the value 0 would indicate no data > > read. > > Doesn't that just mean a byte was read with the value 0. > > Yes. It does mean that. Please don't ask rhetorical > questions... :( > This list is full of people who can't resist answering every > question. > > > For instance, if the input to the adc is 0V. Can you point me to > > where > > you're seeing that this would indicate no data read? > > drivers/i2c/i2c-core-smbus.c > 88 /** > 89 * i2c_smbus_read_byte - SMBus "receive byte" protocol > 90 * @client: Handle to slave device > 91 * > 92 * This executes the SMBus "receive byte" protocol, returning > negative errno > 93 * else the byte received from the device. > 94 */ > 95 s32 i2c_smbus_read_byte(const struct i2c_client *client) > 96 { > 97 union i2c_smbus_data data; > 98 int status; > 99 >100 status = i2c_smbus_xfer(client->adapter, client- > >addr, client->flags, >101 I2C_SMBUS_READ, 0, >102 I2C_SMBUS_BYTE, &data); >103 return (status < 0) ? status : data.byte; > ^ >104 } >105 EXPORT_SYMBOL(i2c_smbus_read_byte); Even I had sent the same code to Jonathan and we had a discussion on this. I asked him that this code clearly shows that there is an error condition only when status < 0 then why do we need a check for status = 0. Then he explained me that 0 isn't an error. The issue is the silliness of the i2c interface. Pretty much every other bus returns an error (negative) if less data is received than expected. Most i2c bus master's do as well but in theory it can return 0 to indicate no error but no data read (which doesn't make any sense) 0 doesn't ever happen in reality but it should be handled for correctness though. So we should wait for what Jonathan has to say on this :) Thanks > You are right. Commit 00426e997893 ("Staging: iio: adt7316: Add an > extra check for 'ret' equals to 0") needs to be reverted... > > regards, > dan carpenter > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 3/3] Staging: iio: adt7316: Add a dev_err() message
Add a dev_err() message "failed to request irq" for describing what went wrong when an error contition is statisfied. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 97dd48153293..e3eb8ad06403 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1832,8 +1832,11 @@ static int adt7316_setup_irq(struct iio_dev *indio_dev) NULL, adt7316_event_handler, irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); - if (ret) + if (ret) { + dev_err(&indio_dev->dev, "failed to request irq %d\n", + chip->bus.irq); return ret; + } if (irq_type & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 2/3] Staging: iio: adt7316: Move interrupt related code
There is a function adt7316_irq_setup() where irq_type is being set. It would be good to move devm_request_threaded_irq() function and assignment of chip->config1 in adt7316_irq_setup() to unclutter the code in probe function. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 34 ++--- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 86b2c3d53588..97dd48153293 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1807,11 +1807,12 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) return IRQ_HANDLED; } -static int adt7316_setup_irq(struct device *dev, int irq) +static int adt7316_setup_irq(struct iio_dev *indio_dev) { - int irq_type; + struct adt7316_chip_info *chip = iio_priv(indio_dev); + int irq_type, ret; - irq_type = irqd_get_trigger_type(irq_get_irq_data(irq)); + irq_type = irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); switch (irq_type) { case IRQF_TRIGGER_HIGH: @@ -1821,13 +1822,23 @@ static int adt7316_setup_irq(struct device *dev, int irq) case IRQF_TRIGGER_FALLING: break; default: - dev_info(dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", + dev_info(&indio_dev->dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", irq_type); irq_type = IRQF_TRIGGER_LOW; break; } - return irq_type; + ret = devm_request_threaded_irq(&indio_dev->dev, chip->bus.irq, + NULL, adt7316_event_handler, + irq_type | IRQF_ONESHOT, + indio_dev->name, indio_dev); + if (ret) + return ret; + + if (irq_type & IRQF_TRIGGER_HIGH) + chip->config1 |= ADT7316_INT_POLARITY; + + return ret; } /* @@ -2124,7 +2135,6 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; - int irq_type; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2168,19 +2178,9 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->modes = INDIO_DIRECT_MODE; if (chip->bus.irq > 0) { - irq_type = adt7316_setup_irq(dev, chip->bus.irq); - - ret = devm_request_threaded_irq(dev, chip->bus.irq, - NULL, - adt7316_event_handler, - irq_type | IRQF_ONESHOT, - indio_dev->name, - indio_dev); + ret = adt7316_setup_irq(indio_dev); if (ret) return ret; - - if (irq_type & IRQF_TRIGGER_HIGH) - chip->config1 |= ADT7316_INT_POLARITY; } ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG1, chip->config1); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 0/3] Remove platform data and introduce DT bindings
This patchset introduces the use of device tree bindings for setting up the irq_type and removes the usage of platform data. Also, code related to interrupt is moved to the new function adt7316_setup_irq to unclutter the code in adt7316_probe(). A dev_err() message is added to give more details about the error. Shreeya Patel (3): Staging: iio: adt7316: Use device tree data to assign irq_type Staging: iio: adt7316: Move interrupt related code Staging: iio: adt7316: Add a dev_err() message drivers/staging/iio/addac/adt7316.c | 52 + 1 file changed, 38 insertions(+), 14 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 1/3] Staging: iio: adt7316: Use device tree data to assign irq_type
ADT7316 driver no more uses platform data and hence use device tree data instead of platform data for assigning irq_type field. Switch case figures out the type of irq and if it's the default case then assign the default value to the irq_type i.e. irq_type = IRQF_TRIGGER_LOW All this is implemented in a new function called adt7316_setup_irq. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316.c | 29 + 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 9c72538baf9e..86b2c3d53588 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1807,6 +1807,29 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) return IRQ_HANDLED; } +static int adt7316_setup_irq(struct device *dev, int irq) +{ + int irq_type; + + irq_type = irqd_get_trigger_type(irq_get_irq_data(irq)); + + switch (irq_type) { + case IRQF_TRIGGER_HIGH: + case IRQF_TRIGGER_RISING: + break; + case IRQF_TRIGGER_LOW: + case IRQF_TRIGGER_FALLING: + break; + default: + dev_info(dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", +irq_type); + irq_type = IRQF_TRIGGER_LOW; + break; + } + + return irq_type; +} + /* * Show mask of enabled interrupts in Hex. */ @@ -2101,8 +2124,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; - unsigned short *adt7316_platform_data = dev->platform_data; - int irq_type = IRQF_TRIGGER_LOW; + int irq_type; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,8 +2168,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->modes = INDIO_DIRECT_MODE; if (chip->bus.irq > 0) { - if (adt7316_platform_data[0]) - irq_type = adt7316_platform_data[0]; + irq_type = adt7316_setup_irq(dev, chip->bus.irq); ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Revert "Staging: iio: adt7316: Add an extra check for 'ret' equals to 0"
On Sat, 2018-12-08 at 11:17 +, Jonathan Cameron wrote: > On Sat, 08 Dec 2018 00:07:21 +0530 > Shreeya Patel wrote: > > > On Thu, 2018-12-06 at 15:40 +0300, Dan Carpenter wrote: > > > On Wed, Dec 05, 2018 at 02:59:53PM -0700, Jeremy Fertic wrote: > > > > On Thu, Dec 06, 2018 at 01:25:55AM +0530, Shreeya Patel > > > > wrote: > > > > > On Tue, 2018-12-04 at 18:49 -0700, Jeremy Fertic wrote: > > > > > > This reverts commit > > > > > > 00426e99789357dbff7e719a092ce36a3ce49d94. > > > > > > > > > > > > i2c_smbus_read_byte() returns 0 when a byte with the value > > > > > > 0 is > > > > > > read > > > > > > from > > > > > > the device. This is a valid read so revert the check for 0. > > > > > > > > > > > > Signed-off-by: Jeremy Fertic > > > > > > --- > > > > > > > > > > Hi Jeremy, > > > > > > > > > > As per my understanding, 0 value indicates no error but no > > > > > data > > > > > read. > > > > > Then how can this be a valid case? > > > > > > > > > > Can you please make me understand that how can we consider > > > > > this > > > > > as a > > > > > valid case even when no data has been read? > > > > > > It's not reading no data. It's reading one byte of data and > > > returning > > > it. > > > > > > > > > > > > > > > > > > Thanks > > > > > > > > I'm not sure I understand why the value 0 would indicate no > > > > data > > > > read. > > > > Doesn't that just mean a byte was read with the value 0. > > > > > > Yes. It does mean that. Please don't ask rhetorical > > > questions... :( > > > This list is full of people who can't resist answering every > > > question. > > > > > > > For instance, if the input to the adc is 0V. Can you point me > > > > to > > > > where > > > > you're seeing that this would indicate no data read? > > > > > > drivers/i2c/i2c-core-smbus.c > > > 88 /** > > > 89 * i2c_smbus_read_byte - SMBus "receive byte" protocol > > > 90 * @client: Handle to slave device > > > 91 * > > > 92 * This executes the SMBus "receive byte" protocol, > > > returning > > > negative errno > > > 93 * else the byte received from the device. > > > 94 */ > > > 95 s32 i2c_smbus_read_byte(const struct i2c_client *client) > > > 96 { > > > 97 union i2c_smbus_data data; > > > 98 int status; > > > 99 > > >100 status = i2c_smbus_xfer(client->adapter, > > > client- > > > > addr, client->flags, > > > > > >101 I2C_SMBUS_READ, 0, > > >102 I2C_SMBUS_BYTE, &data); > > >103 return (status < 0) ? status : data.byte; > > > ^ > > >104 } > > >105 EXPORT_SYMBOL(i2c_smbus_read_byte); > > > > Even I had sent the same code to Jonathan and we had a discussion > > on > > this. > > I asked him that this code clearly shows that there is an error > > condition only when status < 0 then why do we need a check for > > status = > > 0. > > > > Then he explained me that 0 isn't an error. The issue is the > > silliness > > of the i2c interface. > > > > Pretty much every other bus returns an error (negative) if less > > data is > > received than expected. Most i2c > > bus master's do as well but in theory it can return 0 to indicate > > no > > error but no data read (which doesn't make any sense) > > > > 0 doesn't ever happen in reality but it should be handled for > > correctness though. > > > > So we should wait for what Jonathan has to say on this :) > > Yup, I was being an idiot. Sorry about that! For some reason I'd > gotten it into my head that the particular function we were talking > about was i2c_master_send which does indeed do as discussed above. > > Apologies for misleading you on this. Definitely a proper idiot > moment of me not reading what the code actually was properly, even > when you questioned what I was going on about. It was not your mistake! There was a confusion because of delay in replying to you from my side. So it was just the case of human error :) > > Thanks to Jeremy for catching this one. > > Applied to the togreg branch of iio.git and pushed out as testing for > the autobuilders to play with it. > > Jonathan > > > > > Thanks > > > > > You are right. Commit 00426e997893 ("Staging: iio: adt7316: Add > > > an > > > extra check for 'ret' equals to 0") needs to be reverted... > > > > > > regards, > > > dan carpenter > > > > > > > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 2/3] Staging: iio: adt7316: Move interrupt related code
On Sat, 2018-12-08 at 16:12 +, Jonathan Cameron wrote: > On Sat, 8 Dec 2018 20:46:37 +0530 > Shreeya Patel wrote: > > > There is a function adt7316_irq_setup() where irq_type is being > > set. It would be good to move devm_request_threaded_irq() function > > and assignment of chip->config1 in adt7316_irq_setup() to unclutter > > the code in probe function. > > > > Signed-off-by: Shreeya Patel > > As commented below, this didn't end up as tidy as it might have been. > It would I think have been simpler before patch 1 or just merged with > it. > As I was introducing a new function named "adt7316_setup_irq" so I thought patch 1 should come first because we are setting up the irq_type there. But yes, this made the code complex to review. I didn't merge both patches because both the patches were having different changes. If I would have done that then there was a possibility where someone would have said to split the patches. > Anyhow, I might combine the two whilst applying. However before I do > that I'd like to leave this on list for a few days to let Alex > or others have time for another look before I apply it. > It's ok, I'll merge both patches and send as a v4 to you. I'll send it after 3-4 days so we can get other reviews by that time if there are any to come. My vacation has started so I'll work faster now. > All heading in the right direction! > > Thanks, > > Jonathan > > > --- > > drivers/staging/iio/addac/adt7316.c | 34 ++--- > > > > 1 file changed, 17 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/staging/iio/addac/adt7316.c > > b/drivers/staging/iio/addac/adt7316.c > > index 86b2c3d53588..97dd48153293 100644 > > --- a/drivers/staging/iio/addac/adt7316.c > > +++ b/drivers/staging/iio/addac/adt7316.c > > @@ -1807,11 +1807,12 @@ static irqreturn_t > > adt7316_event_handler(int irq, void *private) > > return IRQ_HANDLED; > > } > > > > -static int adt7316_setup_irq(struct device *dev, int irq) > > +static int adt7316_setup_irq(struct iio_dev *indio_dev) > > Hmm. This has ended up a lot more complex than ideal due > to the effective two layers of rework. > > I would either have done patches 1 and 2 as one patch or > reordered them so the rework preceded the change > to DT. It's not that important but it would have lead > to code that was easier to review. > > > > { > > - int irq_type; > > + struct adt7316_chip_info *chip = iio_priv(indio_dev); > > + int irq_type, ret; > > > > - irq_type = irqd_get_trigger_type(irq_get_irq_data(irq)); > > + irq_type = irqd_get_trigger_type(irq_get_irq_data(chip- > > >bus.irq)); > > > > switch (irq_type) { > > case IRQF_TRIGGER_HIGH: > > @@ -1821,13 +1822,23 @@ static int adt7316_setup_irq(struct device > > *dev, int irq) > > case IRQF_TRIGGER_FALLING: > > break; > > default: > > - dev_info(dev, "mode %d unsupported, using > > IRQF_TRIGGER_LOW\n", > > + dev_info(&indio_dev->dev, "mode %d unsupported, > > using IRQF_TRIGGER_LOW\n", > > irq_type); > > irq_type = IRQF_TRIGGER_LOW; > > break; > > } > > > > - return irq_type; > > + ret = devm_request_threaded_irq(&indio_dev->dev, chip- > > >bus.irq, > > + NULL, > > adt7316_event_handler, > > + irq_type | IRQF_ONESHOT, > > + indio_dev->name, > > indio_dev); > > + if (ret) > > + return ret; > > + > > + if (irq_type & IRQF_TRIGGER_HIGH) > > + chip->config1 |= ADT7316_INT_POLARITY; > > + > > + return ret; > > } > > > > /* > > @@ -2124,7 +2135,6 @@ int adt7316_probe(struct device *dev, struct > > adt7316_bus *bus, > > { > > struct adt7316_chip_info *chip; > > struct iio_dev *indio_dev; > > - int irq_type; > > int ret = 0; > > > > indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); > > @@ -2168,19 +2178,9 @@ int adt7316_probe(struct device *dev, struct > > adt7316_bus *bus, > > indio_dev->modes = INDIO_DIRECT_MODE; > > > > if (chip->bus.irq > 0) { > > - irq_type = adt7316_setup_irq(dev, chip->bus.irq); > > - > > - ret = devm_request_thr
[PATCH v4] Staging: iio: adt7316: Add all irq related code in adt7316_irq_setup()
ADT7316 driver no more uses platform data and hence use device tree data instead of platform data for assigning irq_type field and implement this in adt7316_irq_setup function. Switch case figures out the type of irq and if it's the default case then assign the default value to the irq_type i.e. irq_type = IRQF_TRIGGER_LOW Move devm_request_threaded_irq() and assignment of chip->config1 into the adt7316_setup_irq() to unclutter the code in probe function. Signed-off-by: Shreeya Patel --- Changes in v4 - Merge patches *[1/3 v3], *[2/3 v3] and *[3/3 v3] to make it less complex to review. Changes in v3 - Add a new function for having all interrupt related code. Changes in v2 - Make the commit message of patch *[1/5] appropriate. drivers/staging/iio/addac/adt7316.c | 52 + 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 9c72538baf9e..1ca4ee0f30ee 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1807,6 +1807,43 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) return IRQ_HANDLED; } +static int adt7316_setup_irq(struct iio_dev *indio_dev) +{ + struct adt7316_chip_info *chip = iio_priv(indio_dev); + int irq_type, ret; + + irq_type = irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); + + switch (irq_type) { + case IRQF_TRIGGER_HIGH: + case IRQF_TRIGGER_RISING: + break; + case IRQF_TRIGGER_LOW: + case IRQF_TRIGGER_FALLING: + break; + default: + dev_info(&indio_dev->dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n", +irq_type); + irq_type = IRQF_TRIGGER_LOW; + break; + } + + ret = devm_request_threaded_irq(&indio_dev->dev, chip->bus.irq, + NULL, adt7316_event_handler, + irq_type | IRQF_ONESHOT, + indio_dev->name, indio_dev); + if (ret) { + dev_err(&indio_dev->dev, "failed to request irq %d\n", + chip->bus.irq); + return ret; + } + + if (irq_type & IRQF_TRIGGER_HIGH) + chip->config1 |= ADT7316_INT_POLARITY; + + return 0; +} + /* * Show mask of enabled interrupts in Hex. */ @@ -2101,8 +2138,6 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; - unsigned short *adt7316_platform_data = dev->platform_data; - int irq_type = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2146,20 +2181,9 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->modes = INDIO_DIRECT_MODE; if (chip->bus.irq > 0) { - if (adt7316_platform_data[0]) - irq_type = adt7316_platform_data[0]; - - ret = devm_request_threaded_irq(dev, chip->bus.irq, - NULL, - adt7316_event_handler, - irq_type | IRQF_ONESHOT, - indio_dev->name, - indio_dev); + ret = adt7316_setup_irq(indio_dev); if (ret) return ret; - - if (irq_type & IRQF_TRIGGER_HIGH) - chip->config1 |= ADT7316_INT_POLARITY; } ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG1, chip->config1); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: iio: adt7316: Add regmap support
Both i2c and spi drivers have functions for reading and writing to/from registers. Remove this redundant and common code by using regmap API. Also remove multi_read and multi_write functions from i2c and spi driver as they are not being used anywhere. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 101 ++-- drivers/staging/iio/addac/adt7316-spi.c | 94 +++ drivers/staging/iio/addac/adt7316.c | 147 drivers/staging/iio/addac/adt7316.h | 15 +-- 4 files changed, 103 insertions(+), 254 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index ac91163656b5..435b65845174 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -12,105 +12,28 @@ #include #include #include +#include #include "adt7316.h" -/* - * adt7316 register access by I2C - */ -static int adt7316_i2c_read(void *client, u8 reg, u8 *data) -{ - struct i2c_client *cl = client; - int ret; - - ret = i2c_smbus_write_byte(cl, reg); - if (ret < 0) { - dev_err(&cl->dev, "I2C fail to select reg\n"); - return ret; - } - - ret = i2c_smbus_read_byte(client); - - if (!ret) - return -EIO; - - if (ret < 0) { - dev_err(&cl->dev, "I2C read error\n"); - return ret; - } - - *data = ret; - - return 0; -} - -static int adt7316_i2c_write(void *client, u8 reg, u8 data) -{ - struct i2c_client *cl = client; - int ret = 0; - - ret = i2c_smbus_write_byte_data(cl, reg, data); - if (ret < 0) - dev_err(&cl->dev, "I2C write error\n"); - - return ret; -} - -static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_read(cl, reg, &data[i]); - if (ret < 0) { - dev_err(&cl->dev, "I2C multi read error\n"); - return ret; - } - } - - return 0; -} - -static int adt7316_i2c_multi_write(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_write(cl, reg, data[i]); - if (ret < 0) { - dev_err(&cl->dev, "I2C multi write error\n"); - return ret; - } - } - - return 0; -} - /* * device probe and remove */ - static int adt7316_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct adt7316_bus bus = { - .client = client, - .irq = client->irq, - .read = adt7316_i2c_read, - .write = adt7316_i2c_write, - .multi_read = adt7316_i2c_multi_read, - .multi_write = adt7316_i2c_multi_write, - }; + struct regmap *regmap; + + regmap = devm_regmap_init_i2c(client, &adt7316_regmap_config); + + if (IS_ERR(regmap)) { + dev_err(&client->dev, "Error initializing i2c regmap: %ld\n", + PTR_ERR(regmap)); + return PTR_ERR(regmap); + } - return adt7316_probe(&client->dev, &bus, id->name); + return adt7316_probe(&client->dev, regmap, id ? id->name : NULL, +client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index e75827e326a6..9e3decb5cb77 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -11,79 +11,12 @@ #include #include #include +#include #include #include "adt7316.h" #define ADT7316_SPI_MAX_FREQ_HZ500 -#define ADT7316_SPI_CMD_READ 0x91 -#define ADT7316_SPI_CMD_WRITE 0x90 - -/* - * adt7316 register access by SPI - */ - -static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) -{ - struct spi_device *spi_dev = client; - u8 cmd[2]; - int ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - cmd[0] = ADT7316_SPI_CMD_WRITE; - cmd[1] = reg; - - ret = spi_write(spi_dev, cmd, 2); - if (ret < 0) { - dev_err(&spi_dev
[PATCH v2 1/3] Staging: iio: adt7316: Remove irq from bus structure
interrupt request is not needed to be present in the bus structure. It is a good option to pass it as a parameter in the probe function instead of having it in the bus structure. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 3 +-- drivers/staging/iio/addac/adt7316-spi.c | 4 ++-- drivers/staging/iio/addac/adt7316.c | 15 +++ drivers/staging/iio/addac/adt7316.h | 3 +-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index ac91163656b5..335c17731cf7 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -103,14 +103,13 @@ static int adt7316_i2c_probe(struct i2c_client *client, { struct adt7316_bus bus = { .client = client, - .irq = client->irq, .read = adt7316_i2c_read, .write = adt7316_i2c_write, .multi_read = adt7316_i2c_multi_read, .multi_write = adt7316_i2c_multi_write, }; - return adt7316_probe(&client->dev, &bus, id->name); + return adt7316_probe(&client->dev, &bus, id->name, client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index e75827e326a6..adaaa3eecd04 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -93,7 +93,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) { struct adt7316_bus bus = { .client = spi_dev, - .irq = spi_dev->irq, .read = adt7316_spi_read, .write = adt7316_spi_write, .multi_read = adt7316_spi_multi_read, @@ -112,7 +111,8 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) adt7316_spi_write(spi_dev, 0, 0); adt7316_spi_write(spi_dev, 0, 0); - return adt7316_probe(&spi_dev->dev, &bus, spi_dev->modalias); + return adt7316_probe(&spi_dev->dev, &bus, spi_dev->modalias, +spi_dev->irq); } static const struct spi_device_id adt7316_spi_id[] = { diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 1ca4ee0f30ee..6b4b80fd80cc 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1807,12 +1807,12 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) return IRQ_HANDLED; } -static int adt7316_setup_irq(struct iio_dev *indio_dev) +static int adt7316_setup_irq(struct iio_dev *indio_dev, int irq) { struct adt7316_chip_info *chip = iio_priv(indio_dev); int irq_type, ret; - irq_type = irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); + irq_type = irqd_get_trigger_type(irq_get_irq_data(irq)); switch (irq_type) { case IRQF_TRIGGER_HIGH: @@ -1828,13 +1828,12 @@ static int adt7316_setup_irq(struct iio_dev *indio_dev) break; } - ret = devm_request_threaded_irq(&indio_dev->dev, chip->bus.irq, + ret = devm_request_threaded_irq(&indio_dev->dev, irq, NULL, adt7316_event_handler, irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) { - dev_err(&indio_dev->dev, "failed to request irq %d\n", - chip->bus.irq); + dev_err(&indio_dev->dev, "failed to request irq %d\n", irq); return ret; } @@ -2134,7 +2133,7 @@ static const struct iio_info adt7516_info = { * device probe and remove */ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, - const char *name) + const char *name, int irq) { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; @@ -2180,8 +2179,8 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; - if (chip->bus.irq > 0) { - ret = adt7316_setup_irq(indio_dev); + if (irq > 0) { + ret = adt7316_setup_irq(indio_dev, irq); if (ret) return ret; } diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index fd7c5c92b599..03d5300a98cd 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -16,7 +16,6 @@ struct adt7316_bus { void *client; - int irq; int (*read)(void *client, u8 reg, u8 *data); int (*write)(void *client, u8 reg, u8 val); int (*multi_
[PATCH v2 0/3] adt7316 regmap implementation
This patchset consist of some initial patches for heading towards the regmap implementation and also the final patch which enables the driver to use regmap API thus removing the redundant and common code. Shreeya Patel (3): Staging: iio: adt7316: Remove irq from bus structure Staging: iio: adt7316: Remove multi read and write functions Staging: iio: adt7316: Add regmap support drivers/staging/iio/addac/adt7316-i2c.c | 101 ++-- drivers/staging/iio/addac/adt7316-spi.c | 95 +++ drivers/staging/iio/addac/adt7316.c | 147 drivers/staging/iio/addac/adt7316.h | 15 +-- 4 files changed, 103 insertions(+), 255 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 3/3] Staging: iio: adt7316: Add regmap support
Both i2c and spi drivers have functions for reading and writing to/from registers. Remove this redundant and common code by using regmap API. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 60 +++ drivers/staging/iio/addac/adt7316-spi.c | 74 +++-- drivers/staging/iio/addac/adt7316.c | 132 drivers/staging/iio/addac/adt7316.h | 10 +- 4 files changed, 94 insertions(+), 182 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 40aa9e2f1966..435b65845174 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -12,64 +12,28 @@ #include #include #include +#include #include "adt7316.h" -/* - * adt7316 register access by I2C - */ -static int adt7316_i2c_read(void *client, u8 reg, u8 *data) -{ - struct i2c_client *cl = client; - int ret; - - ret = i2c_smbus_write_byte(cl, reg); - if (ret < 0) { - dev_err(&cl->dev, "I2C fail to select reg\n"); - return ret; - } - - ret = i2c_smbus_read_byte(client); - - if (!ret) - return -EIO; - - if (ret < 0) { - dev_err(&cl->dev, "I2C read error\n"); - return ret; - } - - *data = ret; - - return 0; -} - -static int adt7316_i2c_write(void *client, u8 reg, u8 data) -{ - struct i2c_client *cl = client; - int ret = 0; - - ret = i2c_smbus_write_byte_data(cl, reg, data); - if (ret < 0) - dev_err(&cl->dev, "I2C write error\n"); - - return ret; -} - /* * device probe and remove */ - static int adt7316_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct adt7316_bus bus = { - .client = client, - .read = adt7316_i2c_read, - .write = adt7316_i2c_write, - }; + struct regmap *regmap; + + regmap = devm_regmap_init_i2c(client, &adt7316_regmap_config); + + if (IS_ERR(regmap)) { + dev_err(&client->dev, "Error initializing i2c regmap: %ld\n", + PTR_ERR(regmap)); + return PTR_ERR(regmap); + } - return adt7316_probe(&client->dev, &bus, id->name, client->irq); + return adt7316_probe(&client->dev, regmap, id ? id->name : NULL, +client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 1a78dc1e2840..203b5c3ada6e 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -11,74 +11,19 @@ #include #include #include +#include #include #include "adt7316.h" #define ADT7316_SPI_MAX_FREQ_HZ500 -#define ADT7316_SPI_CMD_READ 0x91 -#define ADT7316_SPI_CMD_WRITE 0x90 - -/* - * adt7316 register access by SPI - */ - -static int adt7316_spi_read(void *client, u8 reg, u8 *data) -{ - struct spi_device *spi_dev = client; - u8 cmd[2]; - int ret = 0; - - cmd[0] = ADT7316_SPI_CMD_WRITE; - cmd[1] = reg; - - ret = spi_write(spi_dev, cmd, 2); - if (ret < 0) { - dev_err(&spi_dev->dev, "SPI fail to select reg\n"); - return ret; - } - - cmd[0] = ADT7316_SPI_CMD_READ; - - ret = spi_write_then_read(spi_dev, cmd, 1, data, 1); - if (ret < 0) { - dev_err(&spi_dev->dev, "SPI read data error\n"); - return ret; - } - - return 0; -} - -static int adt7316_spi_write(void *client, u8 reg, u8 val) -{ - struct spi_device *spi_dev = client; - u8 buf[ADT7316_REG_MAX_ADDR + 2]; - int ret = 0; - - buf[0] = ADT7316_SPI_CMD_WRITE; - buf[1] = reg; - buf[2] = val; - - ret = spi_write(spi_dev, buf, 3); - if (ret < 0) { - dev_err(&spi_dev->dev, "SPI write error\n"); - return ret; - } - - return ret; -} /* * device probe and remove */ - static int adt7316_spi_probe(struct spi_device *spi_dev) { - struct adt7316_bus bus = { - .client = spi_dev, - .read = adt7316_spi_read, - .write = adt7316_spi_write, - }; + struct regmap *regmap; /* don't exceed max specified SPI CLK frequency */ if (spi_dev->max_speed_hz > ADT7316_SPI_MAX_FREQ_HZ) { @@ -87,12 +32,19 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) return -EINVAL; } + regmap = devm_regmap_init_spi(spi_dev, &adt731
[PATCH v2 2/3] Staging: iio: adt7316: Remove multi read and write functions
Currently, adt7316 doesn't use multi read and multi write functions hence remove the redundant code and make the necessary changes in the code. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 40 - drivers/staging/iio/addac/adt7316-spi.c | 31 --- drivers/staging/iio/addac/adt7316.h | 2 -- 3 files changed, 6 insertions(+), 67 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 335c17731cf7..40aa9e2f1966 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -56,44 +56,6 @@ static int adt7316_i2c_write(void *client, u8 reg, u8 data) return ret; } -static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_read(cl, reg, &data[i]); - if (ret < 0) { - dev_err(&cl->dev, "I2C multi read error\n"); - return ret; - } - } - - return 0; -} - -static int adt7316_i2c_multi_write(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_write(cl, reg, data[i]); - if (ret < 0) { - dev_err(&cl->dev, "I2C multi write error\n"); - return ret; - } - } - - return 0; -} - /* * device probe and remove */ @@ -105,8 +67,6 @@ static int adt7316_i2c_probe(struct i2c_client *client, .client = client, .read = adt7316_i2c_read, .write = adt7316_i2c_write, - .multi_read = adt7316_i2c_multi_read, - .multi_write = adt7316_i2c_multi_write, }; return adt7316_probe(&client->dev, &bus, id->name, client->irq); diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index adaaa3eecd04..1a78dc1e2840 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -23,15 +23,12 @@ * adt7316 register access by SPI */ -static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) +static int adt7316_spi_read(void *client, u8 reg, u8 *data) { struct spi_device *spi_dev = client; u8 cmd[2]; int ret = 0; - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - cmd[0] = ADT7316_SPI_CMD_WRITE; cmd[1] = reg; @@ -43,7 +40,7 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) cmd[0] = ADT7316_SPI_CMD_READ; - ret = spi_write_then_read(spi_dev, cmd, 1, data, count); + ret = spi_write_then_read(spi_dev, cmd, 1, data, 1); if (ret < 0) { dev_err(&spi_dev->dev, "SPI read data error\n"); return ret; @@ -52,21 +49,17 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) return 0; } -static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data) +static int adt7316_spi_write(void *client, u8 reg, u8 val) { struct spi_device *spi_dev = client; u8 buf[ADT7316_REG_MAX_ADDR + 2]; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; + int ret = 0; buf[0] = ADT7316_SPI_CMD_WRITE; buf[1] = reg; - for (i = 0; i < count; i++) - buf[i + 2] = data[i]; + buf[2] = val; - ret = spi_write(spi_dev, buf, count + 2); + ret = spi_write(spi_dev, buf, 3); if (ret < 0) { dev_err(&spi_dev->dev, "SPI write error\n"); return ret; @@ -75,16 +68,6 @@ static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data) return ret; } -static int adt7316_spi_read(void *client, u8 reg, u8 *data) -{ - return adt7316_spi_multi_read(client, reg, 1, data); -} - -static int adt7316_spi_write(void *client, u8 reg, u8 val) -{ - return adt7316_spi_multi_write(client, reg, 1, &val); -} - /* * device probe and remove */ @@ -95,8 +78,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) .client = spi_dev, .read = adt7316_spi_read, .write = adt7316_spi_write, - .multi_read = adt7316_spi_multi_read, - .multi_write = adt7316_spi_multi_write, };
Re: [PATCH v2 0/3] adt7316 regmap implementation
On Sat, 2019-01-19 at 19:04 +, Jonathan Cameron wrote: > On Sun, 20 Jan 2019 00:09:29 +0530 > Shreeya Patel wrote: > > > This patchset consist of some initial patches for heading > > towards the regmap implementation and also the final patch > > which enables the driver to use regmap API thus removing > > the redundant and common code. > > > > Shreeya Patel (3): > > Staging: iio: adt7316: Remove irq from bus structure > > Staging: iio: adt7316: Remove multi read and write functions > > Staging: iio: adt7316: Add regmap support > > > > drivers/staging/iio/addac/adt7316-i2c.c | 101 ++-- > > drivers/staging/iio/addac/adt7316-spi.c | 95 +++ > > drivers/staging/iio/addac/adt7316.c | 147 -- > > -- > > drivers/staging/iio/addac/adt7316.h | 15 +-- > > 4 files changed, 103 insertions(+), 255 deletions(-) > > > > Hi Shreeya, > > I'm not seeing a change log for any of these. Please make sure to > add one so we know what changed since V1. Saves a lot of trying > to remember things from a while back! > Sorry, I forgot to add it. I remembered it when I had already sent the patches. I'll also cc Jeremy in V3. Thanks > Thanks, > > Jonathan ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 1/3] Staging: iio: adt7316: Remove irq from bus structure
interrupt request is not needed to be present in the bus structure. It is a good option to pass it as a parameter in the probe function instead of having it in the bus structure. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 3 +-- drivers/staging/iio/addac/adt7316-spi.c | 4 ++-- drivers/staging/iio/addac/adt7316.c | 15 +++ drivers/staging/iio/addac/adt7316.h | 3 +-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 2d51bd425662..b6571db2e8d8 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -99,14 +99,13 @@ static int adt7316_i2c_probe(struct i2c_client *client, { struct adt7316_bus bus = { .client = client, - .irq = client->irq, .read = adt7316_i2c_read, .write = adt7316_i2c_write, .multi_read = adt7316_i2c_multi_read, .multi_write = adt7316_i2c_multi_write, }; - return adt7316_probe(&client->dev, &bus, id->name); + return adt7316_probe(&client->dev, &bus, id->name, client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index e75827e326a6..adaaa3eecd04 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -93,7 +93,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) { struct adt7316_bus bus = { .client = spi_dev, - .irq = spi_dev->irq, .read = adt7316_spi_read, .write = adt7316_spi_write, .multi_read = adt7316_spi_multi_read, @@ -112,7 +111,8 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) adt7316_spi_write(spi_dev, 0, 0); adt7316_spi_write(spi_dev, 0, 0); - return adt7316_probe(&spi_dev->dev, &bus, spi_dev->modalias); + return adt7316_probe(&spi_dev->dev, &bus, spi_dev->modalias, +spi_dev->irq); } static const struct spi_device_id adt7316_spi_id[] = { diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 8cf3ff25eb62..30808a897fc2 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1809,12 +1809,12 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) return IRQ_HANDLED; } -static int adt7316_setup_irq(struct iio_dev *indio_dev) +static int adt7316_setup_irq(struct iio_dev *indio_dev, int irq) { struct adt7316_chip_info *chip = iio_priv(indio_dev); int irq_type, ret; - irq_type = irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); + irq_type = irqd_get_trigger_type(irq_get_irq_data(irq)); switch (irq_type) { case IRQF_TRIGGER_HIGH: @@ -1830,13 +1830,12 @@ static int adt7316_setup_irq(struct iio_dev *indio_dev) break; } - ret = devm_request_threaded_irq(&indio_dev->dev, chip->bus.irq, + ret = devm_request_threaded_irq(&indio_dev->dev, irq, NULL, adt7316_event_handler, irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) { - dev_err(&indio_dev->dev, "failed to request irq %d\n", - chip->bus.irq); + dev_err(&indio_dev->dev, "failed to request irq %d\n", irq); return ret; } @@ -2136,7 +2135,7 @@ static const struct iio_info adt7516_info = { * device probe and remove */ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, - const char *name) + const char *name, int irq) { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; @@ -2182,8 +2181,8 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; - if (chip->bus.irq > 0) { - ret = adt7316_setup_irq(indio_dev); + if (irq > 0) { + ret = adt7316_setup_irq(indio_dev, irq); if (ret) return ret; } diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index 84ca4f6c88f5..03d5300a98cd 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -16,7 +16,6 @@ struct adt7316_bus { void *client; - int irq; int (*read)(void *client, u8 reg, u8 *data); int (*write)(void *client, u8 reg, u8 val); int (*multi_
[PATCH v3 0/3] adt7316 regmap implementation
This patchset consist of some initial patches for heading towards the regmap implementation and also the final patch which enables the driver to use regmap API thus removing the redundant and common code. Changes in v3 -Fetch the changes from remote and rebase to have it in the current working directory. Changes in v2 -Change the val_bits to 8 and add two more patches having a different change before the final implemetation of regmap. Shreeya Patel (3): Staging: iio: adt7316: Remove irq from bus structure Staging: iio: adt7316: Remove multi read and write functions Staging: iio: adt7316: Add regmap support drivers/staging/iio/addac/adt7316-i2c.c | 97 ++-- drivers/staging/iio/addac/adt7316-spi.c | 95 +++ drivers/staging/iio/addac/adt7316.c | 147 drivers/staging/iio/addac/adt7316.h | 15 +-- 4 files changed, 103 insertions(+), 251 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3 2/3] Staging: iio: adt7316: Remove multi read and write functions
Currently, adt7316 doesn't use multi read and multi write functions hence remove the redundant code and make the necessary changes in the code. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 40 - drivers/staging/iio/addac/adt7316-spi.c | 31 --- drivers/staging/iio/addac/adt7316.h | 2 -- 3 files changed, 6 insertions(+), 67 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index b6571db2e8d8..c7f82c3fe27c 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -52,44 +52,6 @@ static int adt7316_i2c_write(void *client, u8 reg, u8 data) return ret; } -static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_read(cl, reg, &data[i]); - if (ret < 0) { - dev_err(&cl->dev, "I2C multi read error\n"); - return ret; - } - } - - return 0; -} - -static int adt7316_i2c_multi_write(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_write(cl, reg, data[i]); - if (ret < 0) { - dev_err(&cl->dev, "I2C multi write error\n"); - return ret; - } - } - - return 0; -} - /* * device probe and remove */ @@ -101,8 +63,6 @@ static int adt7316_i2c_probe(struct i2c_client *client, .client = client, .read = adt7316_i2c_read, .write = adt7316_i2c_write, - .multi_read = adt7316_i2c_multi_read, - .multi_write = adt7316_i2c_multi_write, }; return adt7316_probe(&client->dev, &bus, id->name, client->irq); diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index adaaa3eecd04..1a78dc1e2840 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -23,15 +23,12 @@ * adt7316 register access by SPI */ -static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) +static int adt7316_spi_read(void *client, u8 reg, u8 *data) { struct spi_device *spi_dev = client; u8 cmd[2]; int ret = 0; - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - cmd[0] = ADT7316_SPI_CMD_WRITE; cmd[1] = reg; @@ -43,7 +40,7 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) cmd[0] = ADT7316_SPI_CMD_READ; - ret = spi_write_then_read(spi_dev, cmd, 1, data, count); + ret = spi_write_then_read(spi_dev, cmd, 1, data, 1); if (ret < 0) { dev_err(&spi_dev->dev, "SPI read data error\n"); return ret; @@ -52,21 +49,17 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) return 0; } -static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data) +static int adt7316_spi_write(void *client, u8 reg, u8 val) { struct spi_device *spi_dev = client; u8 buf[ADT7316_REG_MAX_ADDR + 2]; - int i, ret = 0; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; + int ret = 0; buf[0] = ADT7316_SPI_CMD_WRITE; buf[1] = reg; - for (i = 0; i < count; i++) - buf[i + 2] = data[i]; + buf[2] = val; - ret = spi_write(spi_dev, buf, count + 2); + ret = spi_write(spi_dev, buf, 3); if (ret < 0) { dev_err(&spi_dev->dev, "SPI write error\n"); return ret; @@ -75,16 +68,6 @@ static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data) return ret; } -static int adt7316_spi_read(void *client, u8 reg, u8 *data) -{ - return adt7316_spi_multi_read(client, reg, 1, data); -} - -static int adt7316_spi_write(void *client, u8 reg, u8 val) -{ - return adt7316_spi_multi_write(client, reg, 1, &val); -} - /* * device probe and remove */ @@ -95,8 +78,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) .client = spi_dev, .read = adt7316_spi_read, .write = adt7316_spi_write, - .multi_read = adt7316_spi_multi_read, - .multi_write = adt7316_spi_multi_write, };
[PATCH v3 3/3] Staging: iio: adt7316: Add regmap support
Both i2c and spi drivers have functions for reading and writing to/from registers. Remove this redundant and common code by using regmap API. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 56 +++--- drivers/staging/iio/addac/adt7316-spi.c | 74 +++-- drivers/staging/iio/addac/adt7316.c | 132 drivers/staging/iio/addac/adt7316.h | 10 +- 4 files changed, 94 insertions(+), 178 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index c7f82c3fe27c..435b65845174 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -12,60 +12,28 @@ #include #include #include +#include #include "adt7316.h" -/* - * adt7316 register access by I2C - */ -static int adt7316_i2c_read(void *client, u8 reg, u8 *data) -{ - struct i2c_client *cl = client; - int ret; - - ret = i2c_smbus_write_byte(cl, reg); - if (ret < 0) { - dev_err(&cl->dev, "I2C fail to select reg\n"); - return ret; - } - - ret = i2c_smbus_read_byte(client); - if (ret < 0) { - dev_err(&cl->dev, "I2C read error\n"); - return ret; - } - - *data = ret; - - return 0; -} - -static int adt7316_i2c_write(void *client, u8 reg, u8 data) -{ - struct i2c_client *cl = client; - int ret = 0; - - ret = i2c_smbus_write_byte_data(cl, reg, data); - if (ret < 0) - dev_err(&cl->dev, "I2C write error\n"); - - return ret; -} - /* * device probe and remove */ - static int adt7316_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct adt7316_bus bus = { - .client = client, - .read = adt7316_i2c_read, - .write = adt7316_i2c_write, - }; + struct regmap *regmap; + + regmap = devm_regmap_init_i2c(client, &adt7316_regmap_config); + + if (IS_ERR(regmap)) { + dev_err(&client->dev, "Error initializing i2c regmap: %ld\n", + PTR_ERR(regmap)); + return PTR_ERR(regmap); + } - return adt7316_probe(&client->dev, &bus, id->name, client->irq); + return adt7316_probe(&client->dev, regmap, id ? id->name : NULL, +client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 1a78dc1e2840..203b5c3ada6e 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -11,74 +11,19 @@ #include #include #include +#include #include #include "adt7316.h" #define ADT7316_SPI_MAX_FREQ_HZ500 -#define ADT7316_SPI_CMD_READ 0x91 -#define ADT7316_SPI_CMD_WRITE 0x90 - -/* - * adt7316 register access by SPI - */ - -static int adt7316_spi_read(void *client, u8 reg, u8 *data) -{ - struct spi_device *spi_dev = client; - u8 cmd[2]; - int ret = 0; - - cmd[0] = ADT7316_SPI_CMD_WRITE; - cmd[1] = reg; - - ret = spi_write(spi_dev, cmd, 2); - if (ret < 0) { - dev_err(&spi_dev->dev, "SPI fail to select reg\n"); - return ret; - } - - cmd[0] = ADT7316_SPI_CMD_READ; - - ret = spi_write_then_read(spi_dev, cmd, 1, data, 1); - if (ret < 0) { - dev_err(&spi_dev->dev, "SPI read data error\n"); - return ret; - } - - return 0; -} - -static int adt7316_spi_write(void *client, u8 reg, u8 val) -{ - struct spi_device *spi_dev = client; - u8 buf[ADT7316_REG_MAX_ADDR + 2]; - int ret = 0; - - buf[0] = ADT7316_SPI_CMD_WRITE; - buf[1] = reg; - buf[2] = val; - - ret = spi_write(spi_dev, buf, 3); - if (ret < 0) { - dev_err(&spi_dev->dev, "SPI write error\n"); - return ret; - } - - return ret; -} /* * device probe and remove */ - static int adt7316_spi_probe(struct spi_device *spi_dev) { - struct adt7316_bus bus = { - .client = spi_dev, - .read = adt7316_spi_read, - .write = adt7316_spi_write, - }; + struct regmap *regmap; /* don't exceed max specified SPI CLK frequency */ if (spi_dev->max_speed_hz > ADT7316_SPI_MAX_FREQ_HZ) { @@ -87,12 +32,19 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) return -EINVAL; } + regmap = devm_regmap_init_spi(spi_dev, &adt7316_regmap_config); + if (IS_ERR(regmap)) { + dev_err(&a
Re: [PATCH v3 0/3] adt7316 regmap implementation
On Fri, 2019-01-25 at 18:22 -0700, Jeremy Fertic wrote: > On Sun, Jan 20, 2019 at 09:06:30PM +0530, Shreeya Patel wrote: > > This patchset consist of some initial patches for heading > > towards the regmap implementation and also the final patch > > which enables the driver to use regmap API thus removing > > the redundant and common code. > > > > Changes in v3 > > -Fetch the changes from remote and rebase to have it in > > the current working directory. > > > > Changes in v2 > > -Change the val_bits to 8 and add two more patches > > having a different change before the final implemetation > > of regmap. > > > > Shreeya Patel (3): > > Staging: iio: adt7316: Remove irq from bus structure > > Staging: iio: adt7316: Remove multi read and write functions > > Staging: iio: adt7316: Add regmap support > > > > drivers/staging/iio/addac/adt7316-i2c.c | 97 ++-- > > drivers/staging/iio/addac/adt7316-spi.c | 95 +++ > > drivers/staging/iio/addac/adt7316.c | 147 -- > > -- > > drivers/staging/iio/addac/adt7316.h | 15 +-- > > 4 files changed, 103 insertions(+), 251 deletions(-) > > > > -- > > 2.17.1 > > > > The series doesn't apply to the current iio testing branch. If > there's any > value in a quick sanity testing, I can do that after a rebase. I > wasn't > planning to test everything the patch touches, but thought I could at > least test a few register reads and writes to make sure we haven't > missed > anything obvious in the regmap implementation. Hi Jeremy, Is it still not applying? Jonathan told me that v2 of this series wasn't applying so I rebased for this series. I hope I didn't mess things up while rebasing :( Thanks > > Jeremy > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3 0/3] adt7316 regmap implementation
On Sat, 2019-01-26 at 10:42 +0530, Shreeya Patel wrote: > On Fri, 2019-01-25 at 18:22 -0700, Jeremy Fertic wrote: > > On Sun, Jan 20, 2019 at 09:06:30PM +0530, Shreeya Patel wrote: > > > This patchset consist of some initial patches for heading > > > towards the regmap implementation and also the final patch > > > which enables the driver to use regmap API thus removing > > > the redundant and common code. > > > > > > Changes in v3 > > > -Fetch the changes from remote and rebase to have it in > > > the current working directory. > > > > > > Changes in v2 > > > -Change the val_bits to 8 and add two more patches > > > having a different change before the final implemetation > > > of regmap. > > > > > > Shreeya Patel (3): > > > Staging: iio: adt7316: Remove irq from bus structure > > > Staging: iio: adt7316: Remove multi read and write functions > > > Staging: iio: adt7316: Add regmap support > > > > > > drivers/staging/iio/addac/adt7316-i2c.c | 97 ++-- > > > drivers/staging/iio/addac/adt7316-spi.c | 95 +++ > > > drivers/staging/iio/addac/adt7316.c | 147 -- > > > -- > > > drivers/staging/iio/addac/adt7316.h | 15 +-- > > > 4 files changed, 103 insertions(+), 251 deletions(-) > > > > > > -- > > > 2.17.1 > > > > > > > The series doesn't apply to the current iio testing branch. If > > there's any > > value in a quick sanity testing, I can do that after a rebase. I > > wasn't > > planning to test everything the patch touches, but thought I could > > at > > least test a few register reads and writes to make sure we haven't > > missed > > anything obvious in the regmap implementation. > > Hi Jeremy, > > Is it still not applying? Jonathan told me that v2 of this series > wasn't applying so I rebased for this series. > > I hope I didn't mess things up while rebasing :( > > Thanks Yes it is my mistake. I've rebased against greg's staging tree. I will soon send a v4 for the series. Thanks > > > > > Jeremy > > > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4 1/3] Staging: iio: adt7316: Remove irq from bus structure
interrupt request is not needed to be present in the bus structure. It is a good option to pass it as a parameter in the probe function instead of having it in the bus structure. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 3 +-- drivers/staging/iio/addac/adt7316-spi.c | 4 ++-- drivers/staging/iio/addac/adt7316.c | 15 +++ drivers/staging/iio/addac/adt7316.h | 3 +-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 0f26bc38edc6..9dfe3be21849 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -99,14 +99,13 @@ static int adt7316_i2c_probe(struct i2c_client *client, { struct adt7316_bus bus = { .client = client, - .irq = client->irq, .read = adt7316_i2c_read, .write = adt7316_i2c_write, .multi_read = adt7316_i2c_multi_read, .multi_write = adt7316_i2c_multi_write, }; - return adt7316_probe(&client->dev, &bus, id->name); + return adt7316_probe(&client->dev, &bus, id->name, client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 8294b9c1e3c2..ec4848acec9f 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -93,7 +93,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) { struct adt7316_bus bus = { .client = spi_dev, - .irq = spi_dev->irq, .read = adt7316_spi_read, .write = adt7316_spi_write, .multi_read = adt7316_spi_multi_read, @@ -112,7 +111,8 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) adt7316_spi_write(spi_dev, 0, 0); adt7316_spi_write(spi_dev, 0, 0); - return adt7316_probe(&spi_dev->dev, &bus, spi_dev->modalias); + return adt7316_probe(&spi_dev->dev, &bus, spi_dev->modalias, +spi_dev->irq); } static const struct spi_device_id adt7316_spi_id[] = { diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 6f7891b567b9..7c4f84822c18 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -1799,12 +1799,12 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) return IRQ_HANDLED; } -static int adt7316_setup_irq(struct iio_dev *indio_dev) +static int adt7316_setup_irq(struct iio_dev *indio_dev, int irq) { struct adt7316_chip_info *chip = iio_priv(indio_dev); int irq_type, ret; - irq_type = irqd_get_trigger_type(irq_get_irq_data(chip->bus.irq)); + irq_type = irqd_get_trigger_type(irq_get_irq_data(irq)); switch (irq_type) { case IRQF_TRIGGER_HIGH: @@ -1820,13 +1820,12 @@ static int adt7316_setup_irq(struct iio_dev *indio_dev) break; } - ret = devm_request_threaded_irq(&indio_dev->dev, chip->bus.irq, + ret = devm_request_threaded_irq(&indio_dev->dev, irq, NULL, adt7316_event_handler, irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) { - dev_err(&indio_dev->dev, "failed to request irq %d\n", - chip->bus.irq); + dev_err(&indio_dev->dev, "failed to request irq %d\n", irq); return ret; } @@ -2126,7 +2125,7 @@ static const struct iio_info adt7516_info = { * device probe and remove */ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, - const char *name) + const char *name, int irq) { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; @@ -2179,8 +2178,8 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; - if (chip->bus.irq > 0) { - ret = adt7316_setup_irq(indio_dev); + if (irq > 0) { + ret = adt7316_setup_irq(indio_dev, irq); if (ret) return ret; } diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index 84ca4f6c88f5..03d5300a98cd 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -16,7 +16,6 @@ struct adt7316_bus { void *client; - int irq; int (*read)(void *client, u8 reg, u8 *data); int (*write)(void *client, u8 reg, u8 val); int (*multi_
[PATCH v4 2/3] Staging: iio: adt7316: Remove multi read and write functions
Currently, adt7316 doesn't use multi read and multi write functions hence remove the redundant code and make the necessary changes in the code. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 40 - drivers/staging/iio/addac/adt7316-spi.c | 31 --- drivers/staging/iio/addac/adt7316.h | 2 -- 3 files changed, 6 insertions(+), 67 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 9dfe3be21849..167eafe3dd8c 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -52,44 +52,6 @@ static int adt7316_i2c_write(void *client, u8 reg, u8 data) return ret; } -static int adt7316_i2c_multi_read(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_read(cl, reg, &data[i]); - if (ret < 0) { - dev_err(&cl->dev, "I2C multi read error\n"); - return ret; - } - } - - return 0; -} - -static int adt7316_i2c_multi_write(void *client, u8 reg, u8 count, u8 *data) -{ - struct i2c_client *cl = client; - int i, ret; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - - for (i = 0; i < count; i++) { - ret = adt7316_i2c_write(cl, reg, data[i]); - if (ret < 0) { - dev_err(&cl->dev, "I2C multi write error\n"); - return ret; - } - } - - return 0; -} - /* * device probe and remove */ @@ -101,8 +63,6 @@ static int adt7316_i2c_probe(struct i2c_client *client, .client = client, .read = adt7316_i2c_read, .write = adt7316_i2c_write, - .multi_read = adt7316_i2c_multi_read, - .multi_write = adt7316_i2c_multi_write, }; return adt7316_probe(&client->dev, &bus, id->name, client->irq); diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index ec4848acec9f..06c943c2cc01 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -23,15 +23,12 @@ * adt7316 register access by SPI */ -static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) +static int adt7316_spi_read(void *client, u8 reg, u8 *data) { struct spi_device *spi_dev = client; u8 cmd[2]; int ret; - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; - cmd[0] = ADT7316_SPI_CMD_WRITE; cmd[1] = reg; @@ -43,7 +40,7 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) cmd[0] = ADT7316_SPI_CMD_READ; - ret = spi_write_then_read(spi_dev, cmd, 1, data, count); + ret = spi_write_then_read(spi_dev, cmd, 1, data, 1); if (ret < 0) { dev_err(&spi_dev->dev, "SPI read data error\n"); return ret; @@ -52,21 +49,17 @@ static int adt7316_spi_multi_read(void *client, u8 reg, u8 count, u8 *data) return 0; } -static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data) +static int adt7316_spi_write(void *client, u8 reg, u8 val) { struct spi_device *spi_dev = client; u8 buf[ADT7316_REG_MAX_ADDR + 2]; - int i, ret; - - if (count > ADT7316_REG_MAX_ADDR) - count = ADT7316_REG_MAX_ADDR; + int ret = 0; buf[0] = ADT7316_SPI_CMD_WRITE; buf[1] = reg; - for (i = 0; i < count; i++) - buf[i + 2] = data[i]; + buf[2] = val; - ret = spi_write(spi_dev, buf, count + 2); + ret = spi_write(spi_dev, buf, 3); if (ret < 0) { dev_err(&spi_dev->dev, "SPI write error\n"); return ret; @@ -75,16 +68,6 @@ static int adt7316_spi_multi_write(void *client, u8 reg, u8 count, u8 *data) return ret; } -static int adt7316_spi_read(void *client, u8 reg, u8 *data) -{ - return adt7316_spi_multi_read(client, reg, 1, data); -} - -static int adt7316_spi_write(void *client, u8 reg, u8 val) -{ - return adt7316_spi_multi_write(client, reg, 1, &val); -} - /* * device probe and remove */ @@ -95,8 +78,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) .client = spi_dev, .read = adt7316_spi_read, .write = adt7316_spi_write, - .multi_read = adt7316_spi_multi_read, - .multi_write = adt7316_spi_multi_write, }; /* don&
[PATCH v4 3/3] Staging: iio: adt7316: Add regmap support
Both i2c and spi drivers have functions for reading and writing to/from registers. Remove this redundant and common code by using regmap API. Signed-off-by: Shreeya Patel --- drivers/staging/iio/addac/adt7316-i2c.c | 56 +++--- drivers/staging/iio/addac/adt7316-spi.c | 74 +++-- drivers/staging/iio/addac/adt7316.c | 134 drivers/staging/iio/addac/adt7316.h | 10 +- 4 files changed, 95 insertions(+), 179 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 167eafe3dd8c..435b65845174 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -12,60 +12,28 @@ #include #include #include +#include #include "adt7316.h" -/* - * adt7316 register access by I2C - */ -static int adt7316_i2c_read(void *client, u8 reg, u8 *data) -{ - struct i2c_client *cl = client; - int ret; - - ret = i2c_smbus_write_byte(cl, reg); - if (ret < 0) { - dev_err(&cl->dev, "I2C fail to select reg\n"); - return ret; - } - - ret = i2c_smbus_read_byte(client); - if (ret < 0) { - dev_err(&cl->dev, "I2C read error\n"); - return ret; - } - - *data = ret; - - return 0; -} - -static int adt7316_i2c_write(void *client, u8 reg, u8 data) -{ - struct i2c_client *cl = client; - int ret; - - ret = i2c_smbus_write_byte_data(cl, reg, data); - if (ret < 0) - dev_err(&cl->dev, "I2C write error\n"); - - return ret; -} - /* * device probe and remove */ - static int adt7316_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct adt7316_bus bus = { - .client = client, - .read = adt7316_i2c_read, - .write = adt7316_i2c_write, - }; + struct regmap *regmap; + + regmap = devm_regmap_init_i2c(client, &adt7316_regmap_config); + + if (IS_ERR(regmap)) { + dev_err(&client->dev, "Error initializing i2c regmap: %ld\n", + PTR_ERR(regmap)); + return PTR_ERR(regmap); + } - return adt7316_probe(&client->dev, &bus, id->name, client->irq); + return adt7316_probe(&client->dev, regmap, id ? id->name : NULL, +client->irq); } static const struct i2c_device_id adt7316_i2c_id[] = { diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 06c943c2cc01..203b5c3ada6e 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -11,74 +11,19 @@ #include #include #include +#include #include #include "adt7316.h" #define ADT7316_SPI_MAX_FREQ_HZ500 -#define ADT7316_SPI_CMD_READ 0x91 -#define ADT7316_SPI_CMD_WRITE 0x90 - -/* - * adt7316 register access by SPI - */ - -static int adt7316_spi_read(void *client, u8 reg, u8 *data) -{ - struct spi_device *spi_dev = client; - u8 cmd[2]; - int ret; - - cmd[0] = ADT7316_SPI_CMD_WRITE; - cmd[1] = reg; - - ret = spi_write(spi_dev, cmd, 2); - if (ret < 0) { - dev_err(&spi_dev->dev, "SPI fail to select reg\n"); - return ret; - } - - cmd[0] = ADT7316_SPI_CMD_READ; - - ret = spi_write_then_read(spi_dev, cmd, 1, data, 1); - if (ret < 0) { - dev_err(&spi_dev->dev, "SPI read data error\n"); - return ret; - } - - return 0; -} - -static int adt7316_spi_write(void *client, u8 reg, u8 val) -{ - struct spi_device *spi_dev = client; - u8 buf[ADT7316_REG_MAX_ADDR + 2]; - int ret = 0; - - buf[0] = ADT7316_SPI_CMD_WRITE; - buf[1] = reg; - buf[2] = val; - - ret = spi_write(spi_dev, buf, 3); - if (ret < 0) { - dev_err(&spi_dev->dev, "SPI write error\n"); - return ret; - } - - return ret; -} /* * device probe and remove */ - static int adt7316_spi_probe(struct spi_device *spi_dev) { - struct adt7316_bus bus = { - .client = spi_dev, - .read = adt7316_spi_read, - .write = adt7316_spi_write, - }; + struct regmap *regmap; /* don't exceed max specified SPI CLK frequency */ if (spi_dev->max_speed_hz > ADT7316_SPI_MAX_FREQ_HZ) { @@ -87,12 +32,19 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) return -EINVAL; } + regmap = devm_regmap_init_spi(spi_dev, &adt7316_regmap_config); + if (IS_ERR(regmap)) { + dev_err(&a
[PATCH v4 0/3] adt7316 regmap implementation
This patchset consist of some initial patches for heading towards the regmap implementation and also the final patch which enables the driver to use regmap API thus removing the redundant and common code. Changes in v4 -Rebase against iio's testing branch. Previous series was rebased against greg's testing branch. Changes in v3 -Fetch the changes from remote and rebase to have it in the current working directory. Changes in v2 -Change the val_bits to 8 and add two more patches having a different change before the final implemetation of regmap. Shreeya Patel (3): Staging: iio: adt7316: Remove irq from bus structure Staging: iio: adt7316: Remove multi read and write functions Staging: iio: adt7316: Add regmap support drivers/staging/iio/addac/adt7316-i2c.c | 97 ++- drivers/staging/iio/addac/adt7316-spi.c | 95 +++ drivers/staging/iio/addac/adt7316.c | 149 drivers/staging/iio/addac/adt7316.h | 15 +-- 4 files changed, 104 insertions(+), 252 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: rtl8723bs: Remove unnecessary comments.
The comments regarding memset are not needed in the files which have been modified since the necessary changes are already there in the files. Signed-off-by: Shreeya Patel --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 3 --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 3 --- drivers/staging/rtl8723bs/core/rtw_recv.c | 3 --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 3 --- 4 files changed, 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 6b77820..5b583f7 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -28,9 +28,6 @@ sint _rtw_init_mlme_priv(struct adapter *padapter) struct mlme_priv*pmlmepriv = &padapter->mlmepriv; sintres = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((u8 *)pmlmepriv, 0, sizeof(struct mlme_priv)); */ - pmlmepriv->nic_hdl = (u8 *)padapter; pmlmepriv->pscanned = NULL; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index b6d137f..ca35c1c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -474,9 +474,6 @@ int init_mlme_ext_priv(struct adapter *padapter) struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((u8 *)pmlmeext, 0, sizeof(struct mlme_ext_priv)); */ - pmlmeext->padapter = padapter; /* fill_fwpriv(padapter, &(pmlmeext->fwpriv)); */ diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 68a6303..9c08307 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -46,9 +46,6 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) union recv_frame *precvframe; sintres = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((unsigned char *)precvpriv, 0, sizeof (struct recv_priv)); */ - spin_lock_init(&precvpriv->lock); _rtw_init_queue(&precvpriv->free_recv_queue); diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 022f654..8cd05f8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -51,9 +51,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) struct xmit_frame *pxframe; sintres = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv)); */ - spin_lock_init(&pxmitpriv->lock); spin_lock_init(&pxmitpriv->lock_sctx); sema_init(&pxmitpriv->xmit_sema, 0); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: Remove unnecessary comments.
On Fri, 2017-09-29 at 23:10 +0200, Julia Lawall wrote: > > On Sat, 30 Sep 2017, Shreeya Patel wrote: > > > > > The comments regarding memset are not needed in the > > files which have been modified since the necessary changes > > are already there in the files. > The comments don't look very useful, but I don't understand "since > the > necessary changes are alread there in the files" > > julia The comments are put to notify that memset() is not required because vzalloc is used. But we don't need this comment as patches for this driver has already been applied to remove memset() code. Also I have checked the whole file, but there isn't any place where memset() needs to be removed. > > > > > > > > Signed-off-by: Shreeya Patel > > --- > > drivers/staging/rtl8723bs/core/rtw_mlme.c | 3 --- > > drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 3 --- > > drivers/staging/rtl8723bs/core/rtw_recv.c | 3 --- > > drivers/staging/rtl8723bs/core/rtw_xmit.c | 3 --- > > 4 files changed, 12 deletions(-) > > > > diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c > > b/drivers/staging/rtl8723bs/core/rtw_mlme.c > > index 6b77820..5b583f7 100644 > > --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c > > +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c > > @@ -28,9 +28,6 @@ sint _rtw_init_mlme_priv(struct adapter > > *padapter) > > struct mlme_priv *pmlmepriv = &padapter->mlmepriv; > > sintres = _SUCCESS; > > > > - /* We don't need to memset padapter->XXX to zero, because > > adapter is allocated by vzalloc(). */ > > - /* memset((u8 *)pmlmepriv, 0, sizeof(struct mlme_priv)); > > */ > > - > > pmlmepriv->nic_hdl = (u8 *)padapter; > > > > pmlmepriv->pscanned = NULL; > > diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c > > b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c > > index b6d137f..ca35c1c 100644 > > --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c > > +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c > > @@ -474,9 +474,6 @@ int init_mlme_ext_priv(struct adapter > > *padapter) > > struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); > > struct mlme_ext_info *pmlmeinfo = &(pmlmeext- > > >mlmext_info); > > > > - /* We don't need to memset padapter->XXX to zero, because > > adapter is allocated by vzalloc(). */ > > - /* memset((u8 *)pmlmeext, 0, sizeof(struct > > mlme_ext_priv)); */ > > - > > pmlmeext->padapter = padapter; > > > > /* fill_fwpriv(padapter, &(pmlmeext->fwpriv)); */ > > diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c > > b/drivers/staging/rtl8723bs/core/rtw_recv.c > > index 68a6303..9c08307 100644 > > --- a/drivers/staging/rtl8723bs/core/rtw_recv.c > > +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c > > @@ -46,9 +46,6 @@ sint _rtw_init_recv_priv(struct recv_priv > > *precvpriv, struct adapter *padapter) > > union recv_frame *precvframe; > > sintres = _SUCCESS; > > > > - /* We don't need to memset padapter->XXX to zero, because > > adapter is allocated by vzalloc(). */ > > - /* memset((unsigned char *)precvpriv, 0, sizeof > > (struct recv_priv)); */ > > - > > spin_lock_init(&precvpriv->lock); > > > > _rtw_init_queue(&precvpriv->free_recv_queue); > > diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c > > b/drivers/staging/rtl8723bs/core/rtw_xmit.c > > index 022f654..8cd05f8 100644 > > --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c > > +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c > > @@ -51,9 +51,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv > > *pxmitpriv, struct adapter *padapter) > > struct xmit_frame *pxframe; > > sintres = _SUCCESS; > > > > - /* We don't need to memset padapter->XXX to zero, because > > adapter is allocated by vzalloc(). */ > > - /* memset((unsigned char *)pxmitpriv, 0, sizeof(struct > > xmit_priv)); */ > > - > > spin_lock_init(&pxmitpriv->lock); > > spin_lock_init(&pxmitpriv->lock_sctx); > > sema_init(&pxmitpriv->xmit_sema, 0); > > -- > > 2.7.4 > > > > -- > > You received this message because you are subscribed to the Google > > Groups "outreachy-kernel" group. > > To unsubscribe from this group and stop receiving emails from it, > > send an email to outreachy-kernel+unsubscr...@googlegroups.com. > > To post to this group, send email to outreachy-kernel@googlegroups. > > com. > > To view this discussion on the web visit https://groups.google.com/ > > d/msgid/outreachy-kernel/1506711232-19670-1-git-send-email- > > shreeya.patel23498%40gmail.com. > > For more options, visit https://groups.google.com/d/optout. > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2] Staging: rtl8723bs: Remove unnecessary comments.
This patch removes unnecessary comments which are there to explain why call to memset is in comments. Both of the comments are not needed as they are not very useful. Signed-off-by: Shreeya Patel --- Changes in v2: -Remove some more unnecessary comments and make the commit message more appropriate. drivers/staging/rtl8723bs/core/rtw_mlme.c | 3 --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 3 --- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 2 -- drivers/staging/rtl8723bs/core/rtw_recv.c | 4 drivers/staging/rtl8723bs/core/rtw_xmit.c | 3 --- 5 files changed, 15 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 6b77820..5b583f7 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -28,9 +28,6 @@ sint _rtw_init_mlme_priv(struct adapter *padapter) struct mlme_priv*pmlmepriv = &padapter->mlmepriv; sintres = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((u8 *)pmlmepriv, 0, sizeof(struct mlme_priv)); */ - pmlmepriv->nic_hdl = (u8 *)padapter; pmlmepriv->pscanned = NULL; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index b6d137f..ca35c1c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -474,9 +474,6 @@ int init_mlme_ext_priv(struct adapter *padapter) struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((u8 *)pmlmeext, 0, sizeof(struct mlme_ext_priv)); */ - pmlmeext->padapter = padapter; /* fill_fwpriv(padapter, &(pmlmeext->fwpriv)); */ diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index aabdaaf..820a061 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -1193,8 +1193,6 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) void rtw_free_pwrctrl_priv(struct adapter *adapter) { - /* memset((unsigned char *)pwrctrlpriv, 0, sizeof(struct pwrctrl_priv)); */ - #ifdef CONFIG_PNO_SUPPORT if (pwrctrlpriv->pnlo_info != NULL) printk("** pnlo_info memory leak\n"); diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 68a6303..73e6e41 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -46,9 +46,6 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) union recv_frame *precvframe; sintres = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((unsigned char *)precvpriv, 0, sizeof (struct recv_priv)); */ - spin_lock_init(&precvpriv->lock); _rtw_init_queue(&precvpriv->free_recv_queue); @@ -65,7 +62,6 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) res = _FAIL; goto exit; } - /* memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); */ precvpriv->precv_frame_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ); /* precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + RXFRAME_ALIGN_SZ - */ diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 022f654..8cd05f8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -51,9 +51,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) struct xmit_frame *pxframe; sintres = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv)); */ - spin_lock_init(&pxmitpriv->lock); spin_lock_init(&pxmitpriv->lock_sctx); sema_init(&pxmitpriv->xmit_sema, 0); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v2] Staging: rtl8723bs: Remove unnecessary comments.
On Sat, 2017-09-30 at 21:06 +1000, Tobin C. Harding wrote: > Hi Shreeya, > > We don't usually add a period to the subject line for kernel patches. > (reason: we only have about > 52 characters for the commit brief description so best not to waste > any). > > On Sat, Sep 30, 2017 at 01:30:34PM +0530, Shreeya Patel wrote: > > > > This patch removes unnecessary comments which are there > > to explain why call to memset is in comments. Both of the > > comments are not needed as they are not very useful. > You may like to read Documentation/process/submitting-patches.rst > (specifically > section 2) for tips on writing your git log. > > Describe your changes in imperative mood, e.g. "make xyzzy do > frotz" > instead of "[This patch] makes xyzzy do frotz" or "[I] > changed xyzzy > to do frotz", as if you are giving orders to the codebase to > change > its behaviour. > > Good luck, > Tobin. Hello, Thanks for correcting me :) I'll do the necessary changes and will send as v3. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3] Staging: rtl8723bs: Remove unnecessary comments.
Remove unnecessary comments which are there to explain why call to memset is in comments. Both of the comments are not needed as they are not very useful. Signed-off-by: Shreeya Patel --- Changes in v2: -Remove some more unnecessary comments and make the commit message more appropriate. Changes in v3: -Make the commit message in imperative form. drivers/staging/rtl8723bs/core/rtw_mlme.c | 3 --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 3 --- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 2 -- drivers/staging/rtl8723bs/core/rtw_recv.c | 4 drivers/staging/rtl8723bs/core/rtw_xmit.c | 3 --- 5 files changed, 15 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 6b77820..5b583f7 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -28,9 +28,6 @@ sint _rtw_init_mlme_priv(struct adapter *padapter) struct mlme_priv*pmlmepriv = &padapter->mlmepriv; sintres = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((u8 *)pmlmepriv, 0, sizeof(struct mlme_priv)); */ - pmlmepriv->nic_hdl = (u8 *)padapter; pmlmepriv->pscanned = NULL; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index b6d137f..ca35c1c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -474,9 +474,6 @@ int init_mlme_ext_priv(struct adapter *padapter) struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((u8 *)pmlmeext, 0, sizeof(struct mlme_ext_priv)); */ - pmlmeext->padapter = padapter; /* fill_fwpriv(padapter, &(pmlmeext->fwpriv)); */ diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index aabdaaf..820a061 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -1193,8 +1193,6 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) void rtw_free_pwrctrl_priv(struct adapter *adapter) { - /* memset((unsigned char *)pwrctrlpriv, 0, sizeof(struct pwrctrl_priv)); */ - #ifdef CONFIG_PNO_SUPPORT if (pwrctrlpriv->pnlo_info != NULL) printk("** pnlo_info memory leak\n"); diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 68a6303..73e6e41 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -46,9 +46,6 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) union recv_frame *precvframe; sintres = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((unsigned char *)precvpriv, 0, sizeof (struct recv_priv)); */ - spin_lock_init(&precvpriv->lock); _rtw_init_queue(&precvpriv->free_recv_queue); @@ -65,7 +62,6 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) res = _FAIL; goto exit; } - /* memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); */ precvpriv->precv_frame_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ); /* precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + RXFRAME_ALIGN_SZ - */ diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 022f654..8cd05f8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -51,9 +51,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) struct xmit_frame *pxframe; sintres = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv)); */ - spin_lock_init(&pxmitpriv->lock); spin_lock_init(&pxmitpriv->lock_sctx); sema_init(&pxmitpriv->xmit_sema, 0); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v4] Staging: rtl8723bs: Remove unnecessary comments
Remove unnecessary comments which are there to explain why call to memset is in comments. Both of the comments are not needed as they are not very useful. Signed-off-by: Shreeya Patel --- Changes in v2: -Remove some more unnecessary comments and make the commit message more appropriate. Changes in v3: -Make the commit message in imperative form. Changes in v4: -Remove the period from the subject line. drivers/staging/rtl8723bs/core/rtw_mlme.c | 3 --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 3 --- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 2 -- drivers/staging/rtl8723bs/core/rtw_recv.c | 4 drivers/staging/rtl8723bs/core/rtw_xmit.c | 3 --- 5 files changed, 15 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 6b77820..5b583f7 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -28,9 +28,6 @@ sint _rtw_init_mlme_priv(struct adapter *padapter) struct mlme_priv*pmlmepriv = &padapter->mlmepriv; sintres = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((u8 *)pmlmepriv, 0, sizeof(struct mlme_priv)); */ - pmlmepriv->nic_hdl = (u8 *)padapter; pmlmepriv->pscanned = NULL; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index b6d137f..ca35c1c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -474,9 +474,6 @@ int init_mlme_ext_priv(struct adapter *padapter) struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((u8 *)pmlmeext, 0, sizeof(struct mlme_ext_priv)); */ - pmlmeext->padapter = padapter; /* fill_fwpriv(padapter, &(pmlmeext->fwpriv)); */ diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index aabdaaf..820a061 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -1193,8 +1193,6 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) void rtw_free_pwrctrl_priv(struct adapter *adapter) { - /* memset((unsigned char *)pwrctrlpriv, 0, sizeof(struct pwrctrl_priv)); */ - #ifdef CONFIG_PNO_SUPPORT if (pwrctrlpriv->pnlo_info != NULL) printk("** pnlo_info memory leak\n"); diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 68a6303..73e6e41 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -46,9 +46,6 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) union recv_frame *precvframe; sintres = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((unsigned char *)precvpriv, 0, sizeof (struct recv_priv)); */ - spin_lock_init(&precvpriv->lock); _rtw_init_queue(&precvpriv->free_recv_queue); @@ -65,7 +62,6 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) res = _FAIL; goto exit; } - /* memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); */ precvpriv->precv_frame_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ); /* precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + RXFRAME_ALIGN_SZ - */ diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 022f654..8cd05f8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -51,9 +51,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) struct xmit_frame *pxframe; sintres = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - /* memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv)); */ - spin_lock_init(&pxmitpriv->lock); spin_lock_init(&pxmitpriv->lock_sctx); sema_init(&pxmitpriv->xmit_sema, 0); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3] Staging: rtl8723bs: Remove unnecessary comments.
On Sun, 2017-10-01 at 09:42 +1100, Tobin C. Harding wrote: > On Sat, Sep 30, 2017 at 07:41:11PM +0530, Shreeya Patel wrote: > > > > Remove unnecessary comments which are there > > to explain why call to memset is in comments. Both of the > > comments are not needed as they are not very useful. > > > > > > Signed-off-by: Shreeya Patel > > --- > > Changes in v2: > > -Remove some more unnecessary comments and make the > > commit message more appropriate. > > > > Changes in v3: > > -Make the commit message in imperative form. > Well done. You forgot the period on the commit subject. Here is a > blog post you might like (it is > not kernel specific but useful still IMO). > > Good luck, > Tobin. I did the necessary changes and have sent it as v4. Thanks. > > > > > drivers/staging/rtl8723bs/core/rtw_mlme.c | 3 --- > > drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 3 --- > > drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 2 -- > > drivers/staging/rtl8723bs/core/rtw_recv.c | 4 > > drivers/staging/rtl8723bs/core/rtw_xmit.c | 3 --- > > 5 files changed, 15 deletions(-) > > > > diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c > > b/drivers/staging/rtl8723bs/core/rtw_mlme.c > > index 6b77820..5b583f7 100644 > > --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c > > +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c > > @@ -28,9 +28,6 @@ sint _rtw_init_mlme_priv(struct adapter > > *padapter) > > struct mlme_priv *pmlmepriv = &padapter->mlmepriv; > > sintres = _SUCCESS; > > > > - /* We don't need to memset padapter->XXX to zero, because > > adapter is allocated by vzalloc(). */ > > - /* memset((u8 *)pmlmepriv, 0, sizeof(struct mlme_priv)); > > */ > > - > > pmlmepriv->nic_hdl = (u8 *)padapter; > > > > pmlmepriv->pscanned = NULL; > > diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c > > b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c > > index b6d137f..ca35c1c 100644 > > --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c > > +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c > > @@ -474,9 +474,6 @@ int init_mlme_ext_priv(struct adapter > > *padapter) > > struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); > > struct mlme_ext_info *pmlmeinfo = &(pmlmeext- > > >mlmext_info); > > > > - /* We don't need to memset padapter->XXX to zero, because > > adapter is allocated by vzalloc(). */ > > - /* memset((u8 *)pmlmeext, 0, sizeof(struct > > mlme_ext_priv)); */ > > - > > pmlmeext->padapter = padapter; > > > > /* fill_fwpriv(padapter, &(pmlmeext->fwpriv)); */ > > diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c > > b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c > > index aabdaaf..820a061 100644 > > --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c > > +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c > > @@ -1193,8 +1193,6 @@ void rtw_init_pwrctrl_priv(struct adapter > > *padapter) > > > > void rtw_free_pwrctrl_priv(struct adapter *adapter) > > { > > - /* memset((unsigned char *)pwrctrlpriv, 0, sizeof(struct > > pwrctrl_priv)); */ > > - > > #ifdef CONFIG_PNO_SUPPORT > > if (pwrctrlpriv->pnlo_info != NULL) > > printk("** pnlo_info memory leak\n"); > > diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c > > b/drivers/staging/rtl8723bs/core/rtw_recv.c > > index 68a6303..73e6e41 100644 > > --- a/drivers/staging/rtl8723bs/core/rtw_recv.c > > +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c > > @@ -46,9 +46,6 @@ sint _rtw_init_recv_priv(struct recv_priv > > *precvpriv, struct adapter *padapter) > > union recv_frame *precvframe; > > sintres = _SUCCESS; > > > > - /* We don't need to memset padapter->XXX to zero, because > > adapter is allocated by vzalloc(). */ > > - /* memset((unsigned char *)precvpriv, 0, sizeof > > (struct recv_priv)); */ > > - > > spin_lock_init(&precvpriv->lock); > > > > _rtw_init_queue(&precvpriv->free_recv_queue); > > @@ -65,7 +62,6 @@ sint _rtw_init_recv_priv(struct recv_priv > > *precvpriv, struct adapter *padapter) > > res = _FAIL; > > goto exit; > > } > > - /* memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME > > * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); */ > >
[PATCH] Staging: rtlwifi: Remove NULL pointer dereference
Remove NULL pointer dereference as it results in undefined behaviour, and will usually lead to a runtime error. Signed-off-by: Shreeya Patel --- drivers/staging/rtlwifi/base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c index b88b0e8..5bb8f98 100644 --- a/drivers/staging/rtlwifi/base.c +++ b/drivers/staging/rtlwifi/base.c @@ -781,7 +781,7 @@ static void _rtl_txrate_selectmode(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - struct rtl_sta_info *sta_entry = NULL; + struct rtl_sta_info *sta_entry; u8 ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC); if (sta) { -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Staging: rtlwifi: Remove NULL pointer dereference
On Tue, 2017-10-10 at 11:06 +1100, Tobin C. Harding wrote: > On Tue, Oct 10, 2017 at 02:48:58AM +0530, Shreeya Patel wrote: > > > > Remove NULL pointer dereference as it results in undefined > > behaviour, and will usually lead to a runtime error. > The diff does not show any pointer dereference so it is hard to > understand what you are trying to do > with this patch. > > > > > Signed-off-by: Shreeya Patel > > --- > > drivers/staging/rtlwifi/base.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/staging/rtlwifi/base.c > > b/drivers/staging/rtlwifi/base.c > > index b88b0e8..5bb8f98 100644 > > --- a/drivers/staging/rtlwifi/base.c > > +++ b/drivers/staging/rtlwifi/base.c > > @@ -781,7 +781,7 @@ static void _rtl_txrate_selectmode(struct > > ieee80211_hw *hw, > > > > struct rtl_priv *rtlpriv = rtl_priv(hw); > > struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); > > - struct rtl_sta_info *sta_entry = NULL; > > + struct rtl_sta_info *sta_entry; > Now the pointer just has garbage in it instead of the testable value > of NULL. If you are concerned > with the dereference perhaps you could add a NULL check, again it's > hard to say without seeing the > code. Hello, Thanks for making me understand. Here is the code after declaration and initialization of sta_entry. Will it be good to add a NULL check in this case? struct rtl_sta_info *sta_entry = NULL; u8 ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC); if (sta) { sta_entry = (struct rtl_sta_info *)sta->drv_priv; ratr_index = sta_entry->ratr_index; } If we are making a pointer point to NULL then what if any other variable is already pointing to NULL for some other purpose. Instead, removing initialization will be good right? > > It is hard to see how this patch is correct though. > > Hope this helps, > Tobin. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Staging: rtlwifi: Remove NULL pointer dereference
On Thu, 2017-10-12 at 13:16 +1100, Tobin C. Harding wrote: > On Wed, Oct 11, 2017 at 06:02:47PM +0530, Shreeya Patel wrote: > > > > On Tue, 2017-10-10 at 11:06 +1100, Tobin C. Harding wrote: > > > > > > On Tue, Oct 10, 2017 at 02:48:58AM +0530, Shreeya Patel wrote: > > > > > > > > > > > > Remove NULL pointer dereference as it results in undefined > > > > behaviour, and will usually lead to a runtime error. > > > The diff does not show any pointer dereference so it is hard to > > > understand what you are trying to do > > > with this patch. > > > > > > > > > > > > > > > Signed-off-by: Shreeya Patel > > > > --- > > > > drivers/staging/rtlwifi/base.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/staging/rtlwifi/base.c > > > > b/drivers/staging/rtlwifi/base.c > > > > index b88b0e8..5bb8f98 100644 > > > > --- a/drivers/staging/rtlwifi/base.c > > > > +++ b/drivers/staging/rtlwifi/base.c > > > > @@ -781,7 +781,7 @@ static void _rtl_txrate_selectmode(struct > > > > ieee80211_hw *hw, > > > > > > > > struct rtl_priv *rtlpriv = rtl_priv(hw); > > > > struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); > > > > - struct rtl_sta_info *sta_entry = NULL; > > > > + struct rtl_sta_info *sta_entry; > > > Now the pointer just has garbage in it instead of the testable > > > value > > > of NULL. If you are concerned > > > with the dereference perhaps you could add a NULL check, again > > > it's > > > hard to say without seeing the > > > code. > > Hello, > > > > Thanks for making me understand. > > > > Here is the code after declaration and initialization of > > sta_entry. > > Will it be good to add a NULL check in this case? > > > > struct rtl_sta_info *sta_entry = NULL; > > u8 ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC); > > > > if (sta) { > > sta_entry = (struct rtl_sta_info *)sta->drv_priv; > > ratr_index = sta_entry->ratr_index; > > } > Later in this function the macro SET_RATE_ID() is called, it relies > on sta_entry being NULL if it > was not explicitly set. > > Here is the macro; > > #define SET_RATE_ID(rate_id) \ > ((rtlpriv->cfg->spec_ver & RTL_SPEC_NEW_RATEID) ? \ > rtl_mrate_idx_to_arfr_id(hw, rate_id, \ > (sta_entry ? sta_entry->wireless_mode : > \ > WIRELESS_MODE_G)) :\ > rate_id) > > > > > If we are making a pointer point to NULL then what if any other > > variable is already pointing to NULL for some other purpose. > > Instead, removing initialization will be good right? > A pointer does not _point_ to NULL as such. A NULL pointer has a > value of all zero bytes. Have you > read (and completed all the exercises) in KnR > > https://en.wikipedia.org/wiki/The_C_Programming_Language > > It is, in my opinion, one of the best tech books ever written. If you > have any holes in your C > knowledge, this is the place to start. Thank you so much. I will make sure that I don't make the same mistake again. > > Good luck, > Tobin. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: irda: Remove trailing whitespace errors
Remove trailing whitespace checkpatch errors. Signed-off-by: Shreeya Patel --- drivers/staging/irda/drivers/esi-sir.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/irda/drivers/esi-sir.c b/drivers/staging/irda/drivers/esi-sir.c index 019a3e8..eb7aa64 100644 --- a/drivers/staging/irda/drivers/esi-sir.c +++ b/drivers/staging/irda/drivers/esi-sir.c @@ -1,5 +1,5 @@ /* - * + * * Filename: esi.c * Version: 1.6 * Description: Driver for the Extended Systems JetEye PC dongle @@ -8,25 +8,25 @@ * Created at:Sat Feb 21 18:54:38 1998 * Modified at: Sun Oct 27 22:01:04 2002 * Modified by: Martin Diehl - * + * * Copyright (c) 1999 Dag Brattli, , * Copyright (c) 1998 Thomas Davis, , * Copyright (c) 2002 Martin Diehl, , * All Rights Reserved. - * - * 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 + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License + * + * You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. - * + * / #include @@ -97,7 +97,7 @@ static int esi_change_speed(struct sir_dev *dev, unsigned speed) { int ret = 0; int dtr, rts; - + switch (speed) { case 19200: dtr = TRUE; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: speakup: Replace symbolic permissions with octal permissions
Resolve following checkpatch issue: WARNING: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. Signed-off-by: Shreeya Patel --- drivers/staging/speakup/speakup_bns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/speakup/speakup_bns.c b/drivers/staging/speakup/speakup_bns.c index 60bcf0d..402b0fb 100644 --- a/drivers/staging/speakup/speakup_bns.c +++ b/drivers/staging/speakup/speakup_bns.c @@ -120,7 +120,7 @@ static struct spk_synth synth_bns = { }; module_param_named(ser, synth_bns.ser, int, 0444); -module_param_named(dev, synth_bns.dev_name, charp, S_IRUGO); +module_param_named(dev, synth_bns.dev_name, charp, 0444); module_param_named(start, synth_bns.startup, short, 0444); MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0-based)."); -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: speakup: Replace symbolic permissions with octal permissions
On Fri, 2017-10-13 at 23:44 +0200, Julia Lawall wrote: > > On Sat, 14 Oct 2017, Shreeya Patel wrote: > > > > > Resolve following checkpatch issue: > > WARNING: Symbolic permissions 'S_IRUGO' are not preferred. > > Consider using octal permissions '0444'. > > > > Signed-off-by: Shreeya Patel > > --- > > drivers/staging/speakup/speakup_bns.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/staging/speakup/speakup_bns.c > > b/drivers/staging/speakup/speakup_bns.c > > index 60bcf0d..402b0fb 100644 > > --- a/drivers/staging/speakup/speakup_bns.c > > +++ b/drivers/staging/speakup/speakup_bns.c > > @@ -120,7 +120,7 @@ static struct spk_synth synth_bns = { > > }; > > > > module_param_named(ser, synth_bns.ser, int, 0444); > > -module_param_named(dev, synth_bns.dev_name, charp, S_IRUGO); > > +module_param_named(dev, synth_bns.dev_name, charp, 0444); > This change is already made. You need to update your staging tree. > > julia Oh, ok i'll do it. > > > > > module_param_named(start, synth_bns.startup, short, 0444); > > > > MODULE_PARM_DESC(ser, "Set the serial port for the synthesizer (0- > > based)."); > > -- > > 2.7.4 > > > > -- > > You received this message because you are subscribed to the Google > > Groups "outreachy-kernel" group. > > To unsubscribe from this group and stop receiving emails from it, > > send an email to outreachy-kernel+unsubscr...@googlegroups.com. > > To post to this group, send email to outreachy-kernel@googlegroups. > > com. > > To view this discussion on the web visit https://groups.google.com/ > > d/msgid/outreachy-kernel/1507930425-5471-1-git-send-email- > > shreeya.patel23498%40gmail.com. > > For more options, visit https://groups.google.com/d/optout. > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: rtl8723bs: Merge assignment with return
Merge the assignment and return statements to return the value directly. Done using the following semantic patch by coccinelle. @@ local idexpression ret; expression e; @@ -ret = +return e; -return ret; Also, remove the variable declaration and some braces that became useless after the merge. Signed-off-by: Shreeya Patel --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 53 +++- 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 9a4c248..93ac083 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -157,23 +157,20 @@ static u32 _cvrt2ftaddr(const u32 addr, u8 *pdeviceId, u16 *poffset) static u8 sdio_read8(struct intf_hdl *pintfhdl, u32 addr) { u32 ftaddr; - u8 val; - ftaddr = _cvrt2ftaddr(addr, NULL, NULL); - val = sd_read8(pintfhdl, ftaddr, NULL); - return val; + + return sd_read8(pintfhdl, ftaddr, NULL); } static u16 sdio_read16(struct intf_hdl *pintfhdl, u32 addr) { u32 ftaddr; - u16 val; __le16 le_tmp; ftaddr = _cvrt2ftaddr(addr, NULL, NULL); sd_cmd52_read(pintfhdl, ftaddr, 2, (u8 *)&le_tmp); - val = le16_to_cpu(le_tmp); - return val; + + return le16_to_cpu(le_tmp); } static u32 sdio_read32(struct intf_hdl *pintfhdl, u32 addr) @@ -201,8 +198,7 @@ static u32 sdio_read32(struct intf_hdl *pintfhdl, u32 addr) #ifdef SDIO_DEBUG_IO if (!err) { #endif - val = le32_to_cpu(le_tmp); - return val; + return le32_to_cpu(le_tmp); #ifdef SDIO_DEBUG_IO } @@ -254,10 +250,8 @@ static s32 sdio_readN(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pbuf) ((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) || (false == bMacPwrCtrlOn) || (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) - ) { - err = sd_cmd52_read(pintfhdl, ftaddr, cnt, pbuf); - return err; - } + ) + return sd_cmd52_read(pintfhdl, ftaddr, cnt, pbuf); /* 4 bytes alignment */ shift = ftaddr & 0x3; @@ -295,14 +289,11 @@ static s32 sdio_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) static s32 sdio_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) { u32 ftaddr; - s32 err; __le16 le_tmp; ftaddr = _cvrt2ftaddr(addr, NULL, NULL); le_tmp = cpu_to_le16(val); - err = sd_cmd52_write(pintfhdl, ftaddr, 2, (u8 *)&le_tmp); - - return err; + return sd_cmd52_write(pintfhdl, ftaddr, 2, (u8 *)&le_tmp); } static s32 sdio_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) @@ -328,8 +319,8 @@ static s32 sdio_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) (adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) ) { le_tmp = cpu_to_le32(val); - err = sd_cmd52_write(pintfhdl, ftaddr, 4, (u8 *)&le_tmp); - return err; + + return sd_cmd52_write(pintfhdl, ftaddr, 4, (u8 *)&le_tmp); } /* 4 bytes alignment */ @@ -363,10 +354,8 @@ static s32 sdio_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pbuf) ((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) || (false == bMacPwrCtrlOn) || (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) - ) { - err = sd_cmd52_write(pintfhdl, ftaddr, cnt, pbuf); - return err; - } + ) + return sd_cmd52_write(pintfhdl, ftaddr, cnt, pbuf); shift = ftaddr & 0x3; if (shift == 0) { @@ -588,10 +577,8 @@ static s32 _sdio_local_read( HalSdioGetCmdAddr8723BSdio(padapter, SDIO_LOCAL_DEVICE_ID, addr, &addr); rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); - if (false == bMacPwrCtrlOn) { - err = _sd_cmd52_read(pintfhdl, addr, cnt, pbuf); - return err; - } + if (false == bMacPwrCtrlOn) + return _sd_cmd52_read(pintfhdl, addr, cnt, pbuf); n = RND4(cnt); ptmpbuf = rtw_malloc(n); @@ -631,10 +618,8 @@ s32 sdio_local_read( if ( (false == bMacPwrCtrlOn) || (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) - ) { - err = sd_cmd52_read(pintfhdl, addr, cnt, pbuf); - return err; - } + ) + return sd_cmd52_read(pintfhdl, addr, cnt, pbuf); n = RND4(cnt); ptmpbuf = rtw_malloc(n); @@ -679,10 +664,8 @@ s32 sdio_local_write( if ( (false == bMacPwrCtrlOn) || (true == adapter_to_pwrctl(padapter)
[PATCH 0/4] Remove checkpatch warnings
This patchset removes some warnings generated by checkpatch for cleanup of the rtl8723bs driver. Also some additional cleanups are introduced in the *[1/4] and *[3/4] patches to make the code according to the kernel coding style. Shreeya Patel (4): Staging: rtl8723bs: Replace true with x and false with !x Staging: rtl8723bs: Change names to conform to the kernel code Staging: rtl8723bs: Change condition to assignment Staging: rtl8723bs: Use !x instead of NULL comparison drivers/staging/rtl8723bs/hal/sdio_ops.c | 722 +++ 1 file changed, 360 insertions(+), 362 deletions(-) -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/4] Staging: rtl8723bs: Replace true with x and false with !x
Replace true and false keywords with "x" and "!x" respectively to follow the kernel coding style. Signed-off-by: Shreeya Patel --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 30 ++ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 93ac083..aa52c31 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -191,8 +191,8 @@ static u32 sdio_read32(struct intf_hdl *pintfhdl, u32 addr) rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); if ( ((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) || - (false == bMacPwrCtrlOn) || - (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) + (!bMacPwrCtrlOn) || + (adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) ) { err = sd_cmd52_read(pintfhdl, ftaddr, 4, (u8 *)&le_tmp); #ifdef SDIO_DEBUG_IO @@ -248,8 +248,8 @@ static s32 sdio_readN(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pbuf) rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); if ( ((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) || - (false == bMacPwrCtrlOn) || - (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) + (!bMacPwrCtrlOn) || + (adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) ) return sd_cmd52_read(pintfhdl, ftaddr, cnt, pbuf); @@ -352,8 +352,8 @@ static s32 sdio_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pbuf) rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); if ( ((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) || - (false == bMacPwrCtrlOn) || - (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) + (!bMacPwrCtrlOn) || + (adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) ) return sd_cmd52_write(pintfhdl, ftaddr, cnt, pbuf); @@ -513,7 +513,7 @@ static u32 sdio_write_port( padapter = pintfhdl->padapter; psdio = &adapter_to_dvobj(padapter)->intf_data; - if (padapter->hw_init_completed == false) { + if (!padapter->hw_init_completed) { DBG_871X("%s [addr = 0x%x cnt =%d] padapter->hw_init_completed == false\n", __func__, addr, cnt); return _FAIL; } @@ -577,7 +577,7 @@ static s32 _sdio_local_read( HalSdioGetCmdAddr8723BSdio(padapter, SDIO_LOCAL_DEVICE_ID, addr, &addr); rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); - if (false == bMacPwrCtrlOn) + if (!bMacPwrCtrlOn) return _sd_cmd52_read(pintfhdl, addr, cnt, pbuf); n = RND4(cnt); @@ -616,8 +616,8 @@ s32 sdio_local_read( rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); if ( - (false == bMacPwrCtrlOn) || - (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) + (!bMacPwrCtrlOn) || + (adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) ) return sd_cmd52_read(pintfhdl, addr, cnt, pbuf); @@ -662,8 +662,8 @@ s32 sdio_local_write( rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); if ( - (false == bMacPwrCtrlOn) || - (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) + (!bMacPwrCtrlOn) || + (adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) ) return sd_cmd52_write(pintfhdl, addr, cnt, pbuf); @@ -843,8 +843,7 @@ void ClearInterrupt8723BSdio(struct adapter *padapter) struct hal_com_data *pHalData; u8 *clear; - - if (true == padapter->bSurpriseRemoved) + if (padapter->bSurpriseRemoved) return; pHalData = GET_HAL_DATA(padapter); @@ -1161,8 +1160,7 @@ void sd_int_hdl(struct adapter *padapter) if ( - (padapter->bDriverStopped == true) || - (padapter->bSurpriseRemoved == true) + (padapter->bDriverStopped) || (padapter->bSurpriseRemoved) ) return; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/4] Staging: rtl8723bs: Change names to conform to the kernel code
Change names of some variables and functions to conform to the kernel coding style. Signed-off-by: Shreeya Patel --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 714 +++ 1 file changed, 357 insertions(+), 357 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index aa52c31..00b20c0 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -28,35 +28,35 @@ /* Creadted by Roger, 2011.01.31. */ /* */ static void HalSdioGetCmdAddr8723BSdio( - struct adapter *padapter, - u8 DeviceID, - u32 Addr, - u32 *pCmdAddr + struct adapter *adapter, + u8 device_id, + u32 addr, + u32 *cmdaddr ) { - switch (DeviceID) { + switch (device_id) { case SDIO_LOCAL_DEVICE_ID: - *pCmdAddr = ((SDIO_LOCAL_DEVICE_ID << 13) | (Addr & SDIO_LOCAL_MSK)); + *cmdaddr = ((SDIO_LOCAL_DEVICE_ID << 13) | (addr & SDIO_LOCAL_MSK)); break; case WLAN_IOREG_DEVICE_ID: - *pCmdAddr = ((WLAN_IOREG_DEVICE_ID << 13) | (Addr & WLAN_IOREG_MSK)); + *cmdaddr = ((WLAN_IOREG_DEVICE_ID << 13) | (addr & WLAN_IOREG_MSK)); break; case WLAN_TX_HIQ_DEVICE_ID: - *pCmdAddr = ((WLAN_TX_HIQ_DEVICE_ID << 13) | (Addr & WLAN_FIFO_MSK)); + *cmdaddr = ((WLAN_TX_HIQ_DEVICE_ID << 13) | (addr & WLAN_FIFO_MSK)); break; case WLAN_TX_MIQ_DEVICE_ID: - *pCmdAddr = ((WLAN_TX_MIQ_DEVICE_ID << 13) | (Addr & WLAN_FIFO_MSK)); + *cmdaddr = ((WLAN_TX_MIQ_DEVICE_ID << 13) | (addr & WLAN_FIFO_MSK)); break; case WLAN_TX_LOQ_DEVICE_ID: - *pCmdAddr = ((WLAN_TX_LOQ_DEVICE_ID << 13) | (Addr & WLAN_FIFO_MSK)); + *cmdaddr = ((WLAN_TX_LOQ_DEVICE_ID << 13) | (addr & WLAN_FIFO_MSK)); break; case WLAN_RX0FF_DEVICE_ID: - *pCmdAddr = ((WLAN_RX0FF_DEVICE_ID << 13) | (Addr & WLAN_RX0FF_MSK)); + *cmdaddr = ((WLAN_RX0FF_DEVICE_ID << 13) | (addr & WLAN_RX0FF_MSK)); break; default: @@ -66,64 +66,64 @@ static void HalSdioGetCmdAddr8723BSdio( static u8 get_deviceid(u32 addr) { - u8 devideId; - u16 pseudoId; + u8 devide_id; + u16 pseudo_id; - pseudoId = (u16)(addr >> 16); - switch (pseudoId) { + pseudo_id = (u16)(addr >> 16); + switch (pseudo_id) { case 0x1025: - devideId = SDIO_LOCAL_DEVICE_ID; + devide_id = SDIO_LOCAL_DEVICE_ID; break; case 0x1026: - devideId = WLAN_IOREG_DEVICE_ID; + devide_id = WLAN_IOREG_DEVICE_ID; break; /* case 0x1027: */ -/* devideId = SDIO_FIRMWARE_FIFO; */ +/* devide_id = SDIO_FIRMWARE_FIFO; */ /* break; */ case 0x1031: - devideId = WLAN_TX_HIQ_DEVICE_ID; + devide_id = WLAN_TX_HIQ_DEVICE_ID; break; case 0x1032: - devideId = WLAN_TX_MIQ_DEVICE_ID; + devide_id = WLAN_TX_MIQ_DEVICE_ID; break; case 0x1033: - devideId = WLAN_TX_LOQ_DEVICE_ID; + devide_id = WLAN_TX_LOQ_DEVICE_ID; break; case 0x1034: - devideId = WLAN_RX0FF_DEVICE_ID; + devide_id = WLAN_RX0FF_DEVICE_ID; break; default: -/* devideId = (u8)((addr >> 13) & 0xF); */ - devideId = WLAN_IOREG_DEVICE_ID; +/* devide_id = (u8)((addr >> 13) & 0xF); */ + devide_id = WLAN_IOREG_DEVICE_ID; break; } - return devideId; + return devide_id; } /* * Ref: *HalSdioGetCmdAddr8723BSdio() */ -static u32 _cvrt2ftaddr(const u32 addr, u8 *pdeviceId, u16 *poffset) +static u32 _cvrt2ftaddr(const u32 addr, u8 *pdevice_id, u16 *poffset) { - u8 deviceId; + u8 device_id; u16 offset; u32 ftaddr; - deviceId = get_deviceid(addr); + device_id = get_deviceid(addr); offset = 0; - switch (deviceId) { + switch (device_id) { case SDIO_LOCAL_DEVICE_ID: offset = addr & SDIO_LOCAL_MSK; break; @@ -140,44 +140,44 @@ static u32 _cvrt2ftaddr(const u32 addr, u8 *pdeviceId, u16 *poffset) case WLAN_IOREG_DEVICE_ID: default: - deviceId = WLAN_IOREG_DEVICE_ID; + device_id = WLAN_IOREG_DEVICE_ID; offset = addr & WLAN_IOREG_MSK; break;
[PATCH 3/4] Staging: rtl8723bs: Change condition to assignment
Change the conditional operator to assignment as it is not a conditional statement. Signed-off-by: Shreeya Patel --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 00b20c0..314b31f 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -460,7 +460,7 @@ static u32 sdio_read_port( if (mem == NULL) { DBG_8192C(KERN_WARNING "%s: allocate memory %d bytes fail!\n", __func__, cnt); mem = oldmem; - oldmem == NULL; + oldmem = NULL; } #else /* in this case, caller should gurante the buffer is big enough */ -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 4/4] Staging: rtl8723bs: Use !x instead of NULL comparison
If "x" is compared to NULL, use "!x" instead of it, so as to follow the kernel coding style. Signed-off-by: Shreeya Patel --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 314b31f..08e6a7b 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -215,7 +215,7 @@ static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr) u8 *tmpbuf; tmpbuf = rtw_malloc(8); - if (NULL == tmpbuf) { + if (!tmpbuf) { DBG_8192C(KERN_ERR "%s: Allocate memory FAIL!(size =8) addr = 0x%x\n", __func__, addr); return SDIO_ERR_VAL32; } @@ -264,7 +264,7 @@ static s32 sdio_readN(struct intf_hdl *intfhdl, u32 addr, u32 cnt, u8 *buf) ftaddr &= ~(u16)0x3; n = cnt + shift; tmpbuf = rtw_malloc(n); - if (NULL == tmpbuf) + if (!tmpbuf) return -1; err = sd_read(intfhdl, ftaddr, n, tmpbuf); @@ -367,7 +367,7 @@ static s32 sdio_writeN(struct intf_hdl *intfhdl, u32 addr, u32 cnt, u8 *buf) ftaddr &= ~(u16)0x3; n = cnt + shift; tmpbuf = rtw_malloc(n); - if (NULL == tmpbuf) + if (!tmpbuf) return -1; err = sd_read(intfhdl, ftaddr, 4, tmpbuf); if (err) { @@ -457,7 +457,7 @@ static u32 sdio_read_port( #ifdef SDIO_DYNAMIC_ALLOC_MEM oldmem = mem; mem = rtw_malloc(cnt); - if (mem == NULL) { + if (!mem) { DBG_8192C(KERN_WARNING "%s: allocate memory %d bytes fail!\n", __func__, cnt); mem = oldmem; oldmem = NULL; @@ -745,7 +745,7 @@ static s32 ReadInterrupt8723BSdio(struct adapter *adapter, u32 *phisr) u8 val8, hisr_len; - if (phisr == NULL) + if (!phisr) return false; himr = GET_HAL_DATA(adapter)->sdio_himr; @@ -969,13 +969,13 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter *adapter, u32 size) /* 3 1. alloc recvbuf */ recv_priv = &adapter->recvpriv; recvbuf = rtw_dequeue_recvbuf(&recv_priv->free_recv_buf_queue); - if (recvbuf == NULL) { + if (!recvbuf) { DBG_871X_LEVEL(_drv_err_, "%s: alloc recvbuf FAIL!\n", __func__); return NULL; } /* 3 2. alloc skb */ - if (recvbuf->pskb == NULL) { + if (!recvbuf->pskb) { SIZE_PTR tmpaddr = 0; SIZE_PTR alignment = 0; @@ -989,7 +989,7 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter *adapter, u32 size) skb_reserve(recvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); } - if (recvbuf->pskb == NULL) { + if (!recvbuf->pskb) { DBG_871X("%s: alloc_skb fail! read =%d\n", __func__, readsize); return NULL; } @@ -1247,7 +1247,7 @@ u8 RecvOnePkt(struct adapter *adapter, u32 size) DBG_871X("+%s: size: %d+\n", __func__, size); - if (adapter == NULL) { + if (!adapter) { DBG_871X(KERN_ERR "%s: adapter is NULL!\n", __func__); return false; } -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 1/4] Staging: rtl8723bs: Replace true with x and false with !x
On Sun, 2017-12-17 at 01:45 -0800, Joe Perches wrote: > On Sun, 2017-12-17 at 15:07 +0530, Shreeya Patel wrote: > > > > Replace true and false keywords with "x" and "!x" > > respectively to follow the kernel coding style. > [] > > > > diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c > > b/drivers/staging/rtl8723bs/hal/sdio_ops.c > [] > > > > @@ -191,8 +191,8 @@ static u32 sdio_read32(struct intf_hdl > > *pintfhdl, u32 addr) > > rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, > > &bMacPwrCtrlOn); > > if ( > > ((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < > > 0x100)) || > > - (false == bMacPwrCtrlOn) || > > - (true == adapter_to_pwrctl(padapter)- > > >bFwCurrentInPSMode) > > + (!bMacPwrCtrlOn) || > When you do these sorts of conversions can you > please remove the unnecessary parentheses too? > Yes, surely I'll keep this in mind. Thank you ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: irda: Do not check for NOT NULL before kfree()
Do not check for NOT NULL before calling kfree because if the pointer is NULL, no action occurs. Done using the following semantic patch by coccinelle. @@ expression ptr; @@ - if (ptr != NULL) { kfree(ptr); ptr = NULL; - } The semantic patch has the effect of adding an assignment of ptr to NULL in the case where ptr is NULL already. Signed-off-by: Shreeya Patel --- drivers/staging/irda/net/irnet/irnet_irda.c | 28 ++-- drivers/staging/irda/net/irnet/irnet_ppp.c | 10 -- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/staging/irda/net/irnet/irnet_irda.c b/drivers/staging/irda/net/irnet/irnet_irda.c index e390bce..9fb79fe 100644 --- a/drivers/staging/irda/net/irnet/irnet_irda.c +++ b/drivers/staging/irda/net/irnet/irnet_irda.c @@ -659,13 +659,9 @@ irda_irnet_destroy(irnet_socket * self) self->iriap = NULL; } - /* Cleanup eventual discoveries from connection attempt or control channel */ - if(self->discoveries != NULL) -{ - /* Cleanup our copy of the discovery log */ - kfree(self->discoveries); - self->discoveries = NULL; -} + /* Cleanup our copy of the discovery log */ + kfree(self->discoveries); + self->discoveries = NULL; /* Close our IrTTP connection */ if(self->tsap) @@ -874,11 +870,9 @@ irnet_connect_socket(irnet_socket *server, iriap_close(new->iriap); new->iriap = NULL; } - if(new->discoveries != NULL) -{ - kfree(new->discoveries); - new->discoveries = NULL; -} + + kfree(new->discoveries); + new->discoveries = NULL; #ifdef CONNECT_INDIC_KICK /* As currently we don't block packets in ppp_irnet_send() while passive, @@ -1605,12 +1599,10 @@ irnet_discovervalue_confirm(int result, /* No more items : remove the log and signal termination */ DEBUG(IRDA_OCB_INFO, "Cleaning up log (0x%p)\n", self->discoveries); - if(self->discoveries != NULL) -{ - /* Cleanup our copy of the discovery log */ - kfree(self->discoveries); - self->discoveries = NULL; -} + + /* Cleanup our copy of the discovery log */ + kfree(self->discoveries); + self->discoveries = NULL; self->disco_number = -1; /* Check out what we found */ diff --git a/drivers/staging/irda/net/irnet/irnet_ppp.c b/drivers/staging/irda/net/irnet/irnet_ppp.c index 7025dcb..855ce58 100644 --- a/drivers/staging/irda/net/irnet/irnet_ppp.c +++ b/drivers/staging/irda/net/irnet/irnet_ppp.c @@ -259,12 +259,10 @@ irnet_read_discovery_log(irnet_socket *ap, char *event, int buf_size) /* No more items : remove the log and signal termination */ DEBUG(CTRL_INFO, "Cleaning up log (0x%p)\n", ap->discoveries); - if(ap->discoveries != NULL) - { - /* Cleanup our copy of the discovery log */ - kfree(ap->discoveries); - ap->discoveries = NULL; - } + + /* Cleanup our copy of the discovery log */ + kfree(ap->discoveries); + ap->discoveries = NULL; ap->disco_number = -1; } -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Staging: irda: Do not check for NOT NULL before kfree()
On Mon, 2017-12-18 at 11:20 -0800, Stephen Hemminger wrote: > On Tue, 19 Dec 2017 00:41:30 +0530 > Shreeya Patel wrote: > > > > > Do not check for NOT NULL before calling kfree because if the > > pointer is NULL, no action occurs. > > Done using the following semantic patch by coccinelle. > > > > @@ > > expression ptr; > > @@ > > > > - if (ptr != NULL) { > > kfree(ptr); > > ptr = NULL; > > - } > > > > The semantic patch has the effect of adding an assignment > > of ptr to NULL in the case where ptr is NULL already. > > > > Signed-off-by: Shreeya Patel > Please read drivers/staging/irda/TODO Oh, I was not knowing about it. Thank you > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: lustre: Use kmemdup() instead of kzalloc and memcpy
Replace calls to kzalloc or kmalloc followed by a memcpy with a direct call to kmemdup to shorten the code. The Coccinelle semantic patch used to make this change is as follows: @@ expression from,to,size,flag; statement S; @@ - to = \(kmalloc\|kzalloc\)(size,flag); + to = kmemdup(from,size,flag); if (to==NULL || ...) S - memcpy(to, from, size); Signed-off-by: Shreeya Patel --- drivers/staging/lustre/lnet/lnet/api-ni.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index f9ed697..36ea14e 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1271,15 +1271,14 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf) lnd_tunables = (struct lnet_ioctl_config_lnd_tunables *)conf->cfg_bulk; if (lnd_tunables) { - ni->ni_lnd_tunables = kzalloc(sizeof(*ni->ni_lnd_tunables), + ni->ni_lnd_tunables = kmemdup(lnd_tunables, + sizeof(*ni->ni_lnd_tunables), GFP_NOFS); if (!ni->ni_lnd_tunables) { mutex_unlock(&the_lnet.ln_lnd_mutex); rc = -ENOMEM; goto failed0; } - memcpy(ni->ni_lnd_tunables, lnd_tunables, - sizeof(*ni->ni_lnd_tunables)); } /* -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operator
Add space around & operator for improving the code readability. Signed-off-by: Shreeya Patel --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index e764436e120f..8da955e8343b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -924,7 +924,7 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net /* update fw_state will clr _FW_UNDER_LINKING here indirectly */ switch (pnetwork->network.InfrastructureMode) { case Ndis802_11Infrastructure: - if (pmlmepriv->fw_state&WIFI_UNDER_WPS) + if (pmlmepriv->fw_state & WIFI_UNDER_WPS) pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; else pmlmepriv->fw_state = WIFI_STATION_STATE; -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operator
On Sun, 2020-03-08 at 12:59 -0700, Joe Perches wrote: Hi Joe, > On Sun, 2020-03-08 at 20:31 +0100, Julia Lawall wrote: > > On Mon, 9 Mar 2020, Shreeya Patel wrote: > > > > > Add space around & operator for improving the code > > > readability. > > I guess you found this with checkpatch. If so, it could be nice to > > add > > "Reported by checkpatch." to the log message. OK otherwise. > > It's also be nice to do all the whitespace changes at once. > > See below... > > > Acked-by: Julia Lawall > > > > > Signed-off-by: Shreeya Patel > > [] > > > diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c > > > b/drivers/staging/rtl8188eu/core/rtw_mlme.c > > [] > > > @@ -924,7 +924,7 @@ static void rtw_joinbss_update_network(struct > > > adapter *padapter, struct wlan_net > > > /* update fw_state will clr _FW_UNDER_LINKING here indirectly > > > */ > > > switch (pnetwork->network.InfrastructureMode) { > > > case Ndis802_11Infrastructure: > > > - if (pmlmepriv->fw_state&WIFI_UNDER_WPS) > > > + if (pmlmepriv->fw_state & WIFI_UNDER_WPS) > > > pmlmepriv->fw_state = > > > WIFI_STATION_STATE|WIFI_UNDER_WPS; > > Like adding spaces around the | here too. > I thought of doing this but then it was introducing another warning of "Line over 80 charachters" that is why I didn't proceed with it. What is your suggestion over it? Should I let the line be over 80 characters and add spaces around the operators? > An automated way to do this is: > > Here's the diff produced by the commands below > > $ git diff --shortstat drivers/staging/rtl8188eu > 32 files changed, 407 insertions(+), 407 deletions(-) > $ git diff -w --shortstat drivers/staging/rtl8188eu > 32 files changed, 0 insertions(+), 0 deletions(-) > > $ git ls-files drivers/staging/rtl8188eu | \ > xargs ./scripts/checkpatch.pl --fix-inplace -f --types=spacing -- > terse --no-summary > drivers/staging/rtl8188eu/core/rtw_mlme.c:152: CHECK: spaces > preferred around that '/' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:252: CHECK: spaces > preferred around that '>>' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:253: CHECK: spaces > preferred around that '>>' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:360: CHECK: spaces > preferred around that '+' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:360: CHECK: spaces > preferred around that '*' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:360: CHECK: spaces > preferred around that '/' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:361: CHECK: spaces > preferred around that '+' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:361: CHECK: spaces > preferred around that '*' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:361: CHECK: spaces > preferred around that '/' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:362: CHECK: spaces > preferred around that '+' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:362: CHECK: spaces > preferred around that '*' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:362: CHECK: spaces > preferred around that '/' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:513: CHECK: spaces > preferred around that '+' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:513: CHECK: spaces > preferred around that '-' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:927: CHECK: spaces > preferred around that '&' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:928: CHECK: spaces > preferred around that '|' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1100: CHECK: spaces > preferred around that '-' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1107: CHECK: spaces > preferred around that '-' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1126: CHECK: spaces > preferred around that '<<' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1126: CHECK: spaces > preferred around that '|' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1216: CHECK: spaces > preferred around that '<<' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1216: CHECK: spaces > preferred around that '|' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw_mlme.c:1643: CHECK: spaces > preferred around that '+' (ctx:VxV) > drivers/staging/rtl8188eu/core/rtw
[Outreachy kernel] [PATCH] Staging: rtl8723bs: Remove comparison to true
Remove comparison to "true" from if statement to maintain the kernel coding style. Reported by checkpatch.pl Signed-off-by: Shreeya Patel --- drivers/staging/rtl8723bs/core/rtw_ap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 7117d16a30f9..a76e81330756 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -2417,7 +2417,7 @@ void stop_ap_mode(struct adapter *padapter) paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); - if (paclnode->valid == true) { + if (paclnode->valid) { paclnode->valid = false; list_del_init(&paclnode->list); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operator
On Sun, 2020-03-08 at 13:19 -0700, Joe Perches wrote: > On Mon, 2020-03-09 at 01:40 +0530, Shreeya Patel wrote: > > On Sun, 2020-03-08 at 12:59 -0700, Joe Perches wrote: > > Hi Joe, > > Hello. > [] > > > > > diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c > > > > > b/drivers/staging/rtl8188eu/core/rtw_mlme.c > > > > > > [] > > > > > @@ -924,7 +924,7 @@ static void > > > > > rtw_joinbss_update_network(struct > > > > > adapter *padapter, struct wlan_net > > > > > /* update fw_state will clr _FW_UNDER_LINKING here > > > > > indirectly > > > > > */ > > > > > switch (pnetwork->network.InfrastructureMode) { > > > > > case Ndis802_11Infrastructure: > > > > > - if (pmlmepriv->fw_state&WIFI_UNDER_WPS) > > > > > + if (pmlmepriv->fw_state & WIFI_UNDER_WPS) > > > > > pmlmepriv->fw_state = > > > > > WIFI_STATION_STATE|WIFI_UNDER_WPS; > > > > > > Like adding spaces around the | here too. > > > > > > > I thought of doing this but then it was introducing another warning > > of > > "Line over 80 charachters" that is why I didn't proceed with it. > > [] > > What is your suggestion over it? Should I let the line be over 80 > > characters and add spaces around the operators? > > Just ignore the long line warnings, there are many already > existing long > lines in that subsystem. > > That should be a style challenge for a later time. Okay got it. > > $ git ls-files drivers/staging/rtl8188eu | \ > xargs awk '{ print length($0); }' | \ > sort | uniq -c | sort -rn -k2 > 1 187 > 1 180 > 1 171 > 1 166 > 1 163 > 1 159 > 1 158 > 2 157 > 1 153 > 2 151 > 1 146 > 1 145 > 1 144 > 1 143 > 1 142 > 2 141 > 1 140 > 1 139 > 1 137 > 1 135 > 5 134 > 6 132 > 3 131 > 3 130 > 6 129 > 3 128 > 6 127 > 6 126 > 3 125 > 3 124 > 5 123 > 4 122 > 8 121 > 6 120 > 4 119 > 7 118 > 10 117 > 11 116 > 9 115 > 5 114 > 11 113 > 13 112 > 8 111 > 17 110 > 25 109 > 24 108 > 14 107 > 20 106 > 19 105 > 34 104 > 19 103 > 26 102 > 22 101 > 22 100 > 25 99 > 20 98 > 23 97 > 33 96 > 32 95 > 43 94 > 40 93 > 49 92 > 47 91 > 51 90 > 48 89 > 55 88 > 50 87 > 37 86 > 48 85 > 57 84 > 45 83 > 61 82 > 61 81 I think the idea of yours to automate the change for some common warnings will be really helpful to get rid of them. Thanks, I'm going to try doing it for other drivers as well :) > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operator
On Sun, 2020-03-08 at 21:17 +0100, Julia Lawall wrote: > > On Mon, 9 Mar 2020, Shreeya Patel wrote: > > > On Sun, 2020-03-08 at 12:59 -0700, Joe Perches wrote: > > > > Hi Joe, > > > > > On Sun, 2020-03-08 at 20:31 +0100, Julia Lawall wrote: > > > > On Mon, 9 Mar 2020, Shreeya Patel wrote: > > > > > > > > > Add space around & operator for improving the code > > > > > readability. > > > > > > > > I guess you found this with checkpatch. If so, it could be > > > > nice to > > > > add > > > > "Reported by checkpatch." to the log message. OK otherwise. > > > > > > It's also be nice to do all the whitespace changes at once. > > > > > > See below... > > > > > > > Acked-by: Julia Lawall > > > > > > > > > Signed-off-by: Shreeya Patel > > > > > > [] > > > > > diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c > > > > > b/drivers/staging/rtl8188eu/core/rtw_mlme.c > > > > > > [] > > > > > @@ -924,7 +924,7 @@ static void > > > > > rtw_joinbss_update_network(struct > > > > > adapter *padapter, struct wlan_net > > > > > /* update fw_state will clr _FW_UNDER_LINKING here > > > > > indirectly > > > > > */ > > > > > switch (pnetwork->network.InfrastructureMode) { > > > > > case Ndis802_11Infrastructure: > > > > > - if (pmlmepriv->fw_state&WIFI_UNDER_WPS) > > > > > + if (pmlmepriv->fw_state & WIFI_UNDER_WPS) > > > > > pmlmepriv->fw_state = > > > > > WIFI_STATION_STATE|WIFI_UNDER_WPS; > > > > > > Like adding spaces around the | here too. > > > > > > > I thought of doing this but then it was introducing another warning > > of > > "Line over 80 charachters" that is why I didn't proceed with it. > > > > What is your suggestion over it? Should I let the line be over 80 > > characters and add spaces around the operators? > > Maybe put the right side of the assignment on a separate line? With > an > extra tab in front of it. Yup we can try this as well but I think this will require manual effort to check whether alignment is proper or not. So I will first try to get rid of all the common warnings using the command suggested by Joe and then look after the 80 characters warning. > > julia > > > > > > An automated way to do this is: > > > > > > Here's the diff produced by the commands below > > > > > > $ git diff --shortstat drivers/staging/rtl8188eu > > > 32 files changed, 407 insertions(+), 407 deletions(-) > > > $ git diff -w --shortstat drivers/staging/rtl8188eu > > > 32 files changed, 0 insertions(+), 0 deletions(-) > > > > > > $ git ls-files drivers/staging/rtl8188eu | \ > > > xargs ./scripts/checkpatch.pl --fix-inplace -f --types=spacing > > > -- > > > terse --no-summary > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:152: CHECK: spaces > > > preferred around that '/' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:252: CHECK: spaces > > > preferred around that '>>' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:253: CHECK: spaces > > > preferred around that '>>' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:360: CHECK: spaces > > > preferred around that '+' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:360: CHECK: spaces > > > preferred around that '*' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:360: CHECK: spaces > > > preferred around that '/' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:361: CHECK: spaces > > > preferred around that '+' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:361: CHECK: spaces > > > preferred around that '*' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:361: CHECK: spaces > > > preferred around that '/' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:362: CHECK: spaces > > > preferred around that '+' (ctx:VxV) > > > drivers/staging/rtl8188eu/core/rtw_mlme.c:362: CHECK: spaces > > > preferred around that '*' (ctx:VxV) > > > dr
[Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl Signed-off-by: Shreeya Patel --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 8da955e8343b..9de2d421f6b1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -149,7 +149,7 @@ static void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network * (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) lifetime = 1; if (!isfreeall) { - delta_time = (curr_time - pnetwork->last_scanned)/HZ; + delta_time = (curr_time - pnetwork->last_scanned) / HZ; if (delta_time < lifetime)/* unit:sec */ return; } @@ -249,8 +249,8 @@ void rtw_generate_random_ibss(u8 *pibss) pibss[1] = 0x11; pibss[2] = 0x87; pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ - pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ - pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ + pibss[4] = (u8)((curtime >> 8) & 0xff);/* p[1]; */ + pibss[5] = (u8)((curtime >> 16) & 0xff);/* p[2]; */ } u8 *rtw_get_capability_from_ie(u8 *ie) @@ -357,9 +357,9 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, rssi_final = rssi_ori; } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = (src->Rssi+dst->Rssi*4)/5; + ss_final = ((u32)(src->PhyInfo.SignalStrength) + (u32)(dst->PhyInfo.SignalStrength) * 4) / 5; + sq_final = ((u32)(src->PhyInfo.SignalQuality) + (u32)(dst->PhyInfo.SignalQuality) * 4) / 5; + rssi_final = (src->Rssi + dst->Rssi * 4) / 5; } else { /* bss info not receiving from the right channel, use the original RX signal infos */ ss_final = dst->PhyInfo.SignalStrength; @@ -510,7 +510,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * privacy = pnetwork->network.Privacy; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - if (rtw_get_wps_ie(pnetwork->network.ies+_FIXED_IE_LENGTH_, pnetwork->network.ie_length-_FIXED_IE_LENGTH_, NULL, &wps_ielen)) + if (rtw_get_wps_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, pnetwork->network.ie_length - _FIXED_IE_LENGTH_, NULL, &wps_ielen)) return true; else return false; @@ -925,7 +925,7 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net switch (pnetwork->network.InfrastructureMode) { case Ndis802_11Infrastructure: if (pmlmepriv->fw_state & WIFI_UNDER_WPS) - pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; + pmlmepriv->fw_state = WIFI_STATION_STATE | WIFI_UNDER_WPS; else pmlmepriv->fw_state = WIFI_STATION_STATE; break; @@ -1097,14 +1097,14 @@ static u8 search_max_mac_id(struct adapter *padapter) #if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { for (aid = pstapriv->max_num_sta; aid > 0; aid--) { - if (pstapriv->sta_aid[aid-1]) + if (pstapriv->sta_aid[aid - 1]) break; } mac_id = aid + 1; } else #endif {/* adhoc id = 31~2 */ - for (mac_id = NUM_STA-1; mac_id >= IBSS_START_MAC_ID; mac_id--) { + for (mac_id = NUM_STA - 1; mac_id >= IBSS_START_MAC_ID; mac_id--) { if (pmlmeinfo->FW_sta_info[mac_id].status == 1) break; } @@ -1123,7 +1123,7 @@ void rtw_stassoc_hw_rpt(struct adapter *adapter, struct sta_info *psta) macid = search_max_mac_id(adapter); rtw_hal_set_hwreg(adapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&macid); - media_status = (psta->mac_id<<8)|1; /* MACID|OPMODE:1 connect */ + media_status = (psta->mac_id << 8) | 1; /* MACID|OPMODE:1 connect */ rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); } @@ -1213,7 +1213,7 @@ void rtw_stade
Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operators
On Sun, 2020-03-08 at 16:05 -0700, Joe Perches wrote: > On Mon, 2020-03-09 at 03:30 +0530, Shreeya Patel wrote: > > Add space around operators for improving the code > > readability. > > Hello again Shreeya. > > The subject isn't really quite appropriate as you > are not doing this space around operator addition > for the entire subsystem. > > IMO, the subject should be: > > [PATCH] staging: rtl8188eu: rtw_mlme: Add spaces around operators > > because you are only performing this change on this > single file. > > If you were to do this for every single file in the > subsystem, you could have many individual patches with > the exact same subject line. Oh yes, thanks for correcting me. > > And it would be good to show in the changelog that you > have compiled the file pre and post patch without object > code change. > > Also, it's good to show that git diff -w shows no source > file changes. okay will do this in v2. > > > Reported by checkpatch.pl > > > > Signed-off-by: Shreeya Patel > > --- > > drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++-- > > -- > > 1 file changed, 20 insertions(+), 20 deletions(-) > > When I try this using checkpatch --fix-inplace, I get > 21 changes against the latest -next tree. > > What tree are you doing this against? I am doing this against the latest -testing tree Thanks > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operators
On Sun, 2020-03-08 at 16:05 -0700, Joe Perches wrote: > On Mon, 2020-03-09 at 03:30 +0530, Shreeya Patel wrote: > > Add space around operators for improving the code > > readability. > > Hello again Shreeya. > I have some questions here... > The subject isn't really quite appropriate as you > are not doing this space around operator addition > for the entire subsystem. > > IMO, the subject should be: > > [PATCH] staging: rtl8188eu: rtw_mlme: Add spaces around operators > > because you are only performing this change on this > single file. > > If you were to do this for every single file in the > subsystem, you could have many individual patches with > the exact same subject line. > > And it would be good to show in the changelog that you > have compiled the file pre and post patch without object > code change. > I'm not sure how to show this. Do you mean to add the output of "make drivers/staging/rtl8188eu/core" before and after the changes? I also don't understand the meaning of no object code change. If we are making the changes to code and then compiling it using the make command then a new file with .o extension is created and replaced by the previous one isn't it? > Also, it's good to show that git diff -w shows no source > file changes. > And this has to be... git diff -w --shortstat drivers/staging/rtl8188eu/core/ Am I correct? Thanks > > Reported by checkpatch.pl > > > > Signed-off-by: Shreeya Patel > > --- > > drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++-- > > -- > > 1 file changed, 20 insertions(+), 20 deletions(-) > > When I try this using checkpatch --fix-inplace, I get > 21 changes against the latest -next tree. > > What tree are you doing this against? > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Add space around operators
On Mon, 2020-03-09 at 08:35 +0100, Julia Lawall wrote: > On Mon, 9 Mar 2020, Shreeya Patel wrote: > > > On Sun, 2020-03-08 at 16:05 -0700, Joe Perches wrote: > > > On Mon, 2020-03-09 at 03:30 +0530, Shreeya Patel wrote: > > > > Add space around operators for improving the code > > > > readability. > > > > > > Hello again Shreeya. > > > > > > > I have some questions here... > > > > > The subject isn't really quite appropriate as you > > > are not doing this space around operator addition > > > for the entire subsystem. > > > > > > IMO, the subject should be: > > > > > > [PATCH] staging: rtl8188eu: rtw_mlme: Add spaces around operators > > > > > > because you are only performing this change on this > > > single file. > > > > > > If you were to do this for every single file in the > > > subsystem, you could have many individual patches with > > > the exact same subject line. > > > > > > And it would be good to show in the changelog that you > > > have compiled the file pre and post patch without object > > > code change. > > > > > > > I'm not sure how to show this. Do you mean to add the output of > > "make drivers/staging/rtl8188eu/core" before and after the changes? > > You are working on one specific file, maybe foo.c. Compile before > making changes, which will give you foo.o. Rename that file to > something > else. Make your changes and compile again. Do a diff with the > previously > compiled file. It should produce nothing, indicating no difference. > > If this .o file doesn't change and you only changed this .c file, the > whole compiled driver won't change either. > ok, got it. > > I also don't understand the meaning of no object code change. If we > > are > > making the changes to code and then compiling it using the make > > command > > then a new file with .o extension is created and replaced by the > > previous one isn't it? > > > > > Also, it's good to show that git diff -w shows no source > > > file changes. > > > > > > > And this has to be... > > git diff -w --shortstat drivers/staging/rtl8188eu/core/ > > --shortstat does not seem useful. What you hope to see is that it > produces nothing. > Okay. I will send a V2 with all the changes required. Btw Joe, I am working against staging-testing tree > julia > > > Am I correct? > > > > Thanks > > > > > > Reported by checkpatch.pl > > > > > > > > Signed-off-by: Shreeya Patel > > > > --- > > > > drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++-- > > > > > > > > -- > > > > 1 file changed, 20 insertions(+), 20 deletions(-) > > > > > > When I try this using checkpatch --fix-inplace, I get > > > 21 changes against the latest -next tree. > > > > > > What tree are you doing this against? > > > > > > > > > > -- > > You received this message because you are subscribed to the Google > > Groups "outreachy-kernel" group. > > To unsubscribe from this group and stop receiving emails from it, > > send an email to outreachy-kernel+unsubscr...@googlegroups.com. > > To view this discussion on the web visit > > https://groups.google.com/d/msgid/outreachy-kernel/af1a27fb8c5f7efbaf99ce3055cf3801b366d627.camel%40gmail.com > > . > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH v2] Staging: rtl8188eu: rtw_mlme: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl Signed-off-by: Shreeya Patel --- rtw_mlme_old.o - Previously produced object file before making any changes to the source code. rtw_mlme.o - Object file produced after compiling the changes done in source file. Following is the output of diff between the previously produced object file and the object file produced after compiling the changes. shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/core$ diff rtw_mlme_old.o rtw_mlme.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/core$ Following output shows that there was no other change in the source code except for whitespace. shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/core/ shreeya@Shreeya-Patel:~git/kernels/staging$ Changes in v2 - Include the file name in Subject to make it more specific. - Add the output of diff between the previously produced object file and the object file produced after compiling the changes. - Add the output of git diff -w to show no changes in source file except for whitespace. drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 8da955e8343b..9de2d421f6b1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -149,7 +149,7 @@ static void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network * (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) lifetime = 1; if (!isfreeall) { - delta_time = (curr_time - pnetwork->last_scanned)/HZ; + delta_time = (curr_time - pnetwork->last_scanned) / HZ; if (delta_time < lifetime)/* unit:sec */ return; } @@ -249,8 +249,8 @@ void rtw_generate_random_ibss(u8 *pibss) pibss[1] = 0x11; pibss[2] = 0x87; pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ - pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ - pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ + pibss[4] = (u8)((curtime >> 8) & 0xff);/* p[1]; */ + pibss[5] = (u8)((curtime >> 16) & 0xff);/* p[2]; */ } u8 *rtw_get_capability_from_ie(u8 *ie) @@ -357,9 +357,9 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, rssi_final = rssi_ori; } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = (src->Rssi+dst->Rssi*4)/5; + ss_final = ((u32)(src->PhyInfo.SignalStrength) + (u32)(dst->PhyInfo.SignalStrength) * 4) / 5; + sq_final = ((u32)(src->PhyInfo.SignalQuality) + (u32)(dst->PhyInfo.SignalQuality) * 4) / 5; + rssi_final = (src->Rssi + dst->Rssi * 4) / 5; } else { /* bss info not receiving from the right channel, use the original RX signal infos */ ss_final = dst->PhyInfo.SignalStrength; @@ -510,7 +510,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * privacy = pnetwork->network.Privacy; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - if (rtw_get_wps_ie(pnetwork->network.ies+_FIXED_IE_LENGTH_, pnetwork->network.ie_length-_FIXED_IE_LENGTH_, NULL, &wps_ielen)) + if (rtw_get_wps_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, pnetwork->network.ie_length - _FIXED_IE_LENGTH_, NULL, &wps_ielen)) return true; else return false; @@ -925,7 +925,7 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net switch (pnetwork->network.InfrastructureMode) { case Ndis802_11Infrastructure: if (pmlmepriv->fw_state & WIFI_UNDER_WPS) - pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; + pmlmepriv->fw_state = WIFI_STATION_STATE | WIFI_UNDER_WPS; else pmlmepriv->fw_state = WIFI_STATION_STATE; break; @@ -1097,14 +1097,14 @@ static u8 search_max_mac_id(struct adapter *padapter) #if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { for (aid = pstapriv->max_num_sta; aid > 0; aid--) { - if (pstapriv->sta_aid[aid-1]) +
[Outreachy kernel] [PATCH v3] Staging: rtl8188eu: rtw_mlme: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/core/ shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w shows no difference. shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/core$ diff rtw_mlme_old.o rtw_mlme.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/core$ diff of the .o files before and after the changes shows no difference Changes in v3 - Make the diff output explanation more readable. Changes in v2 - Include the file name in Subject to make it more specific. - Add the output of diff of the .o files before and after the changes to show no difference. - Add the output of git diff -w to show no difference. drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 8da955e8343b..9de2d421f6b1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -149,7 +149,7 @@ static void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network * (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) lifetime = 1; if (!isfreeall) { - delta_time = (curr_time - pnetwork->last_scanned)/HZ; + delta_time = (curr_time - pnetwork->last_scanned) / HZ; if (delta_time < lifetime)/* unit:sec */ return; } @@ -249,8 +249,8 @@ void rtw_generate_random_ibss(u8 *pibss) pibss[1] = 0x11; pibss[2] = 0x87; pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ - pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ - pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ + pibss[4] = (u8)((curtime >> 8) & 0xff);/* p[1]; */ + pibss[5] = (u8)((curtime >> 16) & 0xff);/* p[2]; */ } u8 *rtw_get_capability_from_ie(u8 *ie) @@ -357,9 +357,9 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, rssi_final = rssi_ori; } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = (src->Rssi+dst->Rssi*4)/5; + ss_final = ((u32)(src->PhyInfo.SignalStrength) + (u32)(dst->PhyInfo.SignalStrength) * 4) / 5; + sq_final = ((u32)(src->PhyInfo.SignalQuality) + (u32)(dst->PhyInfo.SignalQuality) * 4) / 5; + rssi_final = (src->Rssi + dst->Rssi * 4) / 5; } else { /* bss info not receiving from the right channel, use the original RX signal infos */ ss_final = dst->PhyInfo.SignalStrength; @@ -510,7 +510,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * privacy = pnetwork->network.Privacy; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - if (rtw_get_wps_ie(pnetwork->network.ies+_FIXED_IE_LENGTH_, pnetwork->network.ie_length-_FIXED_IE_LENGTH_, NULL, &wps_ielen)) + if (rtw_get_wps_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, pnetwork->network.ie_length - _FIXED_IE_LENGTH_, NULL, &wps_ielen)) return true; else return false; @@ -925,7 +925,7 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net switch (pnetwork->network.InfrastructureMode) { case Ndis802_11Infrastructure: if (pmlmepriv->fw_state & WIFI_UNDER_WPS) - pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; + pmlmepriv->fw_state = WIFI_STATION_STATE | WIFI_UNDER_WPS; else pmlmepriv->fw_state = WIFI_STATION_STATE; break; @@ -1097,14 +1097,14 @@ static u8 search_max_mac_id(struct adapter *padapter) #if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { for (aid = pstapriv->max_num_sta; aid > 0; aid--) { - if (pstapriv->sta_aid[aid-1]) + if (pstapriv->sta_aid[aid - 1]) break; } mac_id = aid + 1; } else #endif {/* adhoc id = 31~2 */ - for (mac_id = NUM_STA-1; mac_id >= IBSS_START_MAC_ID; mac_id--) { +
[Outreachy kernel] [PATCH v4] Staging: rtl8188eu: rtw_mlme: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/core/ shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/core$ diff rtw_mlme_old.o rtw_mlme.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/core$ Changes in v4 - Move important statements into the commit message. Changes in v3 - Make the diff output explanation more readable. Changes in v2 - Include the file name in Subject to make it more specific. - Add the output of diff of the .o files before and after the changes to show no difference. - Add the output of git diff -w to show no difference. drivers/staging/rtl8188eu/core/rtw_mlme.c | 40 +++ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 8da955e8343b..9de2d421f6b1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -149,7 +149,7 @@ static void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network * (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) lifetime = 1; if (!isfreeall) { - delta_time = (curr_time - pnetwork->last_scanned)/HZ; + delta_time = (curr_time - pnetwork->last_scanned) / HZ; if (delta_time < lifetime)/* unit:sec */ return; } @@ -249,8 +249,8 @@ void rtw_generate_random_ibss(u8 *pibss) pibss[1] = 0x11; pibss[2] = 0x87; pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ - pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ - pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ + pibss[4] = (u8)((curtime >> 8) & 0xff);/* p[1]; */ + pibss[5] = (u8)((curtime >> 16) & 0xff);/* p[2]; */ } u8 *rtw_get_capability_from_ie(u8 *ie) @@ -357,9 +357,9 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, rssi_final = rssi_ori; } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = (src->Rssi+dst->Rssi*4)/5; + ss_final = ((u32)(src->PhyInfo.SignalStrength) + (u32)(dst->PhyInfo.SignalStrength) * 4) / 5; + sq_final = ((u32)(src->PhyInfo.SignalQuality) + (u32)(dst->PhyInfo.SignalQuality) * 4) / 5; + rssi_final = (src->Rssi + dst->Rssi * 4) / 5; } else { /* bss info not receiving from the right channel, use the original RX signal infos */ ss_final = dst->PhyInfo.SignalStrength; @@ -510,7 +510,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * privacy = pnetwork->network.Privacy; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - if (rtw_get_wps_ie(pnetwork->network.ies+_FIXED_IE_LENGTH_, pnetwork->network.ie_length-_FIXED_IE_LENGTH_, NULL, &wps_ielen)) + if (rtw_get_wps_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, pnetwork->network.ie_length - _FIXED_IE_LENGTH_, NULL, &wps_ielen)) return true; else return false; @@ -925,7 +925,7 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net switch (pnetwork->network.InfrastructureMode) { case Ndis802_11Infrastructure: if (pmlmepriv->fw_state & WIFI_UNDER_WPS) - pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; + pmlmepriv->fw_state = WIFI_STATION_STATE | WIFI_UNDER_WPS; else pmlmepriv->fw_state = WIFI_STATION_STATE; break; @@ -1097,14 +1097,14 @@ static u8 search_max_mac_id(struct adapter *padapter) #if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { for (aid = pstapriv->max_num_sta; aid > 0; aid--) { - if (pstapriv->sta_aid[aid-1]) + if (pstapriv->sta_aid[aid - 1]) break; } mac_id = aid + 1; } else #endif {/* adhoc id = 31~2 */ -
[Outreachy kernel] [PATCH] Staging: rtl8723bs: sdio_halinit: Remove unnecessary conditions
Remove if and else conditions since both are leading to the initialization of "valueDMATimeout" and "valueDMAPageCount" with the same value. Found using coccinelle script. Signed-off-by: Shreeya Patel --- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index e813382e78a6..643592b0bd38 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -551,18 +551,11 @@ static void HalRxAggr8723BSdio(struct adapter *padapter) pregistrypriv = &padapter->registrypriv; - if (pregistrypriv->wifi_spec) { - /* 2010.04.27 hpfan */ - /* Adjust RxAggrTimeout to close to zero disable RxAggr, suggested by designer */ - /* Timeout value is calculated by 34 / (2^n) */ - valueDMATimeout = 0x06; - valueDMAPageCount = 0x06; - } else { - /* 20130530, Isaac@SD1 suggest 3 kinds of parameter */ - /* TX/RX Balance */ - valueDMATimeout = 0x06; - valueDMAPageCount = 0x06; - } + /* 2010.04.27 hpfan */ + /* Adjust RxAggrTimeout to close to zero disable RxAggr, suggested by designer */ + /* Timeout value is calculated by 34 / (2^n) */ + valueDMATimeout = 0x06; + valueDMAPageCount = 0x06; rtw_write8(padapter, REG_RXDMA_AGG_PG_TH + 1, valueDMATimeout); rtw_write8(padapter, REG_RXDMA_AGG_PG_TH, valueDMAPageCount); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH] Staging: rtl8723bs: rtw_mlme: Remove unnecessary conditions
Remove unnecessary if and else conditions since both are leading to the initialization of "phtpriv->ampdu_enable" with the same value. Signed-off-by: Shreeya Patel --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 71fcb466019a..48e9faf27321 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2772,13 +2772,9 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe /* maybe needs check if ap supports rx ampdu. */ if (!(phtpriv->ampdu_enable) && pregistrypriv->ampdu_enable == 1) { - if (pregistrypriv->wifi_spec == 1) { - /* remove this part because testbed AP should disable RX AMPDU */ - /* phtpriv->ampdu_enable = false; */ - phtpriv->ampdu_enable = true; - } else { - phtpriv->ampdu_enable = true; - } + /* remove this part because testbed AP should disable RX AMPDU */ + /* phtpriv->ampdu_enable = false; */ + phtpriv->ampdu_enable = true; } else if (pregistrypriv->ampdu_enable == 2) { /* remove this part because testbed AP should disable RX AMPDU */ /* phtpriv->ampdu_enable = true; */ -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: sdio_halinit: Remove unnecessary conditions
Hey Joe, On March 11, 2020 10:56:29 PM GMT+05:30, Joe Perches wrote: >On Wed, 2020-03-11 at 19:08 +0530, Shreeya Patel wrote: >> Remove if and else conditions since both are leading to the >> initialization of "valueDMATimeout" and "valueDMAPageCount" with >> the same value. > >You might consider removing the > /* Timeout value is calculated by 34 / (2^n) */ >comment entirely as it doesn't make much sense. > You want me to remove the other comments as well? Since Julia suggested in another email that the comments are not useful if we are removing the condition since they were applied to only one branch ( i.e. "if" branch ) Thanks >For what N is "(34 / (2 ^ N))" = 6 ? > >> diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c >b/drivers/staging/rtl8723bs/hal/sdio_halinit.c >[] >> @@ -551,18 +551,11 @@ static void HalRxAggr8723BSdio(struct adapter >*padapter) >> >> pregistrypriv = &padapter->registrypriv; >> >> -if (pregistrypriv->wifi_spec) { >> -/* 2010.04.27 hpfan */ >> -/* Adjust RxAggrTimeout to close to zero disable RxAggr, >suggested by designer */ >> -/* Timeout value is calculated by 34 / (2^n) */ >> -valueDMATimeout = 0x06; >> -valueDMAPageCount = 0x06; >> -} else { >> -/* 20130530, Isaac@SD1 suggest 3 kinds of parameter */ >> -/* TX/RX Balance */ >> -valueDMATimeout = 0x06; >> -valueDMAPageCount = 0x06; >> -} >> +/* 2010.04.27 hpfan */ >> +/* Adjust RxAggrTimeout to close to zero disable RxAggr, suggested >by designer */ >> +/* Timeout value is calculated by 34 / (2^n) */ >> +valueDMATimeout = 0x06; >> +valueDMAPageCount = 0x06; -- Sent from my Android device with K-9 Mail. Please excuse my brevity. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH v4] Staging: rtl8188eu: rtw_mlme: Add space around operators
On March 11, 2020 10:34:28 PM GMT+05:30, Stefano Brivio wrote: Hey Stefano, >On Wed, 11 Mar 2020 18:47:42 +0530 >Shreeya Patel wrote: > >> Add space around operators for improving the code >> readability. >> Reported by checkpatch.pl >> >> git diff -w shows no difference. >> diff of the .o files before and after the changes shows no >difference. >> >> Signed-off-by: Shreeya Patel > >This looks good to me. Further clean-ups here could probably make this >look less messy (there are long lines, unnecessary parentheses that are >rather confusing, especially on that 4/5 factor, "magic" constants that >might make sense to figure out the meaning of, etc.). > Thanks for reviewing. I will surely look at the other clean-ups as well :) Thanks >Reviewed-by: Stefano Brivio -- Sent from my Android device with K-9 Mail. Please excuse my brevity. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: sdio_halinit: Remove unnecessary conditions
On Fri, 2020-03-13 at 10:20 +0300, Dan Carpenter wrote: > On Wed, Mar 11, 2020 at 07:08:11PM +0530, Shreeya Patel wrote: > > diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c > > b/drivers/staging/rtl8723bs/hal/sdio_halinit.c > > index e813382e78a6..643592b0bd38 100644 > > --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c > > +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c > > @@ -551,18 +551,11 @@ static void HalRxAggr8723BSdio(struct adapter > > *padapter) > > > > pregistrypriv = &padapter->registrypriv; > > > > - if (pregistrypriv->wifi_spec) { > > - /* 2010.04.27 hpfan */ > > - /* Adjust RxAggrTimeout to close to zero disable > > RxAggr, suggested by designer */ > > - /* Timeout value is calculated by 34 / (2^n) */ > > - valueDMATimeout = 0x06; > > - valueDMAPageCount = 0x06; > > - } else { > > - /* 20130530, Isaac@SD1 suggest 3 kinds of parameter */ > > - /* TX/RX Balance */ > > - valueDMATimeout = 0x06; > > - valueDMAPageCount = 0x06; > > - } > > + /* 2010.04.27 hpfan */ > > Delete these sorts of comments where it's just a name of someone and > a time stamp when they wrote it. We don't know how to contact > "hpfan" > so it's useless. > Thanks Joe and Dan for your explanation. I will remove the comments and send the patch again. > regards, > dan carpenter > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH v2] Staging: rtl8723bs: rtw_mlme: Remove unnecessary conditions
Remove unnecessary if and else conditions since both are leading to the initialization of "phtpriv->ampdu_enable" with the same value. Also, remove the unnecessary else-if condition since it does nothing. Signed-off-by: Shreeya Patel --- Changes in v2 - Remove unnecessary comments - Remove unnecessary else-if condition which does nothing. drivers/staging/rtl8723bs/core/rtw_mlme.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 71fcb466019a..d7a58af76ea0 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2772,16 +2772,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe /* maybe needs check if ap supports rx ampdu. */ if (!(phtpriv->ampdu_enable) && pregistrypriv->ampdu_enable == 1) { - if (pregistrypriv->wifi_spec == 1) { - /* remove this part because testbed AP should disable RX AMPDU */ - /* phtpriv->ampdu_enable = false; */ - phtpriv->ampdu_enable = true; - } else { - phtpriv->ampdu_enable = true; - } - } else if (pregistrypriv->ampdu_enable == 2) { - /* remove this part because testbed AP should disable RX AMPDU */ - /* phtpriv->ampdu_enable = true; */ + phtpriv->ampdu_enable = true; } /* check Max Rx A-MPDU Size */ -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH v2] Staging: rtl8723bs: sdio_halinit: Remove unnecessary conditions
Remove if and else conditions since both are leading to the initialization of "valueDMATimeout" and "valueDMAPageCount" with the same value. Found using coccinelle script. Signed-off-by: Shreeya Patel --- Changes in v2 - Remove unnecessary comments. drivers/staging/rtl8723bs/hal/sdio_halinit.c | 14 ++ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index e813382e78a6..4894f7d9a1d4 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -551,18 +551,8 @@ static void HalRxAggr8723BSdio(struct adapter *padapter) pregistrypriv = &padapter->registrypriv; - if (pregistrypriv->wifi_spec) { - /* 2010.04.27 hpfan */ - /* Adjust RxAggrTimeout to close to zero disable RxAggr, suggested by designer */ - /* Timeout value is calculated by 34 / (2^n) */ - valueDMATimeout = 0x06; - valueDMAPageCount = 0x06; - } else { - /* 20130530, Isaac@SD1 suggest 3 kinds of parameter */ - /* TX/RX Balance */ - valueDMATimeout = 0x06; - valueDMAPageCount = 0x06; - } + valueDMATimeout = 0x06; + valueDMAPageCount = 0x06; rtw_write8(padapter, REG_RXDMA_AGG_PG_TH + 1, valueDMATimeout); rtw_write8(padapter, REG_RXDMA_AGG_PG_TH, valueDMAPageCount); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH v2] Staging: rtl8723bs: sdio_halinit: Remove unnecessary conditions
Remove if and else conditions since both are leading to the initialization of "valueDMATimeout" and "valueDMAPageCount" with the same value. Found using coccinelle script. Signed-off-by: Shreeya Patel --- Changes in v2 - Remove unnecessary comments. drivers/staging/rtl8723bs/hal/sdio_halinit.c | 14 ++ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index e813382e78a6..4894f7d9a1d4 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -551,18 +551,8 @@ static void HalRxAggr8723BSdio(struct adapter *padapter) pregistrypriv = &padapter->registrypriv; - if (pregistrypriv->wifi_spec) { - /* 2010.04.27 hpfan */ - /* Adjust RxAggrTimeout to close to zero disable RxAggr, suggested by designer */ - /* Timeout value is calculated by 34 / (2^n) */ - valueDMATimeout = 0x06; - valueDMAPageCount = 0x06; - } else { - /* 20130530, Isaac@SD1 suggest 3 kinds of parameter */ - /* TX/RX Balance */ - valueDMATimeout = 0x06; - valueDMAPageCount = 0x06; - } + valueDMATimeout = 0x06; + valueDMAPageCount = 0x06; rtw_write8(padapter, REG_RXDMA_AGG_PG_TH + 1, valueDMATimeout); rtw_write8(padapter, REG_RXDMA_AGG_PG_TH, valueDMAPageCount); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH] Staging: wilc1000: cfg80211: Use kmemdup instead of kmalloc and memcpy
Replace calls to kmalloc followed by a memcpy with a direct call to kmemdup. The Coccinelle semantic patch used to make this change is as follows: @@ expression from,to,size,flag; statement S; @@ - to = \(kmalloc\|kzalloc\)(size,flag); + to = kmemdup(from,size,flag); if (to==NULL || ...) S - memcpy(to, from, size); Signed-off-by: Shreeya Patel --- drivers/staging/wilc1000/cfg80211.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/wilc1000/cfg80211.c b/drivers/staging/wilc1000/cfg80211.c index 54e02807cebf..4bdcbc5fd2fd 100644 --- a/drivers/staging/wilc1000/cfg80211.c +++ b/drivers/staging/wilc1000/cfg80211.c @@ -1142,14 +1142,13 @@ static int mgmt_tx(struct wiphy *wiphy, goto out; } - mgmt_tx->buff = kmalloc(len, GFP_KERNEL); + mgmt_tx->buff = kmemdup(buf, len, GFP_KERNEL); if (!mgmt_tx->buff) { ret = -ENOMEM; kfree(mgmt_tx); goto out; } - memcpy(mgmt_tx->buff, buf, len); mgmt_tx->size = len; if (ieee80211_is_probe_resp(mgmt->frame_control)) { -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH v2] Staging: rtl8723bs: rtw_mlme: Remove unnecessary conditions
On Fri, 2020-03-13 at 14:21 -0700, Joe Perches wrote: Hi Joe, > On Fri, 2020-03-13 at 15:59 +0530, Shreeya Patel wrote: > > Remove unnecessary if and else conditions since both are leading to > > the > > initialization of "phtpriv->ampdu_enable" with the same value. > > Also, remove the unnecessary else-if condition since it does > > nothing. > > [] > > diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c > > b/drivers/staging/rtl8723bs/core/rtw_mlme.c > > [] > > @@ -2772,16 +2772,7 @@ void rtw_update_ht_cap(struct adapter > > *padapter, u8 *pie, uint ie_len, u8 channe > > > > /* maybe needs check if ap supports rx ampdu. */ > > if (!(phtpriv->ampdu_enable) && pregistrypriv->ampdu_enable == > > 1) { > > - if (pregistrypriv->wifi_spec == 1) { > > - /* remove this part because testbed AP should > > disable RX AMPDU */ > > - /* phtpriv->ampdu_enable = false; */ > > - phtpriv->ampdu_enable = true; > > - } else { > > - phtpriv->ampdu_enable = true; > > - } > > - } else if (pregistrypriv->ampdu_enable == 2) { > > - /* remove this part because testbed AP should disable > > RX AMPDU */ > > - /* phtpriv->ampdu_enable = true; */ > > + phtpriv->ampdu_enable = true; > > This isn't the same test. > > This could be: > if ((!(phtpriv->ampdu_enable) && pregistrypriv->ampdu_enable == > 1)) || > pregistrypriv->ampdu_enable == 2) > phtpriv->ampdu_enable = true; > > Though it is probably more sensible to just set > phtpriv->ampdu_enable without testing whether or > not it's already set: > > if (pregistrypriv->ampdu_enable == 1 || > pregistrypriv->ampdu_enable == 2) > phtpriv->ampdu_enable = true; But the else-if block which I removed in v2 of this patch had nothing in the block. It was not assigning any value to "phtpriv->ampdu_enable". ( basically it was empty and useless) Now as per your suggestion if I do the change then the value of "phtpriv->ampdu_enable" will be changed to true when we have "pregistrypriv->ampdu_enable == 2" condition. But in real it should be the same as it was by default coming from the start of the function. ( This is because the else-if block was empty and doing nothing ) Please let me know if I was able to make you understand my point of view here. Also, please correct me if I am wrong. Thanks > > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH 00/11] Staging: rtl8188eu: hal: Add space around operators
This patchset adds space around operators and removes all the checkpatch warnings for the same from the files present under drivers/staging/rtl8188eu/hal/ directory. Shreeya Patel (11): Staging: rtl8188eu: hal_com: Add space around operators Staging: rtl8188eu: odm: Add space around operators Staging: rtl8188eu: odm_hwconfig: Add space around operators Staging: rtl8188eu: phy: Add space around operators Staging: rtl8188eu: pwrseqcmd: Add space around operators Staging: rtl8188eu: rf: Add space around operators Staging: rtl8188eu: rf_cfg: Add space around operators Staging: rtl8188eu: rtl8188e_cmd: Add space around operators Staging: rtl8188eu: rtl8188e_hal_init: Add space around operators Staging: rtl8188eu: rtl8188e_rxdesc: Add space around operators Staging: rtl8188eu: rtl8188eu_xmit: Add space around operators drivers/staging/rtl8188eu/hal/hal_com.c | 22 +-- drivers/staging/rtl8188eu/hal/odm.c | 48 +++--- drivers/staging/rtl8188eu/hal/odm_hwconfig.c | 54 +++ drivers/staging/rtl8188eu/hal/phy.c | 138 +- drivers/staging/rtl8188eu/hal/pwrseqcmd.c | 2 +- drivers/staging/rtl8188eu/hal/rf.c| 60 drivers/staging/rtl8188eu/hal/rf_cfg.c| 4 +- drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 42 +++--- .../staging/rtl8188eu/hal/rtl8188e_hal_init.c | 44 +++--- .../staging/rtl8188eu/hal/rtl8188e_rxdesc.c | 2 +- .../staging/rtl8188eu/hal/rtl8188eu_xmit.c| 32 ++-- 11 files changed, 224 insertions(+), 224 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH 01/11] Staging: rtl8188eu: hal_com: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/hal_com.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff hal_com_old.o hal_com.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/hal_com.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_com.c b/drivers/staging/rtl8188eu/hal/hal_com.c index 95f1b1431373..ebe19e076ff2 100644 --- a/drivers/staging/rtl8188eu/hal/hal_com.c +++ b/drivers/staging/rtl8188eu/hal/hal_com.c @@ -18,26 +18,26 @@ void dump_chip_info(struct HAL_VERSION chip_vers) uint cnt = 0; char buf[128]; - cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8188E_"); - cnt += sprintf((buf+cnt), "%s_", chip_vers.ChipType == NORMAL_CHIP ? + cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8188E_"); + cnt += sprintf((buf + cnt), "%s_", chip_vers.ChipType == NORMAL_CHIP ? "Normal_Chip" : "Test_Chip"); - cnt += sprintf((buf+cnt), "%s_", chip_vers.VendorType == CHIP_VENDOR_TSMC ? + cnt += sprintf((buf + cnt), "%s_", chip_vers.VendorType == CHIP_VENDOR_TSMC ? "TSMC" : "UMC"); if (chip_vers.CUTVersion == A_CUT_VERSION) - cnt += sprintf((buf+cnt), "A_CUT_"); + cnt += sprintf((buf + cnt), "A_CUT_"); else if (chip_vers.CUTVersion == B_CUT_VERSION) - cnt += sprintf((buf+cnt), "B_CUT_"); + cnt += sprintf((buf + cnt), "B_CUT_"); else if (chip_vers.CUTVersion == C_CUT_VERSION) - cnt += sprintf((buf+cnt), "C_CUT_"); + cnt += sprintf((buf + cnt), "C_CUT_"); else if (chip_vers.CUTVersion == D_CUT_VERSION) - cnt += sprintf((buf+cnt), "D_CUT_"); + cnt += sprintf((buf + cnt), "D_CUT_"); else if (chip_vers.CUTVersion == E_CUT_VERSION) - cnt += sprintf((buf+cnt), "E_CUT_"); + cnt += sprintf((buf + cnt), "E_CUT_"); else - cnt += sprintf((buf+cnt), "UNKNOWN_CUT(%d)_", + cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_", chip_vers.CUTVersion); - cnt += sprintf((buf+cnt), "1T1R_"); - cnt += sprintf((buf+cnt), "RomVer(0)\n"); + cnt += sprintf((buf + cnt), "1T1R_"); + cnt += sprintf((buf + cnt), "RomVer(0)\n"); pr_info("%s", buf); } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH 02/11] Staging: rtl8188eu: odm: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/odm.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff odm_old.o odm.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/odm.c | 48 ++--- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 7489491f5aaa..a6eb9798b6f8 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -342,7 +342,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) u8 CurrentIGI = pDM_DigTable->CurIGValue; ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG()==>\n")); - if ((!(pDM_Odm->SupportAbility&ODM_BB_DIG)) || (!(pDM_Odm->SupportAbility&ODM_BB_FA_CNT))) { + if ((!(pDM_Odm->SupportAbility & ODM_BB_DIG)) || (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT))) { ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: SupportAbility ODM_BB_DIG or ODM_BB_FA_CNT is disabled\n")); return; @@ -419,7 +419,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) } if (pDM_DigTable->LargeFAHit >= 3) { - if ((pDM_DigTable->ForbiddenIGI+1) > pDM_DigTable->rx_gain_range_max) + if ((pDM_DigTable->ForbiddenIGI + 1) > pDM_DigTable->rx_gain_range_max) pDM_DigTable->rx_gain_range_min = pDM_DigTable->rx_gain_range_max; else pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1); @@ -432,7 +432,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) pDM_DigTable->Recover_cnt--; } else { if (pDM_DigTable->LargeFAHit < 3) { - if ((pDM_DigTable->ForbiddenIGI-1) < DIG_Dynamic_MIN) { /* DM_DIG_MIN) */ + if ((pDM_DigTable->ForbiddenIGI - 1) < DIG_Dynamic_MIN) { /* DM_DIG_MIN) */ pDM_DigTable->ForbiddenIGI = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ pDM_DigTable->rx_gain_range_min = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Normal Case: At Lower Bound\n")); @@ -518,24 +518,24 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) phy_set_bb_reg(adapter, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 1); /* hold page D counter */ ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord); - FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0x); - FalseAlmCnt->Cnt_SB_Search_fail = (ret_value & 0x)>>16; + FalseAlmCnt->Cnt_Fast_Fsync = (ret_value & 0x); + FalseAlmCnt->Cnt_SB_Search_fail = (ret_value & 0x) >> 16; ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord); - FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0x); - FalseAlmCnt->Cnt_Parity_Fail = (ret_value & 0x)>>16; + FalseAlmCnt->Cnt_OFDM_CCA = (ret_value & 0x); + FalseAlmCnt->Cnt_Parity_Fail = (ret_value & 0x) >> 16; ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord); - FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0x); - FalseAlmCnt->Cnt_Crc8_fail = (ret_value & 0x)>>16; + FalseAlmCnt->Cnt_Rate_Illegal = (ret_value & 0x); + FalseAlmCnt->Cnt_Crc8_fail = (ret_value & 0x) >> 16; ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord); - FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0x); + FalseAlmCnt->Cnt_Mcs_fail = (ret_value & 0x); FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail + FalseAlmCnt->Cnt_Fast_Fsync + FalseAlmCnt->Cnt_SB_Search_fail; ret_value = phy_query_bb_reg(adapter, ODM_REG_SC_CNT_11N, bMaskDWord); - FalseAlmCnt->Cnt_BW_LSC = (ret_value&0x); - FalseAlmCnt->C
[Outreachy kernel] [PATCH 03/11] Staging: rtl8188eu: odm_hwconfig: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/odm_hwconfig.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff odm_hwconfig_old.o odm_hwconfig.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/odm_hwconfig.c | 54 ++-- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c index d5a9ac51e907..a6f2731b076d 100644 --- a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c +++ b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c @@ -103,33 +103,33 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, switch (LNA_idx) { case 7: if (VGA_idx <= 27) - rx_pwr_all = -100 + 2 * (27-VGA_idx); /* VGA_idx = 27~2 */ + rx_pwr_all = -100 + 2 * (27 - VGA_idx); /* VGA_idx = 27~2 */ else rx_pwr_all = -100; break; case 6: - rx_pwr_all = -48 + 2 * (2-VGA_idx); /* VGA_idx = 2~0 */ + rx_pwr_all = -48 + 2 * (2 - VGA_idx); /* VGA_idx = 2~0 */ break; case 5: - rx_pwr_all = -42 + 2 * (7-VGA_idx); /* VGA_idx = 7~5 */ + rx_pwr_all = -42 + 2 * (7 - VGA_idx); /* VGA_idx = 7~5 */ break; case 4: - rx_pwr_all = -36 + 2 * (7-VGA_idx); /* VGA_idx = 7~4 */ + rx_pwr_all = -36 + 2 * (7 - VGA_idx); /* VGA_idx = 7~4 */ break; case 3: - rx_pwr_all = -24 + 2 * (7-VGA_idx); /* VGA_idx = 7~0 */ + rx_pwr_all = -24 + 2 * (7 - VGA_idx); /* VGA_idx = 7~0 */ break; case 2: if (cck_highpwr) - rx_pwr_all = -12 + 2 * (5-VGA_idx); /* VGA_idx = 5~0 */ + rx_pwr_all = -12 + 2 * (5 - VGA_idx); /* VGA_idx = 5~0 */ else - rx_pwr_all = -6 + 2 * (5-VGA_idx); + rx_pwr_all = -6 + 2 * (5 - VGA_idx); break; case 1: - rx_pwr_all = 8-2 * VGA_idx; + rx_pwr_all = 8 - 2 * VGA_idx; break; case 0: - rx_pwr_all = 14-2 * VGA_idx; + rx_pwr_all = 14 - 2 * VGA_idx; break; default: break; @@ -138,7 +138,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, PWDB_ALL = odm_query_rxpwrpercentage(rx_pwr_all); if (!cck_highpwr) { if (PWDB_ALL >= 80) - PWDB_ALL = ((PWDB_ALL-80)<<1) + ((PWDB_ALL-80)>>1) + 80; + PWDB_ALL = ((PWDB_ALL - 80) << 1) + ((PWDB_ALL - 80) >> 1) + 80; else if ((PWDB_ALL <= 78) && (PWDB_ALL >= 20)) PWDB_ALL += 3; if (PWDB_ALL > 100) @@ -162,7 +162,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, else if (SQ_rpt < 20) SQ = 100; else - SQ = ((64-SQ_rpt) * 100) / 44; + SQ = ((64 - SQ_rpt) * 100) / 44; } pPhyInfo->SignalQuality = SQ; pPhyInfo->RxMIMOSignalQuality[RF_PATH_A] = SQ; @@ -200,8 +200,8 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, pPhyInfo->RxMIMOSignalStrength[i] = (u8)RSSI; /* Get Rx snr value in DB */ - pPhyInfo->RxSNR[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); - dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); + pPhyInfo->RxSNR[i] = (s32)(pPhyStaRpt->path_rxsnr[i] / 2); + dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i] / 2); } /* (2)PWDB, Average PWDB calcul
[Outreachy kernel] [PATCH 04/11] Staging: rtl8188eu: phy: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/phy.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff phy_old.o phy.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/phy.c | 138 ++-- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index afaf9e55195a..b9025815b682 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -69,10 +69,10 @@ static u32 rf_serial_read(struct adapter *adapt, bMaskDWord); tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | - (offset<<23) | bLSSIReadEdge; + (offset << 23) | bLSSIReadEdge; phy_set_bb_reg(adapt, rFPGA0_XA_HSSIParameter2, bMaskDWord, - tmplong&(~bLSSIReadEdge)); + tmplong & (~bLSSIReadEdge)); udelay(10); phy_set_bb_reg(adapt, phyreg->rfHSSIPara2, bMaskDWord, tmplong2); @@ -102,7 +102,7 @@ static void rf_serial_write(struct adapter *adapt, struct bb_reg_def *phyreg = &adapt->HalData->PHYRegDef[rfpath]; offset &= 0xff; - data_and_addr = ((offset<<20) | (data&0x000f)) & 0x0fff; + data_and_addr = ((offset << 20) | (data & 0x000f)) & 0x0fff; phy_set_bb_reg(adapt, phyreg->rf3wireOffset, bMaskDWord, data_and_addr); } @@ -143,20 +143,20 @@ static void get_tx_power_index(struct adapter *adapt, u8 channel, u8 *cck_pwr, for (TxCount = 0; TxCount < path_nums; TxCount++) { if (TxCount == RF_PATH_A) { cck_pwr[TxCount] = hal_data->Index24G_CCK_Base[TxCount][index]; - ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ + ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index] + hal_data->OFDM_24G_Diff[TxCount][RF_PATH_A]; - bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ + bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index] + hal_data->BW20_24G_Diff[TxCount][RF_PATH_A]; bw40_pwr[TxCount] = hal_data->Index24G_BW40_Base[TxCount][index]; } else if (TxCount == RF_PATH_B) { cck_pwr[TxCount] = hal_data->Index24G_CCK_Base[TxCount][index]; - ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ - hal_data->BW20_24G_Diff[RF_PATH_A][index]+ + ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index] + + hal_data->BW20_24G_Diff[RF_PATH_A][index] + hal_data->BW20_24G_Diff[TxCount][index]; - bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index]+ - hal_data->BW20_24G_Diff[TxCount][RF_PATH_A]+ + bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index] + + hal_data->BW20_24G_Diff[TxCount][RF_PATH_A] + hal_data->BW20_24G_Diff[TxCount][index]; bw40_pwr[TxCount] = hal_data->Index24G_BW40_Base[TxCount][index]; } @@ -205,7 +205,7 @@ static void phy_set_bw_mode_callback(struct adapter *adapt) /* Set MAC register */ reg_bw_opmode = usb_read8(adapt, REG_BWOPMODE); - reg_prsr_rsc = usb_read8(adapt, REG_RRSR+2); + reg_prsr_rsc = usb_read8(adapt, REG_RRSR + 2); switch (hal_data->CurrentChannelBW) { case HT_CHANNEL_WIDTH_20: @@ -215,9 +215,9 @@ static void phy_set_bw_mode_callback(struct adapter *adapt) case HT_CHANNEL_WIDTH_40: reg_bw_opmode &= ~BW_OPMODE_20MHZ; usb_write8(adapt, REG_BWOPMODE, reg_bw_opmode); - reg_prsr_rsc = (reg_prsr_rsc&0x90) | - (hal_data->nCur40MhzPrimeSC<<5); - usb_write8(adapt, REG_RRSR+2, reg_prsr_rsc); + reg_prsr_rsc = (reg_prsr_rsc & 0x90) | + (hal_data->nCur40MhzPrimeSC << 5); + usb_write8(adapt, REG_RRSR + 2, reg_prsr_rsc); break; defau
[Outreachy kernel] [PATCH 05/11] Staging: rtl8188eu: pwrseqcmd: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/pwrseqcmd.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff pwrseqcmd_old.o pwrseqcmd.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/pwrseqcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c b/drivers/staging/rtl8188eu/hal/pwrseqcmd.c index 249cbc375074..77edd7ad19a1 100644 --- a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c +++ b/drivers/staging/rtl8188eu/hal/pwrseqcmd.c @@ -85,7 +85,7 @@ u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, u8 cut_vers, if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)); else - udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)*1000); + udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd) * 1000); break; case PWR_CMD_END: /* When this command is parsed, end the process */ -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH 06/11] Staging: rtl8188eu: rf: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/rf.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff rf_old.o rf.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/rf.c | 60 +++--- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rf.c b/drivers/staging/rtl8188eu/hal/rf.c index 6fe4daea8fd5..00a9f692bb06 100644 --- a/drivers/staging/rtl8188eu/hal/rf.c +++ b/drivers/staging/rtl8188eu/hal/rf.c @@ -49,9 +49,9 @@ void rtl88eu_phy_rf6052_set_cck_txpower(struct adapter *adapt, u8 *powerlevel) tx_agc[RF_PATH_B] = 0x3f3f3f3f; for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { tx_agc[idx1] = powerlevel[idx1] | - (powerlevel[idx1]<<8) | - (powerlevel[idx1]<<16) | - (powerlevel[idx1]<<24); + (powerlevel[idx1] << 8) | + (powerlevel[idx1] << 16) | + (powerlevel[idx1] << 24); } } else { if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) { @@ -63,17 +63,17 @@ void rtl88eu_phy_rf6052_set_cck_txpower(struct adapter *adapt, u8 *powerlevel) } else { for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { tx_agc[idx1] = powerlevel[idx1] | - (powerlevel[idx1]<<8) | - (powerlevel[idx1]<<16) | - (powerlevel[idx1]<<24); + (powerlevel[idx1] << 8) | + (powerlevel[idx1] << 16) | + (powerlevel[idx1] << 24); } if (hal_data->EEPROMRegulatory == 0) { tmpval = hal_data->MCSTxPowerLevelOriginalOffset[0][6] + - (hal_data->MCSTxPowerLevelOriginalOffset[0][7]<<8); + (hal_data->MCSTxPowerLevelOriginalOffset[0][7] << 8); tx_agc[RF_PATH_A] += tmpval; tmpval = hal_data->MCSTxPowerLevelOriginalOffset[0][14] + - (hal_data->MCSTxPowerLevelOriginalOffset[0][15]<<24); + (hal_data->MCSTxPowerLevelOriginalOffset[0][15] << 24); tx_agc[RF_PATH_B] += tmpval; } } @@ -100,15 +100,15 @@ void rtl88eu_phy_rf6052_set_cck_txpower(struct adapter *adapt, u8 *powerlevel) } /* rf-A cck tx power */ - tmpval = tx_agc[RF_PATH_A]&0xff; + tmpval = tx_agc[RF_PATH_A] & 0xff; phy_set_bb_reg(adapt, rTxAGC_A_CCK1_Mcs32, bMaskByte1, tmpval); - tmpval = tx_agc[RF_PATH_A]>>8; + tmpval = tx_agc[RF_PATH_A] >> 8; phy_set_bb_reg(adapt, rTxAGC_B_CCK11_A_CCK2_11, 0xff00, tmpval); /* rf-B cck tx power */ - tmpval = tx_agc[RF_PATH_B]>>24; + tmpval = tx_agc[RF_PATH_B] >> 24; phy_set_bb_reg(adapt, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, tmpval); - tmpval = tx_agc[RF_PATH_B]&0x00ff; + tmpval = tx_agc[RF_PATH_B] & 0x00ff; phy_set_bb_reg(adapt, rTxAGC_B_CCK1_55_Mcs32, 0xff00, tmpval); } @@ -124,9 +124,9 @@ static void getpowerbase88e(struct adapter *adapt, u8 *pwr_level_ofdm, for (i = 0; i < 2; i++) { powerbase0 = pwr_level_ofdm[i]; - powerbase0 = (powerbase0<<24) | (powerbase0<<16) | -(powerbase0<<8) | powerbase0; - *(ofdmbase+i) = powerbase0; + powerbase0 = (powerbase0 << 24) | (powerbase0 << 16) | +(powerbase0 << 8) | powerbase0; + *(ofdmbase + i) = powerbase0; } /* Check HT20 to HT40 diff */ if (adapt->HalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20) @@ -134,8 +134,8 @@ static void getpowerbase88e(struct adapter *adapt, u8 *pwr_level_ofdm, else powerlevel[0] = pwr_level_bw4
[Outreachy kernel] [PATCH 08/11] Staging: rtl8188eu: rtl8188e_cmd: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff rtl8188e_cmd_old.o rtl8188e_cmd.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 42 ++-- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c index 7646167a0b36..371e746915dd 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c @@ -113,24 +113,24 @@ void rtw_hal_add_ra_tid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi_le struct odm_dm_struct *odmpriv = &pAdapter->HalData->odmpriv; u8 macid, init_rate, raid, shortGIrate = false; - macid = arg&0x1f; + macid = arg & 0x1f; - raid = (bitmap>>28) & 0x0f; + raid = (bitmap >> 28) & 0x0f; bitmap &= 0x0fff; if (rssi_level != DM_RATR_STA_INIT) bitmap = ODM_Get_Rate_Bitmap(odmpriv, macid, bitmap, rssi_level); - bitmap |= ((raid<<28)&0xf000); + bitmap |= ((raid << 28) & 0xf000); - init_rate = get_highest_rate_idx(bitmap&0x0fff)&0x3f; + init_rate = get_highest_rate_idx(bitmap & 0x0fff) & 0x3f; shortGIrate = (arg & BIT(5)) ? true : false; if (shortGIrate) init_rate |= BIT(6); - raid = (bitmap>>28) & 0x0f; + raid = (bitmap >> 28) & 0x0f; bitmap &= 0x0fff; @@ -172,7 +172,7 @@ void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode) break; } - H2CSetPwrMode.SmartPS_RLBM = (((pwrpriv->smart_ps<<4)&0xf0) | (RLBM & 0x0f)); + H2CSetPwrMode.SmartPS_RLBM = (((pwrpriv->smart_ps << 4) & 0xf0) | (RLBM & 0x0f)); H2CSetPwrMode.AwakeInterval = 1; @@ -239,9 +239,9 @@ static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength) pframe += 2; pktlen += 2; - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { pktlen += cur_network->ie_length - sizeof(struct ndis_802_11_fixed_ie); - memcpy(pframe, cur_network->ies+sizeof(struct ndis_802_11_fixed_ie), pktlen); + memcpy(pframe, cur_network->ies + sizeof(struct ndis_802_11_fixed_ie), pktlen); goto _ConstructBeacon; } @@ -258,7 +258,7 @@ static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength) /* DS parameter set */ pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pktlen); - if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { u32 ATIMWindow; /* IBSS Parameter Set... */ ATIMWindow = 0; @@ -473,7 +473,7 @@ static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) /* 3 (2) ps-poll *1 page */ RsvdPageLoc.LocPsPoll = PageNum; ConstructPSPoll(adapt, &ReservedPagePacket[BufIndex], &PSPollLength); - rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], PSPollLength, true, false); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], PSPollLength, true, false); PageNeed = (u8)PageNum_128(TxDescLen + PSPollLength); PageNum += PageNeed; @@ -483,7 +483,7 @@ static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) /* 3 (3) null data * 1 page */ RsvdPageLoc.LocNullData = PageNum; ConstructNullFunctionData(adapt, &ReservedPagePacket[BufIndex], &NullDataLength, pnetwork->MacAddress, false, 0, 0, false); - rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], NullDataLength, false, false); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], NullDataLength, false, false); PageNeed = (u8)PageNum_128(TxDescLen + NullDataLength); PageNum += PageNeed; @@ -493,7 +493,7 @@ static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) /* 3 (4) probe response * 1page */ RsvdPageLoc.LocProbeRsp = PageNum; ConstructProbeRsp(adapt, &ReservedPagePacket[BufInd
[Outreachy kernel] [PATCH 07/11] Staging: rtl8188eu: rf_cfg: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/rf_cfg.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff rf_cfg_old.o rf_cfg.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/rf_cfg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rf_cfg.c b/drivers/staging/rtl8188eu/hal/rf_cfg.c index 004e19301eae..0b20e62f9a68 100644 --- a/drivers/staging/rtl8188eu/hal/rf_cfg.c +++ b/drivers/staging/rtl8188eu/hal/rf_cfg.c @@ -143,7 +143,7 @@ static u32 Array_RadioA_1T_8188E[] = { #define READ_NEXT_PAIR(v1, v2, i) \ do { \ i += 2; v1 = array[i]; \ - v2 = array[i+1];\ + v2 = array[i + 1]; \ } while (0) #define RFREG_OFFSET_MASK 0xf @@ -190,7 +190,7 @@ static bool rtl88e_phy_config_rf_with_headerfile(struct adapter *adapt) for (i = 0; i < array_len; i += 2) { u32 v1 = array[i]; - u32 v2 = array[i+1]; + u32 v2 = array[i + 1]; if (v1 < 0xCDCDCDCD) { rtl8188e_config_rf_reg(adapt, v1, v2); -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH 09/11] Staging: rtl8188eu: rtl8188e_hal_init: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff rtl8188e_hal_init_old.o rtl8188e_hal_init.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ .../staging/rtl8188eu/hal/rtl8188e_hal_init.c | 44 +-- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 57ae0e83dd3e..740004d71a15 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -22,7 +22,7 @@ void iol_mode_enable(struct adapter *padapter, u8 enable) if (enable) { /* Enable initial offload */ reg_0xf0 = usb_read8(padapter, REG_SYS_CFG); - usb_write8(padapter, REG_SYS_CFG, reg_0xf0|SW_OFFLOAD_EN); + usb_write8(padapter, REG_SYS_CFG, reg_0xf0 | SW_OFFLOAD_EN); if (!padapter->bFWReady) { DBG_88E("bFWReady == false call reset 8051...\n"); @@ -42,9 +42,9 @@ s32 iol_execute(struct adapter *padapter, u8 control) u8 reg_0x88 = 0; unsigned long start = 0; - control = control&0x0f; + control = control & 0x0f; reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0); - usb_write8(padapter, REG_HMEBOX_E0, reg_0x88|control); + usb_write8(padapter, REG_HMEBOX_E0, reg_0x88 | control); start = jiffies; while ((reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0)) & control && @@ -54,7 +54,7 @@ s32 iol_execute(struct adapter *padapter, u8 control) reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0); status = (reg_0x88 & control) ? _FAIL : _SUCCESS; - if (reg_0x88 & control<<4) + if (reg_0x88 & control << 4) status = _FAIL; return status; } @@ -64,7 +64,7 @@ static s32 iol_InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) s32 rst = _SUCCESS; iol_mode_enable(padapter, 1); - usb_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); + usb_write8(padapter, REG_TDECTRL + 1, txpktbuf_bndy); rst = iol_execute(padapter, CMD_INIT_LLT); iol_mode_enable(padapter, 0); return rst; @@ -92,9 +92,9 @@ void _8051Reset88E(struct adapter *padapter) { u8 u1bTmp; - u1bTmp = usb_read8(padapter, REG_SYS_FUNC_EN+1); - usb_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp&(~BIT(2))); - usb_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp|(BIT(2))); + u1bTmp = usb_read8(padapter, REG_SYS_FUNC_EN + 1); + usb_write8(padapter, REG_SYS_FUNC_EN + 1, u1bTmp & (~BIT(2))); + usb_write8(padapter, REG_SYS_FUNC_EN + 1, u1bTmp | (BIT(2))); DBG_88E("=> _8051Reset88E(): 8051 reset success .\n"); } @@ -122,7 +122,7 @@ void rtw_hal_read_chip_version(struct adapter *padapter) value32 = usb_read32(padapter, REG_SYS_CFG); ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP); ChipVersion.VendorType = ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC); - ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK)>>CHIP_VER_RTL_SHIFT; /* IC version (CUT) */ + ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK) >> CHIP_VER_RTL_SHIFT; /* IC version (CUT) */ dump_chip_info(ChipVersion); @@ -163,10 +163,10 @@ void rtw_hal_notch_filter(struct adapter *adapter, bool enable) { if (enable) { DBG_88E("Enable notch filter\n"); - usb_write8(adapter, rOFDM0_RxDSP+1, usb_read8(adapter, rOFDM0_RxDSP+1) | BIT(1)); + usb_write8(adapter, rOFDM0_RxDSP + 1, usb_read8(adapter, rOFDM0_RxDSP + 1) | BIT(1)); } else { DBG_88E("Disable notch filter\n"); - usb_write8(adapter, rOFDM0_RxDSP+1, usb_read8(adapter, rOFDM0_RxDSP+1) & ~BIT(1)); + usb_write8(adapter, rOFDM0_RxDSP + 1, usb_read8(adapter, rOFDM0_RxDSP + 1) & ~BIT(1)); } } @@ -308,7 +308,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, if (pwrInfo24G->IndexCCK_Base[rfPath][group] == 0xFF) pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; } - for (group = 0; group < MAX_CHNL_GROUP_24G-1; group++) { + for (group = 0; group < MAX_CHNL_GROUP_24G - 1;
[Outreachy kernel] [PATCH 10/11] Staging: rtl8188eu: rtl8188e_rxdesc: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff rtl8188e_rxdesc_old.o rtl8188e_rxdesc.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c index 0a900827c4fc..7d0135fde795 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c @@ -182,7 +182,7 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe, rtl8188e_process_phy_info(padapter, precvframe); } } else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) { - if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { + if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) { if (psta) precvframe->psta = psta; } -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[Outreachy kernel] [PATCH 11/11] Staging: rtl8188eu: rtl8188eu_xmit: Add space around operators
Add space around operators for improving the code readability. Reported by checkpatch.pl git diff -w shows no difference. diff of the .o files before and after the changes shows no difference. Signed-off-by: Shreeya Patel --- shreeya@Shreeya-Patel:~git/kernels/staging$ git diff -w drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c shreeya@Shreeya-Patel:~git/kernels/staging$ shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ diff rtl8188eu_xmit_old.o rtl8188eu_xmit.o shreeya@Shreeya-Patel:~git/kernels/staging/drivers/staging/rtl8188eu/hal$ .../staging/rtl8188eu/hal/rtl8188eu_xmit.c| 32 +-- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c index 2808f2b119bf..7d315bd438d4 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -58,12 +58,12 @@ void rtl8188e_fill_fake_txdesc(struct adapter *adapt, u8 *desc, u32 BufferLen, u /* offset 0 */ ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); /* own, bFirstSeg, bLastSeg; */ - ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ)<txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & 0x00ff); /* 32 bytes for TX Desc */ - ptxdesc->txdw0 |= cpu_to_le32(BufferLen&0x); /* Buffer size + command header */ + ptxdesc->txdw0 |= cpu_to_le32(BufferLen & 0x); /* Buffer size + command header */ /* offset 4 */ - ptxdesc->txdw1 |= cpu_to_le32((QSLT_MGNT<txdw1 |= cpu_to_le32((QSLT_MGNT << QSEL_SHT) & 0x1f00); /* Fixed queue of Mgnt queue */ /* Set NAVUSEHDR to prevent Ps-poll AId filed to be changed to error vlaue by Hw. */ if (ispspoll) { @@ -91,16 +91,16 @@ static void fill_txdesc_sectype(struct pkt_attrib *pattrib, struct tx_desc *ptxd /* SEC_TYPE : 0:NO_ENC,1:WEP40/TKIP,2:WAPI,3:AES */ case _WEP40_: case _WEP104_: - ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw1 |= cpu_to_le32((0x01 << SEC_TYPE_SHT) & 0x00c0); ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); break; case _TKIP_: case _TKIP_WTMIC_: - ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw1 |= cpu_to_le32((0x01 << SEC_TYPE_SHT) & 0x00c0); ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); break; case _AES_: - ptxdesc->txdw1 |= cpu_to_le32((0x03<txdw1 |= cpu_to_le32((0x03 << SEC_TYPE_SHT) & 0x00c0); ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); break; case _NO_PRIVACY_: @@ -127,7 +127,7 @@ static void fill_txdesc_vcs(struct pkt_attrib *pattrib, __le32 *pdw) *pdw |= cpu_to_le32(HW_RTS_EN); /* Set RTS BW */ if (pattrib->ht_en) { - *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(27)) : 0; + *pdw |= (pattrib->bwmode & HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(27)) : 0; if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) *pdw |= cpu_to_le32((0x01 << 28) & 0x3000); @@ -144,7 +144,7 @@ static void fill_txdesc_vcs(struct pkt_attrib *pattrib, __le32 *pdw) static void fill_txdesc_phy(struct pkt_attrib *pattrib, __le32 *pdw) { if (pattrib->ht_en) { - *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(25)) : 0; + *pdw |= (pattrib->bwmode & HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(25)) : 0; if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) *pdw |= cpu_to_le32((0x01 << DATA_SC_SHT) & 0x003f); @@ -171,7 +171,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag if (adapt->registrypriv.mp_mode == 0) { if ((!bagg_pkt) && (urb_zero_packet_chk(adapt, sz) == 0)) { - ptxdesc = (struct tx_desc *)(pmem+PACKET_OFFSET_SZ); + ptxdesc = (struct tx_desc *)(pmem + PACKET_OFFSET_SZ); pull = 1; } } @@ -263,11 +263,11 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag ptxdesc->txdw4 |= cpu_to_le32(BIT(24));/* DATA_SHORT */ ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); } - } else if ((pxmitframe-&g
Re: [Outreachy kernel] [PATCH 01/11] Staging: rtl8188eu: hal_com: Add space around operators
On Sun, 2020-03-22 at 08:09 -0700, Joe Perches wrote: > On Sun, 2020-03-22 at 12:27 +0100, Greg KH wrote: Hi Greg and Joe, > > On Sun, Mar 22, 2020 at 03:51:13AM +0530, Shreeya Patel wrote: > > > Add space around operators for improving the code > > > readability. > > > Reported by checkpatch.pl > > > > > > git diff -w shows no difference. > > > diff of the .o files before and after the changes shows no > > > difference. > > > > There is no need to have these two lines on every changelog comment > > in > > this series :( > Yes I get that. > In my opinion, there's no need for a series here. > > Whitespace only changes _should_ be done all at once. > > Whitespace changes _could_ have changed string constants. > > So noting that the patch in only whitespace and that > there isn't a difference in object files is useful as > it shows any change has been compiled and tested. > Joe, I feel the same thing, there is no need of a patch series for it but I was given a suggestion that it becomes difficult for the reviewers to review the patch so it is good to send a patchset instead. But as you said, we are testing that there is no change in the object file so we can go ahead with a single patch for all the whitespace changes. If you feel this is right then can I go ahead and send a single patch for it? ( need your or Greg's confirmation before I do it ) Thanks > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel