Skip to content

rtmouse.cの分割(リファクタリング) #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6e53c59
renamed rtmouse.c to rtmouse_main.c
YusukeKato Nov 5, 2024
a4b6b0e
lintの対象ファイルを修正
YusukeKato Nov 5, 2024
4f0ef43
Cファイル分割の準備
YusukeKato Nov 5, 2024
93ad739
外部変数をヘッダファイルで宣言
YusukeKato Nov 5, 2024
bd7640b
デバイス関連の関数をrtmouse_dev.cへ移動
YusukeKato Nov 5, 2024
f2e86ce
lint対象を修正&インデント修正
YusukeKato Nov 5, 2024
f260f46
lintに対応して修正
YusukeKato Nov 5, 2024
152d057
lintに対応して修正
YusukeKato Nov 5, 2024
560bd67
rtmouse_dev.cをrtmouse_dev_fops.cへ名称変更
YusukeKato Nov 5, 2024
d530af8
ライセンスとバージョンを更新
YusukeKato Nov 5, 2024
71aa661
関数の並びを整理
YusukeKato Nov 5, 2024
b2d7b7d
外部変数を整理
YusukeKato Nov 5, 2024
c680610
lintに対応して修正
YusukeKato Nov 5, 2024
2948238
外部からも使用する関数を整理
YusukeKato Nov 5, 2024
92ec244
lintに対応して修正
YusukeKato Nov 5, 2024
cead9f2
rtmouse_main.cで使用する関数はrtmouse_main.cに残す
YusukeKato Nov 7, 2024
5b87a72
rtmouse_spi.cを作成してSPI関連の関数を移す
YusukeKato Nov 7, 2024
c1f774a
rtmouse_spi.cにコメントを追加
YusukeKato Nov 7, 2024
f6cd192
rtmouse_i2c.cを作成してI2C関連の関数を移す
YusukeKato Nov 7, 2024
b175fbc
register_dev()をrtmouse_dev_fops.cへ移す
YusukeKato Nov 7, 2024
77bb477
rtmouse_dev_fops.cをrtmouse_dev.cへ名称変更
YusukeKato Nov 7, 2024
a556d62
lintに対応して修正
YusukeKato Nov 7, 2024
0cc93d9
lint対象のファイルを修正
YusukeKato Nov 7, 2024
6e95fbf
rtmouse_gpio.cを作成してGPIO関連の関数を移す
YusukeKato Nov 7, 2024
2b50070
コメントなど微修正
YusukeKato Nov 7, 2024
b3c3c79
lintに対応して修正
YusukeKato Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
外部変数をヘッダファイルで宣言
  • Loading branch information
YusukeKato committed Nov 5, 2024
commit 93ad739e6abbfca757a6ddfa9c4817b192ee36f8
35 changes: 30 additions & 5 deletions src/drivers/rtmouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@
#define ID_DEV_CNT 8
#define ID_DEV_SIZE 9

extern unsigned int NUM_DEV[ID_DEV_SIZE];
extern char *NAME_DEV[ID_DEV_SIZE];
extern char *NAME_DEV_U[ID_DEV_SIZE];

#define NUM_DEV_TOTAL \
(NUM_DEV[ID_DEV_LED] + NUM_DEV[ID_DEV_SWITCH] + \
NUM_DEV[ID_DEV_SENSOR] + NUM_DEV[ID_DEV_BUZZER] + \
Expand Down Expand Up @@ -230,7 +226,36 @@ extern char *NAME_DEV_U[ID_DEV_SIZE];
#define SIGNED_COUNT_SIZE 32767
#define MAX_PULSE_COUNT 65535

/* -- Buffer -- */
/* --- Buffer --- */
#define MAX_BUFLEN 64

/* --- extern --- */
extern unsigned int NUM_DEV[ID_DEV_SIZE];
extern char *NAME_DEV[ID_DEV_SIZE];
extern char *NAME_DEV_U[ID_DEV_SIZE];
extern int _major_dev[ID_DEV_SIZE];
extern int _minor_dev[ID_DEV_SIZE];
extern struct cdev *cdev_array;
extern struct class *class_dev[ID_DEV_SIZE];
extern volatile void __iomem *pwm_base;
extern volatile void __iomem *clk_base;
extern volatile uint32_t *gpio_base;
extern volatile int cdev_index;
extern struct mutex lock;
extern struct spi_device_id mcp3204_id[];
extern struct spi_board_info mcp3204_info;
extern struct spi_driver mcp3204_driver;
extern struct i2c_client *i2c_client_r;
extern struct i2c_client *i2c_client_l;
extern unsigned int motor_l_freq_is_positive;
extern unsigned int motor_r_freq_is_positive;
extern struct i2c_device_id i2c_counter_id[];
extern struct i2c_driver i2c_counter_driver;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)
extern struct device *mcp320x_dev;
#endif

void tmp_func(void);

#endif // RTMOUSE_H
42 changes: 21 additions & 21 deletions src/drivers/rtmouse_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,32 @@ char *NAME_DEV_U[ID_DEV_SIZE] = {[ID_DEV_LED] = "rtled%u",
[ID_DEV_MOTOR] = "rtmotor%u"};

// used in by register_dev() and cleanup_each_dev()
static int _major_dev[ID_DEV_SIZE] = {
int _major_dev[ID_DEV_SIZE] = {
[ID_DEV_LED] = DEV_MAJOR, [ID_DEV_SWITCH] = DEV_MAJOR,
[ID_DEV_SENSOR] = DEV_MAJOR, [ID_DEV_BUZZER] = DEV_MAJOR,
[ID_DEV_MOTORRAWR] = DEV_MAJOR, [ID_DEV_MOTORRAWL] = DEV_MAJOR,
[ID_DEV_MOTOREN] = DEV_MAJOR, [ID_DEV_MOTOR] = DEV_MAJOR};

// used in register_dev() and cleanup_each_dev()
static int _minor_dev[ID_DEV_SIZE] = {
int _minor_dev[ID_DEV_SIZE] = {
[ID_DEV_LED] = DEV_MINOR, [ID_DEV_SWITCH] = DEV_MINOR,
[ID_DEV_SENSOR] = DEV_MINOR, [ID_DEV_BUZZER] = DEV_MINOR,
[ID_DEV_MOTORRAWR] = DEV_MINOR, [ID_DEV_MOTORRAWL] = DEV_MINOR,
[ID_DEV_MOTOREN] = DEV_MINOR, [ID_DEV_MOTOR] = DEV_MINOR};

/* --- General Options --- */
static struct cdev *cdev_array = NULL;
static struct class *class_dev[ID_DEV_SIZE] = {
struct cdev *cdev_array = NULL;
struct class *class_dev[ID_DEV_SIZE] = {
[ID_DEV_LED] = NULL, [ID_DEV_SWITCH] = NULL,
[ID_DEV_SENSOR] = NULL, [ID_DEV_BUZZER] = NULL,
[ID_DEV_MOTORRAWR] = NULL, [ID_DEV_MOTORRAWL] = NULL,
[ID_DEV_MOTOREN] = NULL, [ID_DEV_MOTOR] = NULL};

static volatile void __iomem *pwm_base;
static volatile void __iomem *clk_base;
static volatile uint32_t *gpio_base;

static volatile int cdev_index = 0;

static struct mutex lock;
volatile void __iomem *pwm_base;
volatile void __iomem *clk_base;
volatile uint32_t *gpio_base;
volatile int cdev_index = 0;
struct mutex lock;

/* --- Function Declarations --- */
static void set_motor_r_freq(int freq);
Expand Down Expand Up @@ -123,13 +121,13 @@ struct mcp3204_drvdata {

/* --- Static variables --- */
/* SPI device ID */
static struct spi_device_id mcp3204_id[] = {
struct spi_device_id mcp3204_id[] = {
{"mcp3204", 0},
{},
};

/* SPI Info */
static struct spi_board_info mcp3204_info = {
struct spi_board_info mcp3204_info = {
.modalias = "mcp3204",
.max_speed_hz = 100000,
.bus_num = 0,
Expand All @@ -138,11 +136,11 @@ static struct spi_board_info mcp3204_info = {
};

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)
static struct device *mcp320x_dev;
struct device *mcp320x_dev;
#endif

/* SPI Dirver Info */
static struct spi_driver mcp3204_driver = {
struct spi_driver mcp3204_driver = {
.driver =
{
.name = DEVNAME_SENSOR,
Expand All @@ -165,20 +163,20 @@ struct rtcnt_device_info {
int raw_pulse_count;
};

static struct i2c_client *i2c_client_r = NULL;
static struct i2c_client *i2c_client_l = NULL;
static unsigned int motor_l_freq_is_positive = 1;
static unsigned int motor_r_freq_is_positive = 1;
struct i2c_client *i2c_client_r = NULL;
struct i2c_client *i2c_client_l = NULL;
unsigned int motor_l_freq_is_positive = 1;
unsigned int motor_r_freq_is_positive = 1;

/* I2C Device ID */
static struct i2c_device_id i2c_counter_id[] = {
struct i2c_device_id i2c_counter_id[] = {
{DEVNAME_CNTL, 0},
{DEVNAME_CNTR, 1},
{},
};

/* I2C Dirver Info */
static struct i2c_driver i2c_counter_driver = {
struct i2c_driver i2c_counter_driver = {
.driver =
{
.name = "rtcounter",
Expand Down Expand Up @@ -1673,6 +1671,8 @@ int dev_init_module(void)
int registered_devices = 0;
size_t size;

tmp_func();

/* log loding message */
printk(KERN_INFO "%s: loading driver...\n", DRIVER_NAME);

Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy