From patchwork Thu Dec 29 16:00:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 37435 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2476339wrt; Thu, 29 Dec 2022 08:11:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXuUXtfups73Cog5+h3aO2vRNrJz7BiCxsncMlSgc8zbTPsdYoRIiHUqBUD4+e/6cF56Vx4C X-Received: by 2002:a17:907:9d0b:b0:78d:f455:30db with SMTP id kt11-20020a1709079d0b00b0078df45530dbmr25442419ejc.3.1672330296996; Thu, 29 Dec 2022 08:11:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672330296; cv=none; d=google.com; s=arc-20160816; b=L7wuq4goHFTVfcvjEv+PvILoqAUmYkQReyAxlyrgkGfaVxMuJPQZhfevewEb9RX6St M4yloYXIfoTyn9ydNxw6GRXSdw+9AIu65PfYQRyw9Lk3e3hpbvvZsyRcJgoXEU67r57l 9L530n97IzMXsuBagfu9z44kvdZks/wh9FcsaNuRq1kIwmr/c/5envdij9NmpAYokDCR C2bfR21DvGv98/4gi5SjARnuGUoy8y4RqtJXhy2adBFeDe98K3lY5EtYDIMFvH7lJmKb g6t98fuwrLa0CTbOlClxZyOk+4mcxTV1obCGaHNY/IdwjHVz9yE7fq/og80DYcyEguyz SKbA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rU7sDwiy4wxWca9BJshy+agHeUQnApN7sCu5RKlRtdM=; b=x894NjaMfN7Rs1rDyLTeMlYclShIdHHaHA3/JeREuEweAzZ0ARTyPkcLkTk3KAWDkE VlFp5NjuoJqcdNx+H59EcnQwr8jy6XxgGiPm5uZQFrSjJi059ZkjYafZlZ/+Li7Lgc+n cndPJH1xmQAHN/jtC/G5U2w8/yxmWocngAyKnbt5kWpdGuDV05baOW28xZXm3RCYk5mQ Tghd6uVsJZOOlODAD9neAWFgxxXV+VDOdHmj5JZXvNqJYaorAlaXiJWKVR1OnBOScSui DiCx6C8CrVNFYHCwBeqE5UlzALWFDka4S5xJ0FBAq49YYgiMbh+Bf6mtj6L1/DyX1JIr GA+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b="QMG0v/1n"; 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 qb25-20020a1709077e9900b0084bbd97edc4si13895218ejc.573.2022.12.29.08.11.12; Thu, 29 Dec 2022 08:11:36 -0800 (PST) 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.20210112.gappssmtp.com header.s=20210112 header.b="QMG0v/1n"; 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 S233645AbiL2QA4 (ORCPT + 99 others); Thu, 29 Dec 2022 11:00:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233548AbiL2QAw (ORCPT ); Thu, 29 Dec 2022 11:00:52 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27D46C2A for ; Thu, 29 Dec 2022 08:00:51 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id k26-20020a05600c1c9a00b003d972646a7dso10342462wms.5 for ; Thu, 29 Dec 2022 08:00:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rU7sDwiy4wxWca9BJshy+agHeUQnApN7sCu5RKlRtdM=; b=QMG0v/1nbi8hZ9k+X70DoEIE//b9nhmqplfikAPHlsmTZe0xNR2l8nbm2O0DqduQEp d5uEnccRjQpPn3ruyZ1t7DEuKhwxuQGVmpJoUtDbHF61PKSy+MNX7c3QaSS+LmKGA9h4 Cj7SCwh1kzAWFjTGnCER9W7spZKATQR/wfjGZu4qOTBL9sb4RSfPgcSfaqJlUmO2m/B1 nXpNroyIn3zjqGtPwPHUuHorNkwTKe5uP1L+hCqPFNrDZcYkJY/XrIWqmJL25pad4GC/ rW2CJyVUI4dw/irPK1J2hAwnjnc7rDGMxWBHAQ045TexoC72zdqEADUK9FdApcoCtbGO d5Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rU7sDwiy4wxWca9BJshy+agHeUQnApN7sCu5RKlRtdM=; b=qaAL/1MqcFNQm2Z89IsWi+Ob7YELrZxp8nCSKzinQ6r29LKiHxmDY9lDl6CblIfApY D3nWjAd1wxcHPmJaz/a0d/jhyhJ2ychl54cYu+cDa3sZRJiQV2tHq3e2+2ZGf2fb5eHU FhwpZGMXX5dPrxdwP84cLmRz9B2b8D3w6zafdbeKy4TGhUYTXHghbvjPri7uhJKBTGVL 3qrloaJPXza0Ef6aCJ8oxuPVW4hOchHCunTCxdABX1HSVL65joJNSOtm+Htp2T0ab2p1 pHRwKwDyRiIJTz1yXZhr1eNggEy5cLEmR7tshRXHzKytNZJV+Y7Ev75Jv/YNcDokzqP4 T1og== X-Gm-Message-State: AFqh2kobRPaZjtZqg4zC8ft9NWqPWJXgGuphuae1103f8gtSzh4VvMuu IumObFUmGyMQUYo+e5zaNnkD27RSM7s99SuX X-Received: by 2002:a05:600c:4995:b0:3d3:4f43:fbc2 with SMTP id h21-20020a05600c499500b003d34f43fbc2mr20646046wmp.41.1672329649761; Thu, 29 Dec 2022 08:00:49 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:8f7a:98d8:9d8d:ced8]) by smtp.gmail.com with ESMTPSA id c12-20020a05600c0a4c00b003cfa3a12660sm42511593wmq.1.2022.12.29.08.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 08:00:49 -0800 (PST) From: Bartosz Golaszewski To: Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 1/2] i2c: dev: fix notifier return values Date: Thu, 29 Dec 2022 17:00:44 +0100 Message-Id: <20221229160045.535778-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221229160045.535778-1-brgl@bgdev.pl> References: <20221229160045.535778-1-brgl@bgdev.pl> 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=ham 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753565413389299873?= X-GMAIL-MSGID: =?utf-8?q?1753565413389299873?= From: Bartosz Golaszewski We have a set of return values that notifier callbacks can return. They should not return 0, error codes or anything other than those predefined values. Make the i2c character device's callback return NOTIFY_DONE or NOTIFY_OK depending on the situation. Signed-off-by: Bartosz Golaszewski --- drivers/i2c/i2c-dev.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index ab0adaa130da..107623c4cc14 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -653,12 +653,12 @@ static int i2cdev_attach_adapter(struct device *dev, void *dummy) int res; if (dev->type != &i2c_adapter_type) - return 0; + return NOTIFY_DONE; adap = to_i2c_adapter(dev); i2c_dev = get_free_i2c_dev(adap); if (IS_ERR(i2c_dev)) - return PTR_ERR(i2c_dev); + return NOTIFY_DONE; cdev_init(&i2c_dev->cdev, &i2cdev_fops); i2c_dev->cdev.owner = THIS_MODULE; @@ -678,11 +678,11 @@ static int i2cdev_attach_adapter(struct device *dev, void *dummy) goto err_put_i2c_dev; pr_debug("adapter [%s] registered as minor %d\n", adap->name, adap->nr); - return 0; + return NOTIFY_OK; err_put_i2c_dev: put_i2c_dev(i2c_dev, false); - return res; + return NOTIFY_DONE; } static int i2cdev_detach_adapter(struct device *dev, void *dummy) @@ -691,17 +691,17 @@ static int i2cdev_detach_adapter(struct device *dev, void *dummy) struct i2c_dev *i2c_dev; if (dev->type != &i2c_adapter_type) - return 0; + return NOTIFY_DONE; adap = to_i2c_adapter(dev); i2c_dev = i2c_dev_get_by_minor(adap->nr); if (!i2c_dev) /* attach_adapter must have failed */ - return 0; + return NOTIFY_DONE; put_i2c_dev(i2c_dev, true); pr_debug("adapter [%s] unregistered\n", adap->name); - return 0; + return NOTIFY_OK; } static int i2cdev_notifier_call(struct notifier_block *nb, unsigned long action, @@ -716,7 +716,7 @@ static int i2cdev_notifier_call(struct notifier_block *nb, unsigned long action, return i2cdev_detach_adapter(dev, NULL); } - return 0; + return NOTIFY_DONE; } static struct notifier_block i2cdev_notifier = {