Refactor inline functions and clean up code formatting
This commit is contained in:
1 parent
d818a3035e
commit
6637e820e2
1 file changed
+11
-14
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
@@ -17,18 +16,13 @@
|
|||||||
#define DRIVER_NAME "clock_drv"
|
#define DRIVER_NAME "clock_drv"
|
||||||
#define CLASS_NAME "clock_drv_class"
|
#define CLASS_NAME "clock_drv_class"
|
||||||
|
|
||||||
|
|
||||||
#define DS_RST 17
|
#define DS_RST 17
|
||||||
#define DS_DAT 4
|
#define DS_DAT 4
|
||||||
#define DS_SCLK 22
|
#define DS_SCLK 22
|
||||||
|
|
||||||
#define ENC_S1 24
|
#define ENC_S1 24
|
||||||
#define ENC_S2 25
|
#define ENC_S2 25
|
||||||
#define ENC_SW 26
|
#define ENC_SW 26
|
||||||
|
|
||||||
#define DHT_GPIO 23
|
#define DHT_GPIO 23
|
||||||
|
|
||||||
|
|
||||||
#define LED0 5
|
#define LED0 5
|
||||||
#define LED1 6
|
#define LED1 6
|
||||||
#define LED2 12
|
#define LED2 12
|
||||||
@@ -110,8 +104,15 @@ static u8 ds_read_byte(void)
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int bcd2int(u8 b) { return (b & 0x0F) + ((b >> 4) & 0x0F) * 10; }
|
static inline int bcd2int(u8 b)
|
||||||
static inline u8 int2bcd(int v){ return (u8)(((v/10) << 4) | (v%10)); }
|
{
|
||||||
|
return (b & 0x0F) + ((b >> 4) & 0x0F) * 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u8 int2bcd(int v)
|
||||||
|
{
|
||||||
|
return (u8)(((v/10) << 4) | (v%10));
|
||||||
|
}
|
||||||
|
|
||||||
static void ds1302_read_time(struct rtc_simple *t)
|
static void ds1302_read_time(struct rtc_simple *t)
|
||||||
{
|
{
|
||||||
@@ -176,7 +177,6 @@ static const char *field_name(int f)
|
|||||||
return "SEC";
|
return "SEC";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int dht_wait_level(int level, int timeout_us)
|
static int dht_wait_level(int level, int timeout_us)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -328,8 +328,6 @@ static void page_toggle_if_cw_locked(void)
|
|||||||
last_page_switch_j = now;
|
last_page_switch_j = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static irqreturn_t s1_irq_handler(int irq, void *dev_id)
|
static irqreturn_t s1_irq_handler(int irq, void *dev_id)
|
||||||
{
|
{
|
||||||
unsigned long now = jiffies;
|
unsigned long now = jiffies;
|
||||||
@@ -389,7 +387,6 @@ static void set_led_level(int level)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ssize_t dev_read(struct file *f, char __user *ubuf, size_t cnt, loff_t *ppos)
|
static ssize_t dev_read(struct file *f, char __user *ubuf, size_t cnt, loff_t *ppos)
|
||||||
{
|
{
|
||||||
char kbuf[160];
|
char kbuf[160];
|
||||||
@@ -427,8 +424,7 @@ static ssize_t dev_read(struct file *f, char __user *ubuf, size_t cnt, loff_t *p
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t dev_write(struct file *f, const char __user *ubuf,
|
static ssize_t dev_write(struct file *f, const char __user *ubuf, size_t cnt, loff_t *ppos)
|
||||||
size_t cnt, loff_t *ppos)
|
|
||||||
{
|
{
|
||||||
char kbuf[64];
|
char kbuf[64];
|
||||||
int hh, mm, ss;
|
int hh, mm, ss;
|
||||||
@@ -555,6 +551,7 @@ static int __init mod_init(void)
|
|||||||
mutex_unlock(&lock0);
|
mutex_unlock(&lock0);
|
||||||
|
|
||||||
printk(KERN_INFO "OK: DHT cached every %d ms\n", DHT_CACHE_MS);
|
printk(KERN_INFO "OK: DHT cached every %d ms\n", DHT_CACHE_MS);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_gpio:
|
err_gpio:
|
||||||
|
|||||||
Reference in new issue
Block a user