From patchwork Sun Nov 20 17:36:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9438555 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 29AE260235 for ; Sun, 20 Nov 2016 17:36:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DD2528904 for ; Sun, 20 Nov 2016 17:36:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12DD2289B3; Sun, 20 Nov 2016 17:36:38 +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 BB91428904 for ; Sun, 20 Nov 2016 17:36:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752929AbcKTRgh (ORCPT ); Sun, 20 Nov 2016 12:36:37 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:59122 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752891AbcKTRgg (ORCPT ); Sun, 20 Nov 2016 12:36:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=References:In-Reply-To:Message-Id:Date:Subject: Cc:To:From; bh=Q3thqGT/ctvcvJoB4bB8GC7FKteXNYTm3gGp2qS8fA4=; b=tPxQHpYg0qT7lN 6VZ3iM88gLOqOqoARr6NNJvQ1Ch6aAk0iRa3t1geIYDp8WI5PzKs2vaCMSfG3FUsobtk4+AbJrrCp u37UnZChxkAkyF7/5Rd1p6vPJB2iJ6zTXxOJWIsxVMxLQiQjJpF4wJOBEIyNuoU+MAlglyAROJXJo 2eXbtdx2DOdWhgQEkFjk2Y13yicjPJs+UmIBxCi+ItAyzbVzrZre9x+qmB42Qfb4lVqK1TJRMNUdX T4+zFooXhcg5wi0WKJ7zpWiR5MARwKePYBfex2dlXgGH9V4EJZRCqrZBoNZMZh/xtLlvI9jMpg3AC PRIvfkIa730wgQCn7QLg==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:42456 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1c8W2b-0034Ls-0N; Sun, 20 Nov 2016 17:36:33 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck Subject: [PATCH 5/7] hwmon: (core) Make is_visible callback truly mandatory Date: Sun, 20 Nov 2016 09:36:26 -0800 Message-Id: <1479663388-2000-5-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1479663388-2000-1-git-send-email-linux@roeck-us.net> References: <1479663388-2000-1-git-send-email-linux@roeck-us.net> 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 The is_visible callback provides the sysfs attribute mode and is thus truly mandatory as documented. Check it once at registration and remove other checks for its existence. Signed-off-by: Guenter Roeck --- drivers/hwmon/hwmon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 971c9eb78e6a..a0b5becf91fa 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -559,7 +559,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, hdev = &hwdev->dev; - if (chip && chip->ops->is_visible) { + if (chip) { struct attribute **attrs; int ngroups = 2; @@ -605,7 +605,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, if (err) goto free_hwmon; - if (chip && chip->ops->is_visible && chip->ops->read && + if (chip && chip->ops->read && chip->info[0]->type == hwmon_chip && (chip->info[0]->config[0] & HWMON_C_REGISTER_TZ)) { const struct hwmon_channel_info **info = chip->info; @@ -673,7 +673,7 @@ hwmon_device_register_with_info(struct device *dev, const char *name, const struct hwmon_chip_info *chip, const struct attribute_group **groups) { - if (chip && (!chip->ops || !chip->info)) + if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info)) return ERR_PTR(-EINVAL); return __hwmon_device_register(dev, name, drvdata, chip, groups);