Skip to content

Compact initialization of mpu6050 driver.#36

Open
oleksii-kogutenko wants to merge 1 commit into
Kernel-GL-HRK:masterfrom
oleksii-kogutenko:alexandr_mpu6050
Open

Compact initialization of mpu6050 driver.#36
oleksii-kogutenko wants to merge 1 commit into
Kernel-GL-HRK:masterfrom
oleksii-kogutenko:alexandr_mpu6050

Conversation

@oleksii-kogutenko

@oleksii-kogutenko oleksii-kogutenko commented Nov 20, 2017

Copy link
Copy Markdown

Compact initialization of mpu6050 driver.

  • use one class structure for all internal files
  • use one show function for all class files
  • use dtsi file from 4.14 kernel branch
  • cdev device added
  • use kthread_run to read i2c data
  • use timer callback to allow reading i2c data
  • use wait_for_completion to sync timer with thread
  • use spin_lock_irqsave to lock read/write data area

Signed-off-by: oleksii-kogutenko oleksii.kogutenko@gmail.com

Comment thread mpu6050/mpu6050.h
// ----------------------------------------------------------------------------
// Reading data from I2C2 device to the static mpu6050_data structure
// ----------------------------------------------------------------------------
static int mpu6050_read_data(void);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Statics should not be exported in headers

@oleksii-kogutenko oleksii-kogutenko Nov 28, 2017

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it have error of compilation like:
error: static declaration of ‘function’ follows non-static declaration static int function()

Comment thread mpu6050/am335x-bone-common.dtsi Outdated
};
};

&am33xx_pinmux {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please tell, why so massive changes in dtsi?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use the kernel version 4.14, please see beagleboard/linux@82d75af

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it lead to issues to be fixed in "Remove wrong copy/past from am335x-bone-common.dtsi"

Anyway, if some commit is not yet merged, it is needed to rebase and modify it instead of adding a patch on top.

 - use one class structure for all internal files
 - use one show function for all class files
 - use dtsi file from 4.14 kernel branch
 - cdev device added
 - use kthread_run to read i2c data
 - use timer callback to allow reading i2c data
 - use wait_for_completion to sync timer with thread
 - use spin_lock_irqsave to lock read/write data area

Signed-off-by: oleksii-kogutenko <oleksii.kogutenko@gmail.com>

@an1kh an1kh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it have error of compilation like:
error: static declaration of ‘function’ follows non-static declaration static int function()
Please fix this issue. Looks like both header and source should not have "static".

Everything else if fine.
Maybe finding which parameter to show need improvement: switch from if-else to some pointer logic. But current implementation is OK. Keep it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants