text
stringlengths 213
7.14k
| idx
int64 16
12.5k
|
---|---|
--- initial
+++ final
@@ -1,74 +1,74 @@
static int mxsfb_load(struct drm_device *drm, unsigned long flags) {
struct platform_device *pdev = to_platform_device(drm->dev);
struct mxsfb_drm_private *mxsfb;
struct resource *res;
int ret;
mxsfb = devm_kzalloc(&pdev->dev, sizeof(*mxsfb), GFP_KERNEL);
if (!mxsfb) return -ENOMEM;
drm->dev_private = mxsfb;
mxsfb->devdata = &mxsfb_devdata[pdev->id_entry->driver_data];
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
mxsfb->base = devm_ioremap_resource(drm->dev, res);
if (IS_ERR(mxsfb->base)) return PTR_ERR(mxsfb->base);
mxsfb->clk = devm_clk_get(drm->dev, NULL);
if (IS_ERR(mxsfb->clk)) return PTR_ERR(mxsfb->clk);
mxsfb->clk_axi = devm_clk_get(drm->dev, "axi");
if (IS_ERR(mxsfb->clk_axi)) mxsfb->clk_axi = NULL;
mxsfb->clk_disp_axi = devm_clk_get(drm->dev, "disp_axi");
if (IS_ERR(mxsfb->clk_disp_axi)) mxsfb->clk_disp_axi = NULL;
ret = dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32));
if (ret) return ret;
pm_runtime_enable(drm->dev);
ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
if (ret < 0) {
dev_err(drm->dev, "Failed to initialise vblank\n");
goto err_vblank;
}
/* Modeset init */
drm_mode_config_init(drm);
ret = mxsfb_create_output(drm);
if (ret < 0) {
dev_err(drm->dev, "Failed to create outputs\n");
goto err_vblank;
}
ret = drm_simple_display_pipe_init(drm, &mxsfb->pipe, &mxsfb_funcs, mxsfb_formats, ARRAY_SIZE(mxsfb_formats), &mxsfb->connector);
if (ret < 0) {
dev_err(drm->dev, "Cannot setup simple display pipe\n");
goto err_vblank;
}
ret = drm_panel_attach(mxsfb->panel, &mxsfb->connector);
if (ret) {
dev_err(drm->dev, "Cannot connect panel\n");
goto err_vblank;
}
drm->mode_config.min_width = MXSFB_MIN_XRES;
drm->mode_config.min_height = MXSFB_MIN_YRES;
drm->mode_config.max_width = MXSFB_MAX_XRES;
drm->mode_config.max_height = MXSFB_MAX_YRES;
drm->mode_config.funcs = &mxsfb_mode_config_funcs;
drm_mode_config_reset(drm);
pm_runtime_get_sync(drm->dev);
ret = drm_irq_install(drm, platform_get_irq(pdev, 0));
pm_runtime_put_sync(drm->dev);
if (ret < 0) {
dev_err(drm->dev, "Failed to install IRQ handler\n");
goto err_irq;
}
drm_kms_helper_poll_init(drm);
- mxsfb->fbdev = drm_fbdev_cma_init(drm, 32, drm->mode_config.num_crtc, drm->mode_config.num_connector);
+ mxsfb->fbdev = drm_fbdev_cma_init(drm, 32, drm->mode_config.num_connector);
if (IS_ERR(mxsfb->fbdev)) {
mxsfb->fbdev = NULL;
dev_err(drm->dev, "Failed to init FB CMA area\n");
goto err_cma;
}
platform_set_drvdata(pdev, drm);
drm_helper_hpd_irq_event(drm);
return 0;
err_cma:
drm_irq_uninstall(drm);
err_irq:
drm_panel_detach(mxsfb->panel);
err_vblank:
pm_runtime_disable(drm->dev);
return ret;
}<sep>@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
<|end_of_text|>
| 8,982 |
--- initial
+++ final
@@ -1,32 +1,32 @@
int nouveau_fbcon_init(struct drm_device *dev) {
struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_fbdev *fbcon;
int preferred_bpp;
int ret;
if (!dev->mode_config.num_crtc || (dev->pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) return 0;
fbcon = kzalloc(sizeof(struct nouveau_fbdev), GFP_KERNEL);
if (!fbcon) return -ENOMEM;
drm->fbcon = fbcon;
drm_fb_helper_prepare(dev, &fbcon->helper, &nouveau_fbcon_helper_funcs);
- ret = drm_fb_helper_init(dev, &fbcon->helper, dev->mode_config.num_crtc, 4);
+ ret = drm_fb_helper_init(dev, &fbcon->helper, 4);
if (ret) goto free;
ret = drm_fb_helper_single_add_all_connectors(&fbcon->helper);
if (ret) goto fini;
if (drm->device.info.ram_size <= 32 * 1024 * 1024)
preferred_bpp = 8;
else if (drm->device.info.ram_size <= 64 * 1024 * 1024)
preferred_bpp = 16;
else
preferred_bpp = 32;
/* disable all the possible outputs/crtcs before entering KMS mode */
if (!drm_drv_uses_atomic_modeset(dev)) drm_helper_disable_unused_functions(dev);
ret = drm_fb_helper_initial_config(&fbcon->helper, preferred_bpp);
if (ret) goto fini;
if (fbcon->helper.fbdev) fbcon->helper.fbdev->pixmap.buf_align = 4;
return 0;
fini:
drm_fb_helper_fini(&fbcon->helper);
free:
kfree(fbcon);
return ret;
}<sep>@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
<|end_of_text|>
| 8,983 |
--- initial
+++ final
@@ -1,29 +1,29 @@
struct drm_fb_helper *omap_fbdev_init(struct drm_device *dev) {
struct omap_drm_private *priv = dev->dev_private;
struct omap_fbdev *fbdev = NULL;
struct drm_fb_helper *helper;
int ret = 0;
fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL);
if (!fbdev) goto fail;
INIT_WORK(&fbdev->work, pan_worker);
helper = &fbdev->base;
drm_fb_helper_prepare(dev, helper, &omap_fb_helper_funcs);
- ret = drm_fb_helper_init(dev, helper, priv->num_crtcs, priv->num_connectors);
+ ret = drm_fb_helper_init(dev, helper, priv->num_connectors);
if (ret) {
dev_err(dev->dev, "could not init fbdev: ret=%d\n", ret);
goto fail;
}
ret = drm_fb_helper_single_add_all_connectors(helper);
if (ret) goto fini;
ret = drm_fb_helper_initial_config(helper, 32);
if (ret) goto fini;
priv->fbdev = helper;
return helper;
fini:
drm_fb_helper_fini(helper);
fail:
kfree(fbdev);
dev_warn(dev->dev, "omap_fbdev_init failed\n");
/* well, limp along without an fbdev.. maybe X11 will work? */
return NULL;
}<sep>@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
<|end_of_text|>
| 8,984 |
--- initial
+++ final
@@ -1,24 +1,24 @@
int qxl_fbdev_init(struct qxl_device *qdev) {
struct qxl_fbdev *qfbdev;
int bpp_sel = 32; /* TODO: parameter from somewhere? */
int ret;
qfbdev = kzalloc(sizeof(struct qxl_fbdev), GFP_KERNEL);
if (!qfbdev) return -ENOMEM;
qfbdev->qdev = qdev;
qdev->mode_info.qfbdev = qfbdev;
spin_lock_init(&qfbdev->delayed_ops_lock);
INIT_LIST_HEAD(&qfbdev->delayed_ops);
drm_fb_helper_prepare(&qdev->ddev, &qfbdev->helper, &qxl_fb_helper_funcs);
- ret = drm_fb_helper_init(&qdev->ddev, &qfbdev->helper, qxl_num_crtc, QXLFB_CONN_LIMIT);
+ ret = drm_fb_helper_init(&qdev->ddev, &qfbdev->helper, QXLFB_CONN_LIMIT);
if (ret) goto free;
ret = drm_fb_helper_single_add_all_connectors(&qfbdev->helper);
if (ret) goto fini;
ret = drm_fb_helper_initial_config(&qfbdev->helper, bpp_sel);
if (ret) goto fini;
return 0;
fini:
drm_fb_helper_fini(&qfbdev->helper);
free:
kfree(qfbdev);
return ret;
}<sep>@r@
expression A,B,D,E;
identifier C;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
<|end_of_text|>
| 8,985 |
--- initial
+++ final
@@ -1,28 +1,28 @@
int radeon_fbdev_init(struct radeon_device *rdev) {
struct radeon_fbdev *rfbdev;
int bpp_sel = 32;
int ret;
/* don't enable fbdev if no connectors */
if (list_empty(&rdev->ddev->mode_config.connector_list)) return 0;
/* select 8 bpp console on RN50 or 16MB cards */
if (ASIC_IS_RN50(rdev) || rdev->mc.real_vram_size <= (32 * 1024 * 1024)) bpp_sel = 8;
rfbdev = kzalloc(sizeof(struct radeon_fbdev), GFP_KERNEL);
if (!rfbdev) return -ENOMEM;
rfbdev->rdev = rdev;
rdev->mode_info.rfbdev = rfbdev;
drm_fb_helper_prepare(rdev->ddev, &rfbdev->helper, &radeon_fb_helper_funcs);
- ret = drm_fb_helper_init(rdev->ddev, &rfbdev->helper, rdev->num_crtc, RADEONFB_CONN_LIMIT);
+ ret = drm_fb_helper_init(rdev->ddev, &rfbdev->helper, RADEONFB_CONN_LIMIT);
if (ret) goto free;
ret = drm_fb_helper_single_add_all_connectors(&rfbdev->helper);
if (ret) goto fini;
/* disable all the possible outputs/crtcs before entering KMS mode */
drm_helper_disable_unused_functions(rdev->ddev);
ret = drm_fb_helper_initial_config(&rfbdev->helper, bpp_sel);
if (ret) goto fini;
return 0;
fini:
drm_fb_helper_fini(&rfbdev->helper);
free:
kfree(rfbdev);
return ret;
}<sep>@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
<|end_of_text|>
| 8,986 |
--- initial
+++ final
@@ -1,91 +1,91 @@
int rcar_du_modeset_init(struct rcar_du_device *rcdu) {
static const unsigned int mmio_offsets[] = {DU0_REG_OFFSET, DU2_REG_OFFSET};
struct drm_device *dev = rcdu->ddev;
struct drm_encoder *encoder;
struct drm_fbdev_cma *fbdev;
unsigned int num_encoders;
unsigned int num_groups;
unsigned int i;
int ret;
drm_mode_config_init(dev);
dev->mode_config.min_width = 0;
dev->mode_config.min_height = 0;
dev->mode_config.max_width = 4095;
dev->mode_config.max_height = 2047;
dev->mode_config.funcs = &rcar_du_mode_config_funcs;
rcdu->num_crtcs = rcdu->info->num_crtcs;
ret = rcar_du_properties_init(rcdu);
if (ret < 0) return ret;
/* Initialize vertical blanking interrupts handling. Start with vblank
* disabled for all CRTCs.
*/
ret = drm_vblank_init(dev, (1 << rcdu->info->num_crtcs) - 1);
if (ret < 0) return ret;
/* Initialize the groups. */
num_groups = DIV_ROUND_UP(rcdu->num_crtcs, 2);
for (i = 0; i < num_groups; ++i) {
struct rcar_du_group *rgrp = &rcdu->groups[i];
mutex_init(&rgrp->lock);
rgrp->dev = rcdu;
rgrp->mmio_offset = mmio_offsets[i];
rgrp->index = i;
rgrp->num_crtcs = min(rcdu->num_crtcs - 2 * i, 2U);
/* If we have more than one CRTCs in this group pre-associate
* the low-order planes with CRTC 0 and the high-order planes
* with CRTC 1 to minimize flicker occurring when the
* association is changed.
*/
rgrp->dptsr_planes = rgrp->num_crtcs > 1 ? (rcdu->info->gen >= 3 ? 0x04 : 0xf0) : 0;
if (!rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) {
ret = rcar_du_planes_init(rgrp);
if (ret < 0) return ret;
}
}
/* Initialize the compositors. */
if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) {
for (i = 0; i < rcdu->num_crtcs; ++i) {
struct rcar_du_vsp *vsp = &rcdu->vsps[i];
vsp->index = i;
vsp->dev = rcdu;
rcdu->crtcs[i].vsp = vsp;
ret = rcar_du_vsp_init(vsp);
if (ret < 0) return ret;
}
}
/* Create the CRTCs. */
for (i = 0; i < rcdu->num_crtcs; ++i) {
struct rcar_du_group *rgrp = &rcdu->groups[i / 2];
ret = rcar_du_crtc_create(rgrp, i);
if (ret < 0) return ret;
}
/* Initialize the encoders. */
ret = rcar_du_lvdsenc_init(rcdu);
if (ret < 0) return ret;
ret = rcar_du_encoders_init(rcdu);
if (ret < 0) return ret;
if (ret == 0) {
dev_err(rcdu->dev, "error: no encoder could be initialized\n");
return -EINVAL;
}
num_encoders = ret;
/* Set the possible CRTCs and possible clones. There's always at least
* one way for all encoders to clone each other, set all bits in the
* possible clones field.
*/
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
struct rcar_du_encoder *renc = to_rcar_encoder(encoder);
const struct rcar_du_output_routing *route = &rcdu->info->routes[renc->output];
encoder->possible_crtcs = route->possible_crtcs;
encoder->possible_clones = (1 << num_encoders) - 1;
}
drm_mode_config_reset(dev);
drm_kms_helper_poll_init(dev);
if (dev->mode_config.num_connector) {
- fbdev = drm_fbdev_cma_init(dev, 32, dev->mode_config.num_crtc, dev->mode_config.num_connector);
+ fbdev = drm_fbdev_cma_init(dev, 32, dev->mode_config.num_connector);
if (IS_ERR(fbdev)) return PTR_ERR(fbdev);
rcdu->fbdev = fbdev;
} else {
dev_info(rcdu->dev, "no connector found, disabling fbdev emulation\n");
}
return 0;
}<sep>@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
<|end_of_text|>
| 8,987 |
--- initial
+++ final
@@ -1,29 +1,27 @@
int rockchip_drm_fbdev_init(struct drm_device *dev) {
struct rockchip_drm_private *private = dev->dev_private;
struct drm_fb_helper *helper;
- unsigned int num_crtc;
int ret;
if (!dev->mode_config.num_crtc || !dev->mode_config.num_connector) return -EINVAL;
- num_crtc = dev->mode_config.num_crtc;
helper = &private->fbdev_helper;
drm_fb_helper_prepare(dev, helper, &rockchip_drm_fb_helper_funcs);
- ret = drm_fb_helper_init(dev, helper, num_crtc, ROCKCHIP_MAX_CONNECTOR);
+ ret = drm_fb_helper_init(dev, helper, ROCKCHIP_MAX_CONNECTOR);
if (ret < 0) {
dev_err(dev->dev, "Failed to initialize drm fb helper - %d.\n", ret);
return ret;
}
ret = drm_fb_helper_single_add_all_connectors(helper);
if (ret < 0) {
dev_err(dev->dev, "Failed to add connectors - %d.\n", ret);
goto err_drm_fb_helper_fini;
}
ret = drm_fb_helper_initial_config(helper, PREFERRED_BPP);
if (ret < 0) {
dev_err(dev->dev, "Failed to set initial hw config - %d.\n", ret);
goto err_drm_fb_helper_fini;
}
return 0;
err_drm_fb_helper_fini:
drm_fb_helper_fini(helper);
return ret;
}<sep>@r@
expression A,B,D,E;
identifier C;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
@@
identifier r.C;
type T;
expression V;
@@
- T C;
<...
when != C
- C = V;
...>
<|end_of_text|>
| 8,988 |
--- initial
+++ final
@@ -1,35 +1,35 @@
static int sti_bind(struct device *dev) {
struct drm_device *ddev;
struct sti_private *private;
struct drm_fbdev_cma *fbdev;
int ret;
ddev = drm_dev_alloc(&sti_driver, dev);
if (IS_ERR(ddev)) return PTR_ERR(ddev);
ddev->platformdev = to_platform_device(dev);
ret = sti_init(ddev);
if (ret) goto err_drm_dev_unref;
ret = component_bind_all(ddev->dev, ddev);
if (ret) goto err_cleanup;
ret = drm_dev_register(ddev, 0);
if (ret) goto err_register;
drm_mode_config_reset(ddev);
private
= ddev->dev_private;
if (ddev->mode_config.num_connector) {
- fbdev = drm_fbdev_cma_init(ddev, 32, ddev->mode_config.num_crtc, ddev->mode_config.num_connector);
+ fbdev = drm_fbdev_cma_init(ddev, 32, ddev->mode_config.num_connector);
if (IS_ERR(fbdev)) {
DRM_DEBUG_DRIVER("Warning: fails to create fbdev\n");
fbdev = NULL;
}
private
->fbdev = fbdev;
}
return 0;
err_register:
drm_mode_config_cleanup(ddev);
err_cleanup:
sti_cleanup(ddev);
err_drm_dev_unref:
drm_dev_unref(ddev);
return ret;
}<sep>@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
<|end_of_text|>
| 8,989 |
--- initial
+++ final
@@ -1,7 +1,7 @@
struct drm_fbdev_cma *sun4i_framebuffer_init(struct drm_device *drm) {
drm_mode_config_reset(drm);
drm->mode_config.max_width = 8192;
drm->mode_config.max_height = 8192;
drm->mode_config.funcs = &sun4i_de_mode_config_funcs;
- return drm_fbdev_cma_init(drm, 32, drm->mode_config.num_crtc, drm->mode_config.num_connector);
+ return drm_fbdev_cma_init(drm, 32, drm->mode_config.num_connector);
}<sep>@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
<|end_of_text|>
| 8,990 |
--- initial
+++ final
@@ -1,144 +1,144 @@
static int tilcdc_init(struct drm_driver *ddrv, struct device *dev) {
struct drm_device *ddev;
struct platform_device *pdev = to_platform_device(dev);
struct device_node *node = dev->of_node;
struct tilcdc_drm_private *priv;
struct resource *res;
u32 bpp = 0;
int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv) {
dev_err(dev, "failed to allocate private data\n");
return -ENOMEM;
}
ddev = drm_dev_alloc(ddrv, dev);
if (IS_ERR(ddev)) return PTR_ERR(ddev);
ddev->platformdev = pdev;
ddev->dev_private = priv;
platform_set_drvdata(pdev, ddev);
drm_mode_config_init(ddev);
priv->is_componentized = tilcdc_get_external_components(dev, NULL) > 0;
priv->wq = alloc_ordered_workqueue("tilcdc", 0);
if (!priv->wq) {
ret = -ENOMEM;
goto init_failed;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(dev, "failed to get memory resource\n");
ret = -EINVAL;
goto init_failed;
}
priv->mmio = ioremap_nocache(res->start, resource_size(res));
if (!priv->mmio) {
dev_err(dev, "failed to ioremap\n");
ret = -ENOMEM;
goto init_failed;
}
priv->clk = clk_get(dev, "fck");
if (IS_ERR(priv->clk)) {
dev_err(dev, "failed to get functional clock\n");
ret = -ENODEV;
goto init_failed;
}
#ifdef CONFIG_CPU_FREQ
priv->freq_transition.notifier_call = cpufreq_transition;
ret = cpufreq_register_notifier(&priv->freq_transition, CPUFREQ_TRANSITION_NOTIFIER);
if (ret) {
dev_err(dev, "failed to register cpufreq notifier\n");
priv->freq_transition.notifier_call = NULL;
goto init_failed;
}
#endif
if (of_property_read_u32(node, "max-bandwidth", &priv->max_bandwidth)) priv->max_bandwidth = TILCDC_DEFAULT_MAX_BANDWIDTH;
DBG("Maximum Bandwidth Value %d", priv->max_bandwidth);
if (of_property_read_u32(node, "max-width", &priv->max_width)) priv->max_width = TILCDC_DEFAULT_MAX_WIDTH;
DBG("Maximum Horizontal Pixel Width Value %dpixels", priv->max_width);
if (of_property_read_u32(node, "max-pixelclock", &priv->max_pixelclock)) priv->max_pixelclock = TILCDC_DEFAULT_MAX_PIXELCLOCK;
DBG("Maximum Pixel Clock Value %dKHz", priv->max_pixelclock);
pm_runtime_enable(dev);
/* Determine LCD IP Version */
pm_runtime_get_sync(dev);
switch (tilcdc_read(ddev, LCDC_PID_REG)) {
case 0x4c100102: priv->rev = 1; break;
case 0x4f200800:
case 0x4f201000: priv->rev = 2; break;
default:
dev_warn(dev,
"Unknown PID Reg value 0x%08x, "
"defaulting to LCD revision 1\n",
tilcdc_read(ddev, LCDC_PID_REG));
priv->rev = 1;
break;
}
pm_runtime_put_sync(dev);
if (priv->rev == 1) {
DBG("Revision 1 LCDC supports only RGB565 format");
priv->pixelformats = tilcdc_rev1_formats;
priv->num_pixelformats = ARRAY_SIZE(tilcdc_rev1_formats);
bpp = 16;
} else {
const char *str = "\0";
of_property_read_string(node, "blue-and-red-wiring", &str);
if (0 == strcmp(str, "crossed")) {
DBG("Configured for crossed blue and red wires");
priv->pixelformats = tilcdc_crossed_formats;
priv->num_pixelformats = ARRAY_SIZE(tilcdc_crossed_formats);
bpp = 32; /* Choose bpp with RGB support for fbdef */
} else if (0 == strcmp(str, "straight")) {
DBG("Configured for straight blue and red wires");
priv->pixelformats = tilcdc_straight_formats;
priv->num_pixelformats = ARRAY_SIZE(tilcdc_straight_formats);
bpp = 16; /* Choose bpp with RGB support for fbdef */
} else {
DBG("Blue and red wiring '%s' unknown, use legacy mode", str);
priv->pixelformats = tilcdc_legacy_formats;
priv->num_pixelformats = ARRAY_SIZE(tilcdc_legacy_formats);
bpp = 16; /* This is just a guess */
}
}
ret = tilcdc_crtc_create(ddev);
if (ret < 0) {
dev_err(dev, "failed to create crtc\n");
goto init_failed;
}
modeset_init(ddev);
if (priv->is_componentized) {
ret = component_bind_all(dev, ddev);
if (ret < 0) goto init_failed;
ret = tilcdc_add_component_encoder(ddev);
if (ret < 0) goto init_failed;
} else {
ret = tilcdc_attach_external_device(ddev);
if (ret) goto init_failed;
}
if (!priv->external_connector && ((priv->num_encoders == 0) || (priv->num_connectors == 0))) {
dev_err(dev, "no encoders/connectors found\n");
ret = -ENXIO;
goto init_failed;
}
ret = drm_vblank_init(ddev, 1);
if (ret < 0) {
dev_err(dev, "failed to initialize vblank\n");
goto init_failed;
}
ret = drm_irq_install(ddev, platform_get_irq(pdev, 0));
if (ret < 0) {
dev_err(dev, "failed to install IRQ handler\n");
goto init_failed;
}
drm_mode_config_reset(ddev);
- priv->fbdev = drm_fbdev_cma_init(ddev, bpp, ddev->mode_config.num_crtc, ddev->mode_config.num_connector);
+ priv->fbdev = drm_fbdev_cma_init(ddev, bpp, ddev->mode_config.num_connector);
if (IS_ERR(priv->fbdev)) {
ret = PTR_ERR(priv->fbdev);
goto init_failed;
}
drm_kms_helper_poll_init(ddev);
ret = drm_dev_register(ddev, 0);
if (ret) goto init_failed;
priv->is_registered = true;
return 0;
init_failed:
tilcdc_fini(ddev);
return ret;
}<sep>@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
<|end_of_text|>
| 8,991 |
--- initial
+++ final
@@ -1,24 +1,24 @@
int udl_fbdev_init(struct drm_device *dev) {
struct udl_device *udl = dev->dev_private;
int bpp_sel = fb_bpp;
struct udl_fbdev *ufbdev;
int ret;
ufbdev = kzalloc(sizeof(struct udl_fbdev), GFP_KERNEL);
if (!ufbdev) return -ENOMEM;
udl->fbdev = ufbdev;
drm_fb_helper_prepare(dev, &ufbdev->helper, &udl_fb_helper_funcs);
- ret = drm_fb_helper_init(dev, &ufbdev->helper, 1, 1);
+ ret = drm_fb_helper_init(dev, &ufbdev->helper, 1);
if (ret) goto free;
ret = drm_fb_helper_single_add_all_connectors(&ufbdev->helper);
if (ret) goto fini;
/* disable all the possible outputs/crtcs before entering KMS mode */
drm_helper_disable_unused_functions(dev);
ret = drm_fb_helper_initial_config(&ufbdev->helper, bpp_sel);
if (ret) goto fini;
return 0;
fini:
drm_fb_helper_fini(&ufbdev->helper);
free:
kfree(ufbdev);
return ret;
}<sep>@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
<|end_of_text|>
| 8,992 |
--- initial
+++ final
@@ -1,20 +1,20 @@
int vc4_kms_load(struct drm_device *dev) {
struct vc4_dev *vc4 = to_vc4_dev(dev);
int ret;
sema_init(&vc4->async_modeset, 1);
ret = drm_vblank_init(dev, dev->mode_config.num_crtc);
if (ret < 0) {
dev_err(dev->dev, "failed to initialize vblank\n");
return ret;
}
dev->mode_config.max_width = 2048;
dev->mode_config.max_height = 2048;
dev->mode_config.funcs = &vc4_mode_funcs;
dev->mode_config.preferred_depth = 24;
dev->mode_config.async_page_flip = true;
drm_mode_config_reset(dev);
- vc4->fbdev = drm_fbdev_cma_init(dev, 32, dev->mode_config.num_crtc, dev->mode_config.num_connector);
+ vc4->fbdev = drm_fbdev_cma_init(dev, 32, dev->mode_config.num_connector);
if (IS_ERR(vc4->fbdev)) vc4->fbdev = NULL;
drm_kms_helper_poll_init(dev);
return 0;
}<sep>@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
<|end_of_text|>
| 8,993 |
--- initial
+++ final
@@ -1,19 +1,19 @@
int virtio_gpu_fbdev_init(struct virtio_gpu_device *vgdev) {
struct virtio_gpu_fbdev *vgfbdev;
int bpp_sel = 32; /* TODO: parameter from somewhere? */
int ret;
vgfbdev = kzalloc(sizeof(struct virtio_gpu_fbdev), GFP_KERNEL);
if (!vgfbdev) return -ENOMEM;
vgfbdev->vgdev = vgdev;
vgdev->vgfbdev = vgfbdev;
INIT_DELAYED_WORK(&vgfbdev->work, virtio_gpu_fb_dirty_work);
drm_fb_helper_prepare(vgdev->ddev, &vgfbdev->helper, &virtio_gpu_fb_helper_funcs);
- ret = drm_fb_helper_init(vgdev->ddev, &vgfbdev->helper, vgdev->num_scanouts, VIRTIO_GPUFB_CONN_LIMIT);
+ ret = drm_fb_helper_init(vgdev->ddev, &vgfbdev->helper, VIRTIO_GPUFB_CONN_LIMIT);
if (ret) {
kfree(vgfbdev);
return ret;
}
drm_fb_helper_single_add_all_connectors(&vgfbdev->helper);
drm_fb_helper_initial_config(&vgfbdev->helper, bpp_sel);
return 0;
}<sep>@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
<|end_of_text|>
| 8,994 |
--- initial
+++ final
@@ -1,60 +1,60 @@
static int zx_drm_bind(struct device *dev) {
struct drm_device *drm;
struct zx_drm_private *priv;
int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv) return -ENOMEM;
drm = drm_dev_alloc(&zx_drm_driver, dev);
if (IS_ERR(drm)) return PTR_ERR(drm);
drm->dev_private = priv;
dev_set_drvdata(dev, drm);
drm_mode_config_init(drm);
drm->mode_config.min_width = 16;
drm->mode_config.min_height = 16;
drm->mode_config.max_width = 4096;
drm->mode_config.max_height = 4096;
drm->mode_config.funcs = &zx_drm_mode_config_funcs;
ret = component_bind_all(dev, drm);
if (ret) {
DRM_DEV_ERROR(dev, "failed to bind all components: %d\n", ret);
goto out_unregister;
}
ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
if (ret < 0) {
DRM_DEV_ERROR(dev, "failed to init vblank: %d\n", ret);
goto out_unbind;
}
/*
* We will manage irq handler on our own. In this case, irq_enabled
* need to be true for using vblank core support.
*/
drm->irq_enabled = true;
drm_mode_config_reset(drm);
drm_kms_helper_poll_init(drm);
- priv->fbdev = drm_fbdev_cma_init(drm, 32, drm->mode_config.num_crtc, drm->mode_config.num_connector);
+ priv->fbdev = drm_fbdev_cma_init(drm, 32, drm->mode_config.num_connector);
if (IS_ERR(priv->fbdev)) {
ret = PTR_ERR(priv->fbdev);
DRM_DEV_ERROR(dev, "failed to init cma fbdev: %d\n", ret);
priv->fbdev = NULL;
goto out_poll_fini;
}
ret = drm_dev_register(drm, 0);
if (ret) goto out_fbdev_fini;
return 0;
out_fbdev_fini:
if (priv->fbdev) {
drm_fbdev_cma_fini(priv->fbdev);
priv->fbdev = NULL;
}
out_poll_fini:
drm_kms_helper_poll_fini(drm);
drm_mode_config_cleanup(drm);
drm_vblank_cleanup(drm);
out_unbind:
component_unbind_all(dev, drm);
out_unregister:
dev_set_drvdata(dev, NULL);
drm->dev_private = NULL;
drm_dev_unref(drm);
return ret;
}<sep>@@
expression A,B,C,D,E;
@@
(
- drm_fb_helper_init(A,B,C,D)
+ drm_fb_helper_init(A,B,D)
|
- drm_fbdev_cma_init_with_funcs(A,B,C,D,E)
+ drm_fbdev_cma_init_with_funcs(A,B,D,E)
|
- drm_fbdev_cma_init(A,B,C,D)
+ drm_fbdev_cma_init(A,B,D)
)
<|end_of_text|>
| 8,995 |
--- initial
+++ final
@@ -1,11 +1,11 @@
int amdgpu_framebuffer_init(struct drm_device *dev, struct amdgpu_framebuffer *rfb, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object *obj) {
int ret;
rfb->obj = obj;
- drm_helper_mode_fill_fb_struct(&rfb->base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd);
ret = drm_framebuffer_init(dev, &rfb->base, &amdgpu_fb_funcs);
if (ret) {
rfb->obj = NULL;
return ret;
}
return 0;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 8,996 |
--- initial
+++ final
@@ -1,11 +1,11 @@
int ast_framebuffer_init(struct drm_device *dev, struct ast_framebuffer *ast_fb, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object *obj) {
int ret;
- drm_helper_mode_fill_fb_struct(&ast_fb->base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &ast_fb->base, mode_cmd);
ast_fb->obj = obj;
ret = drm_framebuffer_init(dev, &ast_fb->base, &ast_fb_funcs);
if (ret) {
DRM_ERROR("framebuffer init failed %d\n", ret);
return ret;
}
return 0;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 8,998 |
--- initial
+++ final
@@ -1,11 +1,11 @@
int bochs_framebuffer_init(struct drm_device *dev, struct bochs_framebuffer *gfb, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object *obj) {
int ret;
- drm_helper_mode_fill_fb_struct(&gfb->base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &gfb->base, mode_cmd);
gfb->obj = obj;
ret = drm_framebuffer_init(dev, &gfb->base, &bochs_fb_funcs);
if (ret) {
DRM_ERROR("drm_framebuffer_init failed: %d\n", ret);
return ret;
}
return 0;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 8,999 |
--- initial
+++ final
@@ -1,11 +1,11 @@
int cirrus_framebuffer_init(struct drm_device *dev, struct cirrus_framebuffer *gfb, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object *obj) {
int ret;
- drm_helper_mode_fill_fb_struct(&gfb->base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &gfb->base, mode_cmd);
gfb->obj = obj;
ret = drm_framebuffer_init(dev, &gfb->base, &cirrus_fb_funcs);
if (ret) {
DRM_ERROR("drm_framebuffer_init failed: %d\n", ret);
return ret;
}
return 0;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,000 |
--- initial
+++ final
@@ -1,17 +1,17 @@
static struct drm_fb_cma *drm_fb_cma_alloc(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_cma_object **obj, unsigned int num_planes, const struct drm_framebuffer_funcs *funcs) {
struct drm_fb_cma *fb_cma;
int ret;
int i;
fb_cma = kzalloc(sizeof(*fb_cma), GFP_KERNEL);
if (!fb_cma) return ERR_PTR(-ENOMEM);
- drm_helper_mode_fill_fb_struct(&fb_cma->fb, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &fb_cma->fb, mode_cmd);
for (i = 0; i < num_planes; i++)
fb_cma->obj[i] = obj[i];
ret = drm_framebuffer_init(dev, &fb_cma->fb, funcs);
if (ret) {
dev_err(dev->dev, "Failed to initialize framebuffer: %d\n", ret);
kfree(fb_cma);
return ERR_PTR(ret);
}
return fb_cma;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,001 |
--- initial
+++ final
@@ -1,23 +1,23 @@
-void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, const struct drm_mode_fb_cmd2 *mode_cmd) {
+void drm_helper_mode_fill_fb_struct(struct drm_device *dev, struct drm_framebuffer *fb, const struct drm_mode_fb_cmd2 *mode_cmd) {
const struct drm_format_info *info;
int i;
info = drm_format_info(mode_cmd->pixel_format);
if (!info || !info->depth) {
struct drm_format_name_buf format_name;
DRM_DEBUG_KMS("non-RGB pixel format %s\n", drm_get_format_name(mode_cmd->pixel_format, &format_name));
fb->depth = 0;
fb->bits_per_pixel = 0;
} else {
fb->depth = info->depth;
fb->bits_per_pixel = info->cpp[0] * 8;
}
fb->width = mode_cmd->width;
fb->height = mode_cmd->height;
for (i = 0; i < 4; i++) {
fb->pitches[i] = mode_cmd->pitches[i];
fb->offsets[i] = mode_cmd->offsets[i];
}
fb->modifier = mode_cmd->modifier[0];
fb->pixel_format = mode_cmd->pixel_format;
fb->flags = mode_cmd->flags;
}<sep>@@
identifier fb, mode_cmd;
@@
void drm_helper_mode_fill_fb_struct(
+ struct drm_device *dev,
struct drm_framebuffer *fb,
const struct drm_mode_fb_cmd2 *mode_cmd
)
{ ... }
<|end_of_text|>
| 9,002 |
--- initial
+++ final
@@ -1,23 +1,23 @@
struct drm_framebuffer *exynos_drm_framebuffer_init(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd, struct exynos_drm_gem **exynos_gem, int count) {
struct exynos_drm_fb *exynos_fb;
int i;
int ret;
exynos_fb = kzalloc(sizeof(*exynos_fb), GFP_KERNEL);
if (!exynos_fb) return ERR_PTR(-ENOMEM);
for (i = 0; i < count; i++) {
ret = check_fb_gem_memory_type(dev, exynos_gem[i]);
if (ret < 0) goto err;
exynos_fb->exynos_gem[i] = exynos_gem[i];
exynos_fb->dma_addr[i] = exynos_gem[i]->dma_addr + mode_cmd->offsets[i];
}
- drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &exynos_fb->fb, mode_cmd);
ret = drm_framebuffer_init(dev, &exynos_fb->fb, &exynos_drm_fb_funcs);
if (ret < 0) {
DRM_ERROR("failed to initialize framebuffer\n");
goto err;
}
return &exynos_fb->fb;
err:
kfree(exynos_fb);
return ERR_PTR(ret);
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,003 |
--- initial
+++ final
@@ -1,24 +1,24 @@
static struct tegra_fb *tegra_fb_alloc(struct drm_device *drm, const struct drm_mode_fb_cmd2 *mode_cmd, struct tegra_bo **planes, unsigned int num_planes) {
struct tegra_fb *fb;
unsigned int i;
int err;
fb = kzalloc(sizeof(*fb), GFP_KERNEL);
if (!fb) return ERR_PTR(-ENOMEM);
fb->planes = kzalloc(num_planes * sizeof(*planes), GFP_KERNEL);
if (!fb->planes) {
kfree(fb);
return ERR_PTR(-ENOMEM);
}
fb->num_planes = num_planes;
- drm_helper_mode_fill_fb_struct(&fb->base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(drm, &fb->base, mode_cmd);
for (i = 0; i < fb->num_planes; i++)
fb->planes[i] = planes[i];
err = drm_framebuffer_init(drm, &fb->base, &tegra_fb_funcs);
if (err < 0) {
dev_err(drm->dev, "failed to initialize framebuffer: %d\n", err);
kfree(fb->planes);
kfree(fb);
return ERR_PTR(err);
}
return fb;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,004 |
--- initial
+++ final
@@ -1,19 +1,19 @@
static int psb_framebuffer_init(struct drm_device *dev, struct psb_framebuffer *fb, const struct drm_mode_fb_cmd2 *mode_cmd, struct gtt_range *gt) {
const struct drm_format_info *info;
int ret;
/*
* Reject unknown formats, YUV formats, and formats with more than
* 4 bytes per pixel.
*/
info = drm_format_info(mode_cmd->pixel_format);
if (!info || !info->depth || info->cpp[0] > 4) return -EINVAL;
if (mode_cmd->pitches[0] & 63) return -EINVAL;
- drm_helper_mode_fill_fb_struct(&fb->base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &fb->base, mode_cmd);
fb->gtt = gt;
ret = drm_framebuffer_init(dev, &fb->base, &psb_fb_funcs);
if (ret) {
dev_err(dev->dev, "framebuffer init failed: %d\n", ret);
return ret;
}
return 0;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,005 |
--- initial
+++ final
@@ -1,18 +1,18 @@
struct hibmc_framebuffer *hibmc_framebuffer_init(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object *obj) {
struct hibmc_framebuffer *hibmc_fb;
int ret;
hibmc_fb = kzalloc(sizeof(*hibmc_fb), GFP_KERNEL);
if (!hibmc_fb) {
DRM_ERROR("failed to allocate hibmc_fb\n");
return ERR_PTR(-ENOMEM);
}
- drm_helper_mode_fill_fb_struct(&hibmc_fb->fb, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &hibmc_fb->fb, mode_cmd);
hibmc_fb->obj = obj;
ret = drm_framebuffer_init(dev, &hibmc_fb->fb, &hibmc_fb_funcs);
if (ret) {
DRM_ERROR("drm_framebuffer_init failed: %d\n", ret);
kfree(hibmc_fb);
return ERR_PTR(ret);
}
return hibmc_fb;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,006 |
--- initial
+++ final
@@ -1,119 +1,119 @@
static int intel_framebuffer_init(struct drm_device *dev, struct intel_framebuffer *intel_fb, struct drm_mode_fb_cmd2 *mode_cmd, struct drm_i915_gem_object *obj) {
struct drm_i915_private *dev_priv = to_i915(dev);
unsigned int tiling = i915_gem_object_get_tiling(obj);
int ret;
u32 pitch_limit, stride_alignment;
struct drm_format_name_buf format_name;
WARN_ON(!mutex_is_locked(&dev->struct_mutex));
if (mode_cmd->flags & DRM_MODE_FB_MODIFIERS) {
/*
* If there's a fence, enforce that
* the fb modifier and tiling mode match.
*/
if (tiling != I915_TILING_NONE && tiling != intel_fb_modifier_to_tiling(mode_cmd->modifier[0])) {
DRM_DEBUG("tiling_mode doesn't match fb modifier\n");
return -EINVAL;
}
} else {
if (tiling == I915_TILING_X) {
mode_cmd->modifier[0] = I915_FORMAT_MOD_X_TILED;
} else if (tiling == I915_TILING_Y) {
DRM_DEBUG("No Y tiling for legacy addfb\n");
return -EINVAL;
}
}
/* Passed in modifier sanity checking. */
switch (mode_cmd->modifier[0]) {
case I915_FORMAT_MOD_Y_TILED:
case I915_FORMAT_MOD_Yf_TILED:
if (INTEL_GEN(dev_priv) < 9) {
DRM_DEBUG("Unsupported tiling 0x%llx!\n", mode_cmd->modifier[0]);
return -EINVAL;
}
case DRM_FORMAT_MOD_NONE:
case I915_FORMAT_MOD_X_TILED: break;
default: DRM_DEBUG("Unsupported fb modifier 0x%llx!\n", mode_cmd->modifier[0]); return -EINVAL;
}
/*
* gen2/3 display engine uses the fence if present,
* so the tiling mode must match the fb modifier exactly.
*/
if (INTEL_INFO(dev_priv)->gen < 4 && tiling != intel_fb_modifier_to_tiling(mode_cmd->modifier[0])) {
DRM_DEBUG("tiling_mode must match fb modifier exactly on gen2/3\n");
return -EINVAL;
}
stride_alignment = intel_fb_stride_alignment(dev_priv, mode_cmd->modifier[0], mode_cmd->pixel_format);
if (mode_cmd->pitches[0] & (stride_alignment - 1)) {
DRM_DEBUG("pitch (%d) must be at least %u byte aligned\n", mode_cmd->pitches[0], stride_alignment);
return -EINVAL;
}
pitch_limit = intel_fb_pitch_limit(dev_priv, mode_cmd->modifier[0], mode_cmd->pixel_format);
if (mode_cmd->pitches[0] > pitch_limit) {
DRM_DEBUG("%s pitch (%u) must be at less than %d\n", mode_cmd->modifier[0] != DRM_FORMAT_MOD_NONE ? "tiled" : "linear", mode_cmd->pitches[0], pitch_limit);
return -EINVAL;
}
/*
* If there's a fence, enforce that
* the fb pitch and fence stride match.
*/
if (tiling != I915_TILING_NONE && mode_cmd->pitches[0] != i915_gem_object_get_stride(obj)) {
DRM_DEBUG("pitch (%d) must match tiling stride (%d)\n", mode_cmd->pitches[0], i915_gem_object_get_stride(obj));
return -EINVAL;
}
/* Reject formats not supported by any plane early. */
switch (mode_cmd->pixel_format) {
case DRM_FORMAT_C8:
case DRM_FORMAT_RGB565:
case DRM_FORMAT_XRGB8888:
case DRM_FORMAT_ARGB8888: break;
case DRM_FORMAT_XRGB1555:
if (INTEL_GEN(dev_priv) > 3) {
DRM_DEBUG("unsupported pixel format: %s\n", drm_get_format_name(mode_cmd->pixel_format, &format_name));
return -EINVAL;
}
break;
case DRM_FORMAT_ABGR8888:
if (!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv) && INTEL_GEN(dev_priv) < 9) {
DRM_DEBUG("unsupported pixel format: %s\n", drm_get_format_name(mode_cmd->pixel_format, &format_name));
return -EINVAL;
}
break;
case DRM_FORMAT_XBGR8888:
case DRM_FORMAT_XRGB2101010:
case DRM_FORMAT_XBGR2101010:
if (INTEL_GEN(dev_priv) < 4) {
DRM_DEBUG("unsupported pixel format: %s\n", drm_get_format_name(mode_cmd->pixel_format, &format_name));
return -EINVAL;
}
break;
case DRM_FORMAT_ABGR2101010:
if (!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv)) {
DRM_DEBUG("unsupported pixel format: %s\n", drm_get_format_name(mode_cmd->pixel_format, &format_name));
return -EINVAL;
}
break;
case DRM_FORMAT_YUYV:
case DRM_FORMAT_UYVY:
case DRM_FORMAT_YVYU:
case DRM_FORMAT_VYUY:
if (INTEL_GEN(dev_priv) < 5) {
DRM_DEBUG("unsupported pixel format: %s\n", drm_get_format_name(mode_cmd->pixel_format, &format_name));
return -EINVAL;
}
break;
default: DRM_DEBUG("unsupported pixel format: %s\n", drm_get_format_name(mode_cmd->pixel_format, &format_name)); return -EINVAL;
}
/* FIXME need to adjust LINOFF/TILEOFF accordingly. */
if (mode_cmd->offsets[0] != 0) return -EINVAL;
- drm_helper_mode_fill_fb_struct(&intel_fb->base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &intel_fb->base, mode_cmd);
intel_fb->obj = obj;
ret = intel_fill_fb_info(dev_priv, &intel_fb->base);
if (ret) return ret;
ret = drm_framebuffer_init(dev, &intel_fb->base, &intel_fb_funcs);
if (ret) {
DRM_ERROR("framebuffer init failed %d\n", ret);
return ret;
}
intel_fb->obj->framebuffer_references++;
return 0;
}<sep>@@
expression E1, E2;
@@
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
<|end_of_text|>
| 9,007 |
--- initial
+++ final
@@ -1,12 +1,12 @@
int mgag200_framebuffer_init(struct drm_device *dev, struct mga_framebuffer *gfb, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object *obj) {
int ret;
- drm_helper_mode_fill_fb_struct(&gfb->base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &gfb->base, mode_cmd);
gfb->obj = obj;
ret = drm_framebuffer_init(dev, &gfb->base, &mga_fb_funcs);
if (ret) {
DRM_ERROR("drm_framebuffer_init failed: %d\n", ret);
return ret;
}
return 0;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,008 |
--- initial
+++ final
@@ -1,52 +1,52 @@
struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos) {
struct msm_drm_private *priv = dev->dev_private;
struct msm_kms *kms = priv->kms;
struct msm_framebuffer *msm_fb = NULL;
struct drm_framebuffer *fb;
const struct msm_format *format;
int ret, i, n;
unsigned int hsub, vsub;
DBG("create framebuffer: dev=%p, mode_cmd=%p (%dx%d@%4.4s)", dev, mode_cmd, mode_cmd->width, mode_cmd->height, (char *)&mode_cmd->pixel_format);
n = drm_format_num_planes(mode_cmd->pixel_format);
hsub = drm_format_horz_chroma_subsampling(mode_cmd->pixel_format);
vsub = drm_format_vert_chroma_subsampling(mode_cmd->pixel_format);
format = kms->funcs->get_format(kms, mode_cmd->pixel_format);
if (!format) {
dev_err(dev->dev, "unsupported pixel format: %4.4s\n", (char *)&mode_cmd->pixel_format);
ret = -EINVAL;
goto fail;
}
msm_fb = kzalloc(sizeof(*msm_fb), GFP_KERNEL);
if (!msm_fb) {
ret = -ENOMEM;
goto fail;
}
fb = &msm_fb->base;
msm_fb->format = format;
if (n > ARRAY_SIZE(msm_fb->planes)) {
ret = -EINVAL;
goto fail;
}
for (i = 0; i < n; i++) {
unsigned int width = mode_cmd->width / (i ? hsub : 1);
unsigned int height = mode_cmd->height / (i ? vsub : 1);
unsigned int min_size;
min_size = (height - 1) * mode_cmd->pitches[i] + width * drm_format_plane_cpp(mode_cmd->pixel_format, i) + mode_cmd->offsets[i];
if (bos[i]->size < min_size) {
ret = -EINVAL;
goto fail;
}
msm_fb->planes[i] = bos[i];
}
- drm_helper_mode_fill_fb_struct(fb, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
ret = drm_framebuffer_init(dev, fb, &msm_framebuffer_funcs);
if (ret) {
dev_err(dev->dev, "framebuffer init failed: %d\n", ret);
goto fail;
}
DBG("create: FB ID: %d (%p)", fb->base.id, fb);
return fb;
fail:
kfree(msm_fb);
return ERR_PTR(ret);
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,009 |
--- initial
+++ final
@@ -1,16 +1,16 @@
static struct mtk_drm_fb *mtk_drm_framebuffer_init(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode, struct drm_gem_object *obj) {
struct mtk_drm_fb *mtk_fb;
int ret;
if (drm_format_num_planes(mode->pixel_format) != 1) return ERR_PTR(-EINVAL);
mtk_fb = kzalloc(sizeof(*mtk_fb), GFP_KERNEL);
if (!mtk_fb) return ERR_PTR(-ENOMEM);
- drm_helper_mode_fill_fb_struct(&mtk_fb->base, mode);
+ drm_helper_mode_fill_fb_struct(dev, &mtk_fb->base, mode);
mtk_fb->gem_obj = obj;
ret = drm_framebuffer_init(dev, &mtk_fb->base, &mtk_drm_fb_funcs);
if (ret) {
DRM_ERROR("failed to initialize framebuffer\n");
kfree(mtk_fb);
return ERR_PTR(ret);
}
return mtk_fb;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,010 |
--- initial
+++ final
@@ -1,10 +1,10 @@
int nouveau_framebuffer_new(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd, struct nouveau_bo *nvbo, struct nouveau_framebuffer **pfb) {
struct nouveau_framebuffer *fb;
int ret;
if (!(fb = *pfb = kzalloc(sizeof(*fb), GFP_KERNEL))) return -ENOMEM;
- drm_helper_mode_fill_fb_struct(&fb->base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &fb->base, mode_cmd);
fb->nvbo = nvbo;
ret = drm_framebuffer_init(dev, &fb->base, &nouveau_framebuffer_funcs);
if (ret) kfree(fb);
return ret;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,011 |
--- initial
+++ final
@@ -1,66 +1,66 @@
struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos) {
struct omap_framebuffer *omap_fb = NULL;
struct drm_framebuffer *fb = NULL;
const struct format *format = NULL;
int ret, i, n = drm_format_num_planes(mode_cmd->pixel_format);
DBG("create framebuffer: dev=%p, mode_cmd=%p (%dx%d@%4.4s)", dev, mode_cmd, mode_cmd->width, mode_cmd->height, (char *)&mode_cmd->pixel_format);
for (i = 0; i < ARRAY_SIZE(formats); i++) {
if (formats[i].pixel_format == mode_cmd->pixel_format) {
format = &formats[i];
break;
}
}
if (!format) {
dev_err(dev->dev, "unsupported pixel format: %4.4s\n", (char *)&mode_cmd->pixel_format);
ret = -EINVAL;
goto fail;
}
omap_fb = kzalloc(sizeof(*omap_fb), GFP_KERNEL);
if (!omap_fb) {
ret = -ENOMEM;
goto fail;
}
fb = &omap_fb->base;
omap_fb->format = format;
mutex_init(&omap_fb->lock);
for (i = 0; i < n; i++) {
struct plane *plane = &omap_fb->planes[i];
int size, pitch = mode_cmd->pitches[i];
if (pitch < (mode_cmd->width * format->planes[i].stride_bpp)) {
dev_err(dev->dev, "provided buffer pitch is too small! %d < %d\n", pitch, mode_cmd->width * format->planes[i].stride_bpp);
ret = -EINVAL;
goto fail;
}
if (pitch % format->planes[i].stride_bpp != 0) {
dev_err(dev->dev, "buffer pitch (%d bytes) is not a multiple of pixel size (%d bytes)\n", pitch, format->planes[i].stride_bpp);
ret = -EINVAL;
goto fail;
}
size = pitch * mode_cmd->height / format->planes[i].sub_y;
if (size > (omap_gem_mmap_size(bos[i]) - mode_cmd->offsets[i])) {
dev_err(dev->dev, "provided buffer object is too small! %d < %d\n", bos[i]->size - mode_cmd->offsets[i], size);
ret = -EINVAL;
goto fail;
}
if (i > 0 && pitch != mode_cmd->pitches[i - 1]) {
dev_err(dev->dev, "pitches are not the same between framebuffer planes %d != %d\n", pitch, mode_cmd->pitches[i - 1]);
ret = -EINVAL;
goto fail;
}
plane->bo = bos[i];
plane->offset = mode_cmd->offsets[i];
plane->pitch = pitch;
plane->paddr = 0;
}
- drm_helper_mode_fill_fb_struct(fb, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
ret = drm_framebuffer_init(dev, fb, &omap_framebuffer_funcs);
if (ret) {
dev_err(dev->dev, "framebuffer init failed: %d\n", ret);
goto fail;
}
DBG("create: FB ID: %d (%p)", fb->base.id, fb);
return fb;
fail:
kfree(omap_fb);
return ERR_PTR(ret);
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,012 |
--- initial
+++ final
@@ -1,11 +1,11 @@
int qxl_framebuffer_init(struct drm_device *dev, struct qxl_framebuffer *qfb, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object *obj, const struct drm_framebuffer_funcs *funcs) {
int ret;
qfb->obj = obj;
ret = drm_framebuffer_init(dev, &qfb->base, funcs);
if (ret) {
qfb->obj = NULL;
return ret;
}
- drm_helper_mode_fill_fb_struct(&qfb->base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &qfb->base, mode_cmd);
return 0;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,013 |
--- initial
+++ final
@@ -1,11 +1,11 @@
int radeon_framebuffer_init(struct drm_device *dev, struct radeon_framebuffer *rfb, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object *obj) {
int ret;
rfb->obj = obj;
- drm_helper_mode_fill_fb_struct(&rfb->base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &rfb->base, mode_cmd);
ret = drm_framebuffer_init(dev, &rfb->base, &radeon_fb_funcs);
if (ret) {
rfb->obj = NULL;
return ret;
}
return 0;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,014 |
--- initial
+++ final
@@ -1,17 +1,17 @@
static struct rockchip_drm_fb *rockchip_fb_alloc(struct drm_device *dev, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **obj, unsigned int num_planes) {
struct rockchip_drm_fb *rockchip_fb;
int ret;
int i;
rockchip_fb = kzalloc(sizeof(*rockchip_fb), GFP_KERNEL);
if (!rockchip_fb) return ERR_PTR(-ENOMEM);
- drm_helper_mode_fill_fb_struct(&rockchip_fb->fb, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &rockchip_fb->fb, mode_cmd);
for (i = 0; i < num_planes; i++)
rockchip_fb->obj[i] = obj[i];
ret = drm_framebuffer_init(dev, &rockchip_fb->fb, &rockchip_drm_fb_funcs);
if (ret) {
dev_err(dev->dev, "Failed to initialize framebuffer: %d\n", ret);
kfree(rockchip_fb);
return ERR_PTR(ret);
}
return rockchip_fb;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,015 |
--- initial
+++ final
@@ -1,7 +1,7 @@
static int udl_framebuffer_init(struct drm_device *dev, struct udl_framebuffer *ufb, const struct drm_mode_fb_cmd2 *mode_cmd, struct udl_gem_object *obj) {
int ret;
ufb->obj = obj;
- drm_helper_mode_fill_fb_struct(&ufb->base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &ufb->base, mode_cmd);
ret = drm_framebuffer_init(dev, &ufb->base, &udlfb_funcs);
return ret;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,016 |
--- initial
+++ final
@@ -1,16 +1,16 @@
int virtio_gpu_framebuffer_init(struct drm_device *dev, struct virtio_gpu_framebuffer *vgfb, const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object *obj) {
int ret;
struct virtio_gpu_object *bo;
vgfb->obj = obj;
bo = gem_to_virtio_gpu_obj(obj);
ret = drm_framebuffer_init(dev, &vgfb->base, &virtio_gpu_fb_funcs);
if (ret) {
vgfb->obj = NULL;
return ret;
}
- drm_helper_mode_fill_fb_struct(&vgfb->base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &vgfb->base, mode_cmd);
spin_lock_init(&vgfb->dirty_lock);
vgfb->x1 = vgfb->y1 = INT_MAX;
vgfb->x2 = vgfb->y2 = 0;
return 0;
}<sep>@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
<|end_of_text|>
| 9,017 |
--- initial
+++ final
@@ -1,41 +1,41 @@
static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv, struct vmw_dma_buffer *dmabuf, struct vmw_framebuffer **out, const struct drm_mode_fb_cmd2 *mode_cmd) {
struct drm_device *dev = dev_priv->dev;
struct vmw_framebuffer_dmabuf *vfbd;
unsigned int requested_size;
struct drm_format_name_buf format_name;
int ret;
requested_size = mode_cmd->height * mode_cmd->pitches[0];
if (unlikely(requested_size > dmabuf->base.num_pages * PAGE_SIZE)) {
DRM_ERROR("Screen buffer object size is too small "
"for requested mode.\n");
return -EINVAL;
}
/* Limited framebuffer color depth support for screen objects */
if (dev_priv->active_display_unit == vmw_du_screen_object) {
switch (mode_cmd->pixel_format) {
case DRM_FORMAT_XRGB8888:
case DRM_FORMAT_ARGB8888: break;
case DRM_FORMAT_XRGB1555:
case DRM_FORMAT_RGB565: break;
default: DRM_ERROR("Invalid pixel format: %s\n", drm_get_format_name(mode_cmd->pixel_format, &format_name)); return -EINVAL;
}
}
vfbd = kzalloc(sizeof(*vfbd), GFP_KERNEL);
if (!vfbd) {
ret = -ENOMEM;
goto out_err1;
}
- drm_helper_mode_fill_fb_struct(&vfbd->base.base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &vfbd->base.base, mode_cmd);
vfbd->base.dmabuf = true;
vfbd->buffer = vmw_dmabuf_reference(dmabuf);
vfbd->base.user_handle = mode_cmd->handles[0];
*out = &vfbd->base;
ret = drm_framebuffer_init(dev, &vfbd->base.base, &vmw_framebuffer_dmabuf_funcs);
if (ret) goto out_err2;
return 0;
out_err2:
vmw_dmabuf_unreference(&dmabuf);
kfree(vfbd);
out_err1:
return ret;
}<sep>@@
expression E1, E2;
@@
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
<|end_of_text|>
| 9,018 |
--- initial
+++ final
@@ -1,52 +1,52 @@
static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv, struct vmw_surface *surface, struct vmw_framebuffer **out, const struct drm_mode_fb_cmd2 *mode_cmd, bool is_dmabuf_proxy) {
struct drm_device *dev = dev_priv->dev;
struct vmw_framebuffer_surface *vfbs;
enum SVGA3dSurfaceFormat format;
int ret;
struct drm_format_name_buf format_name;
/* 3D is only supported on HWv8 and newer hosts */
if (dev_priv->active_display_unit == vmw_du_legacy) return -ENOSYS;
/*
* Sanity checks.
*/
/* Surface must be marked as a scanout. */
if (unlikely(!surface->scanout)) return -EINVAL;
if (unlikely(surface->mip_levels[0] != 1 || surface->num_sizes != 1 || surface->base_size.width < mode_cmd->width || surface->base_size.height < mode_cmd->height || surface->base_size.depth != 1)) {
DRM_ERROR("Incompatible surface dimensions "
"for requested mode.\n");
return -EINVAL;
}
switch (mode_cmd->pixel_format) {
case DRM_FORMAT_ARGB8888: format = SVGA3D_A8R8G8B8; break;
case DRM_FORMAT_XRGB8888: format = SVGA3D_X8R8G8B8; break;
case DRM_FORMAT_RGB565: format = SVGA3D_R5G6B5; break;
case DRM_FORMAT_XRGB1555: format = SVGA3D_A1R5G5B5; break;
default: DRM_ERROR("Invalid pixel format: %s\n", drm_get_format_name(mode_cmd->pixel_format, &format_name)); return -EINVAL;
}
/*
* For DX, surface format validation is done when surface->scanout
* is set.
*/
if (!dev_priv->has_dx && format != surface->format) {
DRM_ERROR("Invalid surface format for requested mode.\n");
return -EINVAL;
}
vfbs = kzalloc(sizeof(*vfbs), GFP_KERNEL);
if (!vfbs) {
ret = -ENOMEM;
goto out_err1;
}
- drm_helper_mode_fill_fb_struct(&vfbs->base.base, mode_cmd);
+ drm_helper_mode_fill_fb_struct(dev, &vfbs->base.base, mode_cmd);
vfbs->surface = vmw_surface_reference(surface);
vfbs->base.user_handle = mode_cmd->handles[0];
vfbs->is_dmabuf_proxy = is_dmabuf_proxy;
*out = &vfbs->base;
ret = drm_framebuffer_init(dev, &vfbs->base.base, &vmw_framebuffer_surface_funcs);
if (ret) goto out_err2;
return 0;
out_err2:
vmw_surface_unreference(&surface);
kfree(vfbs);
out_err1:
return ret;
}<sep>@@
expression E1, E2;
@@
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
<|end_of_text|>
| 9,019 |
--- initial
+++ final
@@ -1,83 +1,83 @@
static int bcm_kp_matrix_key_parse_dt(struct bcm_kp *kp) {
struct device *dev = kp->input_dev->dev.parent;
struct device_node *np = dev->of_node;
int error;
unsigned int dt_val;
unsigned int i;
unsigned int num_rows, col_mask, rows_set;
/* Initialize the KPCR Keypad Configuration Register */
kp->kpcr = KPCR_STATUSFILTERENABLE | KPCR_COLFILTERENABLE;
- error = matrix_keypad_parse_of_params(dev, &kp->n_rows, &kp->n_cols);
+ error = matrix_keypad_parse_properties(dev, &kp->n_rows, &kp->n_cols);
if (error) {
dev_err(dev, "failed to parse kp params\n");
return error;
}
/* Set row width for the ASIC block. */
kp->kpcr |= (kp->n_rows - 1) << KPCR_ROWWIDTH_SHIFT;
/* Set column width for the ASIC block. */
kp->kpcr |= (kp->n_cols - 1) << KPCR_COLUMNWIDTH_SHIFT;
/* Configure the IMR registers */
/*
* IMR registers contain interrupt enable bits for 8x8 matrix
* IMR0 register format: <row3> <row2> <row1> <row0>
* IMR1 register format: <row7> <row6> <row5> <row4>
*/
col_mask = (1 << (kp->n_cols)) - 1;
num_rows = kp->n_rows;
/* Set column bits in rows 0 to 3 in IMR0 */
kp->imr0_val = col_mask;
rows_set = 1;
while (--num_rows && rows_set++ < 4)
kp->imr0_val |= kp->imr0_val << MAX_COLS;
/* Set column bits in rows 4 to 7 in IMR1 */
kp->imr1_val = 0;
if (num_rows) {
kp->imr1_val = col_mask;
while (--num_rows)
kp->imr1_val |= kp->imr1_val << MAX_COLS;
}
/* Initialize the KPEMR Keypress Edge Mode Registers */
/* Trigger on both edges */
kp->kpemr = 0;
for (i = 0; i <= 30; i += 2)
kp->kpemr |= (KPEMR_EDGETYPE_BOTH << i);
/*
* Obtain the Status filter debounce value and verify against the
* possible values specified in the DT binding.
*/
of_property_read_u32(np, "status-debounce-filter-period", &dt_val);
if (dt_val > KPCR_STATUSFILTERTYPE_MAX) {
dev_err(dev, "Invalid Status filter debounce value %d\n", dt_val);
return -EINVAL;
}
kp->kpcr |= dt_val << KPCR_STATUSFILTERTYPE_SHIFT;
/*
* Obtain the Column filter debounce value and verify against the
* possible values specified in the DT binding.
*/
of_property_read_u32(np, "col-debounce-filter-period", &dt_val);
if (dt_val > KPCR_COLFILTERTYPE_MAX) {
dev_err(dev, "Invalid Column filter debounce value %d\n", dt_val);
return -EINVAL;
}
kp->kpcr |= dt_val << KPCR_COLFILTERTYPE_SHIFT;
/*
* Determine between the row and column,
* which should be configured as output.
*/
if (of_property_read_bool(np, "row-output-enabled")) {
/*
* Set RowOContrl or ColumnOContrl in KPIOR
* to the number of pins to drive as outputs
*/
kp->kpior = ((1 << kp->n_rows) - 1) << KPIOR_ROWOCONTRL_SHIFT;
} else {
kp->kpior = ((1 << kp->n_cols) - 1) << KPIOR_COLUMNOCONTRL_SHIFT;
}
/*
* Determine if the scan pull up needs to be enabled
*/
if (of_property_read_bool(np, "pull-up-enabled")) kp->kpcr |= KPCR_MODE;
dev_dbg(dev, "n_rows=%d n_col=%d kpcr=%x kpior=%x kpemr=%x\n", kp->n_rows, kp->n_cols, kp->kpcr, kp->kpior, kp->kpemr);
return 0;
}<sep>@@
expression e1,e2,e3;
@@
- matrix_keypad_parse_of_params
+ matrix_keypad_parse_properties
(e1,e2,e3)
<|end_of_text|>
| 9,020 |
--- initial
+++ final
@@ -1,49 +1,49 @@
static int cros_ec_keyb_probe(struct platform_device *pdev) {
struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent);
struct device *dev = &pdev->dev;
struct cros_ec_keyb *ckdev;
struct input_dev *idev;
struct device_node *np;
int err;
np = dev->of_node;
if (!np) return -ENODEV;
ckdev = devm_kzalloc(dev, sizeof(*ckdev), GFP_KERNEL);
if (!ckdev) return -ENOMEM;
- err = matrix_keypad_parse_of_params(dev, &ckdev->rows, &ckdev->cols);
+ err = matrix_keypad_parse_properties(dev, &ckdev->rows, &ckdev->cols);
if (err) return err;
ckdev->valid_keys = devm_kzalloc(dev, ckdev->cols, GFP_KERNEL);
if (!ckdev->valid_keys) return -ENOMEM;
ckdev->old_kb_state = devm_kzalloc(dev, ckdev->cols, GFP_KERNEL);
if (!ckdev->old_kb_state) return -ENOMEM;
idev = devm_input_allocate_device(dev);
if (!idev) return -ENOMEM;
ckdev->ec = ec;
ckdev->notifier.notifier_call = cros_ec_keyb_work;
ckdev->dev = dev;
idev->name = CROS_EC_DEV_NAME;
idev->phys = ec->phys_name;
__set_bit(EV_REP, idev->evbit);
idev->id.bustype = BUS_VIRTUAL;
idev->id.version = 1;
idev->id.product = 0;
idev->dev.parent = dev;
idev->open = cros_ec_keyb_open;
idev->close = cros_ec_keyb_close;
ckdev->ghost_filter = of_property_read_bool(np, "google,needs-ghost-filter");
err = matrix_keypad_build_keymap(NULL, NULL, ckdev->rows, ckdev->cols, NULL, idev);
if (err) {
dev_err(dev, "cannot build key matrix\n");
return err;
}
ckdev->row_shift = get_count_order(ckdev->cols);
input_set_capability(idev, EV_MSC, MSC_SCAN);
input_set_drvdata(idev, ckdev);
ckdev->idev = idev;
cros_ec_keyb_compute_valid_keys(ckdev);
err = input_register_device(ckdev->idev);
if (err) {
dev_err(dev, "cannot register input device\n");
return err;
}
return 0;
}<sep>@@
expression e1,e2,e3;
@@
- matrix_keypad_parse_of_params
+ matrix_keypad_parse_properties
(e1,e2,e3)
<|end_of_text|>
| 9,021 |
--- initial
+++ final
@@ -1,20 +1,20 @@
static int lpc32xx_parse_dt(struct device *dev, struct lpc32xx_kscan_drv *kscandat) {
struct device_node *np = dev->of_node;
u32 rows = 0, columns = 0;
int err;
- err = matrix_keypad_parse_of_params(dev, &rows, &columns);
+ err = matrix_keypad_parse_properties(dev, &rows, &columns);
if (err) return err;
if (rows != columns) {
dev_err(dev, "rows and columns must be equal!\n");
return -EINVAL;
}
kscandat->matrix_sz = rows;
kscandat->row_shift = get_count_order(columns);
of_property_read_u32(np, "nxp,debounce-delay-ms", &kscandat->deb_clks);
of_property_read_u32(np, "nxp,scan-delay-ms", &kscandat->scan_delay);
if (!kscandat->deb_clks || !kscandat->scan_delay) {
dev_err(dev, "debounce or scan delay not specified\n");
return -EINVAL;
}
return 0;
}<sep>@@
expression e1,e2,e3;
@@
- matrix_keypad_parse_of_params
+ matrix_keypad_parse_properties
(e1,e2,e3)
<|end_of_text|>
| 9,022 |
--- initial
+++ final
@@ -1,29 +1,29 @@
int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, const char *keymap_name, unsigned int rows, unsigned int cols, unsigned short *keymap, struct input_dev *input_dev) {
unsigned int row_shift = get_count_order(cols);
size_t max_keys = rows << row_shift;
int i;
int error;
if (WARN_ON(!input_dev->dev.parent)) return -EINVAL;
if (!keymap) {
keymap = devm_kzalloc(input_dev->dev.parent, max_keys * sizeof(*keymap), GFP_KERNEL);
if (!keymap) {
dev_err(input_dev->dev.parent, "Unable to allocate memory for keymap");
return -ENOMEM;
}
}
input_dev->keycode = keymap;
input_dev->keycodesize = sizeof(*keymap);
input_dev->keycodemax = max_keys;
__set_bit(EV_KEY, input_dev->evbit);
if (keymap_data) {
for (i = 0; i < keymap_data->keymap_size; i++) {
unsigned int key = keymap_data->keymap[i];
if (!matrix_keypad_map_key(input_dev, rows, cols, row_shift, key)) return -EINVAL;
}
} else {
- error = matrix_keypad_parse_of_keymap(keymap_name, rows, cols, input_dev);
+ error = matrix_keypad_parse_keymap(keymap_name, rows, cols, input_dev);
if (error) return error;
}
__clear_bit(KEY_RESERVED, input_dev->keybit);
return 0;
}<sep>@@
expression e1,e2,e3,e4;
@@
- matrix_keypad_parse_of_keymap
+ matrix_keypad_parse_keymap
(e1,e2,e3,e4)
<|end_of_text|>
| 9,023 |
--- initial
+++ final
@@ -1,8 +1,8 @@
static int omap4_keypad_parse_dt(struct device *dev, struct omap4_keypad *keypad_data) {
struct device_node *np = dev->of_node;
int err;
- err = matrix_keypad_parse_of_params(dev, &keypad_data->rows, &keypad_data->cols);
+ err = matrix_keypad_parse_properties(dev, &keypad_data->rows, &keypad_data->cols);
if (err) return err;
if (of_get_property(np, "linux,input-no-autorepeat", NULL)) keypad_data->no_autorepeat = true;
return 0;
}<sep>@@
expression e1,e2,e3;
@@
- matrix_keypad_parse_of_params
+ matrix_keypad_parse_properties
(e1,e2,e3)
<|end_of_text|>
| 9,024 |
--- initial
+++ final
@@ -1,89 +1,89 @@
static int pmic8xxx_kp_probe(struct platform_device *pdev) {
struct device_node *np = pdev->dev.of_node;
unsigned int rows, cols;
bool repeat;
bool wakeup;
struct pmic8xxx_kp *kp;
int rc;
unsigned int ctrl_val;
- rc = matrix_keypad_parse_of_params(&pdev->dev, &rows, &cols);
+ rc = matrix_keypad_parse_properties(&pdev->dev, &rows, &cols);
if (rc) return rc;
if (cols > PM8XXX_MAX_COLS || rows > PM8XXX_MAX_ROWS || cols < PM8XXX_MIN_COLS) {
dev_err(&pdev->dev, "invalid platform data\n");
return -EINVAL;
}
repeat = !of_property_read_bool(np, "linux,input-no-autorepeat");
wakeup = of_property_read_bool(np, "wakeup-source") ||
/* legacy name */
of_property_read_bool(np, "linux,keypad-wakeup");
kp = devm_kzalloc(&pdev->dev, sizeof(*kp), GFP_KERNEL);
if (!kp) return -ENOMEM;
kp->regmap = dev_get_regmap(pdev->dev.parent, NULL);
if (!kp->regmap) return -ENODEV;
platform_set_drvdata(pdev, kp);
kp->num_rows = rows;
kp->num_cols = cols;
kp->dev = &pdev->dev;
kp->input = devm_input_allocate_device(&pdev->dev);
if (!kp->input) {
dev_err(&pdev->dev, "unable to allocate input device\n");
return -ENOMEM;
}
kp->key_sense_irq = platform_get_irq(pdev, 0);
if (kp->key_sense_irq < 0) {
dev_err(&pdev->dev, "unable to get keypad sense irq\n");
return kp->key_sense_irq;
}
kp->key_stuck_irq = platform_get_irq(pdev, 1);
if (kp->key_stuck_irq < 0) {
dev_err(&pdev->dev, "unable to get keypad stuck irq\n");
return kp->key_stuck_irq;
}
kp->input->name = "PMIC8XXX keypad";
kp->input->phys = "pmic8xxx_keypad/input0";
kp->input->id.bustype = BUS_I2C;
kp->input->id.version = 0x0001;
kp->input->id.product = 0x0001;
kp->input->id.vendor = 0x0001;
kp->input->open = pmic8xxx_kp_open;
kp->input->close = pmic8xxx_kp_close;
rc = matrix_keypad_build_keymap(NULL, NULL, PM8XXX_MAX_ROWS, PM8XXX_MAX_COLS, kp->keycodes, kp->input);
if (rc) {
dev_err(&pdev->dev, "failed to build keymap\n");
return rc;
}
if (repeat) __set_bit(EV_REP, kp->input->evbit);
input_set_capability(kp->input, EV_MSC, MSC_SCAN);
input_set_drvdata(kp->input, kp);
/* initialize keypad state */
memset(kp->keystate, 0xff, sizeof(kp->keystate));
memset(kp->stuckstate, 0xff, sizeof(kp->stuckstate));
rc = pmic8xxx_kpd_init(kp, pdev);
if (rc < 0) {
dev_err(&pdev->dev, "unable to initialize keypad controller\n");
return rc;
}
rc = devm_request_any_context_irq(&pdev->dev, kp->key_sense_irq, pmic8xxx_kp_irq, IRQF_TRIGGER_RISING, "pmic-keypad", kp);
if (rc < 0) {
dev_err(&pdev->dev, "failed to request keypad sense irq\n");
return rc;
}
rc = devm_request_any_context_irq(&pdev->dev, kp->key_stuck_irq, pmic8xxx_kp_stuck_irq, IRQF_TRIGGER_RISING, "pmic-keypad-stuck", kp);
if (rc < 0) {
dev_err(&pdev->dev, "failed to request keypad stuck irq\n");
return rc;
}
rc = regmap_read(kp->regmap, KEYP_CTRL, &ctrl_val);
if (rc < 0) {
dev_err(&pdev->dev, "failed to read KEYP_CTRL register\n");
return rc;
}
kp->ctrl_reg = ctrl_val;
rc = input_register_device(kp->input);
if (rc < 0) {
dev_err(&pdev->dev, "unable to register keypad input device\n");
return rc;
}
device_init_wakeup(&pdev->dev, wakeup);
return 0;
}<sep>@@
expression e1,e2,e3;
@@
- matrix_keypad_parse_of_params
+ matrix_keypad_parse_properties
(e1,e2,e3)
<|end_of_text|>
| 9,025 |
--- initial
+++ final
@@ -1,17 +1,17 @@
static int pxa27x_keypad_matrix_key_parse_dt(struct pxa27x_keypad *keypad, struct pxa27x_keypad_platform_data *pdata) {
struct input_dev *input_dev = keypad->input_dev;
struct device *dev = input_dev->dev.parent;
u32 rows, cols;
int error;
- error = matrix_keypad_parse_of_params(dev, &rows, &cols);
+ error = matrix_keypad_parse_properties(dev, &rows, &cols);
if (error) return error;
if (rows > MAX_MATRIX_KEY_ROWS || cols > MAX_MATRIX_KEY_COLS) {
dev_err(dev, "rows or cols exceeds maximum value\n");
return -EINVAL;
}
pdata->matrix_key_rows = rows;
pdata->matrix_key_cols = cols;
error = matrix_keypad_build_keymap(NULL, NULL, pdata->matrix_key_rows, pdata->matrix_key_cols, keypad->keycodes, input_dev);
if (error) return error;
return 0;
}<sep>@@
expression e1,e2,e3;
@@
- matrix_keypad_parse_of_params
+ matrix_keypad_parse_properties
(e1,e2,e3)
<|end_of_text|>
| 9,026 |
--- initial
+++ final
@@ -1,13 +1,13 @@
static int keypad_matrix_key_parse_dt(struct st_keyscan *keypad_data) {
struct device *dev = keypad_data->input_dev->dev.parent;
struct device_node *np = dev->of_node;
int error;
- error = matrix_keypad_parse_of_params(dev, &keypad_data->n_rows, &keypad_data->n_cols);
+ error = matrix_keypad_parse_properties(dev, &keypad_data->n_rows, &keypad_data->n_cols);
if (error) {
dev_err(dev, "failed to parse keypad params\n");
return error;
}
of_property_read_u32(np, "st,debounce-us", &keypad_data->debounce_us);
dev_dbg(dev, "n_rows=%d n_col=%d debounce=%d\n", keypad_data->n_rows, keypad_data->n_cols, keypad_data->debounce_us);
return 0;
}<sep>@@
expression e1,e2,e3;
@@
- matrix_keypad_parse_of_params
+ matrix_keypad_parse_properties
(e1,e2,e3)
<|end_of_text|>
| 9,027 |
--- initial
+++ final
@@ -1,46 +1,46 @@
static int stmpe_keypad_probe(struct platform_device *pdev) {
struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
struct device_node *np = pdev->dev.of_node;
struct stmpe_keypad *keypad;
struct input_dev *input;
u32 rows;
u32 cols;
int error;
int irq;
irq = platform_get_irq(pdev, 0);
if (irq < 0) return irq;
keypad = devm_kzalloc(&pdev->dev, sizeof(struct stmpe_keypad), GFP_KERNEL);
if (!keypad) return -ENOMEM;
keypad->stmpe = stmpe;
keypad->variant = &stmpe_keypad_variants[stmpe->partnum];
of_property_read_u32(np, "debounce-interval", &keypad->debounce_ms);
of_property_read_u32(np, "st,scan-count", &keypad->scan_count);
keypad->no_autorepeat = of_property_read_bool(np, "st,no-autorepeat");
input = devm_input_allocate_device(&pdev->dev);
if (!input) return -ENOMEM;
input->name = "STMPE keypad";
input->id.bustype = BUS_I2C;
input->dev.parent = &pdev->dev;
- error = matrix_keypad_parse_of_params(&pdev->dev, &rows, &cols);
+ error = matrix_keypad_parse_properties(&pdev->dev, &rows, &cols);
if (error) return error;
error = matrix_keypad_build_keymap(NULL, NULL, rows, cols, keypad->keymap, input);
if (error) return error;
input_set_capability(input, EV_MSC, MSC_SCAN);
if (!keypad->no_autorepeat) __set_bit(EV_REP, input->evbit);
stmpe_keypad_fill_used_pins(keypad, rows, cols);
keypad->input = input;
error = stmpe_keypad_chip_init(keypad);
if (error < 0) return error;
error = devm_request_threaded_irq(&pdev->dev, irq, NULL, stmpe_keypad_irq, IRQF_ONESHOT, "stmpe-keypad", keypad);
if (error) {
dev_err(&pdev->dev, "unable to get irq: %d\n", error);
return error;
}
error = input_register_device(input);
if (error) {
dev_err(&pdev->dev, "unable to register input device: %d\n", error);
return error;
}
platform_set_drvdata(pdev, keypad);
return 0;
}<sep>@@
expression e1,e2,e3;
@@
- matrix_keypad_parse_of_params
+ matrix_keypad_parse_properties
(e1,e2,e3)
<|end_of_text|>
| 9,028 |
--- initial
+++ final
@@ -1,84 +1,84 @@
static int tca8418_keypad_probe(struct i2c_client *client, const struct i2c_device_id *id) {
struct device *dev = &client->dev;
const struct tca8418_keypad_platform_data *pdata = dev_get_platdata(dev);
struct tca8418_keypad *keypad_data;
struct input_dev *input;
const struct matrix_keymap_data *keymap_data = NULL;
u32 rows = 0, cols = 0;
bool rep = false;
bool irq_is_gpio = false;
int irq;
int error, row_shift, max_keys;
unsigned long trigger = 0;
/* Copy the platform data */
if (pdata) {
if (!pdata->keymap_data) {
dev_err(dev, "no keymap data defined\n");
return -EINVAL;
}
keymap_data = pdata->keymap_data;
rows = pdata->rows;
cols = pdata->cols;
rep = pdata->rep;
irq_is_gpio = pdata->irq_is_gpio;
trigger = IRQF_TRIGGER_FALLING;
} else {
struct device_node *np = dev->of_node;
int err;
- err = matrix_keypad_parse_of_params(dev, &rows, &cols);
+ err = matrix_keypad_parse_properties(dev, &rows, &cols);
if (err) return err;
rep = of_property_read_bool(np, "keypad,autorepeat");
}
if (!rows || rows > TCA8418_MAX_ROWS) {
dev_err(dev, "invalid rows\n");
return -EINVAL;
}
if (!cols || cols > TCA8418_MAX_COLS) {
dev_err(dev, "invalid columns\n");
return -EINVAL;
}
/* Check i2c driver capabilities */
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) {
dev_err(dev, "%s adapter not supported\n", dev_driver_string(&client->adapter->dev));
return -ENODEV;
}
row_shift = get_count_order(cols);
max_keys = rows << row_shift;
/* Allocate memory for keypad_data and input device */
keypad_data = devm_kzalloc(dev, sizeof(*keypad_data), GFP_KERNEL);
if (!keypad_data) return -ENOMEM;
keypad_data->client = client;
keypad_data->row_shift = row_shift;
/* Initialize the chip or fail if chip isn't present */
error = tca8418_configure(keypad_data, rows, cols);
if (error < 0) return error;
/* Configure input device */
input = devm_input_allocate_device(dev);
if (!input) return -ENOMEM;
keypad_data->input = input;
input->name = client->name;
input->id.bustype = BUS_I2C;
input->id.vendor = 0x0001;
input->id.product = 0x001;
input->id.version = 0x0001;
error = matrix_keypad_build_keymap(keymap_data, NULL, rows, cols, NULL, input);
if (error) {
dev_err(dev, "Failed to build keymap\n");
return error;
}
if (rep) __set_bit(EV_REP, input->evbit);
input_set_capability(input, EV_MSC, MSC_SCAN);
irq = client->irq;
if (irq_is_gpio) irq = gpio_to_irq(irq);
error = devm_request_threaded_irq(dev, irq, NULL, tca8418_irq_handler, trigger | IRQF_SHARED | IRQF_ONESHOT, client->name, keypad_data);
if (error) {
dev_err(dev, "Unable to claim irq %d; error %d\n", client->irq, error);
return error;
}
error = input_register_device(input);
if (error) {
dev_err(dev, "Unable to register input device, error: %d\n", error);
return error;
}
return 0;
}<sep>@@
expression e1,e2,e3;
@@
- matrix_keypad_parse_of_params
+ matrix_keypad_parse_properties
(e1,e2,e3)
<|end_of_text|>
| 9,029 |
--- initial
+++ final
@@ -1,79 +1,79 @@
static int twl4030_kp_probe(struct platform_device *pdev) {
struct twl4030_keypad_data *pdata = dev_get_platdata(&pdev->dev);
const struct matrix_keymap_data *keymap_data = NULL;
struct twl4030_keypad *kp;
struct input_dev *input;
u8 reg;
int error;
kp = devm_kzalloc(&pdev->dev, sizeof(*kp), GFP_KERNEL);
if (!kp) return -ENOMEM;
input = devm_input_allocate_device(&pdev->dev);
if (!input) return -ENOMEM;
/* get the debug device */
kp->dbg_dev = &pdev->dev;
kp->input = input;
/* setup input device */
input->name = "TWL4030 Keypad";
input->phys = "twl4030_keypad/input0";
input->id.bustype = BUS_HOST;
input->id.vendor = 0x0001;
input->id.product = 0x0001;
input->id.version = 0x0003;
if (pdata) {
if (!pdata->rows || !pdata->cols || !pdata->keymap_data) {
dev_err(&pdev->dev, "Missing platform_data\n");
return -EINVAL;
}
kp->n_rows = pdata->rows;
kp->n_cols = pdata->cols;
kp->autorepeat = pdata->rep;
keymap_data = pdata->keymap_data;
} else {
- error = matrix_keypad_parse_of_params(&pdev->dev, &kp->n_rows, &kp->n_cols);
+ error = matrix_keypad_parse_properties(&pdev->dev, &kp->n_rows, &kp->n_cols);
if (error) return error;
kp->autorepeat = true;
}
if (kp->n_rows > TWL4030_MAX_ROWS || kp->n_cols > TWL4030_MAX_COLS) {
dev_err(&pdev->dev, "Invalid rows/cols amount specified in platform/devicetree data\n");
return -EINVAL;
}
kp->irq = platform_get_irq(pdev, 0);
if (!kp->irq) {
dev_err(&pdev->dev, "no keyboard irq assigned\n");
return -EINVAL;
}
error = matrix_keypad_build_keymap(keymap_data, NULL, TWL4030_MAX_ROWS, 1 << TWL4030_ROW_SHIFT, kp->keymap, input);
if (error) {
dev_err(kp->dbg_dev, "Failed to build keymap\n");
return error;
}
input_set_capability(input, EV_MSC, MSC_SCAN);
/* Enable auto repeat feature of Linux input subsystem */
if (kp->autorepeat) __set_bit(EV_REP, input->evbit);
error = input_register_device(input);
if (error) {
dev_err(kp->dbg_dev, "Unable to register twl4030 keypad device\n");
return error;
}
error = twl4030_kp_program(kp);
if (error) return error;
/*
* This ISR will always execute in kernel thread context because of
* the need to access the TWL4030 over the I2C bus.
*
* NOTE: we assume this host is wired to TWL4040 INT1, not INT2 ...
*/
error = devm_request_threaded_irq(&pdev->dev, kp->irq, NULL, do_kp_irq, 0, pdev->name, kp);
if (error) {
dev_info(kp->dbg_dev, "request_irq failed for irq no=%d: %d\n", kp->irq, error);
return error;
}
/* Enable KP and TO interrupts now. */
reg = (u8) ~(KEYP_IMR1_KP | KEYP_IMR1_TO);
if (twl4030_kpwrite_u8(kp, reg, KEYP_IMR1)) {
/* mask all events - we don't care about the result */
(void)twl4030_kpwrite_u8(kp, 0xff, KEYP_IMR1);
return -EIO;
}
return 0;
}<sep>@@
expression e1,e2,e3;
@@
- matrix_keypad_parse_of_params
+ matrix_keypad_parse_properties
(e1,e2,e3)
<|end_of_text|>
| 9,030 |
--- initial
+++ final
@@ -1,58 +1,57 @@
struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops, void *priv, const char *name, u32 caps, u8 available_las) {
struct cec_adapter *adap;
int res;
if (WARN_ON(!caps)) return ERR_PTR(-EINVAL);
if (WARN_ON(!ops)) return ERR_PTR(-EINVAL);
if (WARN_ON(!available_las || available_las > CEC_MAX_LOG_ADDRS)) return ERR_PTR(-EINVAL);
adap = kzalloc(sizeof(*adap), GFP_KERNEL);
if (!adap) return ERR_PTR(-ENOMEM);
strlcpy(adap->name, name, sizeof(adap->name));
adap->phys_addr = CEC_PHYS_ADDR_INVALID;
adap->log_addrs.cec_version = CEC_OP_CEC_VERSION_2_0;
adap->log_addrs.vendor_id = CEC_VENDOR_ID_NONE;
adap->capabilities = caps;
adap->available_log_addrs = available_las;
adap->sequence = 0;
adap->ops = ops;
adap->priv = priv;
memset(adap->phys_addrs, 0xff, sizeof(adap->phys_addrs));
mutex_init(&adap->lock);
INIT_LIST_HEAD(&adap->transmit_queue);
INIT_LIST_HEAD(&adap->wait_queue);
init_waitqueue_head(&adap->kthread_waitq);
adap->kthread = kthread_run(cec_thread_func, adap, "cec-%s", name);
if (IS_ERR(adap->kthread)) {
pr_err("cec-%s: kernel_thread() failed\n", name);
res = PTR_ERR(adap->kthread);
kfree(adap);
return ERR_PTR(res);
}
if (!(caps & CEC_CAP_RC)) return adap;
#if IS_REACHABLE(CONFIG_RC_CORE)
/* Prepare the RC input device */
- adap->rc = rc_allocate_device();
+ adap->rc = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!adap->rc) {
pr_err("cec-%s: failed to allocate memory for rc_dev\n", name);
kthread_stop(adap->kthread);
kfree(adap);
return ERR_PTR(-ENOMEM);
}
snprintf(adap->input_name, sizeof(adap->input_name), "RC for %s", name);
snprintf(adap->input_phys, sizeof(adap->input_phys), "%s/input0", name);
adap->rc->input_name = adap->input_name;
adap->rc->input_phys = adap->input_phys;
adap->rc->input_id.bustype = BUS_CEC;
adap->rc->input_id.vendor = 0;
adap->rc->input_id.product = 0;
adap->rc->input_id.version = 1;
- adap->rc->driver_type = RC_DRIVER_SCANCODE;
adap->rc->driver_name = CEC_NAME;
adap->rc->allowed_protocols = RC_BIT_CEC;
adap->rc->priv = adap;
adap->rc->map_name = RC_MAP_CEC;
adap->rc->timeout = MS_TO_NS(100);
#else
adap->capabilities &= ~CEC_CAP_RC;
#endif
return adap;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,031 |
--- initial
+++ final
@@ -1,118 +1,117 @@
int cx23885_input_init(struct cx23885_dev *dev) {
struct cx23885_kernel_ir *kernel_ir;
struct rc_dev *rc;
char *rc_map;
enum rc_driver_type driver_type;
u64 allowed_protos;
int ret;
/*
* If the IR device (hardware registers, chip, GPIO lines, etc.) isn't
* encapsulated in a v4l2_subdev, then I'm not going to deal with it.
*/
if (dev->sd_ir == NULL) return -ENODEV;
switch (dev->board) {
case CX23885_BOARD_HAUPPAUGE_HVR1270:
case CX23885_BOARD_HAUPPAUGE_HVR1850:
case CX23885_BOARD_HAUPPAUGE_HVR1290:
case CX23885_BOARD_HAUPPAUGE_HVR1250:
/* Integrated CX2388[58] IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
/* The grey Hauppauge RC-5 remote */
rc_map = RC_MAP_HAUPPAUGE;
break;
case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
/* Integrated CX23885 IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
/* The grey Terratec remote with orange buttons */
rc_map = RC_MAP_NEC_TERRATEC_CINERGY_XS;
break;
case CX23885_BOARD_TEVII_S470:
/* Integrated CX23885 IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
/* A guess at the remote */
rc_map = RC_MAP_TEVII_NEC;
break;
case CX23885_BOARD_MYGICA_X8507:
/* Integrated CX23885 IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
/* A guess at the remote */
rc_map = RC_MAP_TOTAL_MEDIA_IN_HAND_02;
break;
case CX23885_BOARD_TBS_6980:
case CX23885_BOARD_TBS_6981:
/* Integrated CX23885 IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
/* A guess at the remote */
rc_map = RC_MAP_TBS_NEC;
break;
case CX23885_BOARD_DVBSKY_T9580:
case CX23885_BOARD_DVBSKY_T980C:
case CX23885_BOARD_DVBSKY_S950C:
case CX23885_BOARD_DVBSKY_S950:
case CX23885_BOARD_DVBSKY_S952:
case CX23885_BOARD_DVBSKY_T982:
/* Integrated CX23885 IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
rc_map = RC_MAP_DVBSKY;
break;
case CX23885_BOARD_TT_CT2_4500_CI:
/* Integrated CX23885 IR controller */
driver_type = RC_DRIVER_IR_RAW;
allowed_protos = RC_BIT_ALL_IR_DECODER;
rc_map = RC_MAP_TT_1500;
break;
default: return -ENODEV;
}
/* cx23885 board instance kernel IR state */
kernel_ir = kzalloc(sizeof(struct cx23885_kernel_ir), GFP_KERNEL);
if (kernel_ir == NULL) return -ENOMEM;
kernel_ir->cx = dev;
kernel_ir->name = kasprintf(GFP_KERNEL, "cx23885 IR (%s)", cx23885_boards[dev->board].name);
kernel_ir->phys = kasprintf(GFP_KERNEL, "pci-%s/ir0", pci_name(dev->pci));
/* input device */
- rc = rc_allocate_device();
+ rc = rc_allocate_device(driver_type);
if (!rc) {
ret = -ENOMEM;
goto err_out_free;
}
kernel_ir->rc = rc;
rc->input_name = kernel_ir->name;
rc->input_phys = kernel_ir->phys;
rc->input_id.bustype = BUS_PCI;
rc->input_id.version = 1;
if (dev->pci->subsystem_vendor) {
rc->input_id.vendor = dev->pci->subsystem_vendor;
rc->input_id.product = dev->pci->subsystem_device;
} else {
rc->input_id.vendor = dev->pci->vendor;
rc->input_id.product = dev->pci->device;
}
rc->dev.parent = &dev->pci->dev;
- rc->driver_type = driver_type;
rc->allowed_protocols = allowed_protos;
rc->priv = kernel_ir;
rc->open = cx23885_input_ir_open;
rc->close = cx23885_input_ir_close;
rc->map_name = rc_map;
rc->driver_name = MODULE_NAME;
/* Go */
dev->kernel_ir = kernel_ir;
ret = rc_register_device(rc);
if (ret) goto err_out_stop;
return 0;
err_out_stop:
cx23885_input_ir_stop(dev);
dev->kernel_ir = NULL;
rc_free_device(rc);
err_out_free:
kfree(kernel_ir->phys);
kfree(kernel_ir->name);
kfree(kernel_ir);
return ret;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,032 |
--- initial
+++ final
@@ -1,30 +1,29 @@
static int dm1105_ir_init(struct dm1105_dev *dm1105) {
struct rc_dev *dev;
int err = -ENOMEM;
- dev = rc_allocate_device();
+ dev = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!dev) return -ENOMEM;
snprintf(dm1105->ir.input_phys, sizeof(dm1105->ir.input_phys), "pci-%s/ir0", pci_name(dm1105->pdev));
dev->driver_name = MODULE_NAME;
dev->map_name = RC_MAP_DM1105_NEC;
- dev->driver_type = RC_DRIVER_SCANCODE;
dev->input_name = "DVB on-card IR receiver";
dev->input_phys = dm1105->ir.input_phys;
dev->input_id.bustype = BUS_PCI;
dev->input_id.version = 1;
if (dm1105->pdev->subsystem_vendor) {
dev->input_id.vendor = dm1105->pdev->subsystem_vendor;
dev->input_id.product = dm1105->pdev->subsystem_device;
} else {
dev->input_id.vendor = dm1105->pdev->vendor;
dev->input_id.product = dm1105->pdev->device;
}
dev->dev.parent = &dm1105->pdev->dev;
INIT_WORK(&dm1105->ir.work, dm1105_emit_key);
err = rc_register_device(dev);
if (err < 0) {
rc_free_device(dev);
return err;
}
dm1105->ir.dev = dev;
return 0;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,033 |
--- initial
+++ final
@@ -1,30 +1,29 @@
static int rc_core_dvb_usb_remote_init(struct dvb_usb_device *d) {
int err, rc_interval;
struct rc_dev *dev;
- dev = rc_allocate_device();
+ dev = rc_allocate_device(d->props.rc.core.driver_type);
if (!dev) return -ENOMEM;
dev->driver_name = d->props.rc.core.module_name;
dev->map_name = d->props.rc.core.rc_codes;
dev->change_protocol = d->props.rc.core.change_protocol;
dev->allowed_protocols = d->props.rc.core.allowed_protos;
- dev->driver_type = d->props.rc.core.driver_type;
usb_to_input_id(d->udev, &dev->input_id);
dev->input_name = "IR-receiver inside an USB DVB receiver";
dev->input_phys = d->rc_phys;
dev->dev.parent = &d->udev->dev;
dev->priv = d;
err = rc_register_device(dev);
if (err < 0) {
rc_free_device(dev);
return err;
}
d->input_dev = NULL;
d->rc_dev = dev;
if (!d->props.rc.core.rc_query || d->props.rc.core.bulk_mode) return 0;
/* Polling mode - initialize a work queue for handling it */
INIT_DELAYED_WORK(&d->rc_query_work, dvb_usb_read_remote_control);
rc_interval = d->props.rc.core.rc_interval;
info("schedule remote query interval to %d msecs.", rc_interval);
schedule_delayed_work(&d->rc_query_work, msecs_to_jiffies(rc_interval));
return 0;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,034 |
--- initial
+++ final
@@ -1,47 +1,46 @@
static int dvb_usbv2_remote_init(struct dvb_usb_device *d) {
int ret;
struct rc_dev *dev;
dev_dbg(&d->udev->dev, "%s:\n", __func__);
if (dvb_usbv2_disable_rc_polling || !d->props->get_rc_config) return 0;
d->rc.map_name = d->rc_map;
ret = d->props->get_rc_config(d, &d->rc);
if (ret < 0) goto err;
/* disable rc when there is no keymap defined */
if (!d->rc.map_name) return 0;
- dev = rc_allocate_device();
+ dev = rc_allocate_device(d->rc.driver_type);
if (!dev) {
ret = -ENOMEM;
goto err;
}
dev->dev.parent = &d->udev->dev;
dev->input_name = d->name;
usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));
strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));
dev->input_phys = d->rc_phys;
usb_to_input_id(d->udev, &dev->input_id);
/* TODO: likely RC-core should took const char * */
dev->driver_name = (char *)d->props->driver_name;
dev->map_name = d->rc.map_name;
- dev->driver_type = d->rc.driver_type;
dev->allowed_protocols = d->rc.allowed_protos;
dev->change_protocol = d->rc.change_protocol;
dev->priv = d;
ret = rc_register_device(dev);
if (ret < 0) {
rc_free_device(dev);
goto err;
}
d->rc_dev = dev;
/* start polling if needed */
if (d->rc.query && !d->rc.bulk_mode) {
/* initialize a work queue for handling polling */
INIT_DELAYED_WORK(&d->rc_query_work, dvb_usb_read_remote_control);
dev_info(&d->udev->dev, "%s: schedule remote query interval to %d msecs\n", KBUILD_MODNAME, d->rc.interval);
schedule_delayed_work(&d->rc_query_work, msecs_to_jiffies(d->rc.interval));
d->rc_polling_active = true;
}
return 0;
err:
dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
return ret;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,035 |
--- initial
+++ final
@@ -1,74 +1,73 @@
static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) {
int error = -ENOMEM;
struct rc_dev *rdev;
struct ene_device *dev;
/* allocate memory */
dev = kzalloc(sizeof(struct ene_device), GFP_KERNEL);
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!dev || !rdev) goto exit_free_dev_rdev;
/* validate resources */
error = -ENODEV;
/* init these to -1, as 0 is valid for both */
dev->hw_io = -1;
dev->irq = -1;
if (!pnp_port_valid(pnp_dev, 0) || pnp_port_len(pnp_dev, 0) < ENE_IO_SIZE) goto exit_free_dev_rdev;
if (!pnp_irq_valid(pnp_dev, 0)) goto exit_free_dev_rdev;
spin_lock_init(&dev->hw_lock);
dev->hw_io = pnp_port_start(pnp_dev, 0);
dev->irq = pnp_irq(pnp_dev, 0);
pnp_set_drvdata(pnp_dev, dev);
dev->pnp_dev = pnp_dev;
/* don't allow too short/long sample periods */
if (sample_period < 5 || sample_period > 0x7F) sample_period = ENE_DEFAULT_SAMPLE_PERIOD;
/* detect hardware version and features */
error = ene_hw_detect(dev);
if (error) goto exit_free_dev_rdev;
if (!dev->hw_learning_and_tx_capable && txsim) {
dev->hw_learning_and_tx_capable = true;
setup_timer(&dev->tx_sim_timer, ene_tx_irqsim, (long unsigned int)dev);
pr_warn("Simulation of TX activated\n");
}
if (!dev->hw_learning_and_tx_capable) learning_mode_force = false;
- rdev->driver_type = RC_DRIVER_IR_RAW;
rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rdev->priv = dev;
rdev->open = ene_open;
rdev->close = ene_close;
rdev->s_idle = ene_set_idle;
rdev->driver_name = ENE_DRIVER_NAME;
rdev->map_name = RC_MAP_RC6_MCE;
rdev->input_name = "ENE eHome Infrared Remote Receiver";
if (dev->hw_learning_and_tx_capable) {
rdev->s_learning_mode = ene_set_learning_mode;
init_completion(&dev->tx_complete);
rdev->tx_ir = ene_transmit;
rdev->s_tx_mask = ene_set_tx_mask;
rdev->s_tx_carrier = ene_set_tx_carrier;
rdev->s_tx_duty_cycle = ene_set_tx_duty_cycle;
rdev->s_carrier_report = ene_set_carrier_report;
rdev->input_name = "ENE eHome Infrared Remote Transceiver";
}
dev->rdev = rdev;
ene_rx_setup_hw_buffer(dev);
ene_setup_default_settings(dev);
ene_setup_hw_settings(dev);
device_set_wakeup_capable(&pnp_dev->dev, true);
device_set_wakeup_enable(&pnp_dev->dev, true);
error = rc_register_device(rdev);
if (error < 0) goto exit_free_dev_rdev;
/* claim the resources */
error = -EBUSY;
if (!request_region(dev->hw_io, ENE_IO_SIZE, ENE_DRIVER_NAME)) { goto exit_unregister_device; }
if (request_irq(dev->irq, ene_isr, IRQF_SHARED, ENE_DRIVER_NAME, (void *)dev)) { goto exit_release_hw_io; }
pr_notice("driver has been successfully loaded\n");
return 0;
exit_release_hw_io:
release_region(dev->hw_io, ENE_IO_SIZE);
exit_unregister_device:
rc_unregister_device(rdev);
rdev = NULL;
exit_free_dev_rdev:
rc_free_device(rdev);
kfree(dev);
return error;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,036 |
--- initial
+++ final
@@ -1,73 +1,72 @@
static int fintek_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) {
struct fintek_dev *fintek;
struct rc_dev *rdev;
int ret = -ENOMEM;
fintek = kzalloc(sizeof(struct fintek_dev), GFP_KERNEL);
if (!fintek) return ret;
/* input device for IR remote (and tx) */
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rdev) goto exit_free_dev_rdev;
ret = -ENODEV;
/* validate pnp resources */
if (!pnp_port_valid(pdev, 0)) {
dev_err(&pdev->dev, "IR PNP Port not valid!\n");
goto exit_free_dev_rdev;
}
if (!pnp_irq_valid(pdev, 0)) {
dev_err(&pdev->dev, "IR PNP IRQ not valid!\n");
goto exit_free_dev_rdev;
}
fintek->cir_addr = pnp_port_start(pdev, 0);
fintek->cir_irq = pnp_irq(pdev, 0);
fintek->cir_port_len = pnp_port_len(pdev, 0);
fintek->cr_ip = CR_INDEX_PORT;
fintek->cr_dp = CR_DATA_PORT;
spin_lock_init(&fintek->fintek_lock);
pnp_set_drvdata(pdev, fintek);
fintek->pdev = pdev;
ret = fintek_hw_detect(fintek);
if (ret) goto exit_free_dev_rdev;
/* Initialize CIR & CIR Wake Logical Devices */
fintek_config_mode_enable(fintek);
fintek_cir_ldev_init(fintek);
fintek_config_mode_disable(fintek);
/* Initialize CIR & CIR Wake Config Registers */
fintek_cir_regs_init(fintek);
/* Set up the rc device */
rdev->priv = fintek;
- rdev->driver_type = RC_DRIVER_IR_RAW;
rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rdev->open = fintek_open;
rdev->close = fintek_close;
rdev->input_name = FINTEK_DESCRIPTION;
rdev->input_phys = "fintek/cir0";
rdev->input_id.bustype = BUS_HOST;
rdev->input_id.vendor = VENDOR_ID_FINTEK;
rdev->input_id.product = fintek->chip_major;
rdev->input_id.version = fintek->chip_minor;
rdev->dev.parent = &pdev->dev;
rdev->driver_name = FINTEK_DRIVER_NAME;
rdev->map_name = RC_MAP_RC6_MCE;
rdev->timeout = US_TO_NS(1000);
/* rx resolution is hardwired to 50us atm, 1, 25, 100 also possible */
rdev->rx_resolution = US_TO_NS(CIR_SAMPLE_PERIOD);
fintek->rdev = rdev;
ret = -EBUSY;
/* now claim resources */
if (!request_region(fintek->cir_addr, fintek->cir_port_len, FINTEK_DRIVER_NAME)) goto exit_free_dev_rdev;
if (request_irq(fintek->cir_irq, fintek_cir_isr, IRQF_SHARED, FINTEK_DRIVER_NAME, (void *)fintek)) goto exit_free_cir_addr;
ret = rc_register_device(rdev);
if (ret) goto exit_free_irq;
device_init_wakeup(&pdev->dev, true);
fit_pr(KERN_NOTICE, "driver has been successfully loaded\n");
if (debug) cir_dump_regs(fintek);
return 0;
exit_free_irq:
free_irq(fintek->cir_irq, fintek);
exit_free_cir_addr:
release_region(fintek->cir_addr, fintek->cir_port_len);
exit_free_dev_rdev:
rc_free_device(rdev);
kfree(fintek);
return ret;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,037 |
--- initial
+++ final
@@ -1,68 +1,67 @@
static int gpio_ir_recv_probe(struct platform_device *pdev) {
struct gpio_rc_dev *gpio_dev;
struct rc_dev *rcdev;
const struct gpio_ir_recv_platform_data *pdata = pdev->dev.platform_data;
int rc;
if (pdev->dev.of_node) {
struct gpio_ir_recv_platform_data *dtpdata = devm_kzalloc(&pdev->dev, sizeof(*dtpdata), GFP_KERNEL);
if (!dtpdata) return -ENOMEM;
rc = gpio_ir_recv_get_devtree_pdata(&pdev->dev, dtpdata);
if (rc) return rc;
pdata = dtpdata;
}
if (!pdata) return -EINVAL;
if (pdata->gpio_nr < 0) return -EINVAL;
gpio_dev = kzalloc(sizeof(struct gpio_rc_dev), GFP_KERNEL);
if (!gpio_dev) return -ENOMEM;
- rcdev = rc_allocate_device();
+ rcdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rcdev) {
rc = -ENOMEM;
goto err_allocate_device;
}
rcdev->priv = gpio_dev;
- rcdev->driver_type = RC_DRIVER_IR_RAW;
rcdev->input_name = GPIO_IR_DEVICE_NAME;
rcdev->input_phys = GPIO_IR_DEVICE_NAME "/input0";
rcdev->input_id.bustype = BUS_HOST;
rcdev->input_id.vendor = 0x0001;
rcdev->input_id.product = 0x0001;
rcdev->input_id.version = 0x0100;
rcdev->dev.parent = &pdev->dev;
rcdev->driver_name = GPIO_IR_DRIVER_NAME;
rcdev->min_timeout = 0;
rcdev->timeout = IR_DEFAULT_TIMEOUT;
rcdev->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
if (pdata->allowed_protos)
rcdev->allowed_protocols = pdata->allowed_protos;
else
rcdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rcdev->map_name = pdata->map_name ?: RC_MAP_EMPTY;
gpio_dev->rcdev = rcdev;
gpio_dev->gpio_nr = pdata->gpio_nr;
gpio_dev->active_low = pdata->active_low;
setup_timer(&gpio_dev->flush_timer, flush_timer, (unsigned long)gpio_dev);
rc = gpio_request(pdata->gpio_nr, "gpio-ir-recv");
if (rc < 0) goto err_gpio_request;
rc = gpio_direction_input(pdata->gpio_nr);
if (rc < 0) goto err_gpio_direction_input;
rc = rc_register_device(rcdev);
if (rc < 0) {
dev_err(&pdev->dev, "failed to register rc device\n");
goto err_register_rc_device;
}
platform_set_drvdata(pdev, gpio_dev);
rc = request_any_context_irq(gpio_to_irq(pdata->gpio_nr), gpio_ir_recv_irq, IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, "gpio-ir-recv-irq", gpio_dev);
if (rc < 0) goto err_request_irq;
return 0;
err_request_irq:
rc_unregister_device(rcdev);
rcdev = NULL;
err_register_rc_device:
err_gpio_direction_input:
gpio_free(pdata->gpio_nr);
err_gpio_request:
rc_free_device(rcdev);
err_allocate_device:
kfree(gpio_dev);
return rc;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,038 |
--- initial
+++ final
@@ -1,29 +1,28 @@
int picolcd_init_cir(struct picolcd_data *data, struct hid_report *report) {
struct rc_dev *rdev;
int ret = 0;
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rdev) return -ENOMEM;
rdev->priv = data;
- rdev->driver_type = RC_DRIVER_IR_RAW;
rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rdev->open = picolcd_cir_open;
rdev->close = picolcd_cir_close;
rdev->input_name = data->hdev->name;
rdev->input_phys = data->hdev->phys;
rdev->input_id.bustype = data->hdev->bus;
rdev->input_id.vendor = data->hdev->vendor;
rdev->input_id.product = data->hdev->product;
rdev->input_id.version = data->hdev->version;
rdev->dev.parent = &data->hdev->dev;
rdev->driver_name = PICOLCD_NAME;
rdev->map_name = RC_MAP_RC6_MCE;
rdev->timeout = MS_TO_NS(100);
rdev->rx_resolution = US_TO_NS(1);
ret = rc_register_device(rdev);
if (ret) goto err;
data->rc_dev = rdev;
return 0;
err:
rc_free_device(rdev);
return ret;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,039 |
--- initial
+++ final
@@ -1,61 +1,60 @@
static int igorplugusb_probe(struct usb_interface *intf, const struct usb_device_id *id) {
struct usb_device *udev;
struct usb_host_interface *idesc;
struct usb_endpoint_descriptor *ep;
struct igorplugusb *ir;
struct rc_dev *rc;
int ret = -ENOMEM;
udev = interface_to_usbdev(intf);
idesc = intf->cur_altsetting;
if (idesc->desc.bNumEndpoints != 1) {
dev_err(&intf->dev, "incorrect number of endpoints");
return -ENODEV;
}
ep = &idesc->endpoint[0].desc;
if (!usb_endpoint_dir_in(ep) || !usb_endpoint_xfer_control(ep)) {
dev_err(&intf->dev, "endpoint incorrect");
return -ENODEV;
}
ir = devm_kzalloc(&intf->dev, sizeof(*ir), GFP_KERNEL);
if (!ir) return -ENOMEM;
ir->dev = &intf->dev;
setup_timer(&ir->timer, igorplugusb_timer, (unsigned long)ir);
ir->request.bRequest = GET_INFRACODE;
ir->request.bRequestType = USB_TYPE_VENDOR | USB_DIR_IN;
ir->request.wLength = cpu_to_le16(sizeof(ir->buf_in));
ir->urb = usb_alloc_urb(0, GFP_KERNEL);
if (!ir->urb) goto fail;
usb_fill_control_urb(ir->urb, udev, usb_rcvctrlpipe(udev, 0), (uint8_t *)&ir->request, ir->buf_in, sizeof(ir->buf_in), igorplugusb_callback, ir);
usb_make_path(udev, ir->phys, sizeof(ir->phys));
- rc = rc_allocate_device();
+ rc = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rc) goto fail;
rc->input_name = DRIVER_DESC;
rc->input_phys = ir->phys;
usb_to_input_id(udev, &rc->input_id);
rc->dev.parent = &intf->dev;
- rc->driver_type = RC_DRIVER_IR_RAW;
/*
* This device can only store 36 pulses + spaces, which is not enough
* for the NEC protocol and many others.
*/
rc->allowed_protocols = RC_BIT_ALL_IR_DECODER & ~(RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SONY20 | RC_BIT_MCE_KBD | RC_BIT_SANYO);
rc->priv = ir;
rc->driver_name = DRIVER_NAME;
rc->map_name = RC_MAP_HAUPPAUGE;
rc->timeout = MS_TO_NS(100);
rc->rx_resolution = 85333;
ir->rc = rc;
ret = rc_register_device(rc);
if (ret) {
dev_err(&intf->dev, "failed to register rc device: %d", ret);
goto fail;
}
usb_set_intfdata(intf, ir);
igorplugusb_cmd(ir, SET_INFRABUFFER_EMPTY);
return 0;
fail:
rc_free_device(ir->rc);
usb_free_urb(ir->urb);
del_timer(&ir->timer);
return ret;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,040 |
--- initial
+++ final
@@ -1,88 +1,87 @@
static int iguanair_probe(struct usb_interface *intf, const struct usb_device_id *id) {
struct usb_device *udev = interface_to_usbdev(intf);
struct iguanair *ir;
struct rc_dev *rc;
int ret, pipein, pipeout;
struct usb_host_interface *idesc;
ir = kzalloc(sizeof(*ir), GFP_KERNEL);
- rc = rc_allocate_device();
+ rc = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!ir || !rc) {
ret = -ENOMEM;
goto out;
}
ir->buf_in = usb_alloc_coherent(udev, MAX_IN_PACKET, GFP_KERNEL, &ir->dma_in);
ir->packet = usb_alloc_coherent(udev, MAX_OUT_PACKET, GFP_KERNEL, &ir->dma_out);
ir->urb_in = usb_alloc_urb(0, GFP_KERNEL);
ir->urb_out = usb_alloc_urb(0, GFP_KERNEL);
if (!ir->buf_in || !ir->packet || !ir->urb_in || !ir->urb_out) {
ret = -ENOMEM;
goto out;
}
idesc = intf->altsetting;
if (idesc->desc.bNumEndpoints < 2) {
ret = -ENODEV;
goto out;
}
ir->rc = rc;
ir->dev = &intf->dev;
ir->udev = udev;
mutex_init(&ir->lock);
init_completion(&ir->completion);
pipeout = usb_sndintpipe(udev, idesc->endpoint[1].desc.bEndpointAddress);
usb_fill_int_urb(ir->urb_out, udev, pipeout, ir->packet, MAX_OUT_PACKET, iguanair_irq_out, ir, 1);
ir->urb_out->transfer_dma = ir->dma_out;
ir->urb_out->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
pipein = usb_rcvintpipe(udev, idesc->endpoint[0].desc.bEndpointAddress);
usb_fill_int_urb(ir->urb_in, udev, pipein, ir->buf_in, MAX_IN_PACKET, iguanair_rx, ir, 1);
ir->urb_in->transfer_dma = ir->dma_in;
ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
ret = usb_submit_urb(ir->urb_in, GFP_KERNEL);
if (ret) {
dev_warn(&intf->dev, "failed to submit urb: %d\n", ret);
goto out;
}
ret = iguanair_get_features(ir);
if (ret) goto out2;
snprintf(ir->name, sizeof(ir->name), "IguanaWorks USB IR Transceiver version 0x%04x", ir->version);
usb_make_path(ir->udev, ir->phys, sizeof(ir->phys));
rc->input_name = ir->name;
rc->input_phys = ir->phys;
usb_to_input_id(ir->udev, &rc->input_id);
rc->dev.parent = &intf->dev;
- rc->driver_type = RC_DRIVER_IR_RAW;
rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rc->priv = ir;
rc->open = iguanair_open;
rc->close = iguanair_close;
rc->s_tx_mask = iguanair_set_tx_mask;
rc->s_tx_carrier = iguanair_set_tx_carrier;
rc->tx_ir = iguanair_tx;
rc->driver_name = DRIVER_NAME;
rc->map_name = RC_MAP_RC6_MCE;
rc->min_timeout = 1;
rc->timeout = IR_DEFAULT_TIMEOUT;
rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
rc->rx_resolution = RX_RESOLUTION;
iguanair_set_tx_carrier(rc, 38000);
iguanair_set_tx_mask(rc, 0);
ret = rc_register_device(rc);
if (ret < 0) {
dev_err(&intf->dev, "failed to register rc device %d", ret);
goto out2;
}
usb_set_intfdata(intf, ir);
return 0;
out2:
usb_kill_urb(ir->urb_in);
usb_kill_urb(ir->urb_out);
out:
if (ir) {
usb_free_urb(ir->urb_in);
usb_free_urb(ir->urb_out);
usb_free_coherent(udev, MAX_IN_PACKET, ir->buf_in, ir->dma_in);
usb_free_coherent(udev, MAX_OUT_PACKET, ir->packet, ir->dma_out);
}
rc_free_device(rc);
kfree(ir);
return ret;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,041 |
--- initial
+++ final
@@ -1,45 +1,44 @@
static struct rc_dev *imon_init_rdev(struct imon_context *ictx) {
struct rc_dev *rdev;
int ret;
const unsigned char fp_packet[] = {0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88};
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!rdev) {
dev_err(ictx->dev, "remote control dev allocation failed\n");
goto out;
}
snprintf(ictx->name_rdev, sizeof(ictx->name_rdev), "iMON Remote (%04x:%04x)", ictx->vendor, ictx->product);
usb_make_path(ictx->usbdev_intf0, ictx->phys_rdev, sizeof(ictx->phys_rdev));
strlcat(ictx->phys_rdev, "/input0", sizeof(ictx->phys_rdev));
rdev->input_name = ictx->name_rdev;
rdev->input_phys = ictx->phys_rdev;
usb_to_input_id(ictx->usbdev_intf0, &rdev->input_id);
rdev->dev.parent = ictx->dev;
rdev->priv = ictx;
- rdev->driver_type = RC_DRIVER_SCANCODE;
rdev->allowed_protocols = RC_BIT_OTHER | RC_BIT_RC6_MCE; /* iMON PAD or MCE */
rdev->change_protocol = imon_ir_change_protocol;
rdev->driver_name = MOD_NAME;
/* Enable front-panel buttons and/or knobs */
memcpy(ictx->usb_tx_buf, &fp_packet, sizeof(fp_packet));
ret = send_packet(ictx);
/* Not fatal, but warn about it */
if (ret) dev_info(ictx->dev, "panel buttons/knobs setup failed\n");
if (ictx->product == 0xffdc) {
imon_get_ffdc_type(ictx);
rdev->allowed_protocols = ictx->rc_type;
}
imon_set_display_type(ictx);
if (ictx->rc_type == RC_BIT_RC6_MCE)
rdev->map_name = RC_MAP_IMON_MCE;
else
rdev->map_name = RC_MAP_IMON_PAD;
ret = rc_register_device(rdev);
if (ret < 0) {
dev_err(ictx->dev, "remote input dev register failed\n");
goto out;
}
return rdev;
out:
rc_free_device(rdev);
return NULL;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,042 |
--- initial
+++ final
@@ -1,70 +1,69 @@
static int hix5hd2_ir_probe(struct platform_device *pdev) {
struct rc_dev *rdev;
struct device *dev = &pdev->dev;
struct resource *res;
struct hix5hd2_ir_priv *priv;
struct device_node *node = pdev->dev.of_node;
const char *map_name;
int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv) return -ENOMEM;
priv->regmap = syscon_regmap_lookup_by_phandle(node, "hisilicon,power-syscon");
if (IS_ERR(priv->regmap)) {
dev_info(dev, "no power-reg\n");
priv->regmap = NULL;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
priv->base = devm_ioremap_resource(dev, res);
if (IS_ERR(priv->base)) return PTR_ERR(priv->base);
priv->irq = platform_get_irq(pdev, 0);
if (priv->irq < 0) {
dev_err(dev, "irq can not get\n");
return priv->irq;
}
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rdev) return -ENOMEM;
priv->clock = devm_clk_get(dev, NULL);
if (IS_ERR(priv->clock)) {
dev_err(dev, "clock not found\n");
ret = PTR_ERR(priv->clock);
goto err;
}
clk_prepare_enable(priv->clock);
priv->rate = clk_get_rate(priv->clock);
- rdev->driver_type = RC_DRIVER_IR_RAW;
rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rdev->priv = priv;
rdev->open = hix5hd2_ir_open;
rdev->close = hix5hd2_ir_close;
rdev->driver_name = IR_HIX5HD2_NAME;
map_name = of_get_property(node, "linux,rc-map-name", NULL);
rdev->map_name = map_name ?: RC_MAP_EMPTY;
rdev->input_name = IR_HIX5HD2_NAME;
rdev->input_phys = IR_HIX5HD2_NAME "/input0";
rdev->input_id.bustype = BUS_HOST;
rdev->input_id.vendor = 0x0001;
rdev->input_id.product = 0x0001;
rdev->input_id.version = 0x0100;
rdev->rx_resolution = US_TO_NS(10);
rdev->timeout = US_TO_NS(IR_CFG_SYMBOL_MAXWIDTH * 10);
ret = rc_register_device(rdev);
if (ret < 0) goto clkerr;
if (devm_request_irq(dev, priv->irq, hix5hd2_ir_rx_interrupt, 0, pdev->name, priv) < 0) {
dev_err(dev, "IRQ %d register failed\n", priv->irq);
ret = -EINVAL;
goto regerr;
}
priv->rdev = rdev;
priv->dev = dev;
platform_set_drvdata(pdev, priv);
return ret;
regerr:
rc_unregister_device(rdev);
rdev = NULL;
clkerr:
clk_disable_unprepare(priv->clock);
err:
rc_free_device(rdev);
dev_err(dev, "Unable to register device (%d)\n", ret);
return ret;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,043 |
--- initial
+++ final
@@ -1,109 +1,108 @@
static int ite_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) {
const struct ite_dev_params *dev_desc = NULL;
struct ite_dev *itdev = NULL;
struct rc_dev *rdev = NULL;
int ret = -ENOMEM;
int model_no;
int io_rsrc_no;
ite_dbg("%s called", __func__);
itdev = kzalloc(sizeof(struct ite_dev), GFP_KERNEL);
if (!itdev) return ret;
/* input device for IR remote (and tx) */
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rdev) goto exit_free_dev_rdev;
itdev->rdev = rdev;
ret = -ENODEV;
/* get the model number */
model_no = (int)dev_id->driver_data;
ite_pr(KERN_NOTICE, "Auto-detected model: %s\n", ite_dev_descs[model_no].model);
if (model_number >= 0 && model_number < ARRAY_SIZE(ite_dev_descs)) {
model_no = model_number;
ite_pr(KERN_NOTICE, "The model has been fixed by a module parameter.");
}
ite_pr(KERN_NOTICE, "Using model: %s\n", ite_dev_descs[model_no].model);
/* get the description for the device */
dev_desc = &ite_dev_descs[model_no];
io_rsrc_no = dev_desc->io_rsrc_no;
/* validate pnp resources */
if (!pnp_port_valid(pdev, io_rsrc_no) || pnp_port_len(pdev, io_rsrc_no) != dev_desc->io_region_size) {
dev_err(&pdev->dev, "IR PNP Port not valid!\n");
goto exit_free_dev_rdev;
}
if (!pnp_irq_valid(pdev, 0)) {
dev_err(&pdev->dev, "PNP IRQ not valid!\n");
goto exit_free_dev_rdev;
}
/* store resource values */
itdev->cir_addr = pnp_port_start(pdev, io_rsrc_no);
itdev->cir_irq = pnp_irq(pdev, 0);
/* initialize spinlocks */
spin_lock_init(&itdev->lock);
/* initialize raw event */
init_ir_raw_event(&itdev->rawir);
/* set driver data into the pnp device */
pnp_set_drvdata(pdev, itdev);
itdev->pdev = pdev;
/* initialize waitqueues for transmission */
init_waitqueue_head(&itdev->tx_queue);
init_waitqueue_head(&itdev->tx_ended);
/* copy model-specific parameters */
itdev->params = *dev_desc;
/* apply any overrides */
if (sample_period > 0) itdev->params.sample_period = sample_period;
if (tx_carrier_freq > 0) itdev->params.tx_carrier_freq = tx_carrier_freq;
if (tx_duty_cycle > 0 && tx_duty_cycle <= 100) itdev->params.tx_duty_cycle = tx_duty_cycle;
if (rx_low_carrier_freq > 0) itdev->params.rx_low_carrier_freq = rx_low_carrier_freq;
if (rx_high_carrier_freq > 0) itdev->params.rx_high_carrier_freq = rx_high_carrier_freq;
/* print out parameters */
ite_pr(KERN_NOTICE, "TX-capable: %d\n", (int)itdev->params.hw_tx_capable);
ite_pr(KERN_NOTICE, "Sample period (ns): %ld\n", (long)itdev->params.sample_period);
ite_pr(KERN_NOTICE, "TX carrier frequency (Hz): %d\n", (int)itdev->params.tx_carrier_freq);
ite_pr(KERN_NOTICE, "TX duty cycle (%%): %d\n", (int)itdev->params.tx_duty_cycle);
ite_pr(KERN_NOTICE, "RX low carrier frequency (Hz): %d\n", (int)itdev->params.rx_low_carrier_freq);
ite_pr(KERN_NOTICE, "RX high carrier frequency (Hz): %d\n", (int)itdev->params.rx_high_carrier_freq);
/* set up hardware initial state */
itdev->params.init_hardware(itdev);
/* set up ir-core props */
rdev->priv = itdev;
- rdev->driver_type = RC_DRIVER_IR_RAW;
rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rdev->open = ite_open;
rdev->close = ite_close;
rdev->s_idle = ite_s_idle;
rdev->s_rx_carrier_range = ite_set_rx_carrier_range;
rdev->min_timeout = ITE_MIN_IDLE_TIMEOUT;
rdev->max_timeout = ITE_MAX_IDLE_TIMEOUT;
rdev->timeout = ITE_IDLE_TIMEOUT;
rdev->rx_resolution = ITE_BAUDRATE_DIVISOR * itdev->params.sample_period;
rdev->tx_resolution = ITE_BAUDRATE_DIVISOR * itdev->params.sample_period;
/* set up transmitter related values if needed */
if (itdev->params.hw_tx_capable) {
rdev->tx_ir = ite_tx_ir;
rdev->s_tx_carrier = ite_set_tx_carrier;
rdev->s_tx_duty_cycle = ite_set_tx_duty_cycle;
}
rdev->input_name = dev_desc->model;
rdev->input_id.bustype = BUS_HOST;
rdev->input_id.vendor = PCI_VENDOR_ID_ITE;
rdev->input_id.product = 0;
rdev->input_id.version = 0;
rdev->driver_name = ITE_DRIVER_NAME;
rdev->map_name = RC_MAP_RC6_MCE;
ret = rc_register_device(rdev);
if (ret) goto exit_free_dev_rdev;
ret = -EBUSY;
/* now claim resources */
if (!request_region(itdev->cir_addr, dev_desc->io_region_size, ITE_DRIVER_NAME)) goto exit_unregister_device;
if (request_irq(itdev->cir_irq, ite_cir_isr, IRQF_SHARED, ITE_DRIVER_NAME, (void *)itdev)) goto exit_release_cir_addr;
ite_pr(KERN_NOTICE, "driver has been successfully loaded\n");
return 0;
exit_release_cir_addr:
release_region(itdev->cir_addr, itdev->params.io_region_size);
exit_unregister_device:
rc_unregister_device(rdev);
rdev = NULL;
exit_free_dev_rdev:
rc_free_device(rdev);
kfree(itdev);
return ret;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,044 |
--- initial
+++ final
@@ -1,42 +1,41 @@
static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir) {
struct usb_device *udev = ir->usbdev;
struct device *dev = ir->dev;
struct rc_dev *rc;
int ret;
- rc = rc_allocate_device();
+ rc = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rc) {
dev_err(dev, "remote dev allocation failed");
goto out;
}
snprintf(ir->name, sizeof(ir->name), "%s (%04x:%04x)", mceusb_model[ir->model].name ? mceusb_model[ir->model].name : "Media Center Ed. eHome Infrared Remote Transceiver", le16_to_cpu(ir->usbdev->descriptor.idVendor), le16_to_cpu(ir->usbdev->descriptor.idProduct));
usb_make_path(ir->usbdev, ir->phys, sizeof(ir->phys));
rc->input_name = ir->name;
rc->input_phys = ir->phys;
usb_to_input_id(ir->usbdev, &rc->input_id);
rc->dev.parent = dev;
rc->priv = ir;
- rc->driver_type = RC_DRIVER_IR_RAW;
rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rc->timeout = MS_TO_NS(100);
if (!ir->flags.no_tx) {
rc->s_tx_mask = mceusb_set_tx_mask;
rc->s_tx_carrier = mceusb_set_tx_carrier;
rc->tx_ir = mceusb_tx_ir;
}
rc->driver_name = DRIVER_NAME;
switch (le16_to_cpu(udev->descriptor.idVendor)) {
case VENDOR_HAUPPAUGE: rc->map_name = RC_MAP_HAUPPAUGE; break;
case VENDOR_PCTV: rc->map_name = RC_MAP_PINNACLE_PCTV_HD; break;
default: rc->map_name = RC_MAP_RC6_MCE;
}
if (mceusb_model[ir->model].rc_map) rc->map_name = mceusb_model[ir->model].rc_map;
ret = rc_register_device(rc);
if (ret < 0) {
dev_err(dev, "remote dev registration failed");
goto out;
}
return rc;
out:
rc_free_device(rc);
return NULL;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,045 |
--- initial
+++ final
@@ -1,72 +1,71 @@
static int meson_ir_probe(struct platform_device *pdev) {
struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node;
struct resource *res;
const char *map_name;
struct meson_ir *ir;
int ret;
ir = devm_kzalloc(dev, sizeof(struct meson_ir), GFP_KERNEL);
if (!ir) return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ir->reg = devm_ioremap_resource(dev, res);
if (IS_ERR(ir->reg)) {
dev_err(dev, "failed to map registers\n");
return PTR_ERR(ir->reg);
}
ir->irq = platform_get_irq(pdev, 0);
if (ir->irq < 0) {
dev_err(dev, "no irq resource\n");
return ir->irq;
}
- ir->rc = rc_allocate_device();
+ ir->rc = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!ir->rc) {
dev_err(dev, "failed to allocate rc device\n");
return -ENOMEM;
}
ir->rc->priv = ir;
ir->rc->input_name = DRIVER_NAME;
ir->rc->input_phys = DRIVER_NAME "/input0";
ir->rc->input_id.bustype = BUS_HOST;
map_name = of_get_property(node, "linux,rc-map-name", NULL);
ir->rc->map_name = map_name ? map_name : RC_MAP_EMPTY;
ir->rc->dev.parent = dev;
- ir->rc->driver_type = RC_DRIVER_IR_RAW;
ir->rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
ir->rc->rx_resolution = US_TO_NS(MESON_TRATE);
ir->rc->timeout = MS_TO_NS(200);
ir->rc->driver_name = DRIVER_NAME;
spin_lock_init(&ir->lock);
platform_set_drvdata(pdev, ir);
ret = rc_register_device(ir->rc);
if (ret) {
dev_err(dev, "failed to register rc device\n");
goto out_free;
}
ret = devm_request_irq(dev, ir->irq, meson_ir_irq, 0, "ir-meson", ir);
if (ret) {
dev_err(dev, "failed to request irq\n");
goto out_unreg;
}
/* Reset the decoder */
meson_ir_set_mask(ir, IR_DEC_REG1, REG1_RESET, REG1_RESET);
meson_ir_set_mask(ir, IR_DEC_REG1, REG1_RESET, 0);
/* Set general operation mode (= raw/software decoding) */
if (of_device_is_compatible(node, "amlogic,meson6-ir"))
meson_ir_set_mask(ir, IR_DEC_REG1, REG1_MODE_MASK, DECODE_MODE_RAW << REG1_MODE_SHIFT);
else
meson_ir_set_mask(ir, IR_DEC_REG2, REG2_MODE_MASK, DECODE_MODE_RAW << REG2_MODE_SHIFT);
/* Set rate */
meson_ir_set_mask(ir, IR_DEC_REG0, REG0_RATE_MASK, MESON_TRATE - 1);
/* IRQ on rising and falling edges */
meson_ir_set_mask(ir, IR_DEC_REG1, REG1_IRQSEL_MASK, REG1_IRQSEL_RISE_FALL);
/* Enable the decoder */
meson_ir_set_mask(ir, IR_DEC_REG1, REG1_ENABLE, REG1_ENABLE);
dev_info(dev, "receiver initialized\n");
return 0;
out_unreg:
rc_unregister_device(ir->rc);
ir->rc = NULL;
out_free:
rc_free_device(ir->rc);
return ret;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,046 |
--- initial
+++ final
@@ -1,50 +1,49 @@
static int __init loop_init(void) {
struct rc_dev *rc;
int ret;
- rc = rc_allocate_device();
+ rc = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rc) {
printk(KERN_ERR DRIVER_NAME ": rc_dev allocation failed\n");
return -ENOMEM;
}
rc->input_name = "rc-core loopback device";
rc->input_phys = "rc-core/virtual";
rc->input_id.bustype = BUS_VIRTUAL;
rc->input_id.version = 1;
rc->driver_name = DRIVER_NAME;
rc->map_name = RC_MAP_EMPTY;
rc->priv = &loopdev;
- rc->driver_type = RC_DRIVER_IR_RAW;
rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rc->allowed_wakeup_protocols = RC_BIT_ALL_IR_ENCODER;
rc->encode_wakeup = true;
rc->timeout = 100 * 1000 * 1000; /* 100 ms */
rc->min_timeout = 1;
rc->max_timeout = UINT_MAX;
rc->rx_resolution = 1000;
rc->tx_resolution = 1000;
rc->s_tx_mask = loop_set_tx_mask;
rc->s_tx_carrier = loop_set_tx_carrier;
rc->s_tx_duty_cycle = loop_set_tx_duty_cycle;
rc->s_rx_carrier_range = loop_set_rx_carrier_range;
rc->tx_ir = loop_tx_ir;
rc->s_idle = loop_set_idle;
rc->s_learning_mode = loop_set_learning_mode;
rc->s_carrier_report = loop_set_carrier_report;
rc->s_wakeup_filter = loop_set_wakeup_filter;
loopdev.txmask = RXMASK_REGULAR;
loopdev.txcarrier = 36000;
loopdev.txduty = 50;
loopdev.rxcarriermin = 1;
loopdev.rxcarriermax = ~0;
loopdev.idle = true;
loopdev.learning = false;
loopdev.carrierreport = false;
ret = rc_register_device(rc);
if (ret < 0) {
printk(KERN_ERR DRIVER_NAME ": rc_dev registration failed\n");
rc_free_device(rc);
return ret;
}
loopdev.dev = rc;
return 0;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,047 |
--- initial
+++ final
@@ -1,36 +1,35 @@
static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3) {
struct device *dev = rr3->dev;
struct rc_dev *rc;
int ret;
u16 prod = le16_to_cpu(rr3->udev->descriptor.idProduct);
- rc = rc_allocate_device();
+ rc = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rc) return NULL;
snprintf(rr3->name, sizeof(rr3->name), "RedRat3%s Infrared Remote Transceiver", prod == USB_RR3IIUSB_PRODUCT_ID ? "-II" : "");
usb_make_path(rr3->udev, rr3->phys, sizeof(rr3->phys));
rc->input_name = rr3->name;
rc->input_phys = rr3->phys;
usb_to_input_id(rr3->udev, &rc->input_id);
rc->dev.parent = dev;
rc->priv = rr3;
- rc->driver_type = RC_DRIVER_IR_RAW;
rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rc->min_timeout = MS_TO_NS(RR3_RX_MIN_TIMEOUT);
rc->max_timeout = MS_TO_NS(RR3_RX_MAX_TIMEOUT);
rc->timeout = US_TO_NS(redrat3_get_timeout(rr3));
rc->s_timeout = redrat3_set_timeout;
rc->tx_ir = redrat3_transmit_ir;
rc->s_tx_carrier = redrat3_set_tx_carrier;
rc->s_carrier_report = redrat3_wideband_receiver;
rc->driver_name = DRIVER_NAME;
rc->rx_resolution = US_TO_NS(2);
rc->map_name = RC_MAP_HAUPPAUGE;
ret = rc_register_device(rc);
if (ret < 0) {
dev_err(dev, "remote dev registration failed\n");
goto out;
}
return rc;
out:
rc_free_device(rc);
return NULL;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,048 |
--- initial
+++ final
@@ -1,30 +1,29 @@
int smi_ir_init(struct smi_dev *dev) {
int ret;
struct rc_dev *rc_dev;
struct smi_rc *ir = &dev->ir;
- rc_dev = rc_allocate_device();
+ rc_dev = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!rc_dev) return -ENOMEM;
/* init input device */
snprintf(ir->input_name, sizeof(ir->input_name), "IR (%s)", dev->info->name);
snprintf(ir->input_phys, sizeof(ir->input_phys), "pci-%s/ir0", pci_name(dev->pci_dev));
rc_dev->driver_name = "SMI_PCIe";
rc_dev->input_phys = ir->input_phys;
rc_dev->input_name = ir->input_name;
rc_dev->input_id.bustype = BUS_PCI;
rc_dev->input_id.version = 1;
rc_dev->input_id.vendor = dev->pci_dev->subsystem_vendor;
rc_dev->input_id.product = dev->pci_dev->subsystem_device;
rc_dev->dev.parent = &dev->pci_dev->dev;
- rc_dev->driver_type = RC_DRIVER_SCANCODE;
rc_dev->map_name = dev->info->rc_map;
ir->rc_dev = rc_dev;
ir->dev = dev;
INIT_WORK(&ir->work, smi_ir_decode);
smi_ir_disableInterrupt(ir);
ret = rc_register_device(rc_dev);
if (ret) goto ir_err;
return 0;
ir_err:
rc_free_device(rc_dev);
return ret;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,049 |
--- initial
+++ final
@@ -1,38 +1,37 @@
int sms_ir_init(struct smscore_device_t *coredev) {
int err;
int board_id = smscore_get_board_id(coredev);
struct rc_dev *dev;
pr_debug("Allocating rc device\n");
- dev = rc_allocate_device();
+ dev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!dev) return -ENOMEM;
coredev->ir.controller = 0; /* Todo: vega/nova SPI number */
coredev->ir.timeout = IR_DEFAULT_TIMEOUT;
pr_debug("IR port %d, timeout %d ms\n", coredev->ir.controller, coredev->ir.timeout);
snprintf(coredev->ir.name, sizeof(coredev->ir.name), "SMS IR (%s)", sms_get_board(board_id)->name);
strlcpy(coredev->ir.phys, coredev->devpath, sizeof(coredev->ir.phys));
strlcat(coredev->ir.phys, "/ir0", sizeof(coredev->ir.phys));
dev->input_name = coredev->ir.name;
dev->input_phys = coredev->ir.phys;
dev->dev.parent = coredev->device;
#if 0
/* TODO: properly initialize the parameters below */
dev->input_id.bustype = BUS_USB;
dev->input_id.version = 1;
dev->input_id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor);
dev->input_id.product = le16_to_cpu(dev->udev->descriptor.idProduct);
#endif
dev->priv = coredev;
- dev->driver_type = RC_DRIVER_IR_RAW;
dev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
dev->map_name = sms_get_board(board_id)->rc_codes;
dev->driver_name = MODULE_NAME;
pr_debug("Input device (IR) %s is set for key events\n", dev->input_name);
err = rc_register_device(dev);
if (err < 0) {
pr_err("Failed to register device\n");
rc_free_device(dev);
return err;
}
coredev->ir.dev = dev;
return 0;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,050 |
--- initial
+++ final
@@ -1,31 +1,30 @@
static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz) {
struct rc_dev *rdev;
struct device *dev = sz->dev;
int ret;
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!rdev) {
dev_err(dev, "remote dev allocation failed\n");
goto out;
}
snprintf(sz->name, sizeof(sz->name), "Streamzap PC Remote Infrared Receiver (%04x:%04x)", le16_to_cpu(sz->usbdev->descriptor.idVendor), le16_to_cpu(sz->usbdev->descriptor.idProduct));
usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys));
strlcat(sz->phys, "/input0", sizeof(sz->phys));
rdev->input_name = sz->name;
rdev->input_phys = sz->phys;
usb_to_input_id(sz->usbdev, &rdev->input_id);
rdev->dev.parent = dev;
rdev->priv = sz;
- rdev->driver_type = RC_DRIVER_IR_RAW;
rdev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rdev->driver_name = DRIVER_NAME;
rdev->map_name = RC_MAP_STREAMZAP;
ret = rc_register_device(rdev);
if (ret < 0) {
dev_err(dev, "remote input device register failed\n");
goto out;
}
return rdev;
out:
rc_free_device(rdev);
return NULL;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,051 |
--- initial
+++ final
@@ -1,125 +1,124 @@
static int sunxi_ir_probe(struct platform_device *pdev) {
int ret = 0;
unsigned long tmp = 0;
struct device *dev = &pdev->dev;
struct device_node *dn = dev->of_node;
struct resource *res;
struct sunxi_ir *ir;
ir = devm_kzalloc(dev, sizeof(struct sunxi_ir), GFP_KERNEL);
if (!ir) return -ENOMEM;
spin_lock_init(&ir->ir_lock);
if (of_device_is_compatible(dn, "allwinner,sun5i-a13-ir"))
ir->fifo_size = 64;
else
ir->fifo_size = 16;
/* Clock */
ir->apb_clk = devm_clk_get(dev, "apb");
if (IS_ERR(ir->apb_clk)) {
dev_err(dev, "failed to get a apb clock.\n");
return PTR_ERR(ir->apb_clk);
}
ir->clk = devm_clk_get(dev, "ir");
if (IS_ERR(ir->clk)) {
dev_err(dev, "failed to get a ir clock.\n");
return PTR_ERR(ir->clk);
}
/* Reset (optional) */
ir->rst = devm_reset_control_get_optional(dev, NULL);
if (IS_ERR(ir->rst)) {
ret = PTR_ERR(ir->rst);
if (ret == -EPROBE_DEFER) return ret;
ir->rst = NULL;
} else {
ret = reset_control_deassert(ir->rst);
if (ret) return ret;
}
ret = clk_set_rate(ir->clk, SUNXI_IR_BASE_CLK);
if (ret) {
dev_err(dev, "set ir base clock failed!\n");
goto exit_reset_assert;
}
if (clk_prepare_enable(ir->apb_clk)) {
dev_err(dev, "try to enable apb_ir_clk failed\n");
ret = -EINVAL;
goto exit_reset_assert;
}
if (clk_prepare_enable(ir->clk)) {
dev_err(dev, "try to enable ir_clk failed\n");
ret = -EINVAL;
goto exit_clkdisable_apb_clk;
}
/* IO */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
ir->base = devm_ioremap_resource(dev, res);
if (IS_ERR(ir->base)) {
dev_err(dev, "failed to map registers\n");
ret = PTR_ERR(ir->base);
goto exit_clkdisable_clk;
}
- ir->rc = rc_allocate_device();
+ ir->rc = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!ir->rc) {
dev_err(dev, "failed to allocate device\n");
ret = -ENOMEM;
goto exit_clkdisable_clk;
}
ir->rc->priv = ir;
ir->rc->input_name = SUNXI_IR_DEV;
ir->rc->input_phys = "sunxi-ir/input0";
ir->rc->input_id.bustype = BUS_HOST;
ir->rc->input_id.vendor = 0x0001;
ir->rc->input_id.product = 0x0001;
ir->rc->input_id.version = 0x0100;
ir->map_name = of_get_property(dn, "linux,rc-map-name", NULL);
ir->rc->map_name = ir->map_name ?: RC_MAP_EMPTY;
ir->rc->dev.parent = dev;
- ir->rc->driver_type = RC_DRIVER_IR_RAW;
ir->rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
ir->rc->rx_resolution = SUNXI_IR_SAMPLE;
ir->rc->timeout = MS_TO_NS(SUNXI_IR_TIMEOUT);
ir->rc->driver_name = SUNXI_IR_DEV;
ret = rc_register_device(ir->rc);
if (ret) {
dev_err(dev, "failed to register rc device\n");
goto exit_free_dev;
}
platform_set_drvdata(pdev, ir);
/* IRQ */
ir->irq = platform_get_irq(pdev, 0);
if (ir->irq < 0) {
dev_err(dev, "no irq resource\n");
ret = ir->irq;
goto exit_free_dev;
}
ret = devm_request_irq(dev, ir->irq, sunxi_ir_irq, 0, SUNXI_IR_DEV, ir);
if (ret) {
dev_err(dev, "failed request irq\n");
goto exit_free_dev;
}
/* Enable CIR Mode */
writel(REG_CTL_MD, ir->base + SUNXI_IR_CTL_REG);
/* Set noise threshold and idle threshold */
writel(REG_CIR_NTHR(SUNXI_IR_RXNOISE) | REG_CIR_ITHR(SUNXI_IR_RXIDLE), ir->base + SUNXI_IR_CIR_REG);
/* Invert Input Signal */
writel(REG_RXCTL_RPPI, ir->base + SUNXI_IR_RXCTL_REG);
/* Clear All Rx Interrupt Status */
writel(REG_RXSTA_CLEARALL, ir->base + SUNXI_IR_RXSTA_REG);
/*
* Enable IRQ on overflow, packet end, FIFO available with trigger
* level
*/
writel(REG_RXINT_ROI_EN | REG_RXINT_RPEI_EN | REG_RXINT_RAI_EN | REG_RXINT_RAL(ir->fifo_size / 2 - 1), ir->base + SUNXI_IR_RXINT_REG);
/* Enable IR Module */
tmp = readl(ir->base + SUNXI_IR_CTL_REG);
writel(tmp | REG_CTL_GEN | REG_CTL_RXEN, ir->base + SUNXI_IR_CTL_REG);
dev_info(dev, "initialized sunXi IR driver\n");
return 0;
exit_free_dev:
rc_free_device(ir->rc);
exit_clkdisable_clk:
clk_disable_unprepare(ir->clk);
exit_clkdisable_apb_clk:
clk_disable_unprepare(ir->apb_clk);
exit_reset_assert:
if (ir->rst) reset_control_assert(ir->rst);
return ret;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,052 |
--- initial
+++ final
@@ -1,57 +1,56 @@
int tm6000_ir_init(struct tm6000_core *dev) {
struct tm6000_IR *ir;
struct rc_dev *rc;
int err = -ENOMEM;
u64 rc_type;
if (!enable_ir) return -ENODEV;
if (!dev->caps.has_remote) return 0;
if (!dev->ir_codes) return 0;
ir = kzalloc(sizeof(*ir), GFP_ATOMIC);
- rc = rc_allocate_device();
+ rc = rc_allocate_device(RC_DRIVER_SCANCODE);
if (!ir || !rc) goto out;
dprintk(2, "%s\n", __func__);
/* record handles to ourself */
ir->dev = dev;
dev->ir = ir;
ir->rc = rc;
/* input setup */
rc->allowed_protocols = RC_BIT_RC5 | RC_BIT_NEC;
/* Neded, in order to support NEC remotes with 24 or 32 bits */
rc->scancode_mask = 0xffff;
rc->priv = ir;
rc->change_protocol = tm6000_ir_change_protocol;
if (dev->int_in.endp) {
rc->open = __tm6000_ir_int_start;
rc->close = __tm6000_ir_int_stop;
INIT_DELAYED_WORK(&ir->work, tm6000_ir_int_work);
} else {
rc->open = tm6000_ir_start;
rc->close = tm6000_ir_stop;
ir->polling = 50;
INIT_DELAYED_WORK(&ir->work, tm6000_ir_handle_key);
}
- rc->driver_type = RC_DRIVER_SCANCODE;
snprintf(ir->name, sizeof(ir->name), "tm5600/60x0 IR (%s)", dev->name);
usb_make_path(dev->udev, ir->phys, sizeof(ir->phys));
strlcat(ir->phys, "/input0", sizeof(ir->phys));
rc_type = RC_BIT_UNKNOWN;
tm6000_ir_change_protocol(rc, &rc_type);
rc->input_name = ir->name;
rc->input_phys = ir->phys;
rc->input_id.bustype = BUS_USB;
rc->input_id.version = 1;
rc->input_id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor);
rc->input_id.product = le16_to_cpu(dev->udev->descriptor.idProduct);
rc->map_name = dev->ir_codes;
rc->driver_name = "tm6000";
rc->dev.parent = &dev->udev->dev;
/* ir register */
err = rc_register_device(rc);
if (err) goto out;
return 0;
out:
dev->ir = NULL;
rc_free_device(rc);
kfree(ir);
return err;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,053 |
--- initial
+++ final
@@ -1,140 +1,139 @@
static int ttusbir_probe(struct usb_interface *intf, const struct usb_device_id *id) {
struct ttusbir *tt;
struct usb_interface_descriptor *idesc;
struct usb_endpoint_descriptor *desc;
struct rc_dev *rc;
int i, j, ret;
int altsetting = -1;
tt = kzalloc(sizeof(*tt), GFP_KERNEL);
- rc = rc_allocate_device();
+ rc = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!tt || !rc) {
ret = -ENOMEM;
goto out;
}
/* find the correct alt setting */
for (i = 0; i < intf->num_altsetting && altsetting == -1; i++) {
int max_packet, bulk_out_endp = -1, iso_in_endp = -1;
idesc = &intf->altsetting[i].desc;
for (j = 0; j < idesc->bNumEndpoints; j++) {
desc = &intf->altsetting[i].endpoint[j].desc;
max_packet = le16_to_cpu(desc->wMaxPacketSize);
if (usb_endpoint_dir_in(desc) && usb_endpoint_xfer_isoc(desc) && max_packet == 0x10)
iso_in_endp = j;
else if (usb_endpoint_dir_out(desc) && usb_endpoint_xfer_bulk(desc) && max_packet == 0x20)
bulk_out_endp = j;
if (bulk_out_endp != -1 && iso_in_endp != -1) {
tt->bulk_out_endp = bulk_out_endp;
tt->iso_in_endp = iso_in_endp;
altsetting = i;
break;
}
}
}
if (altsetting == -1) {
dev_err(&intf->dev, "cannot find expected altsetting\n");
ret = -ENODEV;
goto out;
}
tt->dev = &intf->dev;
tt->udev = interface_to_usbdev(intf);
tt->rc = rc;
ret = usb_set_interface(tt->udev, 0, altsetting);
if (ret) goto out;
for (i = 0; i < NUM_URBS; i++) {
struct urb *urb = usb_alloc_urb(8, GFP_KERNEL);
void *buffer;
if (!urb) {
ret = -ENOMEM;
goto out;
}
urb->dev = tt->udev;
urb->context = tt;
urb->pipe = usb_rcvisocpipe(tt->udev, tt->iso_in_endp);
urb->interval = 1;
buffer = usb_alloc_coherent(tt->udev, 128, GFP_KERNEL, &urb->transfer_dma);
if (!buffer) {
usb_free_urb(urb);
ret = -ENOMEM;
goto out;
}
urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP | URB_ISO_ASAP;
urb->transfer_buffer = buffer;
urb->complete = ttusbir_urb_complete;
urb->number_of_packets = 8;
urb->transfer_buffer_length = 128;
for (j = 0; j < 8; j++) {
urb->iso_frame_desc[j].offset = j * 16;
urb->iso_frame_desc[j].length = 16;
}
tt->urb[i] = urb;
}
tt->bulk_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!tt->bulk_urb) {
ret = -ENOMEM;
goto out;
}
tt->bulk_buffer[0] = 0xaa;
tt->bulk_buffer[1] = 0x01;
tt->bulk_buffer[2] = 0x05;
tt->bulk_buffer[3] = 0x01;
usb_fill_bulk_urb(tt->bulk_urb, tt->udev, usb_sndbulkpipe(tt->udev, tt->bulk_out_endp), tt->bulk_buffer, sizeof(tt->bulk_buffer), ttusbir_bulk_complete, tt);
tt->led.name = "ttusbir:green:power";
tt->led.default_trigger = "rc-feedback";
tt->led.brightness_set = ttusbir_brightness_set;
tt->led.brightness_get = ttusbir_brightness_get;
tt->is_led_on = tt->led_on = true;
atomic_set(&tt->led_complete, 0);
ret = led_classdev_register(&intf->dev, &tt->led);
if (ret) goto out;
usb_make_path(tt->udev, tt->phys, sizeof(tt->phys));
rc->input_name = DRIVER_DESC;
rc->input_phys = tt->phys;
usb_to_input_id(tt->udev, &rc->input_id);
rc->dev.parent = &intf->dev;
- rc->driver_type = RC_DRIVER_IR_RAW;
rc->allowed_protocols = RC_BIT_ALL_IR_DECODER;
rc->priv = tt;
rc->driver_name = DRIVER_NAME;
rc->map_name = RC_MAP_TT_1500;
rc->min_timeout = 1;
rc->timeout = IR_DEFAULT_TIMEOUT;
rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
/*
* The precision is NS_PER_BIT, but since every 8th bit can be
* overwritten with garbage the accuracy is at best 2 * NS_PER_BIT.
*/
rc->rx_resolution = NS_PER_BIT;
ret = rc_register_device(rc);
if (ret) {
dev_err(&intf->dev, "failed to register rc device %d\n", ret);
goto out2;
}
usb_set_intfdata(intf, tt);
for (i = 0; i < NUM_URBS; i++) {
ret = usb_submit_urb(tt->urb[i], GFP_KERNEL);
if (ret) {
dev_err(tt->dev, "failed to submit urb %d\n", ret);
goto out3;
}
}
return 0;
out3:
rc_unregister_device(rc);
rc = NULL;
out2:
led_classdev_unregister(&tt->led);
out:
if (tt) {
for (i = 0; i < NUM_URBS && tt->urb[i]; i++) {
struct urb *urb = tt->urb[i];
usb_kill_urb(urb);
usb_free_coherent(tt->udev, 128, urb->transfer_buffer, urb->transfer_dma);
usb_free_urb(urb);
}
usb_kill_urb(tt->bulk_urb);
usb_free_urb(tt->bulk_urb);
kfree(tt);
}
rc_free_device(rc);
return ret;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,054 |
--- initial
+++ final
@@ -1,105 +1,104 @@
static int wbcir_probe(struct pnp_dev *device, const struct pnp_device_id *dev_id) {
struct device *dev = &device->dev;
struct wbcir_data *data;
int err;
if (!(pnp_port_len(device, 0) == EHFUNC_IOMEM_LEN && pnp_port_len(device, 1) == WAKEUP_IOMEM_LEN && pnp_port_len(device, 2) == SP_IOMEM_LEN)) {
dev_err(dev, "Invalid resources\n");
return -ENODEV;
}
data = kzalloc(sizeof(*data), GFP_KERNEL);
if (!data) {
err = -ENOMEM;
goto exit;
}
pnp_set_drvdata(device, data);
spin_lock_init(&data->spinlock);
data->ebase = pnp_port_start(device, 0);
data->wbase = pnp_port_start(device, 1);
data->sbase = pnp_port_start(device, 2);
data->irq = pnp_irq(device, 0);
if (data->wbase == 0 || data->ebase == 0 || data->sbase == 0 || data->irq == 0) {
err = -ENODEV;
dev_err(dev, "Invalid resources\n");
goto exit_free_data;
}
dev_dbg(&device->dev, "Found device (w: 0x%lX, e: 0x%lX, s: 0x%lX, i: %u)\n", data->wbase, data->ebase, data->sbase, data->irq);
data->led.name = "cir::activity";
data->led.default_trigger = "rc-feedback";
data->led.brightness_set = wbcir_led_brightness_set;
data->led.brightness_get = wbcir_led_brightness_get;
err = led_classdev_register(&device->dev, &data->led);
if (err) goto exit_free_data;
- data->dev = rc_allocate_device();
+ data->dev = rc_allocate_device(RC_DRIVER_IR_RAW);
if (!data->dev) {
err = -ENOMEM;
goto exit_unregister_led;
}
- data->dev->driver_type = RC_DRIVER_IR_RAW;
data->dev->driver_name = DRVNAME;
data->dev->input_name = WBCIR_NAME;
data->dev->input_phys = "wbcir/cir0";
data->dev->input_id.bustype = BUS_HOST;
data->dev->input_id.vendor = PCI_VENDOR_ID_WINBOND;
data->dev->input_id.product = WBCIR_ID_FAMILY;
data->dev->input_id.version = WBCIR_ID_CHIP;
data->dev->map_name = RC_MAP_RC6_MCE;
data->dev->s_idle = wbcir_idle_rx;
data->dev->s_carrier_report = wbcir_set_carrier_report;
data->dev->s_tx_mask = wbcir_txmask;
data->dev->s_tx_carrier = wbcir_txcarrier;
data->dev->tx_ir = wbcir_tx;
data->dev->priv = data;
data->dev->dev.parent = &device->dev;
data->dev->timeout = MS_TO_NS(100);
data->dev->rx_resolution = US_TO_NS(2);
data->dev->allowed_protocols = RC_BIT_ALL_IR_DECODER;
data->dev->allowed_wakeup_protocols = RC_BIT_NEC | RC_BIT_NECX | RC_BIT_NEC32 | RC_BIT_RC5 | RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE;
data->dev->wakeup_protocol = RC_TYPE_RC6_MCE;
data->dev->scancode_wakeup_filter.data = 0x800f040c;
data->dev->scancode_wakeup_filter.mask = 0xffff7fff;
data->dev->s_wakeup_filter = wbcir_set_wakeup_filter;
err = rc_register_device(data->dev);
if (err) goto exit_free_rc;
if (!request_region(data->wbase, WAKEUP_IOMEM_LEN, DRVNAME)) {
dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", data->wbase, data->wbase + WAKEUP_IOMEM_LEN - 1);
err = -EBUSY;
goto exit_unregister_device;
}
if (!request_region(data->ebase, EHFUNC_IOMEM_LEN, DRVNAME)) {
dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", data->ebase, data->ebase + EHFUNC_IOMEM_LEN - 1);
err = -EBUSY;
goto exit_release_wbase;
}
if (!request_region(data->sbase, SP_IOMEM_LEN, DRVNAME)) {
dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", data->sbase, data->sbase + SP_IOMEM_LEN - 1);
err = -EBUSY;
goto exit_release_ebase;
}
err = request_irq(data->irq, wbcir_irq_handler, 0, DRVNAME, device);
if (err) {
dev_err(dev, "Failed to claim IRQ %u\n", data->irq);
err = -EBUSY;
goto exit_release_sbase;
}
device_init_wakeup(&device->dev, 1);
wbcir_init_hw(data);
return 0;
exit_release_sbase:
release_region(data->sbase, SP_IOMEM_LEN);
exit_release_ebase:
release_region(data->ebase, EHFUNC_IOMEM_LEN);
exit_release_wbase:
release_region(data->wbase, WAKEUP_IOMEM_LEN);
exit_unregister_device:
rc_unregister_device(data->dev);
data->dev = NULL;
exit_free_rc:
rc_free_device(data->dev);
exit_unregister_led:
led_classdev_unregister(&data->led);
exit_free_data:
kfree(data);
pnp_set_drvdata(device, NULL);
exit:
return err;
}<sep>@@
expression rdev,e;
@@
- rdev = rc_allocate_device();
+ rdev = rc_allocate_device(e);
...
- rdev->driver_type = e;
<|end_of_text|>
| 9,055 |
--- initial
+++ final
@@ -1,30 +1,30 @@
void acct_collect(long exitcode, int group_dead) {
struct pacct_struct *pacct = ¤t->signal->pacct;
cputime_t utime, stime;
unsigned long vsize = 0;
if (group_dead && current->mm) {
struct vm_area_struct *vma;
down_read(¤t->mm->mmap_sem);
vma = current->mm->mmap;
while (vma) {
vsize += vma->vm_end - vma->vm_start;
vma = vma->vm_next;
}
up_read(¤t->mm->mmap_sem);
}
spin_lock_irq(¤t->sighand->siglock);
if (group_dead) pacct->ac_mem = vsize / 1024;
if (thread_group_leader(current)) {
pacct->ac_exitcode = exitcode;
if (current->flags & PF_FORKNOEXEC) pacct->ac_flag |= AFORK;
}
if (current->flags & PF_SUPERPRIV) pacct->ac_flag |= ASU;
if (current->flags & PF_DUMPCORE) pacct->ac_flag |= ACORE;
if (current->flags & PF_SIGNALED) pacct->ac_flag |= AXSIG;
- task_cputime(current, &utime, &stime);
+ task_cputime_t(current, &utime, &stime);
pacct->ac_utime += utime;
pacct->ac_stime += stime;
pacct->ac_minflt += current->min_flt;
pacct->ac_majflt += current->maj_flt;
spin_unlock_irq(¤t->sighand->siglock);
}<sep>@@
expression e1,e2,e3;
@@
- task_cputime
+ task_cputime_t
(e1,e2,e3)
<|end_of_text|>
| 9,056 |
--- initial
+++ final
@@ -1,52 +1,52 @@
static int apm_cpu_idle(struct cpuidle_device *dev, struct cpuidle_driver *drv, int index) {
static int use_apm_idle; /* = 0 */
static unsigned int last_jiffies; /* = 0 */
static unsigned int last_stime; /* = 0 */
cputime_t stime, utime;
int apm_idle_done = 0;
unsigned int jiffies_since_last_check = jiffies - last_jiffies;
unsigned int bucket;
recalc:
- task_cputime(current, &utime, &stime);
+ task_cputime_t(current, &utime, &stime);
if (jiffies_since_last_check > IDLE_CALC_LIMIT) {
use_apm_idle = 0;
} else if (jiffies_since_last_check > idle_period) {
unsigned int idle_percentage;
idle_percentage = cputime_to_jiffies(stime - last_stime);
idle_percentage *= 100;
idle_percentage /= jiffies_since_last_check;
use_apm_idle = (idle_percentage > idle_threshold);
if (apm_info.forbid_idle) use_apm_idle = 0;
}
last_jiffies = jiffies;
last_stime = stime;
bucket = IDLE_LEAKY_MAX;
while (!need_resched()) {
if (use_apm_idle) {
unsigned int t;
t = jiffies;
switch (apm_do_idle()) {
case 0:
apm_idle_done = 1;
if (t != jiffies) {
if (bucket) {
bucket = IDLE_LEAKY_MAX;
continue;
}
} else if (bucket) {
bucket--;
continue;
}
break;
case 1: apm_idle_done = 1; break;
default: /* BIOS refused */ break;
}
}
default_idle();
local_irq_disable();
jiffies_since_last_check = jiffies - last_jiffies;
if (jiffies_since_last_check > idle_period) goto recalc;
}
if (apm_idle_done) apm_do_busy();
return index;
}<sep>@@
expression e1,e2,e3;
@@
- task_cputime
+ task_cputime_t
(e1,e2,e3)
<|end_of_text|>
| 9,057 |
--- initial
+++ final
@@ -1,30 +1,30 @@
static void fill_prstatus(struct elf_prstatus *prstatus, struct task_struct *p, long signr) {
prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
prstatus->pr_sigpend = p->pending.signal.sig[0];
prstatus->pr_sighold = p->blocked.sig[0];
rcu_read_lock();
prstatus->pr_ppid = task_pid_vnr(rcu_dereference(p->real_parent));
rcu_read_unlock();
prstatus->pr_pid = task_pid_vnr(p);
prstatus->pr_pgrp = task_pgrp_vnr(p);
prstatus->pr_sid = task_session_vnr(p);
if (thread_group_leader(p)) {
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
/*
* This is the record for the group leader. It shows the
* group-wide total, not its individual thread total.
*/
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
cputime_to_timeval(cputime.utime, &prstatus->pr_utime);
cputime_to_timeval(cputime.stime, &prstatus->pr_stime);
} else {
cputime_t utime, stime;
- task_cputime(p, &utime, &stime);
+ task_cputime_t(p, &utime, &stime);
cputime_to_timeval(utime, &prstatus->pr_utime);
cputime_to_timeval(stime, &prstatus->pr_stime);
}
cputime_to_timeval(p->signal->cutime, &prstatus->pr_cutime);
cputime_to_timeval(p->signal->cstime, &prstatus->pr_cstime);
prstatus->pr_exec_fdpic_loadmap = p->mm->context.exec_fdpic_loadmap;
prstatus->pr_interp_fdpic_loadmap = p->mm->context.interp_fdpic_loadmap;
}<sep>@@
expression e1,e2,e3;
@@
- task_cputime
+ task_cputime_t
(e1,e2,e3)
@@
identifier cputime;
expression p;
@@
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
<...
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
...>
<|end_of_text|>
| 9,058 |
--- initial
+++ final
@@ -1,28 +1,28 @@
static void fill_prstatus(struct elf_prstatus *prstatus, struct task_struct *p, long signr) {
prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
prstatus->pr_sigpend = p->pending.signal.sig[0];
prstatus->pr_sighold = p->blocked.sig[0];
rcu_read_lock();
prstatus->pr_ppid = task_pid_vnr(rcu_dereference(p->real_parent));
rcu_read_unlock();
prstatus->pr_pid = task_pid_vnr(p);
prstatus->pr_pgrp = task_pgrp_vnr(p);
prstatus->pr_sid = task_session_vnr(p);
if (thread_group_leader(p)) {
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
/*
* This is the record for the group leader. It shows the
* group-wide total, not its individual thread total.
*/
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
cputime_to_timeval(cputime.utime, &prstatus->pr_utime);
cputime_to_timeval(cputime.stime, &prstatus->pr_stime);
} else {
cputime_t utime, stime;
- task_cputime(p, &utime, &stime);
+ task_cputime_t(p, &utime, &stime);
cputime_to_timeval(utime, &prstatus->pr_utime);
cputime_to_timeval(stime, &prstatus->pr_stime);
}
cputime_to_timeval(p->signal->cutime, &prstatus->pr_cutime);
cputime_to_timeval(p->signal->cstime, &prstatus->pr_cstime);
}<sep>@@
expression e1,e2,e3;
@@
- task_cputime
+ task_cputime_t
(e1,e2,e3)
@@
identifier cputime;
expression p;
@@
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
<...
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
...>
<|end_of_text|>
| 9,059 |
--- initial
+++ final
@@ -1,39 +1,39 @@
int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk) {
cputime_t utime, stime, stimescaled, utimescaled;
unsigned long long t2, t3;
unsigned long flags, t1;
s64 tmp;
- task_cputime(tsk, &utime, &stime);
+ task_cputime_t(tsk, &utime, &stime);
tmp = (s64)d->cpu_run_real_total;
tmp += cputime_to_nsecs(utime + stime);
d->cpu_run_real_total = (tmp < (s64)d->cpu_run_real_total) ? 0 : tmp;
- task_cputime_scaled(tsk, &utimescaled, &stimescaled);
+ task_cputime_t_scaled(tsk, &utimescaled, &stimescaled);
tmp = (s64)d->cpu_scaled_run_real_total;
tmp += cputime_to_nsecs(utimescaled + stimescaled);
d->cpu_scaled_run_real_total = (tmp < (s64)d->cpu_scaled_run_real_total) ? 0 : tmp;
/*
* No locking available for sched_info (and too expensive to add one)
* Mitigate by taking snapshot of values
*/
t1 = tsk->sched_info.pcount;
t2 = tsk->sched_info.run_delay;
t3 = tsk->se.sum_exec_runtime;
d->cpu_count += t1;
tmp = (s64)d->cpu_delay_total + t2;
d->cpu_delay_total = (tmp < (s64)d->cpu_delay_total) ? 0 : tmp;
tmp = (s64)d->cpu_run_virtual_total + t3;
d->cpu_run_virtual_total = (tmp < (s64)d->cpu_run_virtual_total) ? 0 : tmp;
/* zero XXX_total, non-zero XXX_count implies XXX stat overflowed */
spin_lock_irqsave(&tsk->delays->lock, flags);
tmp = d->blkio_delay_total + tsk->delays->blkio_delay;
d->blkio_delay_total = (tmp < d->blkio_delay_total) ? 0 : tmp;
tmp = d->swapin_delay_total + tsk->delays->swapin_delay;
d->swapin_delay_total = (tmp < d->swapin_delay_total) ? 0 : tmp;
tmp = d->freepages_delay_total + tsk->delays->freepages_delay;
d->freepages_delay_total = (tmp < d->freepages_delay_total) ? 0 : tmp;
d->blkio_count += tsk->delays->blkio_count;
d->swapin_count += tsk->delays->swapin_count;
d->freepages_count += tsk->delays->freepages_count;
spin_unlock_irqrestore(&tsk->delays->lock, flags);
return 0;
}<sep>@@
expression e1,e2,e3;
@@
- task_cputime
+ task_cputime_t
(e1,e2,e3)
@@
expression e1,e2,e3;
@@
- task_cputime_scaled
+ task_cputime_t_scaled
(e1,e2,e3)
<|end_of_text|>
| 9,060 |
--- initial
+++ final
@@ -1,24 +1,24 @@
static void get_cpu_itimer(struct task_struct *tsk, unsigned int clock_id, struct itimerval *const value) {
cputime_t cval, cinterval;
struct cpu_itimer *it = &tsk->signal->it[clock_id];
spin_lock_irq(&tsk->sighand->siglock);
cval = it->expires;
cinterval = it->incr;
if (cval) {
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
cputime_t t;
thread_group_cputimer(tsk, &cputime);
if (clock_id == CPUCLOCK_PROF)
t = cputime.utime + cputime.stime;
else
/* CPUCLOCK_VIRT */
t = cputime.utime;
if (cval < t) /* about to fire */
cval = cputime_one_jiffy;
else
cval = cval - t;
}
spin_unlock_irq(&tsk->sighand->siglock);
cputime_to_timeval(cval, &value->it_value);
cputime_to_timeval(cinterval, &value->it_interval);
}<sep>@@
identifier cputime;
expression p;
@@
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
<...
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
...>
<|end_of_text|>
| 9,061 |
--- initial
+++ final
@@ -1,45 +1,45 @@
static void arm_timer(struct k_itimer *timer) {
struct task_struct *p = timer->it.cpu.task;
struct list_head *head, *listpos;
- struct task_cputime *cputime_expires;
+ struct task_cputime_t *cputime_expires;
struct cpu_timer_list *const nt = &timer->it.cpu;
struct cpu_timer_list *next;
if (CPUCLOCK_PERTHREAD(timer->it_clock)) {
head = p->cpu_timers;
cputime_expires = &p->cputime_expires;
} else {
head = p->signal->cpu_timers;
cputime_expires = &p->signal->cputime_expires;
}
head += CPUCLOCK_WHICH(timer->it_clock);
listpos = head;
list_for_each_entry(next, head, entry) {
if (nt->expires < next->expires) break;
listpos = &next->entry;
}
list_add(&nt->entry, listpos);
if (listpos == head) {
unsigned long long exp = nt->expires;
/*
* We are the new earliest-expiring POSIX 1.b timer, hence
* need to update expiration cache. Take into account that
* for process timers we share expiration cache with itimers
* and RLIMIT_CPU and for thread timers with RLIMIT_RTTIME.
*/
switch (CPUCLOCK_WHICH(timer->it_clock)) {
case CPUCLOCK_PROF:
if (expires_gt(cputime_expires->prof_exp, expires_to_cputime(exp))) cputime_expires->prof_exp = expires_to_cputime(exp);
break;
case CPUCLOCK_VIRT:
if (expires_gt(cputime_expires->virt_exp, expires_to_cputime(exp))) cputime_expires->virt_exp = expires_to_cputime(exp);
break;
case CPUCLOCK_SCHED:
if (cputime_expires->sched_exp == 0 || cputime_expires->sched_exp > exp) cputime_expires->sched_exp = exp;
break;
}
if (CPUCLOCK_PERTHREAD(timer->it_clock))
tick_dep_set_task(p, TICK_DEP_BIT_POSIX_TIMER);
else
tick_dep_set_signal(p->signal, TICK_DEP_BIT_POSIX_TIMER);
}
}<sep>@@
identifier cputime;
expression p;
@@
- struct task_cputime *cputime;
+ struct task_cputime_t *cputime;
<...
- thread_group_cputime(p, cputime);
+ thread_group_cputime_t(p, cputime);
...>
<|end_of_text|>
| 9,062 |
--- initial
+++ final
@@ -1,64 +1,64 @@
static void check_process_timers(struct task_struct *tsk, struct list_head *firing) {
struct signal_struct *const sig = tsk->signal;
unsigned long long utime, ptime, virt_expires, prof_expires;
unsigned long long sum_sched_runtime, sched_expires;
struct list_head *timers = sig->cpu_timers;
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
unsigned long soft;
/*
* If cputimer is not running, then there are no active
* process wide timers (POSIX 1.b, itimers, RLIMIT_CPU).
*/
if (!READ_ONCE(tsk->signal->cputimer.running)) return;
/*
* Signify that a thread is checking for process timers.
* Write access to this field is protected by the sighand lock.
*/
sig->cputimer.checking_timer = true;
/*
* Collect the current process totals.
*/
thread_group_cputimer(tsk, &cputime);
utime = cputime_to_expires(cputime.utime);
ptime = utime + cputime_to_expires(cputime.stime);
sum_sched_runtime = cputime.sum_exec_runtime;
prof_expires = check_timers_list(timers, firing, ptime);
virt_expires = check_timers_list(++timers, firing, utime);
sched_expires = check_timers_list(++timers, firing, sum_sched_runtime);
/*
* Check for the special case process timers.
*/
check_cpu_itimer(tsk, &sig->it[CPUCLOCK_PROF], &prof_expires, ptime, SIGPROF);
check_cpu_itimer(tsk, &sig->it[CPUCLOCK_VIRT], &virt_expires, utime, SIGVTALRM);
soft = READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur);
if (soft != RLIM_INFINITY) {
unsigned long psecs = cputime_to_secs(ptime);
unsigned long hard = READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_max);
cputime_t x;
if (psecs >= hard) {
/*
* At the hard limit, we just die.
* No need to calculate anything else now.
*/
__group_send_sig_info(SIGKILL, SEND_SIG_PRIV, tsk);
return;
}
if (psecs >= soft) {
/*
* At the soft limit, send a SIGXCPU every second.
*/
__group_send_sig_info(SIGXCPU, SEND_SIG_PRIV, tsk);
if (soft < hard) {
soft++;
sig->rlim[RLIMIT_CPU].rlim_cur = soft;
}
}
x = secs_to_cputime(soft);
if (!prof_expires || x < prof_expires) { prof_expires = x; }
}
sig->cputime_expires.prof_exp = expires_to_cputime(prof_expires);
sig->cputime_expires.virt_exp = expires_to_cputime(virt_expires);
sig->cputime_expires.sched_exp = sched_expires;
if (task_cputime_zero(&sig->cputime_expires)) stop_process_timers(sig);
sig->cputimer.checking_timer = false;
}<sep>@@
identifier cputime;
expression p;
@@
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
<...
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
...>
<|end_of_text|>
| 9,063 |
--- initial
+++ final
@@ -1,19 +1,19 @@
static int cpu_clock_sample_group(const clockid_t which_clock, struct task_struct *p, unsigned long long *sample) {
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
switch (CPUCLOCK_WHICH(which_clock)) {
default: return -EINVAL;
case CPUCLOCK_PROF:
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
*sample = cputime_to_expires(cputime.utime + cputime.stime);
break;
case CPUCLOCK_VIRT:
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
*sample = cputime_to_expires(cputime.utime);
break;
case CPUCLOCK_SCHED:
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
*sample = cputime.sum_exec_runtime;
break;
}
return 0;
}<sep>@@
identifier cputime;
expression p;
@@
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
<...
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
...>
<|end_of_text|>
| 9,064 |
--- initial
+++ final
@@ -1,11 +1,11 @@
static int cpu_timer_sample_group(const clockid_t which_clock, struct task_struct *p, unsigned long long *sample) {
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
thread_group_cputimer(p, &cputime);
switch (CPUCLOCK_WHICH(which_clock)) {
default: return -EINVAL;
case CPUCLOCK_PROF: *sample = cputime_to_expires(cputime.utime + cputime.stime); break;
case CPUCLOCK_VIRT: *sample = cputime_to_expires(cputime.utime); break;
case CPUCLOCK_SCHED: *sample = cputime.sum_exec_runtime; break;
}
return 0;
}<sep>@@
identifier cputime;
expression p;
@@
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
<...
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
...>
<|end_of_text|>
| 9,065 |
--- initial
+++ final
@@ -1,30 +1,30 @@
static inline int fastpath_timer_check(struct task_struct *tsk) {
struct signal_struct *sig;
if (!task_cputime_zero(&tsk->cputime_expires)) {
- struct task_cputime task_sample;
- task_cputime(tsk, &task_sample.utime, &task_sample.stime);
+ struct task_cputime_t task_sample;
+ task_cputime_t(tsk, &task_sample.utime, &task_sample.stime);
task_sample.sum_exec_runtime = tsk->se.sum_exec_runtime;
if (task_cputime_expired(&task_sample, &tsk->cputime_expires)) return 1;
}
sig = tsk->signal;
/*
* Check if thread group timers expired when the cputimer is
* running and no other thread in the group is already checking
* for thread group cputimers. These fields are read without the
* sighand lock. However, this is fine because this is meant to
* be a fastpath heuristic to determine whether we should try to
* acquire the sighand lock to check/handle timers.
*
* In the worst case scenario, if 'running' or 'checking_timer' gets
* set but the current thread doesn't see the change yet, we'll wait
* until the next thread in the group gets a scheduler interrupt to
* handle the timer. This isn't an issue in practice because these
* types of delays with signals actually getting sent are expected.
*/
if (READ_ONCE(sig->cputimer.running) && !READ_ONCE(sig->cputimer.checking_timer)) {
- struct task_cputime group_sample;
+ struct task_cputime_t group_sample;
sample_cputime_atomic(&group_sample, &sig->cputimer.cputime_atomic);
if (task_cputime_expired(&group_sample, &sig->cputime_expires)) return 1;
}
return 0;
}<sep>@@
expression e1,e2,e3;
@@
- task_cputime
+ task_cputime_t
(e1,e2,e3)
@@
identifier cputime;
expression p;
@@
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
<...
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
...>
<|end_of_text|>
| 9,066 |
--- initial
+++ final
@@ -1,5 +1,5 @@
static inline unsigned long long prof_ticks(struct task_struct *p) {
cputime_t utime, stime;
- task_cputime(p, &utime, &stime);
+ task_cputime_t(p, &utime, &stime);
return cputime_to_expires(utime + stime);
}<sep>@@
expression e1,e2,e3;
@@
- task_cputime
+ task_cputime_t
(e1,e2,e3)
<|end_of_text|>
| 9,067 |
--- initial
+++ final
@@ -1,5 +1,5 @@
-static inline void sample_cputime_atomic(struct task_cputime *times, struct task_cputime_atomic *atomic_times) {
+static inline void sample_cputime_atomic(struct task_cputime_t *times, struct task_cputime_atomic *atomic_times) {
times->utime = atomic64_read(&atomic_times->utime);
times->stime = atomic64_read(&atomic_times->stime);
times->sum_exec_runtime = atomic64_read(&atomic_times->sum_exec_runtime);
}<sep>@@
identifier cputime,f;
expression p;
@@
f(...,
- struct task_cputime *cputime
+ struct task_cputime_t *cputime
,...) {
<...
- thread_group_cputime(p, cputime);
+ thread_group_cputime_t(p, cputime);
...>
}<|end_of_text|>
| 9,068 |
--- initial
+++ final
@@ -1,6 +1,6 @@
-static inline int task_cputime_expired(const struct task_cputime *sample, const struct task_cputime *expires) {
+static inline int task_cputime_expired(const struct task_cputime_t *sample, const struct task_cputime_t *expires) {
if (expires->utime && sample->utime >= expires->utime) return 1;
if (expires->stime && sample->utime + sample->stime >= expires->stime) return 1;
if (expires->sum_exec_runtime != 0 && sample->sum_exec_runtime >= expires->sum_exec_runtime) return 1;
return 0;
}<sep>@@
identifier cputime,f;
expression p;
@@
f(...,
- struct task_cputime *cputime
+ struct task_cputime_t *cputime
,...) {
<...
- thread_group_cputime(p, cputime);
+ thread_group_cputime_t(p, cputime);
...>
}<|end_of_text|>
| 9,069 |
--- initial
+++ final
@@ -1,4 +1,4 @@
-static inline int task_cputime_zero(const struct task_cputime *cputime) {
+static inline int task_cputime_zero(const struct task_cputime_t *cputime) {
if (!cputime->utime && !cputime->stime && !cputime->sum_exec_runtime) return 1;
return 0;
}<sep>@@
identifier cputime,f;
expression p;
@@
f(...,
- struct task_cputime *cputime
+ struct task_cputime_t *cputime
,...) {
<...
- thread_group_cputime(p, cputime);
+ thread_group_cputime_t(p, cputime);
...>
}<|end_of_text|>
| 9,070 |
--- initial
+++ final
@@ -1,23 +1,23 @@
-void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times) {
+void thread_group_cputimer(struct task_struct *tsk, struct task_cputime_t *times) {
struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
- struct task_cputime sum;
+ struct task_cputime_t sum;
/* Check if cputimer isn't running. This is accessed without locking. */
if (!READ_ONCE(cputimer->running)) {
/*
* The POSIX timer interface allows for absolute time expiry
* values through the TIMER_ABSTIME flag, therefore we have
* to synchronize the timer to the clock every time we start it.
*/
- thread_group_cputime(tsk, &sum);
+ thread_group_cputime_t(tsk, &sum);
update_gt_cputime(&cputimer->cputime_atomic, &sum);
/*
* We're setting cputimer->running without a lock. Ensure
* this only gets written to in one operation. We set
* running after update_gt_cputime() as a small optimization,
* but barriers are not required because update_gt_cputime()
* can handle concurrent updates.
*/
WRITE_ONCE(cputimer->running, true);
}
sample_cputime_atomic(times, &cputimer->cputime_atomic);
}<sep>@@
identifier cputime;
expression p;
@@
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
<...
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
...>
@@
identifier cputime,f;
expression p;
@@
f(...,
- struct task_cputime *cputime
+ struct task_cputime_t *cputime
,...) {
<...
- thread_group_cputime(p, cputime);
+ thread_group_cputime_t(p, cputime);
...>
}<|end_of_text|>
| 9,071 |
--- initial
+++ final
@@ -1,5 +1,5 @@
-static void update_gt_cputime(struct task_cputime_atomic *cputime_atomic, struct task_cputime *sum) {
+static void update_gt_cputime(struct task_cputime_atomic *cputime_atomic, struct task_cputime_t *sum) {
__update_gt_cputime(&cputime_atomic->utime, sum->utime);
__update_gt_cputime(&cputime_atomic->stime, sum->stime);
__update_gt_cputime(&cputime_atomic->sum_exec_runtime, sum->sum_exec_runtime);
}<sep>@@
identifier cputime,f;
expression p;
@@
f(...,
- struct task_cputime *cputime
+ struct task_cputime_t *cputime
,...) {
<...
- thread_group_cputime(p, cputime);
+ thread_group_cputime_t(p, cputime);
...>
}<|end_of_text|>
| 9,072 |
--- initial
+++ final
@@ -1,5 +1,5 @@
static inline unsigned long long virt_ticks(struct task_struct *p) {
cputime_t utime, stime;
- task_cputime(p, &utime, &stime);
+ task_cputime_t(p, &utime, &stime);
return cputime_to_expires(utime);
}<sep>@@
expression e1,e2,e3;
@@
- task_cputime
+ task_cputime_t
(e1,e2,e3)
<|end_of_text|>
| 9,073 |
--- initial
+++ final
@@ -1,72 +1,72 @@
bool do_notify_parent(struct task_struct *tsk, int sig) {
struct siginfo info;
unsigned long flags;
struct sighand_struct *psig;
bool autoreap = false;
cputime_t utime, stime;
BUG_ON(sig == -1);
/* do_notify_parent_cldstop should have been called instead. */
BUG_ON(task_is_stopped_or_traced(tsk));
BUG_ON(!tsk->ptrace && (tsk->group_leader != tsk || !thread_group_empty(tsk)));
if (sig != SIGCHLD) {
/*
* This is only possible if parent == real_parent.
* Check if it has changed security domain.
*/
if (tsk->parent_exec_id != tsk->parent->self_exec_id) sig = SIGCHLD;
}
info.si_signo = sig;
info.si_errno = 0;
/*
* We are under tasklist_lock here so our parent is tied to
* us and cannot change.
*
* task_active_pid_ns will always return the same pid namespace
* until a task passes through release_task.
*
* write_lock() currently calls preempt_disable() which is the
* same as rcu_read_lock(), but according to Oleg, this is not
* correct to rely on this
*/
rcu_read_lock();
info.si_pid = task_pid_nr_ns(tsk, task_active_pid_ns(tsk->parent));
info.si_uid = from_kuid_munged(task_cred_xxx(tsk->parent, user_ns), task_uid(tsk));
rcu_read_unlock();
- task_cputime(tsk, &utime, &stime);
+ task_cputime_t(tsk, &utime, &stime);
info.si_utime = cputime_to_clock_t(utime + tsk->signal->utime);
info.si_stime = cputime_to_clock_t(stime + tsk->signal->stime);
info.si_status = tsk->exit_code & 0x7f;
if (tsk->exit_code & 0x80)
info.si_code = CLD_DUMPED;
else if (tsk->exit_code & 0x7f)
info.si_code = CLD_KILLED;
else {
info.si_code = CLD_EXITED;
info.si_status = tsk->exit_code >> 8;
}
psig = tsk->parent->sighand;
spin_lock_irqsave(&psig->siglock, flags);
if (!tsk->ptrace && sig == SIGCHLD && (psig->action[SIGCHLD - 1].sa.sa_handler == SIG_IGN || (psig->action[SIGCHLD - 1].sa.sa_flags & SA_NOCLDWAIT))) {
/*
* We are exiting and our parent doesn't care. POSIX.1
* defines special semantics for setting SIGCHLD to SIG_IGN
* or setting the SA_NOCLDWAIT flag: we should be reaped
* automatically and not left for our parent's wait4 call.
* Rather than having the parent do it as a magic kind of
* signal handler, we just set this to tell do_exit that we
* can be cleaned up without becoming a zombie. Note that
* we still call __wake_up_parent in this case, because a
* blocked sys_wait4 might now return -ECHILD.
*
* Whether we send SIGCHLD or not for SA_NOCLDWAIT
* is implementation-defined: we do (if you don't want
* it, just use SIG_IGN instead).
*/
autoreap = true;
if (psig->action[SIGCHLD - 1].sa.sa_handler == SIG_IGN) sig = 0;
}
if (valid_signal(sig) && sig) __group_send_sig_info(sig, &info, tsk->parent);
__wake_up_parent(tsk, tsk->parent);
spin_unlock_irqrestore(&psig->siglock, flags);
return autoreap;
}<sep>@@
expression e1,e2,e3;
@@
- task_cputime
+ task_cputime_t
(e1,e2,e3)
<|end_of_text|>
| 9,074 |
--- initial
+++ final
@@ -1,40 +1,40 @@
static void do_notify_parent_cldstop(struct task_struct *tsk, bool for_ptracer, int why) {
struct siginfo info;
unsigned long flags;
struct task_struct *parent;
struct sighand_struct *sighand;
cputime_t utime, stime;
if (for_ptracer) {
parent = tsk->parent;
} else {
tsk = tsk->group_leader;
parent = tsk->real_parent;
}
info.si_signo = SIGCHLD;
info.si_errno = 0;
/*
* see comment in do_notify_parent() about the following 4 lines
*/
rcu_read_lock();
info.si_pid = task_pid_nr_ns(tsk, task_active_pid_ns(parent));
info.si_uid = from_kuid_munged(task_cred_xxx(parent, user_ns), task_uid(tsk));
rcu_read_unlock();
- task_cputime(tsk, &utime, &stime);
+ task_cputime_t(tsk, &utime, &stime);
info.si_utime = cputime_to_clock_t(utime);
info.si_stime = cputime_to_clock_t(stime);
info.si_code = why;
switch (why) {
case CLD_CONTINUED: info.si_status = SIGCONT; break;
case CLD_STOPPED: info.si_status = tsk->signal->group_exit_code & 0x7f; break;
case CLD_TRAPPED: info.si_status = tsk->exit_code & 0x7f; break;
default: BUG();
}
sighand = parent->sighand;
spin_lock_irqsave(&sighand->siglock, flags);
if (sighand->action[SIGCHLD - 1].sa.sa_handler != SIG_IGN && !(sighand->action[SIGCHLD - 1].sa.sa_flags & SA_NOCLDSTOP)) __group_send_sig_info(SIGCHLD, &info, parent);
/*
* Even if SIGCHLD is not generated, we must wake up wait4 calls.
*/
__wake_up_parent(tsk, parent);
spin_unlock_irqrestore(&sighand->siglock, flags);
}<sep>@@
expression e1,e2,e3;
@@
- task_cputime
+ task_cputime_t
(e1,e2,e3)
<|end_of_text|>
| 9,075 |
--- initial
+++ final
@@ -1,99 +1,99 @@
static int mISDNStackd(void *data) {
struct mISDNstack *st = data;
#ifdef MISDN_MSG_STATS
cputime_t utime, stime;
#endif
int err = 0;
sigfillset(¤t->blocked);
if (*debug & DEBUG_MSG_THREAD) printk(KERN_DEBUG "mISDNStackd %s started\n", dev_name(&st->dev->dev));
if (st->notify != NULL) {
complete(st->notify);
st->notify = NULL;
}
for (;;) {
struct sk_buff *skb;
if (unlikely(test_bit(mISDN_STACK_STOPPED, &st->status))) {
test_and_clear_bit(mISDN_STACK_WORK, &st->status);
test_and_clear_bit(mISDN_STACK_RUNNING, &st->status);
} else
test_and_set_bit(mISDN_STACK_RUNNING, &st->status);
while (test_bit(mISDN_STACK_WORK, &st->status)) {
skb = skb_dequeue(&st->msgq);
if (!skb) {
test_and_clear_bit(mISDN_STACK_WORK, &st->status);
/* test if a race happens */
skb = skb_dequeue(&st->msgq);
if (!skb) continue;
test_and_set_bit(mISDN_STACK_WORK, &st->status);
}
#ifdef MISDN_MSG_STATS
st->msg_cnt++;
#endif
err = send_msg_to_layer(st, skb);
if (unlikely(err)) {
if (*debug & DEBUG_SEND_ERR)
printk(KERN_DEBUG "%s: %s prim(%x) id(%x) "
"send call(%d)\n",
__func__, dev_name(&st->dev->dev), mISDN_HEAD_PRIM(skb), mISDN_HEAD_ID(skb), err);
dev_kfree_skb(skb);
continue;
}
if (unlikely(test_bit(mISDN_STACK_STOPPED, &st->status))) {
test_and_clear_bit(mISDN_STACK_WORK, &st->status);
test_and_clear_bit(mISDN_STACK_RUNNING, &st->status);
break;
}
}
if (test_bit(mISDN_STACK_CLEARING, &st->status)) {
test_and_set_bit(mISDN_STACK_STOPPED, &st->status);
test_and_clear_bit(mISDN_STACK_RUNNING, &st->status);
do_clear_stack(st);
test_and_clear_bit(mISDN_STACK_CLEARING, &st->status);
test_and_set_bit(mISDN_STACK_RESTART, &st->status);
}
if (test_and_clear_bit(mISDN_STACK_RESTART, &st->status)) {
test_and_clear_bit(mISDN_STACK_STOPPED, &st->status);
test_and_set_bit(mISDN_STACK_RUNNING, &st->status);
if (!skb_queue_empty(&st->msgq)) test_and_set_bit(mISDN_STACK_WORK, &st->status);
}
if (test_bit(mISDN_STACK_ABORT, &st->status)) break;
if (st->notify != NULL) {
complete(st->notify);
st->notify = NULL;
}
#ifdef MISDN_MSG_STATS
st->sleep_cnt++;
#endif
test_and_clear_bit(mISDN_STACK_ACTIVE, &st->status);
wait_event_interruptible(st->workq, (st->status & mISDN_STACK_ACTION_MASK));
if (*debug & DEBUG_MSG_THREAD) printk(KERN_DEBUG "%s: %s wake status %08lx\n", __func__, dev_name(&st->dev->dev), st->status);
test_and_set_bit(mISDN_STACK_ACTIVE, &st->status);
test_and_clear_bit(mISDN_STACK_WAKEUP, &st->status);
if (test_bit(mISDN_STACK_STOPPED, &st->status)) {
test_and_clear_bit(mISDN_STACK_RUNNING, &st->status);
#ifdef MISDN_MSG_STATS
st->stopped_cnt++;
#endif
}
}
#ifdef MISDN_MSG_STATS
printk(KERN_DEBUG "mISDNStackd daemon for %s proceed %d "
"msg %d sleep %d stopped\n",
dev_name(&st->dev->dev), st->msg_cnt, st->sleep_cnt, st->stopped_cnt);
- task_cputime(st->thread, &utime, &stime);
+ task_cputime_t(st->thread, &utime, &stime);
printk(KERN_DEBUG "mISDNStackd daemon for %s utime(%ld) stime(%ld)\n", dev_name(&st->dev->dev), utime, stime);
printk(KERN_DEBUG "mISDNStackd daemon for %s nvcsw(%ld) nivcsw(%ld)\n", dev_name(&st->dev->dev), st->thread->nvcsw, st->thread->nivcsw);
printk(KERN_DEBUG "mISDNStackd daemon for %s killed now\n", dev_name(&st->dev->dev));
#endif
test_and_set_bit(mISDN_STACK_KILLED, &st->status);
test_and_clear_bit(mISDN_STACK_RUNNING, &st->status);
test_and_clear_bit(mISDN_STACK_ACTIVE, &st->status);
test_and_clear_bit(mISDN_STACK_ABORT, &st->status);
skb_queue_purge(&st->msgq);
st->thread = NULL;
if (st->notify != NULL) {
complete(st->notify);
st->notify = NULL;
}
return 0;
}<sep>@@
expression e1,e2,e3;
@@
- task_cputime
+ task_cputime_t
(e1,e2,e3)
<|end_of_text|>
| 9,076 |
--- initial
+++ final
@@ -1,8 +1,8 @@
void acct_update_integrals(struct task_struct *tsk) {
cputime_t utime, stime;
unsigned long flags;
local_irq_save(flags);
- task_cputime(tsk, &utime, &stime);
+ task_cputime_t(tsk, &utime, &stime);
__acct_update_integrals(tsk, utime, stime);
local_irq_restore(flags);
}<sep>@@
expression e1,e2,e3;
@@
- task_cputime
+ task_cputime_t
(e1,e2,e3)
<|end_of_text|>
| 9,077 |
--- initial
+++ final
@@ -1,39 +1,39 @@
void bacct_add_tsk(struct user_namespace *user_ns, struct pid_namespace *pid_ns, struct taskstats *stats, struct task_struct *tsk) {
const struct cred *tcred;
cputime_t utime, stime, utimescaled, stimescaled;
u64 delta;
BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN);
/* calculate task elapsed time in nsec */
delta = ktime_get_ns() - tsk->start_time;
/* Convert to micro seconds */
do_div(delta, NSEC_PER_USEC);
stats->ac_etime = delta;
/* Convert to seconds for btime */
do_div(delta, USEC_PER_SEC);
stats->ac_btime = get_seconds() - delta;
if (thread_group_leader(tsk)) {
stats->ac_exitcode = tsk->exit_code;
if (tsk->flags & PF_FORKNOEXEC) stats->ac_flag |= AFORK;
}
if (tsk->flags & PF_SUPERPRIV) stats->ac_flag |= ASU;
if (tsk->flags & PF_DUMPCORE) stats->ac_flag |= ACORE;
if (tsk->flags & PF_SIGNALED) stats->ac_flag |= AXSIG;
stats->ac_nice = task_nice(tsk);
stats->ac_sched = tsk->policy;
stats->ac_pid = task_pid_nr_ns(tsk, pid_ns);
rcu_read_lock();
tcred = __task_cred(tsk);
stats->ac_uid = from_kuid_munged(user_ns, tcred->uid);
stats->ac_gid = from_kgid_munged(user_ns, tcred->gid);
stats->ac_ppid = pid_alive(tsk) ? task_tgid_nr_ns(rcu_dereference(tsk->real_parent), pid_ns) : 0;
rcu_read_unlock();
- task_cputime(tsk, &utime, &stime);
+ task_cputime_t(tsk, &utime, &stime);
stats->ac_utime = cputime_to_usecs(utime);
stats->ac_stime = cputime_to_usecs(stime);
- task_cputime_scaled(tsk, &utimescaled, &stimescaled);
+ task_cputime_t_scaled(tsk, &utimescaled, &stimescaled);
stats->ac_utimescaled = cputime_to_usecs(utimescaled);
stats->ac_stimescaled = cputime_to_usecs(stimescaled);
stats->ac_minflt = tsk->min_flt;
stats->ac_majflt = tsk->maj_flt;
strncpy(stats->ac_comm, tsk->comm, sizeof(stats->ac_comm));
}<sep>@@
expression e1,e2,e3;
@@
- task_cputime
+ task_cputime_t
(e1,e2,e3)
@@
expression e1,e2,e3;
@@
- task_cputime_scaled
+ task_cputime_t_scaled
(e1,e2,e3)
<|end_of_text|>
| 9,078 |
--- initial
+++ final
@@ -1,148 +1,148 @@
int hfi1_get_proc_affinity(int node) {
int cpu = -1, ret, i;
struct hfi1_affinity_node *entry;
cpumask_var_t diff, hw_thread_mask, available_mask, intrs_mask;
- const struct cpumask *node_mask, *proc_mask = tsk_cpus_allowed(current);
+ const struct cpumask *node_mask, *proc_mask = ¤t->cpus_allowed;
struct hfi1_affinity_node_list *affinity = &node_affinity;
struct cpu_mask_set *set = &affinity->proc;
/*
* check whether process/context affinity has already
* been set
*/
if (cpumask_weight(proc_mask) == 1) {
hfi1_cdbg(PROC, "PID %u %s affinity set to CPU %*pbl", current->pid, current->comm, cpumask_pr_args(proc_mask));
/*
* Mark the pre-set CPU as used. This is atomic so we don't
* need the lock
*/
cpu = cpumask_first(proc_mask);
cpumask_set_cpu(cpu, &set->used);
goto done;
} else if (cpumask_weight(proc_mask) < cpumask_weight(&set->mask)) {
hfi1_cdbg(PROC, "PID %u %s affinity set to CPU set(s) %*pbl", current->pid, current->comm, cpumask_pr_args(proc_mask));
goto done;
}
/*
* The process does not have a preset CPU affinity so find one to
* recommend using the following algorithm:
*
* For each user process that is opening a context on HFI Y:
* a) If all cores are filled, reinitialize the bitmask
* b) Fill real cores first, then HT cores (First set of HT
* cores on all physical cores, then second set of HT core,
* and, so on) in the following order:
*
* 1. Same NUMA node as HFI Y and not running an IRQ
* handler
* 2. Same NUMA node as HFI Y and running an IRQ handler
* 3. Different NUMA node to HFI Y and not running an IRQ
* handler
* 4. Different NUMA node to HFI Y and running an IRQ
* handler
* c) Mark core as filled in the bitmask. As user processes are
* done, clear cores from the bitmask.
*/
ret = zalloc_cpumask_var(&diff, GFP_KERNEL);
if (!ret) goto done;
ret = zalloc_cpumask_var(&hw_thread_mask, GFP_KERNEL);
if (!ret) goto free_diff;
ret = zalloc_cpumask_var(&available_mask, GFP_KERNEL);
if (!ret) goto free_hw_thread_mask;
ret = zalloc_cpumask_var(&intrs_mask, GFP_KERNEL);
if (!ret) goto free_available_mask;
mutex_lock(&affinity->lock);
/*
* If we've used all available HW threads, clear the mask and start
* overloading.
*/
if (cpumask_equal(&set->mask, &set->used)) {
set->gen++;
cpumask_clear(&set->used);
}
/*
* If NUMA node has CPUs used by interrupt handlers, include them in the
* interrupt handler mask.
*/
entry = node_affinity_lookup(node);
if (entry) {
cpumask_copy(intrs_mask, (entry->def_intr.gen ? &entry->def_intr.mask : &entry->def_intr.used));
cpumask_or(intrs_mask, intrs_mask, (entry->rcv_intr.gen ? &entry->rcv_intr.mask : &entry->rcv_intr.used));
cpumask_or(intrs_mask, intrs_mask, &entry->general_intr_mask);
}
hfi1_cdbg(PROC, "CPUs used by interrupts: %*pbl", cpumask_pr_args(intrs_mask));
cpumask_copy(hw_thread_mask, &set->mask);
/*
* If HT cores are enabled, identify which HW threads within the
* physical cores should be used.
*/
if (affinity->num_core_siblings > 0) {
for (i = 0; i < affinity->num_core_siblings; i++) {
find_hw_thread_mask(i, hw_thread_mask, affinity);
/*
* If there's at least one available core for this HW
* thread number, stop looking for a core.
*
* diff will always be not empty at least once in this
* loop as the used mask gets reset when
* (set->mask == set->used) before this loop.
*/
cpumask_andnot(diff, hw_thread_mask, &set->used);
if (!cpumask_empty(diff)) break;
}
}
hfi1_cdbg(PROC, "Same available HW thread on all physical CPUs: %*pbl", cpumask_pr_args(hw_thread_mask));
node_mask = cpumask_of_node(node);
hfi1_cdbg(PROC, "Device on NUMA %u, CPUs %*pbl", node, cpumask_pr_args(node_mask));
/* Get cpumask of available CPUs on preferred NUMA */
cpumask_and(available_mask, hw_thread_mask, node_mask);
cpumask_andnot(available_mask, available_mask, &set->used);
hfi1_cdbg(PROC, "Available CPUs on NUMA %u: %*pbl", node, cpumask_pr_args(available_mask));
/*
* At first, we don't want to place processes on the same
* CPUs as interrupt handlers. Then, CPUs running interrupt
* handlers are used.
*
* 1) If diff is not empty, then there are CPUs not running
* non-interrupt handlers available, so diff gets copied
* over to available_mask.
* 2) If diff is empty, then all CPUs not running interrupt
* handlers are taken, so available_mask contains all
* available CPUs running interrupt handlers.
* 3) If available_mask is empty, then all CPUs on the
* preferred NUMA node are taken, so other NUMA nodes are
* used for process assignments using the same method as
* the preferred NUMA node.
*/
cpumask_andnot(diff, available_mask, intrs_mask);
if (!cpumask_empty(diff)) cpumask_copy(available_mask, diff);
/* If we don't have CPUs on the preferred node, use other NUMA nodes */
if (cpumask_empty(available_mask)) {
cpumask_andnot(available_mask, hw_thread_mask, &set->used);
/* Excluding preferred NUMA cores */
cpumask_andnot(available_mask, available_mask, node_mask);
hfi1_cdbg(PROC, "Preferred NUMA node cores are taken, cores available in other NUMA nodes: %*pbl", cpumask_pr_args(available_mask));
/*
* At first, we don't want to place processes on the same
* CPUs as interrupt handlers.
*/
cpumask_andnot(diff, available_mask, intrs_mask);
if (!cpumask_empty(diff)) cpumask_copy(available_mask, diff);
}
hfi1_cdbg(PROC, "Possible CPUs for process: %*pbl", cpumask_pr_args(available_mask));
cpu = cpumask_first(available_mask);
if (cpu >= nr_cpu_ids) /* empty */
cpu = -1;
else
cpumask_set_cpu(cpu, &set->used);
mutex_unlock(&affinity->lock);
hfi1_cdbg(PROC, "Process assigned to CPU %d", cpu);
free_cpumask_var(intrs_mask);
free_available_mask:
free_cpumask_var(available_mask);
free_hw_thread_mask:
free_cpumask_var(hw_thread_mask);
free_diff:
free_cpumask_var(diff);
done:
return cpu;
}<sep>@@
expression current;
@@
- tsk_cpus_allowed(current)
+ ¤t->cpus_allowed
<|end_of_text|>
| 9,079 |
--- initial
+++ final
@@ -1,7 +1,7 @@
static struct rq *__migrate_task(struct rq *rq, struct task_struct *p, int dest_cpu) {
if (unlikely(!cpu_active(dest_cpu))) return rq;
/* Affinity changed (again). */
- if (!cpumask_test_cpu(dest_cpu, tsk_cpus_allowed(p))) return rq;
+ if (!cpumask_test_cpu(dest_cpu, &p->cpus_allowed)) return rq;
rq = move_queued_task(rq, p, dest_cpu);
return rq;
}<sep>@@
expression current;
@@
- tsk_cpus_allowed(current)
+ ¤t->cpus_allowed
<|end_of_text|>
| 9,080 |
--- initial
+++ final
@@ -1,22 +1,22 @@
int migrate_swap(struct task_struct *cur, struct task_struct *p) {
struct migration_swap_arg arg;
int ret = -EINVAL;
arg = (struct migration_swap_arg){
.src_task = cur,
.src_cpu = task_cpu(cur),
.dst_task = p,
.dst_cpu = task_cpu(p),
};
if (arg.src_cpu == arg.dst_cpu) goto out;
/*
* These three tests are all lockless; this is OK since all of them
* will be re-checked with proper locks held further down the line.
*/
if (!cpu_active(arg.src_cpu) || !cpu_active(arg.dst_cpu)) goto out;
- if (!cpumask_test_cpu(arg.dst_cpu, tsk_cpus_allowed(arg.src_task))) goto out;
- if (!cpumask_test_cpu(arg.src_cpu, tsk_cpus_allowed(arg.dst_task))) goto out;
+ if (!cpumask_test_cpu(arg.dst_cpu, &arg.src_task->cpus_allowed)) goto out;
+ if (!cpumask_test_cpu(arg.src_cpu, &arg.dst_task->cpus_allowed)) goto out;
trace_sched_swap_numa(cur, arg.src_cpu, p, arg.dst_cpu);
ret = stop_two_cpus(arg.dst_cpu, arg.src_cpu, migrate_swap_stop, &arg);
out:
return ret;
}<sep>@@
expression current;
@@
- tsk_cpus_allowed(current)
+ ¤t->cpus_allowed
<|end_of_text|>
| 9,081 |
--- initial
+++ final
@@ -1,22 +1,22 @@
static int migrate_swap_stop(void *data) {
struct migration_swap_arg *arg = data;
struct rq *src_rq, *dst_rq;
int ret = -EAGAIN;
if (!cpu_active(arg->src_cpu) || !cpu_active(arg->dst_cpu)) return -EAGAIN;
src_rq = cpu_rq(arg->src_cpu);
dst_rq = cpu_rq(arg->dst_cpu);
double_raw_lock(&arg->src_task->pi_lock, &arg->dst_task->pi_lock);
double_rq_lock(src_rq, dst_rq);
if (task_cpu(arg->dst_task) != arg->dst_cpu) goto unlock;
if (task_cpu(arg->src_task) != arg->src_cpu) goto unlock;
- if (!cpumask_test_cpu(arg->dst_cpu, tsk_cpus_allowed(arg->src_task))) goto unlock;
- if (!cpumask_test_cpu(arg->src_cpu, tsk_cpus_allowed(arg->dst_task))) goto unlock;
+ if (!cpumask_test_cpu(arg->dst_cpu, &arg->src_task->cpus_allowed)) goto unlock;
+ if (!cpumask_test_cpu(arg->src_cpu, &arg->dst_task->cpus_allowed)) goto unlock;
__migrate_swap_task(arg->src_task, arg->dst_cpu);
__migrate_swap_task(arg->dst_task, arg->src_cpu);
ret = 0;
unlock:
double_rq_unlock(src_rq, dst_rq);
raw_spin_unlock(&arg->dst_task->pi_lock);
raw_spin_unlock(&arg->src_task->pi_lock);
return ret;
}<sep>@@
expression current;
@@
- tsk_cpus_allowed(current)
+ ¤t->cpus_allowed
<|end_of_text|>
| 9,082 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.