[media] em28xx: remove GPIO register caching
authorFrank Schaefer <fschaefer.oss@googlemail.com>
Mon, 3 Jun 2013 17:12:05 +0000 (14:12 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 19 Jun 2013 14:43:20 +0000 (11:43 -0300)
The GPIO register caching is the result of wrong assumptions and incomplete
knowledge about the GPIO registers and their functionality.
Today, we know that it is not needed.
It is also limited to a single register and therefore incomplete (newer chips
are using multiple registers).
Instead of extending the caching, get rid of it, because it has no real
benefits and just bloats/complicates the code.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/usb/em28xx/em28xx-cards.c
drivers/media/usb/em28xx/em28xx-core.c
drivers/media/usb/em28xx/em28xx.h

index 6ee4bed730dd19c5e5ed6a223f5422f0d6540e9b..dc65742c4bbcabfddf54f8fdd9797d6bdf162a6f 100644 (file)
@@ -2896,10 +2896,6 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
 
        em28xx_set_model(dev);
 
-       /* Set the default GPO/GPIO for legacy devices */
-       dev->reg_gpo_num = EM2880_R04_GPO;
-       dev->reg_gpio_num = EM2820_R08_GPIO_CTRL;
-
        dev->wait_after_write = 5;
 
        /* Based on the Chip ID, set the device configuration */
@@ -2947,13 +2943,11 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
                        break;
                case CHIP_ID_EM2874:
                        chip_name = "em2874";
-                       dev->reg_gpio_num = EM2874_R80_GPIO_P0_CTRL;
                        dev->wait_after_write = 0;
                        dev->eeprom_addrwidth_16bit = 1;
                        break;
                case CHIP_ID_EM28174:
                        chip_name = "em28174";
-                       dev->reg_gpio_num = EM2874_R80_GPIO_P0_CTRL;
                        dev->wait_after_write = 0;
                        dev->eeprom_addrwidth_16bit = 1;
                        break;
@@ -2963,7 +2957,6 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
                        break;
                case CHIP_ID_EM2884:
                        chip_name = "em2884";
-                       dev->reg_gpio_num = EM2874_R80_GPIO_P0_CTRL;
                        dev->wait_after_write = 0;
                        dev->eeprom_addrwidth_16bit = 1;
                        break;
@@ -2992,11 +2985,6 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
                return 0;
        }
 
-       /* Prepopulate cached GPO register content */
-       retval = em28xx_read_reg(dev, dev->reg_gpo_num);
-       if (retval >= 0)
-               dev->reg_gpo = retval;
-
        em28xx_pre_card_setup(dev);
 
        if (!dev->board.is_em2800) {
index a802128ce9c591e57cb7e35b20131e03b15e53e5..fc157af5234a3e2c82c83dbd3f6d498758b96589 100644 (file)
@@ -193,23 +193,7 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
 
 int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len)
 {
-       int rc;
-
-       rc = em28xx_write_regs_req(dev, USB_REQ_GET_STATUS, reg, buf, len);
-
-       /* Stores GPO/GPIO values at the cache, if changed
-          Only write values should be stored, since input on a GPIO
-          register will return the input bits.
-          Not sure what happens on reading GPO register.
-        */
-       if (rc >= 0) {
-               if (reg == dev->reg_gpo_num)
-                       dev->reg_gpo = buf[0];
-               else if (reg == dev->reg_gpio_num)
-                       dev->reg_gpio = buf[0];
-       }
-
-       return rc;
+       return em28xx_write_regs_req(dev, USB_REQ_GET_STATUS, reg, buf, len);
 }
 EXPORT_SYMBOL_GPL(em28xx_write_regs);
 
@@ -231,14 +215,7 @@ int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
        int oldval;
        u8 newval;
 
-       /* Uses cache for gpo/gpio registers */
-       if (reg == dev->reg_gpo_num)
-               oldval = dev->reg_gpo;
-       else if (reg == dev->reg_gpio_num)
-               oldval = dev->reg_gpio;
-       else
-               oldval = em28xx_read_reg(dev, reg);
-
+       oldval = em28xx_read_reg(dev, reg);
        if (oldval < 0)
                return oldval;
 
index 59a95802aa680e1e55a53efaab8a7e625bccdaa5..205e9038b1c0d406989a180d059b9f68e7b517c5 100644 (file)
@@ -637,12 +637,6 @@ struct em28xx {
 
        enum em28xx_mode mode;
 
-       /* register numbers for GPO/GPIO registers */
-       u16 reg_gpo_num, reg_gpio_num;
-
-       /* Caches GPO and GPIO registers */
-       unsigned char   reg_gpo, reg_gpio;
-
        /* Snapshot button */
        char snapshot_button_path[30];  /* path of the input dev */
        struct input_dev *sbutton_input_dev;