Quantcast
Channel: Active questions tagged linux-kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 12244

How to read temperature for driver/thermal file wich i created?

$
0
0

For learning purpose I have created a driver under driver/thermal ( xyz_thermal.c) which can read a temperature (just passing dummies value).

But how can I read this value from user space. I tried /sys/class/thermal/ but I didn't see thermal zone which I have created. Can any one help me on this?

Changes what I have done (xyz_thermal.c):

#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/nvmem-consumer.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/io.h>
#include <linux/thermal.h>
#include <linux/reset.h>
#include <linux/types.h>


struct xyz_therm_info {
    struct device           *dev;
    struct thermal_zone_device  *tz_device;
    int             irq_tj1;
    int             irq_tj2;
    int             irq_tj3;
};



static int xyz_read_temp(void *data, int *temperature)
{
     struct mtk_thermal *mt = data;

     temperature = 100;
     return 0;
}

static const struct thermal_zone_of_device_ops xyz_thermal_ops = {
    .get_temp = xyz_read_temp,
};


static int xyz_thermal_probe(struct platform_device *pdev)
{

}

static struct platform_device_id xyz_thermal_devtype[] = {
    { .name = "xyz-thermal", },
    {},
};

MODULE_DEVICE_TABLE(platform, xyz_thermal_devtype);

static struct platform_driver xyz_thermal_driver = {
    .driver = {
        .name = "xyz-thermal",
    },
    .probe = xyz_thermal_probe,
    .id_table = xyz_thermal_devtype,
};

module_platform_driver(xyz_thermal_driver);

Also I did changes in KConfig and Makefile and enable it in the .config file.

I want to know what I am missing here or am I doing it correctly?


Viewing all articles
Browse latest Browse all 12244

Trending Articles