From patchwork Wed Jul 12 21:41:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaghathiswari Rankappagounder Natarajan X-Patchwork-Id: 9837443 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 1D1BD60393 for ; Wed, 12 Jul 2017 21:41:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B70C28623 for ; Wed, 12 Jul 2017 21:41:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1CB71FFDA; Wed, 12 Jul 2017 21:41:36 +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_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 ED4C328623 for ; Wed, 12 Jul 2017 21:41:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754535AbdGLVl1 (ORCPT ); Wed, 12 Jul 2017 17:41:27 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:36201 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754484AbdGLVlY (ORCPT ); Wed, 12 Jul 2017 17:41:24 -0400 Received: by mail-pf0-f176.google.com with SMTP id q86so18962805pfl.3 for ; Wed, 12 Jul 2017 14:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DuKA42ARPFSYaEvyclETp8jqnY1H6Mwf+FE2QItqXWQ=; b=sJNWfMXTP5XReWhCWvXAuOGKp3mM9aCyaQysJPV/MuP3d+M1QkvzqT+QKtD79iLQUi hx88fC/SJpdOQ7s7wUia3eF132pCZSfOVxHh1aSeA3lvD4Gk2jy1CeeClt4HCP7cqKeR gHg8/1ref35AXjYXsOofhbJVdlfBoenxEROTLfTIebMj2Wxk/vWev/gDLT5nUPd0rsYO NxA0tAum6/IkcGxu0oBVQVIvpr25w/032ygvkk3fdHmO5+jMR9UMOSqIh5LgSQJglnXn 55J9qV3UqRp4CBHEmVujmUUjokAjpbzT5vynk+1Z5oBmjkEkDv9PsOZBCmCEcNDbmW// 86sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DuKA42ARPFSYaEvyclETp8jqnY1H6Mwf+FE2QItqXWQ=; b=ifSQhxc8GxsC+C7ExZepnyk0s2YDDB7grV/oh3eERz1BMmqK/Hlz7vJQzzNhvZbPBk bbJEZ6CgruKeyjN62gewgfQw8MG6bbgXgIbEqq1HY9cu8JKi7fY1RQGLkkNMpyb6eMfz 2qudF42nT3x/ZaKJ4V52vAOE3iAAfwjPAeaWiaPEee3/aWirA4FKI5sPKE0102tIwQM/ XYjTVv6Zd+8M1gWJQP+Vm44slGIguAhFXpRE+9KZvMQ/xfcMo515gqBe5RY9zvSYX/BG hjndeRQeIb8o9+cDfWUeBBR8mVdAxG45dGDJBB28LRV23ERDE4ZjgD/458VvoG9z3yVO P1/g== X-Gm-Message-State: AIVw112ra76xUyUcGm7EA9IR+O+z81ev2lrzPRsiuJU34q+tQNyXpTRQ aEJUdulgdeW8A8Tla8/qcA== X-Received: by 10.84.215.208 with SMTP id g16mr6320926plj.191.1499895683848; Wed, 12 Jul 2017 14:41:23 -0700 (PDT) Received: from jaghu22.svl.corp.google.com ([100.123.242.38]) by smtp.gmail.com with ESMTPSA id y192sm5515859pgd.38.2017.07.12.14.41.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Jul 2017 14:41:23 -0700 (PDT) From: Jaghathiswari Rankappagounder Natarajan To: zbr@ioremap.net, linux-kernel@vger.kernel.org, linux@roeck-us.net, jdelvare@suse.com, linux-hwmon@vger.kernel.org Cc: Jaghathiswari Rankappagounder Natarajan Subject: [PATCH linux v2 1/3] drivers: w1: add hwmon support structures Date: Wed, 12 Jul 2017 14:41:16 -0700 Message-Id: <20170712214118.4306-2-jaghu@google.com> X-Mailer: git-send-email 2.13.2.932.g7449e964c-goog In-Reply-To: <20170712214118.4306-1-jaghu@google.com> References: <20170712214118.4306-1-jaghu@google.com> 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 This patch has changes to w1.h/w1.c/w1_family.h generic files to add (optional) hwmon support structures. Signed-off-by: Jaghathiswari Rankappagounder Natarajan Acked-by: Evgeniy Polyakov --- v2 - made changes to support hwmon_device_register_with_info mentioned by Guenter. drivers/w1/w1.c | 21 ++++++++++++++++++++- drivers/w1/w1.h | 2 ++ drivers/w1/w1_family.h | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) -- 2.13.2.932.g7449e964c-goog -- To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index e213c678bbfe..c37e21597c5c 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -659,13 +660,31 @@ static int w1_family_notify(unsigned long action, struct w1_slave *sl) return err; } } - +#ifdef CONFIG_HWMON + if (fops->chip_info) { + struct device *hwmon + = hwmon_device_register_with_info(&sl->dev, + "w1_slave_temp", sl, + fops->chip_info, + NULL); + if (IS_ERR(hwmon)) { + dev_warn(&sl->dev, + "could not create hwmon device\n"); + } else { + sl->hwmon = hwmon; + } + } +#endif break; case BUS_NOTIFY_DEL_DEVICE: if (fops->remove_slave) sl->family->fops->remove_slave(sl); if (fops->groups) sysfs_remove_groups(&sl->dev.kobj, fops->groups); +#ifdef CONFIG_HWMON + if (fops->chip_info && sl->hwmon) + hwmon_device_unregister(sl->hwmon); +#endif break; } return 0; diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h index 129895f562b0..74ef1a543856 100644 --- a/drivers/w1/w1.h +++ b/drivers/w1/w1.h @@ -83,6 +83,7 @@ struct w1_reg_num * @family: module for device family type * @family_data: pointer for use by the family module * @dev: kernel device identifier + * @hwmon: pointer to hwmon device * */ struct w1_slave @@ -99,6 +100,7 @@ struct w1_slave struct w1_family *family; void *family_data; struct device dev; + struct device *hwmon; }; typedef void (*w1_slave_found_callback)(struct w1_master *, u64); diff --git a/drivers/w1/w1_family.h b/drivers/w1/w1_family.h index 10a7a0767187..9001851e1316 100644 --- a/drivers/w1/w1_family.h +++ b/drivers/w1/w1_family.h @@ -55,12 +55,14 @@ struct w1_slave; * @add_slave: add_slave * @remove_slave: remove_slave * @groups: sysfs group + * @chip_info: pointer to struct hwmon_chip_info */ struct w1_family_ops { int (* add_slave)(struct w1_slave *); void (* remove_slave)(struct w1_slave *); const struct attribute_group **groups; + const struct hwmon_chip_info *chip_info; }; /**