From patchwork Fri Aug 11 13:14:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 134528 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1119992vqi; Fri, 11 Aug 2023 07:06:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmdW7u5UoaZKuiWGALFDuCzBQX6JIGKSMr7ge6SlnUh2Ie0rRXqztQ5hCeF2CvpI+AYtZG X-Received: by 2002:a17:90b:1b0b:b0:268:3299:ef22 with SMTP id nu11-20020a17090b1b0b00b002683299ef22mr1111402pjb.24.1691762777888; Fri, 11 Aug 2023 07:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691762777; cv=none; d=google.com; s=arc-20160816; b=Mo3ZKS8aHOTNUUUlYBjooeZZDo2dHuhCPxTOqGDPVaz9UNmDSFURF/JEOzkCJFmL1/ WxfbMz8ScOcbZXcolJJN+sAq5XyqAUoFaBJf7B+Ua8hLzg//hQ0qoMbr/bh8dznHb4HH 3ZNF1x9GG7tzIaoA3nuaqnkoXTaB0SKD+29w2m6luKZQYtZC4MxrwQxz9iDSC+6dpRwX WCUZVo9V/m/feeGgj81W4myiPy63h4icouuhOWNYH4eSfGmHsJ3l10qRJt4luBalnNpy 1q9JqPtsB8YtuT93JPYqBz/imQm2P3YRCuQ+sMn/tjbokqnZjU3RNOrw9chxR7QLxDQG lRiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=vS6U9ByOuvwpjOWYK9b5NZuGJIMOD+YNxq8azPqe3fQ=; fh=rCqKS5Wgxyvu9nhWEkn7CU+OTiPpAXAWtEe1ogm7zOc=; b=G/bM8qGP7SkvPalXjxAa4U3r/WB9vgO7o84ND13kHHcgMFpYZ5sRr9IaLkEITDynSs 9PGEnxjNqrBTfkRwkmWHfioNJIwtfxJVF4xHEiNv4/5iiKvNN8qESr0s3sSMjbvoF2xL SjLI0Y9zZ9eZA6iG3aWqKf0RDDft8nwVMwPpJBM+0zA60nsnJeKu9EYbJBpVe371OMJY IV8dI+bGo6bwFEp2TlwFy9skW9kXQzV6KPxlXF97AI8Kuh2ni62Kl2JvkDxtfUp2LWZj IL2zC1UqcFiS5u9h9Y9JpSOTH/7vJjcPRUd4o/0t2tEe1JBLdTiRMC2OEPJI/TYwJ66c +x0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=IMr+jRP8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p1-20020a17090a868100b002692eb69014si5465194pjn.20.2023.08.11.07.05.55; Fri, 11 Aug 2023 07:06:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20221208.gappssmtp.com header.s=20221208 header.b=IMr+jRP8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234969AbjHKNOe (ORCPT + 99 others); Fri, 11 Aug 2023 09:14:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234751AbjHKNOd (ORCPT ); Fri, 11 Aug 2023 09:14:33 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40FC5270F for ; Fri, 11 Aug 2023 06:14:32 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fbea147034so17332805e9.0 for ; Fri, 11 Aug 2023 06:14:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1691759671; x=1692364471; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vS6U9ByOuvwpjOWYK9b5NZuGJIMOD+YNxq8azPqe3fQ=; b=IMr+jRP8N25FWJVRdjMffMQQtK3/yI5RHBQJ7cVg1SdZqVwZXwKV9gublQkzhCfsvK t50FLIbVdL5JO9zsrwTPbtzmxox7wMldJVkx+IbLtt8yR9y4LOQPa2X982PqKxd2O9re Zrr2aed8bQ4CwRChrTkAxFR9ZKLBwzFFiAM67sJxSF9lCdMEAVaD+MaoqJ3bR/4+mXK2 w7wWbjfWkqfACSgE7SPKpo7Qfy45UVW1aYISVsGJRp5ViebRk/OSW+iktNk4mrLWI+q/ x7bU7TbHknpEpNy8MNvJ0iT4K6B/id4w6W27ejiPmVAnT0+SMuvPwZDkgkU/XTiXKYXA Ar5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691759671; x=1692364471; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vS6U9ByOuvwpjOWYK9b5NZuGJIMOD+YNxq8azPqe3fQ=; b=GqoDWkoMaNLGf05pjKBr9DjECDR5faQTpMvjjpBKZYl4coZJXlzSmfNWNsKCm+aTEi xiRE5uUgv/eKs9NTPdkW+hx81DInCTeZ1NbgwKteoBEZhQRJERgyw4DdVxQ5JNIGqxjC oH3j0pzmpN/lLwlRh4v11PpFJ+hmTh/2kOxsV+76LDymZ4oWXwAEVFX0AyZXX6qDJVIw uue2fxSNbfv0kS1/UX9SuoIQprqF5Yq7bSpB7GAh7K4TtGHeObPc0UJlnquySzCVT0Qg qqdraZQLEVIW3eiVQfvBW6c+5jCN1BREeCcERN0s+fNpJuWjcXpYsrBAYgT0qnfQHlyC VKsw== X-Gm-Message-State: AOJu0Yw3z3sK6lOqM7iHFYMKB0zfV/EsU6Fa6skSW2OKPYs4DciW93fT ZDaqgbdWcbb8H/JzgXsTbIUAo5zHfsWkQkacpqSrrA== X-Received: by 2002:a5d:6ac9:0:b0:319:62ba:5d08 with SMTP id u9-20020a5d6ac9000000b0031962ba5d08mr687203wrw.33.1691759670685; Fri, 11 Aug 2023 06:14:30 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d0f3:773f:e87a:3b82]) by smtp.gmail.com with ESMTPSA id s2-20020adfecc2000000b0031433443265sm5365969wro.53.2023.08.11.06.14.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 06:14:30 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Kent Gibson Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 1/2] gpio: sim: simplify gpio_sim_device_config_live_store() Date: Fri, 11 Aug 2023 15:14:26 +0200 Message-Id: <20230811131427.40466-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773941846414485936 X-GMAIL-MSGID: 1773941846414485936 From: Bartosz Golaszewski Simplify the logic when checking the current live value against the user input. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- This is the same as what Andy suggested for gpio-consumer. Let's save a line. drivers/gpio/gpio-sim.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c index dc4097dc0fbc..0177b41e0d72 100644 --- a/drivers/gpio/gpio-sim.c +++ b/drivers/gpio/gpio-sim.c @@ -986,8 +986,7 @@ gpio_sim_device_config_live_store(struct config_item *item, mutex_lock(&dev->lock); - if ((!live && !gpio_sim_device_is_live_unlocked(dev)) || - (live && gpio_sim_device_is_live_unlocked(dev))) + if (live == gpio_sim_device_is_live_unlocked(dev)) ret = -EPERM; else if (live) ret = gpio_sim_device_activate_unlocked(dev);