summaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2023-06-29 20:20:38 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2023-06-29 20:20:38 +0300
commit675285ad819293844018aa8096ba9a6d7c77b90b (patch)
tree9cfbd3e4ca5457b041fcc99b9ad5c2f3d5d400e9 /drivers/media
parente5476f57b32621eb8eab892a908df4d0b4808835 (diff)
parentc2d22806aecb24e2de55c30a06e5d6eb297d161d (diff)
downloadlinux-675285ad819293844018aa8096ba9a6d7c77b90b.tar.xz
Merge tag 'fbdev-for-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev
Pull fbdev updates from Helge Deller: "Some fbdev fixes & cleanups. Includes is a fix for a potential out-of-bound memory access in fast_imageblit() and the switch of the VIA fbdev driver to use GPIO descriptors. Summary: - fix potential OOB read in fast_imageblit() - fbdev/media: Use GPIO descriptors for VIA GPIO - broadsheetfb & metronomefb: Add MODULE_FIRMWARE macro - omapfb: error handling fix in mipid_spi_probe() - sh_mobile_lcdcfb, sh7760fb: Typo and warning fixes - hitfb: code cleanups" * tag 'fbdev-for-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev: fbdev: fix potential OOB read in fast_imageblit() MAINTAINERS: adjust entry in VIA UNICHROME(PRO)/CHROME9 FRAMEBUFFER DRIVER fbdev: sh7760fb: Fix -Wimplicit-fallthrough warnings fbdev: sh_mobile_lcdcfb: Fix ARGB32 overlay format typo fbdev: hitfb: Use NULL for pointers fbdev: hitfb: Fix integer-to-pointer cast fbdev/media: Use GPIO descriptors for VIA GPIO video/hdmi: Reorder fields in 'struct hdmi_avi_infoframe' fbdev: broadsheetfb: Add MODULE_FIRMWARE macro fbdev: metronomefb: Add MODULE_FIRMWARE macro fbdev: hitfb: Declare hitfb_blank() as static fbdev: omapfb: lcd_mipid: Fix an error handling path in mipid_spi_probe()
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/platform/via/via-camera.c51
1 files changed, 20 insertions, 31 deletions
diff --git a/drivers/media/platform/via/via-camera.c b/drivers/media/platform/via/via-camera.c
index 450254403fa8..4cb8f29e2f14 100644
--- a/drivers/media/platform/via/via-camera.c
+++ b/drivers/media/platform/via/via-camera.c
@@ -11,7 +11,7 @@
#include <linux/device.h>
#include <linux/list.h>
#include <linux/pci.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/videodev2.h>
@@ -26,7 +26,6 @@
#include <linux/dma-mapping.h>
#include <linux/pm_qos.h>
#include <linux/via-core.h>
-#include <linux/via-gpio.h>
#include <linux/via_i2c.h>
#ifdef CONFIG_X86
@@ -71,8 +70,8 @@ struct via_camera {
/*
* GPIO info for power/reset management
*/
- int power_gpio;
- int reset_gpio;
+ struct gpio_desc *power_gpio;
+ struct gpio_desc *reset_gpio;
/*
* I/O memory stuff.
*/
@@ -180,27 +179,19 @@ static struct via_format *via_find_format(u32 pixelformat)
*/
static int via_sensor_power_setup(struct via_camera *cam)
{
- int ret;
+ struct device *dev = &cam->platdev->dev;
+
+ cam->power_gpio = devm_gpiod_get(dev, "VGPIO3", GPIOD_OUT_LOW);
+ if (IS_ERR(cam->power_gpio))
+ return dev_err_probe(dev, PTR_ERR(cam->power_gpio),
+ "failed to get power GPIO");
+
+ /* Request the reset line asserted */
+ cam->reset_gpio = devm_gpiod_get(dev, "VGPIO2", GPIOD_OUT_HIGH);
+ if (IS_ERR(cam->reset_gpio))
+ return dev_err_probe(dev, PTR_ERR(cam->reset_gpio),
+ "failed to get reset GPIO");
- cam->power_gpio = viafb_gpio_lookup("VGPIO3");
- cam->reset_gpio = viafb_gpio_lookup("VGPIO2");
- if (!gpio_is_valid(cam->power_gpio) || !gpio_is_valid(cam->reset_gpio)) {
- dev_err(&cam->platdev->dev, "Unable to find GPIO lines\n");
- return -EINVAL;
- }
- ret = gpio_request(cam->power_gpio, "viafb-camera");
- if (ret) {
- dev_err(&cam->platdev->dev, "Unable to request power GPIO\n");
- return ret;
- }
- ret = gpio_request(cam->reset_gpio, "viafb-camera");
- if (ret) {
- dev_err(&cam->platdev->dev, "Unable to request reset GPIO\n");
- gpio_free(cam->power_gpio);
- return ret;
- }
- gpio_direction_output(cam->power_gpio, 0);
- gpio_direction_output(cam->reset_gpio, 0);
return 0;
}
@@ -209,25 +200,23 @@ static int via_sensor_power_setup(struct via_camera *cam)
*/
static void via_sensor_power_up(struct via_camera *cam)
{
- gpio_set_value(cam->power_gpio, 1);
- gpio_set_value(cam->reset_gpio, 0);
+ gpiod_set_value(cam->power_gpio, 1);
+ gpiod_set_value(cam->reset_gpio, 1);
msleep(20); /* Probably excessive */
- gpio_set_value(cam->reset_gpio, 1);
+ gpiod_set_value(cam->reset_gpio, 0);
msleep(20);
}
static void via_sensor_power_down(struct via_camera *cam)
{
- gpio_set_value(cam->power_gpio, 0);
- gpio_set_value(cam->reset_gpio, 0);
+ gpiod_set_value(cam->power_gpio, 0);
+ gpiod_set_value(cam->reset_gpio, 1);
}
static void via_sensor_power_release(struct via_camera *cam)
{
via_sensor_power_down(cam);
- gpio_free(cam->power_gpio);
- gpio_free(cam->reset_gpio);
}
/* --------------------------------------------------------------------------*/