From patchwork Tue Jan 24 14:34:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9535301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A5C76042C for ; Tue, 24 Jan 2017 14:34:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22B741FF35 for ; Tue, 24 Jan 2017 14:34:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15B0728111; Tue, 24 Jan 2017 14:34:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B21641FF35 for ; Tue, 24 Jan 2017 14:34:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750867AbdAXOex (ORCPT ); Tue, 24 Jan 2017 09:34:53 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:34279 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750847AbdAXOex (ORCPT ); Tue, 24 Jan 2017 09:34:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=zjaSxUKTXqc7YyI9sgZ0gyd7CA9Ze/HeeBHw1ZD3hy0=; b=R7P/ulN+z9US2x4zM7o/XJJsvT RKCtyhRiYUi3OXoUO0HNB2duxHs5hXMkkouG8yW88HKhH9JYTVQPUZTIcQUXnORJe7r641w5/0uZG MWDl9GwG+35G9eIQM3AnUpffC0ExQNt705JWjK6MH3V6pKnUtqFQqQpY/BHhfoYLrpKiNlNgswG2e DcINpb92rMHlw5WkAZxJVq5ZaT6Z0YbHjsL5UqZqB7G8CsYcfJBQDMSfsNN4Wcpi3ggwE2+4pYPQj oJHok+wN5JZ+FKmTphXz4ROB7MDZfqcpCcTcOaKPDCMZYdFt7pG/8D+CGyZWOXE+yONPl0zUPcSpX /xX2bqgw==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:51858 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1cW2BN-000rSf-Tl; Tue, 24 Jan 2017 14:34:50 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH] hwmon: Make name attribute mandatory for new APIs Date: Tue, 24 Jan 2017 06:34:46 -0800 Message-Id: <1485268486-29960-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It does not make sense to use one of the the new APIs when not even providing a name attribute. Make it mandatory. Signed-off-by: Guenter Roeck --- drivers/hwmon/hwmon.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 0c5660ccdbf4..ead5c94bb56c 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -651,6 +651,9 @@ hwmon_device_register_with_groups(struct device *dev, const char *name, void *drvdata, const struct attribute_group **groups) { + if (!name) + return -EINVAL; + return __hwmon_device_register(dev, name, drvdata, NULL, groups); } EXPORT_SYMBOL_GPL(hwmon_device_register_with_groups); @@ -674,6 +677,9 @@ 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 -EINVAL; + if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info)) return ERR_PTR(-EINVAL);