]> Git Repo - linux.git/commitdiff
Merge branch 'next' into for-linus
authorDmitry Torokhov <[email protected]>
Fri, 12 Nov 2021 05:58:54 +0000 (21:58 -0800)
committerDmitry Torokhov <[email protected]>
Fri, 12 Nov 2021 05:58:54 +0000 (21:58 -0800)
Prepare input updates for 5.16 merge window.

1  2 
drivers/input/joystick/analog.c
drivers/input/touchscreen/elants_i2c.c

index 882c3c8ba3999186e2a56a14153cfc2364f312dd,d9f866ffde6b0297da3987eca9f08572190ca9de..3088c5b829f07a6f8050d680a226f10979c2dc6d
@@@ -19,6 -19,7 +19,7 @@@
  #include <linux/input.h>
  #include <linux/gameport.h>
  #include <linux/jiffies.h>
+ #include <linux/seq_buf.h>
  #include <linux/timex.h>
  #include <linux/timekeeping.h>
  
@@@ -28,6 -29,10 +29,6 @@@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@
  MODULE_DESCRIPTION(DRIVER_DESC);
  MODULE_LICENSE("GPL");
  
 -static bool use_ktime = true;
 -module_param(use_ktime, bool, 0400);
 -MODULE_PARM_DESC(use_ktime, "Use ktime for measuring I/O speed");
 -
  /*
   * Option parsing.
   */
@@@ -106,6 -111,7 +107,6 @@@ struct analog_port 
        char cooked;
        int bads;
        int reads;
 -      int speed;
        int loop;
        int fuzz;
        int axes[4];
        int axtime;
  };
  
 -/*
 - * Time macros.
 - */
 -
 -#ifdef __i386__
 -
 -#include <linux/i8253.h>
 -
 -#define GET_TIME(x)   do { if (boot_cpu_has(X86_FEATURE_TSC)) x = (unsigned int)rdtsc(); else x = get_time_pit(); } while (0)
 -#define DELTA(x,y)    (boot_cpu_has(X86_FEATURE_TSC) ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? PIT_TICK_RATE / HZ : 0)))
 -#define TIME_NAME     (boot_cpu_has(X86_FEATURE_TSC)?"TSC":"PIT")
 -static unsigned int get_time_pit(void)
 -{
 -        unsigned long flags;
 -        unsigned int count;
 -
 -        raw_spin_lock_irqsave(&i8253_lock, flags);
 -        outb_p(0x00, 0x43);
 -        count = inb_p(0x40);
 -        count |= inb_p(0x40) << 8;
 -        raw_spin_unlock_irqrestore(&i8253_lock, flags);
 -
 -        return count;
 -}
 -#elif defined(__x86_64__)
 -#define GET_TIME(x)   do { x = (unsigned int)rdtsc(); } while (0)
 -#define DELTA(x,y)    ((y)-(x))
 -#define TIME_NAME     "TSC"
 -#elif defined(__alpha__) || defined(CONFIG_ARM) || defined(CONFIG_ARM64) || defined(CONFIG_PPC) || defined(CONFIG_RISCV)
 -#define GET_TIME(x)   do { x = get_cycles(); } while (0)
 -#define DELTA(x,y)    ((y)-(x))
 -#define TIME_NAME     "get_cycles"
 -#else
 -#define FAKE_TIME
 -static unsigned long analog_faketime = 0;
 -#define GET_TIME(x)     do { x = analog_faketime++; } while(0)
 -#define DELTA(x,y)    ((y)-(x))
 -#define TIME_NAME     "Unreliable"
 -#warning Precise timer not defined for this architecture.
 -#endif
 -
 -static inline u64 get_time(void)
 -{
 -      if (use_ktime) {
 -              return ktime_get_ns();
 -      } else {
 -              unsigned int x;
 -              GET_TIME(x);
 -              return x;
 -      }
 -}
 -
 -static inline unsigned int delta(u64 x, u64 y)
 -{
 -      if (use_ktime)
 -              return y - x;
 -      else
 -              return DELTA((unsigned int)x, (unsigned int)y);
 -}
 -
  /*
   * analog_decode() decodes analog joystick data and reports input events.
   */
