Lines Matching refs:c2dev
306 struct c2port_device *c2dev = dev_get_drvdata(dev); in c2port_show_name() local
308 return sprintf(buf, "%s\n", c2dev->name); in c2port_show_name()
315 struct c2port_device *c2dev = dev_get_drvdata(dev); in c2port_show_flash_blocks_num() local
316 struct c2port_ops *ops = c2dev->ops; in c2port_show_flash_blocks_num()
325 struct c2port_device *c2dev = dev_get_drvdata(dev); in c2port_show_flash_block_size() local
326 struct c2port_ops *ops = c2dev->ops; in c2port_show_flash_block_size()
335 struct c2port_device *c2dev = dev_get_drvdata(dev); in c2port_show_flash_size() local
336 struct c2port_ops *ops = c2dev->ops; in c2port_show_flash_size()
345 struct c2port_device *c2dev = dev_get_drvdata(dev); in access_show() local
347 return sprintf(buf, "%d\n", c2dev->access); in access_show()
353 struct c2port_device *c2dev = dev_get_drvdata(dev); in access_store() local
354 struct c2port_ops *ops = c2dev->ops; in access_store()
361 mutex_lock(&c2dev->mutex); in access_store()
363 c2dev->access = !!status; in access_store()
367 if (c2dev->access) in access_store()
368 ops->c2ck_set(c2dev, 1); in access_store()
369 ops->access(c2dev, c2dev->access); in access_store()
370 if (c2dev->access) in access_store()
371 ops->c2d_dir(c2dev, 1); in access_store()
373 mutex_unlock(&c2dev->mutex); in access_store()
383 struct c2port_device *c2dev = dev_get_drvdata(dev); in c2port_store_reset() local
386 if (!c2dev->access) in c2port_store_reset()
389 mutex_lock(&c2dev->mutex); in c2port_store_reset()
391 c2port_reset(c2dev); in c2port_store_reset()
392 c2dev->flash_access = 0; in c2port_store_reset()
394 mutex_unlock(&c2dev->mutex); in c2port_store_reset()
419 struct c2port_device *c2dev = dev_get_drvdata(dev); in c2port_show_dev_id() local
423 if (!c2dev->access) in c2port_show_dev_id()
426 mutex_lock(&c2dev->mutex); in c2port_show_dev_id()
427 ret = __c2port_show_dev_id(c2dev, buf); in c2port_show_dev_id()
428 mutex_unlock(&c2dev->mutex); in c2port_show_dev_id()
431 dev_err(dev, "cannot read from %s\n", c2dev->name); in c2port_show_dev_id()
456 struct c2port_device *c2dev = dev_get_drvdata(dev); in c2port_show_rev_id() local
460 if (!c2dev->access) in c2port_show_rev_id()
463 mutex_lock(&c2dev->mutex); in c2port_show_rev_id()
464 ret = __c2port_show_rev_id(c2dev, buf); in c2port_show_rev_id()
465 mutex_unlock(&c2dev->mutex); in c2port_show_rev_id()
468 dev_err(c2dev->dev, "cannot read from %s\n", c2dev->name); in c2port_show_rev_id()
477 struct c2port_device *c2dev = dev_get_drvdata(dev); in c2port_show_flash_access() local
479 return sprintf(buf, "%d\n", c2dev->flash_access); in c2port_show_flash_access()
522 struct c2port_device *c2dev = dev_get_drvdata(dev); in c2port_store_flash_access() local
530 mutex_lock(&c2dev->mutex); in c2port_store_flash_access()
531 ret = __c2port_store_flash_access(c2dev, status); in c2port_store_flash_access()
532 mutex_unlock(&c2dev->mutex); in c2port_store_flash_access()
535 dev_err(c2dev->dev, "cannot enable %s flash programming\n", in c2port_store_flash_access()
536 c2dev->name); in c2port_store_flash_access()
606 struct c2port_device *c2dev = dev_get_drvdata(dev); in c2port_store_flash_erase() local
610 if (!c2dev->access || !c2dev->flash_access) in c2port_store_flash_erase()
613 mutex_lock(&c2dev->mutex); in c2port_store_flash_erase()
614 ret = __c2port_write_flash_erase(c2dev); in c2port_store_flash_erase()
615 mutex_unlock(&c2dev->mutex); in c2port_store_flash_erase()
618 dev_err(c2dev->dev, "cannot erase %s flash\n", c2dev->name); in c2port_store_flash_erase()
720 struct c2port_device *c2dev = dev_get_drvdata(kobj_to_dev(kobj)); in c2port_read_flash_data() local
724 if (!c2dev->access || !c2dev->flash_access) in c2port_read_flash_data()
727 mutex_lock(&c2dev->mutex); in c2port_read_flash_data()
728 ret = __c2port_read_flash_data(c2dev, buffer, offset, count); in c2port_read_flash_data()
729 mutex_unlock(&c2dev->mutex); in c2port_read_flash_data()
732 dev_err(c2dev->dev, "cannot read %s flash\n", c2dev->name); in c2port_read_flash_data()
835 struct c2port_device *c2dev = dev_get_drvdata(kobj_to_dev(kobj)); in c2port_write_flash_data() local
839 if (!c2dev->access || !c2dev->flash_access) in c2port_write_flash_data()
842 mutex_lock(&c2dev->mutex); in c2port_write_flash_data()
843 ret = __c2port_write_flash_data(c2dev, buffer, offset, count); in c2port_write_flash_data()
844 mutex_unlock(&c2dev->mutex); in c2port_write_flash_data()
847 dev_err(c2dev->dev, "cannot write %s flash\n", c2dev->name); in c2port_write_flash_data()
894 struct c2port_device *c2dev; in c2port_device_register() local
902 c2dev = kzalloc(sizeof(struct c2port_device), GFP_KERNEL); in c2port_device_register()
903 if (unlikely(!c2dev)) in c2port_device_register()
908 ret = idr_alloc(&c2port_idr, c2dev, 0, 0, GFP_NOWAIT); in c2port_device_register()
914 c2dev->id = ret; in c2port_device_register()
918 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev, in c2port_device_register()
919 "c2port%d", c2dev->id); in c2port_device_register()
920 if (IS_ERR(c2dev->dev)) { in c2port_device_register()
921 ret = PTR_ERR(c2dev->dev); in c2port_device_register()
924 dev_set_drvdata(c2dev->dev, c2dev); in c2port_device_register()
926 strscpy(c2dev->name, name, sizeof(c2dev->name)); in c2port_device_register()
927 c2dev->ops = ops; in c2port_device_register()
928 mutex_init(&c2dev->mutex); in c2port_device_register()
931 c2dev->access = c2dev->flash_access = 0; in c2port_device_register()
932 ops->access(c2dev, 0); in c2port_device_register()
934 dev_info(c2dev->dev, "C2 port %s added\n", name); in c2port_device_register()
935 dev_info(c2dev->dev, "%s flash has %d blocks x %d bytes " in c2port_device_register()
940 return c2dev; in c2port_device_register()
944 idr_remove(&c2port_idr, c2dev->id); in c2port_device_register()
948 kfree(c2dev); in c2port_device_register()
954 void c2port_device_unregister(struct c2port_device *c2dev) in c2port_device_unregister() argument
956 if (!c2dev) in c2port_device_unregister()
959 dev_info(c2dev->dev, "C2 port %s removed\n", c2dev->name); in c2port_device_unregister()
962 idr_remove(&c2port_idr, c2dev->id); in c2port_device_unregister()
965 device_destroy(c2port_class, c2dev->id); in c2port_device_unregister()
967 kfree(c2dev); in c2port_device_unregister()