From patchwork Wed Jun 14 21:59:42 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: 9787503 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 7FAF8602D9 for ; Wed, 14 Jun 2017 22:00:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 741B4283C5 for ; Wed, 14 Jun 2017 22:00:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69175283ED; Wed, 14 Jun 2017 22:00:11 +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 1DBB5283C5 for ; Wed, 14 Jun 2017 22:00:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752500AbdFNWAE (ORCPT ); Wed, 14 Jun 2017 18:00:04 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:34568 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752546AbdFNWAC (ORCPT ); Wed, 14 Jun 2017 18:00:02 -0400 Received: by mail-pg0-f41.google.com with SMTP id v18so5851068pgb.1 for ; Wed, 14 Jun 2017 15:00:01 -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=E4SSDexNNIXdPBBhXJqtXZUKCfnnBG6EH1w31ayHWM0=; b=QPCPZCLVR38mnThE5AqJWbdXUYrY6P2qrr1UzYOXiA2Rsa8+0TIAqnEGMODKDbtLaX 8+EecgFQmNo7uuF9hN2beqoKvSe5mCu+gxjd1qBr9G72AScWZp+/Yx7btNNu8Gy/AcVI lHdjInbaZKWohJfrhvKDVgWEaoXavesJXixq/mD+ifAZsg9YXdLMhLB5jya6aIvDaBVl zcHYnZtaXlzu1giAC8t3fKb92OLM0ZJ56RPOOpC02+ODbYbEqvSsK3+vFcmNUji5YUxG HJLfhj1B+InBQIvxKrdNLgcRO/n3V9BH+Lwlg43sSq8/MLeGwAwtI4c96yVFxlCv+02m PpDQ== 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=E4SSDexNNIXdPBBhXJqtXZUKCfnnBG6EH1w31ayHWM0=; b=WHaU1l2IlxNg0RGrC9xyXM6SaY1iNxJC7me74CvsfqiO3mZaSIBPiHyks3HRKhQcVG D4PzaTWhqMbce22Qb1IoPq5tZuI/mfD8GJRBSyXfxWiHcRcOtZFZW3T8X3LlB8V8/n4J BYP6UtTLr3f1Yd/VRc0QHbT1AGaRcb5lM0CXwjAzQi+MzsU0//6Xy8ZJiLQA9WKOY2v5 n1a+9e06kq8vN88k7pUmyX/QYzwniI+lI4fmXLIZ81psx7Rp6lEZSxWkbbYkjvLDKdVn 04rXgbCjMsYm0cxXAQdlWTQFs7TKK8Nhqi4FFYKCfx7spylq+xstDU8jSvShIPPlgR5n 3MYA== X-Gm-Message-State: AKS2vOzEQs19zRK/ZDOTY4/2nbS6F3ObCkcUYadplF4VB6AECHj+l6qq NOK95gK16LFF7KJV X-Received: by 10.98.198.2 with SMTP id m2mr1948447pfg.215.1497477591331; Wed, 14 Jun 2017 14:59:51 -0700 (PDT) Received: from jaghu22.svl.corp.google.com ([100.123.242.38]) by smtp.gmail.com with ESMTPSA id e18sm1787757pfk.118.2017.06.14.14.59.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Jun 2017 14:59:50 -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 v1 1/3] drivers: w1: add hwmon support structures Date: Wed, 14 Jun 2017 14:59:42 -0700 Message-Id: <20170614215944.24984-2-jaghu@google.com> X-Mailer: git-send-email 2.13.1.508.gb3defc5cc-goog In-Reply-To: <20170614215944.24984-1-jaghu@google.com> References: <20170614215944.24984-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 Change-Id: I17f7c670e5cd7a3826add720ffa928c3e1aa0abc --- drivers/w1/w1.c | 20 +++++++++++++++++++- drivers/w1/w1.h | 2 ++ drivers/w1/w1_family.h | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) -- 2.13.1.508.gb3defc5cc-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..e3efabccd284 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -659,13 +660,30 @@ static int w1_family_notify(unsigned long action, struct w1_slave *sl) return err; } } - +#ifdef CONFIG_HWMON + if (fops->hwmon_groups && sl->hwmon) { + struct device *hwmon + = hwmon_device_register_with_groups(&sl->dev, + "w1_slave_temp", sl, + fops->hwmon_groups); + 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->hwmon_groups && 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..fc582df5c28e 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 + * @hwmon_groups: hwmon sysfs group */ struct w1_family_ops { int (* add_slave)(struct w1_slave *); void (* remove_slave)(struct w1_slave *); const struct attribute_group **groups; + const struct attribute_group **hwmon_groups; }; /**