Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp604453iog; Mon, 13 Jun 2022 09:00:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+HB4jdp4I33TIld+cVfUMrm9vHilRTQiSxlU5vYdSFjhrFH8yMhIYPNWooK6HvJQKzPqC X-Received: by 2002:a17:90b:1b05:b0:1e2:a053:2fad with SMTP id nu5-20020a17090b1b0500b001e2a0532fadmr16606869pjb.209.1655136048206; Mon, 13 Jun 2022 09:00:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655136048; cv=none; d=google.com; s=arc-20160816; b=BPTrbGef4CV5Gha7ggRKYXQ3Bknf993sZy9mFNNEmmf5PBsvZn02XDerc4a2gMkHPW 0CaCIUZwdeACYlq0gZFOuIFQiua4yQWZ3zZa5FB5VipwJXH8jdvEWfKt0rhqzK1iNz18 k/FEFb7zhPwnavQkMRa/yBWMfLq5oyF/aC1QeWzlO1GP9/Vo65TWoIM57ggxWfMKbb0m 161ZF0zlRfAXx9akuhZVjb+XtZKlDzPmWKjobK92cblC9I+0EWuC/xZs9av6vBuTtAgG GjSC+fsPq+gHnR1ft7JfsFp+2yBjnT+og6rVPdxB8Yg9rPz3w3Nr7Ii6ePP84o81P1nI nFGA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SPPkZ9Qileyvc6y2erLctfbtAFSsVWxsiRlNPe4vpAs=; b=UQ6ERt21V59FB5Mg2DAuJ01Vr/q9rk8fC1IzLYo3m+Zc1QyddtTD8cmJ+lAVQo5pNC xi47/edlZt4JiKJVBiq7G+kkM8XEOFNC5a+/0IX8f8R6m4mbuyRIpyia7E/SH0vfpwRt y0IcB7EShEjDUnXqEyFchcgyvy/umyMpKDbdCt+7pXKYXHmKijYOMmL4E2bshHMRJKpU FXjzuzK4YLNsl56ozZMUGjH0jG++7J/L5oTt9ES3Mi/FiUKy+jAPUETcyTsKFs6VuvEH q8wasruKBqCoIWVYNp+JTZlyOELFB7A4CtAlvAqNkbo0DwjXu5nRZdBkU8Ce95lHJklR 4cWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bI7rO0st; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l2-20020a170903244200b00153b2d16577si11145627pls.383.2022.06.13.09.00.33; Mon, 13 Jun 2022 09:00:48 -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=@linuxfoundation.org header.s=korg header.b=bI7rO0st; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350353AbiFMLFQ (ORCPT + 99 others); Mon, 13 Jun 2022 07:05:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350770AbiFMKzI (ORCPT ); Mon, 13 Jun 2022 06:55:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7409324F0A; Mon, 13 Jun 2022 03:31:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B1506B80E95; Mon, 13 Jun 2022 10:31:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11D1FC3411C; Mon, 13 Jun 2022 10:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655116312; bh=a+nto0WPeTFaOBkATJKClQmpfGywYTjO3j8Tv34EtKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bI7rO0steYOG0hRES+JoP/5IJg+8tSqFo5SOo91r2TPrQyImWbaPk63vy7ja4+Hvk 08DCdMOjbHUOL1UvQuN9aTMou/pWYcLlouVzXrvlMEPwX2zjTBIgzt1Z8N5aZr5LoE 86e4F8FaX535z2mm6eDCr071ZGxP1/aYr4XIpD1A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck , Sasha Levin Subject: [PATCH 5.4 059/411] hwmon: Make chip parameter for with_info API mandatory Date: Mon, 13 Jun 2022 12:05:32 +0200 Message-Id: <20220613094930.285828527@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Guenter Roeck [ Upstream commit ddaefa209c4ac791c1262e97c9b2d0440c8ef1d5 ] Various attempts were made recently to "convert" the old hwmon_device_register() API to devm_hwmon_device_register_with_info() by just changing the function name without actually converting the driver. Prevent this from happening by making the 'chip' parameter of devm_hwmon_device_register_with_info() mandatory. Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- Documentation/hwmon/hwmon-kernel-api.rst | 2 +- drivers/hwmon/hwmon.c | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Documentation/hwmon/hwmon-kernel-api.rst b/Documentation/hwmon/hwmon-kernel-api.rst index c41eb6108103..23f27fe78e37 100644 --- a/Documentation/hwmon/hwmon-kernel-api.rst +++ b/Documentation/hwmon/hwmon-kernel-api.rst @@ -72,7 +72,7 @@ hwmon_device_register_with_info is the most comprehensive and preferred means to register a hardware monitoring device. It creates the standard sysfs attributes in the hardware monitoring core, letting the driver focus on reading from and writing to the chip instead of having to bother with sysfs attributes. -The parent device parameter cannot be NULL with non-NULL chip info. Its +The parent device parameter as well as the chip parameter must not be NULL. Its parameters are described in more detail below. devm_hwmon_device_register_with_info is similar to diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index a2175394cd25..c73b93b9bb87 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -715,11 +715,12 @@ EXPORT_SYMBOL_GPL(hwmon_device_register_with_groups); /** * hwmon_device_register_with_info - register w/ hwmon - * @dev: the parent device - * @name: hwmon name attribute - * @drvdata: driver data to attach to created device - * @chip: pointer to hwmon chip information + * @dev: the parent device (mandatory) + * @name: hwmon name attribute (mandatory) + * @drvdata: driver data to attach to created device (optional) + * @chip: pointer to hwmon chip information (mandatory) * @extra_groups: pointer to list of additional non-standard attribute groups + * (optional) * * hwmon_device_unregister() must be called when the device is no * longer needed. @@ -732,13 +733,10 @@ hwmon_device_register_with_info(struct device *dev, const char *name, const struct hwmon_chip_info *chip, const struct attribute_group **extra_groups) { - if (!name) - return ERR_PTR(-EINVAL); - - if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info)) + if (!dev || !name || !chip) return ERR_PTR(-EINVAL); - if (chip && !dev) + if (!chip->ops || !chip->ops->is_visible || !chip->info) return ERR_PTR(-EINVAL); return __hwmon_device_register(dev, name, drvdata, chip, extra_groups); -- 2.35.1