@@@ -169,18 -235,18 +170,18 @@@ static void analog_decode(struct analo
  static int analog_cooked_read(struct analog_port *port)
  {
        struct gameport *gameport = port->gameport;
 -      u64 time[4], start, loop, now;
 +      ktime_t time[4], start, loop, now;
        unsigned int loopout, timeout;
        unsigned char data[4], this, last;
        unsigned long flags;
        int i, j;
  
        loopout = (ANALOG_LOOP_TIME * port->loop) / 1000;
 -      timeout = ANALOG_MAX_TIME * port->speed;
 +      timeout = ANALOG_MAX_TIME * NSEC_PER_MSEC;
  
        local_irq_save(flags);
        gameport_trigger(gameport);
 -      now = get_time();
 +      now = ktime_get();
        local_irq_restore(flags);
  
        start = now;
  
                local_irq_disable();
                this = gameport_read(gameport) & port->mask;
 -              now = get_time();
 +              now = ktime_get();
                local_irq_restore(flags);
  
 -              if ((last ^ this) && (delta(loop, now) < loopout)) {
 +              if ((last ^ this) && (ktime_sub(now, loop) < loopout)) {
                        data[i] = last ^ this;
                        time[i] = now;
                        i++;
                }
  
 -      } while (this && (i < 4) && (delta(start, now) < timeout));
 +      } while (this && (i < 4) && (ktime_sub(now, start) < timeout));
  
        this <<= 4;
  
                this |= data[i];
                for (j = 0; j < 4; j++)
                        if (data[i] & (1 << j))
 -                              port->axes[j] = (delta(start, time[i]) << ANALOG_FUZZ_BITS) / port->loop;
 +                              port->axes[j] = ((u32)ktime_sub(time[i], start) << ANALOG_FUZZ_BITS) / port->loop;
        }
  
        return -(this != port->mask);
@@@ -310,22 -376,38 +311,22 @@@ static void analog_calibrate_timer(stru
  {
        struct gameport *gameport = port->gameport;
        unsigned int i, t, tx;
 -      u64 t1, t2, t3;
 +      ktime_t t1, t2, t3;
        unsigned long flags;
  
 -      if (use_ktime) {
 -              port->speed = 1000000;
 -      } else {
 -              local_irq_save(flags);
 -              t1 = get_time();
 -#ifdef FAKE_TIME
 -              analog_faketime += 830;
 -#endif
 -              mdelay(1);
 -              t2 = get_time();
 -              t3 = get_time();
 -              local_irq_restore(flags);
 -
 -              port->speed = delta(t1, t2) - delta(t2, t3);
 -      }
 -
        tx = ~0;
  
        for (i = 0; i < 50; i++) {
                local_irq_save(flags);
 -              t1 = get_time();
 +              t1 = ktime_get();
                for (t = 0; t < 50; t++) {
                        gameport_read(gameport);
 -                      t2 = get_time();
 +                      t2 = ktime_get();
                }
 -              t3 = get_time();
 +              t3 = ktime_get();
                local_irq_restore(flags);
                udelay(i);
 -              t = delta(t1, t2) - delta(t2, t3);
 +              t = ktime_sub(t2, t1) - ktime_sub(t3, t2);
                if (t < tx) tx = t;
        }
  
  
  static void analog_name(struct analog *analog)
  {
-       snprintf(analog->name, sizeof(analog->name), "Analog %d-axis %d-button",
+       struct seq_buf s;
+       seq_buf_init(&s, analog->name, sizeof(analog->name));
+       seq_buf_printf(&s, "Analog %d-axis %d-button",
                 hweight8(analog->mask & ANALOG_AXES_STD),
                 hweight8(analog->mask & ANALOG_BTNS_STD) + !!(analog->mask & ANALOG_BTNS_CHF) * 2 +
                 hweight16(analog->mask & ANALOG_BTNS_GAMEPAD) + !!(analog->mask & ANALOG_HBTN_CHF) * 4);
  
        if (analog->mask & ANALOG_HATS_ALL)
-               snprintf(analog->name, sizeof(analog->name), "%s %d-hat",
-                        analog->name, hweight16(analog->mask & ANALOG_HATS_ALL));
+               seq_buf_printf(&s, " %d-hat",
+                              hweight16(analog->mask & ANALOG_HATS_ALL));
  
        if (analog->mask & ANALOG_HAT_FCS)
-               strlcat(analog->name, " FCS", sizeof(analog->name));
+               seq_buf_printf(&s, " FCS");
        if (analog->mask & ANALOG_ANY_CHF)
-               strlcat(analog->name, (analog->mask & ANALOG_SAITEK) ? " Saitek" : " CHF",
-                       sizeof(analog->name));
+               seq_buf_printf(&s, (analog->mask & ANALOG_SAITEK) ? " Saitek" : " CHF");
  
-       strlcat(analog->name, (analog->mask & ANALOG_GAMEPAD) ? " gamepad": " joystick",
-               sizeof(analog->name));
+       seq_buf_printf(&s, (analog->mask & ANALOG_GAMEPAD) ? " gamepad" : " joystick");
  }
  
  /*
@@@ -530,7 -613,7 +532,7 @@@ static int analog_init_port(struct game
                t = gameport_read(gameport);
                msleep(ANALOG_MAX_TIME);
                port->mask = (gameport_read(gameport) ^ t) & t & 0xf;
 -              port->fuzz = (port->speed * ANALOG_FUZZ_MAGIC) / port->loop / 1000 + ANALOG_FUZZ_BITS;
 +              port->fuzz = (NSEC_PER_MSEC * ANALOG_FUZZ_MAGIC) / port->loop / 1000 + ANALOG_FUZZ_BITS;
  
                for (i = 0; i < ANALOG_INIT_RETRIES; i++) {
                        if (!analog_cooked_read(port))
index 68f542bb809f4ae4f0b1819149eb5d3b997d8260,98ba5cab685bca0f84ebdae4963c519ff100e718..7e13a66a8a95c8f9729ba7791df4cb97737b5a49
@@@ -1369,7 -1369,8 +1369,7 @@@ static bool elants_acpi_is_hid_device(s
  }
  #endif
  
 -static int elants_i2c_probe(struct i2c_client *client,
 -                          const struct i2c_device_id *id)
 +static int elants_i2c_probe(struct i2c_client *client)
  {
        union i2c_smbus_data dummy;
        struct elants_data *ts;
        init_completion(&ts->cmd_done);
  
        ts->client = client;
 -      ts->chip_id = (enum elants_chip_id)id->driver_data;
 +      ts->chip_id = (enum elants_chip_id)(uintptr_t)device_get_match_data(&client->dev);
        i2c_set_clientdata(client, ts);
  
        ts->vcc33 = devm_regulator_get(&client->dev, "vcc33");
        if (error)
                return error;
  
-       error = devm_add_action(&client->dev, elants_i2c_power_off, ts);
+       error = devm_add_action_or_reset(&client->dev,
+                                        elants_i2c_power_off, ts);
        if (error) {
                dev_err(&client->dev,
                        "failed to install power off action: %d\n", error);
-               elants_i2c_power_off(ts);
                return error;
        }
  
@@@ -1635,15 -1636,15 +1635,15 @@@ MODULE_DEVICE_TABLE(acpi, elants_acpi_i
  
  #ifdef CONFIG_OF
  static const struct of_device_id elants_of_match[] = {
 -      { .compatible = "elan,ekth3500" },
 -      { .compatible = "elan,ektf3624" },
 +      { .compatible = "elan,ekth3500", .data = (void *)EKTH3500 },
 +      { .compatible = "elan,ektf3624", .data = (void *)EKTF3624 },
        { /* sentinel */ }
  };
  MODULE_DEVICE_TABLE(of, elants_of_match);
  #endif
  
  static struct i2c_driver elants_i2c_driver = {
 -      .probe = elants_i2c_probe,
 +      .probe_new = elants_i2c_probe,
        .id_table = elants_i2c_id,
        .driver = {
                .name = DEVICE_NAME,
This page took 0.070185 seconds and 4 git commands to generate.