mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-14 08:51:46 -04:00
gpio: virtio: Fix config space reading.
Quote from the virtio specification chapter 4.2.2.2:
"For the device-specific configuration space, the driver MUST use 8 bit
wide accesses for 8 bit wide fields, 16 bit wide and aligned accesses
for 16 bit wide fields and 32 bit wide and aligned accesses for 32 and
64 bit wide fields."
Signed-off-by: Harald Mommer <harald.mommer@oss.qualcomm.com>
Cc: stable@vger.kernel.org
Fixes: 3a29355a22 ("gpio: Add virtio-gpio driver")
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/20250724143718.5442-2-harald.mommer@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
committed by
Bartosz Golaszewski
parent
678bae2eaa
commit
4740e1e2f3
@@ -527,7 +527,6 @@ static const char **virtio_gpio_get_names(struct virtio_gpio *vgpio,
|
||||
|
||||
static int virtio_gpio_probe(struct virtio_device *vdev)
|
||||
{
|
||||
struct virtio_gpio_config config;
|
||||
struct device *dev = &vdev->dev;
|
||||
struct virtio_gpio *vgpio;
|
||||
struct irq_chip *gpio_irq_chip;
|
||||
@@ -540,9 +539,11 @@ static int virtio_gpio_probe(struct virtio_device *vdev)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Read configuration */
|
||||
virtio_cread_bytes(vdev, 0, &config, sizeof(config));
|
||||
gpio_names_size = le32_to_cpu(config.gpio_names_size);
|
||||
ngpio = le16_to_cpu(config.ngpio);
|
||||
gpio_names_size =
|
||||
virtio_cread32(vdev, offsetof(struct virtio_gpio_config,
|
||||
gpio_names_size));
|
||||
ngpio = virtio_cread16(vdev, offsetof(struct virtio_gpio_config,
|
||||
ngpio));
|
||||
if (!ngpio) {
|
||||
dev_err(dev, "Number of GPIOs can't be zero\n");
|
||||
return -EINVAL;
|
||||
|
||||
Reference in New Issue
Block a user