从源代码编译 LG 股票内核时,我在以下行中收到“从不兼容的指针类型初始化”错误:
.detect = mmc_detect
在此声明中找到:
static const struct mmc_bus_ops mmc_ops = {
.awake = mmc_awake,
.sleep = mmc_sleep,
.remove = mmc_remove,
.detect = mmc_detect,
.suspend = NULL,
.resume = NULL,
.power_restore = mmc_power_restore,
.alive = mmc_alive,
.change_bus_speed = mmc_change_bus_speed,
};
mmc_bus_ops 声明如下:
struct mmc_bus_ops {
int (*awake)(struct mmc_host *);
int (*sleep)(struct mmc_host *);
void (*remove)(struct mmc_host *);
#ifdef CONFIG_MACH_LGE
int (*detect)(struct mmc_host *);
#else
void (*detect)(struct mmc_host *);
#endif
int (*suspend)(struct mmc_host *);
int (*resume)(struct mmc_host *);
int (*power_save)(struct mmc_host *);
int (*power_restore)(struct mmc_host *);
int (*alive)(struct mmc_host *);
int (*change_bus_speed)(struct mmc_host *, unsigned long *);
};
和 mmc_detect 像这样:
static int mmc_detect(struct mmc_host *host)
{
int err;
BUG_ON(!host);
BUG_ON(!host->card);
mmc_rpm_hold(host, &host->card->dev);
mmc_claim_host(host);
/*
* Just check if our card has been removed.
*/
err = _mmc_detect_card_removed(host);
mmc_release_host(host);
/*
* if detect fails, the device would be removed anyway;
* the rpm framework would mark the device state suspended.
*/
if (!err)
mmc_rpm_release(host, &host->card->dev);
if (err) {
mmc_remove(host);
mmc_claim_host(host);
mmc_detach_bus(host);
mmc_power_off(host);
mmc_release_host(host);
}
return 0;
}
我的猜测是这里的问题是 mmc_bus_ops.detect 被声明为指针,但 mmc_detect 为普通 int。但是,据我所知,mmc_bus_ops.awake 和 mmc_awake 也是如此,但这不会产生任何错误。问题是如何解决这个问题,我怎么会在股票内核中得到这些错误?如果LG可以在这种状态下编译内核,为什么我必须先编辑所有内容?非常感谢任何帮助和解释!