RE: [PATCH V2 3/5] Drivers: hv: kvp: Fix the recent regression caused by incorrect clean-up
> From: Michael Kelley > Sent: Wednesday, October 24, 2018 08:38 > From: k...@linuxonhyperv.com Sent: Wednesday, > October 17, 2018 10:10 PM > > From: Dexuan Cui > > > > In kvp_send_key(), we do need call process_ib_ipinfo() if > > message->kvp_hdr.operation is KVP_OP_GET_IP_INFO, because it turns out > > the userland hv_kvp_daemon needs the info of operation, adapter_id and > > addr_family. With the incorrect fc62c3b1977d, the host can't get the > > VM's IP via KVP. > > > > And, fc62c3b1977d added a "break;", but actually forgot to initialize > > the key_size/value in the case of KVP_OP_SET, so the default key_size of > > 0 is passed to the kvp daemon, and the pool files > > /var/lib/hyperv/.kvp_pool_* can't be updated. > > > > This patch effectively rolls back the previous fc62c3b1977d, and > > correctly fixes the "this statement may fall through" warnings. > > > > This patch is tested on WS 2012 R2 and 2016. > > > > Fixes: fc62c3b1977d ("Drivers: hv: kvp: Fix two "this statement may fall > through" warnings") > > Signed-off-by: Dexuan Cui > > Cc: K. Y. Srinivasan > > Cc: Haiyang Zhang > > Cc: Stephen Hemminger > > Cc: > > Signed-off-by: K. Y. Srinivasan > > --- > > drivers/hv/hv_kvp.c | 26 ++ > > 1 file changed, 22 insertions(+), 4 deletions(-) > > > Reviewed-by: Michael Kelley Hi Greg, Can you please take a look at this patch? We need it to fix a regression introduced by me in: Fixes: fc62c3b1977d ("Drivers: hv: kvp: Fix two "this statement may fall through" warnings") The faulty patch is being meged into the old stable kernels... So we need to take this patch ASAP. Thanks! -- Dexuan ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: vt6656: clean up few indentation issues
On Tue, 2018-10-30 at 11:13 +, Colin King wrote: > From: Colin Ian King > > Trivial fix to clean up indentation issues [] > diff --git a/drivers/staging/vt6656/main_usb.c > b/drivers/staging/vt6656/main_usb.c > index ccafcc2c87ac..b613a1d113bb 100644 > --- a/drivers/staging/vt6656/main_usb.c > +++ b/drivers/staging/vt6656/main_usb.c > @@ -245,10 +245,10 @@ static int vnt_init_registers(struct vnt_private *priv) > } else { > priv->tx_antenna_mode = ANT_B; > > - if (priv->tx_rx_ant_inv) > - priv->rx_antenna_mode = ANT_A; > - else > - priv->rx_antenna_mode = ANT_B; > + if (priv->tx_rx_ant_inv) > + priv->rx_antenna_mode = ANT_A; > + else > + priv->rx_antenna_mode = ANT_B; > } > } This one is perhap better resolved by moving the inversion test after the block like: --- drivers/staging/vt6656/main_usb.c | 25 ++--- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index ccafcc2c87ac..3830437e321a 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -227,29 +227,16 @@ static int vnt_init_registers(struct vnt_private *priv) if (antenna == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) { priv->tx_antenna_mode = ANT_B; priv->rx_antenna_sel = 1; - - if (priv->tx_rx_ant_inv) - priv->rx_antenna_mode = ANT_A; - else - priv->rx_antenna_mode = ANT_B; } else { priv->rx_antenna_sel = 0; - - if (antenna & EEP_ANTENNA_AUX) { + if (antenna & EEP_ANTENNA_AUX) priv->tx_antenna_mode = ANT_A; - - if (priv->tx_rx_ant_inv) - priv->rx_antenna_mode = ANT_B; - else - priv->rx_antenna_mode = ANT_A; - } else { - priv->tx_antenna_mode = ANT_B; - - if (priv->tx_rx_ant_inv) - priv->rx_antenna_mode = ANT_A; else - priv->rx_antenna_mode = ANT_B; - } + priv->tx_antenna_mode = ANT_B; + } + if (priv->tx_rx_ant_inv) { + priv->rx_antenna_mode = + (priv->rx_antenna_mode == ANT_A) ? ANT_B : ANT_A; } /* Set initial antenna mode */ ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] greybus: gpio: switch GPIO portions to use GPIOLIB_IRQCHIP
Convert the GPIO driver to use the GPIO irqchip library GPIOLIB_IRQCHIP instead of reimplementing the same. Signed-off-by: Nishad Kamdar --- drivers/staging/greybus/Kconfig | 1 + drivers/staging/greybus/gpio.c | 123 ++-- 2 files changed, 21 insertions(+), 103 deletions(-) diff --git a/drivers/staging/greybus/Kconfig b/drivers/staging/greybus/Kconfig index ab096bcef98c..b571e4e8060b 100644 --- a/drivers/staging/greybus/Kconfig +++ b/drivers/staging/greybus/Kconfig @@ -148,6 +148,7 @@ if GREYBUS_BRIDGED_PHY config GREYBUS_GPIO tristate "Greybus GPIO Bridged PHY driver" depends on GPIOLIB + select GPIOLIB_IRQCHIP ---help--- Select this option if you have a device that follows the Greybus GPIO Bridged PHY Class specification. diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c index b1d4698019a1..32c228bad33a 100644 --- a/drivers/staging/greybus/gpio.c +++ b/drivers/staging/greybus/gpio.c @@ -9,9 +9,7 @@ #include #include #include -#include -#include -#include +#include #include #include "greybus.h" @@ -40,8 +38,6 @@ struct gb_gpio_controller { struct gpio_chipchip; struct irq_chip irqc; struct irq_chip *irqchip; - struct irq_domain *irqdomain; - unsigned intirq_base; irq_flow_handler_t irq_handler; unsigned intirq_default_type; struct mutexirq_lock; @@ -365,6 +361,7 @@ static int gb_gpio_request_handler(struct gb_operation *op) { struct gb_connection *connection = op->connection; struct gb_gpio_controller *ggc = gb_connection_get_data(connection); + struct gpio_chip *gc = &ggc->chip; struct device *dev = &ggc->gbphy_dev->dev; struct gb_message *request; struct gb_gpio_irq_event_request *event; @@ -391,7 +388,7 @@ static int gb_gpio_request_handler(struct gb_operation *op) return -EINVAL; } - irq = irq_find_mapping(ggc->irqdomain, event->which); + irq = irq_find_mapping(gc->irq.domain, event->which); if (!irq) { dev_err(dev, "failed to find IRQ\n"); return -EINVAL; @@ -506,68 +503,6 @@ static int gb_gpio_controller_setup(struct gb_gpio_controller *ggc) return ret; } -/** - * gb_gpio_irq_map() - maps an IRQ into a GB gpio irqchip - * @d: the irqdomain used by this irqchip - * @irq: the global irq number used by this GB gpio irqchip irq - * @hwirq: the local IRQ/GPIO line offset on this GB gpio - * - * This function will set up the mapping for a certain IRQ line on a - * GB gpio by assigning the GB gpio as chip data, and using the irqchip - * stored inside the GB gpio. - */ -static int gb_gpio_irq_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - struct gpio_chip *chip = domain->host_data; - struct gb_gpio_controller *ggc = gpio_chip_to_gb_gpio_controller(chip); - - irq_set_chip_data(irq, ggc); - irq_set_chip_and_handler(irq, ggc->irqchip, ggc->irq_handler); - irq_set_noprobe(irq); - /* -* No set-up of the hardware will happen if IRQ_TYPE_NONE -* is passed as default type. -*/ - if (ggc->irq_default_type != IRQ_TYPE_NONE) - irq_set_irq_type(irq, ggc->irq_default_type); - - return 0; -} - -static void gb_gpio_irq_unmap(struct irq_domain *d, unsigned int irq) -{ - irq_set_chip_and_handler(irq, NULL, NULL); - irq_set_chip_data(irq, NULL); -} - -static const struct irq_domain_ops gb_gpio_domain_ops = { - .map= gb_gpio_irq_map, - .unmap = gb_gpio_irq_unmap, -}; - -/** - * gb_gpio_irqchip_remove() - removes an irqchip added to a gb_gpio_controller - * @ggc: the gb_gpio_controller to remove the irqchip from - * - * This is called only from gb_gpio_remove() - */ -static void gb_gpio_irqchip_remove(struct gb_gpio_controller *ggc) -{ - unsigned int offset; - - /* Remove all IRQ mappings and delete the domain */ - if (ggc->irqdomain) { - for (offset = 0; offset < (ggc->line_max + 1); offset++) - irq_dispose_mapping(irq_find_mapping(ggc->irqdomain, -offset)); - irq_domain_remove(ggc->irqdomain); - } - - if (ggc->irqchip) - ggc->irqchip = NULL; -} - /** * gb_gpio_irqchip_add() - adds an irqchip to a gpio chip * @chip: the gpio chip to add the irqchip to @@ -595,8 +530,7 @@ static int gb_gpio_irqchip_add(struct gpio_chip *chip, unsigned int type) { struct gb_gpio_controller *ggc; - unsigned int offset; - unsigned int irq_base; + unsigned int err; if (!chip || !irqchip) return -EINVAL; @@ -606,35 +540,21 @@ static int gb_gpio_irqchip_add(st
[PATCH] greybus: gpio: switch GPIO portions to use GPIOLIB_IRQCHIP
Convert the GPIO driver to use the GPIO irqchip library GPIOLIB_IRQCHIP instead of reimplementing the same. Signed-off-by: Nishad Kamdar --- drivers/staging/greybus/Kconfig | 1 + drivers/staging/greybus/gpio.c | 123 ++-- 2 files changed, 21 insertions(+), 103 deletions(-) diff --git a/drivers/staging/greybus/Kconfig b/drivers/staging/greybus/Kconfig index ab096bcef98c..b571e4e8060b 100644 --- a/drivers/staging/greybus/Kconfig +++ b/drivers/staging/greybus/Kconfig @@ -148,6 +148,7 @@ if GREYBUS_BRIDGED_PHY config GREYBUS_GPIO tristate "Greybus GPIO Bridged PHY driver" depends on GPIOLIB + select GPIOLIB_IRQCHIP ---help--- Select this option if you have a device that follows the Greybus GPIO Bridged PHY Class specification. diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c index b1d4698019a1..32c228bad33a 100644 --- a/drivers/staging/greybus/gpio.c +++ b/drivers/staging/greybus/gpio.c @@ -9,9 +9,7 @@ #include #include #include -#include -#include -#include +#include #include #include "greybus.h" @@ -40,8 +38,6 @@ struct gb_gpio_controller { struct gpio_chipchip; struct irq_chip irqc; struct irq_chip *irqchip; - struct irq_domain *irqdomain; - unsigned intirq_base; irq_flow_handler_t irq_handler; unsigned intirq_default_type; struct mutexirq_lock; @@ -365,6 +361,7 @@ static int gb_gpio_request_handler(struct gb_operation *op) { struct gb_connection *connection = op->connection; struct gb_gpio_controller *ggc = gb_connection_get_data(connection); + struct gpio_chip *gc = &ggc->chip; struct device *dev = &ggc->gbphy_dev->dev; struct gb_message *request; struct gb_gpio_irq_event_request *event; @@ -391,7 +388,7 @@ static int gb_gpio_request_handler(struct gb_operation *op) return -EINVAL; } - irq = irq_find_mapping(ggc->irqdomain, event->which); + irq = irq_find_mapping(gc->irq.domain, event->which); if (!irq) { dev_err(dev, "failed to find IRQ\n"); return -EINVAL; @@ -506,68 +503,6 @@ static int gb_gpio_controller_setup(struct gb_gpio_controller *ggc) return ret; } -/** - * gb_gpio_irq_map() - maps an IRQ into a GB gpio irqchip - * @d: the irqdomain used by this irqchip - * @irq: the global irq number used by this GB gpio irqchip irq - * @hwirq: the local IRQ/GPIO line offset on this GB gpio - * - * This function will set up the mapping for a certain IRQ line on a - * GB gpio by assigning the GB gpio as chip data, and using the irqchip - * stored inside the GB gpio. - */ -static int gb_gpio_irq_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - struct gpio_chip *chip = domain->host_data; - struct gb_gpio_controller *ggc = gpio_chip_to_gb_gpio_controller(chip); - - irq_set_chip_data(irq, ggc); - irq_set_chip_and_handler(irq, ggc->irqchip, ggc->irq_handler); - irq_set_noprobe(irq); - /* -* No set-up of the hardware will happen if IRQ_TYPE_NONE -* is passed as default type. -*/ - if (ggc->irq_default_type != IRQ_TYPE_NONE) - irq_set_irq_type(irq, ggc->irq_default_type); - - return 0; -} - -static void gb_gpio_irq_unmap(struct irq_domain *d, unsigned int irq) -{ - irq_set_chip_and_handler(irq, NULL, NULL); - irq_set_chip_data(irq, NULL); -} - -static const struct irq_domain_ops gb_gpio_domain_ops = { - .map= gb_gpio_irq_map, - .unmap = gb_gpio_irq_unmap, -}; - -/** - * gb_gpio_irqchip_remove() - removes an irqchip added to a gb_gpio_controller - * @ggc: the gb_gpio_controller to remove the irqchip from - * - * This is called only from gb_gpio_remove() - */ -static void gb_gpio_irqchip_remove(struct gb_gpio_controller *ggc) -{ - unsigned int offset; - - /* Remove all IRQ mappings and delete the domain */ - if (ggc->irqdomain) { - for (offset = 0; offset < (ggc->line_max + 1); offset++) - irq_dispose_mapping(irq_find_mapping(ggc->irqdomain, -offset)); - irq_domain_remove(ggc->irqdomain); - } - - if (ggc->irqchip) - ggc->irqchip = NULL; -} - /** * gb_gpio_irqchip_add() - adds an irqchip to a gpio chip * @chip: the gpio chip to add the irqchip to @@ -595,8 +530,7 @@ static int gb_gpio_irqchip_add(struct gpio_chip *chip, unsigned int type) { struct gb_gpio_controller *ggc; - unsigned int offset; - unsigned int irq_base; + unsigned int err; if (!chip || !irqchip) return -EINVAL; @@ -606,35 +540,21 @@ static int gb_gpio_irqchip_add(st
[PATCH v7 3/3] staging: iio: ad2s1210: Add device tree table.
Add device tree table for matching vendor ID. Signed-off-by: Nishad Kamdar --- drivers/staging/iio/resolver/ad2s1210.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index d3e7d5aad2c8..7c50def91a2b 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -701,6 +701,12 @@ static int ad2s1210_remove(struct spi_device *spi) return 0; } +static const struct of_device_id ad2s1210_of_match[] = { + { .compatible = "adi,ad2s1210", }, + { } +}; +MODULE_DEVICE_TABLE(of, ad2s1210_of_match); + static const struct spi_device_id ad2s1210_id[] = { { "ad2s1210" }, {} @@ -710,6 +716,7 @@ MODULE_DEVICE_TABLE(spi, ad2s1210_id); static struct spi_driver ad2s1210_driver = { .driver = { .name = DRV_NAME, + .of_match_table = of_match_ptr(ad2s1210_of_match), }, .probe = ad2s1210_probe, .remove = ad2s1210_remove, -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v7 2/3] staging: iio: ad2s1210: Drop the gpioin flag.
Drop gpioin flag which decides how the GPIOs are controlled as the GPIOs must be outputs for the host as per the datasheet. Signed-off-by: Nishad Kamdar --- drivers/staging/iio/resolver/ad2s1210.c | 45 - drivers/staging/iio/resolver/ad2s1210.h | 17 -- 2 files changed, 6 insertions(+), 56 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 82ac9847f6f4..d3e7d5aad2c8 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -80,15 +80,7 @@ struct ad2s1210_gpio { unsigned long flags; }; -static const struct ad2s1210_gpio gpios_in[] = { - [AD2S1210_SAMPLE] = { .name = "adi,sample", .flags = GPIOD_IN }, - [AD2S1210_A0] = { .name = "adi,a0", .flags = GPIOD_IN }, - [AD2S1210_A1] = { .name = "adi,a1", .flags = GPIOD_IN }, - [AD2S1210_RES0] = { .name = "adi,res0", .flags = GPIOD_IN }, - [AD2S1210_RES1] = { .name = "adi,res1", .flags = GPIOD_IN }, -}; - -static const struct ad2s1210_gpio gpios_out[] = { +static const struct ad2s1210_gpio gpios[] = { [AD2S1210_SAMPLE] = { .name = "adi,sample", .flags = GPIOD_OUT_LOW }, [AD2S1210_A0] = { .name = "adi,a0", .flags = GPIOD_OUT_LOW }, [AD2S1210_A1] = { .name = "adi,a1", .flags = GPIOD_OUT_LOW }, @@ -99,7 +91,6 @@ static const struct ad2s1210_gpio gpios_out[] = { static const unsigned int ad2s1210_resolution_value[] = { 10, 12, 14, 16 }; struct ad2s1210_state { - const struct ad2s1210_platform_data *pdata; struct mutex lock; struct spi_device *sdev; struct gpio_desc *gpios[5]; @@ -180,14 +171,6 @@ int ad2s1210_update_frequency_control_word(struct ad2s1210_state *st) return ad2s1210_config_write(st, fcw); } -static unsigned char ad2s1210_read_resolution_pin(struct ad2s1210_state *st) -{ - int resolution = (gpiod_get_value(st->gpios[AD2S1210_RES0]) << 1) | - gpiod_get_value(st->gpios[AD2S1210_RES1]); - - return ad2s1210_resolution_value[resolution]; -} - static const int ad2s1210_res_pins[4][2] = { { 0, 0 }, {0, 1}, {1, 0}, {1, 1} }; @@ -333,13 +316,7 @@ static ssize_t ad2s1210_store_control(struct device *dev, } st->resolution = ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; - if (st->pdata->gpioin) { - data = ad2s1210_read_resolution_pin(st); - if (data != st->resolution) - dev_warn(dev, "ad2s1210: resolution settings not match\n"); - } else { - ad2s1210_set_resolution_pin(st); - } + ad2s1210_set_resolution_pin(st); ret = len; st->hysteresis = !!(data & AD2S1210_ENABLE_HYSTERESIS); @@ -395,13 +372,7 @@ static ssize_t ad2s1210_store_resolution(struct device *dev, } st->resolution = ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; - if (st->pdata->gpioin) { - data = ad2s1210_read_resolution_pin(st); - if (data != st->resolution) - dev_warn(dev, "ad2s1210: resolution settings not match\n"); - } else { - ad2s1210_set_resolution_pin(st); - } + ad2s1210_set_resolution_pin(st); ret = len; error_ret: mutex_unlock(&st->lock); @@ -622,10 +593,7 @@ static int ad2s1210_initial(struct ad2s1210_state *st) int ret; mutex_lock(&st->lock); - if (st->pdata->gpioin) - st->resolution = ad2s1210_read_resolution_pin(st); - else - ad2s1210_set_resolution_pin(st); + ad2s1210_set_resolution_pin(st); ret = ad2s1210_config_write(st, AD2S1210_REG_CONTROL); if (ret < 0) @@ -660,11 +628,11 @@ static const struct iio_info ad2s1210_info = { static int ad2s1210_setup_gpios(struct ad2s1210_state *st) { - struct ad2s1210_gpio *pin = st->pdata->gpioin ? &gpios_in[0] : &gpios_out[0]; + struct ad2s1210_gpio *pin = &gpios[0]; struct spi_device *spi = st->sdev; int i, ret; - for (i = 0; i < ARRAY_SIZE(gpios_in); i++) { + for (i = 0; i < ARRAY_SIZE(gpios); i++) { st->gpios[i] = devm_gpiod_get(&spi->dev, pin[i].name, pin[i].flags); if (IS_ERR(st->gpios[i])) { @@ -692,7 +660,6 @@ static int ad2s1210_probe(struct spi_device *spi) if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); - st->pdata = spi->dev.platform_data; ret = ad2s1210_setup_gpios(st); if (ret < 0) return ret; diff --git a/drivers/staging/iio/resolver/ad2s1210.h b/drivers/staging/iio/resolver/ad2s1210.h index 63d479b20a6c..e69de29bb2d1 100644 --- a/drivers/staging/iio/resolver/ad2s1210.h +++ b/drivers/staging/iio/resolver/ad2s1210.h @@ -1,17 +0,0 @@ -/* - * ad2s1210.h plaform data fo
[PATCH v7 1/3] staging: iio: ad2s1210: Switch to the gpio descriptor interface
Use the gpiod interface instead of the deprecated old non-descriptor interface. Signed-off-by: Nishad Kamdar --- drivers/staging/iio/resolver/ad2s1210.c | 106 ++-- drivers/staging/iio/resolver/ad2s1210.h | 3 - 2 files changed, 62 insertions(+), 47 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index ac13b99bd9cb..82ac9847f6f4 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include @@ -67,12 +67,42 @@ enum ad2s1210_mode { MOD_RESERVED, }; +enum ad2s1210_gpios { + AD2S1210_SAMPLE, + AD2S1210_A0, + AD2S1210_A1, + AD2S1210_RES0, + AD2S1210_RES1, +}; + +struct ad2s1210_gpio { + const char *name; + unsigned long flags; +}; + +static const struct ad2s1210_gpio gpios_in[] = { + [AD2S1210_SAMPLE] = { .name = "adi,sample", .flags = GPIOD_IN }, + [AD2S1210_A0] = { .name = "adi,a0", .flags = GPIOD_IN }, + [AD2S1210_A1] = { .name = "adi,a1", .flags = GPIOD_IN }, + [AD2S1210_RES0] = { .name = "adi,res0", .flags = GPIOD_IN }, + [AD2S1210_RES1] = { .name = "adi,res1", .flags = GPIOD_IN }, +}; + +static const struct ad2s1210_gpio gpios_out[] = { + [AD2S1210_SAMPLE] = { .name = "adi,sample", .flags = GPIOD_OUT_LOW }, + [AD2S1210_A0] = { .name = "adi,a0", .flags = GPIOD_OUT_LOW }, + [AD2S1210_A1] = { .name = "adi,a1", .flags = GPIOD_OUT_LOW }, + [AD2S1210_RES0] = { .name = "adi,res0", .flags = GPIOD_OUT_LOW }, + [AD2S1210_RES1] = { .name = "adi,res1", .flags = GPIOD_OUT_LOW }, +}; + static const unsigned int ad2s1210_resolution_value[] = { 10, 12, 14, 16 }; struct ad2s1210_state { const struct ad2s1210_platform_data *pdata; struct mutex lock; struct spi_device *sdev; + struct gpio_desc *gpios[5]; unsigned int fclkin; unsigned int fexcit; bool hysteresis; @@ -91,8 +121,8 @@ static const int ad2s1210_mode_vals[4][2] = { static inline void ad2s1210_set_mode(enum ad2s1210_mode mode, struct ad2s1210_state *st) { - gpio_set_value(st->pdata->a[0], ad2s1210_mode_vals[mode][0]); - gpio_set_value(st->pdata->a[1], ad2s1210_mode_vals[mode][1]); + gpiod_set_value(st->gpios[AD2S1210_A0], ad2s1210_mode_vals[mode][0]); + gpiod_set_value(st->gpios[AD2S1210_A1], ad2s1210_mode_vals[mode][1]); st->mode = mode; } @@ -152,8 +182,8 @@ int ad2s1210_update_frequency_control_word(struct ad2s1210_state *st) static unsigned char ad2s1210_read_resolution_pin(struct ad2s1210_state *st) { - int resolution = (gpio_get_value(st->pdata->res[0]) << 1) | - gpio_get_value(st->pdata->res[1]); + int resolution = (gpiod_get_value(st->gpios[AD2S1210_RES0]) << 1) | + gpiod_get_value(st->gpios[AD2S1210_RES1]); return ad2s1210_resolution_value[resolution]; } @@ -164,10 +194,10 @@ static const int ad2s1210_res_pins[4][2] = { static inline void ad2s1210_set_resolution_pin(struct ad2s1210_state *st) { - gpio_set_value(st->pdata->res[0], - ad2s1210_res_pins[(st->resolution - 10) / 2][0]); - gpio_set_value(st->pdata->res[1], - ad2s1210_res_pins[(st->resolution - 10) / 2][1]); + gpiod_set_value(st->gpios[AD2S1210_RES0], + ad2s1210_res_pins[(st->resolution - 10) / 2][0]); + gpiod_set_value(st->gpios[AD2S1210_RES1], + ad2s1210_res_pins[(st->resolution - 10) / 2][1]); } static inline int ad2s1210_soft_reset(struct ad2s1210_state *st) @@ -401,15 +431,15 @@ static ssize_t ad2s1210_clear_fault(struct device *dev, int ret; mutex_lock(&st->lock); - gpio_set_value(st->pdata->sample, 0); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 0); /* delay (2 * tck + 20) nano seconds */ udelay(1); - gpio_set_value(st->pdata->sample, 1); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 1); ret = ad2s1210_config_read(st, AD2S1210_REG_FAULT); if (ret < 0) goto error_ret; - gpio_set_value(st->pdata->sample, 0); - gpio_set_value(st->pdata->sample, 1); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 0); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 1); error_ret: mutex_unlock(&st->lock); @@ -466,7 +496,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, s16 vel; mutex_lock(&st->lock); - gpio_set_value(st->pdata->sample, 0); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 0); /* delay (6 * tck + 20) nano seconds */ udelay(1); @@ -512,7 +542,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, } error_ret: - gpio_set_value(st->pdata->sample, 1); +
[PATCH v7 0/3] staging: iio: ad2s1210: Switch to the gpio descriptor interface.
Use the gpiod interface instead of the deprecated old non-descriptor Changes in v7: - Adds a level of indirection to read and write the gpio_desc to make the code simpler. - Drop gpioin flag which decides how the GPIOs are controlled as the GPIOs must be outputs for the host as per the datasheet. Changes in v6: - Split device tree table addition and device tree support addition in two patches. - Replace platform data with device tree support. - Rename boolean property. Changes in v5: - Add device tree support. - Add device tree table for matching vendor ID. - Add Support for retrieving platform data from device tree. Changes in v4: - Add spaces after { and before } in gpios[] initialization. - Check the correct pointer for error. - Align the dev_err msg to existing format in the code. Changes in v3: - Use a pointer to pointer for gpio_desc in struct ad2s1210_gpio as it will be used to modify a pointer. - Use dot notation to initialize the structure. - Use a pointer variable to avoid writing gpios[i]. Changes in v2: - Use the spi_device struct embedded in st instead of passing it as an argument to ad2s1210_setup_gpios(). - Use an array of structs to reduce redundant code in in ad2s1210_setup_gpios(). - Remove ad2s1210_free_gpios() as devm API is being used. Nishad Kamdar (3): staging: iio: ad2s1210: Switch to the gpio descriptor interface staging: iio: ad2s1210: Drop the gpioin flag. staging: iio: ad2s1210: Add device tree table. drivers/staging/iio/resolver/ad2s1210.c | 132 +++- drivers/staging/iio/resolver/ad2s1210.h | 20 2 files changed, 62 insertions(+), 90 deletions(-) -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH v3] staging: vboxvideo: Remove unnecessary parentheses
Hi, On 31-10-18 16:03, Shayenne da Luz Moura wrote: Remove unneeded parentheses around the arguments of ||. This reduces clutter and code behave in the same way. Change suggested by checkpatch.pl. vbox_main.c:119: CHECK: Unnecessary parentheses around 'rects[i].x2 < crtc->x' Signed-off-by: Shayenne da Luz Moura Thank you. Still looks good to me: Acked-by: Hans de Goede Regards, Hans --- Changes in v2: - Make the commit message more clearer. Changes in v3: - Update to apply patch to the latest kernel tree drivers/staging/vboxvideo/vbox_main.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c index 7466c1103ff6..ad0e0b62bd1e 100644 --- a/drivers/staging/vboxvideo/vbox_main.c +++ b/drivers/staging/vboxvideo/vbox_main.c @@ -122,10 +122,10 @@ void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb, struct vbva_cmd_hdr cmd_hdr; unsigned int crtc_id = to_vbox_crtc(crtc)->crtc_id; - if ((rects[i].x1 > crtc_x + mode->hdisplay) || - (rects[i].y1 > crtc_y + mode->vdisplay) || - (rects[i].x2 < crtc_x) || - (rects[i].y2 < crtc_y)) + if (rects[i].x1 > crtc_x + mode->hdisplay || + rects[i].y1 > crtc_y + mode->vdisplay || + rects[i].x2 < crtc_x || + rects[i].y2 < crtc_y) continue; cmd_hdr.x = (s16)rects[i].x1; ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] Re: [PATCH v2] staging: vboxvideo: Remove unnecessary parentheses
On 10/30, Sasha Levin wrote: > On Tue, Oct 30, 2018 at 08:17:57PM -0300, Shayenne Moura wrote: > > On 10/30, Greg Kroah-Hartman wrote: > > > On Tue, Oct 23, 2018 at 02:43:04PM -0300, Shayenne da Luz Moura wrote: > > > > Remove unneeded parentheses around the arguments of ||. This reduces > > > > clutter and code behave in the same way. > > > > Change suggested by checkpatch.pl. > > > > > > > > vbox_main.c:119: CHECK: Unnecessary parentheses around 'rects[i].x2 < > > > > crtc->x' > > > > > > > > Signed-off-by: Shayenne da Luz Moura > > > > Reviewed-by: Hans de Goede > > > > --- > > > > Changes in v2: > > > > - Make the commit message more clearer. > > > > > > This patch does not apply to the latest kernel tree at all :( > > > > > > Please fix up and resend. > > > > > > thanks, > > > > > > greg k-h > > > > Hi Greg! > > > > Sorry, I do not know what branch are expected to be used. > > I used the drm-misc-next to create this patch and I could not > > find any merge problem. > > > > Could you please tell me the details? > > Hi Shayenne, > > There's an easy trick for this: the kernel tree has a script that can > help you find both the relevant maintainers, and their development tree > for each file in the kernel. > > Simply run: > > ./scripts/get_maintainer.pl --scm -f [filename] > > For example, in this case, you'd run: > > $ ./scripts/get_maintainer.pl --scm -f > drivers/staging/vboxvideo/vbox_main.c > Greg Kroah-Hartman (supporter:STAGING > SUBSYSTEM,commit_signer:10/10=100%) > Hans de Goede > (commit_signer:7/10=70%,authored:6/10=60%,added_lines:31/37=84%,removed_lines:153/159=96%) > Fabio Rafael da Rosa > (commit_signer:1/10=10%,authored:1/10=10%) > Alexander Kapshuk > (commit_signer:1/10=10%,authored:1/10=10%) > Nicholas Mc Guire (commit_signer:1/10=10%) > Thomas Zimmermann > (authored:1/10=10%,added_lines:2/37=5%) > Daniel Junho (authored:1/10=10%,added_lines:2/37=5%) > de...@driverdev.osuosl.org (open list:STAGING SUBSYSTEM) > linux-ker...@vger.kernel.org (open list) > git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git > > The list of people and mailing lists are the ones that should be the > recipients of your patch, and the last line is the git tree on which the > patch should be based on. > > -- > Thanks, > Sasha Thanks Sasha! It is a very nice tip! Best regards, Shayenne ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v3] staging: vboxvideo: Remove unnecessary parentheses
Remove unneeded parentheses around the arguments of ||. This reduces clutter and code behave in the same way. Change suggested by checkpatch.pl. vbox_main.c:119: CHECK: Unnecessary parentheses around 'rects[i].x2 < crtc->x' Signed-off-by: Shayenne da Luz Moura --- Changes in v2: - Make the commit message more clearer. Changes in v3: - Update to apply patch to the latest kernel tree drivers/staging/vboxvideo/vbox_main.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c index 7466c1103ff6..ad0e0b62bd1e 100644 --- a/drivers/staging/vboxvideo/vbox_main.c +++ b/drivers/staging/vboxvideo/vbox_main.c @@ -122,10 +122,10 @@ void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb, struct vbva_cmd_hdr cmd_hdr; unsigned int crtc_id = to_vbox_crtc(crtc)->crtc_id; - if ((rects[i].x1 > crtc_x + mode->hdisplay) || - (rects[i].y1 > crtc_y + mode->vdisplay) || - (rects[i].x2 < crtc_x) || - (rects[i].y2 < crtc_y)) + if (rects[i].x1 > crtc_x + mode->hdisplay || + rects[i].y1 > crtc_y + mode->vdisplay || + rects[i].x2 < crtc_x || + rects[i].y2 < crtc_y) continue; cmd_hdr.x = (s16)rects[i].x1; -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: comedi: addi_apci_3501: Use insn->n in EEPROM insn_read handler
The `insn_read` handler for the EEPROM subdevice (`apci3501_eeprom_insn_read()`) currently ignores `insn->n` (the number of samples to be read) and assumes a single sample is to be read. But `insn->n` could be 0, meaning no samples should be read, in which case `data[0]` ought not to be written. (The comedi core at least ensures that `data[0]` exists, but we should not rely on that.) Following the usual Comedi guidelines and interpret `insn->n` as the number of samples to be read, but only read the EEPROM location once and make `insn->n` copies, as we don't expect the contents of the EEPROM location to change between readings. Signed-off-by: Ian Abbott --- drivers/staging/comedi/drivers/addi_apci_3501.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c index a38267928e5e..b4aa588975df 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3501.c +++ b/drivers/staging/comedi/drivers/addi_apci_3501.c @@ -258,8 +258,15 @@ static int apci3501_eeprom_insn_read(struct comedi_device *dev, { struct apci3501_private *devpriv = dev->private; unsigned short addr = CR_CHAN(insn->chanspec); + unsigned int val; + unsigned int i; - data[0] = apci3501_eeprom_readw(devpriv->amcc, 2 * addr); + if (insn->n) { + /* No point reading the same EEPROM location more than once. */ + val = apci3501_eeprom_readw(devpriv->amcc, 2 * addr); + for (i = 0; i < insn->n; i++) + data[i] = val; + } return insn->n; } -- 2.19.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: comedi: change do_insn*_ioctl to allow more samples
On 25/10/18 02:36, Spencer E. Olson wrote: Changes do_insn*_ioctl functions to allow for data lengths for each comedi_insn of up to 2^16. This patch also changes these functions to only allocate as much memory as is necessary for each comedi_insn, rather than allocating a fixed-sized scratch space. In testing some user-space code for the new INSN_DEVICE_CONFIG_GET_ROUTES facility with some newer hardware, I discovered that do_insn_ioctl and do_insnlist_ioctl limited the amount of data that can be passed into the kernel for insn's to a length of 256. For some newer hardware, the number of routes can be greater than 1000. Working around the old limits (256) would complicate the user-space/kernel interaction. The new upper limit is reasonable with current memory available and does not otherwise impact the memory footprint for any current or otherwise typical configuration. Signed-off-by: Spencer E. Olson --- drivers/staging/comedi/comedi_fops.c | 37 +--- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index c1c6b2b4ab91..a163ec2df872 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1500,7 +1500,7 @@ static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, *data (for reads) to insns[].data pointers */ /* arbitrary limits */ -#define MAX_SAMPLES 256 +#define MAX_SAMPLES 65536 static int do_insnlist_ioctl(struct comedi_device *dev, struct comedi_insnlist __user *arg, void *file) { @@ -1513,12 +1513,6 @@ static int do_insnlist_ioctl(struct comedi_device *dev, if (copy_from_user(&insnlist, arg, sizeof(insnlist))) return -EFAULT; - data = kmalloc_array(MAX_SAMPLES, sizeof(unsigned int), GFP_KERNEL); - if (!data) { - ret = -ENOMEM; - goto error; - } - insns = kcalloc(insnlist.n_insns, sizeof(*insns), GFP_KERNEL); if (!insns) { ret = -ENOMEM; @@ -1539,6 +1533,14 @@ static int do_insnlist_ioctl(struct comedi_device *dev, ret = -EINVAL; goto error; } + + data = kmalloc_array(insns[i].n, sizeof(unsigned int), +GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto error; + } + Something you could do here is work out which insn->n in the instruction list is the largest, and allocate the 'data' once outside the instruction list handling loop instead of allocating it inside the loop. -- -=( Ian Abbott || Web: www.mev.co.uk )=- -=( MEV Ltd. is a company registered in England & Wales. )=- -=( Registered number: 02862268. Registered address:)=- -=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: comedi: change do_insn*_ioctl to allow more samples
On 30/10/18 22:27, Spencer Olson wrote: On Tue, Oct 30, 2018 at 6:21 AM Ian Abbott wrote: On 25/10/18 02:36, Spencer E. Olson wrote: Changes do_insn*_ioctl functions to allow for data lengths for each comedi_insn of up to 2^16. This patch also changes these functions to only allocate as much memory as is necessary for each comedi_insn, rather than allocating a fixed-sized scratch space. In testing some user-space code for the new INSN_DEVICE_CONFIG_GET_ROUTES facility with some newer hardware, I discovered that do_insn_ioctl and do_insnlist_ioctl limited the amount of data that can be passed into the kernel for insn's to a length of 256. For some newer hardware, the number of routes can be greater than 1000. Working around the old limits (256) would complicate the user-space/kernel interaction. The new upper limit is reasonable with current memory available and does not otherwise impact the memory footprint for any current or otherwise typical configuration. [snip] There are still some broken drivers that do not check insn->n and assume the data has some minimum length, so we will need to make the data array some minimum length (say 16 * sizeof(unsigned int)) until those drivers have been fixed. I don't think that would be much of a problem, since 16*sizeof(uint) is pretty negligible. How certain are you that we would not have to make that higher, as the previous default was a length of 256*sizeof(uint)? It'll take me a day or two to resubmit (have other things pressing on my time). ai_config_master_clock() in cb_pcidas64.c is the worst offender of using unchecked data[] length, and that only uses a data[] length of 5. I've checked all the insn_read, insn_write, and insn_config handlers now and found a couple more drivers with the problem of potentially using data[] members beyond insn->n-1. These are "s626.c" and "addi_apci_3501.c". (The previously found files with the problem are "cb_pcidas64.c", "cb_pcidda.c", "ni_labpc_common.c", "ni_mio_common.c", and "s526.c". I've submitted patches for some of those, and will submit patches for the others sometime in the next few days.) -- -=( Ian Abbott || Web: www.mev.co.uk )=- -=( MEV Ltd. is a company registered in England & Wales. )=- -=( Registered number: 02862268. Registered address:)=- -=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=- ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel