]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Input: ibm-panel - use guard notation when acquiring spinlock
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 4 Sep 2024 04:47:33 +0000 (21:47 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 3 Oct 2024 16:10:36 +0000 (09:10 -0700)
Using guard notation makes the code more compact and error handling
more robust by ensuring that locks are released in all code paths
when control leaves critical section.

Reviewed-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240904044735.1047285-1-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/ibm-panel.c

index 867ac7aa10d2c16df6c4f2ea9876449ac615411c..aa48f62d7ea05437a84e3df324bead1add68ce7c 100644 (file)
@@ -77,12 +77,11 @@ static void ibm_panel_process_command(struct ibm_panel *panel)
 static int ibm_panel_i2c_slave_cb(struct i2c_client *client,
                                  enum i2c_slave_event event, u8 *val)
 {
-       unsigned long flags;
        struct ibm_panel *panel = i2c_get_clientdata(client);
 
        dev_dbg(&panel->input->dev, "event: %u data: %02x\n", event, *val);
 
-       spin_lock_irqsave(&panel->lock, flags);
+       guard(spinlock_irqsave)(&panel->lock);
 
        switch (event) {
        case I2C_SLAVE_STOP:
@@ -114,8 +113,6 @@ static int ibm_panel_i2c_slave_cb(struct i2c_client *client,
                break;
        }
 
-       spin_unlock_irqrestore(&panel->lock, flags);
-
        return 0;
 }