簡體   English   中英

可以從Linux i2c-dev驅動程序中刪除哪些內容,以作為僅用於一個設備的新驅動程序的基礎?

[英]What can be removed from the Linux i2c-dev driver to serve as a base for a new driver meant for only one device?

我正在嘗試為恰好通過I2C進行通信的設備編寫Linux字符設備驅動程序。 該設備是Atmel微控制器,其代碼提供I2C地址。 它已經在Linux端使用典型的i2c-dev方法工作了。

因此,現在我想將i2c-dev復制為專門用於該特定設備的新驅動程序,以便可以在上面添加一些自己的特定於設備的抽象代碼。 但是我想從i2c-dev中刪除所有不必要的代碼,這些代碼目前已使其通用。 在這種情況下可以刪除什么?

在這種情況下可以刪除什么?

您實際上是在詢問XY問題。
您最好查看並改編現有的I2C設備驅動程序,該驅動程序在所需功能上已經很相似,而不是破解用於用戶空間訪問的特殊情況的驅動程序。

因此,現在我想將i2c-dev復制為專門用於該特定設備的新驅動程序,以便可以在頂部添加一些自己的特定於設備的抽象代碼

因此,您實際上需要按如下所述編寫“客戶端驅動程序”(來自Linux Documentation / i2c / summary):

When we talk about I2C, we use the following terms:
   Bus    -> Algorithm
             Adapter
   Device -> Driver
             Client

 An Algorithm driver contains general code that can be used for a whole class
 of I2C adapters. Each specific adapter driver either depends on one algorithm
 driver, or includes its own implementation.

 A Driver driver (yes, this sounds ridiculous, sorry) contains the general
 code to access some type of device. Each detected device gets its own
 data in the Client structure. Usually, Driver and Client are more closely
 integrated than Algorithm and Adapter.

詳細信息在Documentation / i2c / writing-clients中
要查找具有類似功能的驅動程序,請掃描I2C客戶端驅動程序列表。 請注意,這些I2C驅動程序按其功能(例如, drivers/rtc/drivers/hwmon/ )而不是其接口(即I2C)位於Linux源代碼樹中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM