From patchwork Tue Jan 24 16:57:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9535543 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 439206046A for ; Tue, 24 Jan 2017 16:57:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D4DD2015F for ; Tue, 24 Jan 2017 16:57:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20A4F26907; Tue, 24 Jan 2017 16:57:21 +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 9D1252015F for ; Tue, 24 Jan 2017 16:57:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750757AbdAXQ5U (ORCPT ); Tue, 24 Jan 2017 11:57:20 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:47983 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750716AbdAXQ5T (ORCPT ); Tue, 24 Jan 2017 11:57:19 -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=Uss9YImTpD2MFl+9GHFfhmyIBb2BiHH+18MwojEpSv4=; b=sXcIYUkSvIVPgyO/32nH2Ks8I2 PkrlrE92Be1rnG7JU4gXaFwKzTr0r6uVv4Ay6cxIjyweLIYInbMe035KvUg3k27G9d33n+WzCA0/n ed9/zuccemxe2uqgRVkAtmh92VrC/5WOmjvw0Ok1dcyG0nsznU42zGrwvjM7Ca6cxJCK/iqX7Gs45 ETEAXsuUzaVkMY+93f1mIit1GsxqgxJnaKCwUjc5n7iFLkhzfCcRi3I8WcKyGbKmwffoQ5nnZTYM7 IAdNS4zOs4nDXnwjbGe1EwnYhSBqbacnnPhgP5kk0Z1NNwX2gdUfi3LIZqr4GFTLmsSzxJ9wzuoJU 1WTxXN8w==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:52900 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1cW4PF-00330a-Fi; Tue, 24 Jan 2017 16:57:17 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH v2] hwmon: Make name attribute mandatory for new APIs Date: Tue, 24 Jan 2017 08:57:14 -0800 Message-Id: <1485277034-12364-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 --- v2: One should use ERR_PTR where appropriate drivers/hwmon/hwmon.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 0c5660ccdbf4..a408b10d9a86 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 ERR_PTR(-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 ERR_PTR(-EINVAL); + if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info)) return ERR_PTR(-EINVAL);